Skip to content

Commit

Permalink
added test for sort input-names in csvInput
Browse files Browse the repository at this point in the history
  • Loading branch information
vruge authored and OpenModelica-Hudson committed Feb 2, 2016
1 parent 506ea92 commit e254a60
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
84 changes: 84 additions & 0 deletions openmodelica/cruntime/optimization/basic/DMwarmCsv.mos
@@ -0,0 +1,84 @@
// name: diesel_model_warm_start
// status: correct

setCommandLineOptions("+g=Optimica");
getErrorString();

loadFile("DM.mo");
getErrorString();

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");
getErrorString();

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");
getErrorString();

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();

// Result:
// true
// ""
// true
// ""
// record SimulationResult
// resultFile = "diesel_model_res.csv",
// 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'",
// messages = "
// Optimizer Variables
// ========================================================
// State[0]:p_em(start = 0.339267, nominal = 1.01111, min = 0.337038, max = 1.01111, init = 0.339267)
// State[1]:p_im(start = 0.50615, nominal = 1.01111, min = 0.404445, max = 1.01111, init = 0.50615)
// State[2]:w_ice(start = 0.249899, nominal = 1, min = 0.0181818, max = 1, init = 0.249899)
// State[3]:w_tc(start = 0.0681, nominal = 1, min = 0.03, max = 1, init = 0.0681)
// Input[4]:u_f(start = 9e-06, nominal = 1, min = 0, max = 1)
// Input[5]:u_wg(start = 0.000485, nominal = 1, min = 0, max = 1)
// --------------------------------------------------------
// 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 0.0015511 for the approximation of the state p_em(time = 0.486667)
// LOG_IPOPT_ERROR | info | max error is 0.00153097 for the approximation of the state p_em(time = 0.486667)
// LOG_IPOPT_ERROR | info | max error is 0.00149595 for the approximation of the state p_em(time = 0.486667)
// LOG_IPOPT_ERROR | info | max error is 0.00112748 for the approximation of the state p_em(time = 0.486667)
// LOG_IPOPT_ERROR | info | max error is 0.000313137 for the approximation of the state p_em(time = 0.486667)
// LOG_IPOPT_ERROR | info | max error is 0.000122445 for the approximation of the state p_em(time = 0.486667)
// LOG_IPOPT_ERROR | info | max error is 8.56457e-05 for the approximation of the state p_em(time = 0.486667)
// LOG_IPOPT_ERROR | info | max error is 2.37178e-06 for the approximation of the state p_em(time = 0.485556)
// LOG_IPOPT_ERROR | info | max error is 4.55501e-07 for the approximation of the state p_em(time = 0.485556)
// LOG_IPOPT_ERROR | info | max error is 1.16221e-07 for the approximation of the state p_em(time = 0.485556)
// LOG_IPOPT_ERROR | info | max error is 2.52825e-08 for the approximation of the state p_em(time = 0.485556)
// LOG_IPOPT_ERROR | info | max error is 3.66997e-09 for the approximation of the state p_em(time = 0.485556)
// LOG_IPOPT_ERROR | info | max error is 1.48205e-10 for the approximation of the state p_em(time = 0.485556)
// LOG_IPOPT_ERROR | info | max error is 2.86256e-13 for the approximation of the state p_em(time = 0.485556)
// "
// end SimulationResult;
// ""
// record SimulationResult
// resultFile = "diesel_model_res.mat",
// 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'",
// messages = "
// Optimizer Variables
// ========================================================
// State[0]:p_em(start = 0.339267, nominal = 1.01111, min = 0.337038, max = 1.01111, init = 0.339267)
// State[1]:p_im(start = 0.50615, nominal = 1.01111, min = 0.404445, max = 1.01111, init = 0.50615)
// State[2]:w_ice(start = 0.249899, nominal = 1, min = 0.0181818, max = 1, init = 0.249899)
// State[3]:w_tc(start = 0.0681, nominal = 1, min = 0.03, max = 1, init = 0.0681)
// Input[4]:u_f(start = 8.5502e-07, nominal = 1, min = 0, max = 1)
// Input[5]:u_wg(start = 4.85532e-05, nominal = 1, min = 0, max = 1)
// --------------------------------------------------------
// number of nonlinear constraints: 0
// ========================================================
//
// max_iter = -1"
// end SimulationResult;
// ""
// {"Files Equal!"}
// ""
// endResult
1 change: 1 addition & 0 deletions openmodelica/cruntime/optimization/basic/Makefile
Expand Up @@ -16,6 +16,7 @@ CM.mos \
CM2.mos \
DM.mos \
DMwarm.mos \
DMwarmCsv.mos \
LoopTest.mos \
LRB.mos \
LRB2.mos \
Expand Down

0 comments on commit e254a60

Please sign in to comment.