Search in sources :

Example 1 with OptRunResultSet

use of cbit.vcell.opt.OptSolverResultSet.OptRunResultSet in project vcell by virtualcell.

the class OptXmlReader method getOptRunResultSet.

private static OptRunResultSet getOptRunResultSet(Element optRunElement) throws DataConversionException {
    double bestObjectFuncValue = optRunElement.getAttribute(OptXmlTags.OptSolverResultSetBestObjectiveFunction_Attr).getDoubleValue();
    long numObjectFuncEvals = optRunElement.getAttribute(OptXmlTags.OptSolverResultSetNumObjectiveFunctionEvaluations_Attr).getLongValue();
    String status = optRunElement.getAttributeValue(OptXmlTags.OptSolverResultSetStatus_Attr);
    Attribute statusMessageAttr = optRunElement.getAttribute(OptXmlTags.OptSolverResultSetStatusMessage_Attr);
    List<Element> paramElementList = optRunElement.getChildren(OptXmlTags.Parameter_Tag);
    String[] parameterNames = new String[paramElementList.size()];
    double[] parameterValues = new double[paramElementList.size()];
    int count = 0;
    for (Element parameterElement : paramElementList) {
        parameterNames[count] = parameterElement.getAttributeValue(OptXmlTags.ParameterName_Attr);
        parameterValues[count] = Double.parseDouble(parameterElement.getAttributeValue(OptXmlTags.ParameterBestValue_Attr));
        count++;
    }
    int statusID = OptimizationStatus.statusFromXMLName(status);
    String statusMessage = null;
    if (statusMessageAttr != null) {
        statusMessage = statusMessageAttr.getValue();
    }
    OptimizationStatus optimizationStatus = new OptimizationStatus(statusID, statusMessage);
    OptRunResultSet optRun = new OptRunResultSet(parameterValues, new Double(bestObjectFuncValue), numObjectFuncEvals, optimizationStatus);
    return optRun;
}
Also used : Attribute(org.jdom.Attribute) Element(org.jdom.Element) OptimizationStatus(cbit.vcell.opt.OptimizationStatus) OptRunResultSet(cbit.vcell.opt.OptSolverResultSet.OptRunResultSet)

Example 2 with OptRunResultSet

use of cbit.vcell.opt.OptSolverResultSet.OptRunResultSet in project vcell by virtualcell.

the class ReactionDominantTest method outputProfileLikelihood.

private void outputProfileLikelihood(ProfileDistribution pd, int paramIdx, String fixedParamName, File outputDir) {
    try {
        System.out.println("Writing profile likelihood...");
        // output results
        String outFileName = outputDir.getAbsolutePath() + "\\" + fixedParamName + "_profileLikelihood" + ".txt";
        File outFile = new File(outFileName);
        FileWriter fstream = new FileWriter(outFile);
        BufferedWriter out = new BufferedWriter(fstream);
        // output profile
        out.write("Log base 10 param value" + "\t" + "error");
        ArrayList<OptRunResultSet> orrs = pd.getOptRunResultSetList();
        for (int i = 0; i < orrs.size(); i++) {
            out.newLine();
            String rowStr = Math.log10(orrs.get(i).getParameterValues()[paramIdx]) + "\t" + orrs.get(i).getObjectiveFunctionValue();
            out.write(rowStr);
        }
        out.close();
        System.out.println("Output is done. Restults saved to " + outFileName);
    } catch (IOException e) {
        e.printStackTrace(System.out);
    }
}
Also used : FileWriter(java.io.FileWriter) OptRunResultSet(cbit.vcell.opt.OptSolverResultSet.OptRunResultSet) IOException(java.io.IOException) File(java.io.File) BufferedWriter(java.io.BufferedWriter)

Example 3 with OptRunResultSet

use of cbit.vcell.opt.OptSolverResultSet.OptRunResultSet in project vcell by virtualcell.

the class ParameterEstimationTaskXMLPersistence method getParameterEstimationTask.

