Constraints not meeting the parameters?

Hello:
This is what my code looks like for the the linear equality constraints. However, run I run the code it does not meet the constraints.
in swtOther_Aeq1, the first constraint is to make stocks 1,3,7 comprise 22% of the portfolio.
the second constraint is to make the portfolio return equal to a certain return in the grid (ERGRid).
the third constraint is to have the total weights sum up to one for the portfolio.
However, none of these requirements are being met.
I am confused as to why.
Help would be appreciated. thanks.

3 Comments

Matt J
Matt J on 30 May 2014
Edited: Matt J on 30 May 2014
What does the exitflag output argument say?
And how much greater is the constraint violation than options.TolCon?
Exitflag says 0.04044
output says -2
Also this is what TolCon says:
TolCon =
iterations: 29
funcCount: 337
constrviolation: 9.3468
stepsize: 7.6372e-11
algorithm: 'interior-point'
firstorderopt: 0.059526
cgiterations: 58
message: 'No feasible solution found.
fmi...'

Sign in to comment.

Answers (1)

Matt J
Matt J on 30 May 2014
Edited: Matt J on 30 May 2014
Exitflag=-2 means that no feasible point was found, as output.message also tells you. It means fmincon thinks there is no point satisfying your constraints.

10 Comments

It says output = -2 and exitflag is 0.04044. I read
that a positive exitflag means a successful outcome.
No, exitflag has to be an integer and output has to be a structure. You just called fmincon with the output arguments named in the wrong order. It doesn't matter. This output,
iterations: 29
funcCount: 337
constrviolation: 9.3468
stepsize: 7.6372e-11
algorithm: 'interior-point'
firstorderopt: 0.059526
cgiterations: 58
message: 'No feasible solution found.
gives a message clearly stating 'No feasible solution found'. It tells us everything we need to know.
Sameer
Sameer on 31 May 2014
Edited: Sameer on 31 May 2014
Interesting. My teacher gave this to us as a homework assignment. He says the program should run without constraint problems.
Do you know what he may have done? I heard there are options you may use to modify the tolerance of the constraints?
Matt J
Matt J on 31 May 2014
Edited: Matt J on 31 May 2014
I heard there are options you may use to modify the tolerance of the constraints?
This is the TolCon option. However, I would first consider whether you have entered the data for the constraints incorrectly.
You can also try LCON2VERT to find the vertices of the region defined by your A,b,Aeq,beq,ub,lb constraint data. If the set of vertices V is empty, you know that your constraints are infeasible. Note, however, that you would have to convert your ub,lb data to ineqaulity constraint form.
%options(1) = 1; % 1 = turn on screen, 0 = off, -1 = surpress warning messages
%options (2) = le-5; % tollerance for weights, default = le-4
%options(3) = le-5; % tollerance for objective function, default = le-4
these are the three options my teacher suggested we use in the program. I tried using option 2 with
options = optimset('TolCon',1e-5);
but it did not give me a feasible solution.
sorry I'm new to MATLAB, but I want to understand how it works.
Matt J
Matt J on 1 Jun 2014
Edited: Matt J on 1 Jun 2014
As I said, I would not look to TolCon or any of the other option settings as prime suspects for why things are not working. I would look to your constraint data.
If you look at the third constraint, when I write (i is the loop variable)
swtOther_Aeq1 = ERGrid(2:swtN+1,i)';
swtOther_beq1 = 1.00;
and do not use any other constraints in fmincon, the program runs and says it finds a solution, but when I sum up W (the weights in a portfolio) it does not sum up to 1.
Instead, it sums to -0.1001.
It should some to 1.00, given vector multiplication.
However, when I entered
swtOther_beq = (-1.00*10)+0.01,
the portfolio weights in a bizzare fashion sums to 1.00.
I am confused on the rationale
Sameer
Sameer on 1 Jun 2014
Edited: Sameer on 1 Jun 2014
nevermind, I figured it out. teacher used different constraints!
However the bizarreness is still confusing.

Sign in to comment.

Categories

Asked:

on 30 May 2014

Edited:

on 1 Jun 2014

Community Treasure Hunt

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

Start Hunting!