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
5c2221f2
Commit
5c2221f2
authored
May 30, 2014
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JobShop and TwoServers (except stochastic) examples running
parent
10b97050
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
174 additions
and
116 deletions
+174
-116
dream/simulation/Examples/JobShop1.py
dream/simulation/Examples/JobShop1.py
+17
-12
dream/simulation/Examples/JobShop1Trace.py
dream/simulation/Examples/JobShop1Trace.py
+17
-12
dream/simulation/Examples/JobShop2EDD.py
dream/simulation/Examples/JobShop2EDD.py
+22
-14
dream/simulation/Examples/JobShop2MC.py
dream/simulation/Examples/JobShop2MC.py
+22
-14
dream/simulation/Examples/JobShop2Priority.py
dream/simulation/Examples/JobShop2Priority.py
+22
-14
dream/simulation/Examples/JobShop2RPC.py
dream/simulation/Examples/JobShop2RPC.py
+22
-14
dream/simulation/Examples/TwoServers.py
dream/simulation/Examples/TwoServers.py
+14
-10
dream/simulation/Examples/TwoServersPlots.py
dream/simulation/Examples/TwoServersPlots.py
+18
-11
dream/simulation/Examples/TwoServersStochastic.py
dream/simulation/Examples/TwoServersStochastic.py
+20
-15
dream/simulation/Examples/repairmanPie.jpg
dream/simulation/Examples/repairmanPie.jpg
+0
-0
No files found.
dream/simulation/Examples/JobShop1.py
View file @
5c2221f2
from
dream.simulation.imports
import
MachineJobShop
,
QueueJobShop
,
ExitJobShop
,
Globals
,
Job
,
G
from
dream.simulation.imports
import
simulate
,
activate
,
initialize
,
infinity
from
dream.simulation.imports
import
simpy
G
.
env
=
simpy
.
Environment
()
# define a simpy environment
# this is where all the simulation object 'live'
#define the objects of the model
Q1
=
QueueJobShop
(
'Q1'
,
'Queue1'
,
capacity
=
infinity
)
Q2
=
QueueJobShop
(
'Q2'
,
'Queue2'
,
capacity
=
infinity
)
Q3
=
QueueJobShop
(
'Q3'
,
'Queue3'
,
capacity
=
infinity
)
Q1
=
QueueJobShop
(
'Q1'
,
'Queue1'
,
capacity
=
float
(
"inf"
)
)
Q2
=
QueueJobShop
(
'Q2'
,
'Queue2'
,
capacity
=
float
(
"inf"
)
)
Q3
=
QueueJobShop
(
'Q3'
,
'Queue3'
,
capacity
=
float
(
"inf"
)
)
M1
=
MachineJobShop
(
'M1'
,
'Machine1'
)
M2
=
MachineJobShop
(
'M2'
,
'Machine2'
)
M3
=
MachineJobShop
(
'M3'
,
'Machine3'
)
...
...
@@ -25,24 +28,26 @@ J=Job('J1','Job1',route=J1Route)
G
.
EntityList
=
[
J
]
#a list to hold all the jobs
def
main
():
initialize
()
#initialize the simulation (SimPy method)
#initialize all the objects
#initialize all the objects
for
object
in
G
.
ObjList
:
object
.
initialize
()
J
.
initialize
()
#set the WIP
Globals
.
setWIP
(
G
.
EntityList
)
#activate all the objects
for
object
in
G
.
ObjList
:
activate
(
object
,
object
.
run
())
G
.
env
.
process
(
object
.
run
())
#set the WIP
Globals
.
setWIP
(
G
.
EntityList
)
simulate
(
until
=
infinity
)
#run the simulation until there are no more events
G
.
env
.
run
(
until
=
float
(
"inf"
)
)
#run the simulation until there are no more events
G
.
maxSimTime
=
E
.
timeLastEntityLeft
#calculate the maxSimTime as the time that the last Job left
#carry on the post processing operations for every object in the topology
for
object
in
G
.
ObjList
:
object
.
postProcessing
()
#loop in the schedule to print the results
returnSchedule
=
[]
# dummy variable used just for returning values and testing
for
record
in
J
.
schedule
:
...
...
dream/simulation/Examples/JobShop1Trace.py
View file @
5c2221f2
from
dream.simulation.imports
import
MachineJobShop
,
QueueJobShop
,
ExitJobShop
,
Globals
,
Job
,
G
,
ExcelHandler
from
dream.simulation.imports
import
simulate
,
activate
,
initialize
,
infinity
from
dream.simulation.imports
import
simpy
G
.
env
=
simpy
.
Environment
()
# define a simpy environment
# this is where all the simulation object 'live'
G
.
trace
=
"Yes"
#define the objects of the model
Q1
=
QueueJobShop
(
'Q1'
,
'Queue1'
,
capacity
=
infinity
)
Q2
=
QueueJobShop
(
'Q2'
,
'Queue2'
,
capacity
=
infinity
)
Q3
=
QueueJobShop
(
'Q3'
,
'Queue3'
,
capacity
=
infinity
)
Q1
=
QueueJobShop
(
'Q1'
,
'Queue1'
,
capacity
=
float
(
"inf"
)
)
Q2
=
QueueJobShop
(
'Q2'
,
'Queue2'
,
capacity
=
float
(
"inf"
)
)
Q3
=
QueueJobShop
(
'Q3'
,
'Queue3'
,
capacity
=
float
(
"inf"
)
)
M1
=
MachineJobShop
(
'M1'
,
'Machine1'
)
M2
=
MachineJobShop
(
'M2'
,
'Machine2'
)
M3
=
MachineJobShop
(
'M3'
,
'Machine3'
)
...
...
@@ -27,24 +30,26 @@ J=Job('J1','Job1',route=J1Route)
G
.
EntityList
=
[
J
]
#a list to hold all the jobs
def
main
():
initialize
()
#initialize the simulation (SimPy method)
#initialize all the objects
#initialize all the objects
for
object
in
G
.
ObjList
:
object
.
initialize
()
J
.
initialize
()
#set the WIP
Globals
.
setWIP
(
G
.
EntityList
)
#activate all the objects
for
object
in
G
.
ObjList
:
activate
(
object
,
object
.
run
())
G
.
env
.
process
(
object
.
run
())
#set the WIP
Globals
.
setWIP
(
G
.
EntityList
)
simulate
(
until
=
infinity
)
#run the simulation until there are no more events
G
.
env
.
run
(
until
=
float
(
"inf"
)
)
#run the simulation until there are no more events
G
.
maxSimTime
=
E
.
timeLastEntityLeft
#calculate the maxSimTime as the time that the last Job left
#carry on the post processing operations for every object in the topology
for
object
in
G
.
ObjList
:
object
.
postProcessing
()
#loop in the schedule to print the results
schedule
=
[]
for
record
in
J
.
schedule
:
...
...
dream/simulation/Examples/JobShop2EDD.py
View file @
5c2221f2
from
dream.simulation.imports
import
MachineJobShop
,
QueueJobShop
,
ExitJobShop
,
Globals
,
Job
,
G
from
dream.simulation.imports
import
simulate
,
activate
,
initialize
,
infinity
from
dream.simulation.imports
import
simpy
G
.
env
=
simpy
.
Environment
()
# define a simpy environment
# this is where all the simulation object 'live'
#define the objects of the model
Q1
=
QueueJobShop
(
'Q1'
,
'Queue1'
,
capacity
=
infinity
,
schedulingRule
=
"EDD"
)
Q2
=
QueueJobShop
(
'Q2'
,
'Queue2'
,
capacity
=
infinity
)
Q3
=
QueueJobShop
(
'Q3'
,
'Queue3'
,
capacity
=
infinity
)
Q1
=
QueueJobShop
(
'Q1'
,
'Queue1'
,
capacity
=
float
(
"inf"
)
,
schedulingRule
=
"EDD"
)
Q2
=
QueueJobShop
(
'Q2'
,
'Queue2'
,
capacity
=
float
(
"inf"
)
)
Q3
=
QueueJobShop
(
'Q3'
,
'Queue3'
,
capacity
=
float
(
"inf"
)
)
M1
=
MachineJobShop
(
'M1'
,
'Machine1'
)
M2
=
MachineJobShop
(
'M2'
,
'Machine2'
)
M3
=
MachineJobShop
(
'M3'
,
'Machine3'
)
...
...
@@ -45,13 +48,12 @@ J3Route=[{"stationIdsList": ["Q1"]},
J1
=
Job
(
'J1'
,
'Job1'
,
route
=
J1Route
,
priority
=
1
,
dueDate
=
100
)
J2
=
Job
(
'J2'
,
'Job2'
,
route
=
J2Route
,
priority
=
1
,
dueDate
=
90
)
J3
=
Job
(
'J3'
,
'Job3'
,
route
=
J3Route
,
priority
=
0
,
dueDate
=
110
)
G
.
Job
List
=
[
J1
,
J2
,
J3
]
#a list to hold all the jobs
G
.
Entity
List
=
[
J1
,
J2
,
J3
]
#a list to hold all the jobs
G
.
maxSimTime
=
1440.0
#set G.maxSimTime 1440.0 minutes (1 day)
def
main
():
initialize
()
#initialize the simulation (SimPy method)
#initialize all the objects
for
object
in
G
.
ObjList
:
object
.
initialize
()
...
...
@@ -59,19 +61,25 @@ def main():
#initialize all the jobs
for
job
in
G
.
JobList
:
job
.
initialize
()
#set the WIP
for all the jobs
Globals
.
setWIP
(
G
.
Job
List
)
#set the WIP
Globals
.
setWIP
(
G
.
Entity
List
)
#activate all the objects
for
object
in
G
.
ObjList
:
activate
(
object
,
object
.
run
())
G
.
env
.
process
(
object
.
run
())
G
.
env
.
run
(
until
=
float
(
"inf"
))
#run the simulation until there are no more events
G
.
maxSimTime
=
E
.
timeLastEntityLeft
#calculate the maxSimTime as the time that the last Job left
simulate
(
until
=
G
.
maxSimTime
)
#run the simulation
#carry on the post processing operations for every object in the topology
for
object
in
G
.
ObjList
:
object
.
postProcessing
()
#output the schedule of every job
returnSchedule
=
[]
# dummy variable used just for returning values and testing
for
job
in
G
.
Job
List
:
for
job
in
G
.
Entity
List
:
#loop in the schedule to print the results
for
record
in
job
.
schedule
:
#schedule holds ids of objects. The following loop will identify the name of the CoreObject with the given id
...
...
dream/simulation/Examples/JobShop2MC.py
View file @
5c2221f2
from
dream.simulation.imports
import
MachineJobShop
,
QueueJobShop
,
ExitJobShop
,
Globals
,
Job
,
G
from
dream.simulation.imports
import
simulate
,
activate
,
initialize
,
infinity
from
dream.simulation.imports
import
simpy
G
.
env
=
simpy
.
Environment
()
# define a simpy environment
# this is where all the simulation object 'live'
#define the objects of the model
Q1
=
QueueJobShop
(
'Q1'
,
'Queue1'
,
capacity
=
infinity
,
schedulingRule
=
"MC-Priority-EDD"
)
Q2
=
QueueJobShop
(
'Q2'
,
'Queue2'
,
capacity
=
infinity
)
Q3
=
QueueJobShop
(
'Q3'
,
'Queue3'
,
capacity
=
infinity
)
Q1
=
QueueJobShop
(
'Q1'
,
'Queue1'
,
capacity
=
float
(
"inf"
)
,
schedulingRule
=
"MC-Priority-EDD"
)
Q2
=
QueueJobShop
(
'Q2'
,
'Queue2'
,
capacity
=
float
(
"inf"
)
)
Q3
=
QueueJobShop
(
'Q3'
,
'Queue3'
,
capacity
=
float
(
"inf"
)
)
M1
=
MachineJobShop
(
'M1'
,
'Machine1'
)
M2
=
MachineJobShop
(
'M2'
,
'Machine2'
)
M3
=
MachineJobShop
(
'M3'
,
'Machine3'
)
...
...
@@ -45,13 +48,12 @@ J3Route=[{"stationIdsList": ["Q1"]},
J1
=
Job
(
'J1'
,
'Job1'
,
route
=
J1Route
,
priority
=
1
,
dueDate
=
100
)
J2
=
Job
(
'J2'
,
'Job2'
,
route
=
J2Route
,
priority
=
1
,
dueDate
=
90
)
J3
=
Job
(
'J3'
,
'Job3'
,
route
=
J3Route
,
priority
=
0
,
dueDate
=
110
)
G
.
Job
List
=
[
J1
,
J2
,
J3
]
#a list to hold all the jobs
G
.
Entity
List
=
[
J1
,
J2
,
J3
]
#a list to hold all the jobs
G
.
maxSimTime
=
1440.0
#set G.maxSimTime 1440.0 minutes (1 day)
def
main
():
initialize
()
#initialize the simulation (SimPy method)
#initialize all the objects
for
object
in
G
.
ObjList
:
object
.
initialize
()
...
...
@@ -59,19 +61,25 @@ def main():
#initialize all the jobs
for
job
in
G
.
JobList
:
job
.
initialize
()
#set the WIP
for all the jobs
Globals
.
setWIP
(
G
.
Job
List
)
#set the WIP
Globals
.
setWIP
(
G
.
Entity
List
)
#activate all the objects
for
object
in
G
.
ObjList
:
activate
(
object
,
object
.
run
())
G
.
env
.
process
(
object
.
run
())
G
.
env
.
run
(
until
=
float
(
"inf"
))
#run the simulation until there are no more events
G
.
maxSimTime
=
E
.
timeLastEntityLeft
#calculate the maxSimTime as the time that the last Job left
simulate
(
until
=
G
.
maxSimTime
)
#run the simulation
#carry on the post processing operations for every object in the topology
for
object
in
G
.
ObjList
:
object
.
postProcessing
()
#output the schedule of every job
returnSchedule
=
[]
# dummy variable used just for returning values and testing
for
job
in
G
.
Job
List
:
for
job
in
G
.
Entity
List
:
#loop in the schedule to print the results
for
record
in
job
.
schedule
:
#schedule holds ids of objects. The following loop will identify the name of the CoreObject with the given id
...
...
dream/simulation/Examples/JobShop2Priority.py
View file @
5c2221f2
from
dream.simulation.imports
import
MachineJobShop
,
QueueJobShop
,
ExitJobShop
,
Globals
,
Job
,
G
from
dream.simulation.imports
import
simulate
,
activate
,
initialize
,
infinity
from
dream.simulation.imports
import
simpy
G
.
env
=
simpy
.
Environment
()
# define a simpy environment
# this is where all the simulation object 'live'
#define the objects of the model
Q1
=
QueueJobShop
(
'Q1'
,
'Queue1'
,
capacity
=
infinity
,
schedulingRule
=
"Priority"
)
Q2
=
QueueJobShop
(
'Q2'
,
'Queue2'
,
capacity
=
infinity
)
Q3
=
QueueJobShop
(
'Q3'
,
'Queue3'
,
capacity
=
infinity
)
Q1
=
QueueJobShop
(
'Q1'
,
'Queue1'
,
capacity
=
float
(
"inf"
)
,
schedulingRule
=
"Priority"
)
Q2
=
QueueJobShop
(
'Q2'
,
'Queue2'
,
capacity
=
float
(
"inf"
)
)
Q3
=
QueueJobShop
(
'Q3'
,
'Queue3'
,
capacity
=
float
(
"inf"
)
)
M1
=
MachineJobShop
(
'M1'
,
'Machine1'
)
M2
=
MachineJobShop
(
'M2'
,
'Machine2'
)
M3
=
MachineJobShop
(
'M3'
,
'Machine3'
)
...
...
@@ -45,13 +48,12 @@ J3Route=[{"stationIdsList": ["Q1"]},
J1
=
Job
(
'J1'
,
'Job1'
,
route
=
J1Route
,
priority
=
1
,
dueDate
=
100
)
J2
=
Job
(
'J2'
,
'Job2'
,
route
=
J2Route
,
priority
=
1
,
dueDate
=
90
)
J3
=
Job
(
'J3'
,
'Job3'
,
route
=
J3Route
,
priority
=
0
,
dueDate
=
110
)
G
.
Job
List
=
[
J1
,
J2
,
J3
]
#a list to hold all the jobs
G
.
Entity
List
=
[
J1
,
J2
,
J3
]
#a list to hold all the jobs
G
.
maxSimTime
=
1440.0
#set G.maxSimTime 1440.0 minutes (1 day)
def
main
():
initialize
()
#initialize the simulation (SimPy method)
#initialize all the objects
for
object
in
G
.
ObjList
:
object
.
initialize
()
...
...
@@ -59,19 +61,25 @@ def main():
#initialize all the jobs
for
job
in
G
.
JobList
:
job
.
initialize
()
#set the WIP
for all the jobs
Globals
.
setWIP
(
G
.
Job
List
)
#set the WIP
Globals
.
setWIP
(
G
.
Entity
List
)
#activate all the objects
for
object
in
G
.
ObjList
:
activate
(
object
,
object
.
run
())
G
.
env
.
process
(
object
.
run
())
G
.
env
.
run
(
until
=
float
(
"inf"
))
#run the simulation until there are no more events
G
.
maxSimTime
=
E
.
timeLastEntityLeft
#calculate the maxSimTime as the time that the last Job left
simulate
(
until
=
G
.
maxSimTime
)
#run the simulation
#carry on the post processing operations for every object in the topology
for
object
in
G
.
ObjList
:
object
.
postProcessing
()
#output the schedule of every job
returnSchedule
=
[]
# dummy variable used just for returning values and testing
for
job
in
G
.
Job
List
:
for
job
in
G
.
Entity
List
:
#loop in the schedule to print the results
for
record
in
job
.
schedule
:
#schedule holds ids of objects. The following loop will identify the name of the CoreObject with the given id
...
...
dream/simulation/Examples/JobShop2RPC.py
View file @
5c2221f2
from
dream.simulation.imports
import
MachineJobShop
,
QueueJobShop
,
ExitJobShop
,
Globals
,
Job
,
G
from
dream.simulation.imports
import
simulate
,
activate
,
initialize
,
infinity
from
dream.simulation.imports
import
simpy
G
.
env
=
simpy
.
Environment
()
# define a simpy environment
# this is where all the simulation object 'live'
#define the objects of the model
Q1
=
QueueJobShop
(
'Q1'
,
'Queue1'
,
capacity
=
infinity
,
schedulingRule
=
"RPC"
)
Q2
=
QueueJobShop
(
'Q2'
,
'Queue2'
,
capacity
=
infinity
)
Q3
=
QueueJobShop
(
'Q3'
,
'Queue3'
,
capacity
=
infinity
)
Q1
=
QueueJobShop
(
'Q1'
,
'Queue1'
,
capacity
=
float
(
"inf"
)
,
schedulingRule
=
"RPC"
)
Q2
=
QueueJobShop
(
'Q2'
,
'Queue2'
,
capacity
=
float
(
"inf"
)
)
Q3
=
QueueJobShop
(
'Q3'
,
'Queue3'
,
capacity
=
float
(
"inf"
)
)
M1
=
MachineJobShop
(
'M1'
,
'Machine1'
)
M2
=
MachineJobShop
(
'M2'
,
'Machine2'
)
M3
=
MachineJobShop
(
'M3'
,
'Machine3'
)
...
...
@@ -45,13 +48,12 @@ J3Route=[{"stationIdsList": ["Q1"]},
J1
=
Job
(
'J1'
,
'Job1'
,
route
=
J1Route
,
priority
=
1
,
dueDate
=
100
)
J2
=
Job
(
'J2'
,
'Job2'
,
route
=
J2Route
,
priority
=
1
,
dueDate
=
90
)
J3
=
Job
(
'J3'
,
'Job3'
,
route
=
J3Route
,
priority
=
0
,
dueDate
=
110
)
G
.
Job
List
=
[
J1
,
J2
,
J3
]
#a list to hold all the jobs
G
.
Entity
List
=
[
J1
,
J2
,
J3
]
#a list to hold all the jobs
G
.
maxSimTime
=
1440.0
#set G.maxSimTime 1440.0 minutes (1 day)
def
main
():
initialize
()
#initialize the simulation (SimPy method)
#initialize all the objects
for
object
in
G
.
ObjList
:
object
.
initialize
()
...
...
@@ -59,19 +61,25 @@ def main():
#initialize all the jobs
for
job
in
G
.
JobList
:
job
.
initialize
()
#set the WIP
for all the jobs
Globals
.
setWIP
(
G
.
Job
List
)
#set the WIP
Globals
.
setWIP
(
G
.
Entity
List
)
#activate all the objects
for
object
in
G
.
ObjList
:
activate
(
object
,
object
.
run
())
G
.
env
.
process
(
object
.
run
())
G
.
env
.
run
(
until
=
float
(
"inf"
))
#run the simulation until there are no more events
G
.
maxSimTime
=
E
.
timeLastEntityLeft
#calculate the maxSimTime as the time that the last Job left
simulate
(
until
=
G
.
maxSimTime
)
#run the simulation
#carry on the post processing operations for every object in the topology
for
object
in
G
.
ObjList
:
object
.
postProcessing
()
#output the schedule of every job
returnSchedule
=
[]
# dummy variable used just for returning values and testing
for
job
in
G
.
Job
List
:
for
job
in
G
.
Entity
List
:
#loop in the schedule to print the results
for
record
in
job
.
schedule
:
#schedule holds ids of objects. The following loop will identify the name of the CoreObject with the given id
...
...
dream/simulation/Examples/TwoServers.py
View file @
5c2221f2
from
dream.simulation.imports
import
Machine
,
Source
,
Exit
,
Part
,
G
,
Repairman
,
Queue
,
Failure
from
dream.simulation.imports
import
simulate
,
activate
,
initialize
from
dream.simulation.imports
import
simpy
G
.
env
=
simpy
.
Environment
()
# define a simpy environment
# this is where all the simulation object 'live'
#define the objects of the model
R
=
Repairman
(
'R1'
,
'Bob'
)
...
...
@@ -15,7 +18,7 @@ F2=Failure(victim=M2, distribution={'distributionType':'Fixed','MTTF':40,'MTTR':
G
.
ObjList
=
[
S
,
M1
,
M2
,
E
,
Q
]
#add all the objects in G.ObjList so that they can be easier accessed later
G
.
MachineList
=
[
M1
,
M2
]
G
.
ObjectResourceList
=
[
R
]
G
.
ObjectInterruptionList
=
[
F1
,
F2
]
#add all the objects in G.ObjList so that they can be easier accessed later
#define predecessors and successors for the objects
...
...
@@ -26,33 +29,34 @@ M2.defineRouting([Q],[E])
E
.
defineRouting
([
M2
])
def
main
():
initialize
()
#initialize the simulation (SimPy method)
#initialize all the objects
R
.
initialize
()
for
object
in
G
.
ObjList
:
object
.
initialize
()
for
objectInterruption
in
G
.
ObjectInterruptionList
:
objectInterruption
.
initialize
()
for
objectResource
in
G
.
ObjectResourceList
:
objectResource
.
initialize
()
#activate all the objects
for
object
in
G
.
ObjList
:
activate
(
object
,
object
.
run
())
G
.
env
.
process
(
object
.
run
())
for
objectInterruption
in
G
.
ObjectInterruptionList
:
activate
(
objectInterruption
,
objectInterruption
.
run
())
G
.
env
.
process
(
objectInterruption
.
run
())
G
.
maxSimTime
=
1440.0
#set G.maxSimTime 1440.0 minutes (1 day)
simulate
(
until
=
G
.
maxSimTime
)
#run the simulation
G
.
env
.
run
(
until
=
G
.
maxSimTime
)
#run the simulation
#carry on the post processing operations for every object in the topology
for
object
in
G
.
ObjList
:
object
.
postProcessing
()
R
.
postProcessing
()
for
objectResource
in
G
.
ObjectResourceList
:
objectResource
.
postProcessing
()
#print the results
print
"the system produced"
,
E
.
numOfExits
,
"parts"
...
...
dream/simulation/Examples/TwoServersPlots.py
View file @
5c2221f2
from
dream.simulation.imports
import
Machine
,
Source
,
Exit
,
Part
,
G
,
Repairman
,
Queue
,
Failure
from
dream.simulation.imports
import
sim
ulate
,
activate
,
initialize
from
dream.simulation.imports
import
sim
py
#import Graphs
from
dream.KnowledgeExtraction.Plots
import
Graphs
G
.
env
=
simpy
.
Environment
()
# define a simpy environment
# this is where all the simulation object 'live'
#define the objects of the model
R
=
Repairman
(
'R1'
,
'Bob'
)
S
=
Source
(
'S1'
,
'Source'
,
interarrivalTime
=
{
'distributionType'
:
'Fixed'
,
'mean'
:
0.5
},
entity
=
'Dream.Part'
)
...
...
@@ -17,7 +20,8 @@ F1=Failure(victim=M1, distribution={'distributionType':'Fixed','MTTF':60,'MTTR':
F2
=
Failure
(
victim
=
M2
,
distribution
=
{
'distributionType'
:
'Fixed'
,
'MTTF'
:
40
,
'MTTR'
:
10
},
repairman
=
R
)
G
.
ObjList
=
[
S
,
M1
,
M2
,
E
,
Q
]
#add all the objects in G.ObjList so that they can be easier accessed later
G
.
MachineList
=
[
M1
,
M2
]
G
.
ObjectResourceList
=
[
R
]
G
.
ObjectInterruptionList
=
[
F1
,
F2
]
#add all the objects in G.ObjList so that they can be easier accessed later
#define predecessors and successors for the objects
...
...
@@ -27,34 +31,36 @@ Q.defineRouting([M1],[M2])
M2
.
defineRouting
([
Q
],[
E
])
E
.
defineRouting
([
M2
])
def
main
():
initialize
()
#initialize the simulation (SimPy method)
#initialize all the objects
R
.
initialize
()
def
main
():
#initialize all the objects
for
object
in
G
.
ObjList
:
object
.
initialize
()
for
objectInterruption
in
G
.
ObjectInterruptionList
:
objectInterruption
.
initialize
()
for
objectResource
in
G
.
ObjectResourceList
:
objectResource
.
initialize
()
#activate all the objects
for
object
in
G
.
ObjList
:
activate
(
object
,
object
.
run
())
G
.
env
.
process
(
object
.
run
())
for
objectInterruption
in
G
.
ObjectInterruptionList
:
activate
(
objectInterruption
,
objectInterruption
.
run
())
G
.
env
.
process
(
objectInterruption
.
run
())
G
.
maxSimTime
=
1440.0
#set G.maxSimTime 1440.0 minutes (1 day)
simulate
(
until
=
G
.
maxSimTime
)
#run the simulation
G
.
env
.
run
(
until
=
G
.
maxSimTime
)
#run the simulation
#carry on the post processing operations for every object in the topology
for
object
in
G
.
ObjList
:
object
.
postProcessing
()
R
.
postProcessing
()
for
objectResource
in
G
.
ObjectResourceList
:
objectResource
.
postProcessing
()
#print the results
print
"the system produced"
,
E
.
numOfExits
,
"parts"
...
...
@@ -63,6 +69,7 @@ def main():
waiting_ratio
=
(
R
.
totalWaitingTime
/
G
.
maxSimTime
)
*
100
print
"the blockage ratio of"
,
M1
.
objName
,
"is"
,
blockage_ratio
,
"%"
print
"the working ratio of"
,
R
.
objName
,
"is"
,
working_ratio
,
"%"
#create a graph object
graph
=
Graphs
()
#create the pie
...
...
dream/simulation/Examples/TwoServersStochastic.py
View file @
5c2221f2
from
dream.simulation.imports
import
Machine
,
Source
,
Exit
,
Part
,
G
,
Repairman
,
Queue
,
Failure
from
dream.simulation.imports
import
simulate
,
activate
,
initialize
from
dream.simulation.imports
import
simpy
G
.
env
=
simpy
.
Environment
()
# define a simpy environment
# this is where all the simulation object 'live'
#define the objects of the model
R
=
Repairman
(
'R1'
,
'Bob'
)
...
...
@@ -14,7 +17,7 @@ F1=Failure(victim=M1, distribution={'distributionType':'Fixed','MTTF':60,'MTTR':
F2
=
Failure
(
victim
=
M2
,
distribution
=
{
'distributionType'
:
'Fixed'
,
'MTTF'
:
40
,
'MTTR'
:
10
},
repairman
=
R
)
G
.
ObjList
=
[
S
,
M1
,
M2
,
E
,
Q
]
#add all the objects in G.ObjList so that they can be easier accessed later
G
.
ObjectResourceList
=
[
R
]
G
.
ObjectInterruptionList
=
[
F1
,
F2
]
#add all the objects in G.ObjList so that they can be easier accessed later
#define predecessors and successors for the objects
...
...
@@ -32,29 +35,31 @@ G.confidenceLevel=0.99 #set the confidence level. 0.99=99%
for
i
in
range
(
G
.
numberOfReplications
):
G
.
seed
+=
1
#increment the seed so that we get different random numbers in each run.
initialize
()
#initialize the simulation (SimPy method)
#initialize all the objects
R
.
initialize
()
#initialize all the objects
for
object
in
G
.
ObjList
:
object
.
initialize
()
for
objectInterruption
in
G
.
ObjectInterruptionList
:
objectInterruption
.
initialize
()
#activate all the objects
for
objectResource
in
G
.
ObjectResourceList
:
objectResource
.
initialize
()
#activate all the objects
for
object
in
G
.
ObjList
:
activate
(
object
,
object
.
run
())
G
.
env
.
process
(
object
.
run
())
for
objectInterruption
in
G
.
ObjectInterruptionList
:
activate
(
objectInterruption
,
objectInterruption
.
run
())
G
.
env
.
process
(
objectInterruption
.
run
())
simulate
(
until
=
G
.
maxSimTime
)
#run the simulation
G
.
env
.
run
(
until
=
G
.
maxSimTime
)
#run the simulation
#carry on the post processing operations for every object in the topology
#carry on the post processing operations for every object in the topology
for
object
in
G
.
ObjList
:
object
.
postProcessing
()
R
.
postProcessing
()
for
objectResource
in
G
.
ObjectResourceList
:
objectResource
.
postProcessing
()
#output data to excel for every object
for
object
in
G
.
ObjList
:
...
...
dream/simulation/Examples/repairmanPie.jpg
0 → 100644
View file @
5c2221f2
9.37 KB
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