Solving Cardinality Constrained Portfolio Optimization Problem in Convex.jl

88 views
Skip to first unread message

Ayush Pandey

unread,
Mar 10, 2016, 4:10:22 AM3/10/16
to juli...@googlegroups.com, Julia Users
Hello,
The normal Portfolio Optimization problem is when we are given a portfolio of assets and the only restriction is that the sum of weights assigned to assets is equal to 1(and of course 0<=wi<=1).

But when we put the limit on number of assets to be invested, this problem becomes a Cardinality Constrained Portfolio Optimization Problem(for e.g. I have portfolio of 10 assets but at a time I can only invest in 5 assets).
In such case we introduce a binary variable yi = {0,1}
yi = 0 when no investment is made in asset i and yi = 1 when the investment is made in asset i.

Now, this problem becomes a Mixed Integer Quadratic Programming Problem.
I was trying to solve it using Convex.jl but couldn't succeed. I would be great if someone could help :)

The problem is in the following lines of the code

#Defining variables
w = Variable(10);
y = Variable(10, :Bin);

#Defining constraints
c1 = sum(w) == 1;
c2 = sum(y) = 5;

c3 = w_lower <= w*y'; 
Constraint:
<= constraint
lhs: 0
rhs: AbstractExpr with
head: *
size: (5, 5)
sign: Convex.NoSign()
vexity: Convex.NotDcp()

vexity: Convex.NotDcp()

c4 = w*y' <= w_upper;



Yours Sincerely,
Ayush Pandey        
LinkedIn Profile   
GitHub

Miles Lubin

unread,
Mar 10, 2016, 8:48:22 AM3/10/16
to julia-opt
If you double-post, please give a link (https://groups.google.com/d/msg/julia-users/B88L_byCcy0/zM-KyWsqBgAJ) to avoid duplicate effort on the part of those answering.

Ayush Pandey

unread,
Mar 10, 2016, 2:54:33 PM3/10/16
to juli...@googlegroups.com
Thank you Miles ! I would be taking this into consideration from next time onwards . 

Yours Sincerely,
Ayush Pandey        
LinkedIn Profile   
GitHub


--
You received this message because you are subscribed to the Google Groups "julia-opt" group.
To unsubscribe from this group and stop receiving emails from it, send an email to julia-opt+...@googlegroups.com.
Visit this group at https://groups.google.com/group/julia-opt.
For more options, visit https://groups.google.com/d/optout.

Madeleine Udell

unread,
Mar 14, 2016, 12:16:43 AM3/14/16
to julia-opt, ayush....@iitkgp.ac.in
You've expressed the last constraint by multiplying two variables, which is not a DCP compliant operation. In fact, I'm not entirely sure why you want an outer product constraint; I'd expect you to want to constrain the sum of the weights w

w_lower <= sum(w)

and also enforce that no weight can be positive unless the corresponding element of y is 1, which you can enforce using a big-M relaxation:

w[i] <= M*y[i]

where M is some suitably large constant.

And then you can do the same for the upper bounds.
Reply all
Reply to author
Forward
0 new messages