I have a location facility project where i should optimize the cost of implementing it using fmnincon. The problem is i have a condition on (x,y) (this is th coordinate of my facilities):
sqrt((x-15)^2+(y-48)^2))>10
sqrt((x-18)^2+(y-12)^2))>10
Since this two equation are non linear i can define this function:
function [c,ceq]=NLcon(z)
ceq=[];
c(1)=-z(1)^2 +26*z(1)-z(2)^2+96*z(2)-2473+100;
c(2)=-z(1)^2+36*z(1)+24*z(2)-z(2)^2-468+100;
end
but how can I add this constraint: if 20<=y<=40 then x<=20?

 채택된 답변

Matt J
Matt J 2021년 11월 25일
편집: Matt J 2021년 11월 26일

0 개 추천

Divide into 3 sub-problems. Solve with the constraints
(1) y<=20 and NLcon
(2) 20<=x<=40, y<=20, and NLcon
(3) y>=20 and NLcon
Take the solution to whichever of the 3 sub-problems gives the most optimal cost value.

댓글 수: 2

Thank you for your answer but i have here:
this the equation that i should optimize
and this is my constraint
if 20<=y<=40 then x<=20
and i have y>=0 (as lower bound)
y>-2*x+20 ( i can define it in A)
I'm waiting as output (x,y)
so we can't define three cases where my x can be unconstrained
Matt J
Matt J 2021년 11월 26일
편집: Matt J 2021년 11월 26일
so we can't define three cases where my x can be unconstrained
Since you accepted the answer, I assume you figure it out?
If not, see my updated answer.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 Problem-Based Optimization Setup에 대해 자세히 알아보기

제품

릴리스

R2021b

질문:

2021년 11월 25일

편집:

2021년 11월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by