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
c6718658
Commit
c6718658
authored
Sep 15, 2014
by
Ioannis Papagiannopoulos
Committed by
Georgios Dagkakis
Nov 17, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
checkForManualOperation method added added to MachineJobShop. Clean-up and corrections
parent
000d766c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
124 deletions
+40
-124
dream/simulation/MachineJobShop.py
dream/simulation/MachineJobShop.py
+40
-124
No files found.
dream/simulation/MachineJobShop.py
View file @
c6718658
...
@@ -31,18 +31,7 @@ from RandomNumberGenerator import RandomNumberGenerator
...
@@ -31,18 +31,7 @@ from RandomNumberGenerator import RandomNumberGenerator
# ===========================================================================
# ===========================================================================
# the MachineJobShop object
# the MachineJobShop object
# ===========================================================================
# ===========================================================================
class
MachineJobShop
(
Machine
):
class
MachineJobShop
(
Machine
):
@
staticmethod
def
getOperationTime
(
time
):
'''returns the processingTime dictionary updated'''
if
not
time
:
time
=
{
'distributionType'
:
'Fixed'
,
'mean'
:
0
,
}
if
time
[
'distributionType'
]
==
'Normal'
and
\
time
.
get
(
'max'
,
None
)
is
None
:
time
[
'max'
]
=
float
(
time
[
'mean'
])
+
5
*
float
(
time
[
'stdev'
])
return
time
# =======================================================================
# =======================================================================
# set all the objects in previous and next
# set all the objects in previous and next
# =======================================================================
# =======================================================================
...
@@ -52,89 +41,25 @@ class MachineJobShop(Machine):
...
@@ -52,89 +41,25 @@ class MachineJobShop(Machine):
self
.
next
=
[]
self
.
next
=
[]
Machine
.
initialize
(
self
)
#run default behaviour
Machine
.
initialize
(
self
)
#run default behaviour
# # =======================================================================
# # actions to be carried out when the processing of an Entity ends
# # =======================================================================
# def endProcessingActions(self):
# # set isProcessing to False
# self.isProcessing=False
# # add working time
# self.totalWorkingTime+=self.env.now-self.timeLastProcessingStarted
#
# # blocking starts
# self.isBlocked=True
# self.timeLastBlockageStarted=self.env.now
#
# activeObject=self.getActiveObject()
# activeObjectQueue=activeObject.Res.users
# activeEntity=activeObjectQueue[0]
# # self.printTrace(activeEntity.name,processEnd=activeObject.objName)
# # reset the variables used to handle the interruptions timing
# # self.timeRestartingProcessing=0
# self.breakTime=0
# # output to trace that the processing in the Machine self.objName ended
# try:
# activeObject.outputTrace(activeEntity.name,"ended processing in "+activeObject.objName)
# except IndexError:
# pass
#
# import Globals
# from Globals import G
# # the entity that just got processed is cold again it will get
# # hot again by the time it reaches the giver of the next machine
# # TODO: Not only Machines require time to process entities
# if activeEntity.family=='Job':
# # read the list of next stations for the entity in just finished processing
# nextObjectIds=activeEntity.remainingRoute[0].get('stationIdsList',[])
# nextObjects = []
# for nextObjectId in nextObjectIds:
# nextObject=Globals.findObjectById(nextObjectId)
# nextObjects.append(nextObject)
# successorsAreMachines=True
# for object in nextObjects:
# if not object in G.MachineList:
# successorsAreMachines=False
# break
# if not successorsAreMachines:
# activeObjectQueue[0].hot = False
# # the just processed entity is added to the list of entities
# # pending for the next processing
# G.pendingEntities.append(activeObjectQueue[0])
# # set the variable that flags an Entity is ready to be disposed
# activeObject.waitToDispose=True
# #do this so that if it is overtime working it is not counted as off-shift time
# if not activeObject.onShift:
# activeObject.timeLastShiftEnded=self.env.now
# # update the variables keeping track of Entity related attributes of the machine
# activeObject.timeLastEntityEnded=self.env.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.completedJobs+=1 # Machine completed one more Job
# # reset flags
# self.shouldPreempt=False
# self.isProcessingInitialWIP=False
#
# # TODO: collapse that to Machine
# =======================================================================
# =======================================================================
# gets an entity from the predecessor that the predecessor index points to
# gets an entity from the predecessor that the predecessor index points to
# =======================================================================
# =======================================================================
def
getEntity
(
self
):
def
getEntity
(
self
):
activeObject
=
self
.
getActiveObject
()
activeObject
=
self
.
getActiveObject
()
activeEntity
=
Machine
.
getEntity
(
self
)
#run the default code
activeEntity
=
Machine
.
getEntity
(
self
)
#run the default code
# read the processing time from the corresponding remainingRoute entry
# read the processing/setup/load times from the corresponding remainingRoute entry
processingTime
=
activeEntity
.
remainingRoute
[
0
].
get
(
'processingTime'
,{})
processingTime
=
activeEntity
.
remainingRoute
[
0
].
get
(
'processingTime'
,{})
processingTime
=
self
.
getOperationTime
(
processingTime
)
processingTime
=
self
.
getOperationTime
(
processingTime
)
self
.
rng
=
RandomNumberGenerator
(
self
,
**
processingTime
)
self
.
rng
=
RandomNumberGenerator
(
self
,
**
processingTime
)
self
.
procTime
=
self
.
rng
.
generateNumber
()
self
.
procTime
=
self
.
rng
.
generateNumber
()
# check if there is a need for manual processing
self
.
checkForManualOperation
(
type
=
'Processing'
,
entity
=
activeEntity
)
# read the setup time from the corresponding remainingRoute entry
setupTime
=
activeEntity
.
remainingRoute
[
0
].
get
(
'setupTime'
,{})
setupTime
=
activeEntity
.
remainingRoute
[
0
].
get
(
'setupTime'
,{})
setupTime
=
self
.
getOperationTime
(
setupTime
)
setupTime
=
self
.
getOperationTime
(
setupTime
)
self
.
stpRng
=
RandomNumberGenerator
(
self
,
**
setupTime
)
self
.
stpRng
=
RandomNumberGenerator
(
self
,
**
setupTime
)
# # update the multOperationTypeList according to the needs of the received entity
# check if there is a need for manual processing
# self.readActiveOperationTypes(entity)
self
.
checkForManualOperation
(
type
=
'Setup'
,
entity
=
activeEntity
)
removedStep
=
activeEntity
.
remainingRoute
.
pop
(
0
)
#remove data from the remaining route of the entity
removedStep
=
activeEntity
.
remainingRoute
.
pop
(
0
)
#remove data from the remaining route of the entity
return
activeEntity
return
activeEntity
...
@@ -166,13 +91,13 @@ class MachineJobShop(Machine):
...
@@ -166,13 +91,13 @@ class MachineJobShop(Machine):
def
calculateProcessingTime
(
self
):
def
calculateProcessingTime
(
self
):
# this is only for processing of the initial wip
# this is only for processing of the initial wip
if
self
.
isProcessingInitialWIP
:
if
self
.
isProcessingInitialWIP
:
# read the processing
/setup/load times
from the first entry of the full route
# read the processing
time
from the first entry of the full route
activeEntity
=
self
.
getActiveObjectQueue
()[
0
]
activeEntity
=
self
.
getActiveObjectQueue
()[
0
]
processingTime
=
activeEntity
.
route
[
0
].
get
(
'processingTime'
,{})
processingTime
=
activeEntity
.
route
[
0
].
get
(
'processingTime'
,{})
processingTime
=
self
.
getOperationTime
(
processingTime
)
processingTime
=
self
.
getOperationTime
(
processingTime
)
self
.
rng
=
RandomNumberGenerator
(
self
,
**
processingTime
)
self
.
rng
=
RandomNumberGenerator
(
self
,
**
processingTime
)
self
.
procTime
=
self
.
rng
.
generateNumber
()
self
.
procTime
=
self
.
rng
.
generateNumber
()
# read the setup time from the corresponding remainingRoute entry
setupTime
=
activeEntity
.
route
[
0
].
get
(
'setupTime'
,{})
setupTime
=
activeEntity
.
route
[
0
].
get
(
'setupTime'
,{})
setupTime
=
self
.
getOperationTime
(
setupTime
)
setupTime
=
self
.
getOperationTime
(
setupTime
)
self
.
stpRng
=
RandomNumberGenerator
(
self
,
**
setupTime
)
self
.
stpRng
=
RandomNumberGenerator
(
self
,
**
setupTime
)
...
@@ -202,9 +127,6 @@ class MachineJobShop(Machine):
...
@@ -202,9 +127,6 @@ class MachineJobShop(Machine):
#===========================================================================
#===========================================================================
# method used to check whether the station is in the entity-to-be-received route
# method used to check whether the station is in the entity-to-be-received route
# TODO: consider giving the activeEntity as attribute
# TODO: consider the case when no caller is defined,
# postProcessing calls canAccept on next members with no arguments
#===========================================================================
#===========================================================================
def
isInRoute
(
self
,
callerObject
=
None
):
def
isInRoute
(
self
,
callerObject
=
None
):
activeObjectQueue
=
self
.
Res
.
users
activeObjectQueue
=
self
.
Res
.
users
...
@@ -239,8 +161,8 @@ class MachineJobShop(Machine):
...
@@ -239,8 +161,8 @@ class MachineJobShop(Machine):
return
len
(
activeObjectQueue
)
>
0
\
return
len
(
activeObjectQueue
)
>
0
\
and
self
.
waitToDispose
\
and
self
.
waitToDispose
\
and
self
.
checkIfActive
()
\
and
self
.
checkIfActive
()
\
and
(
thecaller
in
self
.
next
)
\
and
thecaller
.
isInRoute
(
self
)
and
thecaller
.
isInRoute
(
self
)
# and (thecaller in self.next)
# =======================================================================
# =======================================================================
# method to execute preemption
# method to execute preemption
...
@@ -299,42 +221,42 @@ class MachineJobShop(Machine):
...
@@ -299,42 +221,42 @@ class MachineJobShop(Machine):
thecaller
=
callerObject
thecaller
=
callerObject
thecaller
.
sortEntities
()
thecaller
.
sortEntities
()
activeEntity
=
thecaller
.
Res
.
users
[
0
]
activeEntity
=
thecaller
.
Res
.
users
[
0
]
# read the load time from the corresponding remainingRoute entry
loadTime
=
activeEntity
.
remainingRoute
[
0
].
get
(
'loadTime'
,{})
loadTime
=
activeEntity
.
remainingRoute
[
0
].
get
(
'loadTime'
,{})
loadTime
=
self
.
getOperationTime
(
loadTime
)
loadTime
=
self
.
getOperationTime
(
loadTime
)
self
.
loadRng
=
RandomNumberGenerator
(
self
,
**
loadTime
)
self
.
loadRng
=
RandomNumberGenerator
(
self
,
**
loadTime
)
#===========================================================================
#===========================================================================
# to be called by getEntity.
# get the initial operationTypes (Setup/Processing) : manual or automatic
# it must be specified if the currentEntity requires manual setup/processing
#===========================================================================
#===========================================================================
def
readActiveOperationTypes
(
self
,
entity
):
def
checkInitialOperationTypes
(
self
):
activeEntity
=
entity
# check if manual Setup is required
# flag to notify whether the entity defined manual or automatic operation
self
.
checkForManualOperation
(
type
=
'Setup'
)
self
.
entityDefiningOperation
=
False
# check if manual Processing is required
# read the definition of the setupTime from the remainingRoute dict
self
.
checkForManualOperation
(
type
=
'Processing'
)
setupTime
=
activeEntity
.
remainingRoute
[
0
].
get
(
'setupTime'
,{})
setupOpType
=
setupTime
.
get
(
'operationType'
,
'not defined'
)
#===========================================================================
# if the setupOpType is 'not defined'
# check if the operation defined as an argument requires manual operation
if
setupOpType
!=
'not defined'
:
#===========================================================================
# the multOperationTypeList must be cleared by the entity is removed
def
checkForManualOperation
(
self
,
type
,
entity
=
None
):
self
.
entityDefiningOperation
=
True
assert
type
!=
None
,
'a type must be defined for the checkForManualOperation method'
# add setup to the multOpeartionTypeList
if
not
entity
:
if
not
'Setup'
in
self
.
multOperationTypeList
:
activeEntity
=
self
.
getActiveObjectQueue
()[
0
]
self
.
multOperationTypeList
.
append
(
'Setup'
)
else
:
# find out if the setup operation type is automatic or manual
activeEntity
=
entity
if
setupOpType
:
# read the definition of the time from the remainingRoute dict
pass
time
=
activeEntity
.
remainingRoute
[
0
].
get
(
str
(
type
),{})
operationType
=
time
.
get
(
'operationType'
,
'not defined'
)
#
read the definition of the processingTime from the remainingRoute dict
#
if the operationType is not 'not defined'
procTime
=
activeEntity
.
remainingRoute
[
0
].
get
(
'processingTime'
,{})
if
operationType
!=
'not defined'
:
procOpType
=
setupTime
.
get
(
'operationType'
,
'not defined'
)
# if the operationType key has value 1 (manual operation
)
# if the procOpType is 'not defined'
if
operationType
:
if
procOpType
!=
'not defined'
:
# add setup to the multOpeartionTypeList
# the multOperationTypeList must be cleared by the entity is removed
if
not
type
in
self
.
multOperationTypeList
:
self
.
entityDefiningOperation
=
True
self
.
multOperationTypeList
.
append
(
str
(
type
))
# find out if the processing type is manual or automatic
else
:
# otherwise remove it from the multOperationTypeList
if
procOpType
and
not
'Processing'
in
self
.
multOperationTypeList
:
if
type
in
self
.
multOperationTypeList
:
self
.
multOperationTypeList
.
append
(
'Processing'
)
self
.
multOperationTypeList
.
remove
(
str
(
type
)
)
# =======================================================================
# =======================================================================
# removes an entity from the Machine
# removes an entity from the Machine
...
@@ -352,12 +274,6 @@ class MachineJobShop(Machine):
...
@@ -352,12 +274,6 @@ class MachineJobShop(Machine):
# if not entity had the same receiver then the receiver will be removed
# if not entity had the same receiver then the receiver will be removed
if
removeReceiver
:
if
removeReceiver
:
self
.
next
.
remove
(
receiverObject
)
self
.
next
.
remove
(
receiverObject
)
# if self.entityDefiningOperation:
# # reset the multOperationTypeList
# if 'Processing' in self.multOperationTypeList:
# self.multOperationTypeList.remove('Processing')
# if 'Setup' in self.multOperationTypeList:
# self.multOperationTypeList.remove('Setup')
return
activeEntity
return
activeEntity
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