Search in sources :

Example 1 with NonspatialStochSimOptions

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

the class SimulationSummaryPanel method displayTask.

/**
 * Comment
 */
private void displayTask() {
    SolverTaskDescription solverTaskDescription = getSimulation().getSolverTaskDescription();
    try {
        NonspatialStochSimOptions stochOpt = solverTaskDescription.getStochOpt();
        if (stochOpt != null && stochOpt.getNumOfTrials() > 1) {
            if (stochOpt.isHistogram()) {
                getJLabelOutput().setText("Histogram with " + stochOpt.getNumOfTrials() + " Trials(@last time point)");
            } else {
                getJLabelOutput().setText("Average of " + stochOpt.getNumOfTrials() + " trajectories; " + solverTaskDescription.getOutputTimeSpec().getDescription());
            }
        } else {
            // gcwtodo
            String text = solverTaskDescription.getOutputTimeSpec().getShortDescription();
            if (solverTaskDescription.getSolverDescription().isChomboSolver()) {
                text = "Variable";
                if (solverTaskDescription.getChomboSolverSpec().getTimeIntervalList().size() == 1) {
                    text = "Every " + solverTaskDescription.getChomboSolverSpec().getLastTimeInterval().getOutputTimeStep() + "s";
                }
            } else if (solverTaskDescription.getOutputTimeSpec().isDefault() && !solverTaskDescription.getSolverDescription().isSemiImplicitPdeSolver() && !solverTaskDescription.getSolverDescription().equals(SolverDescription.StochGibson)) {
                text += ", at most " + ((DefaultOutputTimeSpec) solverTaskDescription.getOutputTimeSpec()).getKeepAtMost();
            }
            getJLabelOutput().setText(text);
        }
    } catch (Exception exc) {
        exc.printStackTrace(System.out);
        getJLabelOutput().setText("");
    }
    SolverDescription solverDescription = solverTaskDescription.getSolverDescription();
    try {
        ErrorTolerance errorTolerance = solverTaskDescription.getErrorTolerance();
        TimeStep timeStep = solverTaskDescription.getTimeStep();
        getJLabelRelTol().setText("Rel tol");
        getJLabelAbsTol().setText("Abs tol");
        getJLabel12().setText("Timestep");
        getJLabelRelTol().setEnabled(false);
        getJLabelAbsTol().setEnabled(false);
        getJLabel12().setEnabled(false);
        getJLabel10().setText("Sensitivity Analysis");
        getJLabel10().setEnabled(true);
        if (solverDescription.equals(SolverDescription.StochGibson)) {
            getJLabel12().setEnabled(false);
            getJLabelTimestep().setText("");
        } else if (solverDescription.equals(SolverDescription.NFSim)) {
            TimeBounds tb = solverTaskDescription.getTimeBounds();
            double dtime = tb.getEndingTime() - tb.getStartingTime();
            if (solverTaskDescription.getOutputTimeSpec() instanceof UniformOutputTimeSpec) {
                UniformOutputTimeSpec uots = (UniformOutputTimeSpec) solverTaskDescription.getOutputTimeSpec();
                double interval = uots.getOutputTimeStep();
                int steps = (int) Math.round(dtime / interval);
                getJLabel12().setEnabled(true);
                getJLabel12().setText("Timepoints");
                getJLabelTimestep().setText(steps + "");
            } else if (solverTaskDescription.getOutputTimeSpec() instanceof DefaultOutputTimeSpec) {
                DefaultOutputTimeSpec uots = (DefaultOutputTimeSpec) solverTaskDescription.getOutputTimeSpec();
                getJLabel12().setEnabled(true);
                getJLabel12().setText("End Time");
                getJLabelTimestep().setText(solverTaskDescription.getTimeBounds().getEndingTime() + "");
            } else {
                getJLabel12().setEnabled(false);
                getJLabel12().setText("End Time");
                getJLabelTimestep().setText("na");
            }
            NFsimSimulationOptions nfsso = solverTaskDescription.getNFSimSimulationOptions();
            String utl = "default";
            Integer moleculeDistance = nfsso.getMoleculeDistance();
            if (moleculeDistance != null) {
                utl = moleculeDistance + "";
            }
            getJLabelRelTol().setEnabled(true);
            getJLabelRelTol().setText("Universal Transversal Limit");
            getJLabelRelTolValue().setText(utl);
            String gml = "default";
            Integer maxMoleculesPerType = nfsso.getMaxMoleculesPerType();
            if (maxMoleculesPerType != null) {
                gml = maxMoleculesPerType + "";
            }
            getJLabelAbsTol().setEnabled(true);
            getJLabelAbsTol().setText("Max # of each " + MolecularType.typeName);
            getJLabelAbsTolValue().setText(gml);
        } else if (solverDescription.isNonSpatialStochasticSolver()) {
            getJLabel12().setEnabled(true);
            getJLabel12().setText("Timestep");
            getJLabelTimestep().setText(timeStep.getDefaultTimeStep() + "s");
        } else if (solverDescription.hasVariableTimestep()) {
            getJLabel12().setEnabled(true);
            getJLabel12().setText("Max timestep");
            getJLabelTimestep().setText(timeStep.getMaximumTimeStep() + "s");
            getJLabelRelTol().setEnabled(true);
            getJLabelRelTolValue().setText("" + errorTolerance.getRelativeErrorTolerance());
            getJLabelAbsTol().setEnabled(true);
            getJLabelAbsTolValue().setText("" + errorTolerance.getAbsoluteErrorTolerance());
        } else {
            getJLabel12().setEnabled(true);
            getJLabel12().setText("Timestep");
            if (solverDescription.isChomboSolver()) {
                String text = "Variable";
                if (solverTaskDescription.getChomboSolverSpec().getTimeIntervalList().size() == 1) {
                    text = solverTaskDescription.getChomboSolverSpec().getLastTimeInterval().getTimeStep() + "s";
                }
                getJLabelTimestep().setText(text);
            } else {
                getJLabelTimestep().setText(timeStep.getDefaultTimeStep() + "s");
            }
            if (solverDescription.isSemiImplicitPdeSolver()) {
                getJLabelRelTol().setEnabled(true);
                getJLabelRelTolValue().setText("" + errorTolerance.getRelativeErrorTolerance());
            } else {
                getJLabelRelTol().setEnabled(false);
                getJLabelRelTolValue().setText("");
            }
            getJLabelAbsTol().setEnabled(false);
            getJLabelAbsTolValue().setText("");
        }
    } catch (Exception exc) {
        exc.printStackTrace(System.out);
        getJLabelTimestep().setText("");
        getJLabelRelTolValue().setText("");
        getJLabelAbsTolValue().setText("");
    }
    try {
        boolean bChomboSolver = solverDescription.isChomboSolver();
        getJLabelTitleNumProcessors().setVisible(bChomboSolver);
        getJLabelNumProcessors().setVisible(bChomboSolver);
        if (bChomboSolver) {
            getJLabelNumProcessors().setText(String.valueOf(solverTaskDescription.getNumProcessors()));
        }
        if (getSimulation().isSpatial() || solverDescription.isNonSpatialStochasticSolver()) {
            getJLabelSensitivity().setVisible(false);
            getJLabel10().setVisible(false);
        } else if (solverDescription.equals(SolverDescription.NFSim)) {
            getJLabel10().setText("On-the-fly observ comp.");
            NFsimSimulationOptions nfsso = solverTaskDescription.getNFSimSimulationOptions();
            boolean goc = nfsso.getObservableComputationOff();
            getJLabelSensitivity().setText(goc + "");
        } else {
            getJLabelSensitivity().setVisible(true);
            getJLabel10().setVisible(true);
            Constant param = solverTaskDescription.getSensitivityParameter();
            if (param == null) {
                getJLabelSensitivity().setText("no");
            } else {
                getJLabelSensitivity().setText(param.getName());
            }
        }
    } catch (Exception exc) {
        exc.printStackTrace(System.out);
        getJLabelSensitivity().setText("");
    }
    if (solverDescription.isNonSpatialStochasticSolver()) {
        getJLabelRelTol().setVisible(false);
        getJLabelAbsTol().setVisible(false);
        getJLabelRelTolValue().setVisible(false);
        getJLabelAbsTolValue().setVisible(false);
    } else {
        getJLabelRelTol().setVisible(true);
        getJLabelAbsTol().setVisible(true);
    }
}
Also used : NFsimSimulationOptions(cbit.vcell.solver.NFsimSimulationOptions) SolverDescription(cbit.vcell.solver.SolverDescription) UniformOutputTimeSpec(cbit.vcell.solver.UniformOutputTimeSpec) Constant(cbit.vcell.math.Constant) NonspatialStochSimOptions(cbit.vcell.solver.NonspatialStochSimOptions) PropertyVetoException(java.beans.PropertyVetoException) TimeStep(cbit.vcell.solver.TimeStep) TimeBounds(cbit.vcell.solver.TimeBounds) ErrorTolerance(cbit.vcell.solver.ErrorTolerance) SolverTaskDescription(cbit.vcell.solver.SolverTaskDescription) DefaultOutputTimeSpec(cbit.vcell.solver.DefaultOutputTimeSpec)

Example 2 with NonspatialStochSimOptions

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

the class StochSimOptionsPanel method refresh.

// deals with the visual elements when some selection changes (enable / disable other fields, for example)
private void refresh() {
    if (getSolverTaskDescription() != null) {
        if (!getSolverTaskDescription().getSolverDescription().isNonSpatialStochasticSolver()) {
            setVisible(false);
            return;
        }
    }
    setVisible(true);
    NonspatialStochSimOptions sso = getSolverTaskDescription().getStochOpt();
    long numTrials = sso.getNumOfTrials();
    boolean bHistogram = sso.isHistogram();
    if (numTrials == 1) {
        // 1 trial
        getJTextFieldNumOfTrials().setEnabled(false);
        // getMultiRunButton().setEnabled(false);
        getTrajectoryButton().setSelected(true);
    } else {
        // more than 1 trial
        getJTextFieldNumOfTrials().setEnabled(true);
        // getMultiRunButton().setEnabled(true);
        getJTextFieldNumOfTrials().setText(numTrials + "");
        if (bHistogram) {
            getHistogramButton().setSelected(true);
        } else {
            getMultiRunButton().setSelected(true);
        }
    }
    getMultiRunButton().setEnabled(true);
    getMultiRunButton().setSelected(getMultiRunButton().isSelected() && getSolverTaskDescription().getSolverDescription().equals(SolverDescription.StochGibson));
    getMultiRunButton().setEnabled(getSolverTaskDescription().getSolverDescription().equals(SolverDescription.StochGibson));
    // TODO: temporarily disable the button
    // UNDO THIS WHEN DEVELOPMENT IS COMPLETE
    // getMultiRunButton().setEnabled(false);
    boolean isUseCustomSeed = sso.isUseCustomSeed();
    int customSeed = sso.getCustomSeed();
    getJTextFieldCustomSeed().setEnabled(isUseCustomSeed);
    if (isUseCustomSeed) {
        getCustomizedSeedRadioButton().setSelected(true);
        getJTextFieldCustomSeed().setEnabled(true);
    } else {
        getRandomSeedRadioButton().setSelected(true);
        getJTextFieldCustomSeed().setEnabled(false);
    }
    getJTextFieldCustomSeed().setText(customSeed + "");
    NonspatialStochHybridOptions hybridOptions = getSolverTaskDescription().getStochHybridOpt();
    boolean bHybrid = hybridOptions != null;
    getEpsilonLabel().setEnabled(bHybrid);
    getEpsilonTextField().setEnabled(bHybrid);
    getLambdaLabel().setEnabled(bHybrid);
    getLambdaTextField().setEnabled(bHybrid);
    getMSRToleranceLabel().setEnabled(bHybrid);
    getMSRToleranceTextField().setEnabled(bHybrid);
    getSDEToleranceLabel().setEnabled(bHybrid);
    getSDEToleranceTextField().setEnabled(bHybrid);
    if (bHybrid) {
        getEpsilonTextField().setText(hybridOptions.getEpsilon() + "");
        getLambdaTextField().setText(hybridOptions.getLambda() + "");
        getMSRToleranceTextField().setText(hybridOptions.getMSRTolerance() + "");
        getSDEToleranceTextField().setText(hybridOptions.getSDETolerance() + "");
        if (!getSolverTaskDescription().getSolverDescription().equals(SolverDescription.HybridMilAdaptive)) {
            getSDEToleranceTextField().setEnabled(false);
        }
    }
}
Also used : NonspatialStochSimOptions(cbit.vcell.solver.NonspatialStochSimOptions) NonspatialStochHybridOptions(cbit.vcell.solver.NonspatialStochHybridOptions)

Example 3 with NonspatialStochSimOptions

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

the class StochSimOptionsPanel method setNewOptions.

/**
 * Update parameters for stochastic simulations,
 * including using customized seed or not, customized seed, using tractory or histogram, number of trials (for all, and below four paras for hybrid only)
 * Epsilon : minimum number of molecus required for approximation as a continuous Markow process,
 * Lambda : minimum rate of reaction required for approximation to a continuous Markov process,
 * MSR Tolerance : Maximum allowed effect of slow reactions per numerical integration of the SDEs,
 * SDE Tolerance : Maximum allowed value of the drift and diffusion errors
 */
private void setNewOptions() {
    if (!isVisible()) {
        return;
    }
    try {
        NonspatialStochSimOptions stochOpt = getSolverTaskDescription().getStochOpt();
        long numTrials = 1;
        if (getHistogramButton().isSelected() || getMultiRunButton().isSelected()) {
            numTrials = Integer.parseInt(getJTextFieldNumOfTrials().getText());
        }
        boolean bHistogram = getHistogramButton().isSelected();
        boolean bUseCustomSeed = getCustomizedSeedRadioButton().isSelected();
        int customSeed = stochOpt.getCustomSeed();
        if (bUseCustomSeed) {
            customSeed = (Integer.parseInt(getJTextFieldCustomSeed().getText()));
        }
        NonspatialStochSimOptions nssso = new NonspatialStochSimOptions(bUseCustomSeed, customSeed, numTrials, bHistogram);
        getSolverTaskDescription().setStochOpt(nssso);
        if (!getSolverTaskDescription().getSolverDescription().equals(SolverDescription.StochGibson)) {
            NonspatialStochHybridOptions stochHybridOpt = getSolverTaskDescription().getStochHybridOpt();
            double epsilon = stochHybridOpt.getEpsilon();
            if (getEpsilonTextField().isEnabled() && getEpsilonTextField().getText().length() > 0) {
                epsilon = Double.parseDouble(getEpsilonTextField().getText());
            }
            double lambda = stochHybridOpt.getLambda();
            if (getLambdaTextField().isEnabled() && getLambdaTextField().getText().length() > 0) {
                lambda = Double.parseDouble(getLambdaTextField().getText());
            }
            double MSRTolerance = stochHybridOpt.getMSRTolerance();
            if (getMSRToleranceTextField().isEnabled() && getMSRToleranceTextField().getText().length() > 0) {
                MSRTolerance = Double.parseDouble(getMSRToleranceTextField().getText());
            }
            double SDETolerance = stochHybridOpt.getSDETolerance();
            if (getSDEToleranceTextField().isEnabled() && getSDEToleranceTextField().getText().length() > 0) {
                SDETolerance = Double.parseDouble(getSDEToleranceTextField().getText());
            }
            NonspatialStochHybridOptions nssho = new NonspatialStochHybridOptions(epsilon, lambda, MSRTolerance, SDETolerance);
            getSolverTaskDescription().setStochHybridOpt(nssho);
        }
    } catch (Exception e) {
        PopupGenerator.showErrorDialog(this, e.getMessage(), e);
    }
}
Also used : NonspatialStochSimOptions(cbit.vcell.solver.NonspatialStochSimOptions) NonspatialStochHybridOptions(cbit.vcell.solver.NonspatialStochHybridOptions)

