-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolution_plotter.py
More file actions
70 lines (60 loc) · 1.94 KB
/
solution_plotter.py
File metadata and controls
70 lines (60 loc) · 1.94 KB
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
from printer import Plotter
from pathlib import Path
home_path = Path("/home/da_orobix/PycharmProjects/BalancedBoxPython")
actual_sol_path = (
home_path
/ "BOMIP/Part II- Mixed Integer Programs/nondominated frontiers/Before post-processing/"
)
my_sol_path = home_path / "my_solutions"
my_images = home_path / "images"
problem_name = "First problem"
instance_name = "C160"
for solution_num in range(16, 21):
solution_num = str(solution_num)
actual_path_full = (
actual_sol_path / problem_name / instance_name / (solution_num + "out.txt")
)
my_path_full = (
my_sol_path / problem_name / instance_name / (solution_num + "dat.txt")
)
scatter_style = {
"s": 2,
}
plot_style = {"linewidth": 1}
plotter = Plotter(
resolution=800, plot_style=plot_style, scatter_style=scatter_style
)
my_solution_dict = {}
with open(my_path_full, "r") as rfile:
for line in rfile:
try:
v1, v2, conn = line.split()
v1 = float(v1)
v2 = float(v2)
conn = int(conn)
my_solution_dict[(v1, v2)] = conn
except ValueError as e:
print(e)
break
plotter.plot_solutions(
my_solution_dict,
save_path=my_images
/ ("_".join([problem_name, instance_name, solution_num + "mine.png"])),
)
their_solution_dict = {}
with open(actual_path_full, "r") as rfile:
for line in rfile:
try:
v1, v2, conn = line.split()
v1 = float(v1)
v2 = float(v2)
conn = int(conn)
their_solution_dict[(v1, v2)] = conn
except ValueError as e:
print(e)
break
plotter.plot_solutions(
their_solution_dict,
save_path=my_images
/ ("_".join([problem_name, instance_name, solution_num + "their.png"])),
)