Instantly share code, notes, and snippets.

# MateuszKubuszok/0s.dat

Created Feb 4, 2014
MathProg: calculate mixed strategies Nash equilibrium (2 players, 0-sum game)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 data; set P1S := a b c; set P2S := 1 2 3 4; param Payoff : 1 2 3 4 := a -5 3 1 8 b 5 5 4 6 c -4 6 0 5; end;
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 set P1S; set P2S; param Payoff{P1S, P2S}; var y{P1S} >= 0; minimize GameValue: sum{i in P1S} y[i]; s.t. Condition2{j in P2S}: sum{i in P1S} Payoff[i,j] * y[i] >= 1; solve; printf "Value: %s\n", GameValue; printf "Player 1 strategies:\n"; for{i in P1S} printf "Found %s, actual %s\n", y[i], y[i]/GameValue; end;
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 set P1S; set P2S; param Payoff{P1S, P2S}; var x{P2S} >= 0; maximize GameValue: sum{j in P2S} x[j]; s.t. Condition1{i in P1S}: sum{j in P2S} Payoff[i,j] * x[j] <= 1; solve; printf "Value: %s\n", GameValue; printf "Player 2 strategies:\n"; for{j in P2S} printf "Found %s, actual %s\n", x[j], x[j]/GameValue; end;