|
| 1 | +""" |
| 2 | +Two-player Competitive Facility Location and Design (CFLD) problem. |
| 3 | +
|
| 4 | +Based on Crönert and Minner (2024). For futher details, see Section 3.2 of: |
| 5 | + [*T. Crönert, S. Minner, "Equilibrium Identification and Selection in Finite Games". 2024. Operations Research*](https://doi.org/10.1287/opre.2022.2413) |
| 6 | +
|
| 7 | +Note that the players have *nonlinear* payoffs, which SGM can handle because this is a |
| 8 | +two-player game. In other words, the polymatrix can still be computed for the sampled games. |
| 9 | +
|
| 10 | +# Notes |
| 11 | +- SCIP can be replaced with other solvers, such as Gurobi or CPLEX. |
| 12 | +""" |
| 13 | + |
| 14 | +using IPG, IPG.JuMP, SCIP |
| 15 | + |
| 16 | +# ==== Problem Parameters ==== |
| 17 | +d_max = 20 |
| 18 | +β = 0.5 |
| 19 | +B = 40 # B = B^A = B^B |
| 20 | + |
| 21 | +# ==== Problem Data ==== |
| 22 | +a = [ |
| 23 | + 3.00 7.31 14.35; |
| 24 | + 3.00 7.14 10.41; |
| 25 | + 3.00 4.43 6.25; |
| 26 | + 3.00 7.21 12.57; |
| 27 | + 3.00 4.16 11.50; |
| 28 | + 3.00 4.36 6.77; |
| 29 | + 3.00 6.63 13.63; |
| 30 | + 3.00 4.89 6.16; |
| 31 | + 3.00 6.93 12.90; |
| 32 | + 3.00 5.95 9.82; |
| 33 | + 3.00 5.22 8.19; |
| 34 | + 3.00 4.65 13.12; |
| 35 | + 3.00 5.90 13.17; |
| 36 | + 3.00 5.50 7.50; |
| 37 | + 3.00 7.74 9.30; |
| 38 | + 3.00 5.01 6.05; |
| 39 | + 3.00 5.35 10.35; |
| 40 | + 3.00 4.76 7.15; |
| 41 | + 3.00 5.65 9.19; |
| 42 | + 3.00 5.61 14.32; |
| 43 | + 3.00 8.97 12.93; |
| 44 | + 3.00 5.86 13.04; |
| 45 | + 3.00 5.98 14.29; |
| 46 | + 3.00 4.60 11.48; |
| 47 | + 3.00 4.28 9.89; |
| 48 | + 3.00 4.26 5.31; |
| 49 | + 3.00 6.01 11.17; |
| 50 | + 3.00 7.14 9.95; |
| 51 | + 3.00 5.98 9.19; |
| 52 | + 3.00 4.76 13.25; |
| 53 | + 3.00 6.11 8.19; |
| 54 | + 3.00 5.93 9.93; |
| 55 | + 3.00 5.34 13.93; |
| 56 | + 3.00 4.94 8.32; |
| 57 | + 3.00 4.37 8.58; |
| 58 | + 3.00 4.51 8.58; |
| 59 | + 3.00 5.62 8.16; |
| 60 | + 3.00 4.56 10.33; |
| 61 | + 3.00 6.56 7.92; |
| 62 | + 3.00 7.92 16.48; |
| 63 | + 3.00 6.98 12.84; |
| 64 | + 3.00 5.81 11.57; |
| 65 | + 3.00 7.40 12.45; |
| 66 | + 3.00 4.80 11.05; |
| 67 | + 3.00 6.62 8.61; |
| 68 | + 3.00 8.93 11.76; |
| 69 | + 3.00 7.38 14.59; |
| 70 | + 3.00 8.66 11.27; |
| 71 | + 3.00 5.49 8.06; |
| 72 | + 3.00 5.23 11.40 |
| 73 | +] |
| 74 | +f = [ |
| 75 | + 12.70 25.75 60.05; |
| 76 | + 13.67 33.94 45.15; |
| 77 | + 13.20 11.91 17.13; |
| 78 | + 13.03 37.58 46.85; |
| 79 | + 14.58 27.63 24.94; |
| 80 | + 10.26 9.96 32.24; |
| 81 | + 10.49 25.28 35.73; |
| 82 | + 13.07 19.89 28.53; |
| 83 | + 16.65 26.25 66.88; |
| 84 | + 14.86 34.10 54.43; |
| 85 | + 12.90 20.61 47.22; |
| 86 | + 12.50 24.02 62.47; |
| 87 | + 18.76 24.12 59.14; |
| 88 | + 19.63 28.00 42.23; |
| 89 | + 23.37 36.27 43.87; |
| 90 | + 19.28 20.00 28.22; |
| 91 | + 11.69 35.63 48.83; |
| 92 | + 11.17 29.47 22.53; |
| 93 | + 10.74 22.22 20.72; |
| 94 | + 17.06 21.77 72.05; |
| 95 | + 13.30 32.47 54.42; |
| 96 | + 10.90 20.49 46.20; |
| 97 | + 12.94 22.73 62.78; |
| 98 | + 12.30 17.13 21.80; |
| 99 | + 22.82 29.16 34.72; |
| 100 | + 20.50 13.67 25.78; |
| 101 | + 13.32 20.25 35.01; |
| 102 | + 17.04 31.14 45.76; |
| 103 | + 18.18 18.25 41.56; |
| 104 | + 13.33 26.81 28.67; |
| 105 | + 8.18 39.76 46.08; |
| 106 | + 9.30 18.06 52.03; |
| 107 | + 10.58 19.97 52.17; |
| 108 | + 15.18 18.75 32.50; |
| 109 | + 15.08 26.37 16.99; |
| 110 | + 10.03 17.78 26.01; |
| 111 | + 18.82 16.54 24.26; |
| 112 | + 14.08 22.27 32.44; |
| 113 | + 13.92 32.62 33.39; |
| 114 | + 16.08 17.31 47.45; |
| 115 | + 15.29 32.82 51.17; |
| 116 | + 18.97 34.00 26.90; |
| 117 | + 17.51 43.23 67.03; |
| 118 | + 15.12 29.63 44.91; |
| 119 | + 18.69 33.23 29.94; |
| 120 | + 16.75 36.22 65.61; |
| 121 | + 18.76 45.20 39.84; |
| 122 | + 11.16 26.68 47.90; |
| 123 | + 18.34 29.54 26.95; |
| 124 | + 18.25 23.82 50.04 |
| 125 | +] |
| 126 | +locs = [ |
| 127 | + (81.423, 63.358), |
| 128 | + (23.986, 24.907), |
| 129 | + (58.360, 94.707), |
| 130 | + (70.994, 95.909), |
| 131 | + (16.525, 18.016), |
| 132 | + (33.446, 55.179), |
| 133 | + (35.339, 61.412), |
| 134 | + (82.131, 82.424), |
| 135 | + (17.120, 30.418), |
| 136 | + (89.266, 36.745), |
| 137 | + (22.486, 28.671), |
| 138 | + (50.849, 62.173), |
| 139 | + (66.774, 83.822), |
| 140 | + (34.897, 22.596), |
| 141 | + (63.452, 8.297), |
| 142 | + (3.999, 8.276), |
| 143 | + (25.426, 49.606), |
| 144 | + (85.620, 81.129), |
| 145 | + (60.199, 9.892), |
| 146 | + (88.603, 50.964), |
| 147 | + (19.818, 39.411), |
| 148 | + (89.291, 99.867), |
| 149 | + (91.544, 33.614), |
| 150 | + (35.724, 96.915), |
| 151 | + (40.176, 88.541), |
| 152 | + (43.333, 70.414), |
| 153 | + (37.977, 94.200), |
| 154 | + (80.580, 29.840), |
| 155 | + (43.137, 70.615), |
| 156 | + (67.976, 54.672), |
| 157 | + (12.704, 76.245), |
| 158 | + (38.914, 92.317), |
| 159 | + (60.930, 43.457), |
| 160 | + (35.754, 32.293), |
| 161 | + (98.959, 20.722), |
| 162 | + (39.608, 48.879), |
| 163 | + (16.806, 26.254), |
| 164 | + (57.243, 29.399), |
| 165 | + (93.555, 42.752), |
| 166 | + (13.555, 30.350), |
| 167 | + (46.719, 7.948), |
| 168 | + (23.052, 28.537), |
| 169 | + (56.692, 80.636), |
| 170 | + (38.770, 59.428), |
| 171 | + (27.251, 86.887), |
| 172 | + (2.071, 59.893), |
| 173 | + (68.009, 76.120), |
| 174 | + (41.762, 57.527), |
| 175 | + (9.797, 41.724), |
| 176 | + (95.959, 73.750) |
| 177 | +] |
| 178 | +w = [3, 9, 6, 4, 4, 3, 4, 9, 2, 6, 10, 6, 10, 8, 2, 7, 2, 3, 7, 5, 4, 4, 2, 2, 6, 8, 3, 7, 8, 4, 2, 6, 2, 9, 3, 4, 6, 8, 7, 5, 5, 2, 4, 1, 4, 3, 7, 6, 8, 4] |
| 179 | + |
| 180 | +I = J = 1:size(a,1) |
| 181 | +R = 1:size(a,2) |
| 182 | + |
| 183 | +# It is not clear how the distance matrix is computed. In the source, they say that "The |
| 184 | +# matrix d_ij is the Euclidean distance matrix", but that does not give me the info on the |
| 185 | +# location of the facilities, as the .txt only has the location of the customers. |
| 186 | + |
| 187 | +# I assume that the facilities' locations are the same as the customers |
| 188 | +euclidean_distance(x,y) = sqrt((x[1]-y[1])^2 + (x[2]-y[2])^2) |
| 189 | +d = [euclidean_distance(locs[i], locs[j]) for i in I, j in J] |
| 190 | + |
| 191 | +# utility computation |
| 192 | +CM_utility(i,j,r) = (d[i,j] <= d_max) ? a[i,r]/((d[i,j]+1)^β) : 0 |
| 193 | +u = [CM_utility(i,j,r) for i in I, j in J, r in R] |
| 194 | + |
| 195 | + |
| 196 | +# ==== Player Definition ==== |
| 197 | +player_A = Player(; name="Player A") |
| 198 | +@variable(player_A.X, x1[I,R], Bin) |
| 199 | +@constraint(player_A.X, sum(f[i,r] .* x1[i,r] for i in I for r in R) <= B) |
| 200 | +@constraint(player_A.X, [i in I], sum(x1[i,r] for r in R) <= 1) |
| 201 | + |
| 202 | +player_B = Player(; name="Player B") |
| 203 | +@variable(player_B.X, x2[I,R], Bin) |
| 204 | +@constraint(player_B.X, sum(f[i,r] .* x2[i,r] for i in I for r in R) <= B) |
| 205 | +@constraint(player_B.X, [i in I], sum(x2[i,r] for r in R) <= 1) |
| 206 | + |
| 207 | +const ε = 1e-3 # small value to prevent division by zero |
| 208 | +function cfld_payoff(x_self, x_other) |
| 209 | + self_costs = [sum(u[i,j,r] * x_self[i,r] for i in I for r in R) for j in J] |
| 210 | + others_costs = [sum(u[i,j,r] * x_other[i,r] for i in I for r in R) for j in J] |
| 211 | + return sum( |
| 212 | + w[j] * self_costs[j] / (self_costs[j] + others_costs[j] + ε) |
| 213 | + for j in J |
| 214 | + ) |
| 215 | +end |
| 216 | + |
| 217 | +set_payoff!(player_A, cfld_payoff(x1, x2)) |
| 218 | +set_payoff!(player_B, cfld_payoff(x2, x1)) |
| 219 | + |
| 220 | +# ==== SGM ==== |
| 221 | +IPG.initialize_strategies = IPG.initialize_strategies_player_alone |
| 222 | + |
| 223 | +Σ, payoff_improvements = SGM([player_A, player_B], SCIP.Optimizer, max_iter=5, verbose=true) |
0 commit comments