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

The NF scrambles parameter indeces when instantiating arrays of components with 'each' parameter bindings #10794

Closed
casella opened this issue Jun 5, 2023 · 1 comment · Fixed by #10799
Assignees

Comments

@casella
Copy link
Contributor

casella commented Jun 5, 2023

Please consider the following MWE:

package WrongArrayBindings
  model M
    parameter Real p = 1;
    parameter Real q = 2;
  end M;

  model S
    parameter Real p = 2;
    M m[2,3](each p = 2*p);
  end S;
end WrongArrayBindings;

If I instantiate model S with these flags:

-f -d=nonfScalarize,arrayConnect,combineSubscripts,printRecordTypes,evaluateAllParameters,vectorizeBindings --newBackend --showStructuralAnnotations

I get

model 'WrongArrayBindings.S'
  parameter Real 'p' = 2.0;
  parameter Real[2, 3] 'm.q' = {{2.0, 2.0, 2.0}, {2.0, 2.0, 2.0}};
  parameter Real[2, 3] 'm.p' = {{4.0, 4.0}, {4.0, 4.0}, {4.0, 4.0}};
end 'WrongArrayBindings.S';

The binding equation for parameter 'm.q' (which was left at its default value) is correct. The binding equation for parameter 'm.p', which was changed with a modifier in model S, is dimensionally wrong, as the RHS is a Real[3,2] constant array, not a Real[2,3] constant array.

Expected Behaviour

I would expect the flattened model to be

model 'WrongArrayBindings.S'
  parameter Real 'p' = 2.0;
  parameter Real[2, 3] 'm.q' = {{2.0, 2.0, 2.0}, {2.0, 2.0, 2.0}};
  parameter Real[2, 3] 'm.p' = {{4.0, 4.0, 4.0}, {4.0, 4.0, 4.0}};
end 'WrongArrayBindings.S';
@casella
Copy link
Contributor Author

casella commented Jun 5, 2023

Keeping @mscuttari in the loop

perost added a commit to perost/OpenModelica that referenced this issue Jun 7, 2023
perost added a commit to perost/OpenModelica that referenced this issue Jun 7, 2023
perost added a commit to perost/OpenModelica that referenced this issue Jun 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants