Search in sources :

Example 1 with IPostProcessing

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

the class ConnectedComponent method buildReducedCC.

private boolean buildReducedCC() {
    ConnectedComponent ccCopy = this.copy();
    new GreedyClusterer(ccCopy);
    IPostProcessing pp = PostProcessingFactory.EnumPostProcessingClass.PP_REARRANGE_AND_MERGE_BEST.createPostProcessor();
    pp.initPostProcessing(ccCopy);
    /* run post processing */
    pp.run();
    ConnectedComponent ccCopy2 = this.copy();
    ccCopy2.setClusteringScore(Double.MAX_VALUE);
    if (ccCopy.getClusteringScore() < ccCopy2.getClusteringScore()) {
        boolean isChanged = reduceCC(ccCopy, (float) (Math.rint(ccCopy.getClusteringScore() * 1000) + 1) / 1000);
        if (isChanged) {
            this.reducedConnectedComponent = ccCopy;
            if (ccCopy.buildReducedCC()) {
                this.reducedConnectedComponent = ccCopy.reducedConnectedComponent;
            }
        }
        return isChanged;
    } else {
        boolean isChanged = reduceCC(ccCopy2, (float) (Math.rint(ccCopy2.getClusteringScore() * 1000) + 1) / 1000);
        if (isChanged) {
            this.reducedConnectedComponent = ccCopy2;
            if (ccCopy2.buildReducedCC()) {
                this.reducedConnectedComponent = ccCopy2.reducedConnectedComponent;
            }
        }
        return isChanged;
    }
}
Also used : GreedyClusterer(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.greedy.GreedyClusterer) IPostProcessing(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.postprocessing.IPostProcessing)

Example 2 with IPostProcessing

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

the class ClusterPostProcessingTask method runClustering.

