[SciPy-user] Optimization fmin_tnc with equality constraint

Adrien Aulagnier aaulagnier@gmail....
Wed Apr 22 05:08:31 CDT 2009


2009/4/20 Adrien Aulagnier <aaulagnier@gmail.com>

>
>
> 2009/4/20 Dave Hirschfeld <dave.hirschfeld@gmail.com>
>
> Adrien Aulagnier <aaulagnier <at> 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://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
>> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20090422/fecd274e/attachment-0001.html 


More information about the SciPy-user mailing list