Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testcase: Redeclarations: Order of Evaluation #61

Open
modelica-trac-importer opened this issue Nov 2, 2018 · 1 comment
Open

Testcase: Redeclarations: Order of Evaluation #61

modelica-trac-importer opened this issue Nov 2, 2018 · 1 comment
Assignees

Comments

@modelica-trac-importer
Copy link
Collaborator

Reported by choeger on 13 Aug 2014 09:07 UTC
Consider the following small model:

model Test2
  model C
    constant Real k = 1;
    constant Real p = 0;
  end C;

  model D
    constant Real k = 2;
    constant Real p = 2;
  end D;    

  model E
    replaceable model C2 = C;
    replaceable model C3 = C2(k = C2.p + 10);
      
    Real x;
    equation
     x = C3.k;   
  end E;

  model F = E(redeclare model C3 = D, redeclare model C2 = D);

  F e;
end Test2;

I wonder whether this is actually legal? C2 is certainly not transitively non-replacable, so can I have a "redeclaration chain" like that? Dymola accepts this. OpenModelica complains about a field not found.

Assuming it is legal, how about the modifications?

Basically, there are 3 ways to deal with the modification of C2:

  1. evaluate before redeclaration of C3 takes effect (i.e. C3=D, x=2)
    This may also be the case when the modification is discarded.
  2. evaluate after redeclaration of C3 takes effect, but before C2 (i.e. C3=C(k=C.p+2), x=10)
  3. evaluate after redeclaration of C3 and after C2 (i.e. C3=D(k=D.p+10), x=12)

AFAIK, modifications are "merged" according to the spec, i.e. the modification inside E is never lost. When we also assume that redeclarations are always applied before modifications, the only legal answer should be 3.

However we decide, I propose to add this as a test case to the compliance suite.


Migrated-From: https://trac.modelica.org/Modelica/ticket/1552

@HansOlsson
Copy link
Collaborator

I agree that only option 3 makes sense, and also that C2 isn't transitively non-replaceable as it should be.

Will need to check if there is any overlap, but otherwise I think it makes sense to add this as two two-cases, one for the "non-replaceable" issue and one for the value (modified in some way to avoid the previous issue).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants