Matlab code to find optimal solution for A and B
    3 views (last 30 days)
  
       Show older comments
    
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 Comment
  John D'Errico
      
      
 on 17 Sep 2017
				
      Edited: John D'Errico
      
      
 on 17 Sep 2017
  
			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.
Answers (0)
See Also
Categories
				Find more on Particle Swarm in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!