Search in sources :

Example 1 with SimpleBoundsIssue

use of cbit.vcell.model.SimpleBoundsIssue in project vcell by virtualcell.

the class StructureMapping method gatherIssues.

/**
 * Insert the method's description here.
 * Creation date: (11/1/2005 9:57:23 AM)
 * @param issueVector java.util.Vector
 */
public void gatherIssues(IssueContext issueContext, List<Issue> issueVector) {
    // size parameter must be set to non zero value for new ode, and all stoch simulations.
    if (simulationContext != null) {
        Parameter sizeParam = null;
        if (simulationContext.getGeometry().getDimension() == 0) {
            sizeParam = getSizeParameter();
        } else {
            sizeParam = getUnitSizeParameter();
        }
        if (sizeParam != null) {
            if (sizeParam.getExpression() == null) {
                if (!simulationContext.getGeometryContext().isAllVolFracAndSurfVolSpecified()) {
                    issueVector.add(new Issue(this, issueContext, IssueCategory.StructureMappingSizeParameterNotSet, "Size parameter is not set.", Issue.SEVERITY_ERROR));
                }
            } else {
                try {
                    double val = sizeParam.getExpression().evaluateConstant();
                    if (val <= 0) {
                        issueVector.add(new Issue(this, issueContext, IssueCategory.StructureMappingSizeParameterNotPositive, "Size parameter is not positive.", Issue.SEVERITY_ERROR));
                    }
                } catch (ExpressionException e) {
                    e.printStackTrace();
                    issueVector.add(new Issue(this, issueContext, IssueCategory.StructureMappingSizeParameterNotConstant, "Size parameter is not a constant.", Issue.SEVERITY_ERROR));
                }
            }
        }
    }
    // 
    for (int i = 0; fieldParameters != null && i < fieldParameters.length; i++) {
        RealInterval simpleBounds = parameterBounds[fieldParameters[i].getRole()];
        if (simpleBounds != null) {
            String parmName = fieldParameters[i].getNameScope().getName() + "." + fieldParameters[i].getName();
            issueVector.add(new SimpleBoundsIssue(fieldParameters[i], issueContext, simpleBounds, "parameter " + parmName + ": must be within " + simpleBounds.toString()));
        }
    }
    if (geometryClass == null) {
        issueVector.add(new Issue(this, issueContext, IssueCategory.StructureNotMapped, getStructure().getTypeName() + " " + getStructure().getName() + " is not mapped to a geometry subdomain.", Issue.SEVERITY_WARNING));
    }
    if (geometryClass != null && simulationContext.getGeometryContext().getGeometry().getDimension() > 0) {
        detectMappingConflictIssues(issueContext, issueVector, this);
    }
}
Also used : SimpleBoundsIssue(cbit.vcell.model.SimpleBoundsIssue) Issue(org.vcell.util.Issue) SimpleBoundsIssue(cbit.vcell.model.SimpleBoundsIssue) Parameter(cbit.vcell.model.Parameter) RealInterval(net.sourceforge.interval.ia_math.RealInterval) ExpressionException(cbit.vcell.parser.ExpressionException)

Example 2 with SimpleBoundsIssue

use of cbit.vcell.model.SimpleBoundsIssue 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 3 with SimpleBoundsIssue

use of cbit.vcell.model.SimpleBoundsIssue in project vcell by virtualcell.

the class ParameterContext method gatherIssues.

public void gatherIssues(IssueContext issueContext, List<Issue> issueList, ParameterRoleEnum userDefinedRole) {
    // 
    for (int i = 0; fieldUnresolvedParameters != null && i < fieldUnresolvedParameters.length; i++) {
        issueList.add(new Issue(fieldUnresolvedParameters[i], issueContext, IssueCategory.UnresolvedParameter, "Unresolved parameter '" + fieldUnresolvedParameters[i].getName(), Issue.SEVERITY_ERROR));
    }
    // 
    for (int i = 0; fieldParameters != null && i < fieldParameters.length; i++) {
        if (fieldParameters[i].getRole() == userDefinedRole) {
            try {
                if (!isReferenced(fieldParameters[i], 0)) {
                    issueList.add(new Issue(fieldParameters[i], issueContext, IssueCategory.KineticsUnreferencedParameter, "Unreferenced Kinetic Parameter '" + fieldParameters[i].getName(), Issue.SEVERITY_WARNING));
                }
            } catch (ExpressionException e) {
                issueList.add(new Issue(fieldParameters[i], issueContext, IssueCategory.KineticsExpressionError, "error resolving expression " + e.getMessage(), Issue.SEVERITY_WARNING));
            }
        }
    }
    // 
    if (fieldParameters != null) {
        for (LocalParameter parameter : this.fieldParameters) {
            if (parameter.getExpression() == null) {
                issueList.add(new Issue(parameter, issueContext, IssueCategory.KineticsExpressionMissing, "expression is missing", Issue.SEVERITY_INFO));
            } else {
                Expression exp = parameter.getExpression();
                String[] symbols = exp.getSymbols();
                String issueMessagePrefix = "parameter '" + parameter.getName() + "' ";
                if (symbols != null) {
                    for (int j = 0; j < symbols.length; j++) {
                        SymbolTableEntry ste = exp.getSymbolBinding(symbols[j]);
                        if (ste instanceof LocalProxyParameter) {
                            ste = ((LocalProxyParameter) ste).getTarget();
                        }
                        if (ste == null) {
                            issueList.add(new Issue(parameter, issueContext, IssueCategory.KineticsExpressionUndefinedSymbol, issueMessagePrefix + "references undefined symbol '" + symbols[j] + "'", Issue.SEVERITY_ERROR));
                        // } else if (ste instanceof SpeciesContext) {
                        // if (!getReactionStep().getModel().contains((SpeciesContext)ste)) {
                        // issueList.add(new Issue(parameter,issueContext,IssueCategory.KineticsExpressionUndefinedSymbol, issueMessagePrefix + "references undefined species '"+symbols[j]+"'",Issue.SEVERITY_ERROR));
                        // }
                        // if (reactionStep.countNumReactionParticipants((SpeciesContext)ste) == 0){
                        // issueList.add(new Issue(parameter,issueContext,IssueCategory.KineticsExpressionNonParticipantSymbol, issueMessagePrefix + "references species context '"+symbols[j]+"', but it is not a reactant/product/catalyst of this reaction",Issue.SEVERITY_WARNING));
                        // }
                        // } else if (ste instanceof ModelParameter) {
                        // if (!getReactionStep().getModel().contains((ModelParameter)ste)) {
                        // issueList.add(new Issue(parameter,issueContext,IssueCategory.KineticsExpressionUndefinedSymbol, issueMessagePrefix + "references undefined global parameter '"+symbols[j]+"'",Issue.SEVERITY_ERROR));
                        // }
                        }
                    }
                }
            }
        }
        // looking for local param which masks a global and issueing a warning
        for (LocalParameter parameter : fieldParameters) {
            String name = parameter.getName();
            SymbolTableEntry ste = nameScope.getExternalEntry(name, this);
            String steName;
            if (ste != null) {
                if (ste instanceof Displayable) {
                    steName = ((Displayable) ste).getDisplayType() + " " + ste.getName();
                } else {
                    steName = ste.getClass().getSimpleName() + " " + ste.getName();
                }
                String msg = steName + " is overriden by a local parameter " + name;
                issueList.add(new Issue(parameter, issueContext, IssueCategory.Identifiers, msg, Issue.SEVERITY_WARNING));
            }
        }
    }
    try {
        // 
        // determine unit consistency for each expression
        // 
        VCUnitSystem unitSystem = unitSystemProvider.getUnitSystem();
        VCUnitEvaluator unitEvaluator = new VCUnitEvaluator(unitSystem);
        for (int i = 0; i < fieldParameters.length; i++) {
            if (fieldParameters[i].getExpression() == null) {
                continue;
            }
            try {
                VCUnitDefinition paramUnitDef = fieldParameters[i].getUnitDefinition();
                VCUnitDefinition expUnitDef = unitEvaluator.getUnitDefinition(fieldParameters[i].getExpression());
                if (paramUnitDef == null) {
                    issueList.add(new Issue(fieldParameters[i], issueContext, IssueCategory.Units, "defined unit is null", Issue.SEVERITY_WARNING));
                } else if (paramUnitDef.isTBD()) {
                    issueList.add(new Issue(fieldParameters[i], issueContext, IssueCategory.Units, "undefined unit " + unitSystem.getInstance_TBD().getSymbol(), Issue.SEVERITY_WARNING));
                } else if (expUnitDef == null) {
                    issueList.add(new Issue(fieldParameters[i], issueContext, IssueCategory.Units, "computed unit is null", Issue.SEVERITY_WARNING));
                } else if (paramUnitDef.isTBD() || (!paramUnitDef.isEquivalent(expUnitDef) && !expUnitDef.isTBD())) {
                    issueList.add(new Issue(fieldParameters[i], issueContext, IssueCategory.Units, "inconsistent units, defined=[" + fieldParameters[i].getUnitDefinition().getSymbol() + "], computed=[" + expUnitDef.getSymbol() + "]", Issue.SEVERITY_WARNING));
                }
            } catch (VCUnitException e) {
                issueList.add(new Issue(fieldParameters[i], issueContext, IssueCategory.Units, e.getMessage(), Issue.SEVERITY_WARNING));
            } catch (ExpressionException e) {
                issueList.add(new Issue(fieldParameters[i], issueContext, IssueCategory.Units, e.getMessage(), Issue.SEVERITY_WARNING));
            }
        }
    } catch (Throwable e) {
        issueList.add(new Issue(parameterPolicy.getIssueSource(), issueContext, IssueCategory.Units, "unexpected exception: " + e.getMessage(), Issue.SEVERITY_INFO));
    }
    // 
    for (int i = 0; i < fieldParameters.length; i++) {
        RealInterval simpleBounds = parameterPolicy.getConstraintBounds(fieldParameters[i].getRole());
        if (simpleBounds != null) {
            String parmName = fieldParameters[i].getName();
            issueList.add(new SimpleBoundsIssue(fieldParameters[i], issueContext, simpleBounds, "parameter " + parmName + ": must be within " + simpleBounds.toString()));
        }
    }
}
Also used : Displayable(org.vcell.util.Displayable) VCUnitSystem(cbit.vcell.units.VCUnitSystem) SimpleBoundsIssue(cbit.vcell.model.SimpleBoundsIssue) Issue(org.vcell.util.Issue) SimpleBoundsIssue(cbit.vcell.model.SimpleBoundsIssue) RealInterval(net.sourceforge.interval.ia_math.RealInterval) ExpressionException(cbit.vcell.parser.ExpressionException) VCUnitException(cbit.vcell.units.VCUnitException) VCUnitEvaluator(cbit.vcell.parser.VCUnitEvaluator) SymbolTableEntry(cbit.vcell.parser.SymbolTableEntry) VCUnitDefinition(cbit.vcell.units.VCUnitDefinition) Expression(cbit.vcell.parser.Expression)

