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
2eca07ac
Commit
2eca07ac
authored
Mar 12, 2014
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
comments and TODOs added
parent
0b9d4fa0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
8 deletions
+30
-8
dream/simulation/Operator.py
dream/simulation/Operator.py
+3
-0
dream/simulation/OperatorManagedJob.py
dream/simulation/OperatorManagedJob.py
+9
-3
dream/simulation/OperatorRouter.py
dream/simulation/OperatorRouter.py
+18
-5
No files found.
dream/simulation/Operator.py
View file @
2eca07ac
...
...
@@ -61,6 +61,8 @@ class Operator(Repairman): # XXX isn't it the other way around ?
# =======================================================================
# sorts the candidateEntities of the Operator according to the scheduling rule
# TODO: clean the comments
# TODO: maybe the argument is not needed. the candidate entities is a variable of the object
# =======================================================================
def
sortCandidateEntities
(
self
,
candidateEntities
=
[]):
pass
...
...
@@ -78,6 +80,7 @@ class Operator(Repairman): # XXX isn't it the other way around ?
# =======================================================================
# sorts the activeCallerrs of the Operator according to the scheduling rule
# TODO: change the name of the class (they are not entities)
# =======================================================================
def
sortEntities
(
self
):
#if we have sorting according to multiple criteria we have to call the sorter many times
...
...
dream/simulation/OperatorManagedJob.py
View file @
2eca07ac
...
...
@@ -69,6 +69,7 @@ class OperatorManagedJob(Operator):
# =======================================================================
# sorts the candidateEntities of the Operator according to the scheduling rule
# TODO: maybe the argument is not needed. the candidate entities is a variable of the object
# =======================================================================
def
sortCandidateEntities
(
self
,
candidateEntities
=
[]):
# TODO: have to consider what happens in case of a critical order
...
...
@@ -209,21 +210,21 @@ class OperatorManagedJob(Operator):
for
object
in
activeObjectQ
:
object
.
giver
.
sortEntitiesForOperator
(
self
)
# TODO: the entities should be also sort according to their waiting time in case the EDD is the same
activeObjectQ
.
sort
(
key
=
lambda
x
:
x
.
giver
.
getActiveObjectQueue
()[
0
].
dueDate
)
#if the schedulingRule is earliest order date
elif
criterion
==
"EOD"
:
for
object
in
activeObjectQ
:
object
.
giver
.
sortEntitiesForOperator
(
self
)
# TODO: the entities should be also sort according to their waiting time in case the EOD is the same
activeObjectQ
.
sort
(
key
=
lambda
x
:
x
.
giver
.
getActiveObjectQueue
()[
0
].
orderDate
)
#if the schedulingRule is to sort Entities according to the stations they have to visit
elif
criterion
==
"NumStages"
:
for
object
in
activeObjectQ
:
object
.
giver
.
sortEntitiesForOperator
(
self
)
# TODO: the entities should be also sort according to their waiting time in case the NumStages are the same
activeObjectQ
.
sort
(
key
=
lambda
x
:
len
(
x
.
giver
.
getActiveObjectQueue
()[
0
].
remainingRoute
),
reverse
=
True
)
#if the schedulingRule is to sort Entities according to the their remaining processing time in the system
elif
criterion
==
"RPC"
:
...
...
@@ -239,6 +240,7 @@ class OperatorManagedJob(Operator):
if
processingTime
:
RPT
+=
float
(
processingTime
.
get
(
'mean'
,
0
))
entity
.
remainingProcessingTime
=
RPT
# TODO: the entities should be also sort according to their waiting time in case the remainingProcTime is the same
activeObjectQ
.
sort
(
key
=
lambda
x
:
x
.
giver
.
getActiveObjectQueue
()[
0
].
remainingProcessingTime
,
reverse
=
True
)
#if the schedulingRule is to sort Entities according to longest processing time first in the next station
elif
criterion
==
"LPT"
:
...
...
@@ -254,6 +256,7 @@ class OperatorManagedJob(Operator):
entity
.
processingTimeInNextStation
=
float
(
processingTime
.
get
(
'mean'
,
0
))
else
:
entity
.
processingTimeInNextStation
=
0
# TODO: the entities should be also sort according to their waiting time in case the ProcessingTimeInNextStation is the same
activeObjectQ
.
sort
(
key
=
lambda
x
:
x
.
giver
.
getActiveObjectQueue
()[
0
].
processingTimeInNextStation
,
reverse
=
True
)
#if the schedulingRule is to sort Entities according to shortest processing time first in the next station
elif
criterion
==
"SPT"
:
...
...
@@ -268,6 +271,7 @@ class OperatorManagedJob(Operator):
entity
.
processingTimeInNextStation
=
float
(
processingTime
.
get
(
'mean'
,
0
))
else
:
entity
.
processingTimeInNextStation
=
0
# TODO: the entities should be also sort according to their waiting time in case the procTimeInNextStation is the same
activeObjectQ
.
sort
(
key
=
lambda
x
:
x
.
giver
.
getActiveObjectQueue
()[
0
].
processingTimeInNextStation
)
#if the schedulingRule is to sort Entities based on the minimum slackness
elif
criterion
==
"MS"
:
...
...
@@ -283,6 +287,7 @@ class OperatorManagedJob(Operator):
if
processingTime
:
RPT
+=
float
(
processingTime
.
get
(
'mean'
,
0
))
entity
.
remainingProcessingTime
=
RPT
# TODO: the entities should be also sort according to their waiting time in case the minimum slackness are the same
activeObjectQ
.
sort
(
key
=
lambda
x
:
(
x
.
giver
.
getActiveObjectQueue
()[
0
].
dueDate
-
x
.
giver
.
getActiveObjectQueue
()[
0
].
remainingProcessingTime
))
#if the schedulingRule is to sort Entities based on the length of the following Queue
elif
criterion
==
"WINQ"
:
...
...
@@ -298,6 +303,7 @@ class OperatorManagedJob(Operator):
if
obj
.
id
in
nextObjIds
:
nextObject
=
obj
entity
.
nextQueueLength
=
len
(
nextObject
.
getActiveObjectQueue
())
# TODO: the entities should be also sort according to their waiting time in case length of the following queues are the same
activeObjectQ
.
sort
(
key
=
lambda
x
:
x
.
giver
.
getActiveObjectQueue
()[
0
].
nextQueueLength
)
else
:
assert
False
,
"Unknown scheduling criterion %r"
%
(
criterion
,
)
\ No newline at end of file
dream/simulation/OperatorRouter.py
View file @
2eca07ac
...
...
@@ -102,13 +102,15 @@ class Router(ObjectInterruption):
# # TESTING
# print ' {} the candidateOperators ',
# print [str(op.id) for op in self.candidateOperators]
# print [str(entity.id) for entity in G.pendingEntities]
#===================================================================
# sort the pendingEntities list
self
.
sortPendingEntities
()
#===================================================================
# # TESTING
# print [str(entity.id) for entity in G.pendingEntities]
# if G.pendingEntities:
# print ' {} the pending entities that can proceed are: ',
# print [str(entity.id) for entity in G.pendingEntities if entity.canProceed]
...
...
@@ -160,11 +162,13 @@ class Router(ObjectInterruption):
# sort the activeCallersList of the operator
operator
.
sortEntities
()
# find the activeCaller that has priority
priorityObject
=
next
(
x
for
x
in
operator
.
activeCallersList
if
x
in
self
.
pendingObjects
)
#===========================================================
# # TESTING
# print [str(caller.id) for caller in operator.activeCallersList]
# print ' the PRIORITY object is', priorityObject.id
#===========================================================
...
...
@@ -281,6 +285,11 @@ class Router(ObjectInterruption):
#=======================================================================
def
sortPendingEntities
(
self
):
# TODO: to be used for sorting of operators
# there must be also a schedulingRule property for the Router
# there must also be a way to have multiple criteria for the operators (eg MC-Priority-WT)
# WT may be needed to be applied everywhere
# TODO: move that piece of code elsewhere, it doesn't look nice here. and there is not point in doing it here
# maybe it's better in findCandidateOperators method
if
self
.
candidateOperators
:
for
operator
in
self
.
candidateOperators
:
if
operator
.
multipleCriterionList
:
...
...
@@ -396,9 +405,10 @@ class Router(ObjectInterruption):
# finally we have to sort before giving the entities to the operators
# If there is an entity which must have priority then it should be assigned first
#local method that finds a candidate entity for an operator
def
findCandidateEntity
():
return
next
(
x
for
x
in
operator
.
candidateEntities
if
not
x
in
entitiesWithOccupiedReceivers
)
#local method that finds a receiver for a candidate entity
def
findCandidateReceiver
():
# initiate the local list variable available receivers
availableReceivers
=
[
x
for
x
in
operator
.
candidateEntity
.
candidateReceivers
\
...
...
@@ -458,8 +468,10 @@ class Router(ObjectInterruption):
#=======================================================================
# Sort Givers
# TODO: the method currently checks only the first operator of the candidateOperators list
# consider populating the controls
# TODO: the queues of the candidate givers are sorted only if their receiver is not in activeCallersList
# if an operator is called the control returns to the generator of the Router (run())
# the next objects are not checked
# They must be control
#=======================================================================
def
sortGiverQueue
(
self
):
# for those operators that do have candidateEntity
...
...
@@ -479,6 +491,7 @@ class Router(ObjectInterruption):
# =======================================================================
# sorts the Entities of the Queue according to the scheduling rule
# TODO: refine the criteria
# =======================================================================
def
activePendingQSorter
(
self
,
criterion
=
None
):
from
Globals
import
G
...
...
@@ -489,7 +502,7 @@ class Router(ObjectInterruption):
criterion
=
self
.
schedulingRule
#if the schedulingRule is first in first out
if
criterion
==
"FIFO"
:
# FIFO sorting has no meaning when sorting candidateEntities
#
TODO:
FIFO sorting has no meaning when sorting candidateEntities
self
.
activePendingQSorter
(
'WT'
)
# added for testing
# print 'there is no point of using FIFO scheduling rule for operators candidateEntities,\
...
...
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