Skip to content

Commit

Permalink
- change default value of –ils to 1
Browse files Browse the repository at this point in the history
- remove option –iom=nelder_mead_ex2 (use –iom=nelder_mead_ex [–ils=1] instead)


git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@16343 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
lochel committed Jun 13, 2013
1 parent e11c9c7 commit 7be8776
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 131 deletions.
220 changes: 110 additions & 110 deletions Compiler/OpenModelicaBootstrappingHeader.h

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion SimulationRuntime/c/simulation/simulation_runtime.cpp
Expand Up @@ -530,7 +530,7 @@ int startNonInteractiveSimulation(int argc, char**argv, DATA* data)
string init_time_string = "";
double init_time = 0.0;
string init_lambda_steps_string = "";
int init_lambda_steps = 5;
int init_lambda_steps = 1;
string outputVariablesAtEnd = "";
int cpuTime = omc_flag[FLAG_CPU];

Expand Down
Expand Up @@ -83,7 +83,6 @@ enum INIT_OPTI_METHOD
IOM_SIMPLEX,
IOM_NEWUOA,
IOM_NELDER_MEAD_EX,
IOM_NELDER_MEAD_EX2,
IOM_KINSOL,
IOM_KINSOL_SCALED,
IOM_IPOPT,
Expand All @@ -95,7 +94,6 @@ static const char *optiMethodStr[IOM_MAX] = {
"simplex",
"newuoa",
"nelder_mead_ex",
"nelder_mead_ex2",
"kinsol",
"kinsol_scaled",
"ipopt"
Expand All @@ -104,8 +102,7 @@ static const char *optiMethodDescStr[IOM_MAX] = {
"unknown",
"Nelder-Mead method",
"Brent's method",
"Nelder-Mead method with global homotopy - default",
"Nelder-Mead method without global homotopy",
"Nelder-Mead method with global homotopy (see -ils for global homotopy) - default",
"sundials/kinsol",
"sundials/kinsol with scaling",
"Interior Point OPTimizer"
Expand Down Expand Up @@ -358,7 +355,7 @@ static int initialize2(INIT_DATA *initData, int optiMethod, int useScaling, int
DATA *data = initData->simData;

double STOPCR = 1.e-12;
double lambda = (optiMethod == IOM_NELDER_MEAD_EX2) ? 1.0 : 0.0;
double lambda = 0.0;
double funcValue;

long i, j;
Expand Down Expand Up @@ -387,8 +384,6 @@ static int initialize2(INIT_DATA *initData, int optiMethod, int useScaling, int
retVal = newuoa_initialization(initData);
else if(optiMethod == IOM_NELDER_MEAD_EX)
retVal = nelderMeadEx_initialization(initData, &lambda, lambda_steps);
else if(optiMethod == IOM_NELDER_MEAD_EX2)
retVal = nelderMeadEx_initialization(initData, &lambda, 1);
else if(optiMethod == IOM_KINSOL)
retVal = kinsol_initialization(initData);
else if(optiMethod == IOM_KINSOL_SCALED)
Expand Down Expand Up @@ -565,8 +560,7 @@ static int initialize(DATA *data, int optiMethod, int lambda_steps)

/* with scaling */
if(optiMethod == IOM_KINSOL_SCALED ||
optiMethod == IOM_NELDER_MEAD_EX ||
optiMethod == IOM_NELDER_MEAD_EX2)
optiMethod == IOM_NELDER_MEAD_EX)
{
INFO(LOG_INIT, "start with scaling");

Expand Down
Expand Up @@ -50,7 +50,7 @@
* special changes for initialization.
*
* \param [ref] [initData] number of unfixed states and unfixed parameters
* \param [in] [lambda_step]
* \param [in] [lambda_steps] number of steps for homotopy process
* \param [in] [acc]
* \param [in] [maxIt]
* \param [in] [dump]
Expand All @@ -61,7 +61,7 @@
* \author lochel
*/
static void NelderMeadOptimization(INIT_DATA* initData,
double lambda_step, double acc, long maxIt, long dump, double* pLambda, long* pIteration,
long lambda_steps, double acc, long maxIt, long dump, double* pLambda, long* pIteration,
double (*leastSquare)(INIT_DATA*, double))
{
long N = initData->nVars;
Expand Down Expand Up @@ -220,7 +220,7 @@ static void NelderMeadOptimization(INIT_DATA* initData,
{
if(lambda < 1.0)
{
lambda += lambda_step;
lambda += ((double)1.0)/(lambda_steps-1);
if(lambda > 1.0)
lambda = 1.0;

Expand Down Expand Up @@ -372,21 +372,26 @@ static void NelderMeadOptimization(INIT_DATA* initData,
*
* \author lochel
*/
int nelderMeadEx_initialization(INIT_DATA *initData, double *lambda, int lambda_steps)
int nelderMeadEx_initialization(INIT_DATA *initData, double *lambda, long lambda_steps)
{
double lambda_stepsize = 1.0 / (double)lambda_steps;
double STOPCR = 1.e-12;
long NLOOP = 1000 * initData->nVars * lambda_steps;
long iteration = 0;
int retVal;

INFO(LOG_INIT, "NelderMeadOptimization");
INDENT(LOG_INIT);
NelderMeadOptimization(initData, lambda_stepsize, STOPCR, NLOOP, ACTIVE_STREAM(LOG_INIT) ? NLOOP/10 : 0, lambda, &iteration, leastSquareWithLambda);
NelderMeadOptimization(initData, lambda_steps, STOPCR, NLOOP, ACTIVE_STREAM(LOG_INIT) ? NLOOP/10 : 0, lambda, &iteration, leastSquareWithLambda);
INFO1(LOG_INIT, "iterations: %ld", iteration);
RELEASE(LOG_INIT);

if(*lambda < 1.0)
return -1;

return reportResidualValue(initData);
retVal = reportResidualValue(initData);

if(0 != retVal)
WARNING(LOG_INIT, "try -ils to activate start value homotopy");

return retVal;
}
Expand Up @@ -44,7 +44,7 @@ extern "C"
{
#endif

extern int nelderMeadEx_initialization(INIT_DATA *initData, double *lambdaStart, int lambda_steps);
extern int nelderMeadEx_initialization(INIT_DATA *initData, double *lambdaStart, long lambda_steps);

#ifdef __cplusplus
}
Expand Down
6 changes: 3 additions & 3 deletions SimulationRuntime/c/util/simulation_options.c
Expand Up @@ -70,7 +70,7 @@ const char *FLAG_DESC[FLAG_MAX+1] = {
/* FLAG_IIF */ "value specifies an external file for the initialization of the model",
/* FLAG_IIM */ "value specifies the initialization method",
/* FLAG_IIT */ "[double] value specifies a time for the initialization of the model",
/* FLAG_ILS */ "[int] value specifies the number of steps for the global homotopy method (required: -iim=numeric -iom=nelder_mead_ex)",
/* FLAG_ILS */ "[int] default: 1",
/* FLAG_INTERACTIVE */ "specify interactive simulation",
/* FLAG_IOM */ "value specifies the initialization optimization method",
/* FLAG_L */ "value specifies a time where the linearization of the model should be performed",
Expand Down Expand Up @@ -100,9 +100,9 @@ const char *FLAG_DETAILED_DESC[FLAG_MAX+1] = {
/* FLAG_IIF */ "value specifies an external file for the initialization of the model",
/* FLAG_IIM */ "value specifies the initialization method\n none\n numeric\n symbolic",
/* FLAG_IIT */ "value specifies a time for the initialization of the model",
/* FLAG_ILS */ "value specifies the number of steps for the global homotopy method (required: -iim=numeric -iom=nelder_mead_ex)",
/* FLAG_ILS */ "value specifies the number of steps for homotopy method (required: -iim=symbolic) or\n'start value homotopy' method (required: -iim=numeric -iom=nelder_mead_ex)",
/* FLAG_INTERACTIVE */ "specify interactive simulation",
/* FLAG_IOM */ "value specifies the initialization optimization method\n nelder_mead_ex\n nelder_mead_ex2\n simplex\n newuoa",
/* FLAG_IOM */ "value specifies the initialization optimization method\n nelder_mead_ex\n simplex\n newuoa",
/* FLAG_L */ "value specifies a time where the linearization of the model should be performed",
/* FLAG_LS */ "value specifies the linear solver method\n lapack",
/* FLAG_LV */ "value specifies the logging level",
Expand Down

0 comments on commit 7be8776

Please sign in to comment.