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
5de2d166
Commit
5de2d166
authored
Mar 23, 2015
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shift to be able to work as rolling
parent
1a03a489
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
5 deletions
+20
-5
dream/simulation/LineGenerationJSON.py
dream/simulation/LineGenerationJSON.py
+4
-1
dream/simulation/ShiftScheduler.py
dream/simulation/ShiftScheduler.py
+16
-4
No files found.
dream/simulation/LineGenerationJSON.py
View file @
5de2d166
...
...
@@ -337,9 +337,12 @@ def createObjectInterruptions():
endUnfinished
=
bool
(
int
(
shift
.
get
(
'endUnfinished'
,
0
)))
receiveBeforeEndThreshold
=
float
(
shift
.
get
(
'receiveBeforeEndThreshold'
,
0
))
thresholdTimeIsOnShift
=
bool
(
int
(
shift
.
get
(
'thresholdTimeIsOnShift'
,
1
)))
rolling
=
bool
(
int
(
shift
.
get
(
'rolling'
,
0
)))
lastOffShiftDuration
=
float
(
shift
.
get
(
'lastOffShiftDuration'
,
10
))
SS
=
ShiftScheduler
(
victim
=
victim
,
shiftPattern
=
shiftPattern
,
endUnfinished
=
endUnfinished
,
receiveBeforeEndThreshold
=
receiveBeforeEndThreshold
,
thresholdTimeIsOnShift
=
thresholdTimeIsOnShift
)
thresholdTimeIsOnShift
=
thresholdTimeIsOnShift
,
rolling
=
rolling
,
lastOffShiftDuration
=
lastOffShiftDuration
)
G
.
ObjectInterruptionList
.
append
(
SS
)
G
.
ShiftSchedulerList
.
append
(
SS
)
br
=
element
.
get
(
'interruptions'
,{}).
get
(
'break'
,
None
)
...
...
dream/simulation/ShiftScheduler.py
View file @
5de2d166
...
...
@@ -30,6 +30,7 @@ schedules the availability of an object according to its shift pattern
import
simpy
from
RandomNumberGenerator
import
RandomNumberGenerator
from
ObjectInterruption
import
ObjectInterruption
from
copy
import
deepcopy
# ===========================================================================
# the shift scheduler class
...
...
@@ -40,7 +41,7 @@ class ShiftScheduler(ObjectInterruption):
# the __init__() method of the class
# =======================================================================
def
__init__
(
self
,
id
=
''
,
name
=
''
,
victim
=
None
,
shiftPattern
=
[],
endUnfinished
=
False
,
receiveBeforeEndThreshold
=
0.0
,
thresholdTimeIsOnShift
=
True
,
**
kw
):
thresholdTimeIsOnShift
=
True
,
rolling
=
False
,
lastOffShiftDuration
=
10
,
**
kw
):
ObjectInterruption
.
__init__
(
self
,
victim
=
victim
)
self
.
type
=
'ShiftScheduler'
self
.
shiftPattern
=
shiftPattern
...
...
@@ -49,6 +50,8 @@ class ShiftScheduler(ObjectInterruption):
self
.
receiveBeforeEndThreshold
=
receiveBeforeEndThreshold
# flag that shows if the threshold time is counted as off-shift or waiting
self
.
thresholdTimeIsOnShift
=
thresholdTimeIsOnShift
self
.
rolling
=
rolling
self
.
lastOffShiftDuration
=
lastOffShiftDuration
# =======================================================================
# initialize for every replications
...
...
@@ -177,6 +180,15 @@ class ShiftScheduler(ObjectInterruption):
self
.
outputTrace
(
self
.
victim
.
name
,
"is off shift"
)
self
.
remainingShiftPattern
.
pop
(
0
)
# if there is no more shift data break the loop
if
len
(
self
.
remainingShiftPattern
)
==
0
:
break
# if there is no more shift data
if
not
len
(
self
.
remainingShiftPattern
):
# if the shift is rolling recreate the pattern
if
self
.
rolling
:
self
.
remainingShiftPattern
=
deepcopy
(
self
.
shiftPattern
)
for
record
in
self
.
remainingShiftPattern
:
# for value in record:
record
[
0
]
+=
(
self
.
env
.
now
+
self
.
lastOffShiftDuration
)
record
[
1
]
+=
(
self
.
env
.
now
+
self
.
lastOffShiftDuration
)
# else break the loop
else
:
break
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