Skip to content

Commit 44a312b

Browse files
committed
Print less output to pass the testsuite
Ipopt prints different error-messages depending on compiler flags (c++11). Instead, search for the OpenModelica message using a regex.
1 parent 2c1535d commit 44a312b

File tree

1 file changed

+28
-38
lines changed
  • openmodelica/cruntime/optimization/basic

1 file changed

+28
-38
lines changed

openmodelica/cruntime/optimization/basic/TFC5.mos

Lines changed: 28 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ model testFinalCon5
1212
Real y2;
1313
Real y3(start = -1);
1414
input Real u;
15-
15+
1616
Real final_con1(min = 0, max = 0) annotation(isFinalConstraint = true);
1717
Real final_con2(min = 0, max = 0) annotation(isFinalConstraint = true);
1818
Real cost annotation(isLagrange = true);
@@ -37,7 +37,17 @@ getErrorString();
3737

3838
setCommandLineOptions("+maxSizeSolveLinearSystem=0");
3939
getErrorString();
40-
optimize(testFinalCon5_, numberOfIntervals=20, tolerance = 1e-08, stopTime = 5, simflags="-optimizerNP 1");
40+
echo(false);
41+
res:=optimize(testFinalCon5_, numberOfIntervals=20, tolerance = 1e-08, stopTime = 5, simflags="-optimizerNP 1");
42+
messages:=res.messages;
43+
echo(true);
44+
res.resultFile;
45+
if regexBool(messages, "No optimal solution found") then
46+
print("No optimal solution found");
47+
else
48+
print("Optimal solution found? Weird...\n");
49+
exit(1);
50+
end if;
4151
getErrorString();
4252

4353
res := OpenModelica.Scripting.compareSimulationResults("testFinalCon5__res.mat","ReferenceFiles/testFinalCon5_ref.mat","testFinalCon_diff.csv",0.01,0.0001); // Files not equal!!! Testing other convergence with solveLinearSystem
@@ -57,29 +67,9 @@ getErrorString();
5767
// ""
5868
// true
5969
// ""
60-
// record SimulationResult
61-
// resultFile = "testFinalCon5__res.mat",
62-
// simulationOptions = "startTime = 0.0, stopTime = 5.0, numberOfIntervals = 20, tolerance = 1e-08, method = 'optimization', fileNamePrefix = 'testFinalCon5_', options = '', outputFormat = 'mat', variableFilter = '.*', cflags = '', simflags = '-optimizerNP 1'",
63-
// messages = "
64-
// Optimizer Variables
65-
// ========================================================
66-
// State[0]:x1(start = 0, nominal = 1, min = -Inf, max = +Inf, init = 0)
67-
// State[1]:x2(start = 0, nominal = 1, min = -Inf, max = +Inf, init = 0)
68-
// Input[2]:u(start = 0, nominal = 1, min = -Inf, max = +Inf)
69-
// --------------------------------------------------------
70-
// number of nonlinear constraints: 0
71-
// ========================================================
72-
//
73-
// ******************************************************************************
74-
// This program contains Ipopt, a library for large-scale nonlinear optimization.
75-
// Ipopt is released as open source code under the Eclipse Public License (EPL).
76-
// For more information visit http://projects.coin-or.org/Ipopt
77-
// ******************************************************************************
78-
//
79-
// stdout | warning | No optimal solution found!
80-
// | | | | Use -lv=LOG_IPOPT for more information.
81-
// "
82-
// end SimulationResult;
70+
// true
71+
// "testFinalCon5__res.mat"
72+
// No optimal solution found
8373
// "Warning: The initial conditions are not fully specified. Use +d=initialization for more information.
8474
// "
8575
// {"Files not Equal!","y2","y1","x2","x1","u","final_con2","final_con1","der(x2)","der(x1)","cost"}
@@ -159,35 +149,35 @@ getErrorString();
159149
// LOG_IPOPT_ERROR | info | max error is 0.00117418 for the approximation of the state x2(time = 1.62857)
160150
// LOG_IPOPT_ERROR | info | max error is 0.000226267 for the approximation of the state x2(time = 1.62857)
161151
// LOG_IPOPT_ERROR | info | max error is 0.00519079 for the approximation of the state x2(time = 1.62857)
162-
// LOG_IPOPT_ERROR | info | max error is 0.000680889 for the approximation of the state x2(time = 1.62857)
152+
// LOG_IPOPT_ERROR | info | max error is 0.000680888 for the approximation of the state x2(time = 1.62857)
163153
// LOG_IPOPT_ERROR | info | max error is 0.0254465 for the approximation of the state x2(time = 1.62857)
164154
// LOG_IPOPT_ERROR | info | max error is 0.00178654 for the approximation of the state x2(time = 1.62857)
165155
// LOG_IPOPT_ERROR | info | max error is 0.112826 for the approximation of the state x2(time = 1.62857)
166-
// LOG_IPOPT_ERROR | info | max error is 0.000871317 for the approximation of the state x2(time = 1.62143)
156+
// LOG_IPOPT_ERROR | info | max error is 0.000871319 for the approximation of the state x2(time = 1.62143)
167157
// LOG_IPOPT_ERROR | info | max error is 0.149317 for the approximation of the state x2(time = 1.62857)
168-
// LOG_IPOPT_ERROR | info | max error is 10.5399 for the approximation of the state x2(time = 1.62857)
169-
// LOG_IPOPT_ERROR | info | max error is 2.71878 for the approximation of the state x2(time = 1.62857)
170-
// LOG_IPOPT_ERROR | info | max error is 0.158984 for the approximation of the state x2(time = 1.62857)
171-
// LOG_IPOPT_ERROR | info | max error is 2.3919 for the approximation of the state x2(time = 1.62857)
172-
// LOG_IPOPT_ERROR | info | max error is 0.712657 for the approximation of the state x2(time = 1.62857)
173-
// LOG_IPOPT_ERROR | info | max error is 5.27759 for the approximation of the state x2(time = 1.62857)
174-
// LOG_IPOPT_ERROR | info | max error is 4.20358 for the approximation of the state x2(time = 1.62857)
158+
// LOG_IPOPT_ERROR | info | max error is 10.5397 for the approximation of the state x2(time = 1.62857)
159+
// LOG_IPOPT_ERROR | info | max error is 2.71868 for the approximation of the state x2(time = 1.62857)
160+
// LOG_IPOPT_ERROR | info | max error is 0.159005 for the approximation of the state x2(time = 1.62857)
161+
// LOG_IPOPT_ERROR | info | max error is 2.39191 for the approximation of the state x2(time = 1.62857)
162+
// LOG_IPOPT_ERROR | info | max error is 0.712649 for the approximation of the state x2(time = 1.62857)
163+
// LOG_IPOPT_ERROR | info | max error is 5.27761 for the approximation of the state x2(time = 1.62857)
164+
// LOG_IPOPT_ERROR | info | max error is 4.20359 for the approximation of the state x2(time = 1.62857)
175165
// LOG_IPOPT_ERROR | info | max error is 1.53825 for the approximation of the state x2(time = 1.62857)
176166
// LOG_IPOPT_ERROR | info | max error is 0.11331 for the approximation of the state x2(time = 1.62857)
177167
// LOG_IPOPT_ERROR | info | max error is 4.55291 for the approximation of the state x2(time = 1.62857)
178-
// LOG_IPOPT_ERROR | info | max error is 17755.1 for the approximation of the state x2(time = 2.62143)
168+
// LOG_IPOPT_ERROR | info | max error is 17754.6 for the approximation of the state x2(time = 2.62143)
179169
// LOG_IPOPT_ERROR | info | max error is 1.1024 for the approximation of the state x2(time = 1.62857)
180170
// LOG_IPOPT_ERROR | info | max error is 0.335883 for the approximation of the state x2(time = 1.62857)
181171
// LOG_IPOPT_ERROR | info | max error is 0.160613 for the approximation of the state x2(time = 1.62857)
182-
// LOG_IPOPT_ERROR | info | max error is 0.78813 for the approximation of the state x2(time = 1.62857)
172+
// LOG_IPOPT_ERROR | info | max error is 0.788129 for the approximation of the state x2(time = 1.62857)
183173
// LOG_IPOPT_ERROR | info | max error is 2.2839 for the approximation of the state x2(time = 1.62857)
184174
// LOG_IPOPT_ERROR | info | max error is 0.270616 for the approximation of the state x2(time = 1.62857)
185175
// LOG_IPOPT_ERROR | info | max error is 0.167229 for the approximation of the state x2(time = 1.62857)
186176
// LOG_IPOPT_ERROR | info | max error is 1.21769 for the approximation of the state x2(time = 1.62857)
187177
// LOG_IPOPT_ERROR | info | max error is 1.50796 for the approximation of the state x2(time = 1.62857)
188178
// LOG_IPOPT_ERROR | info | max error is 0.035271 for the approximation of the state x2(time = 1.62857)
189-
// LOG_IPOPT_ERROR | info | max error is 1.28969e-05 for the approximation of the state x2(time = 1.62857)
190-
// LOG_IPOPT_ERROR | info | max error is 2.29608e-13 for the approximation of the state x1(time = 2.39286)
179+
// LOG_IPOPT_ERROR | info | max error is 1.2897e-05 for the approximation of the state x2(time = 1.62857)
180+
// LOG_IPOPT_ERROR | info | max error is 2.30774e-13 for the approximation of the state x1(time = 2.34286)
191181
// "
192182
// end SimulationResult;
193183
// "Warning: The initial conditions are not fully specified. Use +d=initialization for more information.

0 commit comments

Comments
 (0)