use of cbit.vcell.biomodel.BioModel in project vcell by virtualcell.
the class SimulationContext method getUnitInfo.
/**
* SimulationContext constructor.
* This constructor differs with the previous one with one more boolean input parameter, which specifies whether
* the new application is a stochastic application or not.
*/
// @Deprecated
// public SimulationContext(Model model, Geometry geometry, boolean bStoch, boolean bRuleBased) throws PropertyVetoException {
// this(model,geometry,null,null,legacyType(bStoch, bRuleBased));
// }
@Override
public UnitInfo getUnitInfo() throws UnsupportedOperationException {
if (unitInfo != null) {
return unitInfo;
}
if (bioModel == null) {
throw new UnsupportedOperationException("bioModel not set yet");
}
Model m = bioModel.getModel();
ModelUnitSystem unitSys = m.getUnitSystem();
VCUnitDefinition tu = unitSys.getTimeUnit();
String sym = tu.getSymbol();
unitInfo = new UnitInfo(sym);
return unitInfo;
}
use of cbit.vcell.biomodel.BioModel in project vcell by virtualcell.
the class TestingFrameworkWindowManager method generateTestCaseReport.
/**
* Insert the method's description here.
* Creation date: (8/18/2003 5:36:47 PM)
*/
public String generateTestCaseReport(TestCaseNew testCase, TestCriteriaNew onlyThisTCrit, ClientTaskStatusSupport pp, TFGenerateReport.VCDocumentAndSimInfo userDefinedRefSimInfo) {
StringBuffer reportTCBuffer = new StringBuffer();
if (testCase == null) {
reportTCBuffer.append("\n\tTEST CASE :\tERROR: Test Case is NULL\n");
} else {
pp.setMessage(testCase.getVersion().getName() + " " + testCase.getType() + " Getting Simulations");
// Get the Simulations
Simulation[] sims = null;
reportTCBuffer.append("\n\tTEST CASE : " + (testCase.getVersion() != null ? testCase.getVersion().getName() : "Null") + "\n\tAnnotation : " + testCase.getAnnotation() + "\n");
try {
if (testCase instanceof TestCaseNewMathModel) {
MathModelInfo mmInfo = ((TestCaseNewMathModel) testCase).getMathModelInfo();
MathModel mathModel = getRequestManager().getDocumentManager().getMathModel(mmInfo);
sims = mathModel.getSimulations();
reportTCBuffer.append("\tMathModel : " + mmInfo.getVersion().getName() + ", " + mmInfo.getVersion().getDate().toString() + "\n");
} else if (testCase instanceof TestCaseNewBioModel) {
TestCaseNewBioModel bioTestCase = (TestCaseNewBioModel) testCase;
// bioTestCase.
BioModelInfo bmInfo = bioTestCase.getBioModelInfo();
BioModel bioModel = getRequestManager().getDocumentManager().getBioModel(bmInfo);
SimulationContext[] simContextArr = bioModel.getSimulationContexts();
if (simContextArr != null && simContextArr.length > 0) {
SimulationContext simContext = null;
for (int i = 0; i < simContextArr.length; i += 1) {
if (simContextArr[i].getVersion().getVersionKey().compareEqual(bioTestCase.getSimContextKey())) {
simContext = simContextArr[i];
break;
}
}
if (simContext != null) {
sims = bioModel.getSimulations(simContext);
reportTCBuffer.append("\tBioModel : " + bmInfo.getVersion().getName() + ", " + bmInfo.getVersion().getDate().toString() + "\n");
}
}
}
if (sims == null || sims.length == 0) {
reportTCBuffer.append("\tERROR " + "No sims found for TestCase " + (testCase.getVersion() != null ? "name=" + testCase.getVersion().getName() : "key=" + testCase.getTCKey()) + "\n");
}
if (testCase.getTestCriterias() == null || sims.length != testCase.getTestCriterias().length) {
reportTCBuffer.append("\tNote " + "Num sims=" + sims.length + " does not match testCriteria length=" + (testCase.getTestCriterias() != null ? testCase.getTestCriterias().length + "" : "null") + " for TestCase " + (testCase.getVersion() != null ? "name=" + testCase.getVersion().getName() : "key=" + testCase.getTCKey()) + "\n");
}
// 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;
}
});
}
TestCriteriaNew[] testCriterias = (onlyThisTCrit != null ? new TestCriteriaNew[] { onlyThisTCrit } : testCase.getTestCriterias());
for (int k = 0; k < sims.length; k++) {
TestCriteriaNew testCriteria = getMatchingTestCriteria(sims[k], testCriterias);
if (testCriteria != null) {
pp.setMessage((testCase instanceof TestCaseNewMathModel ? "(MM)" : "(BM)") + " " + (onlyThisTCrit == null ? "sim " + (k + 1) + " of " + sims.length : "sim=" + onlyThisTCrit.getSimInfo().getName()) + " " + testCase.getVersion().getName() + " " + testCase.getType());
reportTCBuffer.append(generateTestCriteriaReport(testCase, testCriteria, sims[k], userDefinedRefSimInfo));
}
}
} catch (UserCancelException e) {
throw e;
} catch (Throwable e) {
e.printStackTrace();
reportTCBuffer.append("\tERROR " + e.getClass().getName() + " mesg=" + e.getMessage() + "\n");
try {
if (onlyThisTCrit != null) {
updateTCritStatus(onlyThisTCrit, TestCriteriaNew.TCRIT_STATUS_RPERROR, "TestCase Error " + e.getClass().getName() + " " + e.getMessage());
} else if (testCase.getTestCriterias() != null) {
for (int i = 0; i < testCase.getTestCriterias().length; i += 1) {
updateTCritStatus(testCase.getTestCriterias()[i], TestCriteriaNew.TCRIT_STATUS_RPERROR, "TestCase Error " + e.getClass().getName() + " " + e.getMessage());
}
}
} catch (Throwable e2) {
//
}
}
}
return reportTCBuffer.toString();
}
use of cbit.vcell.biomodel.BioModel in project vcell by virtualcell.
the class TestingFrameworkWindowManager method getUserSelectedRefSimInfo.
public SimulationInfo getUserSelectedRefSimInfo(RequestManager currentRequstManager, VCDocumentInfo vcDocInfo) throws Exception {
final int MODELTYPE_INDEX = 0;
final int MODELKEY_INDEX = 2;
final int SIMNAME_INDEX = 5;
final String[] ROWDATACOLNAMES = new String[] { "Type", "Model", "Model Key", "Owner", "App", "Sim", "Date" };
Vector<Object[]> simInfoV = new Vector<Object[]>();
// BioModelMetaData[] bmMetaDataArr = getRequestManager().getDocumentManager().getSessionManager().getUserMetaDbServer().getBioModelMetaDatas(true);
// bmMetaDataArr[0].
BioModelInfo[] bioModelInfoArr = null;
if (vcDocInfo == null) {
bioModelInfoArr = currentRequstManager.getDocumentManager().getBioModelInfos();
} else if (vcDocInfo instanceof BioModelInfo) {
bioModelInfoArr = new BioModelInfo[] { (BioModelInfo) vcDocInfo };
}
for (int i = 0; bioModelInfoArr != null && i < bioModelInfoArr.length; i++) {
if (bioModelInfoArr[i].getBioModelChildSummary() != null) {
String[] bmSimContextNamesArr = bioModelInfoArr[i].getBioModelChildSummary().getSimulationContextNames();
for (int j = 0; bmSimContextNamesArr != null && j < bmSimContextNamesArr.length; j++) {
String[] bmSimNamesArr = bioModelInfoArr[i].getBioModelChildSummary().getSimulationNames(bmSimContextNamesArr[j]);
for (int k = 0; bmSimNamesArr != null && k < bmSimNamesArr.length; k++) {
// System.out.println("BM "+
// bioModelInfoArr[i].getVersion().getOwner().getName()+" "+
// bioModelInfoArr[i].getVersion().getName()+
// " app="+bmSimContextNamesArr[j]+
// " sim="+bmSimNamesArr[k]);
simInfoV.add(new Object[] { "BM", bioModelInfoArr[i].getVersion().getName(), bioModelInfoArr[i].getVersion().getVersionKey(), bioModelInfoArr[i].getVersion().getOwner().getName(), bmSimContextNamesArr[j], bmSimNamesArr[k], bioModelInfoArr[i].getVersion().getDate() });
}
}
}
}
MathModelInfo[] mathModelInfoArr = null;
if (vcDocInfo == null) {
mathModelInfoArr = currentRequstManager.getDocumentManager().getMathModelInfos();
} else if (vcDocInfo instanceof MathModelInfo) {
mathModelInfoArr = new MathModelInfo[] { (MathModelInfo) vcDocInfo };
}
for (int i = 0; mathModelInfoArr != null && i < mathModelInfoArr.length; i++) {
if (mathModelInfoArr[i].getMathModelChildSummary() != null) {
String[] mathSimNamesArr = mathModelInfoArr[i].getMathModelChildSummary().getSimulationNames();
for (int j = 0; mathSimNamesArr != null && j < mathSimNamesArr.length; j++) {
// System.out.println("MM "+
// mathModelInfoArr[i].getVersion().getOwner().getName()+" "+
// mathModelInfoArr[i].getVersion().getName()+
// " sim="+mathSimNamesArr[j]);
simInfoV.add(new Object[] { "MM", mathModelInfoArr[i].getVersion().getName(), mathModelInfoArr[i].getVersion().getVersionKey(), mathModelInfoArr[i].getVersion().getOwner().getName(), null, mathSimNamesArr[j], mathModelInfoArr[i].getVersion().getDate() });
}
}
}
Object[][] rowData = new Object[simInfoV.size()][ROWDATACOLNAMES.length];
simInfoV.copyInto(rowData);
int[] simSelection = DialogUtils.showComponentOKCancelTableList(getComponent(), "Choose Ref Simulation", ROWDATACOLNAMES, rowData, ListSelectionModel.SINGLE_SELECTION);
if (simSelection == null || simSelection.length == 0) {
throw UserCancelException.CANCEL_GENERIC;
}
Simulation[] simArr = null;
if (rowData[simSelection[0]][MODELTYPE_INDEX].equals("BM")) {
BioModel bm = currentRequstManager.getDocumentManager().getBioModel((KeyValue) rowData[simSelection[0]][MODELKEY_INDEX]);
simArr = bm.getSimulations();
} else {
MathModel mm = currentRequstManager.getDocumentManager().getMathModel((KeyValue) rowData[simSelection[0]][MODELKEY_INDEX]);
simArr = mm.getSimulations();
}
for (int i = 0; simArr != null && i < simArr.length; i++) {
if (simArr[i].getName().equals(rowData[simSelection[0]][SIMNAME_INDEX])) {
return simArr[i].getSimulationInfo();
}
}
throw new Exception("Couldn't find selected simulation");
}
use of cbit.vcell.biomodel.BioModel in project vcell by virtualcell.
the class TestingFrameworkWindowManager method generateTestCriteriaReport.
/**
* Insert the method's description here.
* Creation date: (8/18/2003 5:36:47 PM)
*/
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");
}
SimulationSymbolTable simSymbolTable = new SimulationSymbolTable(testSim, 0);
String simReportStatus = null;
String simReportStatusMessage = null;
StringBuffer reportTCBuffer = new StringBuffer();
VariableComparisonSummary[] failVarSummaries = null;
VariableComparisonSummary[] allVarSummaries = null;
double absErr = 0;
double relErr = 0;
if (testCriteria != null) {
absErr = testCriteria.getMaxAbsError().doubleValue();
relErr = testCriteria.getMaxRelError().doubleValue();
}
try {
VCDocument testDoc = null;
if (testCase instanceof TestCaseNewMathModel) {
MathModelInfo mmInfo = ((TestCaseNewMathModel) testCase).getMathModelInfo();
MathModel mathModel = getRequestManager().getDocumentManager().getMathModel(mmInfo);
testDoc = mathModel;
} else if (testCase instanceof TestCaseNewBioModel) {
TestCaseNewBioModel bioTestCase = (TestCaseNewBioModel) testCase;
// bioTestCase.
BioModelInfo bmInfo = bioTestCase.getBioModelInfo();
BioModel bioModel = getRequestManager().getDocumentManager().getBioModel(bmInfo);
testDoc = bioModel;
}
TFGenerateReport.VCDocumentAndSimInfo refVCDocumentAndSimInfo = null;
if (userSelectedRefSimInfo == null) {
SimulationInfo refSimInfo = testCriteria.getRegressionSimInfo();
if (refSimInfo != null) {
VCDocument refDoc = null;
if (testCriteria instanceof TestCriteriaNewMathModel) {
MathModelInfo mmInfo = ((TestCriteriaNewMathModel) testCriteria).getRegressionMathModelInfo();
MathModel mathModel = getRequestManager().getDocumentManager().getMathModel(mmInfo);
refDoc = mathModel;
} else if (testCriteria instanceof TestCriteriaNewBioModel) {
BioModelInfo bmInfo = ((TestCriteriaNewBioModel) testCriteria).getRegressionBioModelInfo();
BioModel bioModel = getRequestManager().getDocumentManager().getBioModel(bmInfo);
refDoc = bioModel;
}
refVCDocumentAndSimInfo = new TFGenerateReport.VCDocumentAndSimInfo(refSimInfo, refDoc);
}
reportTCBuffer.append("\t\t" + testSim.getName() + (refVCDocumentAndSimInfo != null ? " (Using TestCrit RegrRefSim)" : "") + " : " + "\n");
} else {
refVCDocumentAndSimInfo = userSelectedRefSimInfo;
reportTCBuffer.append("\t\t" + testSim.getName() + " (Using UserDefined RegrRefSim '" + userSelectedRefSimInfo.getSimInfo().getAuthoritativeVCSimulationIdentifier() + "') : " + "\n");
}
if (testCase.getType().equals(TestCaseNew.REGRESSION) && refVCDocumentAndSimInfo == null) {
reportTCBuffer.append("\t\t\tNo reference SimInfo, SimInfoKey=" + testCriteria.getSimInfo().getVersion().getName() + ". Cannot perform Regression Test!\n");
simReportStatus = TestCriteriaNew.TCRIT_STATUS_NOREFREGR;
} else {
VCDataIdentifier vcdID = new VCSimulationDataIdentifier(testSim.getSimulationInfo().getAuthoritativeVCSimulationIdentifier(), 0);
DataManager simDataManager = getRequestManager().getDataManager(null, vcdID, testSim.isSpatial());
double[] timeArray = null;
// can be histogram, so there won't be time array
try {
timeArray = simDataManager.getDataSetTimes();
} catch (Exception ex) {
ex.printStackTrace(System.out);
}
NonspatialStochSimOptions stochOpt = testSim.getSolverTaskDescription().getStochOpt();
if ((stochOpt == null || stochOpt.getNumOfTrials() == 1) && (timeArray == null || timeArray.length == 0)) {
reportTCBuffer.append("\t\t\tNO DATA : Simulation not run yet.\n");
simReportStatus = TestCriteriaNew.TCRIT_STATUS_NODATA;
} else {
// SPATIAL simulation
if (testSim.getMathDescription().isSpatial()) {
PDEDataManager pdeDataManager = (PDEDataManager) simDataManager;
// Get EXACT solution if test case type is EXACT, Compare with numerical
if (testCase.getType().equals(TestCaseNew.EXACT) || testCase.getType().equals(TestCaseNew.EXACT_STEADY)) {
SimulationComparisonSummary simCompSummary = MathTestingUtilities.comparePDEResultsWithExact(simSymbolTable, pdeDataManager, testCase.getType(), testCriteria.getMaxAbsError(), testCriteria.getMaxRelError());
// Failed var summaries
failVarSummaries = simCompSummary.getFailingVariableComparisonSummaries(absErr, relErr);
allVarSummaries = simCompSummary.getVariableComparisonSummaries();
if (failVarSummaries.length > 0) {
simReportStatus = TestCriteriaNew.TCRIT_STATUS_FAILEDVARS;
// Failed simulation
reportTCBuffer.append("\t\tTolerance test FAILED \n");
reportTCBuffer.append("\t\tFailed Variables : \n");
for (int m = 0; m < failVarSummaries.length; m++) {
reportTCBuffer.append("\t\t\t" + failVarSummaries[m].toShortString() + "\n");
}
} else {
simReportStatus = TestCriteriaNew.TCRIT_STATUS_PASSED;
reportTCBuffer.append("\t\tTolerance test PASSED \n");
}
reportTCBuffer.append("\t\tPassed Variables : \n");
// Check if varSummary exists in failed summaries list. If not, simulation passed.
for (int m = 0; m < allVarSummaries.length; m++) {
if (!BeanUtils.arrayContains(failVarSummaries, allVarSummaries[m])) {
reportTCBuffer.append("\t\t\t" + allVarSummaries[m].toShortString() + "\n");
}
}
// Get CONSTRUCTED solution if test case type is CONSTRUCTED, Compare with numerical
} else if (testCase.getType().equals(TestCaseNew.CONSTRUCTED)) {
SimulationComparisonSummary simCompSummary = MathTestingUtilities.comparePDEResultsWithExact(simSymbolTable, pdeDataManager, testCase.getType(), testCriteria.getMaxAbsError(), testCriteria.getMaxRelError());
// Failed var summaries
failVarSummaries = simCompSummary.getFailingVariableComparisonSummaries(absErr, relErr);
allVarSummaries = simCompSummary.getVariableComparisonSummaries();
if (failVarSummaries.length > 0) {
simReportStatus = TestCriteriaNew.TCRIT_STATUS_FAILEDVARS;
// Failed simulation
reportTCBuffer.append("\t\tTolerance test FAILED \n");
reportTCBuffer.append("\t\tFailed Variables : \n");
for (int m = 0; m < failVarSummaries.length; m++) {
reportTCBuffer.append("\t\t\t" + failVarSummaries[m].toShortString() + "\n");
}
} else {
simReportStatus = TestCriteriaNew.TCRIT_STATUS_PASSED;
reportTCBuffer.append("\t\tTolerance test PASSED \n");
}
reportTCBuffer.append("\t\tPassed Variables : \n");
// Check if varSummary exists in failed summaries list. If not, simulation passed.
for (int m = 0; m < allVarSummaries.length; m++) {
if (!BeanUtils.arrayContains(failVarSummaries, allVarSummaries[m])) {
reportTCBuffer.append("\t\t\t" + allVarSummaries[m].toShortString() + "\n");
}
}
} else if (testCase.getType().equals(TestCaseNew.REGRESSION)) {
Simulation refSim = ((ClientDocumentManager) getRequestManager().getDocumentManager()).getSimulation(refVCDocumentAndSimInfo.getSimInfo());
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");
}
SimulationSymbolTable refSimSymbolTable = new SimulationSymbolTable(refSim, 0);
String[] varsToCompare = getVariableNamesToCompare(simSymbolTable, refSimSymbolTable);
SimulationComparisonSummary simCompSummary = MathTestingUtilities.comparePDEResults(simSymbolTable, pdeDataManager, refSimSymbolTable, refDataManager, varsToCompare, testCriteria.getMaxAbsError(), testCriteria.getMaxRelError(), refVCDocumentAndSimInfo.getVCDocument(), getDataInfoProvider(refVCDocumentAndSimInfo.getVCDocument(), refDataManager.getPDEDataContext(), refSim.getName()), testDoc, getDataInfoProvider(testDoc, pdeDataManager.getPDEDataContext(), testSim.getName()));
// Failed var summaries
failVarSummaries = simCompSummary.getFailingVariableComparisonSummaries(absErr, relErr);
allVarSummaries = simCompSummary.getVariableComparisonSummaries();
if (failVarSummaries.length > 0) {
simReportStatus = TestCriteriaNew.TCRIT_STATUS_FAILEDVARS;
// Failed simulation
reportTCBuffer.append("\t\tTolerance test FAILED \n");
reportTCBuffer.append("\t\tFailed Variables : \n");
for (int m = 0; m < failVarSummaries.length; m++) {
reportTCBuffer.append("\t\t\t" + failVarSummaries[m].toShortString() + "\n");
}
} else {
simReportStatus = TestCriteriaNew.TCRIT_STATUS_PASSED;
reportTCBuffer.append("\t\tTolerance test PASSED \n");
}
reportTCBuffer.append("\t\tPassed Variables : \n");
// Check if varSummary exists in failed summaries list. If not, simulation passed.
for (int m = 0; m < allVarSummaries.length; m++) {
if (!BeanUtils.arrayContains(failVarSummaries, allVarSummaries[m])) {
reportTCBuffer.append("\t\t\t" + allVarSummaries[m].toShortString() + "\n");
}
}
}
} else {
// NON-SPATIAL CASE
ODEDataManager odeDataManager = (ODEDataManager) simDataManager;
ODESolverResultSet numericalResultSet = odeDataManager.getODESolverResultSet();
// Get EXACT result set if test case type is EXACT, Compare with numerical
if (testCase.getType().equals(TestCaseNew.EXACT) || testCase.getType().equals(TestCaseNew.EXACT_STEADY)) {
ODESolverResultSet exactResultSet = MathTestingUtilities.getExactResultSet(testSim.getMathDescription(), timeArray, testSim.getSolverTaskDescription().getSensitivityParameter());
String[] varsToCompare = getVariableNamesToCompare(simSymbolTable, simSymbolTable);
SimulationComparisonSummary simCompSummary_exact = MathTestingUtilities.compareResultSets(numericalResultSet, exactResultSet, varsToCompare, testCase.getType(), testCriteria.getMaxAbsError(), testCriteria.getMaxRelError());
// Get all the variable comparison summaries and the failed ones to print out report for EXACT solution comparison.
failVarSummaries = simCompSummary_exact.getFailingVariableComparisonSummaries(absErr, relErr);
allVarSummaries = simCompSummary_exact.getVariableComparisonSummaries();
if (failVarSummaries.length > 0) {
simReportStatus = TestCriteriaNew.TCRIT_STATUS_FAILEDVARS;
// Failed simulation
reportTCBuffer.append("\t\tTolerance test FAILED \n");
reportTCBuffer.append("\t\tFailed Variables : \n");
for (int m = 0; m < failVarSummaries.length; m++) {
reportTCBuffer.append("\t\t\t" + failVarSummaries[m].toShortString() + "\n");
}
} else {
simReportStatus = TestCriteriaNew.TCRIT_STATUS_PASSED;
reportTCBuffer.append("\t\tTolerance test PASSED \n");
}
reportTCBuffer.append("\t\tPassed Variables : \n");
// Check if varSummary exists in failed summaries list. If not, simulation passed.
for (int m = 0; m < allVarSummaries.length; m++) {
if (!BeanUtils.arrayContains(failVarSummaries, allVarSummaries[m])) {
reportTCBuffer.append("\t\t\t" + allVarSummaries[m].toShortString() + "\n");
}
}
// Get CONSTRUCTED result set if test case type is CONSTRUCTED , compare with numerical
} else if (testCase.getType().equals(TestCaseNew.CONSTRUCTED)) {
ODESolverResultSet constructedResultSet = MathTestingUtilities.getConstructedResultSet(testSim.getMathDescription(), timeArray);
String[] varsToCompare = getVariableNamesToCompare(simSymbolTable, simSymbolTable);
SimulationComparisonSummary simCompSummary_constr = MathTestingUtilities.compareResultSets(numericalResultSet, constructedResultSet, varsToCompare, testCase.getType(), testCriteria.getMaxAbsError(), testCriteria.getMaxRelError());
// Get all the variable comparison summaries and the failed ones to print out report for CONSTRUCTED solution comparison.
failVarSummaries = simCompSummary_constr.getFailingVariableComparisonSummaries(absErr, relErr);
allVarSummaries = simCompSummary_constr.getVariableComparisonSummaries();
if (failVarSummaries.length > 0) {
simReportStatus = TestCriteriaNew.TCRIT_STATUS_FAILEDVARS;
// Failed simulation
reportTCBuffer.append("\t\tTolerance test FAILED \n");
reportTCBuffer.append("\t\tFailed Variables : \n");
for (int m = 0; m < failVarSummaries.length; m++) {
reportTCBuffer.append("\t\t\t" + failVarSummaries[m].toShortString() + "\n");
}
} else {
simReportStatus = TestCriteriaNew.TCRIT_STATUS_PASSED;
reportTCBuffer.append("\t\tTolerance test PASSED \n");
}
reportTCBuffer.append("\t\tPassed Variables : \n");
// Check if varSummary exists in failed summaries list. If not, simulation passed.
for (int m = 0; m < allVarSummaries.length; m++) {
if (!BeanUtils.arrayContains(failVarSummaries, allVarSummaries[m])) {
reportTCBuffer.append("\t\t\t" + allVarSummaries[m].toShortString() + "\n");
}
}
} 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");
}
SimulationSymbolTable refSimSymbolTable = new SimulationSymbolTable(refSim, 0);
String[] varsToTest = getVariableNamesToCompare(simSymbolTable, refSimSymbolTable);
VCDataIdentifier refVcdID = new VCSimulationDataIdentifier(refVCDocumentAndSimInfo.getSimInfo().getAuthoritativeVCSimulationIdentifier(), 0);
ODEDataManager refDataManager = (ODEDataManager) getRequestManager().getDataManager(null, refVcdID, refSim.isSpatial());
ODESolverResultSet referenceResultSet = refDataManager.getODESolverResultSet();
SimulationComparisonSummary simCompSummary_regr = null;
int interpolationOrder = 1;
SolverTaskDescription solverTaskDescription = refSim.getSolverTaskDescription();
if (solverTaskDescription.getOutputTimeSpec().isDefault() && ((DefaultOutputTimeSpec) solverTaskDescription.getOutputTimeSpec()).getKeepEvery() == 1) {
SolverDescription solverDescription = solverTaskDescription.getSolverDescription();
if ((!solverDescription.supportsAll(SolverDescription.DiscontinutiesFeatures)) || !refSim.getMathDescription().hasDiscontinuities()) {
interpolationOrder = solverDescription.getTimeOrder();
}
}
simCompSummary_regr = MathTestingUtilities.compareUnEqualResultSets(numericalResultSet, referenceResultSet, varsToTest, testCriteria.getMaxAbsError(), testCriteria.getMaxRelError(), interpolationOrder);
// Get all the variable comparison summaries and the failed ones to print out report for CONSTRUCTED solution comparison.
failVarSummaries = simCompSummary_regr.getFailingVariableComparisonSummaries(absErr, relErr);
allVarSummaries = simCompSummary_regr.getVariableComparisonSummaries();
if (failVarSummaries.length > 0) {
simReportStatus = TestCriteriaNew.TCRIT_STATUS_FAILEDVARS;
// Failed simulation
reportTCBuffer.append("\t\tTolerance test FAILED \n");
reportTCBuffer.append("\t\tFailed Variables : \n");
for (int m = 0; m < failVarSummaries.length; m++) {
reportTCBuffer.append("\t\t\t" + failVarSummaries[m].toShortString() + "\n");
}
} else {
simReportStatus = TestCriteriaNew.TCRIT_STATUS_PASSED;
reportTCBuffer.append("\t\tTolerance test PASSED \n");
}
reportTCBuffer.append("\t\tPassed Variables : \n");
// Check if varSummary exists in failed summaries list. If not, simulation passed.
for (int m = 0; m < allVarSummaries.length; m++) {
if (!BeanUtils.arrayContains(failVarSummaries, allVarSummaries[m])) {
reportTCBuffer.append("\t\t\t" + allVarSummaries[m].toShortString() + "\n");
}
}
}
}
}
}
} catch (Throwable e) {
simReportStatus = TestCriteriaNew.TCRIT_STATUS_RPERROR;
simReportStatusMessage = e.getClass().getName() + " " + e.getMessage();
reportTCBuffer.append("\t\t" + simReportStatusMessage + "\n");
e.printStackTrace(System.out);
}
if (userSelectedRefSimInfo == null) {
try {
// Remove any test results already present for testCriteria
RemoveTestResultsOP removeResultsOP = new RemoveTestResultsOP(new BigDecimal[] { testCriteria.getTCritKey() });
// testResultsOPsVector.add(removeResultsOP);
getRequestManager().getDocumentManager().doTestSuiteOP(removeResultsOP);
// Create new AddTestREsultsOP object for the current simulation./testCriteria.
if (allVarSummaries != null) {
AddTestResultsOP testResultsOP = new AddTestResultsOP(testCriteria.getTCritKey(), allVarSummaries);
// testResultsOPsVector.add(testResultsOP);
// Write the testResults for simulation/TestCriteria into the database ...
getRequestManager().getDocumentManager().doTestSuiteOP(testResultsOP);
}
// Update report status
updateTCritStatus(testCriteria, simReportStatus, simReportStatusMessage);
} catch (Throwable e) {
reportTCBuffer.append("\t\tUpdate DB Results failed. " + e.getClass().getName() + " " + e.getMessage() + "\n");
try {
getRequestManager().getDocumentManager().doTestSuiteOP(new EditTestCriteriaOPReportStatus(testCriteria.getTCritKey(), TestCriteriaNew.TCRIT_STATUS_RPERROR, e.getClass().getName() + " " + e.getMessage()));
} catch (Throwable e2) {
// Nothing more can be done
}
}
}
return reportTCBuffer.toString();
}
use of cbit.vcell.biomodel.BioModel in project vcell by virtualcell.
the class TestingFrameworkWindowManager method selectRefSimInfo.
/**
* Insert the method's description here.
* Creation date: (7/15/2004 4:48:36 PM)
* @param newTestingFrameworkWindowPanel cbit.vcell.client.desktop.TestingFrameworkWindowPanel
*/
public Object[] selectRefSimInfo(BioModelInfo bmInfo, String appName) throws DataAccessException {
if (bmInfo == null || appName == null || appName.length() == 0) {
PopupGenerator.showErrorDialog(TestingFrameworkWindowManager.this, "Selected Reference BioModel is null, choose a reference BioModel before choosing simulation!");
return null;
}
// code for obtaining siminfos from Biomodel and displaying it as a list
// and displaying the siminfo in the label
SimulationContext simContext = null;
BioModel bioModel = getRequestManager().getDocumentManager().getBioModel(bmInfo);
for (int i = 0; i < bioModel.getSimulationContexts().length; i += 1) {
if (bioModel.getSimulationContexts()[i].getName().equals(appName)) {
simContext = bioModel.getSimulationContexts()[i];
break;
}
}
if (simContext != null) {
SimulationInfo simInfo = selectSimInfoPrivate(bioModel.getSimulations(simContext));
return new Object[] { simContext.getName(), simInfo };
} else {
PopupGenerator.showErrorDialog(TestingFrameworkWindowManager.this, "No simcontext found for biomodel " + bmInfo + " app=" + appName);
return null;
}
}
Aggregations