Changeset 13612


Ignore:
Timestamp:
Sep 30, 2019 9:17:40 AM (2 months ago)
Author:
Jonathan Kämpe
Message:

#5844 Nominal evaluation during equation solving no longer evaluates parameters which in some cases lead to exceptions.

Location:
branches/dev-jk-2471/Compiler/ModelicaMiddleEnd
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • branches/dev-jk-2471/Compiler/ModelicaMiddleEnd/src/jastadd/structural/Symbolic.jrag

    r12811 r13612  
    182182                    negatedFactor = true;
    183183                } else if (ee.nbrUses(var.name())==0) {
    184                     if (ee.variability().constantVariability() &&
    185                             Math.abs(ee.ceval().realValue()) *
    186                             ee.dynamicFExp(var.nominal()).ceval().realValue() < tol) {
     184                    if (!nominalAllowsDivision(ee, var, tol)) {
    187185                        return new FNoExp();
    188186                    }
     
    207205        }
    208206        return FExp.createBalancedBinaryTree(new FAddExp(), parts);
     207    }
     208   
     209    /**
     210     * Check if nominal values allow the variable to be divided by the factor.
     211     */
     212    private static Boolean FEquation.nominalAllowsDivision(FExp factor, FVariable var, double tol) {
     213        if (factor.variability().constantVariability()) {
     214            FExp nominal = factor.dynamicFExp(var.nominal());
     215            if (nominal.variability().constantVariability() &&
     216                    Math.abs(factor.ceval().realValue()) *
     217                    nominal.ceval().realValue() < tol) {
     218                return false;
     219            }
     220        }
     221        return true;
    209222    }
    210223   
Note: See TracChangeset for help on using the changeset viewer.