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
a3e2ab44
There was an error fetching the commit references. Please try again later.
Verified
Commit
a3e2ab44
authored
4 years ago
by
David Procházka
Browse files
Options
Downloads
Patches
Plain Diff
ADD: distance measure in BuildTree, insert type as BuildTree parameter
parent
10bdf184
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/mhtree/BuildTree.java
+15
-12
15 additions, 12 deletions
src/mhtree/BuildTree.java
with
15 additions
and
12 deletions
src/mhtree/BuildTree.java
+
15
−
12
View file @
a3e2ab44
...
@@ -3,7 +3,6 @@ package mhtree;
...
@@ -3,7 +3,6 @@ package mhtree;
import
cz.muni.fi.disa.similarityoperators.cover.AbstractRepresentation.PrecomputedDistances
;
import
cz.muni.fi.disa.similarityoperators.cover.AbstractRepresentation.PrecomputedDistances
;
import
messif.buckets.BucketDispatcher
;
import
messif.buckets.BucketDispatcher
;
import
messif.buckets.BucketStorageException
;
import
messif.buckets.BucketStorageException
;
import
messif.buckets.LocalBucket
;
import
messif.objects.LocalAbstractObject
;
import
messif.objects.LocalAbstractObject
;
import
java.util.*
;
import
java.util.*
;
...
@@ -22,11 +21,13 @@ class BuildTree {
...
@@ -22,11 +21,13 @@ class BuildTree {
private
final
PrecomputedDistances
objectDistances
;
private
final
PrecomputedDistances
objectDistances
;
private
final
float
[][]
nodeDistances
;
private
final
float
[][]
nodeDistances
;
private
final
InsertType
insertType
;
private
final
DistanceMeasure
distanceMeasure
;
private
final
BucketDispatcher
bucketDispatcher
;
private
final
BucketDispatcher
bucketDispatcher
;
private
Node
root
;
private
Node
root
;
BuildTree
(
List
<
LocalAbstractObject
>
objects
,
int
leafCapacity
,
int
arity
,
InsertType
insertType
,
BucketDispatcher
bucketDispatcher
)
throws
BucketStorageException
{
BuildTree
(
List
<
LocalAbstractObject
>
objects
,
int
leafCapacity
,
int
arity
,
InsertType
insertType
,
DistanceMeasure
distanceMeasure
,
BucketDispatcher
bucketDispatcher
)
throws
BucketStorageException
{
this
.
arity
=
arity
;
this
.
arity
=
arity
;
this
.
leafCapacity
=
leafCapacity
;
this
.
leafCapacity
=
leafCapacity
;
...
@@ -38,17 +39,19 @@ class BuildTree {
...
@@ -38,17 +39,19 @@ class BuildTree {
objectDistances
=
new
PrecomputedDistances
(
objects
);
objectDistances
=
new
PrecomputedDistances
(
objects
);
nodeDistances
=
new
float
[
nodes
.
length
][
nodes
.
length
];
nodeDistances
=
new
float
[
nodes
.
length
][
nodes
.
length
];
this
.
insertType
=
insertType
;
this
.
distanceMeasure
=
distanceMeasure
;
this
.
bucketDispatcher
=
bucketDispatcher
;
this
.
bucketDispatcher
=
bucketDispatcher
;
buildTree
(
insertType
);
buildTree
();
}
}
public
Node
getRoot
()
{
public
Node
getRoot
()
{
return
root
;
return
root
;
}
}
private
void
buildTree
(
InsertType
insertType
)
throws
BucketStorageException
{
private
void
buildTree
()
throws
BucketStorageException
{
if
(!
initHullPoints
(
insertType
))
return
;
if
(!
initHullPoints
())
return
;
precomputeHullDistances
();
precomputeHullDistances
();
...
@@ -62,7 +65,7 @@ class BuildTree {
...
@@ -62,7 +65,7 @@ class BuildTree {
notProcessedIndices
.
stream
().
forEach
(
restOfTheIndices:
:
add
);
notProcessedIndices
.
stream
().
forEach
(
restOfTheIndices:
:
add
);
int
mainIndex
=
restOfTheIndices
.
remove
(
0
);
int
mainIndex
=
restOfTheIndices
.
remove
(
0
);
mergeHulls
(
mainIndex
,
restOfTheIndices
,
insertType
);
mergeHulls
(
mainIndex
,
restOfTheIndices
);
break
;
break
;
}
}
...
@@ -78,16 +81,16 @@ class BuildTree {
...
@@ -78,16 +81,16 @@ class BuildTree {
nnIndices
.
add
(
index
);
nnIndices
.
add
(
index
);
}
}
mergeHulls
(
furthestNodeIndex
,
nnIndices
,
insertType
);
mergeHulls
(
furthestNodeIndex
,
nnIndices
);
}
}
}
}
root
=
nodes
[
validNodeIndices
.
nextSetBit
(
0
)];
root
=
nodes
[
validNodeIndices
.
nextSetBit
(
0
)];
}
}
private
boolean
initHullPoints
(
InsertType
insertType
)
throws
BucketStorageException
{
private
boolean
initHullPoints
()
throws
BucketStorageException
{
if
(
objectDistances
.
getObjectCount
()
<
leafCapacity
)
{
if
(
objectDistances
.
getObjectCount
()
<
leafCapacity
)
{
root
=
new
LeafNode
(
objectDistances
,
bucketDispatcher
.
createBucket
(),
insertType
);
root
=
new
LeafNode
(
objectDistances
,
bucketDispatcher
.
createBucket
(),
insertType
,
distanceMeasure
);
return
false
;
return
false
;
}
}
...
@@ -111,7 +114,7 @@ class BuildTree {
...
@@ -111,7 +114,7 @@ class BuildTree {
// Select the rest of the objects up to the total of leafCapacity
// Select the rest of the objects up to the total of leafCapacity
objects
.
addAll
(
findClosestObjects
(
furthestIndex
,
leafCapacity
-
1
,
notProcessedObjectIndices
));
objects
.
addAll
(
findClosestObjects
(
furthestIndex
,
leafCapacity
-
1
,
notProcessedObjectIndices
));
nodes
[
nodeIndex
]
=
new
LeafNode
(
objectDistances
.
getSubset
(
objects
),
bucketDispatcher
.
createBucket
(),
insertType
);
nodes
[
nodeIndex
]
=
new
LeafNode
(
objectDistances
.
getSubset
(
objects
),
bucketDispatcher
.
createBucket
(),
insertType
,
distanceMeasure
);
}
}
return
true
;
return
true
;
...
@@ -192,7 +195,7 @@ class BuildTree {
...
@@ -192,7 +195,7 @@ class BuildTree {
}
}
}
}
private
void
mergeHulls
(
int
mainHullIndex
,
List
<
Integer
>
otherHullIndices
,
InsertType
insertType
)
{
private
void
mergeHulls
(
int
mainHullIndex
,
List
<
Integer
>
otherHullIndices
)
{
if
(
otherHullIndices
.
size
()
==
0
)
return
;
if
(
otherHullIndices
.
size
()
==
0
)
return
;
List
<
Integer
>
indices
=
new
ArrayList
<>(
otherHullIndices
);
List
<
Integer
>
indices
=
new
ArrayList
<>(
otherHullIndices
);
...
@@ -200,7 +203,7 @@ class BuildTree {
...
@@ -200,7 +203,7 @@ class BuildTree {
List
<
Node
>
nodes
=
indices
.
stream
().
map
(
i
->
this
.
nodes
[
i
]).
collect
(
Collectors
.
toList
());
List
<
Node
>
nodes
=
indices
.
stream
().
map
(
i
->
this
.
nodes
[
i
]).
collect
(
Collectors
.
toList
());
InternalNode
parent
=
Node
.
createParent
(
nodes
,
objectDistances
,
insertType
);
InternalNode
parent
=
Node
.
createParent
(
nodes
,
objectDistances
,
insertType
,
distanceMeasure
);
nodes
.
forEach
(
node
->
node
.
setParent
(
parent
));
nodes
.
forEach
(
node
->
node
.
setParent
(
parent
));
parent
.
addChildren
(
nodes
);
parent
.
addChildren
(
nodes
);
...
...
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