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
9cd884a0
Commit
9cd884a0
authored
Jan 10, 2014
by
Ioannis Papagiannopoulos
Committed by
Jérome Perrin
Jan 20, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Comments added
parent
9c33bce8
Changes
11
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
253 additions
and
117 deletions
+253
-117
dream/simulation/CoreObject.py
dream/simulation/CoreObject.py
+82
-33
dream/simulation/Dismantle.py
dream/simulation/Dismantle.py
+60
-30
dream/simulation/Globals.py
dream/simulation/Globals.py
+18
-4
dream/simulation/Job.py
dream/simulation/Job.py
+17
-11
dream/simulation/LineGenerationJSON.py
dream/simulation/LineGenerationJSON.py
+9
-6
dream/simulation/MachinePreemptive.py
dream/simulation/MachinePreemptive.py
+8
-4
dream/simulation/Order.py
dream/simulation/Order.py
+7
-5
dream/simulation/OrderComponent.py
dream/simulation/OrderComponent.py
+3
-3
dream/simulation/OrderDecomposition.py
dream/simulation/OrderDecomposition.py
+26
-13
dream/simulation/QueuePreemptive.py
dream/simulation/QueuePreemptive.py
+10
-5
dream/simulation/ScheduledMaintenance.py
dream/simulation/ScheduledMaintenance.py
+13
-3
No files found.
dream/simulation/CoreObject.py
View file @
9cd884a0
This diff is collapsed.
Click to expand it.
dream/simulation/Dismantle.py
View file @
9cd884a0
...
...
@@ -34,10 +34,13 @@ from RandomNumberGenerator import RandomNumberGenerator
import
scipy.stats
as
stat
from
CoreObject
import
CoreObject
#the Dismantle object
# ===========================================================================
# the Dismantle object
# ===========================================================================
class
Dismantle
(
CoreObject
):
#initialize the object
# =======================================================================
# initialize the object
# =======================================================================
def
__init__
(
self
,
id
,
name
,
distribution
=
'Fixed'
,
mean
=
1
,
stdev
=
0.1
,
min
=
0
,
max
=
5
):
CoreObject
.
__init__
(
self
)
self
.
id
=
id
...
...
@@ -63,13 +66,15 @@ class Dismantle(CoreObject):
self
.
Working
=
[]
self
.
Blockage
=
[]
#
============================== variable that is used for the loading of machines =============
#
variable that is used for the loading of machines
self
.
exitAssignedToReceiver
=
False
# by default the objects are not blocked
# when the entities have to be loaded to operatedMachines
# then the giverObjects have to be blocked for the time
# that the machine is being loaded
# =======================================================================
# the initialize method
# =======================================================================
def
initialize
(
self
):
Process
.
__init__
(
self
)
CoreObject
.
initialize
(
self
)
...
...
@@ -91,8 +96,6 @@ class Dismantle(CoreObject):
self
.
processingTimeOfCurrentEntity
=
0
#holds the total processing time that the current entity required
self
.
totalBlockageTime
=
0
#holds the total blockage time
self
.
totalWaitingTime
=
0
#holds the total waiting time
self
.
totalWorkingTime
=
0
#holds the total working time
...
...
@@ -108,7 +111,9 @@ class Dismantle(CoreObject):
self
.
Res
.
activeQ
=
[]
self
.
Res
.
waitQ
=
[]
# =======================================================================
# the run method
# =======================================================================
def
run
(
self
):
while
1
:
yield
waituntil
,
self
,
self
.
canAcceptAndIsRequested
#wait until the Assembly can accept a frame
...
...
@@ -136,21 +141,30 @@ class Dismantle(CoreObject):
self
.
waitToDisposeFrame
=
False
#the Dismantle has no Frame to dispose now
#self.totalBlockageTime+=now()-startBlockageTime #add the blockage time
#checks if the Dismantle can accept an entity and there is a Frame waiting for it
# =======================================================================
# checks if the Dismantle can accept an entity and there is a Frame
# waiting for it
# =======================================================================
def
canAcceptAndIsRequested
(
self
):
return
len
(
self
.
getActiveObjectQueue
())
==
0
and
self
.
getGiverObject
().
haveToDispose
(
self
)
#checks if the Dismantle can accept an entity
# =======================================================================
# checks if the Dismantle can accept an entity
# =======================================================================
def
canAccept
(
self
,
callerObject
=
None
):
return
len
(
self
.
getActiveObjectQueue
())
==
0
#defines where parts and frames go after they leave the object
# =======================================================================
# defines where parts and frames go after they leave the object
# =======================================================================
def
definePartFrameRouting
(
self
,
successorPartList
=
[],
successorFrameList
=
[]):
self
.
nextPart
=
successorPartList
self
.
nextFrame
=
successorFrameList
#checks if the caller waits for a part or a frame and if the Dismantle is in the state of disposing one it returnse true
# =======================================================================
# checks if the caller waits for a part or a frame and if the Dismantle
# is in the state of disposing one it returnse true
# =======================================================================
def
haveToDispose
(
self
,
callerObject
=
None
):
thecaller
=
callerObject
...
...
@@ -166,15 +180,21 @@ class Dismantle(CoreObject):
return
True
return
False
#checks if the frame is emptied
# =======================================================================
# checks if the frame is emptied
# =======================================================================
def
frameIsEmpty
(
self
):
return
len
(
self
.
getActiveObjectQueue
())
==
1
#checks if Dismantle is emptied
# =======================================================================
# checks if Dismantle is emptied
# =======================================================================
def
isEmpty
(
self
):
return
len
(
self
.
getActiveObjectQueue
())
==
0
#gets a frame from the giver
# =======================================================================
# gets a frame from the giver
# =======================================================================
def
getEntity
(
self
):
activeEntity
=
CoreObject
.
getEntity
(
self
)
#run the default method
activeObjectQueue
=
self
.
getActiveObjectQueue
()
...
...
@@ -189,7 +209,9 @@ class Dismantle(CoreObject):
activeObjectQueue
.
pop
(
0
)
return
activeEntity
#removes an entity from the Dismantle
# =======================================================================
# removes an entity from the Dismantle
# =======================================================================
def
removeEntity
(
self
):
activeObjectQueue
=
self
.
getActiveObjectQueue
()
activeEntity
=
CoreObject
.
removeEntity
(
self
)
#run the default method
...
...
@@ -202,7 +224,9 @@ class Dismantle(CoreObject):
self
.
waitToDisposePart
=
False
return
activeEntity
#add the blockage only if the very last Entity (Frame) is to depart
# =======================================================================
# add the blockage only if the very last Entity (Frame) is to depart
# =======================================================================
def
addBlockage
(
self
):
if
len
(
self
.
getActiveObjectQueue
())
==
1
:
self
.
totalTimeInCurrentEntity
=
now
()
-
self
.
timeLastEntityEntered
...
...
@@ -210,8 +234,9 @@ class Dismantle(CoreObject):
blockage
=
now
()
-
(
self
.
timeLastEntityEnded
+
self
.
downTimeInTryingToReleaseCurrentEntity
)
self
.
totalBlockageTime
+=
blockage
#actions to be taken after the simulation ends
# =======================================================================
# actions to be taken after the simulation ends
# =======================================================================
def
postProcessing
(
self
,
MaxSimtime
=
None
):
if
MaxSimtime
==
None
:
from
Globals
import
G
...
...
@@ -234,8 +259,10 @@ class Dismantle(CoreObject):
self
.
Working
.
append
(
100
*
self
.
totalWorkingTime
/
MaxSimtime
)
self
.
Blockage
.
append
(
100
*
self
.
totalBlockageTime
/
MaxSimtime
)
#outputs message to the trace.xls. Format is (Simulation Time | Entity or Frame Name | message)
# =======================================================================
# outputs message to the trace.xls.
# Format is (Simulation Time | Entity or Frame Name | message)
# =======================================================================
def
outputTrace
(
self
,
name
,
message
):
from
Globals
import
G
if
(
G
.
trace
==
"Yes"
):
#output only if the user has selected to
...
...
@@ -250,8 +277,9 @@ class Dismantle(CoreObject):
G
.
sheetIndex
+=
1
G
.
traceSheet
=
G
.
traceFile
.
add_sheet
(
'sheet '
+
str
(
G
.
sheetIndex
),
cell_overwrite_ok
=
True
)
#outputs data to "output.xls"
# =======================================================================
# outputs data to "output.xls"
# =======================================================================
def
outputResultsXL
(
self
,
MaxSimtime
=
None
):
from
Globals
import
G
if
MaxSimtime
==
None
:
...
...
@@ -303,7 +331,9 @@ class Dismantle(CoreObject):
G
.
outputIndex
+=
1
G
.
outputIndex
+=
1
#outputs results to JSON File
# =======================================================================
# outputs results to JSON File
# =======================================================================
def
outputResultsJSON
(
self
):
from
Globals
import
G
if
(
G
.
numberOfReplications
==
1
):
#if we had just one replication output the results to excel
...
...
dream/simulation/Globals.py
View file @
9cd884a0
...
...
@@ -34,7 +34,9 @@ import xlrd
from
random
import
Random
,
expovariate
,
gammavariate
,
normalvariate
from
SimPy.Simulation
import
now
# ===========================================================================
# globals
# ===========================================================================
class
G
:
seed
=
1450
#the seed of the random number generator
Rnd
=
Random
(
seed
)
#random number generator
...
...
@@ -49,7 +51,7 @@ class G:
maxSimTime
=
0
#the total simulation time
# data for the trace output in excel
#
=======================================================================
#
-----------------------------------------------------------------------
trace
=
""
#this is written from input. If it is "Yes" then you write to trace, else we do not
traceIndex
=
0
#index that shows in what row we are
sheetIndex
=
1
#index that shows in what sheet we are
...
...
@@ -58,19 +60,22 @@ class G:
# variables for excel output
#
=======================================================================
#
-----------------------------------------------------------------------
outputIndex
=
0
#index that shows in what row we are
sheetIndex
=
1
#index that shows in what sheet we are
outputFile
=
xlwt
.
Workbook
()
#create excel file
outputSheet
=
outputFile
.
add_sheet
(
'sheet '
+
str
(
sheetIndex
),
cell_overwrite_ok
=
True
)
#create excel sheet
#variables for json output
#
=======================================================================
#
-----------------------------------------------------------------------
outputJSON
=
{}
outputJSONFile
=
None
numberOfEntities
=
0
# =======================================================================
# method to move entities exceeding a certain safety stock
# =======================================================================
def
moveExcess
(
argumentDict
=
{}):
giver
=
findObjectById
(
argumentDict
.
get
(
'from'
,
None
))
receiver
=
findObjectById
(
argumentDict
.
get
(
'to'
,
None
))
...
...
@@ -87,20 +92,29 @@ def moveExcess(argumentDict={}):
else
:
print
"Giver and/or Receiver not defined"
# =======================================================================
# method finding objects by ID
# =======================================================================
def
findObjectById
(
id
):
for
obj
in
G
.
ObjList
:
if
obj
.
id
==
id
:
return
obj
return
None
# =======================================================================
# method to set-up the entities in the current stations
# as Work In Progress
# =======================================================================
def
setWIP
(
entityList
):
for
entity
in
entityList
:
# if the entity is of type Part
if
entity
.
type
==
'Part'
:
object
=
entity
.
currentStation
#identify the object
object
.
getActiveObjectQueue
().
append
(
entity
)
#append the entity to its Queue
entity
.
schedule
.
append
([
object
,
now
()])
#append the time to schedule so that it can be read in the result
# if the entity is of type Job/OrderComponent/Order
elif
entity
.
type
==
'Job'
or
'OrderComponent'
or
'Order'
:
object
=
findObjectById
(
entity
.
remainingRoute
[
0
][
0
])
# find the object in the 'G.ObjList
object
=
findObjectById
(
entity
.
remainingRoute
[
0
][
0
])
# find the object in the 'G.ObjList'
object
.
getActiveObjectQueue
().
append
(
entity
)
# append the entity to its Queue
object
.
receiver
=
findObjectById
(
entity
.
remainingRoute
[
1
][
0
])
entity
.
remainingRoute
.
pop
(
0
)
# remove data from the remaining route.
...
...
dream/simulation/Job.py
View file @
9cd884a0
...
...
@@ -29,7 +29,9 @@ in the system and also in the processing times at each station
from
Globals
import
G
from
Entity
import
Entity
# ============================ The job object ==============================
# =======================================================================
# The job object
# =======================================================================
class
Job
(
Entity
):
# inherits from the Entity class
type
=
"Job"
...
...
@@ -43,11 +45,13 @@ class Job(Entity): # inherits from the Entity c
self
.
remainingRoute
=
list
(
route
)
# the remaining route. in the beginning
# this should be the same as the full route
# the scheduling of the entity as resolved by the simulation
self
.
schedule
=
[]
# keeps the result of the simulation.
# A list with the stations and time of entrance
#
self.schedule=[] # keeps the result of the simulation.
#
# A list with the stations and time of entrance
self
.
extraPropertyDict
=
extraPropertyDict
#==================== outputs results to JSON File ======================
# =======================================================================
# outputs results to JSON File
# =======================================================================
def
outputResultsJSON
(
self
):
from
Globals
import
G
if
(
G
.
numberOfReplications
==
1
):
#if we had just one replication output the results to excel
...
...
@@ -74,13 +78,15 @@ class Job(Entity): # inherits from the Entity c
i
=
0
for
record
in
self
.
schedule
:
json
[
'results'
][
'schedule'
].
append
({})
# dictionary holding time and
json
[
'results'
][
'schedule'
][
i
][
'stepNumber'
]
=
i
#the step number
json
[
'results'
][
'schedule'
][
i
][
'stepNumber'
]
=
i
#
the step number
json
[
'results'
][
'schedule'
][
i
][
'stationId'
]
=
record
[
0
].
id
# id of the Object
json
[
'results'
][
'schedule'
][
i
][
'entranceTime'
]
=
record
[
1
]
# time entering the Object
i
+=
1
G
.
outputJSON
[
'elementList'
].
append
(
json
)
# ==== initializes all the Entity for a new simulation replication ======
# =======================================================================
# initializes all the Entity for a new simulation replication
# =======================================================================
def
initialize
(
self
):
# has to be re-initialized each time a new Job is added
self
.
remainingRoute
=
list
(
self
.
route
)
...
...
dream/simulation/LineGenerationJSON.py
View file @
9cd884a0
...
...
@@ -691,7 +691,6 @@ def createObjects():
if
possible_successor
.
id
==
nextId
:
possible_successor
.
previousIds
.
append
(
element
.
id
)
# ===========================================================================
# defines the topology (predecessors and successors for all the objects)
# ===========================================================================
...
...
@@ -914,7 +913,10 @@ def createWIP():
orderDate
=
float
(
entity
.
get
(
'orderDate'
,
'0'
))
isCritical
=
bool
(
int
(
entity
.
get
(
'isCritical'
,
'0'
)))
basicsEnded
=
bool
(
int
(
entity
.
get
(
'basicsEnded'
,
'0'
)))
# read the manager ID
manager
=
entity
.
get
(
'manager'
,
None
)
# if a manager ID is assigned then search for the operator with the corresponding ID
# and assign it as the manager of the order
if
manager
:
for
operator
in
G
.
OperatorsList
:
if
manager
==
operator
.
id
:
...
...
@@ -968,7 +970,6 @@ def createWIP():
G
.
WipList
.
append
(
O
)
G
.
EntityList
.
append
(
O
)
# ===========================================================================
# reads the interruptions of the stations
# ===========================================================================
...
...
@@ -980,9 +981,12 @@ def createObjectInterruptions():
json_data
=
G
.
JSONData
#Read the json data
nodes
=
json_data
[
'nodes'
]
# read from the dictionary the dicts with key 'nodes'
# for the elements in the nodes dict
for
(
element_id
,
element
)
in
nodes
.
iteritems
():
element
[
'id'
]
=
element_id
scheduledMaintenance
=
element
.
get
(
'scheduledMaintenance'
,
{})
# if there is a scheduled maintenance initiate it and append it
# to the interruptions- and scheduled maintenances- list
if
len
(
scheduledMaintenance
):
start
=
float
(
scheduledMaintenance
.
get
(
'start'
,
0
))
duration
=
float
(
scheduledMaintenance
.
get
(
'duration'
,
1
))
...
...
@@ -991,6 +995,8 @@ def createObjectInterruptions():
G
.
ObjectInterruptionList
.
append
(
SM
)
G
.
ScheduledMaintenanceList
.
append
(
SM
)
failure
=
element
.
get
(
'failures'
,
{})
# if there are failures assigned
# initiate them
if
len
(
failure
):
distributionType
=
failure
.
get
(
'failureDistribution'
,
'No'
)
if
distributionType
==
'No'
:
...
...
@@ -1004,15 +1010,12 @@ def createObjectInterruptions():
G
.
ObjectInterruptionList
.
append
(
F
)
G
.
FailureList
.
append
(
F
)
# ===========================================================================
# used to convert a string read from the input to object type
# ===========================================================================
def
str_to_class
(
str
):
return
getattr
(
sys
.
modules
[
__name__
],
str
)
# ===========================================================================
# the main script that is ran
# ===========================================================================
...
...
dream/simulation/MachinePreemptive.py
View file @
9cd884a0
...
...
@@ -27,7 +27,9 @@ inherits from MachineJobShop it can preempt the currently processed Entity if ne
from
MachineJobShop
import
MachineJobShop
from
SimPy.Simulation
import
reactivate
,
now
#the MachineJobShop object
# ===========================================================================
# the MachineJobShop object
# ===========================================================================
class
MachinePreemptive
(
MachineJobShop
):
def
__init__
(
self
,
id
,
name
,
capacity
=
1
,
distribution
=
'Fixed'
,
mean
=
1
,
stdev
=
0
,
min
=
0
,
max
=
10
,
\
...
...
@@ -41,7 +43,9 @@ class MachinePreemptive(MachineJobShop):
self
.
lastGiver
=
self
.
giver
return
activeEntity
#method to execute the preemption
# =======================================================================
# method to execute the preemption
# =======================================================================
def
preempt
(
self
):
activeEntity
=
self
.
getActiveObjectQueue
()[
0
]
#get the active Entity
#calculate the remaining processing time
...
...
dream/simulation/Order.py
View file @
9cd884a0
...
...
@@ -28,7 +28,9 @@ Order is an Entity that can have its design, get broken to sub-components
from
Globals
import
G
from
Job
import
Job
# ============================ The Order object ==============================
# =======================================================================
# The Order object
# =======================================================================
class
Order
(
Job
):
type
=
"Order"
...
...
@@ -36,10 +38,10 @@ class Order(Job):
componentsList
=
[],
manager
=
None
,
basicsEnded
=
False
,
extraPropertyDict
=
None
):
Job
.
__init__
(
self
,
id
=
id
,
name
=
name
,
route
=
route
,
priority
=
priority
,
dueDate
=
dueDate
,
orderDate
=
orderDate
,
extraPropertyDict
=
extraPropertyDict
)
self
.
isCritical
=
isCritical
self
.
componentsList
=
componentsList
self
.
manager
=
manager
self
.
basicsEnded
=
basicsEnded
self
.
isCritical
=
isCritical
# flag to inform weather the order is critical -> preemption
self
.
componentsList
=
componentsList
# list of components that the order will be broken into
self
.
manager
=
manager
# the manager responsible to handle the order
self
.
basicsEnded
=
basicsEnded
# flag that informs that the basic components of the order are finished
dream/simulation/OrderComponent.py
View file @
9cd884a0
...
...
@@ -35,6 +35,6 @@ class OrderComponent(Job): # inherits from the
def
__init__
(
self
,
id
=
None
,
name
=
None
,
route
=
[],
priority
=
0
,
dueDate
=
None
,
orderDate
=
None
,
extraPropertyDict
=
None
,
componentType
=
'Basic'
,
order
=
None
,
isCritical
=
False
):
Job
.
__init__
(
self
,
id
,
name
,
route
,
priority
,
dueDate
,
orderDate
,
extraPropertyDict
)
self
.
auxiliaryList
=
[]
self
.
order
=
order
self
.
isCritical
=
isCritical
#this should be self.order.isCritical. Added now for testing
self
.
auxiliaryList
=
[]
# Holds the auxiliary components that the component needs for a certain processing
self
.
order
=
order
# parent order of the order component
self
.
isCritical
=
isCritical
#
this should be self.order.isCritical. Added now for testing
dream/simulation/OrderDecomposition.py
View file @
9cd884a0
...
...
@@ -47,6 +47,9 @@ class OrderDecomposition(CoreObject):
self
.
objName
=
name
self
.
type
=
'OrderDecomposition'
# =======================================================================
# the initialize method
# =======================================================================
def
initialize
(
self
):
self
.
previous
=
G
.
ObjList
self
.
next
=
G
.
ObjList
...
...
@@ -56,7 +59,9 @@ class OrderDecomposition(CoreObject):
self
.
newlyCreatedComponents
=
[]
# a list to hold components just after decomposition
self
.
orderToBeDecomposed
=
None
#run just waits until there is something to get and gets it
# =======================================================================
# run just waits until there is something to get and gets it
# =======================================================================
def
run
(
self
):
while
1
:
yield
waituntil
,
self
,
self
.
canAcceptAndIsRequested
#wait until the Queue can accept an entity
...
...
@@ -64,12 +69,15 @@ class OrderDecomposition(CoreObject):
self
.
getEntity
()
self
.
decompose
()
# =======================================================================
# as a dummy object can always accept
# =======================================================================
def
canAccept
(
self
,
callerObject
=
None
):
return
True
# =======================================================================
# checks if the OrderDecomposition can accept an entity
and there is an entity in
# some possible giver waiting for it
# checks if the OrderDecomposition can accept an entity
#
and there is an entity in
some possible giver waiting for it
# also updates the giver to the one that is to be taken
# =======================================================================
def
canAcceptAndIsRequested
(
self
):
...
...
@@ -104,7 +112,8 @@ class OrderDecomposition(CoreObject):
return
activeObject
.
Up
and
isRequested
# =======================================================================
# checks if the OrderDecomposition can dispose an entity to the following object
# checks if the OrderDecomposition can dispose
# an entity to the following object
# =======================================================================
def
haveToDispose
(
self
,
callerObject
=
None
):
activeObjectQueue
=
self
.
getActiveObjectQueue
()
...
...
@@ -118,7 +127,9 @@ class OrderDecomposition(CoreObject):
#return True if the OrderDecomposition in the state of disposing and the caller is the receiver
return
self
.
Up
and
(
callerObject
is
self
.
receiver
)
#decomposes the order to its components
# =======================================================================
# decomposes the order to its components
# =======================================================================
def
decompose
(
self
):
activeObjectQueue
=
self
.
getActiveObjectQueue
()
#loop in the internal Queue. Decompose only if an Entity is of type order
...
...
@@ -137,7 +148,9 @@ class OrderDecomposition(CoreObject):
self
.
orderToBeDecomposed
=
None
self
.
newlyCreatedComponents
=
[]
#creates the components
# =======================================================================
# creates the components
# =======================================================================
def
createOrderComponent
(
self
,
component
):
#read attributes fromthe json or from the orderToBeDecomposed
id
=
component
.
get
(
'id'
,
'not found'
)
...
...
dream/simulation/QueuePreemptive.py
View file @
9cd884a0
...
...
@@ -28,10 +28,13 @@ Inherits from QueueJobShop. If it gets an isCritical Entity it can interrupt the
from
QueueJobShop
import
QueueJobShop
from
SimPy.Simulation
import
now
#the QueuePreemptive object
# ===========================================================================
# the QueuePreemptive object
# ===========================================================================
class
QueuePreemptive
(
QueueJobShop
):
#extend he default so that it can interrupt the receiver if need be
# =======================================================================
# extend he default so that it can interrupt the receiver if need be
# =======================================================================
def
getEntity
(
self
):
activeEntity
=
QueueJobShop
.
getEntity
(
self
)
#execute default behaviour
#if the obtained Entity is critical
...
...
@@ -44,7 +47,9 @@ class QueuePreemptive(QueueJobShop):
self
.
receiver
.
preempt
()
self
.
receiver
.
timeLastEntityEnded
=
now
()
#required to count blockage correctly in the preemptied station
#for future use
# =======================================================================
# for future use
# =======================================================================
def
sortEntities
(
self
):
QueueJobShop
.
sortEntities
(
self
)
...
...
dream/simulation/ScheduledMaintenance.py
View file @
9cd884a0
...
...
@@ -30,13 +30,23 @@ from SimPy.Simulation import now, Process, hold, request, release, infinity
from
RandomNumberGenerator
import
RandomNumberGenerator
from
ObjectInterruption
import
ObjectInterruption
# ===========================================================================
# the scheduled maintenance class
# ===========================================================================
class
ScheduledMaintenance
(
ObjectInterruption
):
# =======================================================================
# the __init__() method of the class
# =======================================================================
def
__init__
(
self
,
victim
=
None
,
start
=
0
,
duration
=
1
):
ObjectInterruption
.
__init__
(
self
,
victim
)
self
.
start
=
start
self
.
duration
=
duration
# =======================================================================
# the run method
# holds till the defined start time, interrupts the victim,
# holds for the maintenance duration, and finally reactivates the victim
# =======================================================================
def
run
(
self
):
yield
hold
,
self
,
self
.
start
#wait until the start time
try
:
...
...
@@ -48,7 +58,7 @@ class ScheduledMaintenance(ObjectInterruption):
except
AttributeError
:
print
"AttributeError1"
yield
hold
,
self
,
self
.
duration
#wait until the start time
yield
hold
,
self
,
self
.
duration
# wait for the defined duration of the interruption
self
.
victim
.
totalFailureTime
+=
self
.
duration
try
:
...
...
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