Skip to content

Commit 9524ede

Browse files
committed
More hooman explanations.
1 parent 16a65d2 commit 9524ede

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

python/stochastic/guided_local_search.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,13 @@ def local_search(current, cities, penalties, max_no_improv, l):
111111
if count >= max_no_improv:
112112
return current
113113

114-
def calculate_feature_utilities(penal, cities, permutation):
114+
def calculate_feature_utilities(penalties, cities, permutation):
115+
"""
116+
For every edge in the path, compute its utility, defined as the cost of the
117+
edge / (1 + existing penalty for edge).
118+
119+
Note: The utility is defined per origin node of every edge.
120+
"""
115121
limit = len(permutation)
116122
limit_list = range(limit)
117123
utilities = [0 for i in limit_list]
@@ -127,11 +133,15 @@ def calculate_feature_utilities(penal, cities, permutation):
127133
if c2 < c1:
128134
c1, c2 = c2, c1
129135

130-
utilities[i] = euc_2d(cities[c1], cities[c2]) / (1 + penal[c1][c2])
136+
utilities[i] = euc_2d(cities[c1], cities[c2]) / (1 + penalties[c1][c2])
131137

132138
return utilities
133139

134140
def update_penalties(penalties, cities, permutation, utilities):
141+
"""
142+
Penalize an edge if the utility for its origin is the greatest utility value
143+
in this round.
144+
"""
135145
max_util = max(utilities)
136146
limit = len(permutation)
137147

0 commit comments

Comments
 (0)