You are on page 1of 2

G=input('Enter reward matrix:');

a=[];b=[];[m,n]=size(G);
if min(max(G))==max(min(G'))
q=max(G);Strategy_Ist=[];Strategy_IInd=[];ms=[];
for i=1:n
for j=1:m
if isequal(q(i),G(j,i))
if isequal(G(j,i),min(G(j,:)))
a(length(a)+1)=j;
b(length(b)+1)=i;
end
end
end
end
if (length(a)==1 && length (b)==1)
Answer=['The payoff matrix has a saddle point at the location :- ('
int2str(r) ',' int2str(s) ') and value is ' num2str(L(r,s),6) '.no mixed
strategy is required']
else
for i=1:length(a)
ms=[ms '(' int2str(a(i)) ',' int2str(b(i)) '),'];
end
Answer=['The payoff matrix has saddle points at the locations :-' ms
' and value is ' num2str(G(a(1),b(1)),6) '.no mixed strategy is required']
end
else
X_a=linprog(-[1;zeros(m,1)],[ones(n,1) -G'],zeros(n,1),[0

ones(1,m)],[1],[-inf;zeros(m,1)]);v=X_a(1,1);X_a(1,:)=[];
X_b=linprog([1;zeros(n,1)],[-ones(m,1) L],zeros(m,1),[0 ones(1,n)],[1],[inf;zeros(n,1)]);X_b(1,:)=[];
Answer=['The payoff matrix has no saddle point and value is '
num2str(v,6) ' and so the suggested mixed strategy is given in mixed strategy
matrix.']
Strategy_Ist=X_a
Strategy_IInd=X_b
end

You might also like