Python约束的非线性优化 [英] Python constrained non-linear optimization

查看:678
本文介绍了Python约束的非线性优化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在python中约束非线性优化的推荐软件包是什么?

What's the recommended package for constrained non-linear optimization in python ?

我要解决的具体问题是:

The specific problem I'm trying to solve is this:

我有一个未知的X(Nx1),我有M(Nx1)u向量和M(NxN)s矩阵.

I have an unknown X (Nx1), I have M (Nx1) u vectors and M (NxN) s matrices.

max [5th percentile of (ui_T*X), i in 1 to M]
st 
0<=X<=1 and
[95th percentile of (X_T*si*X), i in 1 to M]<= constant

当我开始研究问题时,我对us的估算仅为1分,因此我可以通过cvxpy解决上述问题.

When I started out the problem I only had one point estimate for u and s and I was able to solve the problem above with cvxpy.

我意识到,我没有一个对us的估计,而是拥有值的整个分布,因此我想更改目标函数,以便可以使用整个分布.上面的问题描述是我试图以有意义的方式包括该信息.

I realized that instead of one estimate for u and s, I had the entire distribution of values so I wanted to change my objective function so that I could use the entire distribution. The problem description above is my attempt to include that information in a meaningful way.

cvxpy不能用于解决此问题,我已经尝试过scipy.optimize.anneal,但是我似乎无法为未知值设置界限.我也看过pulp,但是它不允许非线性约束.

cvxpy cannot be used to solve this, I've tried scipy.optimize.anneal, but I can't seem to set bounds on the unknown values. I've looked at pulp too but it doesnt allow nonlinear constraints.

推荐答案

scipy有一个壮观的软件包,用于约束非线性优化.

scipy has a spectacular package for constrained non-linear optimization.

您可以通过阅读optimize doc 开始,但这是SLSQP的示例:

You can get started by reading the optimize doc, but here's an example with SLSQP:

minimize(func, [-1.0,1.0], args=(-1.0,), jac=func_deriv, constraints=cons, method='SLSQP', options={'disp': True})

这篇关于Python约束的非线性优化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