-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproper-equilibrium.run
107 lines (82 loc) · 2.97 KB
/
proper-equilibrium.run
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# Options
option solver gurobi;
# Include files
model P_t.mod
model Q_t.mod
data game_data.dat
# Define problems
problem P_t: x_P, z, value_of_game, no_regret_on_unexploitable, min_max_on_exploitable, sum_to_one;
problem Q_t: x_Q, p, sum_probabilities, no_regret_on_unexploitable, min_max_on_exploitable_upd;
problem P_t_b: x_P_b, z_b, value_of_game_b, no_regret_on_unexploitable_b, min_max_on_exploitable_b, sum_to_one_b;
problem Q_t_b: x_Q_b, p_b, sum_probabilities_b, no_regret_on_unexploitable_b, min_max_on_exploitable_upd_b;
printf "P1\n";
let phi_2_t := phi_2; # initial exploitable actions = all
let C2_t := {}; # initial unexpl. = empty set
param t default 0; # iteration count
# Solving for D-opt strategy of P1
repeat {
let C2_t := phi_2 diff phi_2_t; # update unexploitable
printf "============Iteration t=%d============\n", t;
printf "Solving P_%d...\n", t;
# Solve P_t
solve P_t;
display x_P, z;
let value_upd := z.val; # update value of the game to be used in Q_t
# Solve Q_t
printf "Solving Q_%d...\n", t;
display phi_2_t;
solve Q_t;
display x_Q, p;
# Delete non-exploitable moves of P2 (update exploitable set)
for {k in phi_2_t} {
if p[k] < 1 then {
let phi_2_t := phi_2_t diff {k};
}
}
let t := t + 1;
let value := z.val; # update value of the game to be used in P_t+1
# Stopping criteria
if forall {k in phi_2_t} p[k] < 1 then {
break;
}
}
printf "=========================================================================\n";
printf "P2\n";
# Solving for D-opt strategy of P2
let phi_1_t := phi_1; # initial exploitable actions = all
let C1_t := {}; # initial unexpl. = empty set
let t := 0; # iteration count
#display phi_1, phi_1_t, C1_t, phi_2, phi_2_t, C2_t;
repeat {
let C1_t := phi_1 diff phi_1_t; # update unexploitable
printf "============Iteration t=%d============\n", t;
printf "Solving P_%d...\n", t;
# Solve P_t
solve P_t_b;
display x_P_b, z_b;
let value_upd_b := z_b.val; # update value of the game
# Solve Q_t
printf "Solving Q_%d...\n", t;
display phi_1_t;
solve Q_t_b;
display x_Q_b, p_b;
# Delete non-exploitable moves of P2 (update exploitable set)
for {k in phi_1_t} {
if p_b[k] < 1 then {
let phi_1_t := phi_1_t diff {k};
}
}
let t := t + 1;
let value_b := z_b.val;
#display phi_1, phi_1_t, C1_t, phi_2, phi_2_t, C2_t;
# Stopping criteria
if forall {k in phi_1_t} p_b[k] < 1 then {
break;
}
}
printf "=========================================================================\n";
printf "SOLUTION:\n";
printf "D-OPT P1:\n";
display x_P;
printf "D-OPT P2:\n";
display x_P_b;