Optimization Questions on set constraint

1 次查看(过去 30 天)
Halo
I have got a question when setting the constraint of optimization I want to optimize the p(1,p(2)and p(3) There are 4 constraint i need to set
1)p(1)+p(2)+p(3)=1
2)p(1)*e(1)+p(2)*e(2)+p(3)*e(3)<=eav
3)0<=p(i), where i=1,2,3
4)p(i)<=1, where i=1,2,3
I want these set in a condition file However matlab just tell me
Warning: The default trust-region-reflective algorithm does not solve problems with the constraints you
have specified. FMINCON will use the active-set algorithm instead. For information on applicable
algorithms, see Choosing the Algorithm in the documentation.
> In fmincon at 504
In optst22 at 32
Warning: Your current settings will run a different algorithm (interior-point) in a future release.
> In fmincon at 509
In optst22 at 32
PS it seems that it failure PLZ help me

回答(3 个)

Matt J
Matt J 2014-12-8
编辑:Matt J 2014-12-8
No, there is non evidence of failure. The messages are just warnings that fmincon switched to non-default settings.

Ho Chun
Ho Chun 2014-12-8
编辑:Matt J 2014-12-8
I have set the constraint that the range of p(1), p(2) and p(3) must within 0 and 1. However, they still have negative value appear. It seems that this constraint does not work.
May you tell me how to set constraint?
My code as follow
c(1)=p(1)*t*e(1)+p(2)*t*e(2)+p(3)*t*e(3);
c(2)=-p(1)*t;
c(3)=-p(2)*t;
c(4)=-p(3)*t;
c(5)=p(1)*t-1;
c(6)=p(2)*t-1;
c(7)=p(3)*t-1;
ceq=[-1+result;];
  2 个评论
Matt J
Matt J 2014-12-8
编辑:Matt J 2014-12-8
Only bound constraints can be satisfied exactly, but only with the interior-point or sqp algorithm, and only if you use the lb,ub arguments to express them, as Alan indicated.
The rest of the constraints can be violated slightly and you must accept this. Although, you can use the TolCon input option to demand a lower non-zero violation. The price will be more iterations and longer compute time for fmincon, however.
Torsten
Torsten 2014-12-8
If t=1, result=p(1)+p(2)+p(3) and your call to fmincon is correct, I don't see anything wrong.
By the way: The constraints p(i)<=1 are superfluous because you claim p(i)>=0 and p(1)+p(2)+p(3)=1.
Best wishes
Torsten.

请先登录,再进行评论。


Alan Weiss
Alan Weiss 2014-12-8
You should not be using nonlinear constraints. Instead, use bounds and linear constraints as follows:
lb = zeros(3,1)
ub = ones(3,1)
Aeq = [1,1,1]; beq = 1;
A = [e(1),e(2),e(3)]; b = eav;
options = optimoptions(@fmincon,'Algorithm','interior-point');
[x,fval,eflag,outpt] = fmincon(fun,x0,A,b,Aeq,beq,lb,ub,[],options)
For more information, see the documentation on constraints.
Alan Weiss
MATLAB mathematical toolbox documentation

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by