简体   繁体   English

使用CVXOPT进行Python二次编程

[英]Python Quadratic Programming with CVXOPT

I am looking for a definitive guide on formulating a CVXOPT quadratic programming problem with quadratic constraints. 我正在寻找有关确定具有二次约束的CVXOPT二次编程问题的权威指南。 There are good documents provided here: 这里提供了很好的文档:

The problem statement I am dealing with is identical to the problem here : 我要处理的问题陈述与这里的问题相同:

在此处输入图片说明

What is the matrix G supposed to look like? 矩阵G应该是什么样子? I've formulated as a system of linear equations, but looking at examples this does not appear to be correct? 我已经公式化为一个线性方程组,但是看看示例,这似乎是不正确的?

The best resource I've found is https://courses.csail.mit.edu/6.867/wiki/images/a/a7/Qp-cvxopt.pdf , but the links at the end are dead for more reading. 我找到的最好的资源是https://courses.csail.mit.edu/6.867/wiki/images/a/a7/Qp-cvxopt.pdf ,但是末尾的链接已经失效,需要更多阅读。

I have an ipython notebook trying to use this programming method but it continually fails: https://gist.github.com/jaredvacanti/62010beda0ccfc20d2eac3c900858e50 我有一个尝试使用此编程方法的ipython笔记本,但它始终失败: https ://gist.github.com/jaredvacanti/62010beda0ccfc20d2eac3c900858e50

Edit: I have edited the data source file in the notebook to provide access to the real data used in this optimization problem. 编辑:我已经在笔记本中编辑了数据源文件,以提供对该优化问题中使用的实际数据的访问。

The notebook you have posted seems to have it all figured out. 您发布的笔记本似乎已经全部弄清楚了。 The problem I had is that the source file for data is not available. 我遇到的问题是数据的源文件不可用。

Now to your question: 现在您的问题:

What is the matrix G supposed to look like? 矩阵G应该是什么样子? I've formulated as a system of linear equations, but looking at examples this does not appear to be correct? 我已经公式化为一个线性方程组,但是看看示例,这似乎是不正确的?

Rewrite your "linear equations" into matrix form, ie 将您的“线性方程”重写为矩阵形式,即

2x + 2y = 4
x  - y  = 1

is equivalent to 相当于

matrix([[2,2],[1,-1]]) * matrix([[x],[y]])  = matrix([[4],[1]])

where matrix is from cvxopt . 其中matrix来自cvxopt

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM