Opened 11 years ago

Closed 9 years ago

Last modified 7 years ago

#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 Martin Sjölund, 11 years ago

Is that the generated equation? Why is it not simplified to:

PNlib.Types.ArcType.inhibitor_arc == PNlib.Types.ArcType.inhibitor_arc and not P2.t_ <  IA1.testValue

comment:2 by Lennart Ochel, 11 years ago

That is the contion 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;
Version 0, edited 11 years ago by Lennart Ochel (next)

comment:3 by Per Östlund, 11 years ago

I have disabled the Test10 test case, please enable it again when this is fixed.

comment:4 by Lennart Ochel, 11 years ago

Owner: changed from Willi Braun to Lennart Ochel
Status: newaccepted

comment:5 by Lennart Ochel, 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.

in reply to:  3 ; comment:6 by Lennart Ochel, 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. ;-)

in reply to:  6 comment:7 by Per Östlund, 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 Willi Braun, 11 years ago

Owner: changed from Lennart Ochel to Willi Braun
Status: acceptedassigned

comment:9 by Lennart Ochel, 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 Lennart Ochel, 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 Lennart Ochel, 11 years ago

Well, it seems that my omc was not clean of changes. Both models trigger no events.

comment:12 by Lennart Ochel, 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 Martin Sjölund, 10 years ago

Milestone: 1.9.11.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 Martin Sjölund, 10 years ago

Milestone: 1.9.21.9.3

Milestone changed to 1.9.3 since 1.9.2 was released.

comment:15 by Martin Sjölund, 9 years ago

Milestone: 1.9.31.9.4

Moved to new milestone 1.9.4

comment:16 by Willi Braun, 9 years ago

Priority: blockerhigh

Is this really a blocker, since we moved it already for 3 releases, and in my option it is a corner case.

comment:17 by Martin Sjölund, 9 years ago

Milestone: 1.9.41.9.5

Milestone pushed to 1.9.5

comment:18 by Martin Sjölund, 9 years ago

Milestone: 1.9.51.10.0

Milestone renamed

comment:19 by Lennart Ochel, 9 years ago

Owner: changed from Willi Braun to Lennart Ochel
Status: assignedaccepted

comment:20 by Lennart Ochel, 9 years ago

Resolution: fixed
Status: acceptedclosed

It seems that all examples in this ticket work as expected now.

comment:21 by Martin Sjölund, 7 years ago

Milestone: 1.10.0

Milestone deleted

Note: See TracTickets for help on using tickets.