When I try this simple modelica code in Wolfram Systemmodeler:
model bug
Integer y(start = 1);
equation
when time > 0.2 then
y = 5 "y = 2";
elsewhen time > 0.4 then
y = 4 "y = 3";
elsewhen time > 0.6 then
y = 3 "y = 4";
elsewhen time > 0.8 then
y = 2 "y = 5";
end when;
end bug;
the result is 1, 2, 3, 4, 5, like this: Model bug simulatiom. The when-equations seems to be activated in the reverse order.
On the othe hand, changing "equation" to "algorithm", and (of course) "=" to ":=" the code turns:
model nobug
Integer y(start = 1);
algorithm
when time > 0.2 then
y := 5;
elsewhen time > 0.4 then
y := 4;
elsewhen time > 0.6 then
y := 3;
elsewhen time > 0.8 then
y := 2;
end when;
end nobug;
and the result is as expected, 1, 5, 4, 3, 2, like this: Model nobug simulation
Is this a relatively basic problem in the Wolfram SystemModeler implementation, or there is something else I cannot see?