python-3.xpyomoipopt

Setting ipopt options through pyomo


I am having trouble setting the ipopt options through pyomo.

For some options one can simply use

executable = os.getcwd()+'/Ipopt/Ipopt/build/bin/ipopt.exe'
opt = SolverFactory("ipopt", executable=executable,solver_io='nl')
opt.options['nlp_scaling_method'] = 'user-scaling'

This works fine. If i try set the option for "fixed_variable_treatment", i.e.:

opt.options['fixed_variable_treatment'] = 'make_parameter'

i get the following error:

ERROR: "[base]\site-packages\pyomo\opt\base\solvers.py", 599, solve
        Solver (asl) returned non-zero return code (1)
ERROR: "[base]\site-packages\pyomo\opt\base\solvers.py", 604, solve
        Solver log:
        Unknown keyword "fixed_variable_treatment"

I am assuming that this is because you cannot set all of the options through python?

Any help or way to overcome this would be greatly appreciated. Thanks


Solution

  • The workaround is to use an ipopt.opt file as described at https://www.coin-or.org/Ipopt/documentation/node35.html. The option file is placed in the current working directory where IPOPT is called.

    Gabe Hackebeil responded on the Github issue:

    The default behavior is to send options to Ipopt through the command line, but not all Ipopt options are available through the command line. This is probably one of them. Historically one would place this kind of option in an options file named "ipopt.opt" in the working directory, and Ipopt would pick it up automatically.

    Very recently I added functionality to the Ipopt interface in Pyomo to write an options file for you. Options that begin with "OF_" will be placed in a temporary options file (with that prefix removed). I don't know if this has made it into a release yet.

    EDIT: Be aware that as of Pyomo version 6.4.1, if you specify options using the "OF_" prefix, then if you have an existing ipopt.opt file in your working directory, it will be ignored and the file created using the "OF_" options will be used instead. i.e. the options specified using "OF_" are not appended - they're used instead of.