/**
 * Insert the method's description here.
 * Creation date: (5/5/2006 4:50:36 PM)
 * @return cbit.vcell.modelopt.ParameterEstimationTask
 * @param element org.jdom.Element
 * @param simContext cbit.vcell.mapping.SimulationContext
 */
public static ParameterEstimationTask getParameterEstimationTask(Element parameterEstimationTaskElement, SimulationContext simContext) throws ExpressionException, MappingException, MathException, java.beans.PropertyVetoException {
    Namespace ns = parameterEstimationTaskElement.getNamespace();
    ParameterEstimationTask parameterEstimationTask = new ParameterEstimationTask(simContext);
    String name = parameterEstimationTaskElement.getAttributeValue(NameAttribute);
    parameterEstimationTask.setName(name);
    Element annotationElement = parameterEstimationTaskElement.getChild(AnnotationTag, ns);
    if (annotationElement != null) {
        String annotationText = annotationElement.getText();
        parameterEstimationTask.setAnnotation(annotationText);
    }
    // 
    // read ParameterMappingSpecs
    // 
    Element parameterMappingSpecListElement = parameterEstimationTaskElement.getChild(ParameterMappingSpecListTag, ns);
    if (parameterMappingSpecListElement != null) {
        List<Element> parameterMappingSpecElementList = parameterMappingSpecListElement.getChildren(ParameterMappingSpecTag, ns);
        for (Element parameterMappingSpecElement : parameterMappingSpecElementList) {
            String parameterName = parameterMappingSpecElement.getAttributeValue(ParameterReferenceAttribute);
            SymbolTableEntry ste = getSymbolTableEntry(simContext, parameterName);
            if (ste instanceof Parameter) {
                Parameter parameter = (Parameter) ste;
                ParameterMappingSpec parameterMappingSpec = parameterEstimationTask.getModelOptimizationSpec().getParameterMappingSpec(parameter);
                if (parameterMappingSpec != null) {
                    String lowLimitString = parameterMappingSpecElement.getAttributeValue(LowLimitAttribute);
                    if (lowLimitString != null) {
                        parameterMappingSpec.setLow(parseDouble(lowLimitString));
                    }
                    String highLimitString = parameterMappingSpecElement.getAttributeValue(HighLimitAttribute);
                    if (highLimitString != null) {
                        parameterMappingSpec.setHigh(parseDouble(highLimitString));
                    }
                    String currentValueString = parameterMappingSpecElement.getAttributeValue(CurrentValueAttribute);
                    if (currentValueString != null) {
                        parameterMappingSpec.setCurrent(Double.parseDouble(currentValueString));
                    }
                    String selectedString = parameterMappingSpecElement.getAttributeValue(SelectedAttribute);
                    if (selectedString != null) {
                        parameterMappingSpec.setSelected(Boolean.valueOf(selectedString).booleanValue());
                    }
                }
            } else {
                System.out.println("couldn't read parameterMappingSpec '" + parameterName + "', ste=" + ste);
            }
        }
    }
    // 
    // read ReferenceData
    // 
    Element referenceDataElement = parameterEstimationTaskElement.getChild(ReferenceDataTag, ns);
    if (referenceDataElement != null) {
        String numRowsText = referenceDataElement.getAttributeValue(NumRowsAttribute);
        String numColsText = referenceDataElement.getAttributeValue(NumColumnsAttribute);
        // int numRows = Integer.parseInt(numRowsText);
        int numCols = Integer.parseInt(numColsText);
        // 
        // read columns
        // 
        String[] columnNames = new String[numCols];
        double[] columnWeights = new double[numCols];
        int columnCounter = 0;
        Element dataColumnListElement = referenceDataElement.getChild(DataColumnListTag, ns);
        List<Element> dataColumnList = dataColumnListElement.getChildren(DataColumnTag, ns);
        for (Element dataColumnElement : dataColumnList) {
            columnNames[columnCounter] = dataColumnElement.getAttributeValue(NameAttribute);
            columnWeights[columnCounter] = Double.parseDouble(dataColumnElement.getAttributeValue(WeightAttribute));
            columnCounter++;
        }
        // 
        // read rows
        // 
        Vector<double[]> rowDataVector = new Vector<double[]>();
        Element dataRowListElement = referenceDataElement.getChild(DataRowListTag, ns);
        List<Element> dataRowList = dataRowListElement.getChildren(DataRowTag, ns);
        for (Element dataRowElement : dataRowList) {
            String rowText = dataRowElement.getText();
            CommentStringTokenizer tokens = new CommentStringTokenizer(rowText);
            double[] rowData = new double[numCols];
            for (int j = 0; j < numCols; j++) {
                if (tokens.hasMoreTokens()) {
                    String token = tokens.nextToken();
                    rowData[j] = Double.parseDouble(token);
                } else {
                    throw new RuntimeException("failed to read row data for ReferenceData");
                }
            }
            rowDataVector.add(rowData);
        }
        ReferenceData referenceData = new SimpleReferenceData(columnNames, columnWeights, rowDataVector);
        parameterEstimationTask.getModelOptimizationSpec().setReferenceData(referenceData);
    }
    // 
    // read ReferenceDataMappingSpecs
    // 
    Element referenceDataMappingSpecListElement = parameterEstimationTaskElement.getChild(ReferenceDataMappingSpecListTag, ns);
    if (referenceDataMappingSpecListElement != null) {
        List<Element> referenceDataMappingSpecList = referenceDataMappingSpecListElement.getChildren(ReferenceDataMappingSpecTag, ns);
        for (Element referenceDataMappingSpecElement : referenceDataMappingSpecList) {
            String referenceDataColumnName = referenceDataMappingSpecElement.getAttributeValue(ReferenceDataColumnNameAttribute);
            String referenceDataModelSymbolName = referenceDataMappingSpecElement.getAttributeValue(ReferenceDataModelSymbolAttribute);
            ReferenceDataMappingSpec referenceDataMappingSpec = parameterEstimationTask.getModelOptimizationSpec().getReferenceDataMappingSpec(referenceDataColumnName);
            SymbolTableEntry modelSymbolTableEntry = null;
            if (referenceDataModelSymbolName != null) {
                modelSymbolTableEntry = getSymbolTableEntry(simContext, referenceDataModelSymbolName);
                if (referenceDataMappingSpec != null && modelSymbolTableEntry != null) {
                    referenceDataMappingSpec.setModelObject(modelSymbolTableEntry);
                }
            }
        }
    }
    // 
    // read OptimizationSolverSpec
    // 
    Element optimizationSolverSpecElement = parameterEstimationTaskElement.getChild(OptimizationSolverSpecTag, ns);
    if (optimizationSolverSpecElement != null) {
        OptimizationSolverSpec optSolverSpec = null;
        String optimizationSolverTypeName = optimizationSolverSpecElement.getAttributeValue(OptimizationSolverTypeAttribute);
        // getting parameters
        Element optimizationSolverParameterList = optimizationSolverSpecElement.getChild(OptimizationListOfParametersTag, ns);
        if (optimizationSolverParameterList != null) {
            List<Element> listOfSolverParams = optimizationSolverParameterList.getChildren(OptimizationParameterTag, ns);
            CopasiOptimizationMethod copasiOptMethod = null;
            if (listOfSolverParams != null && listOfSolverParams.size() > 0) {
                List<CopasiOptimizationParameter> copasiSolverParams = new ArrayList<CopasiOptimizationParameter>();
                for (Element solverParam : listOfSolverParams) {
                    String paramName = solverParam.getAttributeValue(OptimizationParameterNameAttribute);
                    double paramValue = Double.parseDouble(solverParam.getAttributeValue(OptimizationParameterValueAttribute));
                    CopasiOptimizationParameter copasiParam = new CopasiOptimizationParameter(getCopasiOptimizationParameterTypeByName(paramName), paramValue);
                    copasiSolverParams.add(copasiParam);
                }
                copasiOptMethod = new CopasiOptimizationMethod(getCopasiOptimizationMethodTypeByName(optimizationSolverTypeName), copasiSolverParams.toArray(new CopasiOptimizationParameter[copasiSolverParams.size()]));
            } else // no parameters
            {
                copasiOptMethod = new CopasiOptimizationMethod(getCopasiOptimizationMethodTypeByName(optimizationSolverTypeName), new CopasiOptimizationParameter[0]);
            }
            optSolverSpec = new OptimizationSolverSpec(copasiOptMethod);
            // add number of runs attribute
            String numOfRunsStr = optimizationSolverSpecElement.getAttributeValue(OptimizationSolverNumOfRunsAttribute);
            if (numOfRunsStr != null) {
                int numOfRuns = Integer.parseInt(numOfRunsStr);
                optSolverSpec.setNumOfRuns(numOfRuns);
            }
        }
        parameterEstimationTask.setOptimizationSolverSpec(optSolverSpec);
    }
    if (// optimization solver spec is null create a default copasi evolutionary programming
    optimizationSolverSpecElement == null || parameterEstimationTask.getOptimizationSolverSpec() == null) {
        OptimizationSolverSpec optSolverSpec = new OptimizationSolverSpec(new CopasiOptimizationMethod(CopasiOptimizationMethodType.EvolutionaryProgram));
        parameterEstimationTask.setOptimizationSolverSpec(optSolverSpec);
    }
    // read optimization solver result set
    Element optimizationResultSetElement = parameterEstimationTaskElement.getChild(OptXmlTags.OptimizationResultSet_Tag, ns);
    if (optimizationResultSetElement != null) {
        OptimizationResultSet optResultSet = null;
        // read optsolverResultSet
        if (optimizationResultSetElement.getChild(OptXmlTags.bestOptRunResultSet_Tag, ns) != null) {
            Element optSolverResultSetElement = optimizationResultSetElement.getChild(OptXmlTags.bestOptRunResultSet_Tag, ns);
            OptSolverResultSet optSolverResultSet = null;
            // get best parameters, best func value, number of evaluations and construct an optRunResultSet
            Element paramListElement = optSolverResultSetElement.getChild(OptimizationListOfParametersTag, ns);
            OptRunResultSet optRunResultSet = null;
            List<String> paramNames = new ArrayList<String>();
            List<Double> paramValues = new ArrayList<Double>();
            if (paramListElement != null && !paramListElement.getChildren().isEmpty()) {
                List<Element> paramElements = paramListElement.getChildren(OptimizationParameterTag, ns);
                if (paramElements != null) {
                    for (Element paramElement : paramElements) {
                        String paramName = paramElement.getAttributeValue(OptimizationParameterNameAttribute);
                        double paramValue = Double.parseDouble(paramElement.getAttributeValue(OptimizationParameterValueAttribute));
                        paramNames.add(paramName);
                        paramValues.add(paramValue);
                    }
                }
            }
            Element bestFuncValueElement = optSolverResultSetElement.getChild(OptXmlTags.ObjectiveFunction_Tag, ns);
            double bestFuncValue = Double.parseDouble(bestFuncValueElement.getAttributeValue(OptimizationParameterValueAttribute));
            Element numEvaluationsElement = optSolverResultSetElement.getChild(OptXmlTags.OptSolverResultSetFunctionEvaluations_Tag, ns);
            long numEvaluations = Long.parseLong(numEvaluationsElement.getAttributeValue(OptimizationParameterValueAttribute));
            // change List<Double> to double[]
            double[] values = new double[paramValues.size()];
            int index = 0;
            for (Double value : paramValues) {
                values[index++] = value;
            }
            optRunResultSet = new OptRunResultSet(values, bestFuncValue, numEvaluations, null);
            // create optSolverResultSet
            optSolverResultSet = new OptSolverResultSet(paramNames.toArray(new String[paramNames.size()]), optRunResultSet);
            // create optimization result set
            optResultSet = new OptimizationResultSet(optSolverResultSet, null);
        }
        parameterEstimationTask.setOptimizationResultSet(optResultSet);
    }
    return parameterEstimationTask;
}
Also used : OptimizationResultSet(cbit.vcell.opt.OptimizationResultSet) Element(org.jdom.Element) ArrayList(java.util.ArrayList) OptSolverResultSet(cbit.vcell.opt.OptSolverResultSet) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) CopasiOptimizationMethod(cbit.vcell.opt.CopasiOptimizationMethod) CopasiOptimizationParameter(cbit.vcell.opt.CopasiOptimizationParameter) OptimizationSolverSpec(cbit.vcell.opt.OptimizationSolverSpec) Vector(java.util.Vector) Namespace(org.jdom.Namespace) SimpleReferenceData(cbit.vcell.opt.SimpleReferenceData) SimpleReferenceData(cbit.vcell.opt.SimpleReferenceData) ReferenceData(cbit.vcell.opt.ReferenceData) Parameter(cbit.vcell.model.Parameter) CopasiOptimizationParameter(cbit.vcell.opt.CopasiOptimizationParameter) CommentStringTokenizer(org.vcell.util.CommentStringTokenizer) OptRunResultSet(cbit.vcell.opt.OptSolverResultSet.OptRunResultSet)