Example 4 with NonspatialStochSimOptions

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

the class StochFileWriter method write.

/**
 * Write the model to a text file which serves as an input for Stochastic simulation engine.
 * Creation date: (6/22/2006 5:37:26 PM)
 */
public void write(String[] parameterNames) throws Exception, ExpressionException {
    Simulation simulation = simTask.getSimulation();
    SimulationSymbolTable simSymbolTable = simTask.getSimulationJob().getSimulationSymbolTable();
    initialize();
    if (bUseMessaging) {
        writeJMSParamters();
    }
    // Write control information
    printWriter.println("<control>");
    cbit.vcell.solver.SolverTaskDescription solverTaskDescription = simulation.getSolverTaskDescription();
    cbit.vcell.solver.TimeBounds timeBounds = solverTaskDescription.getTimeBounds();
    cbit.vcell.solver.OutputTimeSpec outputTimeSpec = solverTaskDescription.getOutputTimeSpec();
    ErrorTolerance errorTolerance = solverTaskDescription.getErrorTolerance();
    NonspatialStochSimOptions stochOpt = solverTaskDescription.getStochOpt();
    printWriter.println("STARTING_TIME" + "\t" + timeBounds.getStartingTime());
    printWriter.println("ENDING_TIME " + "\t" + timeBounds.getEndingTime());
    // pw.println("MAX_ITERATION"+"\t"+outputTimeSpec.getKeepAtMost());
    printWriter.println("TOLERANCE " + "\t" + errorTolerance.getAbsoluteErrorTolerance());
    if (outputTimeSpec.isDefault()) {
        printWriter.println("SAMPLE_INTERVAL" + "\t" + ((DefaultOutputTimeSpec) outputTimeSpec).getKeepEvery());
        printWriter.println("MAX_SAVE_POINTS" + "\t" + ((DefaultOutputTimeSpec) outputTimeSpec).getKeepAtMost());
    } else if (outputTimeSpec.isUniform()) {
        printWriter.println("SAVE_PERIOD" + "\t" + ((UniformOutputTimeSpec) outputTimeSpec).getOutputTimeStep());
        // need to overwrite limit hardcoded in C++
        double savePoints = (timeBounds.getEndingTime() - timeBounds.getStartingTime()) / ((UniformOutputTimeSpec) outputTimeSpec).getOutputTimeStep();
        printWriter.println("MAX_SAVE_POINTS" + "\t" + (Math.ceil(savePoints) + 1));
    }
    // boolean isMultiTrial = !solverTaskDescription.getStochOpt().isHistogram() &&
    // solverTaskDescription.getStochOpt().getNumOfTrials() > 1;
    // //Multi-trial 'NUM_TRIAL' handled by slurm array within .slurm.sh script
    // printWriter.println("NUM_TRIAL"+"\t"+(isMultiTrial?1:solverTaskDescription.getStochOpt().getNumOfTrials()));
    printWriter.println("NUM_TRIAL" + "\t" + solverTaskDescription.getStochOpt().getNumOfTrials());
    if (stochOpt.isUseCustomSeed()) {
        printWriter.println("SEED" + "\t" + stochOpt.getCustomSeed());
    } else {
        // we generate our own random seed
        RandomDataGenerator rdg = new RandomDataGenerator();
        int randomSeed = rdg.nextInt(1, Integer.MAX_VALUE);
        printWriter.println("SEED" + "\t" + randomSeed);
    }
    if (isMultiTrialNonHisto) {
        printWriter.println("BMULTIBUTNOTHISTO" + "\t" + "1");
    }
    printWriter.println("</control>");
    printWriter.println();
    // write model information
    // Model info. will be extracted from subDomain of mathDescription
    Enumeration<SubDomain> e = simulation.getMathDescription().getSubDomains();
    SubDomain subDomain = null;
    if (e.hasMoreElements()) {
        subDomain = e.nextElement();
    }
    if (subDomain != null) {
        printWriter.println("<model>");
        // variables
        printWriter.println("<discreteVariables>");
        // Species iniCondition (if in concentration) is sampled from a poisson distribution(which has a mean of the current iniExp value)
        // There is only one subDomain for compartmental model
        List<VarIniCondition> varInis = subDomain.getVarIniConditions();
        if ((varInis != null) && (varInis.size() > 0)) {
            RandomDataGenerator dist = new RandomDataGenerator();
            if (simulation.getSolverTaskDescription().getStochOpt().isUseCustomSeed()) {
                Integer randomSeed = simulation.getSolverTaskDescription().getStochOpt().getCustomSeed();
                if (randomSeed != null) {
                    dist.reSeed(randomSeed);
                }
            }
            printWriter.println("TotalVars" + "\t" + varInis.size());
            for (VarIniCondition varIniCondition : varInis) {
                try {
                    Expression iniExp = varIniCondition.getIniVal();
                    iniExp.bindExpression(simSymbolTable);
                    iniExp = simSymbolTable.substituteFunctions(iniExp).flatten();
                    double expectedCount = iniExp.evaluateConstant();
                    // 1000 mill
                    final Integer limit = 1000000000;
                    if (limit < expectedCount) {
                        String eMessage = "The Initial count for Species '" + varIniCondition.getVar().getName() + "' is " + BigDecimal.valueOf(expectedCount).toBigInteger() + "\n";
                        eMessage += "which is higher than the internal vCell limit of " + limit + ".\n";
                        eMessage += "Please reduce the Initial Condition value for this Species or reduce the compartment size.";
                        throw new MathFormatException(eMessage);
                    }
                    long varCount = 0;
                    if (varIniCondition instanceof VarIniCount) {
                        varCount = (long) Math.round(expectedCount);
                    } else {
                        if (expectedCount > 0) {
                            varCount = dist.nextPoisson(expectedCount);
                        }
                    }
                    // System.out.println("expectedCount: " + expectedCount + ", varCount: " + varCount);
                    printWriter.println(varIniCondition.getVar().getName() + "\t" + varCount);
                } catch (ExpressionException ex) {
                    ex.printStackTrace();
                    throw new MathFormatException("variable " + varIniCondition.getVar().getName() + "'s initial condition is required to be a constant.");
                }
            }
        } else
            printWriter.println("TotalVars" + "\t" + "0");
        printWriter.println("</discreteVariables>");
        printWriter.println();
        // jump processes
        printWriter.println("<jumpProcesses>");
        List<JumpProcess> jumpProcesses = subDomain.getJumpProcesses();
        if ((jumpProcesses != null) && (jumpProcesses.size() > 0)) {
            printWriter.println("TotalProcesses" + "\t" + jumpProcesses.size());
            for (int i = 0; i < jumpProcesses.size(); i++) {
                printWriter.println(jumpProcesses.get(i).getName());
            }
        } else
            printWriter.println("TotalProcesses" + "\t" + "0");
        printWriter.println("</jumpProcesses>");
        printWriter.println();
        // process description
        printWriter.println("<processDesc>");
        if ((jumpProcesses != null) && (jumpProcesses.size() > 0)) {
            printWriter.println("TotalDescriptions" + "\t" + jumpProcesses.size());
            for (int i = 0; i < jumpProcesses.size(); i++) {
                JumpProcess temProc = (JumpProcess) jumpProcesses.get(i);
                // jump process name
                printWriter.println("JumpProcess" + "\t" + temProc.getName());
                Expression probExp = temProc.getProbabilityRate();
                try {
                    probExp.bindExpression(simSymbolTable);
                    probExp = simSymbolTable.substituteFunctions(probExp).flatten();
                    if (!isValidProbabilityExpression(probExp)) {
                        throw new MathFormatException("probability rate in jump process " + temProc.getName() + " has illegal symbols(should only contain variable names).");
                    }
                } catch (cbit.vcell.parser.ExpressionException ex) {
                    ex.printStackTrace();
                    throw new cbit.vcell.parser.ExpressionException("Binding math description error in probability rate in jump process " + temProc.getName() + ". Some symbols can not be resolved.");
                }
                // Expression temp = replaceVarIniInProbability(probExp);
                // Propensity
                printWriter.println("\t" + "Propensity" + "\t" + probExp.infix());
                // effects
                printWriter.println("\t" + "Effect" + "\t" + temProc.getActions().size());
                for (int j = 0; j < temProc.getActions().size(); j++) {
                    printWriter.print("\t\t" + ((Action) temProc.getActions().get(j)).getVar().getName() + "\t" + ((Action) temProc.getActions().get(j)).getOperation());
                    printWriter.println("\t" + ((Action) temProc.getActions().get(j)).evaluateOperand());
                    printWriter.println();
                }
                // dependencies
                Vector<String> dependencies = getDependencies(temProc, jumpProcesses);
                if ((dependencies != null) && (dependencies.size() > 0)) {
                    printWriter.println("\t" + "DependentProcesses" + "\t" + dependencies.size());
                    for (int j = 0; j < dependencies.size(); j++) printWriter.println("\t\t" + dependencies.elementAt(j));
                } else
                    printWriter.println("\t" + "DependentProcesses" + "\t" + "0");
                printWriter.println();
            }
        } else
            printWriter.println("TotalDescriptions" + "\t" + "0");
        printWriter.println("</processDesc>");
        printWriter.println("</model>");
    }
// if (subDomain != null)
}
Also used : VarIniCondition(cbit.vcell.math.VarIniCondition) Action(cbit.vcell.math.Action) NonspatialStochSimOptions(cbit.vcell.solver.NonspatialStochSimOptions) MathFormatException(cbit.vcell.math.MathFormatException) ExpressionException(cbit.vcell.parser.ExpressionException) SubDomain(cbit.vcell.math.SubDomain) JumpProcess(cbit.vcell.math.JumpProcess) ErrorTolerance(cbit.vcell.solver.ErrorTolerance) UniformOutputTimeSpec(cbit.vcell.solver.UniformOutputTimeSpec) RandomDataGenerator(org.apache.commons.math3.random.RandomDataGenerator) VarIniCount(cbit.vcell.math.VarIniCount) SimulationSymbolTable(cbit.vcell.solver.SimulationSymbolTable) ExpressionException(cbit.vcell.parser.ExpressionException) Simulation(cbit.vcell.solver.Simulation) Expression(cbit.vcell.parser.Expression) DefaultOutputTimeSpec(cbit.vcell.solver.DefaultOutputTimeSpec)

