Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MH-Tree
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
disa
public
Hulls
MH-Tree
Commits
dd40600b
There was an error fetching the commit references. Please try again later.
Verified
Commit
dd40600b
authored
3 years ago
by
David Procházka
Browse files
Options
Downloads
Patches
Plain Diff
ADD: M-Tree benchmark logic
parent
9d974aac
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/mhtree/Node.java
+7
-7
7 additions, 7 deletions
src/mhtree/Node.java
src/mhtree/benchmarking/RunBenchmark.java
+73
-3
73 additions, 3 deletions
src/mhtree/benchmarking/RunBenchmark.java
with
80 additions
and
10 deletions
src/mhtree/Node.java
+
7
−
7
View file @
dd40600b
...
...
@@ -18,8 +18,8 @@ public abstract class Node implements Serializable {
*/
private
static
final
long
serialVersionUID
=
420L
;
private
final
InsertType
INSERT_TYPE
;
private
final
ObjectToNodeDistance
OBJECT_TO_NODE_DISTANCE
;
private
final
InsertType
insertType
;
private
final
ObjectToNodeDistance
objectToNodeDistance
;
private
HullOptimizedRepresentationV3
hull
;
...
...
@@ -27,8 +27,8 @@ public abstract class Node implements Serializable {
this
.
hull
=
new
HullOptimizedRepresentationV3
(
distances
);
this
.
hull
.
build
();
this
.
INSERT_TYPE
=
insertType
;
this
.
OBJECT_TO_NODE_DISTANCE
=
objectToNodeDistance
;
this
.
insertType
=
insertType
;
this
.
objectToNodeDistance
=
objectToNodeDistance
;
}
protected
static
InternalNode
createParent
(
List
<
Node
>
nodes
,
PrecomputedDistances
distances
,
InsertType
insertType
,
ObjectToNodeDistance
objectToNodeDistance
,
MergeType
mergeType
)
{
...
...
@@ -70,11 +70,11 @@ public abstract class Node implements Serializable {
}
protected
double
getDistance
(
LocalAbstractObject
object
)
{
return
OBJECT_TO_NODE_DISTANCE
.
getDistance
(
object
,
this
);
return
objectToNodeDistance
.
getDistance
(
object
,
this
);
}
protected
double
getDistance
(
LocalAbstractObject
object
,
PrecomputedDistances
distances
)
{
return
OBJECT_TO_NODE_DISTANCE
.
getDistance
(
object
,
this
,
distances
);
return
objectToNodeDistance
.
getDistance
(
object
,
this
,
distances
);
}
protected
double
getDistanceToNearest
(
LocalAbstractObject
object
)
{
...
...
@@ -100,7 +100,7 @@ public abstract class Node implements Serializable {
protected
void
addObjectIntoHull
(
LocalAbstractObject
object
,
PrecomputedDistances
distances
)
{
if
(
isCovered
(
object
,
distances
))
return
;
if
(
INSERT_TYPE
==
InsertType
.
INCREMENTAL
)
{
if
(
insertType
==
InsertType
.
INCREMENTAL
)
{
hull
.
addHullObject
(
object
);
return
;
}
...
...
This diff is collapsed.
Click to expand it.
src/mhtree/benchmarking/RunBenchmark.java
+
73
−
3
View file @
dd40600b
package
mhtree.benchmarking
;
import
cz.muni.fi.disa.similarityoperators.cover.AbstractRepresentation
;
import
messif.algorithms.AlgorithmMethodException
;
import
messif.buckets.BucketStorageException
;
import
messif.objects.LocalAbstractObject
;
import
messif.objects.impl.ObjectFloatVectorNeuralNetworkL2
;
...
...
@@ -8,6 +9,7 @@ import messif.objects.util.AbstractObjectList;
import
messif.objects.util.RankedAbstractObject
;
import
messif.objects.util.StreamGenericAbstractObjectIterator
;
import
messif.operations.Approximate
;
import
messif.operations.data.BulkInsertOperation
;
import
messif.operations.query.ApproxKNNQueryOperation
;
import
messif.operations.query.KNNQueryOperation
;
import
messif.statistics.Statistics
;
...
...
@@ -15,16 +17,18 @@ import mhtree.InsertType;
import
mhtree.MHTree
;
import
mhtree.MergeType
;
import
mhtree.ObjectToNodeDistance
;
import
mtree.MTree
;
import
java.io.IOException
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
public
class
RunBenchmark
{
public
static
void
main
(
String
[]
args
)
throws
IOException
,
BucketStorageException
{
public
static
void
main
(
String
[]
args
)
throws
IOException
,
AlgorithmMethodException
,
InstantiationException
,
NoSuchMethodException
,
BucketStorageException
{
if
(
args
.
length
!=
5
)
{
throw
new
IllegalArgumentException
(
"Unexpected number of params"
);
}
...
...
@@ -50,7 +54,7 @@ public class RunBenchmark {
break
;
}
percentageToRecall
(
new
MHTreeConfig
(
percentageToRecall
MHTree
(
new
MHTreeConfig
(
leafCapacity
,
nodeDegree
,
insertType
,
...
...
@@ -61,7 +65,7 @@ public class RunBenchmark {
);
}
private
static
void
percentageToRecall
(
MHTreeConfig
config
,
List
<
LocalAbstractObject
>
objects
,
int
[]
ks
)
throws
BucketStorageException
,
RuntimeException
{
private
static
void
percentageToRecall
MHTree
(
MHTreeConfig
config
,
List
<
LocalAbstractObject
>
objects
,
int
[]
ks
)
throws
BucketStorageException
,
RuntimeException
{
MHTree
mTree
=
new
MHTree
.
Builder
(
objects
,
config
.
leafCapacity
,
config
.
nodeDegree
)
.
objectToNodeDistance
(
config
.
objectToNodeDistance
)
.
mergeType
(
MergeType
.
REPRESENTATION_BASED
)
...
...
@@ -145,6 +149,72 @@ public class RunBenchmark {
}
}
private
static
void
percentageToRecallMTree
(
MHTreeConfig
config
,
List
<
LocalAbstractObject
>
objects
,
int
[]
ks
)
throws
NoSuchMethodException
,
AlgorithmMethodException
,
RuntimeException
,
InstantiationException
{
int
numberOfObjects
=
objects
.
size
();
MTree
mTree
=
new
MTree
(
config
.
nodeDegree
,
config
.
leafCapacity
);
Collections
.
shuffle
(
objects
);
BulkInsertOperation
op
=
new
BulkInsertOperation
(
objects
);
mTree
.
insert
(
op
);
mTree
.
printStatistics
();
System
.
out
.
println
(
"leafCapacity,nodeDegree,objectToNodeDistance,k,percentage,recall (min),recall (avg),recall (med),recall (max)"
);
double
minimalRecall
=
0
;
int
percentage
=
0
;
int
percentageStep
=
5
;
for
(
int
k
:
ks
)
{
List
<
Double
>
recalls
=
new
ArrayList
<>(
numberOfObjects
);
for
(
int
i
=
0
;
i
<
numberOfObjects
;
i
++)
{
recalls
.
add
(
0.0
);
}
while
(
minimalRecall
!=
1.0
)
{
for
(
int
i
=
0
;
i
<
numberOfObjects
;
i
++)
{
if
(
recalls
.
get
(
i
)
!=
1.0
)
{
ApproxKNNQueryOperation
operation
=
new
ApproxKNNQueryOperation
(
objects
.
get
(
i
),
k
,
percentage
,
Approximate
.
LocalSearchType
.
PERCENTAGE
,
LocalAbstractObject
.
UNKNOWN_DISTANCE
);
mTree
.
executeOperation
(
operation
);
recalls
.
set
(
i
,
PerformanceMeasures
.
measureRecall
(
operation
,
mTree
));
}
}
Stats
recallStats
=
new
Stats
(
new
ArrayList
<>(
recalls
));
System
.
out
.
println
(
String
.
join
(
","
,
String
.
valueOf
(
config
.
leafCapacity
),
String
.
valueOf
(
config
.
nodeDegree
),
String
.
valueOf
(
config
.
objectToNodeDistance
),
String
.
valueOf
(
k
),
String
.
valueOf
(
percentage
),
String
.
format
(
"%.2f,%.2f,%.2f,%.2f"
,
recallStats
.
getMin
(),
recallStats
.
getAverage
(),
recallStats
.
getMedian
(),
recallStats
.
getMax
())));
minimalRecall
=
recallStats
.
getMin
();
percentage
+=
percentageStep
;
}
minimalRecall
=
0
;
percentage
=
0
;
}
}
private
static
List
<
LocalAbstractObject
>
loadDataset
(
String
path
)
throws
IOException
{
return
new
AbstractObjectList
<>(
new
StreamGenericAbstractObjectIterator
<>(
ObjectFloatVectorNeuralNetworkL2
.
class
,
path
));
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment