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
83bbf135
Commit
83bbf135
authored
Feb 27, 2014
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Operator can now handle multiple schedulingRules
parent
2847318d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
9 deletions
+16
-9
dream/simulation/Operator.py
dream/simulation/Operator.py
+16
-9
No files found.
dream/simulation/Operator.py
View file @
83bbf135
...
@@ -37,13 +37,25 @@ class Operator(Repairman):
...
@@ -37,13 +37,25 @@ class Operator(Repairman):
def
__init__
(
self
,
id
,
name
,
capacity
=
1
,
schedulingRule
=
"FIFO"
):
def
__init__
(
self
,
id
,
name
,
capacity
=
1
,
schedulingRule
=
"FIFO"
):
Repairman
.
__init__
(
self
,
id
=
id
,
name
=
name
,
capacity
=
capacity
)
Repairman
.
__init__
(
self
,
id
=
id
,
name
=
name
,
capacity
=
capacity
)
self
.
type
=
"Operator"
self
.
type
=
"Operator"
self
.
activeCallersList
=
[]
self
.
activeCallersList
=
[]
# the list of object that request the operator
self
.
schedulingRule
=
schedulingRule
self
.
schedulingRule
=
schedulingRule
#the scheduling rule that the Queue follows
# #=======================================================================
# #=======================================================================
# # TESTING
# # TESTING
# print now(), self.
objName
, 'schedulingRule'
# print now(), self.
id
, 'schedulingRule'
# print self.schedulingRule
# print self.schedulingRule
# #=======================================================================
# #=======================================================================
self
.
multipleCriterionList
=
[]
#list with the criteria used to sort the Entities in the Queue
SRlist
=
[
schedulingRule
]
if
schedulingRule
.
startswith
(
"MC"
):
# if the first criterion is MC aka multiple criteria
SRlist
=
schedulingRule
.
split
(
"-"
)
# split the string of the criteria (delimiter -)
self
.
schedulingRule
=
SRlist
.
pop
(
0
)
# take the first criterion of the list
self
.
multipleCriterionList
=
SRlist
# hold the criteria list in the property multipleCriterionList
for
scheduling_rule
in
SRlist
:
if
scheduling_rule
not
in
(
"FIFO"
,
"Priority"
,
"WT"
,
"EDD"
,
"EOD"
,
"NumStages"
,
"RPC"
,
"LPT"
,
"SPT"
,
"MS"
,
"WINQ"
):
raise
ValueError
(
"Unknown scheduling rule %s for %s"
%
(
scheduling_rule
,
id
))
# =======================================================================
# =======================================================================
# sorts the Entities of the Queue according to the scheduling rule
# sorts the Entities of the Queue according to the scheduling rule
...
@@ -60,6 +72,7 @@ class Operator(Repairman):
...
@@ -60,6 +72,7 @@ class Operator(Repairman):
# =======================================================================
# =======================================================================
# sorts the Entities of the Queue according to the scheduling rule
# 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
activeQSorter
(
self
,
criterion
=
None
):
def
activeQSorter
(
self
,
criterion
=
None
):
activeObjectQ
=
self
.
activeCallersList
activeObjectQ
=
self
.
activeCallersList
if
criterion
==
None
:
if
criterion
==
None
:
...
@@ -68,7 +81,6 @@ class Operator(Repairman):
...
@@ -68,7 +81,6 @@ class Operator(Repairman):
if
criterion
==
"FIFO"
:
if
criterion
==
"FIFO"
:
pass
pass
#if the schedulingRule is based on a pre-defined priority
#if the schedulingRule is based on a pre-defined priority
# TODO: entityToGet is not updated for all available Objects
elif
criterion
==
"Priority"
:
elif
criterion
==
"Priority"
:
activeObjectQ
.
sort
(
key
=
lambda
x
:
x
.
entityToGet
.
priority
)
activeObjectQ
.
sort
(
key
=
lambda
x
:
x
.
entityToGet
.
priority
)
#if the scheduling rule is time waiting (time waiting of machine
#if the scheduling rule is time waiting (time waiting of machine
...
@@ -86,7 +98,6 @@ class Operator(Repairman):
...
@@ -86,7 +98,6 @@ class Operator(Repairman):
elif
criterion
==
"NumStages"
:
elif
criterion
==
"NumStages"
:
activeObjectQ
.
sort
(
key
=
lambda
x
:
len
(
x
.
entityToGet
.
remainingRoute
),
reverse
=
True
)
activeObjectQ
.
sort
(
key
=
lambda
x
:
len
(
x
.
entityToGet
.
remainingRoute
),
reverse
=
True
)
#if the schedulingRule is to sort Entities according to the their remaining processing time in the system
#if the schedulingRule is to sort Entities according to the their remaining processing time in the system
# TODO: have to compare the entitiesToGet
elif
criterion
==
"RPC"
:
elif
criterion
==
"RPC"
:
for
object
in
activeObjectQ
:
for
object
in
activeObjectQ
:
entity
=
object
.
entityToGet
entity
=
object
.
entityToGet
...
@@ -98,7 +109,6 @@ class Operator(Repairman):
...
@@ -98,7 +109,6 @@ class Operator(Repairman):
entity
.
remainingProcessingTime
=
RPT
entity
.
remainingProcessingTime
=
RPT
activeObjectQ
.
sort
(
key
=
lambda
x
:
x
.
entityToGet
.
remainingProcessingTime
,
reverse
=
True
)
activeObjectQ
.
sort
(
key
=
lambda
x
:
x
.
entityToGet
.
remainingProcessingTime
,
reverse
=
True
)
#if the schedulingRule is to sort Entities according to longest processing time first in the next station
#if the schedulingRule is to sort Entities according to longest processing time first in the next station
# TODO: have to compare the entitiesToGet
elif
criterion
==
"LPT"
:
elif
criterion
==
"LPT"
:
for
object
in
activeObjectQ
:
for
object
in
activeObjectQ
:
entity
=
object
.
entityToGet
entity
=
object
.
entityToGet
...
@@ -110,7 +120,6 @@ class Operator(Repairman):
...
@@ -110,7 +120,6 @@ class Operator(Repairman):
entity
.
processingTimeInNextStation
=
0
entity
.
processingTimeInNextStation
=
0
activeObjectQ
.
sort
(
key
=
lambda
x
:
x
.
entityToGet
.
processingTimeInNextStation
,
reverse
=
True
)
activeObjectQ
.
sort
(
key
=
lambda
x
:
x
.
entityToGet
.
processingTimeInNextStation
,
reverse
=
True
)
#if the schedulingRule is to sort Entities according to shortest processing time first in the next station
#if the schedulingRule is to sort Entities according to shortest processing time first in the next station
# TODO: have to compare the entitiesToGet
elif
criterion
==
"SPT"
:
elif
criterion
==
"SPT"
:
for
object
in
activeObjectQ
:
for
object
in
activeObjectQ
:
entity
=
object
.
entityToGet
entity
=
object
.
entityToGet
...
@@ -121,7 +130,6 @@ class Operator(Repairman):
...
@@ -121,7 +130,6 @@ class Operator(Repairman):
entity
.
processingTimeInNextStation
=
0
entity
.
processingTimeInNextStation
=
0
activeObjectQ
.
sort
(
key
=
lambda
x
:
x
.
entityToGet
.
processingTimeInNextStation
)
activeObjectQ
.
sort
(
key
=
lambda
x
:
x
.
entityToGet
.
processingTimeInNextStation
)
#if the schedulingRule is to sort Entities based on the minimum slackness
#if the schedulingRule is to sort Entities based on the minimum slackness
# TODO: have to compare the entitiesToGet
elif
criterion
==
"MS"
:
elif
criterion
==
"MS"
:
for
object
in
activeObjectQ
:
for
object
in
activeObjectQ
:
object
.
entityToGet
object
.
entityToGet
...
@@ -133,7 +141,6 @@ class Operator(Repairman):
...
@@ -133,7 +141,6 @@ class Operator(Repairman):
entity
.
remainingProcessingTime
=
RPT
entity
.
remainingProcessingTime
=
RPT
activeObjectQ
.
sort
(
key
=
lambda
x
:
(
x
.
entityToGet
.
dueDate
-
x
.
entityToGet
.
remainingProcessingTime
))
activeObjectQ
.
sort
(
key
=
lambda
x
:
(
x
.
entityToGet
.
dueDate
-
x
.
entityToGet
.
remainingProcessingTime
))
#if the schedulingRule is to sort Entities based on the length of the following Queue
#if the schedulingRule is to sort Entities based on the length of the following Queue
# TODO: have to compare the entitiesToGet
elif
criterion
==
"WINQ"
:
elif
criterion
==
"WINQ"
:
from
Globals
import
G
from
Globals
import
G
for
object
in
activeObjectQ
:
for
object
in
activeObjectQ
:
...
...
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