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
6981dad9
Commit
6981dad9
authored
Jun 04, 2014
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
replace simpy2 by their simpy3 equivalents
parent
82b4b0d3
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
50 additions
and
53 deletions
+50
-53
dream/simulation/BatchDecompositionStartTime.py
dream/simulation/BatchDecompositionStartTime.py
+2
-3
dream/simulation/ConditionalBuffer.py
dream/simulation/ConditionalBuffer.py
+1
-2
dream/simulation/Frame.py
dream/simulation/Frame.py
+2
-2
dream/simulation/M3.py
dream/simulation/M3.py
+0
-1
dream/simulation/OperatedMachine.py
dream/simulation/OperatedMachine.py
+43
-42
dream/simulation/OperatorPreemptive.py
dream/simulation/OperatorPreemptive.py
+1
-2
dream/simulation/OperatorRouter.py
dream/simulation/OperatorRouter.py
+1
-1
No files found.
dream/simulation/BatchDecompositionStartTime.py
View file @
6981dad9
...
...
@@ -27,7 +27,6 @@ Custom object. Maybe we should have a generic method that the objects can call i
'''
from
BatchDecomposition
import
BatchDecomposition
from
SimPy.Simulation
import
now
class
BatchDecompositionStartTime
(
BatchDecomposition
):
...
...
@@ -35,7 +34,7 @@ class BatchDecompositionStartTime(BatchDecomposition):
#gets an entity from the predecessor
def getEntity(self):
activeEntity=BatchDecomposition.getEntity(self)
activeEntity.startTime=
now()
activeEntity.startTime=
self.env.now
return activeEntity
'''
...
...
@@ -45,6 +44,6 @@ class BatchDecompositionStartTime(BatchDecomposition):
# assign it as the batch start time
if
len
(
self
.
getActiveObjectQueue
())
==
self
.
numberOfSubBatches
:
batch
=
self
.
getActiveObjectQueue
()[
0
].
parentBatch
batch
.
startTime
=
now
()
batch
.
startTime
=
self
.
env
.
now
activeEntity
=
BatchDecomposition
.
removeEntity
(
self
,
entity
)
return
activeEntity
dream/simulation/ConditionalBuffer.py
View file @
6981dad9
...
...
@@ -26,7 +26,6 @@ Inherits from QueueManagedJob. Checks the condition of (a) component(s) before i
'''
from
QueueManagedJob
import
QueueManagedJob
from
SimPy.Simulation
import
now
# ===========================================================================
# Error in the setting up of the WIP
...
...
dream/simulation/Frame.py
View file @
6981dad9
...
...
@@ -26,7 +26,7 @@ Created on 18 Feb 2013
models a frame entity. This can flow through the system and carry parts
'''
from
SimPy.Simulation
import
Resource
from
simpy
import
Resource
from
Globals
import
G
from
Entity
import
Entity
...
...
@@ -45,4 +45,4 @@ class Frame(Entity):
self
.
lenght
=
2.0
def
getFrameQueue
(
self
):
return
self
.
Res
.
activeQ
return
self
.
Res
.
users
dream/simulation/M3.py
View file @
6981dad9
...
...
@@ -28,7 +28,6 @@ BatchScrapMachine->BatchDecomposition
'''
from
BatchScrapMachine
import
BatchScrapMachine
from
SimPy.Simulation
import
now
class
M3
(
BatchScrapMachine
):
...
...
dream/simulation/OperatedMachine.py
View file @
6981dad9
...
...
@@ -25,8 +25,8 @@ Created on 22 Nov 2012
Models a machine that can also have failures
'''
from
SimPy.Simulation
import
Process
,
Resource
from
SimPy.Simulation
import
activate
,
passivate
,
waituntil
,
now
,
hold
,
request
,
release
# XXX
#from SimPy.Simulation import activate, passivate, waituntil
, hold, request, release
from
Failure
import
Failure
# from CoreObject import CoreObject
...
...
@@ -157,19 +157,19 @@ class OperatedMachine(Machine):
# when it's ready to accept (canAcceptAndIsRequested) then inform the broker
# machines waits to be operated (waits for the operator)
self
.
requestOperator
()
self
.
timeWaitForLoadOperatorStarted
=
now
()
self
.
timeWaitForLoadOperatorStarted
=
self
.
env
.
now
# wait until the Broker has waited times equal to loadTime (if any)
yield
waituntil
,
self
,
self
.
broker
.
brokerIsSet
self
.
timeWaitForLoadOperatorEnded
=
now
()
self
.
timeWaitForLoadOperatorEnded
=
self
.
env
.
now
self
.
loadOperatorWaitTimeCurrentEntity
+=
self
.
timeWaitForLoadOperatorEnded
-
self
.
timeWaitForLoadOperatorStarted
self
.
totalTimeWaitingForLoadOperator
+=
self
.
loadOperatorWaitTimeCurrentEntity
# ======= Load the machine if the Load is defined as one of the Operators' operation types
if
any
(
type
==
"Load"
for
type
in
self
.
multOperationTypeList
)
and
self
.
isOperated
():
self
.
timeLoadStarted
=
now
()
self
.
timeLoadStarted
=
self
.
env
.
now
yield
hold
,
self
,
self
.
calculateLoadTime
()
# if self.interrupted(): There is the issue of failure during the Loading
self
.
timeLoadEnded
=
now
()
self
.
timeLoadEnded
=
self
.
env
.
now
self
.
loadTimeCurrentEntity
=
self
.
timeLoadEnded
-
self
.
timeLoadStarted
self
.
totalLoadTime
+=
self
.
loadTimeCurrentEntity
...
...
@@ -192,10 +192,10 @@ class OperatedMachine(Machine):
# set the currentEntity as the Entity just received and initialize the timer timeLastEntityEntered
self
.
nameLastEntityEntered
=
self
.
currentEntity
.
name
# this holds the name of the last entity that got into Machine
self
.
timeLastEntityEntered
=
now
()
#this holds the last time that an entity got into Machine
self
.
timeLastEntityEntered
=
self
.
env
.
now
#this holds the last time that an entity got into Machine
# variables dedicated to hold the processing times, the time when the Entity entered,
# and the processing time left
timeEntered
=
now
()
# timeEntered dummy Timer that holds the time the last Entity Entered
timeEntered
=
self
.
env
.
now
# timeEntered dummy Timer that holds the time the last Entity Entered
# ======= request a resource if it is not already assigned an Operator
if
(
self
.
operatorPool
!=
"None"
)
\
...
...
@@ -204,10 +204,10 @@ class OperatedMachine(Machine):
# when it's ready to accept (canAcceptAndIsRequested) then inform the broker
# machines waits to be operated (waits for the operator)
self
.
requestOperator
()
self
.
timeWaitForOperatorStarted
=
now
()
self
.
timeWaitForOperatorStarted
=
self
.
env
.
now
# wait until the Broker has waited times equal to loadTime (if any)
yield
waituntil
,
self
,
self
.
broker
.
brokerIsSet
self
.
timeWaitForOperatorEnded
=
now
()
self
.
timeWaitForOperatorEnded
=
self
.
env
.
now
self
.
operatorWaitTimeCurrentEntity
+=
self
.
timeWaitForOperatorEnded
-
self
.
timeWaitForOperatorStarted
...
...
@@ -217,10 +217,10 @@ class OperatedMachine(Machine):
# ======= 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
if
any
(
type
==
"Setup"
for
type
in
self
.
multOperationTypeList
)
and
self
.
isOperated
():
self
.
timeSetupStarted
=
now
()
self
.
timeSetupStarted
=
self
.
env
.
now
yield
hold
,
self
,
self
.
calculateSetupTime
()
# if self.interrupted(): There is the issue of failure during the setup
self
.
timeSetupEnded
=
now
()
self
.
timeSetupEnded
=
self
.
env
.
now
self
.
setupTimeCurrentEntity
=
self
.
timeSetupEnded
-
self
.
timeSetupStarted
self
.
totalSetupTime
+=
self
.
setupTimeCurrentEntity
...
...
@@ -232,7 +232,7 @@ class OperatedMachine(Machine):
# after getting the entity release the operator
# machine has to release the operator
self
.
releaseOperator
()
# print self.objName, 'operator released',
now()
# print self.objName, 'operator released',
self.env.now
# wait until the Broker has finished processing
yield
waituntil
,
self
,
self
.
broker
.
brokerIsSet
...
...
@@ -249,7 +249,7 @@ class OperatedMachine(Machine):
while
processingEndedFlag
:
# tBefore : dummy variable to keep track of the time that the processing starts after
# every interruption
tBefore
=
now
()
tBefore
=
self
.
env
.
now
# wait for the processing time left tinM, if no interruption occurs then change the
# processingEndedFlag and exit loop,
# else (if interrupted()) set interruption flag to true (only if tinM==0),
...
...
@@ -260,7 +260,7 @@ class OperatedMachine(Machine):
# output to trace that the Machine (self.objName) got interrupted
self
.
outputTrace
(
self
.
getActiveObjectQueue
()[
0
].
name
,
"Interrupted at "
+
self
.
objName
)
# recalculate the processing time left tinM
tinM
=
tinM
-
(
now
()
-
tBefore
)
tinM
=
tinM
-
(
self
.
env
.
now
-
tBefore
)
if
(
tinM
==
0
):
# sometimes the failure may happen exactly at the time that the processing would finish
# this may produce disagreement with the simul8 because in both SimPy and Simul8
# it seems to be random which happens 1st
...
...
@@ -268,34 +268,35 @@ class OperatedMachine(Machine):
interruption
=
True
# passivate the Machine for as long as there is no repair
# start counting the down time at breatTime dummy variable
breakTime
=
now
()
# dummy variable that the interruption happened
breakTime
=
self
.
env
.
now
# dummy variable that the interruption happened
# =============== release the operator if there is failure
if
(
self
.
operatorPool
!=
"None"
)
\
and
self
.
isOperated
()
\
and
any
(
type
==
"Processing"
for
type
in
self
.
multOperationTypeList
):
self
.
releaseOperator
()
# print self.objName, 'operator released due to failure',
now()
# print self.objName, 'operator released due to failure',
self.env.now
yield
waituntil
,
self
,
self
.
broker
.
brokerIsSet
# if there is a failure in the machine it is passivated
yield
passivate
,
self
# use the timers to count the time that Machine is down and related
self
.
downTimeProcessingCurrentEntity
+=
now
()
-
breakTime
# count the time that Machine is down while processing this Entity
self
.
downTimeInCurrentEntity
+=
now
()
-
breakTime
# count the time that Machine is down while on currentEntity
self
.
timeLastFailureEnded
=
now
()
# set the timeLastFailureEnded
failureTime
+=
now
()
-
breakTime
# dummy variable keeping track of the failure time
self
.
downTimeProcessingCurrentEntity
+=
self
.
env
.
now
-
breakTime
# count the time that Machine is down while processing this Entity
self
.
downTimeInCurrentEntity
+=
self
.
env
.
now
-
breakTime
# count the time that Machine is down while on currentEntity
self
.
timeLastFailureEnded
=
self
.
env
.
now
# set the timeLastFailureEnded
failureTime
+=
self
.
env
.
now
-
breakTime
# dummy variable keeping track of the failure time
# output to trace that the Machine self.objName was passivated for the current failure time
self
.
outputTrace
(
self
.
getActiveObjectQueue
()[
0
].
name
,
"passivated in "
+
self
.
objName
+
" for "
+
str
(
now
()
-
breakTime
))
self
.
outputTrace
(
self
.
getActiveObjectQueue
()[
0
].
name
,
"passivated in "
+
self
.
objName
+
" for "
+
str
(
self
.
env
.
now
-
breakTime
))
# =============== request a resource after the repair
if
(
self
.
operatorPool
!=
"None"
)
\
and
any
(
type
==
"Processing"
for
type
in
self
.
multOperationTypeList
)
\
and
not
interruption
:
self
.
timeWaitForOperatorStarted
=
now
()
self
.
timeWaitForOperatorStarted
=
self
.
env
.
now
self
.
requestOperator
()
yield
waituntil
,
self
,
self
.
broker
.
brokerIsSet
self
.
timeWaitForOperatorEnded
=
now
()
self
.
timeWaitForOperatorEnded
=
self
.
env
.
now
self
.
operatorWaitTimeCurrentEntity
+=
self
.
timeWaitForOperatorEnded
-
self
.
timeWaitForOperatorStarted
# if no interruption occurred the processing in M1 is ended
...
...
@@ -319,7 +320,7 @@ class OperatedMachine(Machine):
# is what the distribution initially gave
# update the variables keeping track of Entity related attributes of the machine
self
.
timeLastEntityEnded
=
now
()
# this holds the time that the last entity ended processing in Machine
self
.
timeLastEntityEnded
=
self
.
env
.
now
# this holds the time that the last entity ended processing in Machine
self
.
nameLastEntityEnded
=
self
.
currentEntity
.
name
# this holds the name of the last entity that ended processing in Machine
self
.
completedJobs
+=
1
# Machine completed one more Job
# re-initialize the downTimeProcessingCurrentEntity.
...
...
@@ -327,7 +328,7 @@ class OperatedMachine(Machine):
self
.
downTimeProcessingCurrentEntity
=
0
# dummy variable requests the successor object now
reqTime
=
now
()
# entity has ended processing in Machine and requests for the next object
reqTime
=
self
.
env
.
now
# entity has ended processing in Machine and requests for the next object
# initialize the timer downTimeInTryingToReleaseCurrentEntity, we have to count how much time
# the Entity will wait for the next successor to be able to accept (canAccept)
self
.
downTimeInTryingToReleaseCurrentEntity
=
0
...
...
@@ -341,21 +342,21 @@ class OperatedMachine(Machine):
break
# if M1 had failure, we want to wait until it is fixed and also count the failure time.
else
:
failTime
=
now
()
# dummy variable holding the time failure happened
failTime
=
self
.
env
.
now
# dummy variable holding the time failure happened
# passivate until machine is up
yield
waituntil
,
self
,
self
.
checkIfMachineIsUp
failureTime
+=
now
()
-
failTime
# count the failure while on current entity time with failureTime variable
failureTime
+=
self
.
env
.
now
-
failTime
# count the failure while on current entity time with failureTime variable
# calculate the time the Machine was down while trying to dispose the current Entity,
# and the total down time while on current Entity
self
.
downTimeInTryingToReleaseCurrentEntity
+=
now
()
-
failTime
self
.
downTimeInCurrentEntity
+=
now
()
-
failTime
# already updated from failures during processing
self
.
downTimeInTryingToReleaseCurrentEntity
+=
self
.
env
.
now
-
failTime
self
.
downTimeInCurrentEntity
+=
self
.
env
.
now
-
failTime
# already updated from failures during processing
# update the timeLastFailureEnded
self
.
timeLastFailureEnded
=
now
()
self
.
timeLastFailureEnded
=
self
.
env
.
now
# dummy variable holding the total time the Entity spent in the Machine
# count the time the Machine was blocked subtracting the failureTime
# and the processing time from the totalTime spent in the Machine
self
.
totalTimeInCurrentEntity
=
now
()
-
timeEntered
self
.
totalTimeInCurrentEntity
=
self
.
env
.
now
-
timeEntered
# =======================================================================
# checks if the Machine can accept an entity
...
...
@@ -443,9 +444,9 @@ class OperatedMachine(Machine):
if
(
object
.
haveToDispose
(
activeObject
)):
# and not object.exitIsAssigned()):
isRequested
=
True
# if the possible giver has entities to dispose of
if
(
object
.
downTimeInTryingToReleaseCurrentEntity
>
0
):
# and the possible giver has been down while trying to give away the Entity
timeWaiting
=
now
()
-
object
.
timeLastFailureEnded
# the timeWaiting dummy variable counts the time end of the last failure of the giver object
timeWaiting
=
self
.
env
.
now
-
object
.
timeLastFailureEnded
# the timeWaiting dummy variable counts the time end of the last failure of the giver object
else
:
timeWaiting
=
now
()
-
object
.
timeLastEntityEnded
# in any other case, it holds the time since the end of the Entity processing
timeWaiting
=
self
.
env
.
now
-
object
.
timeLastEntityEnded
# in any other case, it holds the time since the end of the Entity processing
#if more than one possible givers have to dispose take the part from the one that is blocked longer
if
(
timeWaiting
>=
maxTimeWaiting
):
...
...
@@ -540,9 +541,9 @@ class OperatedMachine(Machine):
if
(
len
(
activeObjectQueue
)
>
0
)
and
(
mightBeBlocked
)
\
and
((
activeObject
.
nameLastEntityEntered
==
activeObject
.
nameLastEntityEnded
)):
# be careful here, might have to reconsider
activeObject
.
totalBlockageTime
+=
now
()
-
(
activeObject
.
timeLastEntityEnded
+
activeObject
.
downTimeInTryingToReleaseCurrentEntity
)
activeObject
.
totalBlockageTime
+=
self
.
env
.
now
-
(
activeObject
.
timeLastEntityEnded
+
activeObject
.
downTimeInTryingToReleaseCurrentEntity
)
if
activeObject
.
Up
==
False
:
activeObject
.
totalBlockageTime
-=
now
()
-
activeObject
.
timeLastFailure
activeObject
.
totalBlockageTime
-=
self
.
env
.
now
-
activeObject
.
timeLastFailure
alreadyAdded
=
True
#if Machine is currently processing an entity we should count this working time
...
...
@@ -552,8 +553,8 @@ class OperatedMachine(Machine):
#if Machine is down we should add this last failure time to the time that it has been down in current entity
if
self
.
Up
==
False
:
# if(len(activeObjectQueue)>0) and (self.Up==False):
activeObject
.
downTimeProcessingCurrentEntity
+=
now
()
-
activeObject
.
timeLastFailure
activeObject
.
totalWorkingTime
+=
now
()
-
activeObject
.
timeLastEntityEntered
\
activeObject
.
downTimeProcessingCurrentEntity
+=
self
.
env
.
now
-
activeObject
.
timeLastFailure
activeObject
.
totalWorkingTime
+=
self
.
env
.
now
-
activeObject
.
timeLastEntityEntered
\
-
activeObject
.
downTimeProcessingCurrentEntity
\
-
activeObject
.
operatorWaitTimeCurrentEntity
\
-
activeObject
.
setupTimeCurrentEntity
...
...
@@ -563,18 +564,18 @@ class OperatedMachine(Machine):
and
(
activeObject
.
currentOperator
==
None
):
# needs further research as the time of failure while waiting for operator is not counted yet
if
self
.
Up
==
False
:
activeObject
.
downTimeProcessingCurrentEntity
+=
now
()
-
activeObject
.
timeLastFailure
activeObject
.
totalTimeWaitingForOperator
+=
now
()
-
activeObject
.
timeWaitForOperatorStarted
\
activeObject
.
downTimeProcessingCurrentEntity
+=
self
.
env
.
now
-
activeObject
.
timeLastFailure
activeObject
.
totalTimeWaitingForOperator
+=
self
.
env
.
now
-
activeObject
.
timeWaitForOperatorStarted
\
-
activeObject
.
downTimeProcessingCurrentEntity
# if Machine is down we have to add this failure time to its total failure time
# we also need to add the last blocking time to total blockage time
if
(
activeObject
.
Up
==
False
):
activeObject
.
totalFailureTime
+=
now
()
-
activeObject
.
timeLastFailure
activeObject
.
totalFailureTime
+=
self
.
env
.
now
-
activeObject
.
timeLastFailure
# we add the value only if it hasn't already been added
#if((len(self.next[0].Res.activeQ)>0) and (self.nameLastEntityEnded==self.nameLastEntityEntered) and (not alreadyAdded)):
if
((
mightBeBlocked
)
and
(
activeObject
.
nameLastEntityEnded
==
activeObject
.
nameLastEntityEntered
)
and
(
not
alreadyAdded
)):
activeObject
.
totalBlockageTime
+=
(
now
()
-
activeObject
.
timeLastEntityEnded
)
-
(
now
()
-
activeObject
.
timeLastFailure
)
-
activeObject
.
downTimeInTryingToReleaseCurrentEntity
activeObject
.
totalBlockageTime
+=
(
self
.
env
.
now
-
activeObject
.
timeLastEntityEnded
)
-
(
self
.
env
.
now
-
activeObject
.
timeLastFailure
)
-
activeObject
.
downTimeInTryingToReleaseCurrentEntity
#Machine was idle when it was not in any other state
activeObject
.
totalWaitingTime
=
MaxSimtime
-
activeObject
.
totalWorkingTime
-
activeObject
.
totalBlockageTime
-
activeObject
.
totalFailureTime
...
...
dream/simulation/OperatorPreemptive.py
View file @
6981dad9
...
...
@@ -28,7 +28,6 @@ he checks if the operation that calls him is of higher priority than the one
that he is currently in.
'''
from
SimPy.Simulation
import
Resource
,
now
from
Operator
import
Operator
# ===========================================================================
...
...
@@ -94,7 +93,7 @@ class OperatorPreemptive(Operator):
# then the receiver must be preemptied before it can receive any entities from the calerObject
victim
.
shouldPreempt
=
True
victim
.
preempt
()
victim
.
timeLastEntityEnded
=
now
()
#required to count blockage correctly in the preemptied station
victim
.
timeLastEntityEnded
=
self
.
env
.
now
#required to count blockage correctly in the preemptied station
return
True
# if the entity has no isCritical property then ran the default behaviour
except
:
...
...
dream/simulation/OperatorRouter.py
View file @
6981dad9
...
...
@@ -31,7 +31,7 @@ Models an Interruption that schedules the operation of the machines by different
import
simpy
from
ObjectInterruption
import
ObjectInterruption
from
SimPy.Simulation
import
waituntil
,
now
,
hold
,
request
,
release
,
waitevent
#
from SimPy.Simulation import waituntil, now, hold, request, release, waitevent
# ===========================================================================
...
...
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