Skip to content

Commit

Permalink
WIP - new LangevinPostProcessor located in core, here all post proces…
Browse files Browse the repository at this point in the history
…sing happens
  • Loading branch information
danv61 committed Jan 30, 2025
1 parent 947a731 commit 08935a4
Show file tree
Hide file tree
Showing 2 changed files with 152 additions and 32 deletions.
42 changes: 10 additions & 32 deletions vcell-client/src/main/java/cbit/vcell/client/ClientSimManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import cbit.vcell.client.task.AsynchClientTaskFunction;
import cbit.vcell.client.task.ClientTaskDispatcher;
import cbit.vcell.export.server.ExportServiceImpl;
import cbit.vcell.export.server.ExportSpecs;
import cbit.vcell.field.FieldDataIdentifierSpec;
import cbit.vcell.mapping.SimulationContext;
import cbit.vcell.mapping.SimulationContext.NetworkGenerationRequirements;
Expand Down Expand Up @@ -203,45 +204,22 @@ public void showSimulationResults(OutputContext outputContext, Simulation[] simu
*/
public void postProcessLangevinResults(Simulation sim) {

final String FAILURE_KEY = "FAILURE_KEY";
final String SIMULATION_KEY = "SIMULATION_KEY";
SimulationOwner simOwner = getSimWorkspace().getSimulationOwner();

Hashtable<String, Object> hashTable = new Hashtable<String, Object>();
hashTable.put(FAILURE_KEY, false);
hashTable.put(SIMULATION_KEY, sim);
hashTable.put(LangevinPostProcessor.FAILURE_KEY, false);
hashTable.put(LangevinPostProcessor.SIMULATION_KEY, sim);
hashTable.put(LangevinPostProcessor.SIMULATION_OWNER, simOwner);

ArrayList<AsynchClientTask> taskList = new ArrayList<AsynchClientTask>();
AsynchClientTask retrieveLangevinResultsTask = new AsynchClientTask("Retrieving results", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
AsynchClientTask postProcessLangevinResultsTask = new AsynchClientTask("PostProcessLangevinResultsTask", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
boolean failure = (boolean) hashTable.get(FAILURE_KEY);
SolverTaskDescription std = sim.getSolverTaskDescription();
int numTrials = std.getNumTrials();
System.out.println(sim.getName() + ", NumTrials = " + numTrials);
// LangevinSimulationOptions lso = std.getLangevinSimulationOptions();
final VCSimulationIdentifier vcSimulationIdentifier = sim.getSimulationInfo().getAuthoritativeVCSimulationIdentifier();
SimulationOwner simOwner = getSimWorkspace().getSimulationOwner();
Simulation allSims[] = simOwner.getSimulations();
for (Simulation simCandidate : allSims) {
if (simCandidate.getName().startsWith(sim.getName())) {
System.out.println(" --- " + simCandidate.getName() + ", " + simCandidate.getJobCount());
}
}
LangevinPostProcessor lpp = new LangevinPostProcessor();
lpp.postProcessLangevinResults(hashTable);
}
};
AsynchClientTask calculateLangevinAveragesTask = new AsynchClientTask("Retrieving results", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
boolean failure = (boolean)hashTable.get(FAILURE_KEY);

}
};
AsynchClientTask calculateLangevinAdvancedStatisticsTask = new AsynchClientTask("Retrieving results", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
public void run(Hashtable<String, Object> hashTable) throws Exception {
boolean failure = (boolean)hashTable.get(FAILURE_KEY);

}
};
taskList.add(retrieveLangevinResultsTask);
taskList.add(calculateLangevinAveragesTask);
taskList.add(calculateLangevinAdvancedStatisticsTask);
taskList.add(postProcessLangevinResultsTask);
AsynchClientTask[] taskArray = new AsynchClientTask[taskList.size()];
taskList.toArray(taskArray);
ClientTaskDispatcher.dispatch(getDocumentWindowManager().getComponent(), hashTable, taskArray, false, true, null);
Expand Down
142 changes: 142 additions & 0 deletions vcell-core/src/main/java/cbit/vcell/simdata/LangevinPostProcessor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
package cbit.vcell.simdata;

import cbit.vcell.export.server.ExportSpecs;
import cbit.vcell.solver.*;
import cbit.vcell.solver.ode.ODESimData;

import java.util.ArrayList;
import java.util.Hashtable;

public class LangevinPostProcessor {

public static final String FAILURE_KEY = "FAILURE_KEY";
public static final String SIMULATION_KEY = "SIMULATION_KEY";
public static final String SIMULATION_OWNER = "SIMULATION_OWNER";

boolean failure;
Simulation sim;
SimulationOwner simOwner;

public void postProcessLangevinResults(Hashtable<String, Object> hashTable) {

failure = (boolean) hashTable.get(FAILURE_KEY);
sim = (Simulation)hashTable.get(SIMULATION_KEY);
simOwner = (SimulationOwner)hashTable.get(SIMULATION_OWNER);;

if(sim.getVersion() == null) {
throw new RuntimeException("Missing Version.");
}
if(sim.getSimulationInfo() == null) {
throw new RuntimeException("Missing Simulation Info.");
}

retrieveLangevinResultsTask();
calculateLangevinAveragesTask();
calculateLangevinAdvancedStatisticsTask();
}

private void retrieveLangevinResultsTask() {
SolverTaskDescription std = sim.getSolverTaskDescription();
int numTrials = std.getNumTrials();
VCSimulationIdentifier vcSimulationIdentifier = sim.getSimulationInfo().getAuthoritativeVCSimulationIdentifier();
MathOverrides mathOverrides = sim.getMathOverrides();
int sizeOverrides = mathOverrides.getSize();
int scanCount = mathOverrides.getScanCount();

System.out.println(" --- " + sim.getName() + ", numTrials = " + numTrials);
System.out.println(" --- " + sim.getName() + ", jobCount" + sim.getJobCount());
System.out.println(" --- " + sim.getName() + ", sizeOverrides = " + sizeOverrides);
System.out.println(" --- " + sim.getName() + ", scanCount = " + scanCount);

SimulationInfo simInfo = sim.getSimulationInfo();
VCSimulationIdentifier asi = simInfo.getAuthoritativeVCSimulationIdentifier();
VCSimulationDataIdentifier vcSimulationDataIdentifier = new VCSimulationDataIdentifier(asi, 0);

// ODEDataManager dm = (ODEDataManager)getDocumentWindowManager().getRequestManager().getDataManager(null, vcSimulationDataIdentifier, false);
// ODESimData osd = (ODESimData)dm.getODESolverResultSet();


System.out.println(" ------------------------------------");

}
private void calculateLangevinAveragesTask() {

}
private void calculateLangevinAdvancedStatisticsTask() {

}

// public void postProcessLangevinResults(Simulation sim) {
//
// final String FAILURE_KEY = "FAILURE_KEY";
// final String SIMULATION_KEY = "SIMULATION_KEY";
// Hashtable<String, Object> hashTable = new Hashtable<String, Object>();
// hashTable.put(FAILURE_KEY, false);
// hashTable.put(SIMULATION_KEY, sim);
//
// ArrayList<AsynchClientTask> taskList = new ArrayList<AsynchClientTask>();
// AsynchClientTask retrieveLangevinResultsTask = new AsynchClientTask("Retrieving results", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
// public void run(Hashtable<String, Object> hashTable) throws Exception {
// boolean failure = (boolean) hashTable.get(FAILURE_KEY);
// SolverTaskDescription std = sim.getSolverTaskDescription();
// int numTrials = std.getNumTrials();
// System.out.println(sim.getName() + ", numTrials = " + numTrials);
//// LangevinSimulationOptions lso = std.getLangevinSimulationOptions();
// final VCSimulationIdentifier vcSimulationIdentifier = sim.getSimulationInfo().getAuthoritativeVCSimulationIdentifier();
// SimulationOwner simOwner = getSimWorkspace().getSimulationOwner();
// Simulation allSims[] = simOwner.getSimulations();
// for (Simulation simCandidate : allSims) {
// if (simCandidate.getName().startsWith(sim.getName())) {
// System.out.println(" --- " + simCandidate.getName() + ", jobCount" + simCandidate.getJobCount());
// MathOverrides mathOverrides = simCandidate.getMathOverrides();
// int sizeOverrides = mathOverrides.getSize();
// int scanCount = mathOverrides.getScanCount();
// System.out.println(" --- " + sim.getName() + ", sizeOverrides = " + sizeOverrides);
// System.out.println(" --- " + sim.getName() + ", scanCount = " + scanCount);
//
// ExportSpecs.ExportParamScanInfo es = ExportSpecs.getParamScanInfo(simCandidate,0);
// ExportSpecs.ExportParamScanInfo es1 = ExportSpecs.getParamScanInfo(simCandidate,1);
// ExportSpecs.ExportParamScanInfo es2 = ExportSpecs.getParamScanInfo(simCandidate,2);
//
// if(sim.getVersion() == null) {
// throw new RuntimeException("Missing Version.");
// }
// SimulationInfo simInfo = sim.getSimulationInfo();
// if(simInfo == null) {
// throw new RuntimeException("Missing Simulation Info.");
// }
//
// VCSimulationIdentifier asi = simInfo.getAuthoritativeVCSimulationIdentifier();
// VCSimulationDataIdentifier vcSimulationDataIdentifier = new VCSimulationDataIdentifier(asi, 0);
//
// ODEDataManager dm = (ODEDataManager)getDocumentWindowManager().getRequestManager().getDataManager(outputContext, vcSimulationDataIdentifier, false);
// ODESimData osd = (ODESimData)dm.getODESolverResultSet();
//
//
// System.out.println(" ------------------------------------");
// }
// }
// }
// };
// AsynchClientTask calculateLangevinAveragesTask = new AsynchClientTask("Retrieving results", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
// public void run(Hashtable<String, Object> hashTable) throws Exception {
// boolean failure = (boolean)hashTable.get(FAILURE_KEY);
//
// }
// };
// AsynchClientTask calculateLangevinAdvancedStatisticsTask = new AsynchClientTask("Retrieving results", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
// public void run(Hashtable<String, Object> hashTable) throws Exception {
// boolean failure = (boolean)hashTable.get(FAILURE_KEY);
//
// }
// };
// taskList.add(retrieveLangevinResultsTask);
// taskList.add(calculateLangevinAveragesTask);
// taskList.add(calculateLangevinAdvancedStatisticsTask);
// AsynchClientTask[] taskArray = new AsynchClientTask[taskList.size()];
// taskList.toArray(taskArray);
// ClientTaskDispatcher.dispatch(getDocumentWindowManager().getComponent(), hashTable, taskArray, false, true, null);
//
// }

}

0 comments on commit 08935a4

Please sign in to comment.