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
b5de2456
Commit
b5de2456
authored
Jun 05, 2015
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enumeration to stop if total delay gets increased
parent
4d53e46b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
6 deletions
+19
-6
dream/plugins/CapacityStations/CapacityStationsEnumeration.py
...m/plugins/CapacityStations/CapacityStationsEnumeration.py
+14
-3
dream/plugins/Enumeration.py
dream/plugins/Enumeration.py
+5
-3
No files found.
dream/plugins/CapacityStations/CapacityStationsEnumeration.py
View file @
b5de2456
...
...
@@ -37,7 +37,7 @@ class CapacityStationsEnumeration(Enumeration):
return
totalDelay
# creates the collated scenarios, i.e. the list
# of options collated into a
dictionary
for ease of referencing in ManPy
# of options collated into a
list
for ease of referencing in ManPy
def
createScenarioList
(
self
,
data
):
scenarioList
=
[]
step
=
data
[
'general'
].
get
(
'thresholdStep'
,
7
)
...
...
@@ -60,7 +60,18 @@ class CapacityStationsEnumeration(Enumeration):
scenarioData
[
'graph'
][
'node'
][
'CSC'
][
'dueDateThreshold'
]
=
scenario
[
'threshold'
]
return
scenarioData
# checks if the algorithm should terminate.
Default is set to False so that the algorithm
#
terminates only when all scenarios are consider
ed
# checks if the algorithm should terminate.
#
in this case terminate if the total delat is increas
ed
def
checkIfShouldTerminate
(
self
,
data
,
scenarioList
):
if
len
(
scenarioList
)
<
2
:
return
False
index
=
0
for
i
in
range
(
len
(
scenarioList
)):
if
scenarioList
[
i
].
get
(
'score'
,
None
)
==
None
:
index
=
i
-
1
break
if
index
:
if
scenarioList
[
index
][
'score'
]
>
scenarioList
[
index
-
1
][
'score'
]:
scenarioList
=
scenarioList
[:
index
+
1
]
return
True
return
False
dream/plugins/Enumeration.py
View file @
b5de2456
...
...
@@ -35,7 +35,6 @@ class Enumeration(plugin.ExecutionPlugin):
def
checkIfShouldTerminate
(
self
,
data
,
scenarioList
):
return
False
def
run
(
self
,
data
):
# distributor_url = data['general'].get('distributorURL',None)
# distributor = None
...
...
@@ -45,18 +44,21 @@ class Enumeration(plugin.ExecutionPlugin):
start
=
time
.
time
()
# start counting execution time
numberOfSolutions
=
int
(
data
[
'general'
].
get
(
'numberOfSolutions'
,
3
))
numberOfSolutions
=
int
(
data
[
'general'
].
get
(
'numberOfSolutions'
,
15
))
assert
numberOfSolutions
>=
1
scenarioList
=
self
.
createScenarioList
(
data
)
i
=
0
for
scenario
in
scenarioList
:
scenario
[
'input'
]
=
self
.
createScenarioData
(
data
,
scenario
)
scenario
[
'result'
]
=
self
.
runOneScenario
(
scenario
[
'input'
])[
'result'
]
scenario
[
'score'
]
=
self
.
calculateScenarioScore
(
scenario
)
if
self
.
checkIfShouldTerminate
(
data
,
scenarioList
):
scenarioList
=
scenarioList
[:
i
+
1
]
break
i
+=
1
# ran
d
the scenarios based on their score and take only the numberOfSolutions best
# ran
k
the scenarios based on their score and take only the numberOfSolutions best
scenariosToReturn
=
sorted
(
scenarioList
,
key
=
operator
.
itemgetter
(
'score'
))[:
numberOfSolutions
]
# return the number of scenarios that need to be returned
...
...
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