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

Method assess

doc/code/tutorials/part_4/sortingnetwork.py:72–86  ·  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

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

Callers 1

evalEvoSNFunction · 0.95

Calls 2

sortMethod · 0.95
productFunction · 0.85

Tested by

no test coverage detected