Ant*_*ouc 5 python-3.x ipopt pyomo
我在通过 pyomo 设置 iopt 选项时遇到问题。
对于某些选项,可以简单地使用
executable = os.getcwd()+'/Ipopt/Ipopt/build/bin/ipopt.exe'
opt = SolverFactory("ipopt", executable=executable,solver_io='nl')
opt.options['nlp_scaling_method'] = 'user-scaling'
Run Code Online (Sandbox Code Playgroud)
这很好用。如果我尝试设置“fixed_variable_treatment”选项,即:
opt.options['fixed_variable_treatment'] = 'make_parameter'
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
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"
Run Code Online (Sandbox Code Playgroud)
我假设这是因为你无法通过 python 设置所有选项?
任何帮助或克服这个问题的方法将不胜感激。谢谢
解决方法是使用 ipopt.opt 文件,如https://www.coin-or.org/Ipopt/documentation/node35.html中所述。选项文件放置在调用 IPOPT 的当前工作目录中。
默认行为是通过命令行向 Ipopt 发送选项,但并非所有 Ipopt 选项都可以通过命令行使用。这可能就是其中之一。过去,人们会将这种选项放在工作目录中名为“ipopt.opt”的选项文件中,Ipopt 会自动选择它。
最近,我向 Pyomo 中的 Ipopt 界面添加了功能,以便为您编写选项文件。以“OF_”开头的选项将被放置在临时选项文件中(删除该前缀)。我不知道这是否已发布。
编辑:请注意,从 Pyomo 版本 6.4.1 开始,如果您使用“OF_”前缀指定选项,那么如果您ipopt.opt的工作目录中有现有文件,它将被忽略,并使用“OF_”选项创建文件将被使用。即使用“OF_”指定的选项不会被附加 - 它们被使用。
| 归档时间: |
|
| 查看次数: |
3186 次 |
| 最近记录: |