[SciPy-user] Optimization fmin_tnc with equality constraint

dmitrey dmitrey15@ukr....
Wed Apr 22 05:40:25 CDT 2009


Adrien Aulagnier пишет:
>
>
> 2009/4/20 Adrien Aulagnier <aaulagnier@gmail.com 
> <mailto:aaulagnier@gmail.com>>
>
>
>
>     2009/4/20 Dave Hirschfeld <dave.hirschfeld@gmail.com
>     <mailto:dave.hirschfeld@gmail.com>>
>
>         Adrien Aulagnier <aaulagnier <at> gmail.com
>         <http://gmail.com>> writes:
>
>         >
>         > HelloSorry to disturb you. My question might be simple:The
>         function to
>         minimize is simply f (w) = w' * Sigma * wwith w a vector and
>         Sigma a square
>         matrixThe constraints are : 0 <= w <= 1
>         > sum(w) = 1This last constraint is my problem.Could you give
>         me some clue
>         ?Thanks for your help
>         >
>         > _______________________________________________
>         > SciPy-user mailing list
>         > SciPy-user <at> scipy.org <http://scipy.org>
>         > http://mail.scipy.org/mailman/listinfo/scipy-user
>         >
>
>         This discussion may help:
>
>         http://thread.gmane.org/gmane.comp.python.scientific.user/16180/focus=16187
>
>         _______________________________________________
>         SciPy-user mailing list
>         SciPy-user@scipy.org <mailto:SciPy-user@scipy.org>
>         http://mail.scipy.org/mailman/listinfo/scipy-user
>
>
>
>     Thank you for the help but my description was not complet:
>
>
>     The function to minimize is simply f (w) = w' * Sigma * w
>
>     with w a vector and Sigma a square matrix
>
>     The constraints are :
>
>     0 <= w <= 1
>     sum(w) = 1
>     R' * w = a constant
>
>     and R a vector of the same size as w
>
>     Sorry for the missing information.
>
>     I think that the Aitchison transformation won't work in this case...
>
>     Do you have an idea to solve this system ?
>
>     Thanks for your help
>
>
> The problem is simply a quadratic programming problem
>
> scipy.optimize is not provided with a direct tool for this problem
>
> This type of problem is used a lot in Markowitz portfolio theory or 
> efficient frontier construction
>
> One should use an addon module call cvxopt http://abel.ee.ucla.edu/cvxopt/
> This is a software for convex optimization which is really useful with 
> scipy
>
> A simple usage is provided with openopt
>
> I used openopt
>
> f = scipy.zeros(numberOfAssets)
>
> Aeq = scipy.ones((2, numberOfAssets))
> Aeq[0,:] = expReturns.T
> beq = scipy.ones((2, 1)) # adapt this
>
> lb = scipy.zeros((numberOfAssets, 1))
> lh = scipy.ones((numberOfAssets, 1))
>
> p = scikits.openopt.QP(cov, f, Aeq = Aeq, beq = beq, lb = lb, lh = lh, 
> iprint = -1)
> r = p.solve('cvxopt_qp')
>
>
> That's all folks
>
> Hope this might help someone
>
> Thanks for this mailing list
Hi there,
I don't know what lh stands for, it is unused, maybe you meant ub here?
p = scikits.openopt.QP(cov, f, Aeq = Aeq, beq = beq, lb = lb, ub = lh, 
iprint = -1)
Also, using scikits.openopt means you use obsolete openopt ver <= 0.19, 
v 0.21 and 0.23 are outside of scikits.
Regards, D.



More information about the SciPy-user mailing list