Opened 10 years ago

Closed 10 years ago

Last modified 7 years ago

#3213 closed defect (fixed)

Failure with arrays composed of arrays if at least one index is of enumeration type

Reported by: Gustaf Thorslund Owned by: somebody
Priority: high Milestone: 1.9.4
Component: Backend Version: trunk
Keywords: array, enumeration, index, algorithm Cc: Per Östlund, Lennart Ochel, Willi Braun

Description (last modified by Gustaf Thorslund)

This is more or less ticket #3212 reloaded (revolutions might come later)

Instead of just indexing a real valued array with enumeration types, one may want to take the abstraction one step further and create arrays of arrays. Now (using r25040) if one of the indexes happens to be of enumeration type one will run into trouble.

package ArrayArrayTest
  constant Integer N = 3;
  type E = enumeration (e1, e2, e3);
  type AI = Real[N];
  type AE = Real[E];
  type AEAE = AE[E];
  type AEAI = AI[E];
  type AIAE = AE[N];
  type AIAI = AI[N];

  model AEAETest
    AEAE x(each start=0, each fixed=true);
  algorithm
    when sample(0,0.1) then
      for i loop
  for j loop
    x[i, j] := time;
  end for;
      end for;
    end when;
  end AEAETest;

  model AEAITest
    AEAI x(each start=0, each fixed=true);
  algorithm
    when sample(0,0.1) then
      for i loop
  for j loop
    x[i, j] := time;
  end for;
      end for;
    end when;
  end AEAITest;

  model AIAETest
    AIAE x(each start=0, each fixed=true);
  algorithm
    when sample(0,0.1) then
      for i loop
  for j loop
    x[i, j] := time;
  end for;
      end for;
    end when;
  end AIAETest;

  model AIAITest
    AIAI x(each start=0, each fixed=true);
  algorithm
    when sample(0,0.1) then
      for i loop
  for j loop
    x[i, j] := time;
  end for;
      end for;
    end when;
  end AIAITest;
end ArrayArrayTest;

Now when trying to generate code of AEAETest, AEAITest or AIAETest all fail in the same way, so to save some space I'm just posting the result of AEAETest:

build$ omc ../ArrayArrayTest.mo -i=ArrayArrayTest.AEAETest -s
class ArrayArrayTest.AEAETest
  Real x[ArrayArrayTest.E.e1,ArrayArrayTest.E.e1];
  Real x[ArrayArrayTest.E.e1,ArrayArrayTest.E.e2];
  Real x[ArrayArrayTest.E.e1,ArrayArrayTest.E.e3];
  Real x[ArrayArrayTest.E.e2,ArrayArrayTest.E.e1];
  Real x[ArrayArrayTest.E.e2,ArrayArrayTest.E.e2];
  Real x[ArrayArrayTest.E.e2,ArrayArrayTest.E.e3];
  Real x[ArrayArrayTest.E.e3,ArrayArrayTest.E.e1];
  Real x[ArrayArrayTest.E.e3,ArrayArrayTest.E.e2];
  Real x[ArrayArrayTest.E.e3,ArrayArrayTest.E.e3];
algorithm
  when sample(0.0, 0.1) then
    for i in ArrayArrayTest.E.e1:ArrayArrayTest.E.e3 loop
      for j in ArrayArrayTest.E.e1:ArrayArrayTest.E.e3 loop
        x[i,j] := time;
      end for;
    end for;
  end when;
end ArrayArrayTest.AEAETest;
Error processing file: ../ArrayArrayTest.mo
Error: Model is structurally singular, error found sorting equations 
 1: algorithm
  when sample(1, 0.0, 0.1) then
    for i in ArrayArrayTest.E.e1:ArrayArrayTest.E.e3 loop
      for j in ArrayArrayTest.E.e1:ArrayArrayTest.E.e3 loop
        x[i,j] := time;
      end for;
    end for;
  end when;
;
 for variables 
 x[ArrayArrayTest.E.e3,ArrayArrayTest.E.e3](1), x[ArrayArrayTest.E.e3,ArrayArrayTest.E.e2](2), x[ArrayArrayTest.E.e3,ArrayArrayTest.E.e1](3), x[ArrayArrayTest.E.e2,ArrayArrayTest.E.e3](4), x[ArrayArrayTest.E.e2,ArrayArrayTest.E.e2](5), x[ArrayArrayTest.E.e2,ArrayArrayTest.E.e1](6), x[ArrayArrayTest.E.e1,ArrayArrayTest.E.e3](7), x[ArrayArrayTest.E.e1,ArrayArrayTest.E.e2](8), x[ArrayArrayTest.E.e1,ArrayArrayTest.E.e1](9)
Error: Internal error Transformation Module PFPlusExt index Reduction Method Pantelides failed!

# Error encountered! Exiting...
# Please check the error message and the flags.

Execution failed!

If just using integer indexes it works fine.

build$ omc ../ArrayArrayTest.mo -i=ArrayArrayTest.AIAITest -s
class ArrayArrayTest.AIAITest
  Real x[1,1];
  Real x[1,2];
  Real x[1,3];
  Real x[2,1];
  Real x[2,2];
  Real x[2,3];
  Real x[3,1];
  Real x[3,2];
  Real x[3,3];
algorithm
  when sample(0.0, 0.1) then
    for i in 1:3 loop
      for j in 1:3 loop
        x[i,j] := time;
      end for;
    end for;
  end when;
end ArrayArrayTest.AIAITest;

Building and simulation worked fine too.

$ omc --version
1.9.2+dev (r25040)

Change History (7)

comment:1 by Gustaf Thorslund, 10 years ago

Description: modified (diff)

comment:2 by Gustaf Thorslund, 10 years ago

Description: modified (diff)

comment:3 by Gustaf Thorslund, 10 years ago

Just verified the issue still remains in r25069, so was not fixed by the fix in r25063 (for ticket #3212).

comment:4 by Per Östlund, 10 years ago

Fixed in r25085, seems it was the same issue as #3212.

comment:5 by Per Östlund, 10 years ago

Resolution: fixed
Status: newclosed

comment:6 by Dietmar Winkler, 9 years ago

Milestone: Futurepre1.9.4

It doesn't make sense to keep closed ticket in the "Future" milestone that were simply forgotten to assign to the correct milestone in the past.

comment:7 by Martin Sjölund, 7 years ago

Milestone: pre1.9.41.9.4

Removing the pre1.9.4 milestone in favor of 1.9.4.

Note: See TracTickets for help on using tickets.