Created
December 6, 2013 00:27
-
-
Save cmd-ntrf/7816665 to your computer and use it in GitHub Desktop.
Example of evaluation function, see
https://groups.google.com/d/topic/deap-users/iyEgrd4OHKc/discussion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import networkx | |
from metric import measure_A, measure_B, measure_C, measure_D | |
def evaluate(individual): | |
matrix = numpy.zeros((n,n)) | |
index = 0 | |
for i in range(n-1): | |
for j in range(i+1, n): | |
matrix[i,j] = matrix[j,i] = individual[index] | |
index += 1 | |
graph = networkx.from_numpy_matrix(matrix) | |
return measure_A(graph), measure_B(graph), measure_C(graph), measure_D(graph) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment