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
bbe55023
Commit
bbe55023
authored
Jun 05, 2015
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup and comments
parent
ce655c47
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
4 deletions
+8
-4
dream/plugins/CapacityStations/CapacityStationsEnumeration.py
...m/plugins/CapacityStations/CapacityStationsEnumeration.py
+5
-3
dream/plugins/Enumeration.py
dream/plugins/Enumeration.py
+3
-1
No files found.
dream/plugins/CapacityStations/CapacityStationsEnumeration.py
View file @
bbe55023
...
...
@@ -54,24 +54,26 @@ class CapacityStationsEnumeration(Enumeration):
scenarioList
.
append
({
'key'
:
str
(
threshold
),
'threshold'
:
threshold
})
return
scenarioList
# creates the
ant scenario based on what ACO randomly selecte
d
# creates the
scenario. Here just set the dueDateThreshol
d
def
createScenarioData
(
self
,
data
,
scenario
):
scenarioData
=
deepcopy
(
data
)
scenarioData
[
'graph'
][
'node'
][
'CSC'
][
'dueDateThreshold'
]
=
scenario
[
'threshold'
]
return
scenarioData
# checks if the algorithm should terminate.
# in this case terminate if the total dela
t
is increased
# in this case terminate if the total dela
y
is increased
def
checkIfShouldTerminate
(
self
,
data
,
scenarioList
):
# in the first scenario no need to terminate
if
len
(
scenarioList
)
<
2
:
return
False
# find the last scenario that is scored
index
=
0
for
i
in
range
(
len
(
scenarioList
)):
if
scenarioList
[
i
].
get
(
'score'
,
None
)
==
None
:
index
=
i
-
1
break
# if the delay of the last scenario is bigger than the previous return true
if
index
:
if
scenarioList
[
index
][
'score'
]
>
scenarioList
[
index
-
1
][
'score'
]:
scenarioList
=
scenarioList
[:
index
+
1
]
return
True
return
False
dream/plugins/Enumeration.py
View file @
bbe55023
...
...
@@ -26,7 +26,7 @@ class Enumeration(plugin.ExecutionPlugin):
def
createScenarioList
(
self
,
data
):
raise
NotImplementedError
(
"Subclass must define 'createScenarioList' method"
)
# create
s the ant scenario based on what ACO randomly selected
# create
the scenario
def
createScenarioData
(
self
,
data
,
scenario
):
raise
NotImplementedError
(
"Subclass must define 'createScenarioData' method"
)
...
...
@@ -48,11 +48,13 @@ class Enumeration(plugin.ExecutionPlugin):
assert
numberOfSolutions
>=
1
scenarioList
=
self
.
createScenarioList
(
data
)
# run the scenario. Only synchronous for now
i
=
0
for
scenario
in
scenarioList
:
scenario
[
'input'
]
=
self
.
createScenarioData
(
data
,
scenario
)
scenario
[
'result'
]
=
self
.
runOneScenario
(
scenario
[
'input'
])[
'result'
]
scenario
[
'score'
]
=
self
.
calculateScenarioScore
(
scenario
)
# it we should terminate remove the scenarios that are not scored yet
if
self
.
checkIfShouldTerminate
(
data
,
scenarioList
):
scenarioList
=
scenarioList
[:
i
+
1
]
break
...
...
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