How to change CPLEX parameters in oplrun?

浪尽此生 提交于 2019-12-12 04:57:31

问题


Is there a way to let oplrun take a specific CPLEX parameter, such as CPX_PARAM_LPMETHOD (Linear Programming method). In the reference here, it is called by various names for different languages:

C Name: CPX_PARAM_LPMETHOD

C++ Name: RootAlg

Java Name: RootAlg

.NET Name: RootAlg

InteractiveOptimizer: lpmethod 

But there is no reference about the OPL or oplrun.

Is it possible to change this parameter in an oplrun session? Or do I have to use these other languages/interfaces?


回答1:


in the .mod you may write

execute
{
  cplex.lpmethod=4;
}

and then you will see in the log

CPXPARAM_LPMethod                                4

regards




回答2:


if you just have a specific parameter you would like to change, in the .mod file you can have something like:

int myParameter = …;

In the same .mod file you can also use

execute
{
  cplex.lpmethod=myParameter;
}

And then you have some default value in your .dat file.

To change that parameter from run to run when using oplrun, you can call it with the following command line arguments:

oplrun myModel.mod myData.dat -D myParameter=4



回答3:


It's not possible to do this (directly) using oplrun command line options. You can, however, use oplrun to execute a specific run configuration that has an associated settings file (a .ops file). For example:

oplrun [options] -p project-dir [run-configuration ...]

When you use the IDE to set individual parameters, the OPL names for the parameters are stored in the .ops file. For example, the CPLEX parameter CPX_PARAM_TILIMIT is named tiLimit in OPL (see here for more).

Alternately, you could export your OPL model using the -e oplrun option. Then, you could run that using the CPLEX interactive and use a parameter file or set them in the command line itself (see here for the syntax).

Lastly, you can surely use one of the programming language APIs available in CPLEX to accomplish the same thing. This would provide the most control, but may take more time (depending on how comfortable you are with programming).



来源:https://stackoverflow.com/questions/44942964/how-to-change-cplex-parameters-in-oplrun

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!