Opened 4 years ago

Closed 3 years ago

#6101 closed defect (fixed)

Issue with arrays of components containing conditional components in the NF

Reported by: Francesco Casella Owned by: Per Östlund
Priority: blocker Milestone: 1.19.0
Component: New Instantiation Version:
Keywords: Cc: Andrea Bartolini

Description

Please consider the attached package, also reported here for convenience.

package TestConditionalArray3
  connector C
    Real x;
    flow Real y;
  end C;

  model M1
    C c;
  equation
    c.x = 10;
  end M1;
  
  model M2
    parameter Boolean act;
    C c;
    M3 m3 if act;
    M4 m4 if not act;
  equation
    connect(c, m3.c);
    connect(c, m4.c);
  end M2;

  model M3
    C c;
  equation
    c.y = 1;
  end M3;
  
  model M4
    C c;
  equation
    c.y = 2;
  end M4;

  model S
    parameter Integer N = 3;
    parameter Boolean act[3] = {true, true, false};
    M1 m1;
    M2 m2[N](act = act);
  equation
  for i in 1:N loop
      connect(m1.c, m2[i].c);
    end for;
  end S;
end TestConditionalArray3;

Try to compile model S. The NF complains that

[TestConditionalArray3: 16:5-16:17]: 
The conditional expression {true, true, false} could not be evaluated.

while the OF processes the model without a hiccup. I understand this is perfectly legal, so it should also be handled by the NF.

Attachments (1)

TestConditionalArray3.mo (688 bytes ) - added by Francesco Casella 4 years ago.

Download all attachments as: .zip

Change History (7)

by Francesco Casella, 4 years ago

Attachment: TestConditionalArray3.mo added

comment:1 by Per Östlund, 4 years ago

The issue is that there's only one node for e.g. m2.m3 and m2.m4 in the instance tree, and the NF handles deleted conditional components by replacing their node with a deleted component node. So currently the NF can't handle the case where only some elements in a structured array is deleted.

To handle this we'll have to add information to the deleted component node that indicates which scalar elements are deleted (which is a bit more complicated than it might sound like), and take the subscripts into account when checking for deleted components during connection handling.

comment:2 by Francesco Casella, 4 years ago

Milestone: 1.16.01.17.0

Retargeted to 1.17.0 after 1.16.0 release

comment:3 by Francesco Casella, 4 years ago

Milestone: 1.17.01.18.0

Rescheduled to 1.18.0

comment:4 by Francesco Casella, 3 years ago

Milestone: 1.18.0

Ticket retargeted after milestone closed

comment:5 by Francesco Casella, 3 years ago

Milestone: 1.19.0

1.18.0 blocker tickets moved to 1.19.0

comment:6 by Per Östlund, 3 years ago

Resolution: fixed
Status: newclosed

This was fixed a few weeks ago in 78435df8.

Note: See TracTickets for help on using tickets.