Example 5 with NonspatialStochSimOptions

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

the class HybridSolver method getMathExecutableCommand.

@Override
protected String[] getMathExecutableCommand() {
    String randomNumber = "";
    // if one of the following paras is applied, all the paras in front of it must be set.
    String epsilon = " 100";
    String lambda = " 10";
    String MSR_Tolerance = " 0.01";
    String SDE_Tolerance = " 1e-4";
    String SDE_dt = " 0.1";
    String paraString = "";
    SolverTaskDescription solverTaskDescription = simTask.getSimulation().getSolverTaskDescription();
    NonspatialStochSimOptions stochOpts = solverTaskDescription.getStochOpt();
    NonspatialStochHybridOptions hybridOpts = solverTaskDescription.getStochHybridOpt();
    if (hybridOpts == null) {
        throw new RuntimeException("expecting StochHybridOptions for solver type " + solverTaskDescription.getSolverDescription().getDisplayLabel());
    }
    epsilon = " " + String.valueOf(hybridOpts.getEpsilon());
    lambda = " " + String.valueOf(hybridOpts.getLambda());
    MSR_Tolerance = " " + String.valueOf(hybridOpts.getMSRTolerance());
    if (solverTaskDescription.getSolverDescription().equals(SolverDescription.HybridMilAdaptive))
        SDE_Tolerance = " " + String.valueOf(hybridOpts.getSDETolerance());
    else
        SDE_Tolerance = "";
    SDE_dt = " " + String.valueOf(solverTaskDescription.getTimeStep().getDefaultTimeStep());
    paraString = epsilon + lambda + MSR_Tolerance + SDE_Tolerance + SDE_dt;
    if (stochOpts.isUseCustomSeed())
        randomNumber = " -R " + String.valueOf(stochOpts.getCustomSeed());
    SolverDescription solverDescription = null;
    if (getIntegratorType() == HybridSolver.EMIntegrator) {
        solverDescription = SolverDescription.HybridEuler;
    } else if (getIntegratorType() == HybridSolver.MilsteinIntegrator) {
        solverDescription = SolverDescription.HybridMilstein;
    } else {
        solverDescription = SolverDescription.HybridMilAdaptive;
    }
    String executableName;
    try {
        executableName = SolverUtilities.getExes(SolverDescription.HybridEuler)[0].getAbsolutePath();
    } catch (IOException e) {
        throw new RuntimeException("failed to get executable for solver " + solverDescription.getDisplayLabel() + ": " + e.getMessage(), e);
    }
    ArrayList<String> commandList = new ArrayList<String>();
    commandList.add(executableName);
    commandList.add(getInputFilename());
    String argumentString = paraString.toLowerCase() + randomNumber + " -OV";
    StringTokenizer st = new StringTokenizer(argumentString);
    while (st.hasMoreTokens()) {
        commandList.add(st.nextToken());
    }
    return commandList.toArray(new String[0]);
}
Also used : StringTokenizer(java.util.StringTokenizer) SolverDescription(cbit.vcell.solver.SolverDescription) NonspatialStochSimOptions(cbit.vcell.solver.NonspatialStochSimOptions) ArrayList(java.util.ArrayList) SolverTaskDescription(cbit.vcell.solver.SolverTaskDescription) NonspatialStochHybridOptions(cbit.vcell.solver.NonspatialStochHybridOptions) IOException(java.io.IOException)

