@@ -52,14 +52,11 @@ def solve(self):
52
52
cost = tools .compute_solution (self .problem , tmp_solution )
53
53
self .history .append (cost )
54
54
if self .cur_cost > cost :
55
- # print('less')
56
55
self .solution = tmp_solution
57
56
self .cur_cost = cost
58
57
self .last_state = epoch
59
58
unimprove_counter = 0
60
59
else :
61
- # self.solution = tmp_solution
62
- # self.cur_cost = cost
63
60
no_improve_counter += 1
64
61
self .update_penalty ()
65
62
self .refresh_params ()
@@ -78,19 +75,13 @@ def update_penalty(self):
78
75
self .utility = np .zeros ((self .n , self .n ), dtype = np .float32 )
79
76
for i in range (self .n ):
80
77
for j in range (self .n ):
81
- # dist = self.dist[self.solution[i]][self.solution[j]]
82
78
dist = self .dist [i ][self .solution [i ]]
83
79
flow = self .flow [i ][j ]
84
80
c = dist * flow
85
- # self.utility[self.solution[i]][self.solution[j]] = \
86
- # c / (1 + self.penalty[self.solution[i]][self.solution[j]])
87
81
self .utility [i ][self .solution [i ]] = \
88
82
c / (1 + self .penalty [i ][self .solution [i ]])
89
83
maximized = self .utility .max ()
90
84
for i in range (self .n ):
91
- # for j in range(self.n):
92
- # if self.utility[self.solution[i]][self.solution[j]] == maximized:
93
- # self.penalty[self.solution[i]][self.solution[j]] += 1
94
85
if self .utility [i ][self .solution [i ]] == maximized :
95
86
self .penalty [i ][self .solution [i ]] += 1
96
87
@@ -101,13 +92,9 @@ def augmented_cost(problem, solution, params):
101
92
mu = params ['mu' ]
102
93
n = params ['n' ]
103
94
total_penalty = 0
104
- # for i in range(n):
105
- # for j in range(n):
106
- # total_penalty += penalty[solution[i]][solution[j]]
107
95
for i in range (n ):
108
96
total_penalty += penalty [i ][solution [i ]]
109
97
_lambda = cost / n
110
- # print( mu * _lambda )
111
98
return cost + mu * _lambda * total_penalty
112
99
113
100
@@ -139,5 +126,4 @@ def get_history(self):
139
126
plt .grid ()
140
127
plt .legend ()
141
128
plt .title (self .name )
142
- # plt.show()
143
129
return self .history
0 commit comments