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
86c092f9
Commit
86c092f9
authored
Mar 07, 2014
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sortCandidateEntities method update for OperatorManagedJob
parent
b6adfd03
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
109 additions
and
1 deletion
+109
-1
dream/simulation/OperatorManagedJob.py
dream/simulation/OperatorManagedJob.py
+109
-1
No files found.
dream/simulation/OperatorManagedJob.py
View file @
86c092f9
...
@@ -66,6 +66,114 @@ class OperatorManagedJob(Operator):
...
@@ -66,6 +66,114 @@ class OperatorManagedJob(Operator):
# if self.operatorAssignedTo==None:
# if self.operatorAssignedTo==None:
# return False
# return False
return
len
(
self
.
Res
.
activeQ
)
<
self
.
capacity
return
len
(
self
.
Res
.
activeQ
)
<
self
.
capacity
# =======================================================================
# sorts the candidateEntities of the Operator according to the scheduling rule
# =======================================================================
def
sortCandidateEntities
(
self
,
candidateEntities
=
[]):
# TODO: have to consider what happens in case of a critical order
# FIFO sorting has no meaning when sorting candidateEntities
if
self
.
schedulingRule
==
"FIFO"
:
self
.
activeCandidateQSorter
(
'WT'
,
candidateEntities
=
candidateEntities
)
#if we have sorting according to multiple criteria we have to call the sorter many times
elif
self
.
schedulingRule
==
"MC"
:
for
criterion
in
reversed
(
self
.
multipleCriterionList
):
self
.
activeCandidateQSorter
(
criterion
=
criterion
,
candidateEntities
=
candidateEntities
)
#else we just use the default scheduling rule
else
:
self
.
activeCandidateQSorter
(
self
.
schedulingRule
,
candidateEntities
=
candidateEntities
)
# =======================================================================
# sorts the Entities of the Queue according to the scheduling rule
# =======================================================================
# TODO: entityToGet is not updated for all stations, consider using it for all stations or withdraw the idea
def
activeCandidateQSorter
(
self
,
criterion
=
None
,
candidateEntities
=
[]):
activeObjectQ
=
candidateEntities
if
not
activeObjectQ
:
assert
False
,
"empty candidate list"
if
criterion
==
None
:
criterion
=
self
.
schedulingRule
#if the schedulingRule is first in first out
if
criterion
==
"FIFO"
:
pass
#if the schedulingRule is based on a pre-defined priority
elif
criterion
==
"Priority"
:
activeObjectQ
.
sort
(
key
=
lambda
x
:
x
.
priority
)
#if the scheduling rule is time waiting (time waiting of machine
# TODO: consider that the timeLastEntityEnded is not a
# indicative identifier of how long the station was waiting
elif
criterion
==
'WT'
:
activeObjectQ
.
sort
(
key
=
lambda
x
:
x
.
schedule
[
-
1
][
1
])
#if the schedulingRule is earliest due date
elif
criterion
==
"EDD"
:
activeObjectQ
.
sort
(
key
=
lambda
x
:
x
.
dueDate
)
#if the schedulingRule is earliest order date
elif
criterion
==
"EOD"
:
activeObjectQ
.
sort
(
key
=
lambda
x
:
x
.
orderDate
)
#if the schedulingRule is to sort Entities according to the stations they have to visit
elif
criterion
==
"NumStages"
:
activeObjectQ
.
sort
(
key
=
lambda
x
:
len
(
x
.
remainingRoute
),
reverse
=
True
)
#if the schedulingRule is to sort Entities according to the their remaining processing time in the system
elif
criterion
==
"RPC"
:
for
entity
in
activeObjectQ
:
RPT
=
0
for
step
in
entity
.
remainingRoute
:
processingTime
=
step
.
get
(
'processingTime'
,
None
)
if
processingTime
:
RPT
+=
float
(
processingTime
.
get
(
'mean'
,
0
))
entity
.
remainingProcessingTime
=
RPT
activeObjectQ
.
sort
(
key
=
lambda
x
:
x
.
remainingProcessingTime
,
reverse
=
True
)
#if the schedulingRule is to sort Entities according to longest processing time first in the next station
elif
criterion
==
"LPT"
:
for
entity
in
activeObjectQ
:
processingTime
=
entity
.
remainingRoute
[
0
].
get
(
'processingTime'
,
None
)
entity
.
processingTimeInNextStation
=
float
(
processingTime
.
get
(
'mean'
,
0
))
if
processingTime
:
entity
.
processingTimeInNextStation
=
float
(
processingTime
.
get
(
'mean'
,
0
))
else
:
entity
.
processingTimeInNextStation
=
0
activeObjectQ
.
sort
(
key
=
lambda
x
:
x
.
processingTimeInNextStation
,
reverse
=
True
)
#if the schedulingRule is to sort Entities according to shortest processing time first in the next station
elif
criterion
==
"SPT"
:
for
entity
in
activeObjectQ
:
processingTime
=
entity
.
remainingRoute
[
0
].
get
(
'processingTime'
,
None
)
if
processingTime
:
entity
.
processingTimeInNextStation
=
float
(
processingTime
.
get
(
'mean'
,
0
))
else
:
entity
.
processingTimeInNextStation
=
0
activeObjectQ
.
sort
(
key
=
lambda
x
:
x
.
processingTimeInNextStation
)
#if the schedulingRule is to sort Entities based on the minimum slackness
elif
criterion
==
"MS"
:
for
entity
in
activeObjectQ
:
RPT
=
0
for
step
in
entity
.
remainingRoute
:
processingTime
=
step
.
get
(
'processingTime'
,
None
)
if
processingTime
:
RPT
+=
float
(
processingTime
.
get
(
'mean'
,
0
))
entity
.
remainingProcessingTime
=
RPT
activeObjectQ
.
sort
(
key
=
lambda
x
:
(
x
.
dueDate
-
x
.
remainingProcessingTime
))
#if the schedulingRule is to sort Entities based on the length of the following Queue
elif
criterion
==
"WINQ"
:
from
Globals
import
G
for
entity
in
activeObjectQ
:
nextObjIds
=
entity
.
remainingRoute
[
1
].
get
(
'stationIdsList'
,[])
for
obj
in
G
.
ObjList
:
if
obj
.
id
in
nextObjIds
:
nextObject
=
obj
entity
.
nextQueueLength
=
len
(
nextObject
.
getActiveObjectQueue
())
activeObjectQ
.
sort
(
key
=
lambda
x
:
x
.
nextQueueLength
)
else
:
assert
False
,
"Unknown scheduling criterion %r"
%
(
criterion
,
)
# =======================================================================
# =======================================================================
# sorts the Entities of the Queue according to the scheduling rule
# sorts the Entities of the Queue according to the scheduling rule
...
@@ -167,7 +275,7 @@ class OperatorManagedJob(Operator):
...
@@ -167,7 +275,7 @@ class OperatorManagedJob(Operator):
object
.
giver
.
sortEntitiesForOperator
(
self
)
object
.
giver
.
sortEntitiesForOperator
(
self
)
for
object
in
activeObjectQ
:
for
object
in
activeObjectQ
:
object
.
giver
.
getActiveObjectQueue
()[
0
]
entity
=
object
.
giver
.
getActiveObjectQueue
()[
0
]
RPT
=
0
RPT
=
0
for
step
in
entity
.
remainingRoute
:
for
step
in
entity
.
remainingRoute
:
processingTime
=
step
.
get
(
'processingTime'
,
None
)
processingTime
=
step
.
get
(
'processingTime'
,
None
)
...
...
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