ModelicaSpecification icon indicating copy to clipboard operation
ModelicaSpecification copied to clipboard

Meaning of argument-less experiment annotation

Open henrikt-ma opened this issue 2 years ago • 4 comments

Bringing up question as suggested in https://github.com/modelica/ModelicaSpecification/pull/2922#discussion_r639702197:

Quoting the grammar for the experiment annotation:

"experiment"
   [ "(" [ experimentOption { "," experimentOption } ] ")" ]

What is the purpose of allowing the annotation without argument list?

model M
  annotation(experiment); /* Valid, but what is the purpose? */
end M;

Why don't we simply require the argument list?

henrikt-ma avatar Sep 01 '21 12:09 henrikt-ma

Having an empty experiment would make sense if the experiment annotation was inherited, to mark the model as an experiment but the settings are elsewhere. (Or perhaps just stating it is an experiment; use default settings)

sjoelund avatar Sep 01 '21 12:09 sjoelund

Having an empty experiment would make sense if the experiment annotation was inherited, to mark the model as an experiment but the settings are elsewhere. (Or perhaps just stating it is an experiment; use default settings)

To me, it would be more natural to express that with experiment() instead, although I'm hesitant to consider anything without StopTime a meaningful experiment.

henrikt-ma avatar Sep 01 '21 12:09 henrikt-ma

Why is there even specific grammar for some of the annotations in the specification, while others are defined as records? The actual grammar of Modelica for annotations is annotation class-modification, which is not consistent with the grammar given for experiment.

OpenModelica ignores modifiers with neither submodifiers nor an expression (like Real x(start)), so for what it's worth we currently ignore an experiment annotation such as this. That might be wrong in this case since it means the model is not even marked as an experiment, but I guess that's what this issue is about.

perost avatar Sep 01 '21 13:09 perost

See also #2852, #2314 and #2535.

maltelenz avatar Sep 01 '21 13:09 maltelenz

Without reopening, let me just try to summarize how I interpret the resolution by #2999:

When an annotation is defined by a pseudo-record, the record constructor form must be used in order to express a valid annotation, so annotation(experiement) is invalid (but unfortunately, invalid annotations like this are not errors), while annotation(experiemnt()) is valid:

model A
  annotation(experiment(StartTime = -1.0));
end A;
model B
  extends A;
  /* This model has StartTime = -1.0, inherited from A. */
  annotation(experiment); /* Not a valid experiment annotation; means nothing at all. */
end B;
model C
  extends A;
  /* This model has StartTime = 0.0, coming from the local annotation. */
  annotation(experiment()); /* Valid annotation. */
end C;

henrikt-ma avatar Nov 22 '23 09:11 henrikt-ma

Without reopening, let me just try to summarize how I interpret the resolution by #2999:

When an annotation is defined by a pseudo-record, the record constructor form must be used in order to express a valid annotation, so annotation(experiement) is invalid (but unfortunately, invalid annotations like this are not errors), while annotation(experiemnt()) is valid:

model A
  annotation(experiment(StartTime = -1.0));
end A;
model B
  extends A;
  /* This model has StartTime = -1.0, inherited from A. */
  annotation(experiment); /* Not a valid experiment annotation; means nothing at all. */
end B;
model C
  extends A;
  /* This model has StartTime = 0.0, coming from the local annotation. */
  annotation(experiment()); /* Valid annotation. */
end C;

experiment() is not a record constructor in this context though, it's an empty class modifier. If the normal modifier semantics were to be used it wouldn't have any meaning either.

perost avatar Nov 22 '23 10:11 perost

experiment() is not a record constructor in this context though, it's an empty class modifier. If the normal modifier semantics were to be used it wouldn't have any meaning either.

This comment by @HansOlsson shows where the confusion comes from. I believe it is best we continue the discussion there.

henrikt-ma avatar Nov 22 '23 16:11 henrikt-ma