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
d0ff13d1
Commit
d0ff13d1
authored
May 08, 2014
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sorting method of simple operator simplified. Now picks the stations that waits the most
parent
8cb7b68e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
9 deletions
+27
-9
dream/simulation/Operator.py
dream/simulation/Operator.py
+27
-9
No files found.
dream/simulation/Operator.py
View file @
d0ff13d1
...
@@ -97,16 +97,29 @@ class Operator(ObjectResource):
...
@@ -97,16 +97,29 @@ class Operator(ObjectResource):
# =======================================================================
# =======================================================================
# sorts the candidateEntities of the Operator according to the scheduling rule
# sorts the candidateEntities of the Operator according to the scheduling rule
# TODO: find a way to sort machines or candidate entities for machines,
# now picks the machine that waits the most
# =======================================================================
# =======================================================================
def
sortCandidateEntities
(
self
):
def
sortCandidateEntities
(
self
):
# TODO: have to consider what happens in case of a critical order
candidateMachines
=
self
.
candidateStations
#if we have sorting according to multiple criteria we have to call the sorter many times
# for the candidateMachines
if
self
.
schedulingRule
==
"MC"
:
if
candidateMachines
:
for
criterion
in
reversed
(
self
.
multipleCriterionList
):
# choose the one that waits the most time and give it the chance to grasp the resource
self
.
activeCandidateQSorter
(
criterion
=
criterion
)
for
machine
in
candidateMachines
:
#else we just use the default scheduling rule
if
machine
.
broker
.
waitForOperator
:
else
:
machine
.
timeWaiting
=
now
()
-
machine
.
broker
.
timeWaitForOperatorStarted
self
.
activeCandidateQSorter
(
self
.
schedulingRule
)
else
:
machine
.
timeWaiting
=
now
()
-
machine
.
timeLastEntityLeft
self
.
candidateStations
.
sort
(
key
=
lambda
x
:
x
.
timeWaiting
,
reverse
=
True
)
# # TODO: have to consider what happens in case of a critical order
# #if we have sorting according to multiple criteria we have to call the sorter many times
# if self.schedulingRule=="MC":
# for criterion in reversed(self.multipleCriterionList):
# self.activeCandidateQSorter(criterion=criterion)
# #else we just use the default scheduling rule
# else:
# print self.schedulingRule
# self.activeCandidateQSorter(self.schedulingRule)
# =======================================================================
# =======================================================================
...
@@ -114,12 +127,17 @@ class Operator(ObjectResource):
...
@@ -114,12 +127,17 @@ class Operator(ObjectResource):
# =======================================================================
# =======================================================================
def
activeCandidateQSorter
(
self
,
criterion
=
None
):
def
activeCandidateQSorter
(
self
,
criterion
=
None
):
# TODO: entityToGet is not updated for all stations, consider using it for all stations or withdraw the idea
# TODO: entityToGet is not updated for all stations, consider using it for all stations or withdraw the idea
# TODO: sorting candidateStations is strange. some of them are waiting to get an entity, others are waiting for operator while holding an entity
activeObjectQ
=
self
.
candidateStations
activeObjectQ
=
self
.
candidateStations
if
criterion
==
None
:
if
criterion
==
None
:
criterion
=
self
.
schedulingRule
criterion
=
self
.
schedulingRule
#if the schedulingRule is first in first out
#if the schedulingRule is first in first out
if
criterion
==
"FIFO"
:
if
criterion
==
"FIFO"
:
pass
# FIFO sorting has no meaning when sorting candidateEntities
self
.
activeCandidateQSorter
(
'WT'
)
# added for testing
# print 'there is no point of using FIFO scheduling rule for operators candidateEntities,\
# WT scheduling rule used instead'
#if the schedulingRule is based on a pre-defined priority
#if the schedulingRule is based on a pre-defined priority
elif
criterion
==
"Priority"
:
elif
criterion
==
"Priority"
:
activeObjectQ
.
sort
(
key
=
lambda
x
:
x
.
identifyEntityToGet
().
priority
)
activeObjectQ
.
sort
(
key
=
lambda
x
:
x
.
identifyEntityToGet
().
priority
)
...
...
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