Example 4 with OptRunResultSet

use of cbit.vcell.opt.OptSolverResultSet.OptRunResultSet in project vcell by virtualcell.

the class CopasiOptimizationSolver method solveRemoteApi.

public static OptimizationResultSet solveRemoteApi(ParameterEstimationTaskSimulatorIDA parestSimulator, ParameterEstimationTask parameterEstimationTask, CopasiOptSolverCallbacks optSolverCallbacks, MathMappingCallback mathMappingCallback) throws IOException, ExpressionException, OptimizationException {
    try {
        OptProblem optProblem = CopasiServicePython.makeOptProblem(parameterEstimationTask);
        boolean bIgnoreCertProblems = true;
        boolean bIgnoreHostMismatch = true;
        // e.g. vcell.serverhost=vcellapi.cam.uchc.edu:8080
        String serverHost = PropertyLoader.getRequiredProperty(PropertyLoader.vcellServerHost);
        String[] parts = serverHost.split(":");
        String host = parts[0];
        int port = Integer.parseInt(parts[1]);
        VCellApiClient apiClient = new VCellApiClient(host, port, bIgnoreCertProblems, bIgnoreHostMismatch);
        TSerializer serializer = new TSerializer(new TJSONProtocol.Factory());
        String optProblemJson = serializer.toString(optProblem);
        String optimizationId = apiClient.submitOptimization(optProblemJson);
        // 20 second minute timeout
        final long TIMEOUT_MS = 1000 * 20;
        long startTime = System.currentTimeMillis();
        OptRun optRun = null;
        while ((System.currentTimeMillis() - startTime) < TIMEOUT_MS) {
            if (optSolverCallbacks.getStopRequested()) {
                throw new RuntimeException(STOP_REQUESTED);
            }
            String optRunJson = apiClient.getOptRunJson(optimizationId);
            TDeserializer deserializer = new TDeserializer(new TJSONProtocol.Factory());
            optRun = new OptRun();
            deserializer.deserialize(optRun, optRunJson.getBytes());
            OptRunStatus status = optRun.status;
            if (status == OptRunStatus.Complete) {
                System.out.println("job " + optimizationId + ": status " + status + " " + optRun.getOptResultSet().toString());
                break;
            }
            if (status == OptRunStatus.Failed) {
                throw new RuntimeException("optimization failed, message=" + optRun.statusMessage);
            }
            System.out.println("job " + optimizationId + ": status " + status);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
            }
        }
        System.out.println("done with optimization");
        OptResultSet optResultSet = optRun.getOptResultSet();
        int numFittedParameters = optResultSet.getOptParameterValues().size();
        String[] paramNames = new String[numFittedParameters];
        double[] paramValues = new double[numFittedParameters];
        for (int pIndex = 0; pIndex < numFittedParameters; pIndex++) {
            OptParameterValue optParamValue = optResultSet.getOptParameterValues().get(pIndex);
            paramNames[pIndex] = optParamValue.parameterName;
            paramValues[pIndex] = optParamValue.bestValue;
        }
        OptimizationStatus status = new OptimizationStatus(OptimizationStatus.NORMAL_TERMINATION, optRun.statusMessage);
        OptRunResultSet optRunResultSet = new OptRunResultSet(paramValues, optResultSet.objectiveFunction, optResultSet.numFunctionEvaluations, status);
        OptSolverResultSet copasiOptSolverResultSet = new OptSolverResultSet(paramNames, optRunResultSet);
        RowColumnResultSet copasiRcResultSet = parestSimulator.getRowColumnRestultSetByBestEstimations(parameterEstimationTask, paramNames, paramValues);
        OptimizationResultSet copasiOptimizationResultSet = new OptimizationResultSet(copasiOptSolverResultSet, copasiRcResultSet);
        System.out.println("-----------SOLUTION FROM VCellAPI---------------\n" + optResultSet.toString());
        return copasiOptimizationResultSet;
    } catch (Exception e) {
        e.printStackTrace(System.out);
        if (e.getMessage() != null && e.getMessage().equals(STOP_REQUESTED)) {
            throw UserCancelException.CANCEL_GENERIC;
        }
        throw new OptimizationException(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
    }
}
Also used : OptimizationException(cbit.vcell.opt.OptimizationException) TDeserializer(org.apache.thrift.TDeserializer) OptimizationResultSet(cbit.vcell.opt.OptimizationResultSet) OptParameterValue(org.vcell.optimization.thrift.OptParameterValue) OptSolverResultSet(cbit.vcell.opt.OptSolverResultSet) TJSONProtocol(org.apache.thrift.protocol.TJSONProtocol) OptRunStatus(org.vcell.optimization.thrift.OptRunStatus) OptRun(org.vcell.optimization.thrift.OptRun) OptResultSet(org.vcell.optimization.thrift.OptResultSet) OptimizationStatus(cbit.vcell.opt.OptimizationStatus) RowColumnResultSet(cbit.vcell.math.RowColumnResultSet) OptProblem(org.vcell.optimization.thrift.OptProblem) VCellApiClient(org.vcell.api.client.VCellApiClient) OptimizationException(cbit.vcell.opt.OptimizationException) IOException(java.io.IOException) ExpressionException(cbit.vcell.parser.ExpressionException) MathException(cbit.vcell.math.MathException) UserCancelException(org.vcell.util.UserCancelException) TSerializer(org.apache.thrift.TSerializer) OptRunResultSet(cbit.vcell.opt.OptSolverResultSet.OptRunResultSet)

