Example #1
0
def evalTSPAdjacentEdges(individual):
    #if individual is not a valid adjacent representation then it is a path representation
    #we change once that individual to path representation
    if not checkIfValidAdjacent(individual):
        raise ValueError("Individual is not valid according to adjacent representation.\n", individual)
    evaluation = evalTSP(fromAdjacentToPath(individual))
    return evaluation
Example #2
0
def evalTSPAdjacentEdges(individual):
    #if individual is not a valid adjacent representation then it is a path representation
    #we change once that individual to path representation
    if not checkIfValidAdjacent(individual):
        raise ValueError(
            "Individual is not valid according to adjacent representation.\n",
            individual)
    evaluation = evalTSP(fromAdjacentToPath(individual))
    return evaluation
Example #3
0
def test_loopConversion():
    'Testing if we get the same result after the two translations:'
    orig = creators.path_creator()
    adj_individual = fromPathToAdjacent(orig)
    new = fromAdjacentToPath(adj_individual)

    index = orig.index(0)
    o = orig[index:] + orig[0:index]
    assert o == list(new)
Example #4
0
 def wrapped(individual, indpb):
     # print 'mut from:', individual
     if not checkIfValidAdjacent(individual):
         raise ValueError('Invalid individual. Does not comply with adjacent repr.')
     # print 'individual', type(individual), individual
     indi = fromAdjacentToPath(individual)
     # print 'indi', type(indi), indi
     result = function(indi, indpb)
     # print 'result', type(result), result
     individual[:] = fromPathToAdjacent(result[0])
     # print 'individual', type(individual), individual
     # print '\n'*5
     return individual
Example #5
0
 def wrapped(individual, indpb):
     # print 'mut from:', individual
     if not checkIfValidAdjacent(individual):
         raise ValueError(
             'Invalid individual. Does not comply with adjacent repr.')
     # print 'individual', type(individual), individual
     indi = fromAdjacentToPath(individual)
     # print 'indi', type(indi), indi
     result = function(indi, indpb)
     # print 'result', type(result), result
     individual[:] = fromPathToAdjacent(result[0])
     # print 'individual', type(individual), individual
     # print '\n'*5
     return individual
Example #6
0
def test_fromAdjacentToPath():
    adj_individual = creators.adj_creator()
    path_individual = fromAdjacentToPath(adj_individual)
    print path_individual