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)

 Accepted Answer

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 Comments

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.

Sign in to comment.

More Answers (0)

Categories

Find more on Mathematics and Optimization in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!