when i do fmincon live script optimize, the coordinate is different
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
Matt J
2022 年 12 月 4 日
in my picture, it says optimal point is x= 1, y=1
It doesn't say that, as far as I can see.
回答 (1 件)
VINAYAK LUHA
2023 年 9 月 12 日
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
0 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!