/
testAlgLoop1.mos
70 lines (63 loc) · 3.23 KB
/
testAlgLoop1.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
// name: testAlgLoop1
// status: correct
// cflags: -d=-newInst
setCommandLineOptions("+gDynOpt +loop2con=all");
//setCommandLineOptions("+gDynOpt");
getErrorString();
loadString("
model testAlgLoop1
Real y(start = 1,max=0,min=-1);
Real y_ = -sqrt(sin(time +1));
Real cost annotation(isLagrange = true);
equation
y^2 = sin(time + 1); // -+sqrt(sin(time +1))
cost = (y + sqrt(sin(time +1)))^2;
end testAlgLoop1;
");
getErrorString();
optimize(testAlgLoop1, numberOfIntervals=50, tolerance = 1e-08, simflags="-lv LOG_IPOPT_ERROR -optimizerNP 3");
getErrorString();
res := OpenModelica.Scripting.compareSimulationResults("testAlgLoop1_res.mat","ReferenceFiles/testAlgLoop1_ref.mat","testAlgLoop1_diff.csv",0.01,0.0001,{"y","y_","cost"});
getErrorString();
// Result:
// true
// ""
// true
// ""
// record SimulationResult
// resultFile = "testAlgLoop1_res.mat",
// simulationOptions = "startTime = 0.0, stopTime = 1.0, numberOfIntervals = 50, tolerance = 1e-08, method = 'optimization', fileNamePrefix = 'testAlgLoop1', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-lv LOG_IPOPT_ERROR -optimizerNP 3'",
// messages = "assert | warning | The following assertion has been violated at time 0.000000
// | | | | $EqCon$y >= 0.0 and $EqCon$y <= 0.0
// assert | warning | Variable violating min/max constraint: 0.0 <= $EqCon$y <= 0.0, has value: 0.158529
// assert | warning | The following assertion has been violated at time 0.000000
// | | | | y >= -1.0 and y <= 0.0
// assert | warning | Variable violating min/max constraint: -1.0 <= y <= 0.0, has value: 1
// LOG_SUCCESS | info | The initialization finished successfully without homotopy method.
//
// Optimizer Variables
// ========================================================
// Input[0]:$y(start = 0, nominal = 1, min = -1, max = 0)
// --------------------------------------------------------
// number of nonlinear constraints: 1
// ========================================================
//
// ******************************************************************************
// 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 https://github.com/coin-or/Ipopt
// ******************************************************************************
//
// LOG_IPOPT_ERROR | info | max violation is 0.999898 for the constraint $EqCon$y(time = 0.572899)
// LOG_IPOPT_ERROR | info | max violation is 0.143661 for the constraint $EqCon$y(time = 0.00310102)
// LOG_IPOPT_ERROR | info | max violation is 0.00503129 for the constraint $EqCon$y(time = 0.00310102)
// LOG_IPOPT_ERROR | info | max violation is 7.46128e-06 for the constraint $EqCon$y(time = 0.00310102)
// LOG_IPOPT_ERROR | info | max violation is 1.65069e-11 for the constraint $EqCon$y(time = 0.00310102)
// LOG_SUCCESS | info | The simulation finished successfully.
// "
// end SimulationResult;
// ""
// {"Files Equal!"}
// "Warning: 'compareSimulationResults' is deprecated. It is recommended to use 'diffSimulationResults' instead.
// "
// endResult