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
302452f4
Commit
302452f4
authored
Apr 07, 2015
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
several changes
parent
d9d19ad4
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
42 additions
and
51 deletions
+42
-51
dream/simulation/CoreObject.py
dream/simulation/CoreObject.py
+1
-7
dream/simulation/Exit.py
dream/simulation/Exit.py
+3
-6
dream/simulation/Globals.py
dream/simulation/Globals.py
+1
-0
dream/simulation/LineGenerationJSON.py
dream/simulation/LineGenerationJSON.py
+2
-0
dream/simulation/ManPyObject.py
dream/simulation/ManPyObject.py
+4
-5
dream/simulation/PrintRoute.py
dream/simulation/PrintRoute.py
+26
-26
dream/simulation/Queue.py
dream/simulation/Queue.py
+3
-5
dream/simulation/Source.py
dream/simulation/Source.py
+2
-2
No files found.
dream/simulation/CoreObject.py
View file @
302452f4
...
@@ -69,9 +69,6 @@ class CoreObject(ManPyObject):
...
@@ -69,9 +69,6 @@ class CoreObject(ManPyObject):
# attributes/indices used for printing the route, hold the cols corresponding to the object (entities route and operators route)
# attributes/indices used for printing the route, hold the cols corresponding to the object (entities route and operators route)
self
.
station_col_inds
=
[]
self
.
station_col_inds
=
[]
self
.
op_col_indx
=
None
self
.
op_col_indx
=
None
# if there is input in a dictionary parse from it
from
Globals
import
ManPyEnvironment
G
.
ObjList
.
append
(
self
)
# add object to ObjList
# list of expected signals of a station (values can be used as flags to inform on which signals is the station currently yielding)
# list of expected signals of a station (values can be used as flags to inform on which signals is the station currently yielding)
self
.
expectedSignals
=
{
self
.
expectedSignals
=
{
"isRequested"
:
0
,
"isRequested"
:
0
,
...
@@ -93,8 +90,6 @@ class CoreObject(ManPyObject):
...
@@ -93,8 +90,6 @@ class CoreObject(ManPyObject):
self
.
WipStat
=
[]
self
.
WipStat
=
[]
def
initialize
(
self
):
def
initialize
(
self
):
from
Globals
import
ManPyEnvironment
self
.
env
=
G
.
env
self
.
Up
=
True
#Boolean that shows if the object is in failure ("Down") or not ("up")
self
.
Up
=
True
#Boolean that shows if the object is in failure ("Down") or not ("up")
self
.
onShift
=
True
self
.
onShift
=
True
self
.
onBreak
=
False
self
.
onBreak
=
False
...
@@ -618,8 +613,7 @@ class CoreObject(ManPyObject):
...
@@ -618,8 +613,7 @@ class CoreObject(ManPyObject):
# =======================================================================
# =======================================================================
def
postProcessing
(
self
,
MaxSimtime
=
None
):
def
postProcessing
(
self
,
MaxSimtime
=
None
):
if
MaxSimtime
==
None
:
if
MaxSimtime
==
None
:
from
Globals
import
ManPyEnvironment
MaxSimtime
=
self
.
environment
.
maxSimTime
MaxSimtime
=
G
.
maxSimTime
activeObject
=
self
.
getActiveObject
()
activeObject
=
self
.
getActiveObject
()
activeObjectQueue
=
self
.
getActiveObjectQueue
()
activeObjectQueue
=
self
.
getActiveObjectQueue
()
...
...
dream/simulation/Exit.py
View file @
302452f4
...
@@ -46,13 +46,12 @@ class Exit(CoreObject):
...
@@ -46,13 +46,12 @@ class Exit(CoreObject):
self
.
TaktTime
=
[]
self
.
TaktTime
=
[]
# if input is given in a dictionary
# if input is given in a dictionary
CoreObject
.
__init__
(
self
,
id
,
name
)
CoreObject
.
__init__
(
self
,
id
,
name
)
from
Globals
import
ManPyEnvironment
G
.
ExitList
.
append
(
self
)
self
.
cancelCondition
=
cancelCondition
self
.
cancelCondition
=
cancelCondition
def
initialize
(
self
):
def
initialize
(
self
):
# using the Process __init__ and not the CoreObject __init__
# using the Process __init__ and not the CoreObject __init__
CoreObject
.
initialize
(
self
)
CoreObject
.
initialize
(
self
)
self
.
environment
.
ExitList
.
append
(
self
)
# initialize the internal Queue (type Resource) of the Exit
# initialize the internal Queue (type Resource) of the Exit
self
.
Res
=
simpy
.
Resource
(
self
.
env
,
capacity
=
float
(
'inf'
))
self
.
Res
=
simpy
.
Resource
(
self
.
env
,
capacity
=
float
(
'inf'
))
...
@@ -153,9 +152,8 @@ class Exit(CoreObject):
...
@@ -153,9 +152,8 @@ class Exit(CoreObject):
# actions to be taken after the simulation ends
# actions to be taken after the simulation ends
# =======================================================================
# =======================================================================
def
postProcessing
(
self
,
MaxSimtime
=
None
):
def
postProcessing
(
self
,
MaxSimtime
=
None
):
from
Globals
import
ManPyEnvironment
if
MaxSimtime
==
None
:
if
MaxSimtime
==
None
:
MaxSimtime
=
G
.
maxSimTime
MaxSimtime
=
self
.
environment
.
maxSimTime
# hold the numberOfExits of each replication
# hold the numberOfExits of each replication
self
.
Exits
.
append
(
self
.
numOfExits
)
self
.
Exits
.
append
(
self
.
numOfExits
)
self
.
UnitExits
.
append
(
self
.
totalNumberOfUnitsExited
)
self
.
UnitExits
.
append
(
self
.
totalNumberOfUnitsExited
)
...
@@ -172,7 +170,6 @@ class Exit(CoreObject):
...
@@ -172,7 +170,6 @@ class Exit(CoreObject):
# outputs results to JSON File
# outputs results to JSON File
# =======================================================================
# =======================================================================
def
outputResultsJSON
(
self
):
def
outputResultsJSON
(
self
):
from
Globals
import
ManPyEnvironment
json
=
{
'_class'
:
'Dream.%s'
%
self
.
__class__
.
__name__
,
json
=
{
'_class'
:
'Dream.%s'
%
self
.
__class__
.
__name__
,
'id'
:
self
.
id
,
'id'
:
self
.
id
,
'family'
:
self
.
family
,
'family'
:
self
.
family
,
...
@@ -182,4 +179,4 @@ class Exit(CoreObject):
...
@@ -182,4 +179,4 @@ class Exit(CoreObject):
json
[
'results'
][
'takt_time'
]
=
self
.
TaktTime
json
[
'results'
][
'takt_time'
]
=
self
.
TaktTime
if
self
.
Exits
!=
self
.
UnitExits
:
#output this only if there was variability in units
if
self
.
Exits
!=
self
.
UnitExits
:
#output this only if there was variability in units
json
[
'results'
][
'unitsThroughput'
]
=
self
.
UnitExits
json
[
'results'
][
'unitsThroughput'
]
=
self
.
UnitExits
G
.
outputJSON
[
'elementList'
].
append
(
json
)
self
.
environment
.
outputJSON
[
'elementList'
].
append
(
json
)
dream/simulation/Globals.py
View file @
302452f4
...
@@ -117,6 +117,7 @@ class ManPyEnvironment(object):
...
@@ -117,6 +117,7 @@ class ManPyEnvironment(object):
self
.
env
=
simpy
.
Environment
()
self
.
env
=
simpy
.
Environment
()
self
.
totalPulpTime
=
0
# temporary to track how much time PuLP needs to run
self
.
totalPulpTime
=
0
# temporary to track how much time PuLP needs to run
self
.
SimPyEnvironment
=
simpy
.
Environment
()
# =======================================================================
# =======================================================================
# method to move entities exceeding a certain safety stock
# method to move entities exceeding a certain safety stock
...
...
dream/simulation/LineGenerationJSON.py
View file @
302452f4
...
@@ -219,7 +219,9 @@ def createObjectResourcesAndCoreObjects(environment,json_data):
...
@@ -219,7 +219,9 @@ def createObjectResourcesAndCoreObjects(environment,json_data):
inputDict
=
dict
(
element
)
inputDict
=
dict
(
element
)
# create the CoreObject
# create the CoreObject
coreObject
=
objectType
(
**
inputDict
)
coreObject
=
objectType
(
**
inputDict
)
coreObject
.
environment
=
environment
coreObject
.
env
=
environment
.
SimPyEnvironment
coreObject
.
env
=
environment
.
SimPyEnvironment
environment
.
ObjList
.
append
(
coreObject
)
# update the nextIDs list of the object
# update the nextIDs list of the object
coreObject
.
nextIds
=
getSuccessorList
(
element
[
'id'
])
coreObject
.
nextIds
=
getSuccessorList
(
element
[
'id'
])
# (Below is only for Dismantle for now)
# (Below is only for Dismantle for now)
...
...
dream/simulation/ManPyObject.py
View file @
302452f4
...
@@ -101,14 +101,14 @@ class ManPyObject(object):
...
@@ -101,14 +101,14 @@ class ManPyObject(object):
return
any
(
operator
.
skillsList
for
operator
in
G
.
OperatorsList
)
return
any
(
operator
.
skillsList
for
operator
in
G
.
OperatorsList
)
@
staticmethod
@
staticmethod
def
printTrace
(
entity
=
''
,
**
kw
):
def
printTrace
(
en
vironment
,
en
tity
=
''
,
**
kw
):
assert
len
(
kw
)
==
1
,
'only one phrase per printTrace supported for the moment'
assert
len
(
kw
)
==
1
,
'only one phrase per printTrace supported for the moment'
from
Globals
import
ManPyEnvironment
from
Globals
import
ManPyEnvironment
import
Globals
import
Globals
time
=
G
.
env
.
now
time
=
environment
.
env
.
now
charLimit
=
60
charLimit
=
60
remainingChar
=
charLimit
-
len
(
entity
)
-
len
(
str
(
time
))
remainingChar
=
charLimit
-
len
(
entity
)
-
len
(
str
(
time
))
if
(
G
.
console
==
'Yes'
):
if
(
environment
.
console
==
'Yes'
):
print
time
,
entity
,
print
time
,
entity
,
for
key
in
kw
:
for
key
in
kw
:
if
key
not
in
Globals
.
getSupportedPrintKwrds
():
if
key
not
in
Globals
.
getSupportedPrintKwrds
():
...
@@ -127,8 +127,7 @@ class ManPyObject(object):
...
@@ -127,8 +127,7 @@ class ManPyObject(object):
suffix
=
suffix
+
'>'
suffix
=
suffix
+
'>'
print
phrase
,
arg
,
suffix
print
phrase
,
arg
,
suffix
else
:
else
:
print
phrase
,
arg
print
phrase
,
arg
# =======================================================================
# =======================================================================
# outputs message to the trace.xls
# outputs message to the trace.xls
# 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)
...
...
dream/simulation/PrintRoute.py
View file @
302452f4
...
@@ -29,7 +29,7 @@ def getEventsList(objectsList=[]):
...
@@ -29,7 +29,7 @@ def getEventsList(objectsList=[]):
events_list
.
append
(
exit_time
)
events_list
.
append
(
exit_time
)
return
events_list
return
events_list
def
outputRoute
():
def
outputRoute
(
environment
):
'''
'''
prints the routes of the Jobs through the model as a table
prints the routes of the Jobs through the model as a table
the horizontal axis represents the different stations of the model
the horizontal axis represents the different stations of the model
...
@@ -54,53 +54,53 @@ def outputRoute():
...
@@ -54,53 +54,53 @@ def outputRoute():
# xx for each station allocate 2 rows and a 3rd one for operators
# xx for each station allocate 2 rows and a 3rd one for operators
if
G
.
trace
==
'Yes'
:
if
environment
.
trace
==
'Yes'
:
if
G
.
JobList
:
if
environment
.
JobList
:
G
.
routeSheetIndex
=
G
.
sheetIndex
+
1
environment
.
routeSheetIndex
=
environment
.
sheetIndex
+
1
# add one more sheet to the trace file
# add one more sheet to the trace file
G
.
routeTraceSheet
=
G
.
traceFile
.
add_sheet
(
'sheet '
+
str
(
G
.
routeSheetIndex
)
+
' route'
,
cell_overwrite_ok
=
True
)
environment
.
routeTraceSheet
=
environment
.
traceFile
.
add_sheet
(
'sheet '
+
str
(
environment
.
routeSheetIndex
)
+
' route'
,
cell_overwrite_ok
=
True
)
number_of_machines
=
len
(
G
.
MachineList
)
number_of_machines
=
len
(
environment
.
MachineList
)
sortMachines
()
# sort the machines according to the priority specified in JOB_SHOP_TECHNOLOGY_SEQ
sortMachines
()
# sort the machines according to the priority specified in JOB_SHOP_TECHNOLOGY_SEQ
# get the events list
# get the events list
G
.
events_list
=
getEventsList
(
G
.
JobList
+
G
.
OperatorsList
)
environment
.
events_list
=
getEventsList
(
environment
.
JobList
+
environment
.
OperatorsList
)
G
.
events_list
.
sort
(
cmp
=
None
,
key
=
None
,
reverse
=
False
)
# sort the events
environment
.
events_list
.
sort
(
cmp
=
None
,
key
=
None
,
reverse
=
False
)
# sort the events
number_of_events
=
len
(
G
.
events_list
)
# keep the total number of events
number_of_events
=
len
(
environment
.
events_list
)
# keep the total number of events
# create a table number_of_events X number_of_machines
# create a table number_of_events X number_of_machines
G
.
routeTraceSheet
.
write
(
0
,
0
,
'Time/Machines'
)
environment
.
routeTraceSheet
.
write
(
0
,
0
,
'Time/Machines'
)
# write the events in the first column and the machineIDs in the first row
# write the events in the first column and the machineIDs in the first row
for
j
,
event
in
enumerate
(
G
.
events_list
):
for
j
,
event
in
enumerate
(
environment
.
events_list
):
G
.
routeTraceSheet
.
write
(
j
+
1
,
0
,
float
(
event
))
environment
.
routeTraceSheet
.
write
(
j
+
1
,
0
,
float
(
event
))
# XXX create 3 times as many columns as the number of machines
# XXX create 3 times as many columns as the number of machines
for
j
,
machine
in
enumerate
(
G
.
MachineList
):
for
j
,
machine
in
enumerate
(
environment
.
MachineList
):
machine
.
station_col_inds
=
range
(
j
*
3
+
1
,
j
*
3
+
3
)
machine
.
station_col_inds
=
range
(
j
*
3
+
1
,
j
*
3
+
3
)
machine
.
op_col_indx
=
j
*
3
+
3
machine
.
op_col_indx
=
j
*
3
+
3
G
.
routeTraceSheet
.
write_merge
(
0
,
0
,
j
*
3
+
1
,
j
*
3
+
3
,
str
(
machine
.
id
))
environment
.
routeTraceSheet
.
write_merge
(
0
,
0
,
j
*
3
+
1
,
j
*
3
+
3
,
str
(
machine
.
id
))
# sort the jobs according to their name
# sort the jobs according to their name
G
.
JobList
.
sort
(
key
=
lambda
x
:
x
.
id
)
environment
.
JobList
.
sort
(
key
=
lambda
x
:
x
.
id
)
G
.
cells_to_write
=
[]
environment
.
cells_to_write
=
[]
for
job
in
G
.
JobList
:
for
job
in
environment
.
JobList
:
job
.
printRoute
()
job
.
printRoute
()
# list of cells to be written
# list of cells to be written
G
.
cells_to_write
=
[]
environment
.
cells_to_write
=
[]
# for every job in the JobList
# for every job in the JobList
for
worker
in
G
.
OperatorsList
:
for
worker
in
environment
.
OperatorsList
:
worker
.
printRoute
()
worker
.
printRoute
()
# reset list of cells to be written
# reset list of cells to be written
del
G
.
cells_to_write
[:]
del
environment
.
cells_to_write
[:]
del
G
.
events_list
[:]
del
environment
.
events_list
[:]
# print aliases
# print aliases
try
:
try
:
sample_job
=
next
(
x
for
x
in
G
.
JobList
)
sample_job
=
next
(
x
for
x
in
environment
.
JobList
)
if
sample_job
.
__class__
.
__name__
in
ORDER_COMPONENT_TYPE_SET
:
if
sample_job
.
__class__
.
__name__
in
ORDER_COMPONENT_TYPE_SET
:
G
.
JobList
.
sort
(
key
=
lambda
x
:
x
.
order
.
id
)
environment
.
JobList
.
sort
(
key
=
lambda
x
:
x
.
order
.
id
)
except
:
except
:
pass
pass
for
j
,
job
in
enumerate
(
G
.
JobList
):
for
j
,
job
in
enumerate
(
environment
.
JobList
):
if
job
.
schedule
:
if
job
.
schedule
:
G
.
routeTraceSheet
.
write
(
number_of_events
+
2
+
j
,
0
,
job
.
id
)
environment
.
routeTraceSheet
.
write
(
number_of_events
+
2
+
j
,
0
,
job
.
id
)
G
.
routeTraceSheet
.
write
(
number_of_events
+
2
+
j
,
1
,
job
.
alias
)
environment
.
routeTraceSheet
.
write
(
number_of_events
+
2
+
j
,
1
,
job
.
alias
)
\ No newline at end of file
dream/simulation/Queue.py
View file @
302452f4
...
@@ -66,8 +66,6 @@ class Queue(CoreObject):
...
@@ -66,8 +66,6 @@ class Queue(CoreObject):
if
level
:
if
level
:
assert
level
<=
self
.
capacity
,
"the level cannot be bigger than the capacity of the queue"
assert
level
<=
self
.
capacity
,
"the level cannot be bigger than the capacity of the queue"
self
.
level
=
level
self
.
level
=
level
from
Globals
import
ManPyEnvironment
G
.
QueueList
.
append
(
self
)
@
staticmethod
@
staticmethod
def
getSupportedSchedulingRules
():
def
getSupportedSchedulingRules
():
...
@@ -80,6 +78,7 @@ class Queue(CoreObject):
...
@@ -80,6 +78,7 @@ class Queue(CoreObject):
def
initialize
(
self
):
def
initialize
(
self
):
# using the Process __init__ and not the CoreObject __init__
# using the Process __init__ and not the CoreObject __init__
CoreObject
.
initialize
(
self
)
CoreObject
.
initialize
(
self
)
self
.
environment
.
QueueList
.
append
(
self
)
# initialise the internal Queue (type Resource) of the Queue object
# initialise the internal Queue (type Resource) of the Queue object
self
.
Res
=
simpy
.
Resource
(
self
.
env
,
self
.
capacity
)
self
.
Res
=
simpy
.
Resource
(
self
.
env
,
self
.
capacity
)
# event used by router
# event used by router
...
@@ -99,7 +98,7 @@ class Queue(CoreObject):
...
@@ -99,7 +98,7 @@ class Queue(CoreObject):
# check if there is WIP and signal receiver
# check if there is WIP and signal receiver
self
.
initialSignalReceiver
()
self
.
initialSignalReceiver
()
while
1
:
while
1
:
self
.
printTrace
(
self
.
id
,
waitEvent
=
''
)
self
.
printTrace
(
self
.
environment
,
self
.
id
,
waitEvent
=
''
)
# wait until the Queue can accept an entity and one predecessor requests it
# wait until the Queue can accept an entity and one predecessor requests it
self
.
expectedSignals
[
'canDispose'
]
=
1
self
.
expectedSignals
[
'canDispose'
]
=
1
self
.
expectedSignals
[
'isRequested'
]
=
1
self
.
expectedSignals
[
'isRequested'
]
=
1
...
@@ -322,11 +321,10 @@ class Queue(CoreObject):
...
@@ -322,11 +321,10 @@ class Queue(CoreObject):
assert
False
,
"Unknown scheduling criterion %r"
%
(
criterion
,
)
assert
False
,
"Unknown scheduling criterion %r"
%
(
criterion
,
)
def
outputResultsJSON
(
self
):
def
outputResultsJSON
(
self
):
from
Globals
import
ManPyEnvironment
json
=
{
'_class'
:
'Dream.%s'
%
self
.
__class__
.
__name__
,
json
=
{
'_class'
:
'Dream.%s'
%
self
.
__class__
.
__name__
,
'id'
:
str
(
self
.
id
),
'id'
:
str
(
self
.
id
),
'family'
:
self
.
family
,
'family'
:
self
.
family
,
'results'
:
{}
}
'results'
:
{}
}
if
self
.
gatherWipStat
:
if
self
.
gatherWipStat
:
json
[
'results'
][
'wip_stat_list'
]
=
self
.
WipStat
json
[
'results'
][
'wip_stat_list'
]
=
self
.
WipStat
G
.
outputJSON
[
'elementList'
].
append
(
json
)
self
.
environment
.
outputJSON
[
'elementList'
].
append
(
json
)
dream/simulation/Source.py
View file @
302452f4
...
@@ -42,9 +42,9 @@ class EntityGenerator(object):
...
@@ -42,9 +42,9 @@ class EntityGenerator(object):
# the __init__ method of the EntityGenerator
# the __init__ method of the EntityGenerator
#===========================================================================
#===========================================================================
def
__init__
(
self
,
victim
=
None
):
def
__init__
(
self
,
victim
=
None
):
self
.
env
=
G
.
env
self
.
type
=
"EntityGenerator"
#String that shows the type of object
self
.
type
=
"EntityGenerator"
#String that shows the type of object
self
.
victim
=
victim
self
.
victim
=
victim
self
.
env
=
victim
.
environment
.
SimPyEnvironment
#===========================================================================
#===========================================================================
# the generator of the EntitiesGenerator
# the generator of the EntitiesGenerator
...
@@ -101,7 +101,6 @@ class Source(CoreObject):
...
@@ -101,7 +101,6 @@ class Source(CoreObject):
self
.
scheduledEntities
=
[]
# list of creations that are scheduled. pattern is [timeOfCreation, EntityCounter]
self
.
scheduledEntities
=
[]
# list of creations that are scheduled. pattern is [timeOfCreation, EntityCounter]
from
Globals
import
ManPyEnvironment
from
Globals
import
ManPyEnvironment
G
.
SourceList
.
append
(
self
)
#===========================================================================
#===========================================================================
# The initialize method of the Source class
# The initialize method of the Source class
...
@@ -109,6 +108,7 @@ class Source(CoreObject):
...
@@ -109,6 +108,7 @@ class Source(CoreObject):
def
initialize
(
self
):
def
initialize
(
self
):
# using the Process __init__ and not the CoreObject __init__
# using the Process __init__ and not the CoreObject __init__
CoreObject
.
initialize
(
self
)
CoreObject
.
initialize
(
self
)
self
.
environment
.
SourceList
.
append
(
self
)
# initialize the internal Queue (type Resource) of the Source
# initialize the internal Queue (type Resource) of the Source
# self.Res=Resource(capacity=infinity)
# self.Res=Resource(capacity=infinity)
...
...
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