Search in sources :

Example 1 with ICCEdges

use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.datastructure.ICCEdges in project clusterMaker2 by RBVI.

the class ConnectedComponent method reduceCC.

private boolean reduceCC(ConnectedComponent cc, float clusteringScore2) {
    FixedParameterTreeNode fptn = initFirstTreeNode(cc, clusteringScore2);
    if (fptn.size == cc.getNodeNumber())
        return false;
    ICCEdges ccedges = TaskConfig.ccEdgesEnum.createCCEdges(fptn.size);
    for (int i = 0; i < fptn.size; i++) {
        for (int j = i + 1; j < fptn.size; j++) {
            ccedges.setEdgeCost(i, j, fptn.edgeCosts[i][j]);
        }
    }
    String[] objectIds = new String[fptn.size];
    for (int i = 0; i < objectIds.length; i++) {
        String id = "";
        for (int j = 0; j < fptn.clusters[i].length; j++) {
            if (fptn.clusters[i][j]) {
                id += cc.getObjectID(j) + ";";
            }
        }
        objectIds[i] = id;
    }
    cc.setNodeNumber(fptn.size);
    cc.setCCEdges(ccedges);
    cc.setObjectIDs(objectIds);
    cc.setClusters(new int[fptn.size]);
    cc.setReductionCost(fptn.costs);
    return true;
}
Also used : FixedParameterTreeNode(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.fixedparameterclustering.FixedParameterTreeNode)

Example 2 with ICCEdges

use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.datastructure.ICCEdges in project clusterMaker2 by RBVI.

the class PP_RearrangeAndMergeBest method mergeBest.

protected void mergeBest(ArrayList<ArrayList<Integer>> clusterObject) throws InvalidInputFileException {
    // System.out.println("start merging");
    ICCEdges cc2d = TaskConfig.ccEdgesEnum.createCCEdges(clusterObject.size());
    String[] ids = new String[clusterObject.size()];
    for (int i = 0; i < ids.length; i++) {
        ids[i] = i + "";
        for (int j = i + 1; j < ids.length; j++) {
            cc2d.setEdgeCost(i, j, -(float) calculateCostChange(clusterObject.get(i), clusterObject.get(j)));
        // System.out.println(i + "\t" + j + "\t" + cc2d.getEdgeCost(i, j));
        }
    }
    ConnectedComponent cc2 = new ConnectedComponent(cc2d, ids, null, false);
    ClusteringManager cm = new ClusteringManager(null);
    // cm.runClusteringForOneConnectedComponent(cc2, null, null, null, System.currentTimeMillis());
    new GreedyClusterer(cc2);
    // long dummy = TaskConfig.fpMaxTimeMillis;
    // TaskConfig.fpMaxTimeMillis = Long.MAX_VALUE;
    // FixedParameterClusterer dc = new FixedParameterClusterer(cc2,cc2.getClusteringScore());
    // TaskConfig.fpMaxTimeMillis = dummy;
    // if(cc2.getClusteringScore() != this.bestScore){
    // PP_DivideAndRecluster pp = new PP_DivideAndRecluster();
    // pp.initPostProcessing(cc2);
    // pp.run();
    // }
    ArrayList<ArrayList<Integer>> clusterObjectNew = new ArrayList<ArrayList<Integer>>();
    for (int i = 0; i < cc2.getNumberOfClusters(); i++) {
        ArrayList<Integer> v = new ArrayList<Integer>();
        clusterObjectNew.add(v);
    }
    int[] clustering = cc2.getClusters();
    for (int i = 0; i < clustering.length; i++) {
        clusterObjectNew.get(clustering[i]).addAll(clusterObject.get(i));
    }
    clusterObject = clusterObjectNew;
    this.bestScore = cc2.calculateClusteringScore(clustering);
// System.out.println("end merging");
}
Also used : ClusteringManager(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.taskmanaging.ClusteringManager) GreedyClusterer(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.greedy.GreedyClusterer) ConnectedComponent(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.datastructure.ConnectedComponent) ArrayList(java.util.ArrayList) ICCEdges(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.datastructure.ICCEdges)

Example 3 with ICCEdges

use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.datastructure.ICCEdges in project clusterMaker2 by RBVI.

the class GreedyClusterer method generateSortedList.

private void generateSortedList(boolean[] already2) {
    ICCEdges icce = this.cc.getCCEdges();
    double[] costs = new double[cc.getNodeNumber()];
    for (int i = 0; i < cc.getNodeNumber(); i++) {
        if (already2[i]) {
            costs[i] = Double.POSITIVE_INFINITY;
            continue;
        }
        double cost = 0;
        for (int j = 0; j < cc.getNodeNumber(); j++) {
            if (i == j)
                continue;
            if (already2[j])
                continue;
            cost += icce.getEdgeCost(i, j);
        }
        costs[i] = cost;
    }
    double[] costsClone = Arrays.copyOf(costs, costs.length);
    Arrays.sort(costs);
    boolean[] already = new boolean[costs.length];
    for (int i = costs.length - 1; i >= 0; i--) {
        int position = 0;
        for (int j = 0; j < costsClone.length; j++) {
            if (costs[i] != costsClone[j] || already[j])
                continue;
            position = j;
            already[j] = true;
            break;
        }
        this.listOfElementsSortedByCosts[costs.length - 1 - i] = position;
    }
}
Also used : ICCEdges(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.datastructure.ICCEdges)

Example 4 with ICCEdges

use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.datastructure.ICCEdges in project clusterMaker2 by RBVI.

the class GreedyClusterer method generateSortedList.

private void generateSortedList() {
    ICCEdges icce = this.cc.getCCEdges();
    double[] costs = new double[cc.getNodeNumber()];
    for (int i = 0; i < cc.getNodeNumber(); i++) {
        double cost = 0;
        for (int j = 0; j < cc.getNodeNumber(); j++) {
            if (i == j)
                continue;
            cost += icce.getEdgeCost(i, j);
        }
        costs[i] = cost;
    }
    double[] costsClone = Arrays.copyOf(costs, costs.length);
    Arrays.sort(costs);
    boolean[] already = new boolean[costs.length];
    for (int i = costs.length - 1; i >= 0; i--) {
        int position = 0;
        for (int j = 0; j < costsClone.length; j++) {
            if (costs[i] != costsClone[j] || already[j])
                continue;
            position = j;
            already[j] = true;
            break;
        }
        this.listOfElementsSortedByCosts[costs.length - 1 - i] = position;
    }
}
Also used : ICCEdges(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.datastructure.ICCEdges)

Example 5 with ICCEdges

use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.datastructure.ICCEdges in project clusterMaker2 by RBVI.

the class CopyOfGreedyClusterer method generateSortedList.

private void generateSortedList() {
    ICCEdges icce = this.cc.getCCEdges();
    double[] costs = new double[cc.getNodeNumber()];
    for (int i = 0; i < cc.getNodeNumber(); i++) {
        double cost = 0;
        for (int j = 0; j < cc.getNodeNumber(); j++) {
            if (i == j)
                continue;
            cost += icce.getEdgeCost(i, j);
        }
        costs[i] = cost;
    }
    double[] costsClone = Arrays.copyOf(costs, costs.length);
    Arrays.sort(costs);
    boolean[] already = new boolean[costs.length];
    for (int i = costs.length - 1; i >= 0; i--) {
        int position = 0;
        for (int j = 0; j < costsClone.length; j++) {
            if (costs[i] != costsClone[j] || already[j])
                continue;
            position = j;
            already[j] = true;
            break;
        }
        this.listOfElementsSortedByCosts[costs.length - 1 - i] = position;
    }
}
Also used : ICCEdges(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.datastructure.ICCEdges)

Aggregations

ICCEdges (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.datastructure.ICCEdges)9 ConnectedComponent (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.datastructure.ConnectedComponent)4 ClusteringManager (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.taskmanaging.ClusteringManager)4 ArrayList (java.util.ArrayList)4 Hashtable (java.util.Hashtable)3 Random (java.util.Random)3 Vector (java.util.Vector)3 Semaphore (java.util.concurrent.Semaphore)3 ArgsParseException (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.costmatrixcreation.main.ArgsParseException)1 FixedParameterTreeNode (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.fixedparameterclustering.FixedParameterTreeNode)1 GreedyClusterer (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.greedy.GreedyClusterer)1 InvalidInputFileException (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.taskmanaging.InvalidInputFileException)1 InvalidTypeException (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.taskmanaging.InvalidTypeException)1 BufferedReader (java.io.BufferedReader)1 BufferedWriter (java.io.BufferedWriter)1 FileReader (java.io.FileReader)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1