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
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!