Search in sources :

Example 16 with DefaultOutputTimeSpec

use of cbit.vcell.solver.DefaultOutputTimeSpec in project vcell by virtualcell.

the class OutputOptionsPanel method actionOutputOptionButtonState.

private void actionOutputOptionButtonState(java.awt.event.ActionEvent actionEvent) {
    try {
        if (solverTaskDescription == null) {
            return;
        }
        OutputTimeSpec outputTimeSpec = solverTaskDescription.getOutputTimeSpec();
        if (actionEvent.getSource() == getDefaultOutputRadioButton() && !outputTimeSpec.isDefault()) {
            solverTaskDescription.setOutputTimeSpec(new DefaultOutputTimeSpec());
        } else if (actionEvent.getSource() == getUniformOutputRadioButton() && !outputTimeSpec.isUniform()) {
            double outputTime = 0.0;
            if (solverTaskDescription.getSolverDescription().isSemiImplicitPdeSolver()) {
                String floatStr = "" + (float) (((DefaultOutputTimeSpec) outputTimeSpec).getKeepEvery() * solverTaskDescription.getTimeStep().getDefaultTimeStep());
                outputTime = Double.parseDouble(floatStr);
            } else {
                TimeBounds timeBounds = solverTaskDescription.getTimeBounds();
                Range outputTimeRange = NumberUtils.getDecimalRange(timeBounds.getStartingTime(), timeBounds.getEndingTime() / 100, true, true);
                outputTime = outputTimeRange.getMax();
            }
            solverTaskDescription.setOutputTimeSpec(new UniformOutputTimeSpec(outputTime));
        } else if (actionEvent.getSource() == getExplicitOutputRadioButton() && !outputTimeSpec.isExplicit()) {
            TimeBounds timeBounds = solverTaskDescription.getTimeBounds();
            solverTaskDescription.setOutputTimeSpec(new ExplicitOutputTimeSpec(new double[] { timeBounds.getStartingTime(), timeBounds.getEndingTime() }));
        }
    } catch (java.lang.Throwable ivjExc) {
        handleException(ivjExc);
    }
}
Also used : TimeBounds(cbit.vcell.solver.TimeBounds) DefaultOutputTimeSpec(cbit.vcell.solver.DefaultOutputTimeSpec) UniformOutputTimeSpec(cbit.vcell.solver.UniformOutputTimeSpec) ExplicitOutputTimeSpec(cbit.vcell.solver.ExplicitOutputTimeSpec) OutputTimeSpec(cbit.vcell.solver.OutputTimeSpec) ExplicitOutputTimeSpec(cbit.vcell.solver.ExplicitOutputTimeSpec) UniformOutputTimeSpec(cbit.vcell.solver.UniformOutputTimeSpec) Range(org.vcell.util.Range) DefaultOutputTimeSpec(cbit.vcell.solver.DefaultOutputTimeSpec)

Example 17 with DefaultOutputTimeSpec

use of cbit.vcell.solver.DefaultOutputTimeSpec in project vcell by virtualcell.

the class OutputOptionsPanel method setNewOutputOption.

/**
 * Comment
 */