Aggregations

NonspatialStochSimOptions (cbit.vcell.solver.NonspatialStochSimOptions)8 SolverTaskDescription (cbit.vcell.solver.SolverTaskDescription)5 Simulation (cbit.vcell.solver.Simulation)4 SolverDescription (cbit.vcell.solver.SolverDescription)4 Expression (cbit.vcell.parser.Expression)3 ExpressionException (cbit.vcell.parser.ExpressionException)3 NonspatialStochHybridOptions (cbit.vcell.solver.NonspatialStochHybridOptions)3 SimulationSymbolTable (cbit.vcell.solver.SimulationSymbolTable)3 TimeBounds (cbit.vcell.solver.TimeBounds)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 BioModel (cbit.vcell.biomodel.BioModel)2 Action (cbit.vcell.math.Action)2 JumpProcess (cbit.vcell.math.JumpProcess)2 SubDomain (cbit.vcell.math.SubDomain)2 VarIniCondition (cbit.vcell.math.VarIniCondition)2 VarIniCount (cbit.vcell.math.VarIniCount)2 DefaultOutputTimeSpec (cbit.vcell.solver.DefaultOutputTimeSpec)2 ErrorTolerance (cbit.vcell.solver.ErrorTolerance)2 UniformOutputTimeSpec (cbit.vcell.solver.UniformOutputTimeSpec)2