Fsolve : I want to give a condition which is something should be bigger than something, how can I do it?
1 次查看(过去 30 天)
显示 更早的评论
I am solving one objective function.
And one of the conditions is that something is bigger than something.
I can I write this condition in fsolve function?
pl=@(E) [
g/E(1)+G0(E)+rho*G1(E)*b/(1+a*b)-b/(1+a*b)*(g/E(2)+b*G1(E));
R-E(1)-E(2)
];
P=fsolve(pl, E0);
Here I want to give two more condition such as
pl=@(E) [
g/E(1)+G0(E)+rho*G1(E)*b/(1+a*b)>0
b/(1+a*b)*(g/E(2)+b*G1(E))>0
How can I do this?
0 个评论
回答(2 个)
Walter Roberson
2012-4-17
In order to express that a > b, you can reframe that as a + c = b where c is constrained to be positive.
However, it may perhaps be difficult to express strictly positive, as a lot of the routines are set up for constraints >= 0 rather than > 0
0 个评论
Sargondjani
2012-4-17
you could also use fmincon. have a look at it
then you have to make the objective pl^2, and you can supply the constraints separately
2 个评论
Walter Roberson
2012-4-17
If pl(E).^2 is the objective, then pl(E) and -pl(E) become equally plausible, which does not help in requiring pl(E) > 0 .
Sargondjani
2012-4-17
i think there is some confusion...
his first 'pl' is the objective
his second 'pl' (should have gotten another name) are the constraints, which are the first and second part of the the objective function (both required >0).
when the latter 2 are inserted as constraints in fmincon, the algorithm will solve this properly...
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!