Created
February 4, 2014 15:53
-
-
Save MateuszKubuszok/8806295 to your computer and use it in GitHub Desktop.
MathProg: calculate mixed strategies Nash equilibrium (any 2 players 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 Payoff1 | |
: 1 2 3 4 := | |
a 0 3 1 8 | |
b 5 5 4 6 | |
c 2 6 0 5; | |
param Payoff2 | |
: 1 2 3 4 := | |
a 6 6 2 2 | |
b 3 2 5 6 | |
c 0 7 0 1; | |
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 Payoff1{P1S, P2S}; | |
param Payoff2{P1S, P2S}; | |
param U1 := max{i in P1S, j in P2S} Payoff1[i,j] - min{i in P1S, j in P2S} Payoff1[i,j]; | |
param U2 := max{i in P1S, j in P2S} Payoff2[i,j] - min{i in P1S, j in P2S} Payoff2[i,j]; | |
var b1s{P1S}, binary; | |
var b2s{P2S}, binary; | |
var p1s{P1S}, >= 0, <=1; | |
var p2s{P2S}, >= 0, <=1; | |
var u1s{P1S}; | |
var u2s{P2S}; | |
var r1s{P1S}; | |
var r2s{P2S}; | |
var u1; | |
var u2; | |
minimize AvarageRegret: ( sum{i in P1S} r1s[i] + sum{j in P2S} r2s[j] ) / 2; | |
s.t. Probabilities1: | |
sum{i in P1S} p1s[i] = 1; | |
s.t. Probabilities2: | |
sum{j in P2S} p2s[j] = 1; | |
s.t. UtilitiesValue1{i in P1S}: | |
u1s[i] = sum{j in P2S} p2s[j] * Payoff1[i,j]; | |
s.t. UtilitiesValue2{j in P2S}: | |
u2s[j] = sum{i in P1S} p1s[i] * Payoff2[i,j]; | |
s.t. MaxUtilities1{i in P1S}: | |
u1 >= u1s[i]; | |
s.t. MaxUtilities2{j in P2S}: | |
u2 >= u2s[j]; | |
s.t. Regret1{i in P1S}: | |
r1s[i] = u1 - u1s[i]; | |
s.t. Regret2{j in P2S}: | |
r2s[j] = u2 - u2s[j]; | |
s.t. Probability1{i in P1S}: | |
p1s[i] <= 1 - b1s[i]; | |
s.t. Probability2{j in P2S}: | |
p2s[j] <= 1 - b2s[j]; | |
s.t. RegretAndMax1{i in P1S}: | |
r1s[i] <= U1 * b1s[i]; | |
s.t. RegretAndMax2{j in P2S}: | |
r2s[j] <= U2 * b2s[j]; | |
solve; | |
printf "Player 1 strategies:\n"; | |
for{i in P1S} | |
printf "%s -> %s\n", i, p1s[i]; | |
printf "Sum = %s, \n", sum{i in P1S} p1s[i] * u1s[i]; | |
printf "Max = %s, \n", U1; | |
printf "Player 2 strategies:\n"; | |
for{j in P2S} | |
printf "%s -> %s\n", j, p2s[j]; | |
printf "Sum = %s, \n", sum{j in P2S} p2s[j] * u2s[j]; | |
printf "Max = %s, \n", U2; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment