Search in sources :

Example 1 with IssueContext

use of org.vcell.util.IssueContext in project vcell by virtualcell.

the class ParameterEstimationRunTaskPanel method solve.

private void solve() throws NumberFormatException {
    CopasiOptimizationMethod com = optimizationMethodParameterTableModel.copasiOptimizationMethod;
    OptimizationSolverSpec optSolverSpec = new OptimizationSolverSpec(com);
    // get num runs for stochstic opt mehtods before starting solving...
    if (com.getType().isStochasticMethod()) {
        int numRuns = Integer.parseInt(((String) numberOfRunComboBox.getSelectedItem()));
        optSolverSpec.setNumOfRuns(numRuns);
    }
    parameterEstimationTask.setOptimizationSolverSpec(optSolverSpec);
    parameterEstimationTask.getModelOptimizationSpec().setComputeProfileDistributions(computeProfileDistributionsCheckBox.isSelected());
    optSolverCallbacks.reset();
    Double endValue = com.getEndValue();
    optSolverCallbacks.setEvaluation(0, Double.POSITIVE_INFINITY, 0, endValue, 0);
    // (endValue != null);
    getRunStatusDialog().showProgressBar(com);
    Collection<AsynchClientTask> taskList = ClientRequestManager.updateMath(this, parameterEstimationTask.getSimulationContext(), false, NetworkGenerationRequirements.ComputeFullStandardTimeout);
    AsynchClientTask task1 = new AsynchClientTask("checking issues", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            StringBuffer issueText = new StringBuffer();
            java.util.Vector<Issue> issueList = new java.util.Vector<Issue>();
            IssueContext issueContext = new IssueContext();
            parameterEstimationTask.gatherIssues(issueContext, issueList);
            boolean bFailed = false;
            for (int i = 0; i < issueList.size(); i++) {
                Issue issue = (Issue) issueList.elementAt(i);
                issueText.append(issue.getMessage() + "\n");
                if (issue.getSeverity() == Issue.SEVERITY_ERROR) {
                    bFailed = true;
                    break;
                }
            }
            if (bFailed) {
                throw new OptimizationException(issueText.toString());
            }
            parameterEstimationTask.refreshMappings();
        }
    };
    taskList.add(task1);
    AsynchClientTask task2 = new AsynchClientTask("solving", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            MathMappingCallback mathMappingCallback = new MathMappingCallbackTaskAdapter(getClientTaskStatusSupport());
            // OptimizationResultSet optResultSet = CopasiOptimizationSolver.solveLocalPython(new ParameterEstimationTaskSimulatorIDA(),parameterEstimationTask,optSolverCallbacks,mathMappingCallback);
            OptimizationResultSet optResultSet = CopasiOptimizationSolver.solveRemoteApi(new ParameterEstimationTaskSimulatorIDA(), parameterEstimationTask, optSolverCallbacks, mathMappingCallback);
            hashTable.put(ORS_KEY, optResultSet);
        }
    };
    taskList.add(task2);
    AsynchClientTask setResultTask = new AsynchClientTask("set results", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            OptimizationResultSet optResultSet = (OptimizationResultSet) hashTable.get(ORS_KEY);
            parameterEstimationTask.setOptimizationResultSet(optResultSet);
        }
    };
    taskList.add(setResultTask);
    ClientTaskDispatcher.dispatch(this, new Hashtable<String, Object>(), taskList.toArray(new AsynchClientTask[taskList.size()]), getRunStatusDialog(), true, true, true, null, false);
}
Also used : OptimizationException(cbit.vcell.opt.OptimizationException) AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) Issue(org.vcell.util.Issue) MathMappingCallbackTaskAdapter(cbit.vcell.mapping.MathMappingCallbackTaskAdapter) MathMappingCallback(cbit.vcell.mapping.SimulationContext.MathMappingCallback) Hashtable(java.util.Hashtable) OptimizationResultSet(cbit.vcell.opt.OptimizationResultSet) CopasiOptimizationMethod(cbit.vcell.opt.CopasiOptimizationMethod) IssueContext(org.vcell.util.IssueContext) OptimizationSolverSpec(cbit.vcell.opt.OptimizationSolverSpec) EventObject(java.util.EventObject) ParameterEstimationTaskSimulatorIDA(org.vcell.optimization.ParameterEstimationTaskSimulatorIDA)

Example 2 with IssueContext

use of org.vcell.util.IssueContext in project vcell by virtualcell.

the class DocumentValidUtil method checkIssuesForErrors.

public static void checkIssuesForErrors(BioModel bioModel) {
    Vector<Issue> issueList = new Vector<Issue>();
    IssueContext issueContext = new IssueContext();
    bioModel.gatherIssues(issueContext, issueList);
    checkIssuesForErrors(issueList);
}
Also used : Issue(org.vcell.util.Issue) IssueContext(org.vcell.util.IssueContext) Vector(java.util.Vector)

Example 3 with IssueContext