Example 4 with SimpleBoundsIssue

use of cbit.vcell.model.SimpleBoundsIssue in project vcell by virtualcell.

the class SpeciesContextSpec method gatherIssues.

/**
 * Insert the method's description here.
 * Creation date: (11/1/2005 10:03:46 AM)
 * @param issueVector java.util.Vector
 */
public void gatherIssues(IssueContext issueContext, List<Issue> issueVector) {
    issueContext = issueContext.newChildContext(ContextType.SpeciesContextSpec, this);
    // 
    for (int i = 0; i < fieldParameters.length; i++) {
        RealInterval simpleBounds = parameterBounds[fieldParameters[i].getRole()];
        if (simpleBounds != null) {
            String parmName = fieldParameters[i].getNameScope().getName() + "." + fieldParameters[i].getName();
            issueVector.add(new SimpleBoundsIssue(fieldParameters[i], issueContext, simpleBounds, "parameter " + parmName + ": must be within " + simpleBounds.toString()));
        }
    }
    if (bForceContinuous && !bConstant && getSimulationContext().isStoch() && (getSimulationContext().getGeometry().getDimension() > 0)) {
        // if it's particle or constant we're good
        SpeciesContext sc = getSpeciesContext();
        ReactionContext rc = getSimulationContext().getReactionContext();
        ReactionSpec[] rsArray = rc.getReactionSpecs();
        for (ReactionSpec rs : rsArray) {
            if (!rs.isExcluded()) {
                // we only care about reactions which are not excluded
                // true if "this" is part of current reaction
                boolean iAmParticipant = false;
                // true if current reaction has at least a particle participant
                boolean haveParticle = false;
                ReactionStep step = rs.getReactionStep();
                for (ReactionParticipant p : step.getReactionParticipants()) {
                    if (p instanceof Product || p instanceof Reactant) {
                        SpeciesContextSpec candidate = rc.getSpeciesContextSpec(p.getSpeciesContext());
                        if (candidate == this) {
                            iAmParticipant = true;
                        } else if (!candidate.isForceContinuous() && !candidate.isConstant()) {
                            haveParticle = true;
                        }
                    }
                }
                if (iAmParticipant && haveParticle) {
                    String msg = "Continuous Species won't conserve mass in particle reaction " + rs.getReactionStep().getName() + ".";
                    String tip = "Mass conservation for reactions of binding between discrete and continuous species is handled approximately. <br>" + "To avoid any algorithmic approximation, which may produce undesired results, the user is advised to indicate <br>" + "the continuous species in those reactions as modifiers (i.e. 'catalysts') in the physiology.";
                    issueVector.add(new Issue(this, issueContext, IssueCategory.Identifiers, msg, tip, Issue.SEVERITY_WARNING));
                    // we issue warning as soon as we found the first reaction which satisfies criteria
                    break;
                }
            }
        }
    }
    if (!bForceContinuous && bConstant) {
        if (getSimulationContext().isStoch() && (getSimulationContext().getGeometry().getDimension() > 0)) {
            String msg = "Clamped Species must be continuous rather than particles.";
            String tip = "If choose 'clamped', must also choose 'forceContinuous'";
            issueVector.add(new Issue(this, issueContext, IssueCategory.Identifiers, msg, tip, Issue.SEVERITY_ERROR));
        }
    }
    if (bForceContinuous && !bConstant) {
        if (getSimulationContext().isStoch() && (getSimulationContext().getGeometry().getDimension() == 0)) {
            String msg = "Non-constant species is forced continuous, not supported for nonspatial stochastic applications.";
            issueVector.add(new Issue(this, issueContext, IssueCategory.Identifiers, msg, Issue.SEVERITY_ERROR));
        }
    }
}
Also used : Issue(org.vcell.util.Issue) SimpleBoundsIssue(cbit.vcell.model.SimpleBoundsIssue) SimpleBoundsIssue(cbit.vcell.model.SimpleBoundsIssue) Product(cbit.vcell.model.Product) SpeciesContext(cbit.vcell.model.SpeciesContext) RealInterval(net.sourceforge.interval.ia_math.RealInterval) Reactant(cbit.vcell.model.Reactant) ReactionStep(cbit.vcell.model.ReactionStep) ReactionParticipant(cbit.vcell.model.ReactionParticipant)

