How can i minimize a function provided that another function is greater than 0?

I have a function (WT) and my code created by fmincon minimizes WT with using inequlaties and lower bounds. WT is sum of another functions (R+L+B+S) and when fmincon is running, B function must be greater than zero. I don't know how i can achieve this problem.
Is there a way a pratical approach for this?
Thanks a lot.
.
.
.
first=@(A) 15+7*A
B=@(D,A) sum(2000*(1/(2*5))*((first(A)-D*[2:7]).^2-(first(A)-D*[1:7-1]).^2));
W_Y(D,A)=R(D,A)+B(D,A)+S+R(D,A)
WT=@(YH) W_H(YH(2))+W_Y(YH(1),YH(2));
x0=[0,0];
A=[1 ,-1.066441];
b= 0.058766;
Aeq=[];
beq=[];
lb=[0,0];
ub=[];
YH=fmincon(W_T,x0,A,b,Aeq,beq,lb,ub)

 采纳的回答

Use "nonlcon" to set the constraint
sum(2000*(1/(2*5))*((first(A)-D*[2:7]).^2-(first(A)-D*[1:7-1]).^2)) >= 0
Best wishes
Torsten.

4 个评论

For greater than 0 of this section: ((first(A)-D*[2:7]).^2-(first(A)-D*[1:7-1]).^2)), does it should be written again as a function?
Edit: Yes. :)
If you evaluate
((first(A)-D*[2:7]).^2-(first(A)-D*[1:7-1]).^2))
you get the condition
15+7*A <= 1.5*D
as the condition that the "section" is always >= 0.
This condition can be taken in the A,b part for the call to fmincon.
Best wishes
Torsten.

请先登录,再进行评论。

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Mathematics and Optimization 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by