use of cbit.vcell.solver.NonspatialStochHybridOptions in project vcell by virtualcell.
the class XmlReader method getStochHybridOptions.
/**
* This method returns a TimeStep object from a XML Element.
* Creation date: (5/22/2001 11:45:33 AM)
* @return cbit.vcell.solver.TimeStep
* @param param org.jdom.Element
*/
private NonspatialStochHybridOptions getStochHybridOptions(Element param) {
// StochHybridOptions are immutable, so we grab the default values from the default constructor - and read the options which are stored in XML
NonspatialStochHybridOptions defaultStochHybridOptions = new NonspatialStochHybridOptions();
double epsilon = defaultStochHybridOptions.getEpsilon();
double lambda = defaultStochHybridOptions.getLambda();
double MSRTolerance = defaultStochHybridOptions.getMSRTolerance();
double SDETDolerance = defaultStochHybridOptions.getSDETolerance();
if (param.getAttributeValue(XMLTags.HybridEpsilonAttrTag) != null) {
epsilon = Double.parseDouble(param.getAttributeValue(XMLTags.HybridEpsilonAttrTag));
}
if (param.getAttributeValue(XMLTags.HybridLambdaAttrTag) != null) {
lambda = Double.parseDouble(param.getAttributeValue(XMLTags.HybridLambdaAttrTag));
}
if (param.getAttributeValue(XMLTags.HybridMSRToleranceAttrTag) != null) {
MSRTolerance = Double.parseDouble(param.getAttributeValue(XMLTags.HybridMSRToleranceAttrTag));
}
if (param.getAttributeValue(XMLTags.HybridSDEToleranceAttrTag) != null) {
SDETDolerance = Double.parseDouble(param.getAttributeValue(XMLTags.HybridSDEToleranceAttrTag));
}
// **** create a new StochHybridOptions object and return ****
return new NonspatialStochHybridOptions(epsilon, lambda, MSRTolerance, SDETDolerance);
}
use of cbit.vcell.solver.NonspatialStochHybridOptions 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()) {
numTrials = Integer.parseInt(getJTextFieldNumOfTrials().getText());
}
boolean bUseCustomSeed = getCustomizedSeedRadioButton().isSelected();
int customSeed = stochOpt.getCustomSeed();
if (bUseCustomSeed) {
customSeed = (Integer.parseInt(getJTextFieldCustomSeed().getText()));
}
getSolverTaskDescription().setStochOpt(new NonspatialStochSimOptions(bUseCustomSeed, customSeed, numTrials));
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());
}
getSolverTaskDescription().setStochHybridOpt(new NonspatialStochHybridOptions(epsilon, lambda, MSRTolerance, SDETolerance));
}
} catch (Exception e) {
PopupGenerator.showErrorDialog(this, e.getMessage(), e);
}
}
use of cbit.vcell.solver.NonspatialStochHybridOptions in project vcell by virtualcell.
the class StochSimOptionsPanel method refresh.
private void refresh() {
if (getSolverTaskDescription() != null) {
if (!getSolverTaskDescription().getSolverDescription().isNonSpatialStochasticSolver()) {
setVisible(false);
return;
}
}
setVisible(true);
NonspatialStochSimOptions sso = getSolverTaskDescription().getStochOpt();
long numTrials = sso.getNumOfTrials();
if (numTrials == 1) {
// 1 trial
getJTextFieldNumOfTrials().setEnabled(false);
getTrajectoryButton().setSelected(true);
} else {
// more than 1 trial
getJTextFieldNumOfTrials().setEnabled(true);
getHistogramButton().setSelected(true);
getJTextFieldNumOfTrials().setText(numTrials + "");
}
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);
}
}
}
use of cbit.vcell.solver.NonspatialStochHybridOptions 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]);
}
Aggregations