private void runClustering(ConnectedComponent cc) {
    ConnectedComponent ccCopy = cc.copy(true);
    // ccCopy.setClusteringScore(Double.MAX_VALUE);
    new GreedyClusterer(ccCopy);
    if (!TaskConfig.fixedParameter || cc.getNodeNumber() >= TaskConfig.fixedParameterMax)
        TaskConfig.fpStopped = true;
    if (TaskConfig.fixedParameter && cc.getNodeNumber() < TaskConfig.fixedParameterMax) {
        new FixedParameterClusterer(cc, ccCopy.getClusteringScore());
    }
    if (TaskConfig.greedy && TaskConfig.fpStopped) {
        cc.setClusteringScore(Double.MAX_VALUE);
        TaskConfig.fpStopped = false;
    } else if (TaskConfig.fpStopped) {
        // cc.initialiseClusterInfo(ccCopy.getNumberOfClusters());
        // cc.setClusters(ccCopy.getClusters());
        /* ====== LAYOUTING PHASE ====== */
        TaskConfig.fpStopped = false;
        /* iterate over layouters */
        ILayouter previousLayouter = null;
        for (int i = 0; i < this.layouterEnumTypes.length; i++) {
            IParameters param = this.allparameters[i];
            /* create correct layouter */
            ILayouter layouter = this.layouterEnumTypes[i].createLayouter();
            if (previousLayouter == null) {
                /* initialise cc positions if in clustering mode */
                if (TaskConfig.mode == TaskConfig.CLUSTERING_MODE || TaskConfig.mode == TaskConfig.COMPARISON_MODE || TaskConfig.mode == TaskConfig.HIERARICHAL_MODE) {
                    ILayoutInitialiser li = this.layouterEnumTypes[i].createLayoutInitialiser();
                    li.initLayoutInitialiser(cc);
                    /* initialise and run layouter */
                    layouter.initLayouter(cc, li, param);
                    layouter.run();
                    previousLayouter = layouter;
                } else if (TaskConfig.mode == TaskConfig.GENERAL_TRAINING_MODE) {
                    // else positions already set for training mode
                    layouter.initLayouter(cc, param);
                    layouter.run();
                    previousLayouter = layouter;
                }
            } else {
                /*
					 * initialise and run layouter with previous calculated
					 * positions
					 */
                layouter.initLayouter(cc, previousLayouter, param);
                layouter.run();
            }
        }
        /* ====== GEOMETRIC CLUSTERING */
        IGeometricClusterer geoClust = TaskConfig.geometricClusteringEnum.createGeometricClusterer();
        geoClust.initGeometricClusterer(cc);
        geoClust.run();
    }
    /* ====== POST-PROCESSING ====== */
    if (TaskConfig.doPostProcessing && cc.getClusteringScore() != Double.MAX_VALUE) {
        IPostProcessing pp = PostProcessingFactory.EnumPostProcessingClass.PP_REARRANGE_AND_MERGE_BEST.createPostProcessor();
        pp.initPostProcessing(cc);
        /* run post processing */
        pp.run();
    }
    if (TaskConfig.doPostProcessing && ccCopy.getClusteringScore() != Double.MAX_VALUE) {
        IPostProcessing pp = PostProcessingFactory.EnumPostProcessingClass.PP_REARRANGE_AND_MERGE_BEST.createPostProcessor();
        pp.initPostProcessing(ccCopy);
        /* run post processing */
        pp.run();
    }
    // if(ccCopy.getClusteringScore()<cc.getClusteringScore()&&ccCopy.getClusteringScore()<=ccCopy2.getClusteringScore()){
    if (ccCopy.getClusteringScore() < cc.getClusteringScore()) {
        cc.initialiseClusterInfo(ccCopy.getNumberOfClusters());
        cc.setClusters(ccCopy.getClusters());
        cc.calculateClusterDistribution();
        cc.setClusteringScore(ccCopy.getClusteringScore());
    }
// else if(ccCopy2.getClusteringScore()<cc.getClusteringScore()&&ccCopy.getClusteringScore()>ccCopy2.getClusteringScore()){
// cc.initialiseClusterInfo(ccCopy2.getNumberOfClusters());
// cc.setClusters(ccCopy2.getClusters());
// cc.calculateClusterDistribution();
// cc.setClusteringScore(ccCopy2.getClusteringScore());
// }else{
// }
}
Also used : IParameters(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.layout.IParameters) GreedyClusterer(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.greedy.GreedyClusterer) IGeometricClusterer(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.geometric_clustering.IGeometricClusterer) ConnectedComponent(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.datastructure.ConnectedComponent) ILayouter(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.layout.ILayouter) IPostProcessing(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.postprocessing.IPostProcessing) ILayoutInitialiser(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.layout.ILayoutInitialiser) FixedParameterClusterer(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.fixedparameterclustering.FixedParameterClusterer)

Example 3 with IPostProcessing

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

the class ClusterTrainingTask method runClustering.

private void runClustering(ConnectedComponent cc) {
    /* ====LAYOUTING PHASE ==== */
    ILayouter layouter = layoutEnum.createLayouter();
    layouter.initLayouter(cc, this.parameters);
    layouter.run();
    /* ==== CLUSTERING PHASE ==== */
    IGeometricClusterer geocluster = TaskConfig.geometricClusteringEnum.createGeometricClusterer();
    geocluster.initGeometricClusterer(cc);
    geocluster.run();
    /* ====POST-PROCESSING PHASE ==== */
    if (TaskConfig.doPostProcessing) {
        PostProcessingFactory.EnumPostProcessingClass ppEnum = TaskConfig.postProcessingEnum;
        IPostProcessing pp = ppEnum.createPostProcessor();
        pp.initPostProcessing(cc);
        /* note: training can only be done for one layouter at a time! */
        LayoutFactory.EnumLayouterClass[] layouterTypes = { this.layoutEnum };
        IParameters[] params = { this.parameters };
        if (ppEnum == PostProcessingFactory.EnumPostProcessingClass.PP_DIVIDE_AND_RECLUSTER) {
            ((PP_DivideAndRecluster) pp).setLayoutingInfo(params, layouterTypes);
        } else if (ppEnum == PostProcessingFactory.EnumPostProcessingClass.PP_DIVIDE_AND_RECLUSTER_RECURSIVELY) {
            ((PP_DivideAndReclusterRecursively) pp).setLayoutingInfo(params, layouterTypes);
        }
        pp.run();
    }
}
Also used : IParameters(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.layout.IParameters) IGeometricClusterer(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.geometric_clustering.IGeometricClusterer) ILayouter(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.layout.ILayouter) IPostProcessing(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.postprocessing.IPostProcessing) PostProcessingFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.postprocessing.PostProcessingFactory) PP_DivideAndRecluster(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.postprocessing.PP_DivideAndRecluster)

