Skip to content

Should simulation really not depend on the output of getInstanceName()? #3444

@casella

Description

@casella

Section 3.7.4.5 defines getInstanceName() with the following non-normative text:

[The simulation result should not depend on the return value of this function.]

I see several issues with this.

The first question is, what's the point of writing a prohibition in the conditional instead of in the indicative, as in "The simulation result shall not depend on the return value of this function? What if it does, you get a slap on the wrist but then it's OK?

The second is, what's the point of putting a prohibition in the non-normative part of the specification? That makes it void and null by definition, I would say.

The third is, why is this text actually there at all? What's wrong at having the simulation result depending on the instance name? I can't really see what the problem could be.

The Modelica Standard Library actually contains models whose simulation results indeed depend on the return value of this function, and for a very good reason. The model Modelica.Blocks.Interfaces.PartialNoise sets the local seed of a random number generator by applying a hash function to the output of getInstanceName(). This guarantees that each separate instance of models extending it computes a different seed at initialization, so that each of them outputs a different pseudo-random number sequence.

To me, this is a perfectly legitimate use of getInstanceName(), and actually a smart idea by the library authors.

I would therefore propose to remove that non-normative line of text outright from the MLS.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions