use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.layout.ILayoutInitialiser 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{
// }
}
use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.layout.ILayoutInitialiser in project clusterMaker2 by RBVI.
the class FORCEnDLayouter method initLayouter.
/**
* This Constructor is for the parameter training. Here the positions should
* have already been initialised. If this is not so, then the positions are
* initialised with the correct {@link ILayoutInitialiser} implementation.
*
* @param cc
* The connected Component.
* @param parameters
* The parameters for FORCEnD.
*/
public void initLayouter(ConnectedComponent cc, IParameters parameters) {
this.dim = TaskConfig.dimension;
this.cc = cc;
this.parameters = (FORCEnDParameters) parameters;
if (cc.getCCPositions() == null) {
log.warning("Positions have not been initialised, perhaps" + "wrong use of this constructor!");
ILayoutInitialiser li;
li = LayoutFactory.EnumLayouterClass.FORCEND.createLayoutInitialiser();
li.initLayoutInitialiser(cc);
li.run();
}
}
use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.layout.ILayoutInitialiser in project clusterMaker2 by RBVI.
the class ParameterTraining_SE method run.
public IParameters run(ConnectedComponent cc) {
boolean terminateTraining = false;
/*
* initialise positions of the cc - the same initial positions are used
* for all training rounds
*/
ILayoutInitialiser li = layouterEnum.createLayoutInitialiser();
li.initLayoutInitialiser(cc);
li.run();
/* run initial generation */
IParameters[] initialGeneration = createInitialParameterGeneration();
runOneGeneration(initialGeneration, cc, 0);
terminateTraining = terminateTraining(initialGeneration);
/* add the best 10 random configs to the bestConfigs collection Vector */
for (int i = 0; i < 10; i++) {
// TODO
this.bestConfigs.add(initialGeneration[i]);
}
// System.out.println("terminate training? "+terminateTraining);
/* run all following generations */
IParameters[] generation;
for (int i = 1; i <= this.noOfGenerations; i++) {
if (terminateTraining) {
break;
}
generation = createParameterGeneration();
runOneGeneration(generation, cc, i);
terminateTraining = terminateTraining(generation);
for (int j = 0; j < this.generationSize / 2; j++) {
this.bestConfigs.add(generation[j]);
}
}
/* convert best configurations vector to array */
IParameters[] bestConfigsArray = new IParameters[bestConfigs.size()];
for (int i = 0; i < bestConfigs.size(); i++) {
bestConfigsArray[i] = bestConfigs.get(i);
}
/*
* sort the IParameters array according to their score and return the
* best parameter set.
*/
Arrays.sort(bestConfigsArray, this.paramComparator);
this.bestPreviousIParameters = bestConfigsArray[0];
bestConfigsArray[0].setScore(0.0);
return bestConfigsArray[0];
}
use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.layout.ILayoutInitialiser 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());
// }
{
}
}
use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.layout.ILayoutInitialiser in project clusterMaker2 by RBVI.
the class GeneralParameterTraining method runGeneralTraining.
/**
* Starts the general parameter training using a simple evolutionary method
* for the whole input directory (or just one file if
* this was given). Saves the best found parameters of each layout algorithm to the
* respective config classes. But does not create a config file.
*
* @return The best set of IParameters as an Array.
* @throws InvalidInputFileException If the input file/directory is somehow
* incorrect or cannot be read.
* @throws InvalidTypeException If an method type does not exist or hasn't
* been included properly.
*/
public IParameters[] runGeneralTraining() throws InvalidInputFileException, InvalidTypeException {
/* initialise connected components and parameters */
this.clusteringManager.initParametersAndCCs();
ArrayList<File> connectedComponents = clusteringManager.getConnectedComponents();
/*
* initialise positions of the cc with respect to the FIRST layouter - the same
* initial positions are used for all training rounds
*/
for (File cc : connectedComponents) {
ILayoutInitialiser li = TaskConfig.layouterEnumTypes[0].createLayoutInitialiser();
li.initLayoutInitialiser(new CostMatrixReader(cc).getConnectedComponent());
li.run();
}
boolean terminateTraining = false;
/* run initial generation */
IParameters[][] initialGeneration = createInitialParameterGeneration();
runOneGeneration(initialGeneration, connectedComponents, 0);
terminateTraining = terminateTraining(initialGeneration);
/* add the best 10 random configs to the bestConfigs collection Vector */
for (int i = 0; i < initialGeneration.length; i++) {
this.bestConfigs.add(initialGeneration[i]);
}
/* run all following generations */
IParameters[][] generation;
for (int i = 1; i <= this.noOfGenerations; i++) {
if (terminateTraining) {
break;
}
generation = createParameterGeneration();
runOneGeneration(generation, connectedComponents, i);
terminateTraining = terminateTraining(generation);
for (int j = 0; j < this.generationSize / 2; j++) {
this.bestConfigs.add(initialGeneration[j]);
}
}
/* convert best configurations vector to array */
IParameters[][] bestConfigsArray = new IParameters[bestConfigs.size()][TaskConfig.layouterEnumTypes.length];
for (int i = 0; i < bestConfigs.size(); i++) {
bestConfigsArray[i] = bestConfigs.get(i);
}
/*
* sort the IParameters array according to their score and return the
* best parameter set.
*/
Arrays.sort(bestConfigsArray, this.paramComparator);
this.bestPreviousIParameters = bestConfigsArray[0];
for (int i = 0; i < bestConfigsArray[0].length; i++) {
bestConfigsArray[0][i].saveParametersToConfig();
}
for (int i = 0; i < 30; i++) {
FORCEnDParameters ip = (FORCEnDParameters) bestConfigsArray[i][0];
ip.printParamters();
}
return bestConfigsArray[0];
}
Aggregations