Search in sources :

Example 1 with FORCEnDParameters

use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.layout.forcend.FORCEnDParameters 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();
    }
}
Also used : ILayoutInitialiser(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.layout.ILayoutInitialiser)

Example 2 with FORCEnDParameters

use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.layout.forcend.FORCEnDParameters in project clusterMaker2 by RBVI.

the class GeneralParameterTraining method runOneGeneration.

private void runOneGeneration(IParameters[][] parameters, ArrayList<File> connectedComponents, int gen) throws InvalidInputFileException, InvalidTypeException {
    TaskConfig.monitor.setStatusMessage("Start training generation: " + gen);
    int size = parameters.length;
    /* do clustering for each set of parameter configurations */
    for (int i = 0; i < size; i++) {
        /* copy the cc (ConnectedComponent) ArrayList - shares same resources! */
        ArrayList<ConnectedComponent> newConnectedComponents = new ArrayList<ConnectedComponent>(connectedComponents.size());
        // for (int j = 0; j < connectedComponents.size(); j++) {
        // ConnectedComponent cc = new CostMatrixReader(connectedComponents.get(j)).getConnectedComponent();
        // ConnectedComponent newCC = cc.copy();
        /* sets a new positions array for the copy */
        // newCC.setCCPositions(cc.copyCCPositions());
        // newConnectedComponents.add(newCC);
        // }
        /* start clustering */
        clusteringManager.setConnectedComponents(connectedComponents);
        clusteringManager.setLayouterParameters(parameters[i]);
        clusteringManager.runClustering();
        FORCEnDParameters fndparam = (FORCEnDParameters) parameters[i][0];
        fndparam.printParamters();
        newConnectedComponents.clear();
    }
// log.debug("Finished training generation: "+gen);
}
Also used : FORCEnDParameters(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.layout.forcend.FORCEnDParameters) ConnectedComponent(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.datastructure.ConnectedComponent) ArrayList(java.util.ArrayList)

Example 3 with FORCEnDParameters

use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.layout.forcend.FORCEnDParameters in project clusterMaker2 by RBVI.

the class GeneralParameterTraining method createInitialParameterGeneration.

private IParameters[][] createInitialParameterGeneration() {
    // create enough random configurations to start with
    ArrayList<FORCEnDParameters> parameters = new ArrayList<FORCEnDParameters>();
    for (double attraction = 1; attraction <= 100; attraction += 5) {
        // if((attraction*10)<=repulsion||(repulsion*10)<=attraction) continue;
        for (float temperature = 100; temperature <= 1000; temperature += 100) {
            for (int iterations = 50; iterations < 500; iterations += 50) {
                FORCEnDParameters fndparam = new FORCEnDParameters();
                fndparam.setAttractionFactor(attraction);
                fndparam.setRepulsionFactor(attraction);
                fndparam.setTemperature(temperature);
                fndparam.setIterations(iterations);
                parameters.add(fndparam);
            // System.out.println(" iterations " + iterations);
            }
        // System.out.println(" temperature " + temperature);
        }
    // System.out.println(" repulsion " + repulsion);
    // }
    // System.out.println(" attraction " + attraction);
    }
    // int initialSize = this.generationSize + 10;
    IParameters[][] paramsGen = new IParameters[parameters.size()][TaskConfig.layouterEnumTypes.length];
    // }
    for (int i = 0; i < paramsGen.length; i++) {
        paramsGen[i][0] = parameters.get(i);
    }
    return paramsGen;
}
Also used : FORCEnDParameters(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.layout.forcend.FORCEnDParameters) IParameters(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.layout.IParameters) ArrayList(java.util.ArrayList)

Example 4 with FORCEnDParameters

use of edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.layout.forcend.FORCEnDParameters 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];
}
Also used : IParameters(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.layout.IParameters) FORCEnDParameters(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.layout.forcend.FORCEnDParameters) CostMatrixReader(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.datastructure.CostMatrixReader) ILayoutInitialiser(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.layout.ILayoutInitialiser) File(java.io.File)

Aggregations

FORCEnDParameters (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.layout.forcend.FORCEnDParameters)3 ILayoutInitialiser (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.layout.ILayoutInitialiser)2 IParameters (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.layout.IParameters)2 ArrayList (java.util.ArrayList)2 ConnectedComponent (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.datastructure.ConnectedComponent)1 CostMatrixReader (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.datastructure.CostMatrixReader)1 File (java.io.File)1