use of cbit.vcell.opt.OptSolverResultSet.ProfileDistribution in project vcell by virtualcell.
the class ReactionDominantTest method solve.
private OptimizationResultSet solve() throws ExpressionException, IOException {
Expression Fbleached_bleachFastExp = new Expression(Fbleached_bleachFast);
Expression OmegaExp = new Expression(strOmega);
Expression Omega_cExp = new Expression(strOmega_c);
Expression WExp = new Expression(strW);
Fbleached_bleachFastExp.substituteInPlace(OmegaExp, new Expression(Omega));
Fbleached_bleachFastExp.substituteInPlace(Omega_cExp, new Expression(Omega_c));
Fbleached_bleachFastExp.substituteInPlace(WExp, new Expression(W));
Parameter[] parameters = new Parameter[] { para_alpha, para_Kon_star, para_Koff };
// Expression Fbleached_bleachFast = Fbleached_bleachFastExp.flatten();
// choose optimization solver, currently we have Powell and CFSQP
PowellOptimizationSolver optService = new PowellOptimizationSolver();
OptimizationSpec optSpec = new OptimizationSpec();
// create simple reference data
double[][] realData = new double[2][t.length];
for (int i = 0; i < t.length; i++) {
realData[0][i] = t[i];
realData[1][i] = data_bleached[i];
}
String[] colNames = new String[] { "t", "intensity" };
double[] weights = new double[] { 1.0, 1.0 };
SimpleReferenceData refData = new SimpleReferenceData(colNames, weights, realData);
// send to optimization service
ExplicitFitObjectiveFunction.ExpressionDataPair oneExpDataPair = new ExplicitFitObjectiveFunction.ExpressionDataPair(Fbleached_bleachFastExp.flatten(), 1);
ExplicitFitObjectiveFunction.ExpressionDataPair[] expDataPairs = new ExplicitFitObjectiveFunction.ExpressionDataPair[] { oneExpDataPair };
optSpec.setObjectiveFunction(new ExplicitFitObjectiveFunction(expDataPairs, refData));
optSpec.setComputeProfileDistributions(true);
// get the initial guess to send it to the f() function. ....
for (int i = 0; i < parameters.length; i++) {
optSpec.addParameter(parameters[i]);
}
// Parameters in OptimizationSolverSpec are solver type and objective function change tolerance.
OptimizationSolverSpec optSolverSpec = new OptimizationSolverSpec(OptimizationSolverSpec.SOLVERTYPE_POWELL, 0.000001);
OptSolverCallbacks optSolverCallbacks = new DefaultOptSolverCallbacks();
OptimizationResultSet optResultSet = null;
optResultSet = optService.solve(optSpec, optSolverSpec, optSolverCallbacks);
String[] paramNames = optResultSet.getOptSolverResultSet().getParameterNames();
ArrayList<ProfileDistribution> profileDistributionList = optResultSet.getOptSolverResultSet().getProfileDistributionList();
for (int i = 0; i < profileDistributionList.size(); i++) {
outputProfileLikelihood(profileDistributionList.get(i), i, paramNames[i], new File(fileDir));
}
return optResultSet;
}
Aggregations