private void setNewOutputOption() {
    try {
        OutputTimeSpec ots = null;
        if (getDefaultOutputRadioButton().isSelected()) {
            int keepEvery = Integer.parseInt(getKeepEveryTextField().getText());
            if (solverTaskDescription.getSolverDescription().isSemiImplicitPdeSolver()) {
                ots = new DefaultOutputTimeSpec(keepEvery);
            } else {
                int keepAtMost = Integer.parseInt(getKeepAtMostTextField().getText());
                ots = new DefaultOutputTimeSpec(keepEvery, keepAtMost);
            }
        } else if (getUniformOutputRadioButton().isSelected()) {
            double outputTime = Double.parseDouble(getOutputTimeStepTextField().getText());
            ots = new UniformOutputTimeSpec(outputTime);
        } else if (getExplicitOutputRadioButton().isSelected()) {
            ots = ExplicitOutputTimeSpec.fromString(getOutputTimesTextField().getText());
        }
        try {
            solverTaskDescription.setOutputTimeSpec(ots);
        } catch (java.beans.PropertyVetoException e) {
            e.printStackTrace(System.out);
            throw new RuntimeException(e.getMessage());
        }
    } catch (Exception e) {
        DialogUtils.showErrorDialog(this, e.getMessage(), e);
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) DefaultOutputTimeSpec(cbit.vcell.solver.DefaultOutputTimeSpec) UniformOutputTimeSpec(cbit.vcell.solver.UniformOutputTimeSpec) ExplicitOutputTimeSpec(cbit.vcell.solver.ExplicitOutputTimeSpec) OutputTimeSpec(cbit.vcell.solver.OutputTimeSpec) UniformOutputTimeSpec(cbit.vcell.solver.UniformOutputTimeSpec) DefaultOutputTimeSpec(cbit.vcell.solver.DefaultOutputTimeSpec) PropertyVetoException(java.beans.PropertyVetoException)

Example 18 with DefaultOutputTimeSpec

use of cbit.vcell.solver.DefaultOutputTimeSpec 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();
}
Also used : MathModel(cbit.vcell.mathmodel.MathModel) AddTestCasesOPMathModel(cbit.vcell.numericstest.AddTestCasesOPMathModel) TestCaseNewMathModel(cbit.vcell.numericstest.TestCaseNewMathModel) TestCriteriaNewMathModel(cbit.vcell.numericstest.TestCriteriaNewMathModel) EditTestCriteriaOPMathModel(cbit.vcell.numericstest.EditTestCriteriaOPMathModel) AddTestCriteriaOPMathModel(cbit.vcell.numericstest.AddTestCriteriaOPMathModel) SolverDescription(cbit.vcell.solver.SolverDescription) TestCriteriaNewBioModel(cbit.vcell.numericstest.TestCriteriaNewBioModel) NonspatialStochSimOptions(cbit.vcell.solver.NonspatialStochSimOptions) ClientDocumentManager(cbit.vcell.clientdb.ClientDocumentManager) TFGenerateReport(cbit.vcell.client.task.TFGenerateReport) TestCaseNewBioModel(cbit.vcell.numericstest.TestCaseNewBioModel) RemoveTestResultsOP(cbit.vcell.numericstest.RemoveTestResultsOP) TestCriteriaNewMathModel(cbit.vcell.numericstest.TestCriteriaNewMathModel) AddTestResultsOP(cbit.vcell.numericstest.AddTestResultsOP) SimulationComparisonSummary(cbit.vcell.solver.test.SimulationComparisonSummary) ODESolverResultSet(cbit.vcell.solver.ode.ODESolverResultSet) VariableComparisonSummary(cbit.vcell.solver.test.VariableComparisonSummary) SolverTaskDescription(cbit.vcell.solver.SolverTaskDescription) EditTestCriteriaOPReportStatus(cbit.vcell.numericstest.EditTestCriteriaOPReportStatus) VCDocument(org.vcell.util.document.VCDocument) SimulationSymbolTable(cbit.vcell.solver.SimulationSymbolTable) BioModelInfo(org.vcell.util.document.BioModelInfo) PDEDataManager(cbit.vcell.simdata.PDEDataManager) ODEDataManager(cbit.vcell.simdata.ODEDataManager) DataManager(cbit.vcell.simdata.DataManager) MathModelInfo(org.vcell.util.document.MathModelInfo) VCSimulationDataIdentifier(cbit.vcell.solver.VCSimulationDataIdentifier) ObjectNotFoundException(org.vcell.util.ObjectNotFoundException) DataAccessException(org.vcell.util.DataAccessException) UserCancelException(org.vcell.util.UserCancelException) Simulation(cbit.vcell.solver.Simulation) PDEDataManager(cbit.vcell.simdata.PDEDataManager) TestCaseNewBioModel(cbit.vcell.numericstest.TestCaseNewBioModel) TestCriteriaNewBioModel(cbit.vcell.numericstest.TestCriteriaNewBioModel) AddTestCasesOPBioModel(cbit.vcell.numericstest.AddTestCasesOPBioModel) BioModel(cbit.vcell.biomodel.BioModel) EditTestCriteriaOPBioModel(cbit.vcell.numericstest.EditTestCriteriaOPBioModel) AddTestCriteriaOPBioModel(cbit.vcell.numericstest.AddTestCriteriaOPBioModel) TestCaseNewMathModel(cbit.vcell.numericstest.TestCaseNewMathModel) ODEDataManager(cbit.vcell.simdata.ODEDataManager) VCDataIdentifier(org.vcell.util.document.VCDataIdentifier) DefaultOutputTimeSpec(cbit.vcell.solver.DefaultOutputTimeSpec) SimulationInfo(cbit.vcell.solver.SimulationInfo)

