xiwe...@gmail.com
unread,Oct 9, 2008, 2:08:40 PM10/9/08Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to CVXOPT
Dear Joachim, Lieven, and others,
I try to use solvers.cp to minimize a function. Please see below for
the detail function.
P is a matrix, mu is a number.
G, h are built to have all x's >= 0, and sum(x) <=1. A and b are None.
Note that, inside the matrix, elements of u will change depending on
x's (This might be the reason it can not get the results? I tried to
set u = mu - P*x, and it works!!).
For small P matrix, like 4X5, it will give the answer.
But for big ones, such as 200X200, it will terminated after 99:
95: -4.0718e+006 5.6339e+006 4e+001 5e-001 5e-001
96: -4.0591e+006 5.5153e+006 4e+001 5e-001 5e-001
97: -4.0589e+006 5.5138e+006 4e+001 5e-001 5e-001
98: -4.0522e+006 5.4612e+006 4e+001 5e-001 5e-001
99: -4.0509e+006 5.4517e+006 4e+001 5e-001 5e-001
None
Is my function correct?
Is there any way to let it run more than 99 cycles to try to get the
answers? Can we set initial x's?
def func_min(P, mu, G=None, h=None, A=None, b=None):
m, n = P.size
def F(x=None, z=None):
if x is None: return 0, matrix(1.0, (n,1))
u = matrix([max((mu - xx),0.0) for xx in P*x], (m,1))
f = u.T * u
Df = (-2*P.T*u).T
if z is None: return f, Df
H = 2*z[0]*P.T*P
return f, Df, H
return solvers.cp(F, G=G, h=h,A=A,b=b)['x']
The func_min() is trying to do the same as below:
__________ matlab ____
function [f df] = lower(x,P,mu)
g = max(mu-P*x,0);
f = g'*g;
df = -2*P'*g;
fmincon(@lower,x0,A,b,Aeq,beq,lb,ub,[],option,P,riskThresh)