MCPcopy Create free account
hub / github.com/Valdecy/pyCombinatorial / decoder

Function decoder

pyCombinatorial/algorithm/brkga.py:32–40  ·  view source on GitHub ↗
(individual, distance_matrix, cost_only = False)

Source from the content-addressed store, hash-verified

30
31# Function: Decoder
32def decoder(individual, distance_matrix, cost_only = False):
33 dec = sorted(range(0, len(individual)), key = individual.__getitem__)
34 dec = [item + 1 for item in dec]
35 route = dec + [dec[0]]
36 distance = distance_calc(distance_matrix, [route, 1])
37 if (cost_only == True):
38 return distance
39 else:
40 return route, distance
41
42############################################################################
43

Callers 2

elite_lsFunction · 0.70

Calls 1

distance_calcFunction · 0.70

Tested by

no test coverage detected