2
7/23/2019 Code to find Operations research problem http://slidepdf.com/reader/full/code-to-find-operations-research-problem 1/2 G=input('Enter reward matrix:');  a=[];b=[];[m,n]=size(G);  if min(max(G))==max(min(G'))  q=max(G);Strateg!"st=[];Strateg!""nd=[];ms=[];  f#r i=$:n  f#r %=$:m  if isequa&(q(i),G(%,i))  if isequa&(G(%,i),min(G(%,:)))  a(&engt(a)$)=%;  b(&engt(b)$)=i;  end  end  end  end  if (&engt(a)==$ &engt (b)==$)  *nswer=['+e pa#ff matrix as a sadd&e p#int at te &#ati#n :- (' int.str(r) ',' int.str(s) ') and /a&ue is ' num.str(0(r,s),1) '2n# mixed strateg is required']  e&se f#r i=$:&engt(a)  ms=[ms '(' int.str(a(i)) ',' int.str(b(i)) '),'];  end  *nswer=['+e pa#ff matrix as sadd&e p#ints at te &#ati#ns :-' ms ' and /a&ue is ' num.str(G(a($),b($)),1) '2n# mixed strateg is required']  end  e&se  3!a=&inpr#g(-[$;zer#s(m,$)],[#nes(n,$) -G'],zer#s(n,$),[4

Code to find Operations research problem

Embed Size (px)

Citation preview

Page 1: Code to find Operations research problem

7/23/2019 Code to find Operations research problem

http://slidepdf.com/reader/full/code-to-find-operations-research-problem 1/2

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

 a=[];b=[];[m,n]=size(G);

 if min(max(G))==max(min(G'))

 

q=max(G);Strateg!"st=[];Strateg!""nd=[];ms=[]; 

f#r i=$:n

 f#r %=$:m

 if isequa&(q(i),G(%,i))

 if isequa&(G(%,i),min(G(%,:)))

 a(&engt(a)$)=%;

 b(&engt(b)$)=i;

 end

 end

 end

 end

 if (&engt(a)==$ &engt (b)==$)

 *nswer=['+e pa#ff matrix as a sadd&e p#int at te &#ati#n :- (' 

int.str(r) ',' int.str(s) ') and /a&ue is ' num.str(0(r,s),1) '2n# mixed

strateg is required']

 e&se 

f#r i=$:&engt(a)

 ms=[ms '(' int.str(a(i)) ',' int.str(b(i)) '),'];

 end

 

*nswer=['+e pa#ff matrix as sadd&e p#ints at te &#ati#ns :-' ms

' and /a&ue is ' num.str(G(a($),b($)),1) '2n# mixed strateg is required']

 end

 e&se

 3!a=&inpr#g(-[$;zer#s(m,$)],[#nes(n,$) -G'],zer#s(n,$),[4

Page 2: Code to find Operations research problem

7/23/2019 Code to find Operations research problem

http://slidepdf.com/reader/full/code-to-find-operations-research-problem 2/2

 #nes($,m)],[$],[-inf;zer#s(m,$)]);/=3!a($,$);3!a($,:)=[];

 3!b=&inpr#g([$;zer#s(n,$)],[-#nes(m,$) 0],zer#s(m,$),[4 #nes($,n)],[$],[-

 inf;zer#s(n,$)]);3!b($,:)=[];

 *nswer=['+e pa#ff matrix as n# sadd&e p#int and /a&ue is ' 

num.str(/,1) ' and s# te suggested mixed strateg is gi/en in mixed strateg

matrix2']

 Strateg!"st=3!a

 Strateg!""nd=3!b

end