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 SDPT3: 25 variables, 13 equality constraints
------------------------------------------------------------
num. of constraints = 13
dim. of linear var = 24
dim. of free var = 1 *** convert ublk to lblk
*******************************************************************
SDPT3: Infeasible path-following algorithms
*******************************************************************
version predcorr gam expon scale_data
NT 1 0.000 1 0
it pstep dstep pinfeas dinfeas gap mean(obj) cputime
-------------------------------------------------------------------
0|0.000|0.000|3.6e+01|1.0e+01|6.0e+02| 1.437979e-10| 0:0:00| chol 1 1
1|0.917|0.853|3.0e+00|1.6e+00|8.6e+01| 5.803096e-02| 0:0:00| chol 1 1
2|1.000|0.986|8.8e-07|3.3e-02|8.7e+00| 2.061331e-01| 0:0:00| chol 1 1
3|1.000|0.935|1.7e-06|3.1e-03|2.4e+00|-1.806437e-01| 0:0:00| chol 1 1
4|0.870|0.665|4.1e-06|1.1e-03|6.9e-01|-2.077128e-01| 0:0:00| chol 1 1
5|1.000|0.088|1.9e-06|1.0e-03|6.3e-01|-2.050085e-01| 0:0:00| chol 1 1
6|1.000|0.554|6.9e-07|4.6e-04|3.5e-01|-1.112454e-01| 0:0:00| chol 1 1
7|0.985|0.650|3.2e-07|1.6e-04|1.1e-01|-7.743436e-02| 0:0:00| chol 1 1
8|0.924|0.351|7.4e-08|1.1e-04|6.6e-02|-7.001485e-02| 0:0:00| chol 1 1
9|1.000|0.428|3.1e-08|6.0e-05|3.7e-02|-5.993379e-02| 0:0:00| chol 1 1
10|1.000|0.497|5.8e-09|3.0e-05|1.9e-02|-5.270502e-02| 0:0:00| chol 1 1
11|1.000|0.414|1.5e-09|1.8e-05|1.1e-02|-4.968381e-02| 0:0:00| chol 1 1
12|0.983|0.858|4.5e-10|2.5e-06|1.5e-03|-4.555801e-02| 0:0:00| chol 1 1
13|0.988|0.985|2.5e-11|1.7e-05|2.5e-05|-4.485120e-02| 0:0:00| chol 1 1
14|1.000|0.989|3.4e-14|2.8e-07|5.3e-07|-4.484054e-02| 0:0:00| chol 1 1
15|1.000|0.989|1.1e-14|5.9e-09|9.8e-09|-4.484042e-02| 0:0:00|
stop: max(relative gap, infeasibilities) < 1.49e-08
-------------------------------------------------------------------
number of iterations = 15
primal objective value = -4.48404196e-02
dual objective value = -4.48404289e-02
gap := trace(XZ) = 9.85e-09
relative gap = 9.04e-09
actual relative gap = 8.60e-09
rel. primal infeas = 1.14e-14
rel. dual infeas = 5.92e-09
norm(X), norm(y), norm(Z) = 9.7e-01, 4.0e-01, 7.4e-01
norm(A), norm(b), norm(C) = 1.4e+01, 2.0e+00, 2.4e+00
Total CPU time (secs) = 0.3
CPU time per iteration = 0.0
termination code = 0
DIMACS: 1.1e-14 0.0e+00 7.1e-09 0.0e+00 8.6e-09 9.0e-09
-------------------------------------------------------------------
------------------------------------------------------------
Status: Solved
Optimal value (cvx_optval): -0.0448404
Done!
Computing the optimal strategy for player 2 ...
Calling SDPT3: 25 variables, 13 equality constraints
------------------------------------------------------------
num. of constraints = 13
dim. of linear var = 24
dim. of free var = 1 *** convert ublk to lblk
*******************************************************************
SDPT3: Infeasible path-following algorithms
*******************************************************************
version predcorr gam expon scale_data
NT 1 0.000 1 0
it pstep dstep pinfeas dinfeas gap mean(obj) cputime
-------------------------------------------------------------------
0|0.000|0.000|3.8e+01|1.0e+01|6.0e+02|-1.437979e-10| 0:0:00| chol 1 1
1|0.915|0.847|3.2e+00|1.6e+00|8.8e+01| 1.352019e-01| 0:0:00| chol 1 1
2|1.000|0.986|9.2e-07|3.3e-02|8.8e+00| 2.751661e-01| 0:0:00| chol 1 1
3|1.000|0.899|1.7e-06|4.2e-03|2.5e+00|-1.502898e-01| 0:0:00| chol 1 1
4|0.887|0.352|4.3e-06|2.8e-03|1.3e+00|-2.907480e-01| 0:0:00| chol 1 1
5|1.000|0.227|4.4e-06|2.2e-03|1.1e+00|-2.153276e-01| 0:0:00| chol 1 1
6|1.000|0.596|1.5e-06|8.7e-04|4.1e-01|-9.555833e-02| 0:0:00| chol 1 1
7|1.000|0.277|2.2e-07|6.3e-04|3.1e-01|-5.906355e-02| 0:0:00| chol 1 1
8|1.000|0.371|1.2e-07|4.0e-04|2.0e-01|-2.566743e-02| 0:0:00| chol 1 1
9|1.000|0.499|3.8e-08|2.0e-04|9.9e-02| 5.671373e-03| 0:0:00| chol 1 1
10|1.000|0.661|7.0e-09|6.7e-05|3.2e-02| 3.014456e-02| 0:0:00| chol 1 1
11|1.000|0.811|6.9e-10|1.3e-05|6.0e-03| 4.196714e-02| 0:0:00| chol 1 1
12|0.989|0.970|6.0e-11|3.8e-07|1.8e-04| 4.475275e-02| 0:0:00| chol 1 1
13|0.989|0.988|3.6e-12|2.0e-06|2.3e-06| 4.483941e-02| 0:0:00| chol 1 1
14|1.000|0.989|1.9e-14|2.5e-08|4.7e-08| 4.484041e-02| 0:0:00| chol 1 1
15|1.000|0.989|5.6e-16|5.3e-10|8.9e-10| 4.484042e-02| 0:0:00|
stop: max(relative gap, infeasibilities) < 1.49e-08
-------------------------------------------------------------------
number of iterations = 15
primal objective value = 4.48404225e-02
dual objective value = 4.48404216e-02
gap := trace(XZ) = 8.93e-10
relative gap = 8.20e-10
actual relative gap = 7.80e-10
rel. primal infeas = 5.65e-16
rel. dual infeas = 5.35e-10
norm(X), norm(y), norm(Z) = 7.4e-01, 4.4e-01, 9.7e-01
norm(A), norm(b), norm(C) = 1.4e+01, 2.0e+00, 2.4e+00
Total CPU time (secs) = 0.2
CPU time per iteration = 0.0
termination code = 0
DIMACS: 5.6e-16 0.0e+00 6.5e-10 0.0e+00 7.8e-10 8.2e-10
-------------------------------------------------------------------
------------------------------------------------------------
Status: Solved
Optimal value (cvx_optval): -0.0448404
Done!
------------------------------------------------------------------------
The optimal strategies for players 1 and 2 are respectively:
0.2695 0.0686
0.0000 0.1619
0.0973 0.0000
0.1573 0.2000
0.1145 0.0000
0.0434 0.1545
0.0000 0.1146
0.0000 0.0000
0.2511 0.1030
0.0670 0.0000
0.0000 0.0000
0.0000 0.1974
The expected payoffs for player 1 and player 2 respectively are:
ans =
-0.0448 -0.0448
They are equal as expected!