Example 19 with DefaultOutputTimeSpec

use of cbit.vcell.solver.DefaultOutputTimeSpec in project vcell by virtualcell.

the class XmlReader method getSolverTaskDescription.

/**
 * This method returns a SolverTaskDescription Object from a XML Element.
 * Creation date: (5/22/2001 10:51:23 AM)
 * @return cbit.vcell.solver.SolverTaskDescription
 * @param param org.jdom.Element
 * @param simulation cbit.vcell.solver.Simulation
 */
private SolverTaskDescription getSolverTaskDescription(Element param, Simulation simulation) throws XmlParseException {
    // *** create new SolverTaskDescription ***
    SolverTaskDescription solverTaskDesc = new SolverTaskDescription(simulation);
    // Added July 22nd, 2007, used as condition for stochSimOptions or stochHybridOprtions
    SolverDescription sd = null;
    // Retrieve attributes
    String taskType = param.getAttributeValue(XMLTags.TaskTypeTag);
    int keepEvery = -1;
    int keepAtMost = -1;
    if (param.getAttributeValue(XMLTags.KeepEveryTag) != null) {
        keepEvery = Integer.parseInt(param.getAttributeValue(XMLTags.KeepEveryTag));
        keepAtMost = Integer.parseInt(param.getAttributeValue(XMLTags.KeepAtMostTag));
    }
    boolean useSymJacob = new Boolean(param.getAttributeValue(XMLTags.UseSymbolicJacobianAttrTag)).booleanValue();
    String solverName = param.getAttributeValue(XMLTags.SolverNameTag);
    // get sentivity parameter
    Element sensparamElement = param.getChild(XMLTags.ConstantTag, vcNamespace);
    Constant sensitivityparam = null;
    if (sensparamElement != null) {
        sensitivityparam = getConstant(sensparamElement);
    }
    // set Attributes
    try {
        // set solver
        sd = SolverDescription.fromDatabaseName(solverName);
        if (sd == null) {
            System.err.println("====================================== couldn't find solver description name ==========================================");
        }
        solverTaskDesc.setSolverDescription(sd);
        if (taskType.equalsIgnoreCase(XMLTags.UnsteadyTag)) {
            solverTaskDesc.setTaskType(SolverTaskDescription.TASK_UNSTEADY);
        } else if (taskType.equalsIgnoreCase(XMLTags.SteadyTag)) {
            solverTaskDesc.setTaskType(SolverTaskDescription.TASK_STEADY);
        } else {
            throw new XmlParseException("Unexpected task type: " + taskType);
        }
    } catch (java.beans.PropertyVetoException e) {
        e.printStackTrace();
        throw new XmlParseException("A PropertyVetoException was fired when setting the taskType: " + taskType, e);
    }
    int numProcessors = parseIntWithDefault(param, XMLTags.NUM_PROCESSORS, 1);
    try {
        solverTaskDesc.setNumProcessors(numProcessors);
        solverTaskDesc.setUseSymbolicJacobian(useSymJacob);
        // get TimeBound
        solverTaskDesc.setTimeBounds(getTimeBounds(param.getChild(XMLTags.TimeBoundTag, vcNamespace)));
        // get TimeStep
        solverTaskDesc.setTimeStep(getTimeStep(param.getChild(XMLTags.TimeStepTag, vcNamespace)));
        // get ErrorTolerance
        solverTaskDesc.setErrorTolerance(getErrorTolerance(param.getChild(XMLTags.ErrorToleranceTag, vcNamespace)));
        // get StochSimOptions
        if (simulation != null && simulation.getMathDescription() != null) {
            if (simulation.getMathDescription().isNonSpatialStoch() && param.getChild(XMLTags.StochSimOptionsTag, vcNamespace) != null) {
                // Amended July 22nd, 2007 to read either stochSimOptions or stochHybridOptions
                solverTaskDesc.setStochOpt(getStochSimOptions(param.getChild(XMLTags.StochSimOptionsTag, vcNamespace)));
                if (sd != null && !sd.equals(SolverDescription.StochGibson)) {
                    solverTaskDesc.setStochHybridOpt(getStochHybridOptions(param.getChild(XMLTags.StochSimOptionsTag, vcNamespace)));
                }
            }
        }
        // get OutputOptions
        if (keepEvery != -1) {
            solverTaskDesc.setOutputTimeSpec(new DefaultOutputTimeSpec(keepEvery, keepAtMost));
        }
        OutputTimeSpec ots = getOutputTimeSpec(param.getChild(XMLTags.OutputOptionsTag, vcNamespace));
        if (ots != null) {
            solverTaskDesc.setOutputTimeSpec(getOutputTimeSpec(param.getChild(XMLTags.OutputOptionsTag, vcNamespace)));
        }
        // set SensitivityParameter
        solverTaskDesc.setSensitivityParameter(sensitivityparam);
        // set StopAtSpatiallyUniform
        Element stopSpatiallyElement = param.getChild(XMLTags.StopAtSpatiallyUniform, vcNamespace);
        if (stopSpatiallyElement != null) {
            Element errTolElement = stopSpatiallyElement.getChild(XMLTags.ErrorToleranceTag, vcNamespace);
            if (errTolElement != null) {
                solverTaskDesc.setStopAtSpatiallyUniformErrorTolerance(getErrorTolerance(errTolElement));
            }
        }
        String runParameterScanSeriallyAttributeValue = param.getAttributeValue(XMLTags.RunParameterScanSerially);
        if (runParameterScanSeriallyAttributeValue != null) {
            solverTaskDesc.setSerialParameterScan(new Boolean(runParameterScanSeriallyAttributeValue).booleanValue());
        }
        Element nfsimSimulationOptionsElement = param.getChild(XMLTags.NFSimSimulationOptions, vcNamespace);
        if (nfsimSimulationOptionsElement != null) {
            NFsimSimulationOptions nfsimSimulationOptions = getNFSimSimulationOptions(nfsimSimulationOptionsElement);
            solverTaskDesc.setNFSimSimulationOptions(nfsimSimulationOptions);
        }
        Element smoldySimulationOptionsElement = param.getChild(XMLTags.SmoldynSimulationOptions, vcNamespace);
        if (smoldySimulationOptionsElement != null) {
            SmoldynSimulationOptions smoldynSimulationOptions = getSmoldySimulationOptions(smoldySimulationOptionsElement);
            solverTaskDesc.setSmoldynSimulationOptions(smoldynSimulationOptions);
        }
        Element sundialsPdeSolverOptionsElement = param.getChild(XMLTags.SundialsSolverOptions, vcNamespace);
        if (sundialsPdeSolverOptionsElement != null) {
            SundialsPdeSolverOptions sundialsPdeSolverOptions = getSundialsPdeSolverOptions(sundialsPdeSolverOptionsElement);
            solverTaskDesc.setSundialsPdeSolverOptions(sundialsPdeSolverOptions);
        }
        Element chomboElement = param.getChild(XMLTags.ChomboSolverSpec, vcNamespace);
        if (chomboElement != null) {
            ChomboSolverSpec chombo = getChomboSolverSpec(solverTaskDesc, chomboElement, simulation.getMathDescription().getGeometry().getDimension());
            solverTaskDesc.setChomboSolverSpec(chombo);
        }
        Element mbElement = param.getChild(XMLTags.MovingBoundarySolverOptionsTag, vcNamespace);
        if (mbElement != null) {
            MovingBoundarySolverOptions mb = getMovingBoundarySolverOptions(solverTaskDesc, mbElement);
            solverTaskDesc.setMovingBoundarySolverOptions(mb);
        }
    } catch (java.beans.PropertyVetoException e) {
        e.printStackTrace();
        throw new XmlParseException(e);
    }
    return solverTaskDesc;
}
Also used : NFsimSimulationOptions(cbit.vcell.solver.NFsimSimulationOptions) SolverDescription(cbit.vcell.solver.SolverDescription) MovingBoundarySolverOptions(cbit.vcell.solvers.mb.MovingBoundarySolverOptions) SundialsPdeSolverOptions(cbit.vcell.solver.SundialsPdeSolverOptions) MacroscopicRateConstant(cbit.vcell.math.MacroscopicRateConstant) Constant(cbit.vcell.math.Constant) Element(org.jdom.Element) ChomboSolverSpec(org.vcell.chombo.ChomboSolverSpec) PropertyVetoException(java.beans.PropertyVetoException) SmoldynSimulationOptions(cbit.vcell.solver.SmoldynSimulationOptions) ExplicitOutputTimeSpec(cbit.vcell.solver.ExplicitOutputTimeSpec) OutputTimeSpec(cbit.vcell.solver.OutputTimeSpec) UniformOutputTimeSpec(cbit.vcell.solver.UniformOutputTimeSpec) DefaultOutputTimeSpec(cbit.vcell.solver.DefaultOutputTimeSpec) SolverTaskDescription(cbit.vcell.solver.SolverTaskDescription) DefaultOutputTimeSpec(cbit.vcell.solver.DefaultOutputTimeSpec)

Example 20 with DefaultOutputTimeSpec

use of cbit.vcell.solver.DefaultOutputTimeSpec in project vcell by virtualcell.

the class SimulationListTableModel method setValueAt.

/**
 * Insert the method's description here.
 * Creation date: (7/12/2004 2:01:23 PM)
 * @param aValue java.lang.Object
 * @param rowIndex int
 * @param columnIndex int
 */
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
    Simulation simulation = getValueAt(rowIndex);
    try {
        switch(columnIndex) {
            case COLUMN_NAME:
                if (aValue instanceof String) {
                    String newName = (String) aValue;
                    if (!simulation.getName().equals(newName)) {
                        simulation.setName(newName);
                    }
                }
                break;
            case COLUMN_ENDTIME:
                if (aValue instanceof Double) {
                    SolverTaskDescription solverTaskDescription = simulation.getSolverTaskDescription();
                    double newEndTime = (Double) aValue;
                    if (newEndTime != solverTaskDescription.getTimeBounds().getEndingTime()) {
                        ClientTaskManager.changeEndTime(ownerTable, solverTaskDescription, newEndTime);
                        simulation.setIsDirty(true);
                    }
                }
                break;
            case COLUMN_OUTPUT:
                if (aValue instanceof String) {
                    SolverTaskDescription solverTaskDescription = simulation.getSolverTaskDescription();
                    OutputTimeSpec ots = solverTaskDescription.getOutputTimeSpec();
                    OutputTimeSpec newOts = null;
                    if (ots instanceof DefaultOutputTimeSpec) {
                        int newValue = Integer.parseInt((String) aValue);
                        newOts = new DefaultOutputTimeSpec(newValue, ((DefaultOutputTimeSpec) ots).getKeepAtMost());
                    } else if (ots instanceof UniformOutputTimeSpec) {
                        try {
                            boolean bValid = true;
                            double outputTime = Double.parseDouble((String) aValue);
                            if (solverTaskDescription.getOutputTimeSpec().isUniform()) {
                                if (solverTaskDescription.getSolverDescription().hasVariableTimestep()) {
                                    newOts = new UniformOutputTimeSpec(outputTime);
                                } else {
                                    double timeStep = solverTaskDescription.getTimeStep().getDefaultTimeStep();
                                    double suggestedInterval = outputTime;
                                    if (outputTime < timeStep) {
                                        suggestedInterval = timeStep;
                                        bValid = false;
                                    } else {
                                        if (!BeanUtils.isIntegerMultiple(outputTime, timeStep)) {
                                            double n = outputTime / timeStep;
                                            int intn = (int) Math.round(n);
                                            suggestedInterval = (intn * timeStep);
                                            if (suggestedInterval != outputTime) {
                                                bValid = false;
                                            }
                                        }
                                    }
                                    if (bValid) {
                                        newOts = new UniformOutputTimeSpec(outputTime);
                                    } else {
                                        String ret = PopupGenerator.showWarningDialog(ownerTable, "Output Interval", "Output Interval must " + "be integer multiple of time step.\n\nChange Output Interval to " + suggestedInterval + "?", new String[] { UserMessage.OPTION_YES, UserMessage.OPTION_NO }, UserMessage.OPTION_YES);
                                        if (ret.equals(UserMessage.OPTION_YES)) {
                                            newOts = new UniformOutputTimeSpec(suggestedInterval);
                                        }
                                    }
                                }
                            }
                        } catch (NumberFormatException ex) {
                            DialogUtils.showErrorDialog(ownerTable, "Wrong number format " + ex.getMessage().toLowerCase());
                        }
                    } else if (ots instanceof ExplicitOutputTimeSpec) {
                        newOts = ExplicitOutputTimeSpec.fromString((String) aValue);
                    }
                    if (newOts != null && !newOts.compareEqual(ots)) {
                        solverTaskDescription.setOutputTimeSpec(newOts);
                        simulation.setIsDirty(true);
                    }
                }
                break;
        }
    } catch (Exception ex) {
        ex.printStackTrace(System.out);
        PopupGenerator.showErrorDialog(ownerTable, ex.getMessage());
    }
}
Also used : ExplicitOutputTimeSpec(cbit.vcell.solver.ExplicitOutputTimeSpec) DefaultOutputTimeSpec(cbit.vcell.solver.DefaultOutputTimeSpec) UniformOutputTimeSpec(cbit.vcell.solver.UniformOutputTimeSpec) OutputTimeSpec(cbit.vcell.solver.OutputTimeSpec) ExplicitOutputTimeSpec(cbit.vcell.solver.ExplicitOutputTimeSpec) Simulation(cbit.vcell.solver.Simulation) UniformOutputTimeSpec(cbit.vcell.solver.UniformOutputTimeSpec) SolverTaskDescription(cbit.vcell.solver.SolverTaskDescription) DefaultOutputTimeSpec(cbit.vcell.solver.DefaultOutputTimeSpec)

Aggregations

DefaultOutputTimeSpec (cbit.vcell.solver.DefaultOutputTimeSpec)24 UniformOutputTimeSpec (cbit.vcell.solver.UniformOutputTimeSpec)15 OutputTimeSpec (cbit.vcell.solver.OutputTimeSpec)13 SolverTaskDescription (cbit.vcell.solver.SolverTaskDescription)13 ExplicitOutputTimeSpec (cbit.vcell.solver.ExplicitOutputTimeSpec)8 Simulation (cbit.vcell.solver.Simulation)7 TimeBounds (cbit.vcell.solver.TimeBounds)6 ExpressionException (cbit.vcell.parser.ExpressionException)5 ErrorTolerance (cbit.vcell.solver.ErrorTolerance)5 SolverDescription (cbit.vcell.solver.SolverDescription)5 MathException (cbit.vcell.math.MathException)4 SolverException (cbit.vcell.solver.SolverException)4 Constant (cbit.vcell.math.Constant)3 SubDomain (cbit.vcell.math.SubDomain)3 Expression (cbit.vcell.parser.Expression)3 NonspatialStochSimOptions (cbit.vcell.solver.NonspatialStochSimOptions)3 SimulationSymbolTable (cbit.vcell.solver.SimulationSymbolTable)3 File (java.io.File)3 Geometry (cbit.vcell.geometry.Geometry)2 JumpProcess (cbit.vcell.math.JumpProcess)2