Opened 6 years ago
Last modified 3 years ago
#5041 new defect
assert on parameters are not called in the right order
Reported by: | Francesco Casella | Owned by: | Lennart Ochel |
---|---|---|---|
Priority: | critical | Milestone: | |
Component: | Backend | Version: | |
Keywords: | Cc: |
Description
Please consider the following test case
model TestInitialAssert parameter Real p = 0; parameter Real q = 1/p; initial equation assert(p > 0, "p must be positive"); end TestInitialAssert;
OMEdit fails with
assert | debug | division by zero at time 0, (a=1) / (b=0), where divisor b expression is: p
In fact, the model contains an assertion on p
that could convey more useful information to the end user, but which is not triggered because the expression 1/p
is evaluated first and causes the initialization to fail, which is precisely the reason why the assertion was put there in the first place.
Recommendation: assertions should be evaluated as early as possible in the BLT, i.e. as soon as the variables/parameters they depend on have been computed.
In this case, the assertion on p
should be computed right after the binding equation p = 1
has been evaluated, also in the case the assertion is put in the equation
section.
Change History (4)
comment:1 by , 5 years ago
Milestone: | 1.14.0 → 1.16.0 |
---|
comment:3 by , 4 years ago
Milestone: | 1.17.0 → 1.18.0 |
---|
Retargeted to 1.18.0 because of 1.17.0 timed release.
Releasing 1.14.0 which is stable and has many improvements w.r.t. 1.13.2. This issue is rescheduled to 1.16.0