Opened 9 years ago
Closed 3 years ago
#3150 closed defect (fixed)
Wrong variability for array reduction
Reported by: | adrpo | Owned by: | adrpo |
---|---|---|---|
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 Changed 9 years ago by adrpo
- Owner changed from somebody to adrpo
- Status changed from new to accepted
comment:2 Changed 9 years ago by adrpo
- Resolution set to fixed
- Status changed from accepted to closed
comment:3 Changed 8 years ago by dietmarw
- Milestone changed from Future to pre1.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 Changed 7 years ago by sjoelund.se
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 Changed 7 years ago by sjoelund.se
- Resolution fixed deleted
- Status changed from closed to reopened
comment:6 Changed 7 years ago by sjoelund.se
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 Changed 6 years ago by sjoelund.se
- Milestone changed from pre1.9.4 to 1.9.4
comment:8 Changed 6 years ago by sjoelund.se
- Milestone changed from 1.9.4 to Future
comment:9 Changed 3 years ago by casella
- Component changed from Frontend to New Instantiation
- Milestone changed from Future to 1.17.0
- Resolution set to fixed
- Status changed from reopened to closed
Works in 1.17.0-dev, in including Buildings.Fluid.HeatExchangers.Validation.WetCoilDiscretizedInitializationPerfectGases
Fixed in r24514.