Commit ca6fee58 authored by Vlastislav Dohnal's avatar Vlastislav Dohnal
Browse files

* KNN operation fixes the number of objects added (upon refining its answer)

* KMeans pivots chooser and hierarchical chooser
parent ecdedcc7
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -136,6 +136,10 @@ public class MultipleOverlaysAlgorithm extends Algorithm implements NavigationDi
        return algorithms.size();
    }
    
    public Algorithm getAlgorithm(int i) {
        return algorithms.get(i);
    }

    /**
     * Returns all the currently encapsulated algorithms.
     * @return all the currently encapsulated algorithms
+2 −0
Original line number Diff line number Diff line
@@ -100,6 +100,8 @@ public class PrecomputedDistancesFixedArrayFilter extends PrecomputedDistancesFi

    @Override
    protected void writeData(OutputStream stream) throws IOException {
        if (precompDist == null)
            return;
        for (int i = 0; i < precompDist.length; i++) {
            if (i > 0)
                stream.write(' ');
+9 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.NoSuchElementException;
import messif.utility.SortedCollection;

/**
@@ -188,4 +189,12 @@ public class RankedSortedMultiCollection extends RankedSortedCollection implemen
    public int getSublistCount() {
        return sublists.length;
    }

    public float getThresholdDistance(int subListIndex) {
        return sublists[subListIndex].getThresholdDistance();
    }

    public float getLastDistance(int subListIndex) throws NoSuchElementException {
        return sublists[subListIndex].getLastDistance();
    }
}
+2 −2
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ public class ApproxKNNQueryOperation extends KNNQueryOperation implements Approx
     * @param localSearchType type of the local search parameter
     * @param radiusGuaranteed radius within which the answer is required to be guaranteed as correct
     */
    @AbstractOperation.OperationConstructor({"Query object", "Number of nearest objects", "Local search param", "Type of <br/>local search param", "guaranteed radius <br/>(-1 to switch off)"})
    @AbstractOperation.OperationConstructor({"Query object", "Number of nearest objects", "Local search param", "Type of <br/>local search param", "guaranteed radius <br/>(use LocalAbstractObject.UNKNOWN_DISTANCE to switch off)"})
    public ApproxKNNQueryOperation(LocalAbstractObject queryObject, int k, int localSearchParam, LocalSearchType localSearchType, float radiusGuaranteed) {
        super(queryObject, k);
        this.localSearchParam = localSearchParam;
@@ -108,7 +108,7 @@ public class ApproxKNNQueryOperation extends KNNQueryOperation implements Approx
     * @param localSearchType type of the local search parameter
     * @param radiusGuaranteed radius within which the answer is required to be guaranteed as correct
     */
    @AbstractOperation.OperationConstructor({"Query object", "Number of nearest objects", "Answer type", "Local search param", "Type of <br/>local search param", "guaranteed radius <br/>(-1 to switch off)"})
    @AbstractOperation.OperationConstructor({"Query object", "Number of nearest objects", "Answer type", "Local search param", "Type of <br/>local search param", "guaranteed radius <br/>(use LocalAbstractObject.UNKNOWN_DISTANCE to switch off)"})
    public ApproxKNNQueryOperation(LocalAbstractObject queryObject, int k, AnswerType answerType, int localSearchParam, LocalSearchType localSearchType, float radiusGuaranteed) {
        super(queryObject, k, answerType);
        this.localSearchParam = localSearchParam;
+2 −2
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@ public class KMeansPivotChooser extends AbstractPivotChooser {
    }

    public List<AbstractObjectList<LocalAbstractObject>> getClusters() {
        return actualClusters;
        return resultingPartitioning;
    }
    
    /**
@@ -119,7 +119,7 @@ public class KMeansPivotChooser extends AbstractPivotChooser {
            System.err.print("Running "+nIterations+"th iteration of "); 
            System.err.println((useKmeansForCenters) ? "k-means" : "k-medoids");
            // Compute data partitioning and report cluster sizes
            actualClusters = getPartitioning(objectList, pivots, "initial");
            List<AbstractObjectList<LocalAbstractObject>> actualClusters = getPartitioning(objectList, pivots, "initial");
            
            System.err.println("    Selecting clustroids...");
            // now calculate the new pivots for the new clusters
Loading