通过 pyomo 设置 ipopt 选项
Setting ipopt options through pyomo
我在通过 pyomo 设置 ipopt 选项时遇到问题。
对于某些选项,可以简单地使用
executable = os.getcwd()+'/Ipopt/Ipopt/build/bin/ipopt.exe'
opt = SolverFactory("ipopt", executable=executable,solver_io='nl')
opt.options['nlp_scaling_method'] = 'user-scaling'
这很好用。如果我尝试为 "fixed_variable_treatment" 设置选项,即:
opt.options['fixed_variable_treatment'] = 'make_parameter'
我收到以下错误:
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"
我假设这是因为您无法通过 python?
设置所有选项
任何帮助或解决这个问题的方法都将不胜感激。谢谢
解决方法是使用 ipopt.opt 文件,如 https://www.coin-or.org/Ipopt/documentation/node35.html 中所述。选项文件放在调用IPOPT的当前工作目录下。
Gabe Hackebeil 在 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.
我在通过 pyomo 设置 ipopt 选项时遇到问题。
对于某些选项,可以简单地使用
executable = os.getcwd()+'/Ipopt/Ipopt/build/bin/ipopt.exe'
opt = SolverFactory("ipopt", executable=executable,solver_io='nl')
opt.options['nlp_scaling_method'] = 'user-scaling'
这很好用。如果我尝试为 "fixed_variable_treatment" 设置选项,即:
opt.options['fixed_variable_treatment'] = 'make_parameter'
我收到以下错误:
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"
我假设这是因为您无法通过 python?
设置所有选项任何帮助或解决这个问题的方法都将不胜感激。谢谢
解决方法是使用 ipopt.opt 文件,如 https://www.coin-or.org/Ipopt/documentation/node35.html 中所述。选项文件放在调用IPOPT的当前工作目录下。
Gabe Hackebeil 在 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.