use of org.vcell.util.IssueContext in project vcell by virtualcell.

the class MathDescription method isValid.

public boolean isValid() {
    IssueContext issueContext = new IssueContext(ContextType.MathDescription, this, null);
    ArrayList<Issue> issueList = new ArrayList<Issue>();
    gatherIssues(issueContext, issueList);
    if (issueList.size() > 0) {
        setWarning(issueList.get(0).getMessage());
    }
    return issueList.size() == 0;
}
Also used : Issue(org.vcell.util.Issue) ArrayList(java.util.ArrayList) IssueContext(org.vcell.util.IssueContext)

Example 4 with IssueContext

use of org.vcell.util.IssueContext in project vcell by virtualcell.

the class IssueManager method updateIssues0.

/**
 * @param immediate update now, skip check of {@link #LAST_DIRTY_MILLISECONDS}
 */
private void updateIssues0(boolean immediate) {
    if (vcDocument == null) {
        return;
    }
    if (!immediate) {
        if (dirtyTimestamp == 0) {
            return;
        }
        long elapsedTime = System.currentTimeMillis() - dirtyTimestamp;
        if (elapsedTime < LAST_DIRTY_MILLISECONDS) {
            return;
        }
    }
    try {
        VCDocumentDecorator decorator = VCDocumentDecorator.getDecorator(vcDocument);
        numErrors = 0;
        numWarnings = 0;
        ArrayList<Issue> oldIssueList = new ArrayList<Issue>(issueList);
        ArrayList<Issue> tempIssueList = new ArrayList<Issue>();
        IssueContext issueContext = new ManagerContext();
        decorator.gatherIssues(issueContext, tempIssueList);
        // vcDocument.gatherIssues(issueContext,tempIssueList);
        issueList = new ArrayList<Issue>();
        for (Issue issue : tempIssueList) {
            if (issue instanceof SimpleBoundsIssue) {
                continue;
            }
            issueList.add(issue);
            Severity severity = issue.getSeverity();
            if (severity == Issue.Severity.ERROR) {
                numErrors++;
            } else if (severity == Issue.Severity.WARNING) {
                numWarnings++;
            }
        }
        fireIssueEventListener(new IssueEvent(vcDocument, oldIssueList, issueList));
    // System.out.println("\n................... update performed .................." + System.currentTimeMillis());
    } finally {
        dirtyTimestamp = 0;
        if (bMoreTime) {
            setDirty();
            bMoreTime = false;
        }
    }
}
Also used : SimpleBoundsIssue(cbit.vcell.model.SimpleBoundsIssue) Issue(org.vcell.util.Issue) VCDocumentDecorator(cbit.vcell.client.desktop.VCDocumentDecorator) SimpleBoundsIssue(cbit.vcell.model.SimpleBoundsIssue) ArrayList(java.util.ArrayList) IssueContext(org.vcell.util.IssueContext) Severity(org.vcell.util.Issue.Severity)

Example 5 with IssueContext

use of org.vcell.util.IssueContext in project vcell by virtualcell.

the class MathOverrides method hasUnusedOverrides.

public boolean hasUnusedOverrides() {
    ArrayList<Issue> issueList = new ArrayList<Issue>();
    IssueContext issueContext = new IssueContext(ContextType.Simulation, getSimulation(), null);
    gatherIssues(issueContext, issueList);
    for (Issue issue : issueList) {
        if (issue.getSeverity() == Issue.SEVERITY_ERROR && (issue.getCategory().equals(IssueCategory.Simulation_Override_NotFound) || issue.getCategory().equals(IssueCategory.Simulation_Override_NotSupported))) {
            return true;
        }
    }
    return false;
}
Also used : Issue(org.vcell.util.Issue) ArrayList(java.util.ArrayList) IssueContext(org.vcell.util.IssueContext)

Aggregations

IssueContext (org.vcell.util.IssueContext)17 Issue (org.vcell.util.Issue)14 ArrayList (java.util.ArrayList)9 ReactionRule (cbit.vcell.model.ReactionRule)4 Vector (java.util.Vector)4 MolecularType (org.vcell.model.rbm.MolecularType)4 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)3 MathDescription (cbit.vcell.math.MathDescription)3 Structure (cbit.vcell.model.Structure)3 Hashtable (java.util.Hashtable)3 SimulationContext (cbit.vcell.mapping.SimulationContext)2 Constant (cbit.vcell.math.Constant)2 Model (cbit.vcell.model.Model)2 RbmObservable (cbit.vcell.model.RbmObservable)2 SpeciesContext (cbit.vcell.model.SpeciesContext)2 OptimizationException (cbit.vcell.opt.OptimizationException)2 OptimizationResultSet (cbit.vcell.opt.OptimizationResultSet)2 Color (java.awt.Color)2 ParameterEstimationTaskSimulatorIDA (org.vcell.optimization.ParameterEstimationTaskSimulatorIDA)2 DecoratedIssueSource (cbit.vcell.client.desktop.DecoratedIssueSource)1