when i do fmincon live script optimize, the coordinate is different

i want to get a coordinate for maximum distance which form is
distance =10.361+0.40125.*a-0.34875.*c-0.78375.*a.*c
i plot this surface, and i saw (1,-1) is the best coordinate and the maximum distance is 11.8947
but when i do this for live script fmincon,
x0=[0 0];
lowerbound=[-1 -1];
upperbound =[1 1];
%objective function
function f = distance(x) ;
A=x(1);
C=x(2);
f= (-1).*(10.361+0.40125.*A-0.34875.*C-0.78375.*A.*C);
end
function [c ceq]=const(x)
A=x(1);
C=x(2);
c=A+C-2;
ceq=[];
end
the answer is x=1 y=1 , not x=1 y=-1 that i saw by surface plot !!!!!! plz help me
in my picture, it says optimal point is x= 1, y=1
altough the coordinate is differant (1,1)=/ (1,-1)
result of maximum distance is same

댓글 수: 1

in my picture, it says optimal point is x= 1, y=1
It doesn't say that, as far as I can see.

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

답변 (1개)

Hi Jong,
It is my understanding that the minimum coordinates on the surface plot subjected to the objective function calculated using “fmincon” function is different from the visually observed minimum coordinates. This is due to improper syntax of the used "fmincon" function.
Here's the corrected syntax to use to obtain the desired solution-
distance = @(x) -1 * (10.361 + 0.40125 * x(1) - 0.34875 * x(2) - 0.78375 * x(1) * x(2));
Since the bounds of the parameters is defined as below -
lb = [-1, -1];
ub = [1, 1];
This implies that x1+x2<=2, Which as per the documentation can be modelled as follows-
A =[1,1];
b = 2;
Aeq =[];
Beq =[];
x0 =[0, 0];
x_min =fmincon(distance,x0,[1 1],2,[],[],lb,ub);
Read through the below mentioned documentation on "fmincon" for more details
Hope this helps!
Regards,
Vinayak Luha

카테고리

도움말 센터File Exchange에서 Get Started with Optimization Toolbox에 대해 자세히 알아보기

제품

릴리스

R2022b

질문:

2022년 12월 4일

답변:

2023년 9월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by