Skip to content

Commit

Permalink
Proper management of jobCount and scanCount when adding numTrials
Browse files Browse the repository at this point in the history
  • Loading branch information
danv61 committed Jan 9, 2025
1 parent 75130bd commit f02258b
Show file tree
Hide file tree
Showing 32 changed files with 110 additions and 95 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ private void collectMathModelStats(long startDateInMs, long endDateInMs) throws
boolean bHasCompletedSim = false;
for (Simulation sim : mathModel.getSimulations()) {
SimulationStatusPersistent ss = dbServerImpl.getSimulationStatus(sim.getKey());
for (int scan = 0; ss != null && scan < sim.getScanCount(); scan ++) {
SimulationJobStatusPersistent jobStatus = ss.getJobStatus(scan);
for (int jobIndex = 0; ss != null && jobIndex < sim.getJobCount(); jobIndex ++) {
SimulationJobStatusPersistent jobStatus = ss.getJobStatus(jobIndex);
if (jobStatus != null) {
if (jobStatus.getSchedulerStatus() == SchedulerStatus.COMPLETED) {
bHasCompletedSim = true;
Expand Down Expand Up @@ -422,8 +422,8 @@ private void collectBioModelStats(long startDateInMs, long endDateInMs) throws D
for (Simulation sim : bioModel.getSimulations()) {
SimulationStatusPersistent ss = dbServerImpl.getSimulationStatus(sim.getKey());
if (ss != null) {
for (int scan = 0; scan < sim.getScanCount(); scan ++) {
SimulationJobStatusPersistent jobStatus = ss.getJobStatus(scan);
for (int jobIndex = 0; jobIndex < sim.getJobCount(); jobIndex ++) {
SimulationJobStatusPersistent jobStatus = ss.getJobStatus(jobIndex);
if (jobStatus != null) {
if (jobStatus.getSchedulerStatus() == SchedulerStatus.COMPLETED) {
bHasCompletedSim = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public int compare(RerunMissing o1, RerunMissing o2) {
System.out.println(
BeanUtils.forceStringLength(rerunArr[i].getVCSimulationIdentifier().getSimulationKey().toString(), 12, " ", true)+" "+
BeanUtils.forceStringLength((rerunArr[i].getSimulation()!=null?"'"+rerunArr[i].getSimulation().getVersion().getOwner().getName()+"'":"null"), 15, " ", false)+" "+
BeanUtils.forceStringLength((rerunArr[i].getSimulation()!=null?"scan="+rerunArr[i].getSimulation().getScanCount():"null"), 10, " ", false)+" "+
BeanUtils.forceStringLength((rerunArr[i].getSimulation()!=null?"jobs="+rerunArr[i].getSimulation().getJobCount():"null"), 10, " ", false)+" "+
rerunArr[i].getLastSimStatus());
}
System.out.println("-----\n-----");
Expand All @@ -202,7 +202,7 @@ private static boolean acquireThread(VCSimulationIdentifier vcSimulationIdentifi
while(rerunIter.hasNext()){
RerunMissing rerunMissing = rerunIter.next();
if(rerunMissing.getSimulation() != null){
if(rerunMissing.getSimulation().getScanCount() > 1){
if(rerunMissing.getSimulation().getJobCount() > 1){
//don't proceed until scancounts are done
return false;
}
Expand Down Expand Up @@ -321,15 +321,15 @@ public void run() {
// continue;
// }

int scanCount = simulation.getScanCount();
int jobCount = simulation.getJobCount();
// if(true){return;}
SimulationStatusPersistent simulationStatus = null;
SimulationInfo simulationInfo = simulation.getSimulationInfo();
if(!simulationInfo.getAuthoritativeVCSimulationIdentifier().getSimulationKey().equals(vcSimulationIdentifier.getSimulationKey())){
throw new Exception("Unexpected authoritative and sim id are not the same");
}

vcellConnection.getSimulationController().startSimulation(vcSimulationIdentifier, scanCount);
vcellConnection.getSimulationController().startSimulation(vcSimulationIdentifier, jobCount);
startTime = System.currentTimeMillis();
// SimulationStatusPersistent lastSimStatus = simulationStatus;
while(simulationStatus == null || simulationStatus.isStopped() || simulationStatus.isCompleted() || simulationStatus.isFailed()){
Expand Down Expand Up @@ -1036,8 +1036,8 @@ private static void runSim(SimIDAndJobID simIDAndJobID) throws Exception{
// notCompletedSimIDs.add(simIDAndJobID.simID.toString());
return;
}
int scanCount = sim.getScanCount();
vcellConnection.getSimulationController().startSimulation(vcSimulationIdentifier, scanCount);
int jobCount = sim.getJobCount();
vcellConnection.getSimulationController().startSimulation(vcSimulationIdentifier, jobCount);
long startTime = System.currentTimeMillis();
while(simulationStatus.isStopped() || simulationStatus.isCompleted() || simulationStatus.isFailed()){
Thread.sleep(250);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ private void runsimLoop() {
long eventTimestamp = System.currentTimeMillis();

// submit simulation via an RPC call
RestDatabaseService.callStartSimulation(vcMessagingService, user, vcSimId.getSimulationKey(), sim.getSimulationVersion().getOwner(), sim.getScanCount());
RestDatabaseService.callStartSimulation(vcMessagingService, user, vcSimId.getSimulationKey(), sim.getSimulationVersion().getOwner(), sim.getJobCount());
// get initial status from database
SimulationStatus simStatus = simulationDatabaseDirect.getSimulationStatus(vcSimId.getSimulationKey());

Expand Down
4 changes: 2 additions & 2 deletions vcell-cli/src/main/java/org/vcell/cli/run/SolverHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public void initialize(List<BioModel> bioModelList, SedML sedml) throws Expressi
AbstractTask topTask = entry.getKey();
Task actualTask = topTaskToBaseTask.get(topTask.getId());
TempSimulation tempSimulation = taskToTempSimulationMap.get(topTask);
int scanCount = tempSimulation.getScanCount();
int scanCount = tempSimulation.getScanCount_2();

if(scanCount > 1) { // we know that topTask is a RepeatedTask
// assert task instanceof RepeatedTask;
Expand Down Expand Up @@ -383,7 +383,7 @@ public void simulateAllTasks(ExternalDocInfo externalDocInfo, SedML sedml, CLIRe
tempSimulation.getMeshSpecification().setSamplingSize(newSize);
}

int scanCount = tempSimulation.getScanCount();
int scanCount = tempSimulation.getScanCount_2();
for (int i = 0; i < scanCount; i++) {
TempSimulationJob simJob = new TempSimulationJob(tempSimulation, i, null);
simJobsList.add(simJob);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ public void simStatusChanged(SimStatusEvent simStatusEvent) {
// if failed, notify
if (simStatusEvent.isNewFailureEvent()) {
String qualifier = "";
if (simulation.getScanCount() > 1) {
if (simulation.getJobCount() > 1) {
qualifier += "One job from ";
}
PopupGenerator.showErrorDialog(this, qualifier + "Simulation '" + simulation.getName() + "' failed\n" + simStatus.getDetails());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4381,7 +4381,7 @@ public void run(Hashtable<String, Object> hashTable) throws Exception {
// check for running once more... directly from job status
SimulationStatus serverSimulationStatus = getServerSimulationStatus(simInfo);
if (serverSimulationStatus != null
&& serverSimulationStatus.numberOfJobsDone() < simulations[i].getScanCount()) {
&& serverSimulationStatus.numberOfJobsDone() < simulations[i].getJobCount()) {
SimulationStatus simStatus = getClientServerManager().getJobManager()
.stopSimulation(simInfo.getAuthoritativeVCSimulationIdentifier());
// updateStatus
Expand Down Expand Up @@ -4460,7 +4460,7 @@ public OpenModelInfoHolder[] getOpenDesktopDocumentInfos(boolean bIncludeSimulat
}
Simulation[] sims = simContexts[i].getSimulations();
for (int j = 0; j < sims.length; j += 1) {
for (int k = 0; k < sims[j].getScanCount(); k += 1) {
for (int k = 0; k < sims[j].getJobCount(); k += 1) {
FieldDataWindowManager.OpenModelInfoHolder simInfoHolder = new FieldDataWindowManager.FDSimBioModelInfo(
sims[j].getName(), bioModel.getVersion(), simContexts[i],
sims[j].getSimulationInfo(), k,
Expand Down Expand Up @@ -4488,7 +4488,7 @@ public OpenModelInfoHolder[] getOpenDesktopDocumentInfos(boolean bIncludeSimulat
}
Simulation[] sims = mathModel.getSimulations();
for (int i = 0; i < sims.length; i += 1) {
for (int k = 0; k < sims[i].getScanCount(); k += 1) {
for (int k = 0; k < sims[i].getJobCount(); k += 1) {
FieldDataWindowManager.OpenModelInfoHolder simInfoHolder = new FieldDataWindowManager.FDSimMathModelInfo(
sims[i].getName(), mathModel.getVersion(), mathModel.getMathDescription(),
sims[i].getSimulationInfo(), k,
Expand Down
22 changes: 11 additions & 11 deletions vcell-client/src/main/java/cbit/vcell/client/ClientSimManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public SimulationStatus getSimulationStatus(Simulation simulation) {
SimulationStatus cachedSimStatus = simHash.getSimulationStatus(simulation);
if (cachedSimStatus!=null){
if (simulation.getIsDirty()) {
return SimulationStatus.newNotSaved(simulation.getScanCount());
return SimulationStatus.newNotSaved(simulation.getJobCount());
} else {
return cachedSimStatus;
}
Expand Down Expand Up @@ -151,7 +151,7 @@ private void initHash(Simulation[] simulations) {
if (simStatus != null) {
simHash.setSimulationStatus(simulations[i], simStatus);
} else {
simHash.setSimulationStatus(simulations[i], SimulationStatus.newNeverRan(simulations[i].getScanCount()));
simHash.setSimulationStatus(simulations[i], SimulationStatus.newNeverRan(simulations[i].getJobCount()));
}
}
}
Expand Down Expand Up @@ -498,7 +498,7 @@ void updateStatusFromServer(Simulation simulation) {
SimulationStatus serverStatus = getDocumentWindowManager().getRequestManager().getServerSimulationStatus(simulation.getSimulationInfo());

SimulationStatus newStatus = null;
if (oldStatus.isStopRequested() && serverStatus.numberOfJobsDone() < simulation.getScanCount()) {
if (oldStatus.isStopRequested() && serverStatus.numberOfJobsDone() < simulation.getJobCount()) {
// if stop requested but still going, get updated server info but adjust status
newStatus = SimulationStatus.newStopRequest(serverStatus);
} else {
Expand Down Expand Up @@ -622,7 +622,7 @@ public void runQuickSimulation(final Simulation originalSimulation, ViewerType v
}
//Let user tell how many simultaneous processes to run if this is local paramscan
final int[] simultaneousSimsSetting = new int[] {1};
if(originalSimulation.getScanCount() > 1) {
if(originalSimulation.getJobCount() > 1) {
try {
String simultaneousSims = DialogUtils.showInputDialog0(getDocumentWindowManager().getComponent(), "Local multi-scan simulation, enter maximum simulataneous sims to run at once", "1");
simultaneousSimsSetting[0] = Integer.parseInt(simultaneousSims);
Expand Down Expand Up @@ -741,7 +741,7 @@ public void solverAborted(SolverEvent event) {
taskList.add(task);
}

AsynchClientTask runOthers = new AsynchClientTask("running scans", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
AsynchClientTask runOthers = new AsynchClientTask("running scans/trials", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
if (getClientTaskStatusSupport().isInterrupted()) {
Expand All @@ -750,7 +750,7 @@ public void run(Hashtable<String, Object> hashTable) throws Exception {
Simulation[] sims = (Simulation[])hashTable.get("simsArray");
Simulation simulation = sims[0];
//Run param scans to generate data for scansnum > 0
if(simulation.getScanCount() > 1) {
if(simulation.getJobCount() > 1) {
//Start master thread so clientdispatcher modal dialog can end
new Thread(new Runnable() {
@Override
Expand All @@ -772,7 +772,7 @@ public void windowClosing(WindowEvent e) {
//Counter of how many simultaneous param scan threads are running (decremented when scan thread finishes)
final int[] currentlyRunningCountHolder = new int[] {0};
//Run other scans starting at 1 (scan 0 is already done if we got here)
for (int i = 1; i < simulation.getScanCount(); i++) {
for (int i = 1; i < simulation.getJobCount(); i++) {
//Check if we can start another new param scan thread
while(currentlyRunningCountHolder[0] >= simultaneousSimsSetting[0]) {
try {
Expand All @@ -785,15 +785,15 @@ public void windowClosing(WindowEvent e) {
e.printStackTrace();
}
}
final int scanNum = i;
final int jobIndex = i;
//increment the concurrent running counter
currentlyRunningCountHolder[0]+= 1;
//Start new param scan thread
new Thread(new Runnable() {
@Override
public void run() {
try {
SimulationTask simTask = new SimulationTask(new SimulationJob(simulation, scanNum, null), 0);
SimulationTask simTask = new SimulationTask(new SimulationJob(simulation, jobIndex, null), 0);
Solver solver = createQuickRunSolver(localSimDataDir, simTask);
solver.startSolver();
while(true) {
Expand Down Expand Up @@ -835,8 +835,8 @@ public void run() {
//decrement the concurrent running counter
currentlyRunningCountHolder[0]-= 1;
//Set progress on dataviewer
if(((SimResultsViewer)haveSimulationWindow.getDataViewer()).getLocalScanProgress() < (scanNum+1)) {
((SimResultsViewer)haveSimulationWindow.getDataViewer()).setLocalScanProgress(scanNum+1);
if(((SimResultsViewer)haveSimulationWindow.getDataViewer()).getLocalJobProgress() < (jobIndex+1)) {
((SimResultsViewer)haveSimulationWindow.getDataViewer()).setLocalScanProgress(jobIndex+1);
}
}
}}).start();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ public void simStatusChanged(SimStatusEvent simStatusEvent) {
// if failed, notify
if (simStatusEvent.isNewFailureEvent()) {
String qualifier = "";
if (simulation.getScanCount() > 1) {
if (simulation.getJobCount() > 1) {
qualifier += "One job from ";
}
PopupGenerator.showErrorDialog(this, qualifier + "Simulation '" + simulation.getName() + "' failed\n" + simStatus.getDetails());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public void changeSimulationInstances(Simulation[] newSimulations) {
// look in list for existing status
//
if (newSimulations[i].getKey()==null || newSimulations[i].getIsDirty()){
newHash.put(newSimulations[i],SimulationStatus.newNotSaved(newSimulations[i].getScanCount()));
newHash.put(newSimulations[i],SimulationStatus.newNotSaved(newSimulations[i].getJobCount()));
//
// try to find status for previous instance of this simulation
//
Expand All @@ -72,7 +72,7 @@ public void changeSimulationInstances(Simulation[] newSimulations) {
if (newSimStatus!=null){
newHash.put(newSimulations[i],newSimStatus);
}else{
newHash.put(newSimulations[i],SimulationStatus.newUnknown(newSimulations[i].getScanCount())); // unknown status
newHash.put(newSimulations[i],SimulationStatus.newUnknown(newSimulations[i].getJobCount())); // unknown status
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1178,8 +1178,8 @@ private DataInfoProvider getDataInfoProvider(VCDocument document, PDEDataContext
*/
private String generateTestCriteriaReport(TestCaseNew testCase, TestCriteriaNew testCriteria, Simulation testSim, TFGenerateReport.VCDocumentAndSimInfo userSelectedRefSimInfo/*,VCDocument refDoc,VCDocument testDocument*/) {

if (testSim.getScanCount() != 1) {
throw new RuntimeException("paramater scan is not supported in Math Testing Framework");
if (testSim.getJobCount() != 1) {
throw new RuntimeException("paramater scans and trials are not supported in Math Testing Framework");
}
SimulationSymbolTable simSymbolTable = new SimulationSymbolTable(testSim, MathOverrides.ScanIndex.ZERO);

Expand Down Expand Up @@ -1310,8 +1310,8 @@ private String generateTestCriteriaReport(TestCaseNew testCase, TestCriteriaNew
VCDataIdentifier refVcdID = new VCSimulationDataIdentifier(refVCDocumentAndSimInfo.getSimInfo().getAuthoritativeVCSimulationIdentifier(), 0);
PDEDataManager refDataManager = (PDEDataManager) getRequestManager().getDataManager(null, refVcdID, refSim.isSpatial());

if (refSim.getScanCount() != 1) {
throw new RuntimeException("paramater scan is not supported in Math Testing Framework");
if (refSim.getJobCount() != 1) {
throw new RuntimeException("paramater scans and trials are not supported in Math Testing Framework");
}
SimulationSymbolTable refSimSymbolTable = new SimulationSymbolTable(refSim, MathOverrides.ScanIndex.ZERO);

Expand Down Expand Up @@ -1407,8 +1407,8 @@ private String generateTestCriteriaReport(TestCaseNew testCase, TestCriteriaNew
}
} else if (testCase.getType().equals(TestCaseNew.REGRESSION)) {
Simulation refSim = ((ClientDocumentManager) getRequestManager().getDocumentManager()).getSimulation(testCriteria.getRegressionSimInfo());
if (refSim.getScanCount() != 1) {
throw new RuntimeException("paramater scan is not supported in Math Testing Framework");
if (refSim.getJobCount() != 1) {
throw new RuntimeException("paramater scans and trials are not supported in Math Testing Framework");
}
SimulationSymbolTable refSimSymbolTable = new SimulationSymbolTable(refSim, MathOverrides.ScanIndex.ZERO);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,11 @@ public PlotPane getPlotPane() {
private void initialize() {

setLayout(new BorderLayout());
int scanCount = simulation.getScanCount();
int scanCount = simulation.getScanCount_2();
int trialCount = simulation.getNumTrials();
if (trialCount > 1){
throw new RuntimeException("trials are not yet supported in ODETimePlotMultipleScansPanel");
}

plotPane = new PlotPane();
plotPane.getPlot2DDataPanel1().setXVarName(xVarColumnName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,17 +173,17 @@ private Simulation getSimulation() {
}

private JLabel label = new JLabel("<html><b>Choose Parameter Values</b></html>");
private int localScanProgress;
public void setLocalScanProgress(int localScanProgress) {
this.localScanProgress = localScanProgress;
private int localJobProgress;
public void setLocalScanProgress(int localJobProgress) {
this.localJobProgress = localJobProgress;
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
label.setText("<html><b>Choose Parameter Values progress:("+(localScanProgress)+"/"+getSimulation().getScanCount()+")</b></html>");
label.setText("<html><b>Choose Parameter Values/Trials progress:("+(localJobProgress)+"/"+getSimulation().getJobCount()+")</b></html>");
}});
}
public int getLocalScanProgress() {
return localScanProgress;
public int getLocalJobProgress() {
return localJobProgress;
}
/**
* Insert the method's description here.
Expand Down Expand Up @@ -216,7 +216,7 @@ public void propertyChange(java.beans.PropertyChangeEvent evt) {


// if necessarry, create parameter choices panel and wire it up
if (getSimulation().getScanCount() > 1) {
if (getSimulation().getScanCount_2() > 1) {
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout(5, 0));
panel.setBorder(BorderFactory.createEtchedBorder());
Expand Down Expand Up @@ -321,7 +321,7 @@ public void actionPerformed(ActionEvent e) {
// put things together
setLayout(new java.awt.BorderLayout());
add(getMainViewer(), java.awt.BorderLayout.CENTER);
if (getSimulation().getScanCount() > 1) {
if (getSimulation().getScanCount_2() > 1) {
add(getParamChoicesPanel(), java.awt.BorderLayout.SOUTH);
}
}
Expand Down
Loading

0 comments on commit f02258b

Please sign in to comment.