#2684 closed defect (fixed)
unstable event system
Reported by: | Lennart Ochel | Owned by: | Lennart Ochel |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | Run-time | Version: | trunk |
Keywords: | Cc: |
Description
The OpenModelica event system seems to be unstable for PNlib.Examples.Test10 (see testsuite/simulation/libraries/3rdParty/PNlib r20361).
The example Test10 works fine with NumberOfIntervals=499 and NumberOfIntervals=501. It seems that there is a problem if the event point (time=1.5) is also a time-grid point. This is the case for example if NumberOfIntervals is set to 498 or 500. In both cases the event system is not able to find the following event:
{PNlib.Types.ArcType.normal_arc, PNlib.Types.ArcType.inhibitor_arc}[2] == PNlib.Types.ArcType.inhibitor_arc and not {P1.t_, P2.t_}[2] < {-1.0, IA1.testValue}[2]
.
Change History (21)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
That is the condition of the untriggered event. It is part of an for loop within an algorithm:
algorithm active := true; weaklyInputActiveVec := fill(false, nIn); weaklyOutputActiveVec := fill(false, nOut); //check input places for i in 1:nIn loop if arcType[i] == PNlib.Types.ArcType.normal_arc then if tIn[i] <= minTokens[i] and not fed[i] then active := false; elseif tIn[i] <= minTokens[i] and fed[i] then weaklyInputActiveVec[i] := true; end if; elseif arcType[i] == PNlib.Types.ArcType.inhibitor_arc and not tIn[i] < testValue[i] then active := false; end if; end for; // normal arc // inhibitor arc // invalid //output places for i in 1:nOut loop if tOut[i] >= maxTokens[i] and not emptied[i] then active := false; elseif tOut[i] >= maxTokens[i] and emptied[i] then weaklyOutputActiveVec[i] := true; end if; end for;
follow-up: 6 comment:3 by , 11 years ago
I have disabled the Test10 test case, please enable it again when this is fixed.
comment:4 by , 11 years ago
Owner: | changed from | to
---|---|
Status: | new → accepted |
comment:5 by , 11 years ago
Events get sometimes triggered a bit too early. This happens for example in Test10 for P2.t_ <= 0
. It get triggered at time=1.499999...
with P2.t_=9.998990524749211e-11
.
follow-up: 7 comment:6 by , 11 years ago
Replying to perost:
I have disabled the Test10 test case, please enable it again when this is fixed.
Well, I fixed it for the PNlib tests. Unfortunately my changes break a lot of other test cases (178 of 2562 failed). Probably I should deactivate all of them until someone fixes them. ;-)
comment:7 by , 11 years ago
Replying to lochel:
Replying to perost:
I have disabled the Test10 test case, please enable it again when this is fixed.
Well, I fixed it for the PNlib tests. Unfortunately my changes break a lot of other test cases (178 of 2562 failed). Probably I should deactivate all of them until someone fixes them. ;-)
The difference is that Test10 broke because PNlib was updated, i.e. because of an existing compiler issue. If 178 test cases break with your changes then either all those tests are wrong, or your fix is wrong. Guess which one is more likely ;)
comment:8 by , 11 years ago
Owner: | changed from | to
---|---|
Status: | accepted → assigned |
comment:9 by , 11 years ago
Here are two more model, which pinpoint the Problem of the event system:
model test Boolean a; equation a = exp(-time) > 0.0; annotation (experiment(StartTime=0, StopTime=25)); end test; // LOG_EVENTS | info | state event at time 23.0258509298 // | | | | | [0] exp(-time) > 0.0
model test2 Boolean a; equation a = 1/(time*time*time*time) > 0.0; annotation (experiment(StartTime=1, StopTime=1000)); end test2; // LOG_EVENTS | info | state event at time 316.227766009 // | | | | | [0] time ^ -4.0 > 0.0
Both model shouldn’t trigger any event.
comment:10 by , 11 years ago
It seems that somewhere is a magic border of 1e-10:
316.227766009^(-4) = 1.000000000*10^(-10) exp(-23.0258509298) = 9.999999999*10^(-11)
comment:11 by , 11 years ago
Well, it seems that my omc was not clean of changes. Both models trigger no events.
comment:12 by , 11 years ago
Next try:
The tests work the other way around:
model test2 Boolean a; equation a = 1/(time*time*time*time) > 1e-10; annotation (experiment(StartTime=1, StopTime=1000)); end test2;
This case should trigger an event at time=100*sqrt(10) (which is something like 316.2278), but OpenModelica is not able to find it. If the equation for a get replaced by a = 1/(time*time*time*time) > 2e-10;
even OpenModelica is able to find an event, but it get triggered too late. The reason is still the magic boarder of 1e-10, because the event is triggered after the zero crossing 1/(time*time*time*time) - 2e-10
becomes lower then -1e-10.
comment:13 by , 10 years ago
Milestone: | 1.9.1 → 1.9.2 |
---|
This ticket was not closed for 1.9.1, which has now been released. It was batch modified for milestone 1.9.2 (but maybe an empty milestone was more appropriate; feel free to change it).
comment:14 by , 10 years ago
Milestone: | 1.9.2 → 1.9.3 |
---|
Milestone changed to 1.9.3 since 1.9.2 was released.
comment:16 by , 9 years ago
Priority: | blocker → high |
---|
Is this really a blocker, since we moved it already for 3 releases, and in my option it is a corner case.
comment:19 by , 9 years ago
Owner: | changed from | to
---|---|
Status: | assigned → accepted |
comment:20 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | accepted → closed |
It seems that all examples in this ticket work as expected now.
Is that the generated equation? Why is it not simplified to: