Opened 10 years ago

Closed 4 years ago

#3150 closed defect (fixed)

Wrong variability for array reduction

Reported by: Adrian Pop Owned by: Adrian Pop
Priority: high Milestone: 1.17.0
Component: New Instantiation Version: trunk
Keywords: Cc:

Description

Flattening this model:

model BadVariability

  package Medium
    constant Boolean singleState = false;
  end Medium;

  parameter Integer nReg(min = 2) = 2;

  model CoilRegister  "Register for a heat exchanger" 
    constant Boolean initialize_p1 = not Medium.singleState;
  end CoilRegister;

  CoilRegister[nReg] hexReg(initialize_p1 = array(i == 1 and not Medium.singleState for i in 1:nReg));
end BadVariability;

gives:

adrpo@ida-liu050 ~/dev/OpenModelica/build/bin/media
$ ../omc +locale=C BadVariability.mo 
Error processing file: BadVariability.mo
[c:/bin/cygwin/home/adrpo/dev/OpenModelica/build/bin/media/BadVariability.mo:13:29-13:101:writable] Error: Component hexReg[2].initialize_p1 of variability CONST has binding false of higher variability PARAM.
Error: Error occurred while flattening model BadVariability

The variability should be constant for the array reduction, not parameter.

This affects some of the building models, see for example:
https://test.openmodelica.org/libraries/Buildings/files/Buildings.Fluid.HeatExchangers.Examples.WetCoilDiscretizedPerfectGases.err

Change History (9)

comment:1 by Adrian Pop, 10 years ago

Owner: changed from somebody to Adrian Pop
Status: newaccepted

comment:2 by Adrian Pop, 10 years ago

Resolution: fixed
Status: acceptedclosed

Fixed in r24514.

comment:3 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:4 by Martin Sjölund, 7 years ago

No, a reduction with an iterator that is paramter should not be able to assign to a constant. This also has the side-effect of making OM evaluate things like array(1 for i in 1:n) into {} regardless of value of the parameter n. I will revert this changeset since it conflicts with #4550.

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

Resolution: fixed
Status: closedreopened

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

If necessary for the library (especially old ones), we could have a debug-flag -d=allowAssigningParameterToConstant or something similar which forces evaluation of the parameter and prints a warning (which we could use in the library coverage).

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

Milestone: pre1.9.41.9.4

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

Milestone: 1.9.4Future

comment:9 by Francesco Casella, 4 years ago

Component: FrontendNew Instantiation
Milestone: Future1.17.0
Resolution: fixed
Status: reopenedclosed
Note: See TracTickets for help on using tickets.