[英]How to install ipopt for python on Windows using Anaconda
[英]installing Ipopt for anaconda python
有人在 Anaconda python 上安装过 Ipopt 吗? 我下载了 3.6.1 版本。 此外,我按照自述文件中的说明下载了请求的 intel Fortran 库。
通过使用configure
make
和make install
以及链接到它的所有依赖项,安装应该是直接的。 我希望我能自己解决这个问题。
如果我想在 anaconda 中使用 Ipopt,我还需要考虑什么? 特别是我想构建包含 Ipopt 的 Pygmo。
或者安装 pyopt 或 Casadi 就足够了吗?
我已经通过 anaconda 云在 anaconda 环境中安装了 ipopt; anaconda 云上的 ipopt 可在https://anaconda.org/conda-forge/ipopt上找到。
要在 anaconda 环境中安装 ipopt,您只需要打开 anaconda 终端,激活您希望安装 ipopt 的环境,然后键入:“conda install -c conda-forge ipopt”,然后像安装其他设备一样正常进行包。
我对 Casadi 不是特别熟悉,但优化界面的选择很大程度上取决于您希望如何处理您的问题。 例如,对于一个简单的优化问题,您可以使用 scipy.minimize。
原则上,两者(参考 pyOpt 和 PyGMO)都为您提供了不同的功能集。 例如,PyGMO 具有其他功能,例如 Dr. PyGMO 和使用广义岛屿模型的可能性。 在您的特定情况下,您必须自行决定最适合您的方式。
如果您正在执行的任务明确需要使用 Ipopt,那么 PyGMO、pyOpt 或其他接口的配置应该是您喜欢的任何内容的次要项目。
如果您不想在任何运行 Python 的平台(Windows、MacOS、Linux、ARM Linux - Raspberry Pi)上编译求解器而感到头疼,IPOPT 与 Gekko 一起提供。 这是一个简单的例子:
pip install gekko
用 IPOPT 解决 HS71
from gekko import GEKKO
import numpy as np
m = GEKKO()
x = m.Array(m.Var,4,value=1,lb=1,ub=5)
x1,x2,x3,x4 = x
# change initial values
x2.value = 5; x3.value = 5
m.Equation(x1*x2*x3*x4>=25)
m.Equation(x1**2+x2**2+x3**2+x4**2==40)
m.Minimize(x1*x4*(x1+x2+x3)+x3)
m.solve()
print('x: ', x)
print('Objective: ',m.options.OBJFCNVAL)
IPOPT 的结果
******************************************************************************
This program contains Ipopt, a library for large-scale nonlinear optimization.
Ipopt is released as open source code under the Eclipse Public License (EPL).
For more information visit http://projects.coin-or.org/Ipopt
******************************************************************************
This is Ipopt version 3.12.10, running with linear solver ma57.
Number of nonzeros in equality constraint Jacobian...: 9
Number of nonzeros in inequality constraint Jacobian.: 0
Number of nonzeros in Lagrangian Hessian.............: 10
Total number of variables............................: 5
variables with only lower bounds: 1
variables with lower and upper bounds: 4
variables with only upper bounds: 0
Total number of equality constraints.................: 2
Total number of inequality constraints...............: 0
inequality constraints with only lower bounds: 0
inequality constraints with lower and upper bounds: 0
inequality constraints with only upper bounds: 0
iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls
0 1.6109693e+01 1.12e+01 2.50e+00 0.0 0.00e+00 - 0.00e+00 0.00e+00 0
1 1.6905655e+01 7.44e-01 5.14e-01 -0.9 1.36e-01 - 1.00e+00 1.00e+00f 1
2 1.7136202e+01 1.71e-01 4.57e-01 -1.0 9.40e-02 - 8.95e-01 1.00e+00h 1
3 1.6956645e+01 1.57e-01 7.85e-02 -2.0 1.78e-01 - 9.95e-01 1.00e+00h 1
4 1.7009269e+01 1.63e-02 1.20e-02 -2.8 3.94e-02 - 9.94e-01 1.00e+00h 1
5 1.7013888e+01 4.04e-04 1.76e-04 -4.6 6.22e-03 - 1.00e+00 1.00e+00h 1
6 1.7014017e+01 3.92e-07 6.03e-07 -10.4 1.46e-04 - 9.99e-01 1.00e+00h 1
Number of Iterations....: 6
(scaled) (unscaled)
Objective...............: 1.7014017127073458e+01 1.7014017127073458e+01
Dual infeasibility......: 6.0264909533529361e-07 6.0264909533529361e-07
Constraint violation....: 3.9234873865091858e-07 3.9234873865091858e-07
Complementarity.........: 7.2865190881096349e-08 7.2865190881096349e-08
Overall NLP error.......: 6.0264909533529361e-07 6.0264909533529361e-07
Number of objective function evaluations = 7
Number of objective gradient evaluations = 7
Number of equality constraint evaluations = 7
Number of inequality constraint evaluations = 0
Number of equality constraint Jacobian evaluations = 7
Number of inequality constraint Jacobian evaluations = 0
Number of Lagrangian Hessian evaluations = 6
Total CPU secs in IPOPT (w/o function evaluations) = 0.003
Total CPU secs in NLP function evaluations = 0.000
EXIT: Optimal Solution Found.
The solution was found.
The final value of the objective function is 17.0140171270735
---------------------------------------------------
Solver : IPOPT (v3.12)
Solution time : 9.299999990616925E-003 sec
Objective : 17.0140171270735
Successful solution
---------------------------------------------------
x: [[1.000000057] [4.74299963] [3.8211500283] [1.3794081795]]
Objective: 17.014017127
默认是使用具有更强大的线性求解器的云计算服务。 本地选项可用于 Windows 上的 IPOPT,但使用 MUMPS 线性求解器作为免费分发选项之一。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.