Example 5 with OptRunResultSet

use of cbit.vcell.opt.OptSolverResultSet.OptRunResultSet in project vcell by virtualcell.

the class CopasiOptimizationSolver method solveLocalPython.

public static OptimizationResultSet solveLocalPython(ParameterEstimationTaskSimulatorIDA parestSimulator, ParameterEstimationTask parameterEstimationTask, CopasiOptSolverCallbacks optSolverCallbacks, MathMappingCallback mathMappingCallback) throws IOException, ExpressionException, OptimizationException {
    File dir = Files.createTempDirectory("parest", new FileAttribute<?>[] {}).toFile();
    try {
        String prefix = "testing_" + Math.abs(new Random().nextInt(10000));
        File optProblemThriftFile = new File(dir, prefix + ".optprob.bin");
        File optRunFile = new File(dir, prefix + ".optrun.bin");
        // 
        // Setup Python COPASI opt problem and write to disk
        // 
        OptProblem optProblem = CopasiServicePython.makeOptProblem(parameterEstimationTask);
        CopasiServicePython.writeOptProblem(optProblemThriftFile, optProblem);
        // 
        // run Python COPASI opt problem
        // 
        CopasiServicePython.runCopasiPython(optProblemThriftFile, optRunFile);
        if (!optRunFile.exists()) {
            throw new RuntimeException("COPASI optimization output file not found:\n" + optRunFile.getAbsolutePath());
        }
        OptRun optRun = CopasiServicePython.readOptRun(optRunFile);
        OptResultSet optResultSet = optRun.getOptResultSet();
        int numFittedParameters = optResultSet.getOptParameterValues().size();
        String[] paramNames = new String[numFittedParameters];
        double[] paramValues = new double[numFittedParameters];
        for (int pIndex = 0; pIndex < numFittedParameters; pIndex++) {
            OptParameterValue optParamValue = optResultSet.getOptParameterValues().get(pIndex);
            paramNames[pIndex] = optParamValue.parameterName;
            paramValues[pIndex] = optParamValue.bestValue;
        }
        OptimizationStatus status = new OptimizationStatus(OptimizationStatus.NORMAL_TERMINATION, optRun.statusMessage);
        OptRunResultSet optRunResultSet = new OptRunResultSet(paramValues, optResultSet.objectiveFunction, optResultSet.numFunctionEvaluations, status);
        OptSolverResultSet copasiOptSolverResultSet = new OptSolverResultSet(paramNames, optRunResultSet);
        RowColumnResultSet copasiRcResultSet = parestSimulator.getRowColumnRestultSetByBestEstimations(parameterEstimationTask, paramNames, paramValues);
        OptimizationResultSet copasiOptimizationResultSet = new OptimizationResultSet(copasiOptSolverResultSet, copasiRcResultSet);
        System.out.println("-----------SOLUTION FROM PYTHON---------------\n" + optResultSet.toString());
        return copasiOptimizationResultSet;
    } catch (Throwable e) {
        e.printStackTrace(System.out);
        throw new OptimizationException(e.getCause() != null ? e.getCause().getMessage() : e.getMessage());
    } finally {
        if (dir != null && dir.exists()) {
            FileUtils.deleteDirectory(dir);
        }
    }
}
Also used : OptimizationException(cbit.vcell.opt.OptimizationException) OptProblem(org.vcell.optimization.thrift.OptProblem) OptimizationResultSet(cbit.vcell.opt.OptimizationResultSet) OptParameterValue(org.vcell.optimization.thrift.OptParameterValue) OptSolverResultSet(cbit.vcell.opt.OptSolverResultSet) Random(java.util.Random) OptRun(org.vcell.optimization.thrift.OptRun) OptResultSet(org.vcell.optimization.thrift.OptResultSet) OptimizationStatus(cbit.vcell.opt.OptimizationStatus) OptRunResultSet(cbit.vcell.opt.OptSolverResultSet.OptRunResultSet) File(java.io.File) FileAttribute(java.nio.file.attribute.FileAttribute) RowColumnResultSet(cbit.vcell.math.RowColumnResultSet)

