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
61301df0
Commit
61301df0
authored
Apr 17, 2014
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
preemption enabled for unoperated MachineJobShops
parent
e2e10cac
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
86 deletions
+73
-86
dream/simulation/CoreObject.py
dream/simulation/CoreObject.py
+0
-6
dream/simulation/Machine.py
dream/simulation/Machine.py
+33
-47
dream/simulation/MachineJobShop.py
dream/simulation/MachineJobShop.py
+40
-33
No files found.
dream/simulation/CoreObject.py
View file @
61301df0
...
@@ -566,12 +566,6 @@ class CoreObject(Process):
...
@@ -566,12 +566,6 @@ class CoreObject(Process):
def
unAssignExit
(
self
):
def
unAssignExit
(
self
):
self
.
exitAssignedToReceiver
=
None
self
.
exitAssignedToReceiver
=
None
# # =======================================================================
# # actions to be carried whenever the object is preemptied
# # =======================================================================
# def preempt(self):
# pass
# =======================================================================
# =======================================================================
# actions to be carried whenever the object is interrupted
# actions to be carried whenever the object is interrupted
# (failure, break, preemption, etc)
# (failure, break, preemption, etc)
...
...
dream/simulation/Machine.py
View file @
61301df0
...
@@ -151,10 +151,10 @@ class Machine(CoreObject):
...
@@ -151,10 +151,10 @@ class Machine(CoreObject):
self
.
resetOnPreemption
=
resetOnPreemption
self
.
resetOnPreemption
=
resetOnPreemption
# events used by the broker
# events used by the broker
self
.
brokerIsSet
=
SimEvent
(
'brokerIsSet'
)
self
.
brokerIsSet
=
SimEvent
(
'brokerIsSet'
)
# this event is generated every time an operator is requested by machine for Load operation type.
# this event is generated every time an operator is requested by machine for Load operation type.
# if the machine has not succeeded in getting an entity due to the resource absence
# if the machine has not succeeded in getting an entity due to the resource absence
# and waits for the next event to get the entity,
# and waits for the next event to get the entity,
# then it must be signalled that the operator is now available
# then it must be signalled that the operator is now available
self
.
loadOperatorAvailable
=
SimEvent
(
'loadOperatorAvailable'
)
self
.
loadOperatorAvailable
=
SimEvent
(
'loadOperatorAvailable'
)
self
.
routerCycleOver
=
SimEvent
(
'routerCycleOver'
)
self
.
routerCycleOver
=
SimEvent
(
'routerCycleOver'
)
...
@@ -271,7 +271,6 @@ class Machine(CoreObject):
...
@@ -271,7 +271,6 @@ class Machine(CoreObject):
self
.
loadTimeCurrentEntity
=
0
self
.
loadTimeCurrentEntity
=
0
self
.
setupTimeCurrentEntity
=
0
self
.
setupTimeCurrentEntity
=
0
#===========================================================================
# ======= request a resource
# ======= request a resource
if
(
self
.
operatorPool
!=
"None"
)
and
any
(
type
==
'Load'
for
type
in
self
.
multOperationTypeList
):
if
(
self
.
operatorPool
!=
"None"
)
and
any
(
type
==
'Load'
for
type
in
self
.
multOperationTypeList
):
# when it's ready to accept (canAcceptAndIsRequested) then inform the broker
# when it's ready to accept (canAcceptAndIsRequested) then inform the broker
...
@@ -307,7 +306,6 @@ class Machine(CoreObject):
...
@@ -307,7 +306,6 @@ class Machine(CoreObject):
# TODO: reset the requestinEntity before receiving the currentEntity
# TODO: reset the requestinEntity before receiving the currentEntity
self
.
requestingEntity
=
None
self
.
requestingEntity
=
None
#===========================================================================
# get the entity
# get the entity
# TODO: if there was loading time then we must solve the problem of getting an entity
# TODO: if there was loading time then we must solve the problem of getting an entity
# from an unidentified giver or not getting an entity at all as the giver
# from an unidentified giver or not getting an entity at all as the giver
...
@@ -316,7 +314,6 @@ class Machine(CoreObject):
...
@@ -316,7 +314,6 @@ class Machine(CoreObject):
# TODO: the Machine receive the entity after the operator is available
# TODO: the Machine receive the entity after the operator is available
# the canAcceptAndIsRequested method checks only in case of Load type of operation
# the canAcceptAndIsRequested method checks only in case of Load type of operation
#===========================================================================
# ======= request a resource if it is not already assigned an Operator
# ======= request a resource if it is not already assigned an Operator
if
(
self
.
operatorPool
!=
"None"
)
\
if
(
self
.
operatorPool
!=
"None"
)
\
and
(
any
(
type
==
"Processing"
for
type
in
self
.
multOperationTypeList
)
\
and
(
any
(
type
==
"Processing"
for
type
in
self
.
multOperationTypeList
)
\
...
@@ -330,14 +327,12 @@ class Machine(CoreObject):
...
@@ -330,14 +327,12 @@ class Machine(CoreObject):
yield
waitevent
,
self
,
self
.
brokerIsSet
yield
waitevent
,
self
,
self
.
brokerIsSet
self
.
timeWaitForOperatorEnded
=
now
()
self
.
timeWaitForOperatorEnded
=
now
()
self
.
operatorWaitTimeCurrentEntity
+=
self
.
timeWaitForOperatorEnded
-
self
.
timeWaitForOperatorStarted
self
.
operatorWaitTimeCurrentEntity
+=
self
.
timeWaitForOperatorEnded
-
self
.
timeWaitForOperatorStarted
#===========================================================================
# variables dedicated to hold the processing times, the time when the Entity entered,
# variables dedicated to hold the processing times, the time when the Entity entered,
# and the processing time left
# and the processing time left
self
.
totalProcessingTimeInCurrentEntity
=
self
.
calculateProcessingTime
()
# get the processing time, tinMStarts holds the processing time of the machine
self
.
totalProcessingTimeInCurrentEntity
=
self
.
calculateProcessingTime
()
# get the processing time, tinMStarts holds the processing time of the machine
self
.
tinM
=
self
.
totalProcessingTimeInCurrentEntity
# timer to hold the processing time left
self
.
tinM
=
self
.
totalProcessingTimeInCurrentEntity
# timer to hold the processing time left
#===============================================================================
# ======= setup the machine if the Setup is defined as one of the Operators' operation types
# ======= setup the machine if the Setup is defined as one of the Operators' operation types
# in plantSim the setup is performed when the machine has to process a new type of Entity and only once
# in plantSim the setup is performed when the machine has to process a new type of Entity and only once
if
any
(
type
==
"Setup"
for
type
in
self
.
multOperationTypeList
)
and
self
.
isOperated
():
if
any
(
type
==
"Setup"
for
type
in
self
.
multOperationTypeList
)
and
self
.
isOperated
():
...
@@ -383,7 +378,6 @@ class Machine(CoreObject):
...
@@ -383,7 +378,6 @@ class Machine(CoreObject):
self
.
releaseOperator
()
self
.
releaseOperator
()
# wait until the Broker has finished processing
# wait until the Broker has finished processing
yield
waitevent
,
self
,
self
.
brokerIsSet
yield
waitevent
,
self
,
self
.
brokerIsSet
#===============================================================================
# variables used to flag any interruptions and the end of the processing
# variables used to flag any interruptions and the end of the processing
self
.
interruption
=
False
self
.
interruption
=
False
...
@@ -397,22 +391,20 @@ class Machine(CoreObject):
...
@@ -397,22 +391,20 @@ class Machine(CoreObject):
# timeRestartingProcessing : dummy variable to keep track of the time that the processing starts after
# timeRestartingProcessing : dummy variable to keep track of the time that the processing starts after
# every interruption
# every interruption
self
.
timeRestartingProcessing
=
now
()
self
.
timeRestartingProcessing
=
now
()
# wait for the processing time left tinM, if no interruption occurs then change the
# wait for the processing time left tinM, if no interruption occurs then change the
processingEndedFlag and exit loop,
#
processingEndedFlag and exit loop,
#
else (if interrupted()) set interruption flag to true (only if tinM==0),
#
else (if interrupted()) set interruption flag to true (only if tinM==0),
#
and recalculate the processing time left tinM, passivate while waiting for repair.
#
and recalculate the processing time left tinM, passivate while waiting for repair.
#
if a preemption has occurred then react accordingly (proceed with getting the critical entity)
yield
hold
,
self
,
self
.
tinM
# getting processed for remaining processing time tinM
yield
hold
,
self
,
self
.
tinM
# getting processed for remaining processing time tinM
if
self
.
interrupted
():
# if a failure occurs while processing the machine is interrupted.
if
self
.
interrupted
():
# if a failure occurs while processing the machine is interrupted.
self
.
interruptionActions
()
# execute interruption actions
self
.
interruptionActions
()
# execute interruption actions
#===========================================================================
# =============== release the operator if there is interruption
# =============== release the operator if there is interruption
if
(
self
.
operatorPool
!=
"None"
)
\
if
(
self
.
operatorPool
!=
"None"
)
\
and
self
.
isOperated
()
\
and
self
.
isOperated
()
\
and
any
(
type
==
"Processing"
for
type
in
self
.
multOperationTypeList
):
and
any
(
type
==
"Processing"
for
type
in
self
.
multOperationTypeList
):
self
.
releaseOperator
()
self
.
releaseOperator
()
yield
waitevent
,
self
,
self
.
brokerIsSet
yield
waitevent
,
self
,
self
.
brokerIsSet
#===========================================================================
# if there is a failure in the machine or interruption due to preemption, it is passivated
# if there is a failure in the machine or interruption due to preemption, it is passivated
# passivate the Machine for as long as there is no repair
# passivate the Machine for as long as there is no repair
...
@@ -420,13 +412,7 @@ class Machine(CoreObject):
...
@@ -420,13 +412,7 @@ class Machine(CoreObject):
assert
now
()
==
self
.
interruptionEnd
.
signalparam
,
'the victim of the failure is not the object that received it'
assert
now
()
==
self
.
interruptionEnd
.
signalparam
,
'the victim of the failure is not the object that received it'
self
.
postInterruptionActions
()
self
.
postInterruptionActions
()
#===========================================================
# #if during the interruption the object became empty break
# if (len(self.getActiveObjectQueue())==0 and self.shouldPreempt):
# break
#===========================================================
#===========================================================================
# =============== request a resource after the repair
# =============== request a resource after the repair
if
(
self
.
operatorPool
!=
"None"
)
\
if
(
self
.
operatorPool
!=
"None"
)
\
and
any
(
type
==
"Processing"
for
type
in
self
.
multOperationTypeList
)
\
and
any
(
type
==
"Processing"
for
type
in
self
.
multOperationTypeList
)
\
...
@@ -436,40 +422,33 @@ class Machine(CoreObject):
...
@@ -436,40 +422,33 @@ class Machine(CoreObject):
yield
waitevent
,
self
,
self
.
brokerIsSet
yield
waitevent
,
self
,
self
.
brokerIsSet
self
.
timeWaitForOperatorEnded
=
now
()
self
.
timeWaitForOperatorEnded
=
now
()
self
.
operatorWaitTimeCurrentEntity
+=
self
.
timeWaitForOperatorEnded
-
self
.
timeWaitForOperatorStarted
self
.
operatorWaitTimeCurrentEntity
+=
self
.
timeWaitForOperatorEnded
-
self
.
timeWaitForOperatorStarted
#===========================================================================
# if the station is reactivated by the preempt method
elif
(
self
.
shouldPreempt
):
self
.
interruptionActions
()
# execute interruption actions
# =============== release the operator if there is interruption
if
(
self
.
operatorPool
!=
"None"
)
\
and
self
.
isOperated
()
\
and
any
(
type
==
"Processing"
for
type
in
self
.
multOperationTypeList
):
self
.
releaseOperator
()
yield
waitevent
,
self
,
self
.
brokerIsSet
self
.
postInterruptionActions
()
break
# if no interruption occurred the processing in M1 is ended
# if no interruption occurred the processing in M1 is ended
else
:
else
:
processingNotFinished
=
False
processingNotFinished
=
False
#===================================================================
# #if during the interruption the object became empty continue
# if (len(self.getActiveObjectQueue())==0 and self.shouldPreempt):
# self.shouldPreempt=False
# self.totalWorkingTime+=now()-(self.timeLastEntityEntered)
#===================================================================
#===========================================================================
# # TODO: Should release operator here
# # =============== release resource in case of preemption
# if (self.operatorPool!='None')\
# and any(type=="Processing" for type in self.multOperationTypeList)\
# and not self.interruption:
# self.releaseOperator()
# yield waituntil,self,self.broker.isSet
# continue
#===========================================================================
# carry on actions that have to take place when an Entity ends its processing
# carry on actions that have to take place when an Entity ends its processing
self
.
endProcessingActions
()
self
.
endProcessingActions
()
#===========================================================================
# =============== release resource after the end of processing
# =============== release resource after the end of processing
if
(
self
.
operatorPool
!=
'None'
)
\
if
(
self
.
operatorPool
!=
'None'
)
\
and
any
(
type
==
"Processing"
for
type
in
self
.
multOperationTypeList
)
\
and
any
(
type
==
"Processing"
for
type
in
self
.
multOperationTypeList
)
\
and
not
self
.
interruption
:
and
not
self
.
interruption
:
self
.
releaseOperator
()
self
.
releaseOperator
()
yield
waitevent
,
self
,
self
.
brokerIsSet
yield
waitevent
,
self
,
self
.
brokerIsSet
#===========================================================================
# signal the receiver that the activeObject has something to dispose of
# signal the receiver that the activeObject has something to dispose of
if
not
self
.
signalReceiver
():
if
not
self
.
signalReceiver
():
...
@@ -541,12 +520,19 @@ class Machine(CoreObject):
...
@@ -541,12 +520,19 @@ class Machine(CoreObject):
#do this so that if it is overtime working it is not counted as off-shift time
#do this so that if it is overtime working it is not counted as off-shift time
if
not
activeObject
.
onShift
:
if
not
activeObject
.
onShift
:
activeObject
.
timeLastShiftEnded
=
now
()
activeObject
.
timeLastShiftEnded
=
now
()
# update the total working time # the total processing time for this entity is what the distribution initially gave
# update the total working time
activeObject
.
totalWorkingTime
+=
activeObject
.
totalProcessingTimeInCurrentEntity
# the total processing time for this entity is what the distribution initially gave
if
not
self
.
shouldPreempt
:
activeObject
.
totalWorkingTime
+=
activeObject
.
totalProcessingTimeInCurrentEntity
# if the station was preemptied for a critical order then calculate the total working time accorindingly
else
:
activeObject
.
totalWorkingTime
+=
now
()
-
(
self
.
timeLastEntityEntered
)
# update the variables keeping track of Entity related attributes of the machine
# update the variables keeping track of Entity related attributes of the machine
activeObject
.
timeLastEntityEnded
=
now
()
# this holds the time that the last entity ended processing in Machine
activeObject
.
timeLastEntityEnded
=
now
()
# this holds the time that the last entity ended processing in Machine
activeObject
.
nameLastEntityEnded
=
activeObject
.
currentEntity
.
name
# this holds the name of the last entity that ended processing in Machine
activeObject
.
nameLastEntityEnded
=
activeObject
.
currentEntity
.
name
# this holds the name of the last entity that ended processing in Machine
activeObject
.
completedJobs
+=
1
# Machine completed one more Job
activeObject
.
completedJobs
+=
1
# Machine completed one more Job
# reseting the shouldPreempt flag
self
.
shouldPreempt
=
False
# =======================================================================
# =======================================================================
# actions to be carried out when the processing of an Entity ends
# actions to be carried out when the processing of an Entity ends
...
@@ -720,7 +706,6 @@ class Machine(CoreObject):
...
@@ -720,7 +706,6 @@ class Machine(CoreObject):
activeObject
.
waitToDispose
=
False
# update the waitToDispose flag
activeObject
.
waitToDispose
=
False
# update the waitToDispose flag
# if the Machine canAccept then signal a giver
# if the Machine canAccept then signal a giver
if
activeObject
.
canAccept
():
if
activeObject
.
canAccept
():
# print now(), self.id, 'will singal giver'
activeObject
.
signalGiver
()
activeObject
.
signalGiver
()
# if the Machine is operated then signal Broker that the internal queue is now empty
# if the Machine is operated then signal Broker that the internal queue is now empty
if
activeObject
.
currentOperator
:
if
activeObject
.
currentOperator
:
...
@@ -859,6 +844,7 @@ class Machine(CoreObject):
...
@@ -859,6 +844,7 @@ class Machine(CoreObject):
-
activeObject
.
setupTimeCurrentEntity
\
-
activeObject
.
setupTimeCurrentEntity
\
-
offShiftTimeInCurrentEntity
-
offShiftTimeInCurrentEntity
activeObject
.
totalTimeWaitingForOperator
+=
activeObject
.
operatorWaitTimeCurrentEntity
activeObject
.
totalTimeWaitingForOperator
+=
activeObject
.
operatorWaitTimeCurrentEntity
elif
(
len
(
activeObject
.
getActiveObjectQueue
())
>
0
)
\
elif
(
len
(
activeObject
.
getActiveObjectQueue
())
>
0
)
\
and
(
not
(
activeObject
.
nameLastEntityEnded
==
activeObject
.
nameLastEntityEntered
))
\
and
(
not
(
activeObject
.
nameLastEntityEnded
==
activeObject
.
nameLastEntityEntered
))
\
and
(
activeObject
.
currentOperator
==
None
):
and
(
activeObject
.
currentOperator
==
None
):
...
...
dream/simulation/MachineJobShop.py
View file @
61301df0
...
@@ -86,12 +86,16 @@ class MachineJobShop(Machine):
...
@@ -86,12 +86,16 @@ class MachineJobShop(Machine):
if
not
activeObject
.
onShift
:
if
not
activeObject
.
onShift
:
activeObject
.
timeLastShiftEnded
=
now
()
activeObject
.
timeLastShiftEnded
=
now
()
# update the total working time # the total processing time for this entity is what the distribution initially gave
# update the total working time # the total processing time for this entity is what the distribution initially gave
activeObject
.
totalWorkingTime
+=
activeObject
.
totalProcessingTimeInCurrentEntity
if
not
self
.
shouldPreempt
:
activeObject
.
totalWorkingTime
+=
activeObject
.
totalProcessingTimeInCurrentEntity
else
:
activeObject
.
totalWorkingTime
+=
now
()
-
(
self
.
timeLastEntityEntered
)
# update the variables keeping track of Entity related attributes of the machine
# update the variables keeping track of Entity related attributes of the machine
activeObject
.
timeLastEntityEnded
=
now
()
# this holds the time that the last entity ended processing in Machine
activeObject
.
timeLastEntityEnded
=
now
()
# this holds the time that the last entity ended processing in Machine
activeObject
.
nameLastEntityEnded
=
activeObject
.
currentEntity
.
name
# this holds the name of the last entity that ended processing in Machine
activeObject
.
nameLastEntityEnded
=
activeObject
.
currentEntity
.
name
# this holds the name of the last entity that ended processing in Machine
activeObject
.
completedJobs
+=
1
# Machine completed one more Job
activeObject
.
completedJobs
+=
1
# Machine completed one more Job
# reseting the preemption flag
self
.
shouldPreempt
=
False
# TODO: collapse that to Machine
# TODO: collapse that to Machine
...
@@ -214,37 +218,40 @@ class MachineJobShop(Machine):
...
@@ -214,37 +218,40 @@ class MachineJobShop(Machine):
and
(
thecaller
in
activeObject
.
next
)
\
and
(
thecaller
in
activeObject
.
next
)
\
and
thecaller
.
isInRoute
(
activeObject
)
and
thecaller
.
isInRoute
(
activeObject
)
# # =======================================================================
# =======================================================================
# # method to execute preemption
# method to execute preemption
# # =======================================================================
# =======================================================================
# def preempt(self):
def
preempt
(
self
):
# activeObject=self.getActiveObject()
activeObject
=
self
.
getActiveObject
()
# activeEntity=self.getActiveObjectQueue()[0] #get the active Entity
activeEntity
=
self
.
getActiveObjectQueue
()[
0
]
#get the active Entity
# #calculate the remaining processing time
#calculate the remaining processing time
# #if it is reset then set it as the original processing time
#if it is reset then set it as the original processing time
# if self.resetOnPreemption:
if
self
.
resetOnPreemption
:
# remainingProcessingTime=self.procTime
remainingProcessingTime
=
self
.
procTime
# #else subtract the time that passed since the entity entered
#else subtract the time that passed since the entity entered
# #(may need also failure time if there was. TO BE MELIORATED)
#(may need also failure time if there was. TO BE MELIORATED)
# else:
else
:
# remainingProcessingTime=self.procTime-(now()-self.timeLastEntityEntered)
remainingProcessingTime
=
self
.
procTime
-
(
now
()
-
self
.
timeLastEntityEntered
)
# #update the remaining route of activeEntity
#update the remaining route of activeEntity
# activeEntity.remainingRoute.insert(0, {'stationIdsList':[str(self.id)],\
activeEntity
.
remainingRoute
.
insert
(
0
,
{
'stationIdsList'
:[
str
(
self
.
id
)],
\
# 'processingTime':\
'processingTime'
:
\
# {'distributionType':'Fixed',\
{
'distributionType'
:
'Fixed'
,
\
# 'mean':str(remainingProcessingTime)}})
'mean'
:
str
(
remainingProcessingTime
)}})
# # activeEntity.remainingRoute.insert(0, [self.id, remainingProcessingTime])
# activeEntity.remainingRoute.insert(0, [self.id, remainingProcessingTime])
# activeEntity.remainingRoute.insert(0, {'stationIdsList':[str(self.lastGiver.id)],\
activeEntity
.
remainingRoute
.
insert
(
0
,
{
'stationIdsList'
:[
str
(
self
.
lastGiver
.
id
)],
\
# 'processingTime':\
'processingTime'
:
\
# {'distributionType':'Fixed',\
{
'distributionType'
:
'Fixed'
,
\
# 'mean':'0'}})
'mean'
:
'0'
}})
# # activeEntity.remainingRoute.insert(0, [self.lastGiver.id, 0])
# activeEntity.remainingRoute.insert(0, [self.lastGiver.id, 0])
# #set the receiver as the object where the active entity was preempted from
#set the receiver as the object where the active entity was preempted from
# self.receiver=self.lastGiver
self
.
receiver
=
self
.
lastGiver
# self.next=[self.receiver]
self
.
next
=
[
self
.
receiver
]
# self.waitToDispose=True #set that I have to dispose
self
.
waitToDispose
=
True
#set that I have to dispose
# self.receiver.timeLastEntityEnded=now() #required to count blockage correctly in the preemptied station
self
.
receiver
.
timeLastEntityEnded
=
now
()
#required to count blockage correctly in the preemptied station
# reactivate(self)
# TODO: use a signal and wait for it, reactivation is not recognised as interruption
reactivate
(
self
)
# TODO: consider the case when a failure has the Station down. The event preempt will not be received now()
# but at a later simulation time.
#===========================================================================
#===========================================================================
# extend the default behaviour to check if whether the station
# extend the default behaviour to check if whether the station
...
...
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