Opened 12 years ago
Closed 12 years ago
#2601 closed defect (fixed)
attributes get lost for optimization models
| Reported by: | Lennart Ochel | Owned by: | Lennart Ochel |
|---|---|---|---|
| Priority: | high | Milestone: | 1.9.1 |
| Component: | Backend | Version: | trunk |
| Keywords: | Cc: | Willi Braun, Bernhard Bachmann |
Description
Some variable attributes get lost for the following model
setCommandLineOptions("+g=Optimica");
getErrorString();
loadString("
model BatchReactor
Real x2;
Real x1;
Real y2(start =0, fixed=true, min=-0.1, max=1e4, nominal = 3);
Real y1(start =1, fixed=true, min=-0.1, max=1e6, nominal = 2);
input Real u(min=-0.1, max = 2.0, nominal = 1.0,start = 1.0);
equation
x2 = a*y2;
x1 = b*y1;
b*der(y1) = -(u+u^2/2)*x1;
a*der(y2) = u*x1;
end BatchReactor;
optimization nmpcBatchReactor(objective = cost)
parameter Real a = 10;
parameter Real b = 20;
Real cost = -a*y2;
extends BatchReactor(y1(start =1/b, fixed=true, min=0, max=1/b, nominal = 1/b),
y2(start =0, fixed=true, min=0, max=1/a, nominal = 1/a),
u(min=0, max = 5.0, nominal = 1.0,start = 1.0));
end nmpcBatchReactor;
");
getErrorString();
optimize(nmpcBatchReactor, numberOfIntervals=20, tolerance = 1e-8,simflags="-lv LOG_IPOPT");
getErrorString();
If you run that mos-script, you will get the following output
true
""
true
""
record SimulationResult
resultFile = "/home/lochel/Documents/tests/Opt/nmpcBatchReactor_res.mat",
simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 20, tolerance = 1e-08, method = 'optimization', fileNamePrefix = 'nmpcBatchReactor', options = '', outputFormat = 'mat', variableFi
lter = '.*', measureTime = false, cflags = '', simflags = '-lv LOG_IPOPT'",
messages = "Optimizer Variables
========================================================
State[0]:y1(start = 0.05, nominal = 0.05, min = -Inf, max = 0.05, init = 0.05)
State[1]:y2(start = 0, nominal = 0.1, min = -Inf, max = 0.1, init = 0)
Input[2]:u(start = 1, nominal = 1, min = 0, max = 5)
--------------------------------------------------------
========================================================
[…]
As you can see, the min-Attributes are wrong (should be 0.0).
The min attributes get readout from the *_init.xml file, and some attributes are missing:
<ScalarVariable name = "y1" valueReference = "1000" variability = "continuous" isDiscrete = "false" causality = "internal" isValueChangeable = "true" alias = "noAlias" classIndex = "0" classType = "rSta" fileName = "<interactive>" startLine = "6" startColumn = "3" endLine = "6" endColumn = "64" fileWritable = "true"> <Real useStart="false" start="0.0" fixed="true" useNominal="true" /> </ScalarVariable>
Change History (6)
comment:1 by , 12 years ago
comment:2 by , 12 years ago
The max attribute is set correctly, because it is parameter dependent and therefore determined during initialization.
comment:3 by , 12 years ago
Probably I can fix it. I did some changes and get now:
======================================================== State[0]:y1(start = 0.05, nominal = 0.05, min = 0, max = 0.05, init = 0.05) State[1]:y2(start = 0, nominal = 0.1, min = 0, max = 0.1, init = 0) Input[2]:u(start = 1, nominal = 1, min = 0, max = 5) --------------------------------------------------------
Unfortunately, now I get another error ...
comment:4 by , 12 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → accepted |
Note:
See TracTickets
for help on using tickets.

Using +d=dumpindxdae shows that the min attributes are somehow present correctly in the back end:
Vitalij, why occurs the dumpindxdae dump that often for optimization models? It seems that there are different DAEs with partially overlapping variables. Is that on purpose?