Section 5.2.5: Mixed strategies for matrix games (LP formulation)
randn('state',0);
n = 12;
m = 12;
P = randn(n,m);
fprintf(1,'Computing the optimal strategy for player 1 ... ');
cvx_begin
variables u(n) t1
minimize ( t1 )
u >= 0;
ones(1,n)*u == 1;
P'*u <= t1*ones(m,1);
cvx_end
fprintf(1,'Done! \n');
fprintf(1,'Computing the optimal strategy for player 2 ... ');
cvx_begin
variables v(m) t2
maximize ( t2 )
v >= 0;
ones(1,m)*v == 1;
P*v >= t2*ones(n,1);
cvx_end
fprintf(1,'Done! \n');
disp('------------------------------------------------------------------------');
disp('The optimal strategies for players 1 and 2 are respectively: ');
disp([u v]);
disp('The expected payoffs for player 1 and player 2 respectively are: ');
[t1 t2]
disp('They are equal as expected!');
Computing the optimal strategy for player 1 ...
Calling SeDuMi: 25 variables (1 free), 13 equality constraints
------------------------------------------------------------------------
SeDuMi 1.1 by AdvOL, 2005 and Jos F. Sturm, 1998, 2001-2003.
Alg = 2: xz-corrector, Adaptive Step-Differentiation, theta = 0.250, beta = 0.500
Split 1 free variables
eqs m = 13, order n = 27, dim = 27, blocks = 1
nnz(A) = 192 + 0, nnz(ADA) = 169, nnz(L) = 91
it : b*y gap delta rate t/tP* t/tD* feas cg cg prec
0 : 8.33E+000 0.000
1 : -3.47E-001 3.67E+000 0.000 0.4406 0.9000 0.9000 2.44 1 1 6.6E+000
2 : -4.31E-002 1.64E+000 0.000 0.4457 0.9000 0.9000 4.60 1 1 1.1E+000
3 : -4.52E-002 4.48E-001 0.000 0.2738 0.9000 0.9000 1.52 1 1 2.3E-001
4 : -4.50E-002 8.38E-002 0.000 0.1872 0.9000 0.9000 1.13 1 1 4.2E-002
5 : -4.49E-002 7.41E-003 0.000 0.0884 0.9900 0.9900 1.03 1 1 3.9E-003
6 : -4.48E-002 1.39E-005 0.000 0.0019 0.9990 0.9990 1.01 1 1
iter seconds digits c*x b*y
6 0.0 Inf -4.4840422221e-002 -4.4840422221e-002
|Ax-b| = 2.2e-016, [Ay-c]_+ = 1.2E-016, |x|= 1.0e+000, |y|= 4.0e-001
Detailed timing (sec)
Pre IPM Post
0.000E+000 1.001E-002 0.000E+000
Max-norms: ||b||=1, ||c|| = 1,
Cholesky |add|=0, |skip| = 0, ||L.L|| = 1.40372.
------------------------------------------------------------------------
Status: Solved
Optimal value (cvx_optval): -0.0448404
Done!
Computing the optimal strategy for player 2 ...
Calling SeDuMi: 25 variables (1 free), 13 equality constraints
------------------------------------------------------------------------
SeDuMi 1.1 by AdvOL, 2005 and Jos F. Sturm, 1998, 2001-2003.
Alg = 2: xz-corrector, Adaptive Step-Differentiation, theta = 0.250, beta = 0.500
Split 1 free variables
eqs m = 13, order n = 27, dim = 27, blocks = 1
nnz(A) = 192 + 0, nnz(ADA) = 169, nnz(L) = 91
it : b*y gap delta rate t/tP* t/tD* feas cg cg prec
0 : 8.33E+000 0.000
1 : -3.23E-001 3.71E+000 0.000 0.4455 0.9000 0.9000 2.42 1 1 6.7E+000
2 : 1.15E-002 1.61E+000 0.000 0.4343 0.9000 0.9000 4.60 1 1 1.0E+000
3 : 3.84E-002 4.33E-001 0.000 0.2688 0.9000 0.9000 1.51 1 1 2.2E-001
4 : 4.33E-002 8.56E-002 0.000 0.1975 0.9000 0.9000 1.12 1 1 4.3E-002
5 : 4.47E-002 6.91E-003 0.000 0.0808 0.9900 0.9900 1.03 1 1 3.6E-003
6 : 4.48E-002 5.43E-005 0.000 0.0079 0.9990 0.9825 1.01 1 1
iter seconds digits c*x b*y
6 0.0 Inf 4.4840422221e-002 4.4840422221e-002
|Ax-b| = 2.5e-016, [Ay-c]_+ = 1.3E-016, |x|= 8.4e-001, |y|= 4.4e-001
Detailed timing (sec)
Pre IPM Post
0.000E+000 2.003E-002 0.000E+000
Max-norms: ||b||=1, ||c|| = 1,
Cholesky |add|=0, |skip| = 0, ||L.L|| = 5.12072.
------------------------------------------------------------------------
Status: Solved
Optimal value (cvx_optval): -0.0448404
Done!
------------------------------------------------------------------------
The optimal strategies for players 1 and 2 are respectively:
(1,1) 0.2695
(3,1) 0.0973
(4,1) 0.1573
(5,1) 0.1145
(6,1) 0.0434
(9,1) 0.2511
(10,1) 0.0670
(1,2) 0.0686
(2,2) 0.1619
(4,2) 0.2000
(6,2) 0.1545
(7,2) 0.1146
(9,2) 0.1030
(12,2) 0.1974
The expected payoffs for player 1 and player 2 respectively are:
ans =
-0.0448 -0.0448
They are equal as expected!