Search in sources :

Example 1 with ClusterTrainingTask

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

the class ParameterTraining_SE method runOneGeneration.

private void runOneGeneration(IParameters[] generationParameterSet, ConnectedComponent cc, int gen) {
    int size = generationParameterSet.length;
    // List<Semaphore> parallelSem = new ArrayList<Semaphore>();
    for (int i = 0; i < size; i++) {
        /* copy the cc (ConnectedComponent) - shares same resources! */
        ConnectedComponent newCC = cc.copy();
        /* sets a new positions array for the copy */
        newCC.setCCPositions(cc.copyCCPositions());
        /* start clustering */
        ClusterTrainingTask clusteringTask = new ClusterTrainingTask(newCC, generationParameterSet[i], layouterEnum);
        /*check whether threads are being used and do things related to this */
        // if(TaskConfig.useThreads){
        // Semaphore semaphore = new Semaphore(1, true);
        // clusteringTask.setSemaphore(semaphore);
        // parallelSem.add(semaphore);
        // Thread t = new Thread(clusteringTask);
        // clusteringTask.setMaxThreadSemaphore(maxThreadSemaphore, this.allThreads, t);
        // t.start();
        // }else{
        clusteringTask.run();
    // }
    }
/* wait until all threads are done! */
// if (TaskConfig.useThreads) {
// 
// /*
// * For each semaphore it is tested if a permit can be aquired.
// * This forces the main program thread to wait until all threads
// * are finished.
// */
// for (Semaphore sem : parallelSem) {
// sem.acquire();
// }
// }
// 
// } catch (InterruptedException e) {
// /*
// * Exception created by Semaphore.aquire() - if the thread is
// * interrupted
// */
// log.severe(e.getMessage());
// e.printStackTrace();
// }
}
Also used : ConnectedComponent(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.datastructure.ConnectedComponent) ClusterTrainingTask(edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.taskmanaging.ClusterTrainingTask)

Aggregations

ConnectedComponent (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.datastructure.ConnectedComponent)1 ClusterTrainingTask (edu.ucsf.rbvi.clusterMaker2.internal.algorithms.networkClusterers.TransClust.de.layclust.taskmanaging.ClusterTrainingTask)1