Commit 4e38a114 authored by Jérome Perrin's avatar Jérome Perrin

ACO: use two different variables (patch under discussion)

parent e612e1d8
...@@ -74,6 +74,8 @@ class ACO(plugin.ExecutionPlugin): ...@@ -74,6 +74,8 @@ class ACO(plugin.ExecutionPlugin):
max_results = int(data['general'].get('numberOfSolutions',0)) max_results = int(data['general'].get('numberOfSolutions',0))
assert max_results >= 1 assert max_results >= 1
numberOfAntsForNextGeneration = int(data['general'].get('numberOfAntsForNextGeneration', max_results))
ants = [] #list of ants for keeping track of their performance ants = [] #list of ants for keeping track of their performance
# Number of times new ants are to be created, i.e. number of generations (a # Number of times new ants are to be created, i.e. number of generations (a
...@@ -163,9 +165,11 @@ class ACO(plugin.ExecutionPlugin): ...@@ -163,9 +165,11 @@ class ACO(plugin.ExecutionPlugin):
ants_without_duplicates[ant_result] = ant ants_without_duplicates[ant_result] = ant
# The ants in this generation are ranked based on their scores and the # The ants in this generation are ranked based on their scores and the
# best (max_results) are selected # best (numberOfAntsForNextGeneration) are added again to the list to increase
# the probability of their characteristics since they are more likely to
# be selected again
ants = sorted(ants_without_duplicates.values(), ants = sorted(ants_without_duplicates.values(),
key=operator.itemgetter('score'))[:max_results] key=operator.itemgetter('score'))[:numberOfAntsForNextGeneration]
for l in ants: for l in ants:
# update the options list to ensure that good performing queue-rule # update the options list to ensure that good performing queue-rule
...@@ -178,7 +182,7 @@ class ACO(plugin.ExecutionPlugin): ...@@ -178,7 +182,7 @@ class ACO(plugin.ExecutionPlugin):
collated[m].append(l[m]) collated[m].append(l[m])
data['result']['result_list'] = result_list = [] data['result']['result_list'] = result_list = []
for ant in ants: for ant in ants[:max_results]:
result, = ant['result']['result_list'] result, = ant['result']['result_list']
result['score'] = ant['score'] result['score'] = ant['score']
result['key'] = ant['key'] result['key'] = ant['key']
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment