Skip to content

Commit 030c9b5

Browse files
lochelOpenModelica-Hudson
authored andcommitted
Emit protected variables
1 parent 771ca55 commit 030c9b5

File tree

3 files changed

+18
-35
lines changed

3 files changed

+18
-35
lines changed

openmodelica/cruntime/optimization/basic/DM.mos

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
// name: diesel_model
22
// status: correct
33

4-
setCommandLineOptions("+g=Optimica");
5-
getErrorString();
6-
7-
loadFile("DM.mo");
8-
getErrorString();
4+
setCommandLineOptions("+g=Optimica"); getErrorString();
5+
loadFile("DM.mo"); getErrorString();
96

107
echo(false);
11-
res := optimize(diesel_model, stopTime=0.5, numberOfIntervals=450,tolerance=1e-10, simflags="-lv LOG_IPOPT -optimizerNP 1");
8+
res := optimize(diesel_model, stopTime=0.5, numberOfIntervals=450,tolerance=1e-10, simflags="-lv LOG_IPOPT -optimizerNP 1 -emit_protected");
129
messages:=res.messages;
1310
echo(true);
1411
res.resultFile;
1512
if regexBool(messages, "EXIT: Optimal Solution Found.") then
16-
if regexBool(messages, "Number of Iterations....: 46") then
13+
if regexBool(messages, "Number of Iterations....: 46") then
1714
print("Number of Iterations....: 46\nEXIT: Optimal Solution Found.");
1815
else
1916
print("Number of Iterations changed.\tUpdate test\n");
@@ -25,8 +22,6 @@ else
2522
end if;
2623
getErrorString();
2724

28-
29-
3025
res := OpenModelica.Scripting.compareSimulationResults("diesel_model_res.mat","ReferenceFiles/diesel_model_ref.mat","diesel_model_res.csv",0.05,0.0005);
3126
getErrorString();
3227

openmodelica/cruntime/optimization/basic/DMwarm.mos

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
// name: diesel_model_warm_start
22
// status: correct
33

4-
setCommandLineOptions("+g=Optimica");
5-
getErrorString();
4+
setCommandLineOptions("+g=Optimica"); getErrorString();
5+
loadFile("DM.mo"); getErrorString();
66

7-
loadFile("DM.mo");
8-
getErrorString();
7+
optimize(diesel_model, stopTime=0.5, numberOfIntervals=450,tolerance=1e-10, simflags="-lv LOG_IPOPT_ERROR -optimizerNP 1 -exInputFile ./ReferenceFiles/initDM.csv -ipopt_warm_start 12 -emit_protected"); getErrorString();
98

10-
optimize(diesel_model, stopTime=0.5, numberOfIntervals=450,tolerance=1e-10, simflags="-lv LOG_IPOPT_ERROR -optimizerNP 1 -exInputFile ./ReferenceFiles/initDM.csv -ipopt_warm_start 12");
11-
getErrorString();
12-
13-
res := OpenModelica.Scripting.compareSimulationResults("diesel_model_res.mat","ReferenceFiles/diesel_model_ref.mat","diesel_model_res.csv",0.05,0.0005);
14-
getErrorString();
9+
res := OpenModelica.Scripting.compareSimulationResults("diesel_model_res.mat","ReferenceFiles/diesel_model_ref.mat","diesel_model_res.csv",0.05,0.0005); getErrorString();
1510

1611
// Result:
1712
// true
@@ -20,7 +15,7 @@ getErrorString();
2015
// ""
2116
// record SimulationResult
2217
// resultFile = "diesel_model_res.mat",
23-
// simulationOptions = "startTime = 0.0, stopTime = 0.5, numberOfIntervals = 450, tolerance = 1e-10, method = 'optimization', fileNamePrefix = 'diesel_model', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-lv LOG_IPOPT_ERROR -optimizerNP 1 -exInputFile ./ReferenceFiles/initDM.csv -ipopt_warm_start 12'",
18+
// simulationOptions = "startTime = 0.0, stopTime = 0.5, numberOfIntervals = 450, tolerance = 1e-10, method = 'optimization', fileNamePrefix = 'diesel_model', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-lv LOG_IPOPT_ERROR -optimizerNP 1 -exInputFile ./ReferenceFiles/initDM.csv -ipopt_warm_start 12 -emit_protected'",
2419
// messages = "
2520
// Optimizer Variables
2621
// ========================================================
@@ -53,7 +48,7 @@ getErrorString();
5348
// LOG_IPOPT_ERROR | info | max error is 2.52825e-08 for the approximation of the state p_em(time = 0.485556)
5449
// LOG_IPOPT_ERROR | info | max error is 3.66997e-09 for the approximation of the state p_em(time = 0.485556)
5550
// LOG_IPOPT_ERROR | info | max error is 1.48205e-10 for the approximation of the state p_em(time = 0.485556)
56-
// LOG_IPOPT_ERROR | info | max error is 2.86256e-13 for the approximation of the state p_em(time = 0.485556)
51+
// LOG_IPOPT_ERROR | info | max error is 2.86215e-13 for the approximation of the state p_em(time = 0.485556)
5752
// "
5853
// end SimulationResult;
5954
// ""

openmodelica/cruntime/optimization/basic/DMwarmCsv.mos

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
11
// name: diesel_model_warm_start
22
// status: correct
33

4-
setCommandLineOptions("+g=Optimica");
5-
getErrorString();
4+
setCommandLineOptions("+g=Optimica"); getErrorString();
5+
loadFile("DM.mo"); getErrorString();
66

7-
loadFile("DM.mo");
8-
getErrorString();
7+
optimize(diesel_model, stopTime=0.5, numberOfIntervals=450,tolerance=1e-10, simflags="-lv LOG_IPOPT_ERROR -optimizerNP 1 -exInputFile ./ReferenceFiles/initDM.csv -ipopt_warm_start 12 -emit_protected", outputFormat="csv"); getErrorString();
8+
optimize(diesel_model, stopTime=0.5, numberOfIntervals=450,tolerance=1e-10, simflags="-lv LOG_IPOPT_ERROR -optimizerNP 1 -csvInput ./diesel_model_res.csv -ipopt_max_iter=-1 -emit_protected", outputFormat="mat"); getErrorString();
99

10-
optimize(diesel_model, stopTime=0.5, numberOfIntervals=450,tolerance=1e-10, simflags="-lv LOG_IPOPT_ERROR -optimizerNP 1 -exInputFile ./ReferenceFiles/initDM.csv -ipopt_warm_start 12", outputFormat="csv");
11-
getErrorString();
12-
13-
optimize(diesel_model, stopTime=0.5, numberOfIntervals=450,tolerance=1e-10, simflags="-lv LOG_IPOPT_ERROR -optimizerNP 1 -csvInput ./diesel_model_res.csv -ipopt_max_iter=-1", outputFormat="mat");
14-
getErrorString();
15-
16-
res := OpenModelica.Scripting.compareSimulationResults("diesel_model_res.mat","ReferenceFiles/diesel_model_ref.mat","diesel_model_diff.csv",0.05,0.0005,{"u_f","u_wg"});
17-
getErrorString();
10+
res := OpenModelica.Scripting.compareSimulationResults("diesel_model_res.mat","ReferenceFiles/diesel_model_ref.mat","diesel_model_diff.csv",0.05,0.0005,{"u_f","u_wg"}); getErrorString();
1811

1912
// Result:
2013
// true
@@ -23,7 +16,7 @@ getErrorString();
2316
// ""
2417
// record SimulationResult
2518
// resultFile = "diesel_model_res.csv",
26-
// simulationOptions = "startTime = 0.0, stopTime = 0.5, numberOfIntervals = 450, tolerance = 1e-10, method = 'optimization', fileNamePrefix = 'diesel_model', options = '', outputFormat = 'csv', variableFilter = '.*', cflags = '', simflags = '-lv LOG_IPOPT_ERROR -optimizerNP 1 -exInputFile ./ReferenceFiles/initDM.csv -ipopt_warm_start 12'",
19+
// simulationOptions = "startTime = 0.0, stopTime = 0.5, numberOfIntervals = 450, tolerance = 1e-10, method = 'optimization', fileNamePrefix = 'diesel_model', options = '', outputFormat = 'csv', variableFilter = '.*', cflags = '', simflags = '-lv LOG_IPOPT_ERROR -optimizerNP 1 -exInputFile ./ReferenceFiles/initDM.csv -ipopt_warm_start 12 -emit_protected'",
2720
// messages = "
2821
// Optimizer Variables
2922
// ========================================================
@@ -56,13 +49,13 @@ getErrorString();
5649
// LOG_IPOPT_ERROR | info | max error is 2.52825e-08 for the approximation of the state p_em(time = 0.485556)
5750
// LOG_IPOPT_ERROR | info | max error is 3.66997e-09 for the approximation of the state p_em(time = 0.485556)
5851
// LOG_IPOPT_ERROR | info | max error is 1.48205e-10 for the approximation of the state p_em(time = 0.485556)
59-
// LOG_IPOPT_ERROR | info | max error is 2.86256e-13 for the approximation of the state p_em(time = 0.485556)
52+
// LOG_IPOPT_ERROR | info | max error is 2.86215e-13 for the approximation of the state p_em(time = 0.485556)
6053
// "
6154
// end SimulationResult;
6255
// ""
6356
// record SimulationResult
6457
// resultFile = "diesel_model_res.mat",
65-
// simulationOptions = "startTime = 0.0, stopTime = 0.5, numberOfIntervals = 450, tolerance = 1e-10, method = 'optimization', fileNamePrefix = 'diesel_model', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-lv LOG_IPOPT_ERROR -optimizerNP 1 -csvInput ./diesel_model_res.csv -ipopt_max_iter=-1'",
58+
// simulationOptions = "startTime = 0.0, stopTime = 0.5, numberOfIntervals = 450, tolerance = 1e-10, method = 'optimization', fileNamePrefix = 'diesel_model', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-lv LOG_IPOPT_ERROR -optimizerNP 1 -csvInput ./diesel_model_res.csv -ipopt_max_iter=-1 -emit_protected'",
6659
// messages = "
6760
// Optimizer Variables
6861
// ========================================================

0 commit comments

Comments
 (0)