cvxopt.solvers.qp()
cvxopt.solvers.qp()
- Purpose
2차 프로그램(quadratic program) 에 대한 인터페이스 제공
- Function
- Ex
1. reshape function to
(make matrix P , q)
2. Inequality Constraint
(make matrix G, h)
3. Equality constraint
(make matrix A, b)
4. python
import numpy from cvxopt
import matrix
P = matrix(numpy.diag([1,0]), tc=’d’)
q = matrix(numpy.array([3,4]), tc=’d’)
G = matrix(numpy.array([[-1,0],[0,-1],[-1,-3],[2,5],[3,4]]), tc=’d’)
h = matrix(numpy.array([0,0,-15,100,80]), tc=’d’)
from cvxopt import solvers
sol = solvers.qp(P,q,G,h)
* cvxopt는 별도의 행렬함수를 지원하므로 cvxopt.matrix 사용. (numpy matrix convert 가능)
* 부등호, 등호 제약조건 생략가능
* 참고
http://henryquant.blogspot.kr/
https://courses.csail.mit.edu/6.867/wiki/images/a/a7/Qp-cvxopt.pdf
http://cvxopt.org/userguide/coneprog.html?highlight=cvxopt%20solvers%20qp#cvxopt.solvers.qp
https://gist.github.com/mblondel/586753