7: We create an array with bool values (apparently, this is not explained in the paper). We assign the current value (value = index) "true"
18: At this point, we could have an array, where all values could be "true" and reached the condition of k = len(parents) 19-22: This would create an infinite loop
Am I missing something?
Paper: Multi-parent extension of partially mapped crossover for combinatorial optimization problems. Chuan-Kang Tinga, , , Chien-Hao Sub, , Chung-Nan Leeb,
http://www.sciencedirect.com/science/article/pii/S0957417409006800
//EDIT: HERE GOES MY CODE PYTHON-2.6
def MappingListDetermination(parents):
mapping_list = []
startparent = parents[random.sample(xrange(0, len(parents)), 1)[0]]
ptr = random.sample(xrange(0, len(startparent)), 1)[0]
temp_value = startparent[ptr]
boolean = [False] * listSize
for j in xrange(0,len(startparent)):
mapping_list.append(temp_value)
boolean[temp_value-1] = True
arr = random.sample(xrange(0, n), n)
if arr[0] == parents.index(startparent):
arr[0] = arr[random.sample(xrange(1, len(arr)), 1)[0]]
endparent = parents[arr[0]]
ptr = endparent.index(temp_value)
k = 0
while((boolean[startparent[ptr]-1] is True) and (k is not len(parents)-1)):
k = k + 1
startparent = parents[arr[k]]
if((boolean[startparent[ptr]-1] is True) and (k is len(parents)-1)):
while(boolean[startparent[ptr]-1] is True ):
startparent = parents[random.sample(xrange(0, len(parents)), 1)[0]]
ptr = startparent[random.sample(xrange(0, len(startparent)), 1)[0]]-1
temp_value = startparent[ptr]ere