Opened 13 years ago

Last modified 13 years ago

#1621 closed defect (fixed)

Error flattening enumerations

Reported by: Leonardo Laguna Owned by: Leonardo Laguna
Priority: high Milestone:
Component: Version:
Keywords: Cc: Leonardo Laguna, Per Östlund

Description

Hi,

I have the following model.

 model modelInner
    parameter typeA param1 = typeA.e1;
    type typeA = enumeration(e1, e2 , e3 );
    parameter Boolean k1 = param1 == typeA.e1;
    parameter Boolean k2 = param1 == typeA.e2;
    parameter Boolean k3 = param1 == typeA.e3;
end modelInner;

It declares a parameter (param1) of typeA, where typeA is an enumeration.

When using this model in the following way it works correctly.

  model topModel
    modelInner m;
  end topModel;

but if I want to change the value of parameter param1 it gives a flattening error.

All the following cases fail.

 modelInner m(param1 = typeA.e2); 
 modelInner m(param1 = modelInner.typeA.e2);
 modelInner m(param1 = testModel.modelInner.typeA.e2); 
 modelInner m(); 

with the following error:

Error: Variable typeA.e2 not found in scope testModel.modelInner
Error: Error occured while flattening model testModel.topModel

Please find attached the code.

Thank you.

Attachments (1)

testModel.mo (388 bytes ) - added by Leonardo Laguna 13 years ago.

Download all attachments as: .zip

Change History (3)

by Leonardo Laguna, 13 years ago

Attachment: testModel.mo added

comment:1 by Martin Sjölund, 13 years ago

I'm a bit unsure of some of the other examples (modelInner does not adhere to the restrictions of a package), but the following should of course work:

model modelInner
    parameter typeA param1 = typeA.e1;
    type typeA = enumeration(e1, e2 , e3 );
end modelInner;

model topModel
  modelInner m(); 
end topModel;

comment:2 by Per Östlund, 13 years ago

Fixed in r9911. The attached model now works as it's written, and it also works with empty parenthesis. The other two cases (typeA.e2 and modelInner.typeA.e2) does not work, and shouldn't work since they reference the wrong scopes.

Note: See TracTickets for help on using tickets.