Search in sources :

Example 21 with RealInterval

use of net.sourceforge.interval.ia_math.RealInterval in project vcell by virtualcell.

the class ASTFloatNode method bind.

public void bind(SymbolTable symbolTable) throws ExpressionBindingException {
    super.bind(symbolTable);
    setInterval(new RealInterval(value.doubleValue(), value.doubleValue()), null);
}
Also used : RealInterval(net.sourceforge.interval.ia_math.RealInterval)

Example 22 with RealInterval

use of net.sourceforge.interval.ia_math.RealInterval in project vcell by virtualcell.

the class ASTInvertTermNode method evaluateInterval.

public RealInterval evaluateInterval(RealInterval[] intervals) throws ExpressionException, DivideByZeroException {
    RealInterval childInterval = jjtGetChild(0).evaluateInterval(intervals);
    if (childInterval.lo() == 0.0 && childInterval.hi() == 0.0) {
        // 
        // DIVIDE BY ZERO !!!!!
        // 
        // form error message for user's consumption.
        // 
        String errorMsg = "divide by zero, divisor is \"" + jjtGetChild(0).infixString(LANGUAGE_DEFAULT) + "\"";
        Set<String> symbols = new HashSet<String>();
        jjtGetChild(0).getSymbols(LANGUAGE_DEFAULT, symbols);
        if (symbols.size() > 0) {
            errorMsg += "\n  where:\n";
            for (String symbol : symbols) {
                SymbolTableEntry symbolTableEntry = jjtGetChild(0).getBinding(symbol);
                errorMsg += "      " + symbolTableEntry.getName() + " = " + intervals[symbolTableEntry.getIndex()] + "\n";
            }
        }
        throw new DivideByZeroException(errorMsg);
    } else {
        setInterval(IAMath.div(new RealInterval(1.0), childInterval), intervals);
        return getInterval(intervals);
    }
}
Also used : RealInterval(net.sourceforge.interval.ia_math.RealInterval) HashSet(java.util.HashSet)

Example 23 with RealInterval

use of net.sourceforge.interval.ia_math.RealInterval in project vcell by virtualcell.

the class ASTMultNode method evaluateInterval.

public RealInterval evaluateInterval(RealInterval[] intervals) throws ExpressionException {
    RealInterval product = jjtGetChild(0).evaluateInterval(intervals);
    for (int i = 1; i < jjtGetNumChildren(); i++) {
        product = IAMath.mul(product, jjtGetChild(i).evaluateInterval(intervals));
    }
    setInterval(product, intervals);
    return getInterval(intervals);
}
Also used : RealInterval(net.sourceforge.interval.ia_math.RealInterval)

Example 24 with RealInterval

use of net.sourceforge.interval.ia_math.RealInterval in project vcell by virtualcell.

the class ASTRelationalNode method bind.

public void bind(SymbolTable symbolTable) throws ExpressionBindingException {
    super.bind(symbolTable);
    // either true or false
    setInterval(new RealInterval(0.0, 1.0), null);
}
Also used : RealInterval(net.sourceforge.interval.ia_math.RealInterval)

Example 25 with RealInterval

use of net.sourceforge.interval.ia_math.RealInterval in project vcell by virtualcell.

the class ASTRelationalNode method evaluateInterval.

public RealInterval evaluateInterval(RealInterval[] intervals) throws ExpressionException {
    if (jjtGetNumChildren() != 2) {
        throw new ExpressionException("Expected two children");
    }
    // 
    // this is a constraint (no value really is possible, exception maybe true/false).
    // the evaluation is done on both children to propagate values into identifiers.
    // 
    RealInterval first = jjtGetChild(0).evaluateInterval(intervals);
    RealInterval second = jjtGetChild(1).evaluateInterval(intervals);
    RealInterval result = null;
    try {
        switch(operation) {
            case GT:
                {
                    result = IAMath.vcell_gt(first, second);
                    break;
                }
            case LT:
                {
                    result = IAMath.vcell_lt(first, second);
                    break;
                }
            case GE:
                {
                    result = IAMath.vcell_ge(first, second);
                    break;
                }
            case LE:
                {
                    result = IAMath.vcell_le(first, second);
                    break;
                }
            case EQ:
                {
                    result = IAMath.vcell_eq(first, second);
                    break;
                }
            case NE:
                {
                    result = IAMath.vcell_ne(first, second);
                    break;
                }
        }
    } catch (IAFunctionDomainException e) {
        e.printStackTrace(System.out);
        throw new FunctionDomainException(e.getMessage());
    }
    setInterval(result, intervals);
    return getInterval(intervals);
}
Also used : IAFunctionDomainException(net.sourceforge.interval.ia_math.IAFunctionDomainException) IAFunctionDomainException(net.sourceforge.interval.ia_math.IAFunctionDomainException) RealInterval(net.sourceforge.interval.ia_math.RealInterval)

Aggregations

RealInterval (net.sourceforge.interval.ia_math.RealInterval)25 Expression (cbit.vcell.parser.Expression)7 ExpressionException (cbit.vcell.parser.ExpressionException)4 Issue (org.vcell.util.Issue)4 AbstractConstraint (cbit.vcell.constraints.AbstractConstraint)3 ConstraintContainerImpl (cbit.vcell.constraints.ConstraintContainerImpl)3 GeneralConstraint (cbit.vcell.constraints.GeneralConstraint)3 SimpleBounds (cbit.vcell.constraints.SimpleBounds)3 SimpleBoundsIssue (cbit.vcell.model.SimpleBoundsIssue)3 SpeciesContextSpecParameter (cbit.vcell.mapping.SpeciesContextSpec.SpeciesContextSpecParameter)2 Kinetics (cbit.vcell.model.Kinetics)2 KineticsParameter (cbit.vcell.model.Kinetics.KineticsParameter)2 MassActionKinetics (cbit.vcell.model.MassActionKinetics)2 SymbolTableEntry (cbit.vcell.parser.SymbolTableEntry)2 VCUnitEvaluator (cbit.vcell.parser.VCUnitEvaluator)2 VCUnitDefinition (cbit.vcell.units.VCUnitDefinition)2 VCUnitException (cbit.vcell.units.VCUnitException)2 ConstraintSolver (cbit.vcell.constraints.ConstraintSolver)1 SubVolume (cbit.vcell.geometry.SubVolume)1 SurfaceClass (cbit.vcell.geometry.SurfaceClass)1