A Simulation of the Game (gameh1)

Run LPL Code  ,  PDF Document

Problem

This model is related to the model gameh.


Listing 1: The Complete Model implemented in LPL [2]
model gameh1 "A Simulation of the Game"; 
  set   i,j :=[1..50]; 
  parameter  p{i,j} := 
    if(i>j+1,-j , i=j+1,i+j , i=j-1,-i-j, i<j-1,i); 
  variable   x{i}  "Strategy of player 1"; 
  constraint  R: sum{i} x = 1; 
  maximize gain: min{j} (sum{i} p*x); 
  parameter y{j}:=if(j=1,1); //fixed strategy for II 
  Write('Player I plays optimal, ' nplayer II always number 1' n'); 
  Write('Average gain of I is: %10.7f ' n' n',sum{i,j} p*x*y); 
  y{j}:=if(j=2,1); //fixed strategy for II 
  Write('Player I plays optimal, ' nplayer II always number 2' n'); 
  Write('Average gain of I is: %10.7f ' n' n',sum{i,j} p*x*y); 
  y{j}:=if(j<=5,0.2); //fixed strategy for II 
  Write('Player I plays optimal, ' nplayer II number 1..5 at 20%' n'); 
  Write('Average gain of I is: %10.7f ' n' n',sum{i,j} p*x*y); 
  y{j}:=if(j<=4,j/10); //fixed strategy for II 
  Write('Player I plays optimal, ' nplayer II each number 1..4 at 10% 20% 30% 40%' n'); 
  Write('Average gain of I is: %10.7f ' n' n',sum{i,j} p*x*y); 
  y{j}:=if(j<=10,0.1); //fixed strategy for II 
  Write('Player I plays optimal, ' nplayer II each number 1..10 at 10%' n'); 
  Write('Average gain of I is: %10.7f ' n' n' n',sum{i,j} p*x*y); 
  Write('Player I optimal, player two 1,2,3,4,5,6' n'); 
  Write('%10.7f ', x[2]*3); 
  Write('%10.7f ' n', x[3]+ x[4]+ x[5]); 
  Write('%10.7f ', x[3]*5); 
  Write('%10.7f ' n', x[1]*3 + x[4]*2 + x[5]*2); 
  Write('%10.7f ', x[1] + 7*x[4]); 
  Write('%10.7f ' n', 5*x[2] + x[5]*3); 
  Write('%10.7f ', x[1] + 2*x[2] + x[5]*9); 
  Write('%10.7f ' n', x[3]*7); 
  Write('%10.7f ', x[1] + x[2]*2+ x[3]*3); 
  Write('%10.7f ' n', x[4]*9); 
  Write('%10.7f ', x[1] + x[2]*2+ x[3]*3+x[4]*4); 
  Write('%10.7f ' n', x[5]*11); 
end

References

[1]   MatMod. Homepage for Learning Mathematical Modeling :  https://matmod.ch.

[2]   Hürlimann T. Reference Manual for the LPL Modeling Language, most recent version. https://matmod.ch/lpl/doc/manual.pdf.