optimization question

66 views
Skip to first unread message

Jose Alberto Sainz

unread,
Nov 25, 2015, 7:44:25 AM11/25/15
to cvxpy
Hi, wondering if anyone might have an idea how to handle this case when it comes to portfolio optimization and how to construct the matrices. Simple case is fine using prob = Problem(Maximize(ret - gamma*risk), constraints) where constraints=[sum_entries(w) == 1, w >= 0]  but what happens if you have n assets and you set upper and lower bounds? Example, if I have 3 assets and say lower bound is 40% and upper bound is 100%, the optimizer will fail because lower weights on all 3 assets will sum to greater than 1. Therefore, that means, 1 asset must fall out. Only way I can understand this case is optimize on the combinations of 3 assets with same lower bound of 40%. Thus, optimize(0,1) then (0,2) and finally (1,2) and find the combination with lowest stdev if that is your objective but if assets are large this process will be computationally heavy. Each combination can have lower bound of 40% and sum to 1. So, my question, how do you change constraints or objective function  Maximize(ret - gamma*risk) so this will work? I think you need to change lower bound <= x <= upper bound to an equality but can not figure this out. Any feedback greatly appreciated. thanks

Steven Diamond

unread,
Nov 25, 2015, 1:37:51 PM11/25/15
to cvxpy
You need to use boolean variables. Like this:

b = Bool(n)
constraints=[sum_entries(w) == 1, b >= w, w >= 0.4*b]
prob = Problem(Maximize(ret - gamma*risk), constraints)

that way each entry w[i] is between 1 and 0.4 (if b[i] is 1) or if b[i] is 0 we have w[i] is 0.

This problem is not convex but ECOS BB will attempt to solve it. If you have gurobi you'll probably get a really good answer.
Reply all
Reply to author
Forward
0 new messages