Aggregations

SimpleBoundsIssue (cbit.vcell.model.SimpleBoundsIssue)4 Issue (org.vcell.util.Issue)4 RealInterval (net.sourceforge.interval.ia_math.RealInterval)3 ExpressionException (cbit.vcell.parser.ExpressionException)2 VCDocumentDecorator (cbit.vcell.client.desktop.VCDocumentDecorator)1 Parameter (cbit.vcell.model.Parameter)1 Product (cbit.vcell.model.Product)1 Reactant (cbit.vcell.model.Reactant)1 ReactionParticipant (cbit.vcell.model.ReactionParticipant)1 ReactionStep (cbit.vcell.model.ReactionStep)1 SpeciesContext (cbit.vcell.model.SpeciesContext)1 Expression (cbit.vcell.parser.Expression)1 SymbolTableEntry (cbit.vcell.parser.SymbolTableEntry)1 VCUnitEvaluator (cbit.vcell.parser.VCUnitEvaluator)1 VCUnitDefinition (cbit.vcell.units.VCUnitDefinition)1 VCUnitException (cbit.vcell.units.VCUnitException)1 VCUnitSystem (cbit.vcell.units.VCUnitSystem)1 ArrayList (java.util.ArrayList)1 Displayable (org.vcell.util.Displayable)1 Severity (org.vcell.util.Issue.Severity)1