Aggregations

OptRunResultSet (cbit.vcell.opt.OptSolverResultSet.OptRunResultSet)7 OptSolverResultSet (cbit.vcell.opt.OptSolverResultSet)5 OptimizationResultSet (cbit.vcell.opt.OptimizationResultSet)4 OptimizationStatus (cbit.vcell.opt.OptimizationStatus)4 OptimizationException (cbit.vcell.opt.OptimizationException)3 Element (org.jdom.Element)3 RowColumnResultSet (cbit.vcell.math.RowColumnResultSet)2 File (java.io.File)2 IOException (java.io.IOException)2 OptParameterValue (org.vcell.optimization.thrift.OptParameterValue)2 OptProblem (org.vcell.optimization.thrift.OptProblem)2 OptResultSet (org.vcell.optimization.thrift.OptResultSet)2 OptRun (org.vcell.optimization.thrift.OptRun)2 MathException (cbit.vcell.math.MathException)1 Parameter (cbit.vcell.model.Parameter)1 CopasiOptimizationMethod (cbit.vcell.opt.CopasiOptimizationMethod)1 CopasiOptimizationParameter (cbit.vcell.opt.CopasiOptimizationParameter)1 OptimizationSolverSpec (cbit.vcell.opt.OptimizationSolverSpec)1 Parameter (cbit.vcell.opt.Parameter)1 ReferenceData (cbit.vcell.opt.ReferenceData)1