Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
3dcfdc10
Commit
3dcfdc10
authored
May 07, 2015
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
evaluate only the best performing ants of current generation
parent
e1c6a38e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
11 deletions
+22
-11
dream/plugins/ACO.py
dream/plugins/ACO.py
+22
-11
No files found.
dream/plugins/ACO.py
View file @
3dcfdc10
...
...
@@ -66,6 +66,7 @@ class ACO(plugin.ExecutionPlugin):
# generation can have more than 1 ant)
seedPlus
=
0
for
i
in
range
(
int
(
data
[
"general"
][
"numberOfGenerations"
])):
antsInCurrentGeneration
=
[]
scenario_list
=
[]
# for the distributor
# number of ants created per generation
for
j
in
range
(
int
(
data
[
"general"
][
"numberOfAntsPerGenerations"
])):
...
...
@@ -138,24 +139,20 @@ class ACO(plugin.ExecutionPlugin):
ant
[
'score'
]
=
self
.
_calculateAntScore
(
ant
)
ants
.
extend
(
scenario_list
)
antsInCurrentGeneration
.
extend
(
scenario_list
)
# remove ants that outputs the same schedules
#
in this generation
remove ants that outputs the same schedules
# XXX we in fact remove ants that produce the same output json
ants_without_duplicates
=
dict
()
for
ant
in
ants
:
uniqueAntsInThisGeneration
=
dict
()
for
ant
in
ants
InCurrentGeneration
:
ant_result
,
=
copy
(
ant
[
'result'
][
'result_list'
])
ant_result
[
'general'
].
pop
(
'totalExecutionTime'
,
None
)
ant_result
=
json
.
dumps
(
ant_result
,
sort_keys
=
True
)
ants_without_duplicates
[
ant_result
]
=
ant
# The ants in this generation are ranked based on their scores and the
# best (max_results) are selected
ants
=
sorted
(
ants_without_duplicates
.
values
(),
key
=
operator
.
itemgetter
(
'score'
))[:
max_results
]
uniqueAntsInThisGeneration
[
ant_result
]
=
ant
# The ants in this generation are ranked based on their scores and the
# best (numberOfAntsForNextGeneration) are selected to carry their pheromones to next generation
antsForNextGeneration
=
sorted
(
ants_without_duplicates
.
values
(),
antsForNextGeneration
=
sorted
(
uniqueAntsInThisGeneration
.
values
(),
key
=
operator
.
itemgetter
(
'score'
))[:
numberOfAntsForNextGeneration
]
for
l
in
antsForNextGeneration
:
...
...
@@ -168,6 +165,20 @@ class ACO(plugin.ExecutionPlugin):
# selected by the next ants.
collated
[
m
].
append
(
l
[
m
])
# from all the ants in the experiment remove ants that outputs the same schedules
# XXX we in fact remove ants that produce the same output json
uniqueAnts
=
dict
()
for
ant
in
ants
:
ant_result
,
=
copy
(
ant
[
'result'
][
'result_list'
])
ant_result
[
'general'
].
pop
(
'totalExecutionTime'
,
None
)
ant_result
=
json
.
dumps
(
ant_result
,
sort_keys
=
True
)
uniqueAnts
[
ant_result
]
=
ant
# The ants in this generation are ranked based on their scores and the
# best (max_results) are selected
ants
=
sorted
(
uniqueAnts
.
values
(),
key
=
operator
.
itemgetter
(
'score'
))[:
max_results
]
data
[
'result'
][
'result_list'
]
=
result_list
=
[]
for
ant
in
ants
:
result
,
=
ant
[
'result'
][
'result_list'
]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment