(weight) constraint within constraint using fmincon

12 Ansichten (letzte 30 Tage)
DankoJones
DankoJones am 10 Mai 2012
I'm at the moment doing some optimal asset allocation while using fmincon.
For example if I have 8 assets, I use
max_alloc=[1;1;0.5;1;1;1;1;1];
as upper bound constraint which shows that the maximum allocation in every asset can be 100% besides the third which is capped at 50%. However, I would like to add an extra constraint which makes the cap on the fourth asset dependable on the max cap of the third asset.
Like,
if weights(3,1)>0.3
weights(4,1)<0.2
end
How do I add this in my fmincon function? Since my upperbound is just a 8x1 vector.
  2 Kommentare
Sargondjani
Sargondjani am 10 Mai 2012
it looks non-differentiable to me. fmincon assumes differentiability of the constraint.
you could either:
1. see if the constraint would bind, and if so implement the constraint
2. replace the constraint with a differentiable constraint, for instance on the sum of the weigths of 3 and 4. That seems more sensible to me: i mean, if w3=0.3 then w4 can be 0.5 and when w3 goes to 0.30001 then w4 is forced to 0.2. That doesnt seem proper risk management to me...
DankoJones
DankoJones am 16 Mai 2012
They are indeed not simple bound constraints. I know been busy working in the nonlcon constraint to fix this issue, but still havent found the solution.
What I'm trying to do is to have a conditional constraint, where the weight of the third asset can only be 10% of the second asset. I do this by the following function, but I receive the error:
??? Error using ==> nonlcon Too many output arguments.
function [c]=nonlcon(x0)
%(x0(3,1)<(0.1*x0(2,1)))
%c < 0;
c(1) = (x0(3,1)-(0.1*(x0(2,1))) < 0)

Melden Sie sich an, um zu kommentieren.

Antworten (2)

John D'Errico
John D'Errico am 10 Mai 2012
Then these are not simple bound constraints, are they?
That would make them inequalities. Can you write down what the form of what that relationship is? Is it linear? Is it nonlinear?
If it is not even differentiable, then fmincon cannot be used.
John

DankoJones
DankoJones am 16 Mai 2012
They are indeed not simple bound constraints. I know been busy working in the nonlcon constraint to fix this issue, but still havent found the solution.
What I'm trying to do is to have a conditional constraint, where the weight of the third asset can only be 10% of the second asset. I do this by the following function, but I receive the error:
??? Error using ==> nonlcon Too many output arguments.
function [c]=nonlcon(x0)
%(x0(3,1)<(0.1*x0(2,1)))
%c < 0;
c(1) = (x0(3,1)-(0.1*(x0(2,1))) < 0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by