Search in sources :

Example 1 with IAFunctionDomainException

use of net.sourceforge.interval.ia_math.IAFunctionDomainException 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

IAFunctionDomainException (net.sourceforge.interval.ia_math.IAFunctionDomainException)1 RealInterval (net.sourceforge.interval.ia_math.RealInterval)1