use of cbit.vcell.solver.SimulationInfo in project vcell by virtualcell.
the class ClientRequestManager method stopSimulations.
public void stopSimulations(final ClientSimManager clientSimManager, final Simulation[] simulations) {
// stop is single step operation, don't bother with tasks, thread inline
AsynchClientTask task1 = new AsynchClientTask("stopping simulations", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
Hashtable<Simulation, Throwable> failures = new Hashtable<Simulation, Throwable>();
if (simulations != null && simulations.length > 0) {
for (int i = 0; i < simulations.length; i++) {
try {
SimulationInfo simInfo = simulations[i].getSimulationInfo();
if (simInfo != null) {
// check for running once more... directly from job status
SimulationStatus serverSimulationStatus = getServerSimulationStatus(simInfo);
if (serverSimulationStatus != null && serverSimulationStatus.numberOfJobsDone() < simulations[i].getScanCount()) {
SimulationStatus simStatus = getClientServerManager().getJobManager().stopSimulation(simInfo.getAuthoritativeVCSimulationIdentifier());
// updateStatus
clientSimManager.updateStatusFromStopRequest(simulations[i], simStatus);
}
} else {
// this should really not happen...
throw new RuntimeException(">>>>>>>>>> trying to stop an unsaved simulation...");
}
} catch (Throwable exc) {
exc.printStackTrace(System.out);
failures.put(simulations[i], exc);
}
}
hashTable.put("failures", failures);
}
}
};
AsynchClientTask task2 = new AsynchClientTask("stopping simulations", AsynchClientTask.TASKTYPE_SWING_BLOCKING, false, false) {
@Override
public void run(Hashtable<String, Object> hashTable) throws Exception {
@SuppressWarnings("unchecked") Hashtable<Simulation, Throwable> failures = (Hashtable<Simulation, Throwable>) hashTable.get("failures");
if (failures != null && !failures.isEmpty()) {
Enumeration<Simulation> en = failures.keys();
while (en.hasMoreElements()) {
Simulation sim = (Simulation) en.nextElement();
Throwable exc = (Throwable) failures.get(sim);
// notify user
PopupGenerator.showErrorDialog(clientSimManager.getDocumentWindowManager(), "Failed to dispatch stop request for simulation'" + sim.getName() + "'\n" + exc.getMessage(), exc);
}
}
}
};
ClientTaskDispatcher.dispatch(clientSimManager.getDocumentWindowManager().getComponent(), new Hashtable<String, Object>(), new AsynchClientTask[] { task1, task2 });
}
use of cbit.vcell.solver.SimulationInfo in project vcell by virtualcell.
the class TestingFrameworkWindowManager method selectSimInfoPrivate.
/**
* Insert the method's description here.
* Creation date: (11/13/2004 1:52:50 PM)
* @return cbit.vcell.solver.SimulationInfo
* @param sims cbit.vcell.solver.Simulation[]
*/
private SimulationInfo selectSimInfoPrivate(Simulation[] sims) {
// Sort
if (sims.length > 0) {
java.util.Arrays.sort(sims, new java.util.Comparator<Simulation>() {
public int compare(Simulation si1, Simulation si2) {
return si1.getName().compareTo(si2.getName());
}
public boolean equals(Object obj) {
return false;
}
});
}
String[] simInfoNames = new String[sims.length];
for (int i = 0; i < simInfoNames.length; i++) {
simInfoNames[i] = sims[i].getSimulationInfo().getName();
}
// Display the list of simInfo names in a list for user to choose the simulationInfo to compare with
// in the case of regression testing.
String selectedRefSimInfoName = (String) PopupGenerator.showListDialog(this, simInfoNames, "Please select reference simulation");
if (selectedRefSimInfoName == null) {
// PopupGenerator.showErrorDialog("Reference SimInfo not selected");
return null;
}
int simIndex = -1;
for (int i = 0; i < simInfoNames.length; i++) {
if (simInfoNames[i].equals(selectedRefSimInfoName)) {
simIndex = i;
}
}
if (simIndex == -1) {
PopupGenerator.showErrorDialog(TestingFrameworkWindowManager.this, "No such SimInfo Exists : " + selectedRefSimInfoName);
return null;
}
SimulationInfo simInfo = (SimulationInfo) sims[simIndex].getSimulationInfo();
return simInfo;
}
use of cbit.vcell.solver.SimulationInfo in project vcell by virtualcell.
the class TestingFrameworkWindowManager method updateTestCriteria.
/**
* Insert the method's description here.
* Creation date: (4/9/2003 1:31:08 PM)
* @return cbit.vcell.numericstestingframework.TestSuiteInfo
*/
public void updateTestCriteria(TestCriteriaNew origTestCriteria, TestCriteriaNew newTestCriteria) throws DataAccessException {
EditTestCriteriaOP testCriteriaOP = null;
if (newTestCriteria instanceof TestCriteriaNewMathModel) {
MathModelInfo regrMMInfo = ((TestCriteriaNewMathModel) newTestCriteria).getRegressionMathModelInfo();
SimulationInfo regrsimInfo = ((TestCriteriaNewMathModel) newTestCriteria).getRegressionSimInfo();
testCriteriaOP = new EditTestCriteriaOPMathModel(origTestCriteria.getTCritKey(), (regrMMInfo != null ? regrMMInfo.getVersion().getVersionKey() : null), (regrsimInfo != null ? regrsimInfo.getVersion().getVersionKey() : null), newTestCriteria.getMaxAbsError(), newTestCriteria.getMaxRelError());
} else if (newTestCriteria instanceof TestCriteriaNewBioModel) {
BioModelInfo regrBMInfo = ((TestCriteriaNewBioModel) newTestCriteria).getRegressionBioModelInfo();
SimulationInfo regrsimInfo = ((TestCriteriaNewBioModel) newTestCriteria).getRegressionSimInfo();
testCriteriaOP = new EditTestCriteriaOPBioModel(origTestCriteria.getTCritKey(), (regrBMInfo != null ? regrBMInfo.getVersion().getVersionKey() : null), (regrsimInfo != null ? regrsimInfo.getVersion().getVersionKey() : null), newTestCriteria.getMaxAbsError(), newTestCriteria.getMaxRelError());
}
getRequestManager().getDocumentManager().doTestSuiteOP(testCriteriaOP);
RemoveTestResultsOP removeTestResults = new RemoveTestResultsOP(new BigDecimal[] { origTestCriteria.getTCritKey() });
getRequestManager().getDocumentManager().doTestSuiteOP(removeTestResults);
}
use of cbit.vcell.solver.SimulationInfo in project vcell by virtualcell.
the class TestCriteriaNewBioModel method describe.
@Override
public String describe() {
StringBuilder sb = new StringBuilder();
if (regrBioModelInfo != null) {
Version v = regrBioModelInfo.getVersion();
if (v != null) {
sb.append(v.getName());
sb.append(' ');
} else {
sb.append("unversioned ");
}
} else {
sb.append("no model info");
}
SimulationInfo si = getSimInfo();
if (si != null) {
sb.append(si.getName());
} else {
sb.append("no simulation");
}
return sb.toString();
}
use of cbit.vcell.solver.SimulationInfo in project vcell by virtualcell.
the class CheckBeforeDelete method checkLostResults.
/**
* Insert the method's description here.
* Creation date: (6/1/2004 3:44:03 PM)
* @return cbit.vcell.solver.SolverResultSetInfo[]
* @param bioModel cbit.vcell.biomodel.BioModel
*/
private Simulation[] checkLostResults(BioModel oldBioModel, BioModel newlySavedBioModel, cbit.vcell.clientdb.DocumentManager documentManager, Simulation[] submittedSimulations) throws Exception {
//
// before deleting old version, prompt user if old simulation results will not be availlable in new edition
//
Vector<Simulation> lostResultsSimulationList = new Vector<Simulation>();
Simulation[] oldSimulations = oldBioModel.getSimulations();
for (int i = 0; i < oldSimulations.length; i++) {
Simulation oldSimulation = oldSimulations[i];
SimulationStatus simStatus = null;
SimulationInfo oldSimInfo = oldSimulation.getSimulationInfo();
if (oldSimInfo != null) {
//
// we need to ask for previous sim results (here we need possible translation to ask for parent's results).
//
simStatus = documentManager.getServerSimulationStatus(oldSimInfo.getAuthoritativeVCSimulationIdentifier());
}
if (simStatus != null && simStatus.getHasData()) {
//
// results exist in old version (the BioModel to be deleted) for SimulationInfo "oldSimInfo"
// Users should be warned when they are going to loose any simulation results in any unexpected way.
//
// WARN if the lost data is because new simulation is not mathematically equivalent to old edition
// (different MathDescription key)
//
// IGNORE if the lost data is from edits of a Simulation only (same MathDescription)
// (same MathDescription key, different Simulation key)
//
// IGNORE if Simulation has been deleted
// (Simulation not found in current BioModel)
//
// IGNORE if Simulation has been submitted for running
//
boolean bDataInNewEdition = false;
Simulation[] newSimulations = newlySavedBioModel.getSimulations();
Simulation correspondingSimulation = null;
for (int j = 0; j < newSimulations.length; j++) {
if (newSimulations[j].getName().equals(oldSimulation.getName())) {
correspondingSimulation = newSimulations[j];
if (correspondingSimulation.getKey().equals(oldSimulation.getKey())) {
//
// exactly same simulation (same key), so no lost data
//
bDataInNewEdition = true;
} else if (correspondingSimulation.getSimulationVersion().getParentSimulationReference() != null) {
//
// new simulation changed but points to same results
//
bDataInNewEdition = true;
}
break;
}
}
if (!bDataInNewEdition && correspondingSimulation != null) {
//
// result set (for "rsInfo") will be lost, should we ignore this fact?
//
boolean bIgnore = false;
//
if (correspondingSimulation.getMathDescription().getKey().equals(oldSimulation.getMathDescription().getKey())) {
bIgnore = true;
}
//
for (int j = 0; submittedSimulations != null && j < submittedSimulations.length; j++) {
if (correspondingSimulation.getName().equals(submittedSimulations[j].getName())) {
bIgnore = true;
}
}
//
if (!bIgnore) {
lostResultsSimulationList.add(correspondingSimulation);
}
}
}
}
return (Simulation[]) BeanUtils.getArray(lostResultsSimulationList, Simulation.class);
}
Aggregations