Skip to content

Commit 8db3c34

Browse files
authored
Testing a simpler version of plant_location.py
1 parent 2aaff9f commit 8db3c34

File tree

1 file changed

+1
-26
lines changed

1 file changed

+1
-26
lines changed

examples/plant_location.py

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
mpl.use('Agg')
1919
del mpl
2020

21-
import matplotlib.pyplot as plt
2221
from math import sqrt, log
2322
from itertools import product
2423
from mip import Model, xsum, minimize, OptimizationStatus
@@ -42,20 +41,6 @@
4241
# demands
4342
d = {1: 302, 2: 273, 3: 275, 4: 266, 5: 287, 6: 296, 7: 297, 8: 310, 9: 302, 10: 309}
4443

45-
# plotting possible plant locations
46-
for i, p in pf.items():
47-
plt.scatter((p[0]), (p[1]), marker="^", color="purple", s=50)
48-
plt.text((p[0]), (p[1]), "$f_%d$" % i)
49-
50-
# plotting location of clients
51-
for i, p in pc.items():
52-
plt.scatter((p[0]), (p[1]), marker="o", color="black", s=15)
53-
plt.text((p[0]), (p[1]), "$c_{%d}$" % i)
54-
55-
plt.text((20), (78), "Region 1")
56-
plt.text((70), (78), "Region 2")
57-
plt.plot((50, 50), (0, 80))
58-
5944
dist = {(f, c): round(sqrt((pf[f][0] - pc[c][0]) ** 2 + (pf[f][1] - pc[c][1]) ** 2), 1)
6045
for (f, c) in product(F, C) }
6146

@@ -102,21 +87,11 @@
10287

10388
m.optimize()
10489

105-
plt.savefig("location.pdf")
106-
10790
if m.num_solutions:
10891
print("Solution with cost {} found.".format(m.objective_value))
10992
print("Facilities capacities: {} ".format([z[f].x for f in F]))
11093
print("Facilities cost: {}".format([y[f].x for f in F]))
111-
112-
# plotting allocations
113-
for (i, j) in [(i, j) for (i, j) in product(F, C) if x[(i, j)].x >= 1e-6]:
114-
plt.plot(
115-
(pf[i][0], pc[j][0]), (pf[i][1], pc[j][1]), linestyle="--", color="darkgray"
116-
)
117-
118-
plt.savefig("location-sol.pdf")
119-
94+
12095
# sanity checks
12196
opt = 99733.94905406
12297
if m.status == OptimizationStatus.OPTIMAL:

0 commit comments

Comments
 (0)