MCPcopy Create free account
hub / github.com/DEAP/deap / assess

Method assess

examples/ga/sortingnetwork.py:66–80  ·  view source on GitHub ↗

Try to sort the **cases** using the network, return the number of misses. If **cases** is None, test all possible cases according to the network dimensionality.

(self, cases=None)

Source from the content-addressed store, hash-verified

64 values[wire1], values[wire2] = values[wire2], values[wire1]
65
66 def assess(self, cases=None):
67 """Try to sort the **cases** using the network, return the number of
68 misses. If **cases** is None, test all possible cases according to
69 the network dimensionality.
70 """
71 if cases is None:
72 cases = product((0, 1), repeat=self.dimension)
73
74 misses = 0
75 ordered = [[0]*(self.dimension-i) + [1]*i for i in range(self.dimension+1)]
76 for sequence in cases:
77 sequence = list(sequence)
78 self.sort(sequence)
79 misses += (sequence != ordered[sum(sequence)])
80 return misses
81
82 def draw(self):
83 """Return an ASCII representation of the network."""

Callers 3

evalNetworkFunction · 0.95
mainFunction · 0.95
evalEvoSNFunction · 0.95

Calls 2

sortMethod · 0.95
productFunction · 0.85

Tested by

no test coverage detected