Matlab code to find optimal solution for A and B

3 次查看(过去 30 天)
Hi i want to find the optimal solution for A and B ?
function[V,A-opt,B-opt]=test(M)
A1=max(M(:,1));
A2=max(M(:,2));
B1=min(M(1,:));
B2=min(M(2,:));
[C,row]= min(max(A1,A2));
[C,col]=max(min(B1,B2));
if min(A1,A2)==max(B1,B2)
fprintf('There is a saddle point')
V=max(B1,B2);
else fprintf('There is no saddle point')
x1=abs(M(1,1)-M(1,2));
y1=abs(M(2,1)-M(2,2));
x2=abs(M(1,1)-M(2,1));
y2=abs(M(1,2)-M(2,2));
fprintf('the game value')
V=(M(1,1)*y1/(x1+y1))+(M(2,1)*x1/(x1+y1))
end
end
  1 个评论
John D'Errico
John D'Errico 2017-9-17
编辑:John D'Errico 2017-9-17
Note that A-opt (as well as B-opt) are NOT valid variable names in MATLAB.
You can use an underscore in a name, thus A_opt is valid, if you insist on that name form. But the - symbol is not valid anywhere in a name.
As far as solving the question at hand, it is not obvious what you mean by optimal. Optimality requires that you postulate some well posed metric to determine what is good versus bad. So without knowing what you intend by the word optimal, it is impossible to answer your question. We are not even told what the code you show is intended to do.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Particle Swarm 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by