Example 4 with IPostProcessing

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

the class ClusteringTask method runClustering.

private void runClustering(ConnectedComponent cc) {
    ConnectedComponent ccCopy = cc.copy(true);
    new GreedyClusterer(ccCopy);
    if (!TaskConfig.fixedParameter || cc.getNodeNumber() >= TaskConfig.fixedParameterMax)
        TaskConfig.fpStopped = true;
    if (TaskConfig.fixedParameter && cc.getNodeNumber() < TaskConfig.fixedParameterMax) {
        new FixedParameterClusterer(cc, ccCopy.getClusteringScore());
    }
    if (TaskConfig.greedy && TaskConfig.fpStopped) {
        cc.setClusteringScore(Double.MAX_VALUE);
        TaskConfig.fpStopped = false;
    } else if (TaskConfig.fpStopped) {
        // cc.initialiseClusterInfo(ccCopy.getNumberOfClusters());
        // cc.setClusters(ccCopy.getClusters());
        /* ====== LAYOUTING PHASE ====== */
        TaskConfig.fpStopped = false;
        /* iterate over layouters */
        ILayouter previousLayouter = null;
        for (int i = 0; i < this.layouterEnumTypes.length; i++) {
            IParameters param = parameters[i];
            /* create correct layouter */
            ILayouter layouter = this.layouterEnumTypes[i].createLayouter();
            if (previousLayouter == null) {
                /* initialise cc positions if in clustering mode */
                if (TaskConfig.mode == TaskConfig.CLUSTERING_MODE || TaskConfig.mode == TaskConfig.COMPARISON_MODE || TaskConfig.mode == TaskConfig.HIERARICHAL_MODE) {
                    ILayoutInitialiser li = this.layouterEnumTypes[i].createLayoutInitialiser();
                    li.initLayoutInitialiser(cc);
                    /* initialise and run layouter */
                    layouter.initLayouter(cc, li, param);
                    layouter.run();
                    previousLayouter = layouter;
                } else if (TaskConfig.mode == TaskConfig.GENERAL_TRAINING_MODE) {
                    ILayoutInitialiser li = this.layouterEnumTypes[i].createLayoutInitialiser();
                    li.initLayoutInitialiser(cc);
                    /* initialise and run layouter */
                    layouter.initLayouter(cc, li, param);
                    layouter.run();
                    previousLayouter = layouter;
                // // else positions already set for training mode
                // layouter.initLayouter(cc, param);
                // layouter.run();
                // previousLayouter = layouter;
                } else {
                }
            } else {
                /*
					 * initialise and run layouter with previous calculated
					 * positions
					 */
                layouter.initLayouter(cc, previousLayouter, param);
                layouter.run();
            }
        }
        /* ====== GEOMETRIC CLUSTERING */
        IGeometricClusterer geoClust = TaskConfig.geometricClusteringEnum.createGeometricClusterer();
        geoClust.initGeometricClusterer(cc);
        geoClust.run();
    }
    /* ====== POST-PROCESSING ====== */
    if (TaskConfig.doPostProcessing && cc.getClusteringScore() != Double.MAX_VALUE) {
        PostProcessingFactory.EnumPostProcessingClass ppEnum = TaskConfig.postProcessingEnum;
        IPostProcessing pp = ppEnum.createPostProcessor();
        pp.initPostProcessing(cc);
        // additional parameters.
        if (ppEnum.equals(PostProcessingFactory.EnumPostProcessingClass.PP_DIVIDE_AND_RECLUSTER)) {
            ((PP_DivideAndRecluster) pp).setLayoutingInfo(this.parameters, this.layouterEnumTypes);
        } else if (ppEnum.equals(PostProcessingFactory.EnumPostProcessingClass.PP_DIVIDE_AND_RECLUSTER_RECURSIVELY)) {
            ((PP_DivideAndReclusterRecursively) pp).setLayoutingInfo(this.parameters, this.layouterEnumTypes);
        }
        /* run post processing */
        pp.run();
    // ppEnum = PostProcessingFactory.EnumPostProcessingClass.PP_REARRANGE_AND_MERGE_BEST;
    // pp = ppEnum.createPostProcessor();
    // pp.initPostProcessing(cc);
    // pp.run();
    }
    if (TaskConfig.doPostProcessing && ccCopy.getClusteringScore() != Double.MAX_VALUE) {
        PostProcessingFactory.EnumPostProcessingClass ppEnum = TaskConfig.postProcessingEnum;
        IPostProcessing pp = ppEnum.createPostProcessor();
        pp.initPostProcessing(ccCopy);
        // additional parameters.
        if (ppEnum.equals(PostProcessingFactory.EnumPostProcessingClass.PP_DIVIDE_AND_RECLUSTER)) {
            ((PP_DivideAndRecluster) pp).setLayoutingInfo(this.parameters, this.layouterEnumTypes);
        } else if (ppEnum.equals(PostProcessingFactory.EnumPostProcessingClass.PP_DIVIDE_AND_RECLUSTER_RECURSIVELY)) {
            ((PP_DivideAndReclusterRecursively) pp).setLayoutingInfo(this.parameters, this.layouterEnumTypes);
        }
        /* run post processing */
        pp.run();
    // ppEnum = PostProcessingFactory.EnumPostProcessingClass.PP_REARRANGE_AND_MERGE_BEST;
    // pp = ppEnum.createPostProcessor();
    // pp.initPostProcessing(cc);
    // pp.run();
    }
    // if(ccCopy.getClusteringScore()<cc.getClusteringScore()&&ccCopy.getClusteringScore()<=ccCopy2.getClusteringScore()){
    if (ccCopy.getClusteringScore() < cc.getClusteringScore()) {
        cc.initialiseClusterInfo(ccCopy.getNumberOfClusters());
        cc.setClusters(ccCopy.getClusters());
        cc.calculateClusterDistribution();
        cc.setClusteringScore(ccCopy.getClusteringScore());
    } else // else if(ccCopy2.getClusteringScore()<cc.getClusteringScore()&&ccCopy.getClusteringScore()>ccCopy2.getClusteringScore()){
    // cc.initialiseClusterInfo(ccCopy2.getNumberOfClusters());
    // cc.setClusters(ccCopy2.getClusters());
    // cc.calculateClusterDistribution();
    // cc.setClusteringScore(ccCopy2.getClusteringScore());
    // }
    {
    }
}
Also used : IParameters(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.layout.IParameters) GreedyClusterer(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.greedy.GreedyClusterer) IGeometricClusterer(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.geometric_clustering.IGeometricClusterer) ConnectedComponent(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.datastructure.ConnectedComponent) ILayouter(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.layout.ILayouter) IPostProcessing(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.postprocessing.IPostProcessing) PostProcessingFactory(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.postprocessing.PostProcessingFactory) PP_DivideAndRecluster(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.postprocessing.PP_DivideAndRecluster) ILayoutInitialiser(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.layout.ILayoutInitialiser) FixedParameterClusterer(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.fixedparameterclustering.FixedParameterClusterer)

Aggregations

IPostProcessing (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.postprocessing.IPostProcessing)4 IGeometricClusterer (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.geometric_clustering.IGeometricClusterer)3 GreedyClusterer (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.greedy.GreedyClusterer)3 ILayouter (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.layout.ILayouter)3 IParameters (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.layout.IParameters)3 ConnectedComponent (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.datastructure.ConnectedComponent)2 FixedParameterClusterer (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.fixedparameterclustering.FixedParameterClusterer)2 ILayoutInitialiser (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.layout.ILayoutInitialiser)2 PP_DivideAndRecluster (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.postprocessing.PP_DivideAndRecluster)2 PostProcessingFactory (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.postprocessing.PostProcessingFactory)2