Opened 7 years ago

Last modified 3 years ago

#4994 assigned defect

Is startTime a built-in variable in OMC?

Reported by: Francesco Casella Owned by: Adeel Asghar
Priority: critical Milestone:
Component: OMEdit Version:
Keywords: Cc: danieljose.penagos@…, Adrian Pop

Description

Consider this test case

model Test
  parameter Real startTime = 1;
end Test;

When simulating it with OMC, the value of startTime is computed to be the value of StartTime in the simulation setup window, completely disregarding the binding equation.

Since startTime is a perfectly legal Modelica parameter name, if you use it in a model some nasty surprises will ensue...

Change History (17)

comment:1 by Francesco Casella, 7 years ago

Cc: danieljose.penagos@… added

comment:2 by Adeel Asghar, 6 years ago

Cc: Adrian Pop added
Component: OMEditFrontend
Owner: changed from Adeel Asghar to Per Östlund
Status: newassigned

Note sure if this is a frontend or backend issue.

in reply to:  2 comment:3 by Per Östlund, 6 years ago

Component: FrontendOMEdit

Replying to adeas31:

Note sure if this is a frontend or backend issue.

This script returns the correct value:

loadString("
  model Test
    parameter Real startTime = 1;
  end Test;
");

simulate(Test, startTime = 4, stopTime = 5);
readSimulationResult("Test_res.mat", startTime);

So the issue seems to be either with OMEdit or the API commands OMEdit uses to simulate. So I'm kicking it back to OMEdit until someone can show that the issue lies elsewhere.

comment:4 by Per Östlund, 6 years ago

Owner: changed from Per Östlund to Adeel Asghar

comment:5 by Adeel Asghar, 6 years ago

Ah okay I know why its happening. In OMEdit we call the simulation executable like this -override=startTime=4,stopTime=5 (note that this is actually required for re-simulation but to keep the code simple I have used it for both normal and re-simulation). This is overriding the parameter defined in the model. Not sure how fix this. Maybe in the runtime we should have a different override flag for simulation parameters and model parameters.

comment:6 by Francesco Casella, 6 years ago

See also #3810

comment:7 by Adrian Pop, 6 years ago

After the discussions in the OSMC dev meeting we decided to go with a new namespace for the settings: -override=settings.startTime=1,startTime=5

comment:8 by Francesco Casella, 6 years ago

Of course this assumes that nobody will ever put a top-level object named settings containing those parameters in his/her model :)

I guess the likelyhood of that happening is very close to zero...

comment:9 by Adrian Pop, 6 years ago

We could go for a prefix such as .startTime or $startTime.

comment:10 by Adeel Asghar, 6 years ago

These are also legal Modelica names.

comment:11 by Adrian Pop, 6 years ago

@adeas31: names can start with "." but only if they are classes and surely cannot start with "$".

IDENT = NONDIGIT { DIGIT | NONDIGIT } | Q-IDENT
Q-IDENT = "’" ( Q-CHAR | S-ESCAPE ) { Q-CHAR | S-ESCAPE } "’"
NONDIGIT = "_" | letters "a" to "z" | letters "A" to "Z"

comment:12 by Francesco Casella, 6 years ago

I'm for $startTime. BTW, this also allows to keep backwards compatibility by accepting startTime with the old meaning if the model does not have a top-level startTime parameter, while at the same time issuing a warining such as "please use $startTime instead".

The remaining question is, should we use €startTime instead?

Just kidding :)

comment:13 by Francesco Casella, 6 years ago

Milestone: 1.13.01.14.0

Rescheduled to 1.14.0 after 1.13.0 releasee

comment:14 by Francesco Casella, 5 years ago

Milestone: 1.14.01.16.0

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

comment:15 by Francesco Casella, 4 years ago

Milestone: 1.16.01.17.0

Retargeted to 1.17.0 after 1.16.0 release

comment:16 by Francesco Casella, 4 years ago

Milestone: 1.17.01.18.0

Retargeted to 1.18.0 because of 1.17.0 timed release.

comment:17 by Francesco Casella, 3 years ago

Milestone: 1.18.0

Ticket retargeted after milestone closed

Note: See TracTickets for help on using tickets.