Matlab code to find optimal solution for A and B
1 回表示 (過去 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
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 Center および File Exchange で Particle Swarm についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!