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
c983514e
Commit
c983514e
authored
Nov 19, 2015
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
if we evaluate all the ants of the generation stochastically no deterministic run is needed
parent
8b73acdf
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
43 additions
and
26 deletions
+43
-26
dream/plugins/Batches/BatchesStochasticACO.py
dream/plugins/Batches/BatchesStochasticACO.py
+43
-26
No files found.
dream/plugins/Batches/BatchesStochasticACO.py
View file @
c983514e
...
@@ -166,6 +166,25 @@ class BatchesStochasticACO(BatchesACO):
...
@@ -166,6 +166,25 @@ class BatchesStochasticACO(BatchesACO):
ant
[
'input'
]
=
ant_data
ant
[
'input'
]
=
ant_data
scenario_list
.
append
(
ant
)
scenario_list
.
append
(
ant
)
ants
.
extend
(
scenario_list
)
antsInCurrentGeneration
.
extend
(
scenario_list
)
# if all the ants of the generation will be evaluated stochastically
# do not do deterministic runs
if
numberOfAntsForStochasticEvaluationInGeneration
==
int
(
data
[
"general"
][
"numberOfAntsPerGenerations"
]):
uniqueAntsInThisGeneration
=
dict
()
for
ant
in
antsInCurrentGeneration
:
ant
[
'result'
]
=
dict
()
ant
[
'result'
][
'result_list'
]
=
[
ant
[
'key'
]]
ant
[
'score'
]
=
0
ant_result
,
=
copy
(
ant
[
'result'
][
'result_list'
])
ant_result
=
json
.
dumps
(
ant_result
,
sort_keys
=
True
)
uniqueAntsInThisGeneration
[
ant_result
]
=
ant
antsForStochasticEvaluationInGeneration
=
sorted
(
uniqueAntsInThisGeneration
.
values
(),
key
=
operator
.
itemgetter
(
'score'
))[:
numberOfAntsForStochasticEvaluationInGeneration
]
else
:
# run the deterministic ants
# run the deterministic ants
for
ant
in
scenario_list
:
for
ant
in
scenario_list
:
self
.
outputSheet
.
write
(
self
.
rowIndex
,
1
,
'running deterministic'
)
self
.
outputSheet
.
write
(
self
.
rowIndex
,
1
,
'running deterministic'
)
...
@@ -178,9 +197,6 @@ class BatchesStochasticACO(BatchesACO):
...
@@ -178,9 +197,6 @@ class BatchesStochasticACO(BatchesACO):
self
.
outputSheet
.
write
(
self
.
rowIndex
,
3
,
-
ant
[
'score'
])
self
.
outputSheet
.
write
(
self
.
rowIndex
,
3
,
-
ant
[
'score'
])
self
.
rowIndex
+=
1
self
.
rowIndex
+=
1
ants
.
extend
(
scenario_list
)
antsInCurrentGeneration
.
extend
(
scenario_list
)
# in this generation 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
# XXX we in fact remove ants that produce the same output json
# XXX in the stochastic case maybe there is not benefit to remove ants.
# XXX in the stochastic case maybe there is not benefit to remove ants.
...
@@ -197,6 +213,7 @@ class BatchesStochasticACO(BatchesACO):
...
@@ -197,6 +213,7 @@ class BatchesStochasticACO(BatchesACO):
antsForStochasticEvaluationInGeneration
=
sorted
(
uniqueAntsInThisGeneration
.
values
(),
antsForStochasticEvaluationInGeneration
=
sorted
(
uniqueAntsInThisGeneration
.
values
(),
key
=
operator
.
itemgetter
(
'score'
))[:
numberOfAntsForStochasticEvaluationInGeneration
]
key
=
operator
.
itemgetter
(
'score'
))[:
numberOfAntsForStochasticEvaluationInGeneration
]
for
ant
in
antsForStochasticEvaluationInGeneration
:
for
ant
in
antsForStochasticEvaluationInGeneration
:
ant
[
'input'
]
=
self
.
createStochasticData
(
ant
[
'input'
])
ant
[
'input'
]
=
self
.
createStochasticData
(
ant
[
'input'
])
ant
[
'input'
][
'general'
][
'numberOfReplications'
]
=
numberOfReplicationsInGeneration
ant
[
'input'
][
'general'
][
'numberOfReplications'
]
=
numberOfReplicationsInGeneration
...
...
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