-
Notifications
You must be signed in to change notification settings - Fork 298
/
reduce1.mos
137 lines (128 loc) · 7.86 KB
/
reduce1.mos
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
// name: reduce1
// status: correct
setCommandLineOptions("+gDynOpt");
getErrorString();
loadString("
model reduceEx1
input Real u(min=-3,max=3);
Real y(start = 1);
Real x1;
Real x2;
Real x3;
Real x4;
Real cost annotation(isLagrange = true);
equation
der(y) = y*u ;
cost = (y + (sin(time +1)))^2;
der(x1) = x2;
der(x2) = x3;
der(x3) = x4;
der(x4) = x1 + x2*u;
end reduceEx1;
");
getErrorString();
optimize(reduceEx1, numberOfIntervals=50, tolerance = 1e-08, simflags="-lv LOG_IPOPT_ERROR -optimizerNP 3");
getErrorString();
res := OpenModelica.Scripting.compareSimulationResults("reduceEx1_res.mat","ReferenceFiles/reduceEx1_ref.mat","reduceEx1_diff.csv",0.01,0.0001,{"y","der(y)","u"});
getErrorString();
setCommandLineOptions("+gDynOpt +d=reduceDynOpt");
getErrorString();
optimize(reduceEx1, numberOfIntervals=50, tolerance = 1e-08, simflags="-lv LOG_IPOPT_ERROR -optimizerNP 3");
getErrorString();
res := OpenModelica.Scripting.compareSimulationResults("reduceEx1_res.mat","ReferenceFiles/reduceEx1_ref.mat","reduceEx1_diff.csv",0.01,0.0001,{"y","der(y)","u"});
getErrorString();
// Result:
// true
// ""
// true
// ""
// record SimulationResult
// resultFile = "reduceEx1_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 50, tolerance = 1e-08, method = 'optimization', fileNamePrefix = 'reduceEx1', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-lv LOG_IPOPT_ERROR -optimizerNP 3'",
// messages = "LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
//
// Optimizer Variables
// ========================================================
// State[0]:x1(start = 0, nominal = 1, min = -Inf, max = +Inf, init = 0)
// State[1]:x2(start = 0, nominal = 1, min = -Inf, max = +Inf, init = 0)
// State[2]:x3(start = 0, nominal = 1, min = -Inf, max = +Inf, init = 0)
// State[3]:x4(start = 0, nominal = 1, min = -Inf, max = +Inf, init = 0)
// State[4]:y(start = 1, nominal = 2, min = -Inf, max = +Inf, init = 1)
// Input[5]:u(start = 0, nominal = 3, min = -3, max = 3)
// --------------------------------------------------------
// number of nonlinear constraints: 0
// ========================================================
//
// ******************************************************************************
// This program contains Ipopt, a library for large-scale nonlinear optimization.
// Ipopt is released as open source code under the Eclipse Public License (EPL).
// For more information visit http://projects.coin-or.org/Ipopt
// ******************************************************************************
//
// LOG_IPOPT_ERROR | info | max error is 4.44089e-16 for the approximation of the state y(time = 0.00310102)
// LOG_IPOPT_ERROR | info | max error is 4.64394e-05 for the approximation of the state y(time = 0.412899)
// LOG_IPOPT_ERROR | info | max error is 0.00183911 for the approximation of the state y(time = 0.332899)
// LOG_IPOPT_ERROR | info | max error is 0.00189787 for the approximation of the state y(time = 0.472899)
// LOG_IPOPT_ERROR | info | max error is 0.00124182 for the approximation of the state y(time = 0.34)
// LOG_IPOPT_ERROR | info | max error is 0.00052515 for the approximation of the state y(time = 0.66)
// LOG_IPOPT_ERROR | info | max error is 0.000130639 for the approximation of the state y(time = 0.972899)
// LOG_IPOPT_ERROR | info | max error is 4.18708e-05 for the approximation of the state y(time = 0.992899)
// LOG_IPOPT_ERROR | info | max error is 1.73594e-06 for the approximation of the state y(time = 0.98)
// LOG_IPOPT_ERROR | info | max error is 1.09311e-08 for the approximation of the state y(time = 1)
// LOG_IPOPT_ERROR | info | max error is 3.68416e-06 for the approximation of the state y(time = 1)
// LOG_IPOPT_ERROR | info | max error is 7.03983e-07 for the approximation of the state y(time = 1)
// LOG_IPOPT_ERROR | info | max error is 6.96787e-08 for the approximation of the state y(time = 1)
// LOG_IPOPT_ERROR | info | max error is 9.86034e-10 for the approximation of the state y(time = 1)
// LOG_SUCCESS | info | The simulation finished successfully.
// "
// end SimulationResult;
// "Warning: The initial conditions are not fully specified. For more information set -d=initialization. In OMEdit Tools->Options->Simulation->OMCFlags, in OMNotebook call setCommandLineOptions(\"-d=initialization\").
// "
// {"Files Equal!"}
// "Warning: 'compareSimulationResults' is deprecated. It is recommended to use 'diffSimulationResults' instead.
// "
// true
// ""
// record SimulationResult
// resultFile = "reduceEx1_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 50, tolerance = 1e-08, method = 'optimization', fileNamePrefix = 'reduceEx1', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-lv LOG_IPOPT_ERROR -optimizerNP 3'",
// messages = "LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
//
// Optimizer Variables
// ========================================================
// State[0]:y(start = 1, nominal = 2, min = -Inf, max = +Inf, init = 1)
// Input[1]:u(start = 0, nominal = 3, min = -3, max = 3)
// --------------------------------------------------------
// number of nonlinear constraints: 0
// ========================================================
//
// ******************************************************************************
// This program contains Ipopt, a library for large-scale nonlinear optimization.
// Ipopt is released as open source code under the Eclipse Public License (EPL).
// For more information visit http://projects.coin-or.org/Ipopt
// ******************************************************************************
//
// LOG_IPOPT_ERROR | info | max error is 4.44089e-16 for the approximation of the state y(time = 0.00310102)
// LOG_IPOPT_ERROR | info | max error is 4.64394e-05 for the approximation of the state y(time = 0.412899)
// LOG_IPOPT_ERROR | info | max error is 0.00183911 for the approximation of the state y(time = 0.332899)
// LOG_IPOPT_ERROR | info | max error is 0.00189787 for the approximation of the state y(time = 0.472899)
// LOG_IPOPT_ERROR | info | max error is 0.00123963 for the approximation of the state y(time = 0.34)
// LOG_IPOPT_ERROR | info | max error is 0.000515132 for the approximation of the state y(time = 0.64)
// LOG_IPOPT_ERROR | info | max error is 0.000134445 for the approximation of the state y(time = 0.972899)
// LOG_IPOPT_ERROR | info | max error is 4.283e-05 for the approximation of the state y(time = 0.992899)
// LOG_IPOPT_ERROR | info | max error is 2.66096e-06 for the approximation of the state y(time = 0.98)
// LOG_IPOPT_ERROR | info | max error is 1.00932e-08 for the approximation of the state y(time = 1)
// LOG_IPOPT_ERROR | info | max error is 3.72096e-06 for the approximation of the state y(time = 1)
// LOG_IPOPT_ERROR | info | max error is 7.13136e-07 for the approximation of the state y(time = 1)
// LOG_IPOPT_ERROR | info | max error is 7.11342e-08 for the approximation of the state y(time = 1)
// LOG_IPOPT_ERROR | info | max error is 1.02648e-09 for the approximation of the state y(time = 1)
// LOG_SUCCESS | info | The simulation finished successfully.
// "
// end SimulationResult;
// "Warning: Deprecated debug flag -d=reduceDynOpt detected. Use --postOptModules+=reduceDynamicOptimization instead.
// Warning: The initial conditions are not fully specified. For more information set -d=initialization. In OMEdit Tools->Options->Simulation->OMCFlags, in OMNotebook call setCommandLineOptions(\"-d=initialization\").
// "
// {"Files Equal!"}
// "Warning: 'compareSimulationResults' is deprecated. It is recommended to use 'diffSimulationResults' instead.
// "
// endResult