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
635f593b
Commit
635f593b
authored
Oct 18, 2013
by
Georgios Dagkakis
Committed by
Sebastien Robin
Nov 06, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new examples added to the documentation and the Examples folder
parent
db6057be
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
346 additions
and
7 deletions
+346
-7
ManPy_documentation.doc
ManPy_documentation.doc
+0
-0
dream/simulation/Examples/JobShop1.py
dream/simulation/Examples/JobShop1.py
+61
-0
dream/simulation/Examples/JobShop2EDD.py
dream/simulation/Examples/JobShop2EDD.py
+69
-0
dream/simulation/Examples/JobShop2MC.py
dream/simulation/Examples/JobShop2MC.py
+70
-0
dream/simulation/Examples/JobShop2Priority.py
dream/simulation/Examples/JobShop2Priority.py
+68
-0
dream/simulation/Examples/JobShop2RPC.py
dream/simulation/Examples/JobShop2RPC.py
+70
-0
dream/simulation/Job.py
dream/simulation/Job.py
+5
-4
dream/simulation/LineGenerationJSON.py
dream/simulation/LineGenerationJSON.py
+1
-1
dream/simulation/Queue.py
dream/simulation/Queue.py
+2
-2
No files found.
ManPy_documentation.doc
View file @
635f593b
No preview for this file type
dream/simulation/Examples/JobShop1.py
0 → 100644
View file @
635f593b
from
SimPy.Simulation
import
simulate
,
activate
,
initialize
,
infinity
,
now
from
simulation.MachineJobShop
import
MachineJobShop
from
simulation.QueueJobShop
import
QueueJobShop
from
simulation.ExitJobShop
import
ExitJobShop
from
simulation.Job
import
Job
from
simulation.Globals
import
G
#define the objects of the model
Q1
=
QueueJobShop
(
'Q1'
,
'Queue1'
,
capacity
=
infinity
)
Q2
=
QueueJobShop
(
'Q2'
,
'Queue2'
,
capacity
=
infinity
)
Q3
=
QueueJobShop
(
'Q3'
,
'Queue3'
,
capacity
=
infinity
)
M1
=
MachineJobShop
(
'M1'
,
'Machine1'
)
M2
=
MachineJobShop
(
'M2'
,
'Machine2'
)
M3
=
MachineJobShop
(
'M3'
,
'Machine3'
)
E
=
ExitJobShop
(
'E'
,
'Exit'
)
G
.
ObjList
=
[
M1
,
M2
,
M3
,
Q1
,
Q2
,
Q3
,
E
]
#add all the objects in G.ObjList so that they can be easier accessed later
#define predecessors and successors for the objects
Q1
.
defineRouting
(
successorList
=
[
M1
])
Q2
.
defineRouting
(
successorList
=
[
M2
])
Q3
.
defineRouting
(
successorList
=
[
M3
])
M1
.
defineRouting
(
predecessorList
=
[
Q1
])
M2
.
defineRouting
(
predecessorList
=
[
Q2
])
M3
.
defineRouting
(
predecessorList
=
[
Q3
])
#define the Jobs
J
=
Job
(
'J1'
,
'Job1'
,
route
=
[[
'Q1'
,
1
],[
'Q3'
,
3
],[
'Q2'
,
2
],[
'E'
,
0
]])
initialize
()
#initialize the simulation (SimPy method)
#initialize all the objects
for
object
in
G
.
ObjList
:
object
.
initialize
()
J
.
initialize
()
#set the WIP
Q1
.
getActiveObjectQueue
().
append
(
J
)
#place the Job at 'Q1'
J
.
remainingRoute
[
0
][
0
]
=
''
#remove data from the remaining route since it is already added in Q1.
#this is to make sure that the Job will not get again into Queue1 while it waits in Queue1
J
.
schedule
.
append
([
'Q1'
,
now
()])
#add the data in the schedule that the Job entered Q1 at time=0
#activate all the objects
for
object
in
G
.
ObjList
:
activate
(
object
,
object
.
run
())
simulate
(
until
=
infinity
)
#run the simulation until there are no more events
G
.
maxSimTime
=
E
.
timeLastEntityLeft
#calculate the maxSimTime as the time that the last Job left
#loop in the schedule to print the results
for
record
in
J
.
schedule
:
#schedule holds ids of objects. The following loop will identify the name of the CoreObject with the given id
name
=
None
for
obj
in
G
.
ObjList
:
if
obj
.
id
==
record
[
0
]:
name
=
obj
.
objName
print
J
.
name
,
"got into"
,
name
,
"at"
,
record
[
1
]
dream/simulation/Examples/JobShop2EDD.py
0 → 100644
View file @
635f593b
from
SimPy.Simulation
import
simulate
,
activate
,
initialize
,
infinity
,
now
from
simulation.MachineJobShop
import
MachineJobShop
from
simulation.QueueJobShop
import
QueueJobShop
from
simulation.ExitJobShop
import
ExitJobShop
from
simulation.Job
import
Job
from
simulation.Globals
import
G
#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
)
M1
=
MachineJobShop
(
'M1'
,
'Machine1'
)
M2
=
MachineJobShop
(
'M2'
,
'Machine2'
)
M3
=
MachineJobShop
(
'M3'
,
'Machine3'
)
E
=
ExitJobShop
(
'E'
,
'Exit'
)
G
.
ObjList
=
[
M1
,
M2
,
M3
,
Q1
,
Q2
,
Q3
,
E
]
#add all the objects in G.ObjList so that they can be easier accessed later
#define predecessors and successors for the objects
Q1
.
defineRouting
(
successorList
=
[
M1
])
Q2
.
defineRouting
(
successorList
=
[
M2
])
Q3
.
defineRouting
(
successorList
=
[
M3
])
M1
.
defineRouting
(
predecessorList
=
[
Q1
])
M2
.
defineRouting
(
predecessorList
=
[
Q2
])
M3
.
defineRouting
(
predecessorList
=
[
Q3
])
#define the Jobs
J1
=
Job
(
'J1'
,
'Job1'
,[[
'Q1'
,
1
],[
'Q3'
,
3
],[
'Q2'
,
2
],[
'E'
,
0
]],
priority
=
0
,
dueDate
=
100
)
J2
=
Job
(
'J2'
,
'Job2'
,[[
'Q1'
,
2
],[
'Q2'
,
4
],[
'Q3'
,
6
],[
'E'
,
0
]],
priority
=
0
,
dueDate
=
90
)
J3
=
Job
(
'J3'
,
'Job3'
,[[
'Q1'
,
10
],[
'Q3'
,
3
],[
'E'
,
0
]],
priority
=
5
,
dueDate
=
110
)
G
.
JobList
=
[
J1
,
J2
,
J3
]
G
.
maxSimTime
=
1440.0
#set G.maxSimTime 1440.0 minutes (1 day)
initialize
()
#initialize the simulation (SimPy method)
#initialize all the objects
for
object
in
G
.
ObjList
:
object
.
initialize
()
#initialize all the jobs
for
job
in
G
.
JobList
:
job
.
initialize
()
#set the WIP for all the jobs
for
job
in
G
.
JobList
:
Q1
.
getActiveObjectQueue
().
append
(
job
)
job
.
remainingRoute
[
0
][
0
]
=
''
#remove data from the remaining route.
job
.
schedule
.
append
([
'Q1'
,
now
()])
#add the data in the schedule that the Job entered Q1 at time=0
#activate all the objects
for
object
in
G
.
ObjList
:
activate
(
object
,
object
.
run
())
simulate
(
until
=
G
.
maxSimTime
)
#run the simulation
#output the schedule of every job
for
job
in
G
.
JobList
:
#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
name
=
None
for
obj
in
G
.
ObjList
:
if
obj
.
id
==
record
[
0
]:
name
=
obj
.
objName
print
job
.
name
,
"got into"
,
name
,
"at"
,
record
[
1
]
print
"-"
*
30
dream/simulation/Examples/JobShop2MC.py
0 → 100644
View file @
635f593b
from
SimPy.Simulation
import
simulate
,
activate
,
initialize
,
infinity
,
now
from
simulation.MachineJobShop
import
MachineJobShop
from
simulation.QueueJobShop
import
QueueJobShop
from
simulation.ExitJobShop
import
ExitJobShop
from
simulation.Job
import
Job
from
simulation.Globals
import
G
#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
)
M1
=
MachineJobShop
(
'M1'
,
'Machine1'
)
M2
=
MachineJobShop
(
'M2'
,
'Machine2'
)
M3
=
MachineJobShop
(
'M3'
,
'Machine3'
)
E
=
ExitJobShop
(
'E'
,
'Exit'
)
G
.
ObjList
=
[
M1
,
M2
,
M3
,
Q1
,
Q2
,
Q3
,
E
]
#add all the objects in G.ObjList so that they can be easier accessed later
#define predecessors and successors for the objects
Q1
.
defineRouting
(
successorList
=
[
M1
])
Q2
.
defineRouting
(
successorList
=
[
M2
])
Q3
.
defineRouting
(
successorList
=
[
M3
])
M1
.
defineRouting
(
predecessorList
=
[
Q1
])
M2
.
defineRouting
(
predecessorList
=
[
Q2
])
M3
.
defineRouting
(
predecessorList
=
[
Q3
])
#define the Jobs
J1
=
Job
(
'J1'
,
'Job1'
,[[
'Q1'
,
1
],[
'Q3'
,
3
],[
'Q2'
,
2
],[
'E'
,
0
]],
priority
=
0
,
dueDate
=
100
)
J2
=
Job
(
'J2'
,
'Job2'
,[[
'Q1'
,
2
],[
'Q2'
,
4
],[
'Q3'
,
6
],[
'E'
,
0
]],
priority
=
0
,
dueDate
=
90
)
J3
=
Job
(
'J3'
,
'Job3'
,[[
'Q1'
,
10
],[
'Q3'
,
3
],[
'E'
,
0
]],
priority
=
5
,
dueDate
=
110
)
G
.
JobList
=
[
J1
,
J2
,
J3
]
G
.
maxSimTime
=
1440.0
#set G.maxSimTime 1440.0 minutes (1 day)
initialize
()
#initialize the simulation (SimPy method)
#initialize all the objects
for
object
in
G
.
ObjList
:
object
.
initialize
()
#initialize all the jobs
for
job
in
G
.
JobList
:
job
.
initialize
()
#set the WIP for all the jobs
for
job
in
G
.
JobList
:
Q1
.
getActiveObjectQueue
().
append
(
job
)
job
.
remainingRoute
[
0
][
0
]
=
''
#remove data from the remaining route.
job
.
schedule
.
append
([
'Q1'
,
now
()])
#add the data in the schedule that the Job entered Q1 at time=0
#activate all the objects
for
object
in
G
.
ObjList
:
activate
(
object
,
object
.
run
())
simulate
(
until
=
G
.
maxSimTime
)
#run the simulation
#output the schedule of every job
for
job
in
G
.
JobList
:
#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
name
=
None
for
obj
in
G
.
ObjList
:
if
obj
.
id
==
record
[
0
]:
name
=
obj
.
objName
print
job
.
name
,
"got into"
,
name
,
"at"
,
record
[
1
]
print
"-"
*
30
dream/simulation/Examples/JobShop2Priority.py
0 → 100644
View file @
635f593b
from
SimPy.Simulation
import
simulate
,
activate
,
initialize
,
infinity
,
now
from
simulation.MachineJobShop
import
MachineJobShop
from
simulation.QueueJobShop
import
QueueJobShop
from
simulation.ExitJobShop
import
ExitJobShop
from
simulation.Job
import
Job
from
simulation.Globals
import
G
#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
)
M1
=
MachineJobShop
(
'M1'
,
'Machine1'
)
M2
=
MachineJobShop
(
'M2'
,
'Machine2'
)
M3
=
MachineJobShop
(
'M3'
,
'Machine3'
)
E
=
ExitJobShop
(
'E'
,
'Exit'
)
G
.
ObjList
=
[
M1
,
M2
,
M3
,
Q1
,
Q2
,
Q3
,
E
]
#add all the objects in G.ObjList so that they can be easier accessed later
#define predecessors and successors for the objects
Q1
.
defineRouting
(
successorList
=
[
M1
])
Q2
.
defineRouting
(
successorList
=
[
M2
])
Q3
.
defineRouting
(
successorList
=
[
M3
])
M1
.
defineRouting
(
predecessorList
=
[
Q1
])
M2
.
defineRouting
(
predecessorList
=
[
Q2
])
M3
.
defineRouting
(
predecessorList
=
[
Q3
])
#define the Jobs
J1
=
Job
(
'J1'
,
'Job1'
,[[
'Q1'
,
1
],[
'Q3'
,
3
],[
'Q2'
,
2
],[
'E'
,
0
]],
priority
=
0
,
dueDate
=
100
)
J2
=
Job
(
'J2'
,
'Job2'
,[[
'Q1'
,
2
],[
'Q2'
,
4
],[
'Q3'
,
6
],[
'E'
,
0
]],
priority
=
0
,
dueDate
=
90
)
J3
=
Job
(
'J3'
,
'Job3'
,[[
'Q1'
,
10
],[
'Q3'
,
3
],[
'E'
,
0
]],
priority
=
5
,
dueDate
=
110
)
G
.
JobList
=
[
J1
,
J2
,
J3
]
G
.
maxSimTime
=
1440.0
#set G.maxSimTime 1440.0 minutes (1 day)
initialize
()
#initialize the simulation (SimPy method)
#initialize all the objects
for
object
in
G
.
ObjList
:
object
.
initialize
()
#initialize all the jobs
for
job
in
G
.
JobList
:
job
.
initialize
()
#set the WIP for all the jobs
for
job
in
G
.
JobList
:
Q1
.
getActiveObjectQueue
().
append
(
job
)
job
.
remainingRoute
[
0
][
0
]
=
''
#remove data from the remaining route.
job
.
schedule
.
append
([
'Q1'
,
now
()])
#add the data in the schedule that the Job entered Q1 at time=0
#activate all the objects
for
object
in
G
.
ObjList
:
activate
(
object
,
object
.
run
())
simulate
(
until
=
G
.
maxSimTime
)
#run the simulation
#output the schedule of every job
for
job
in
G
.
JobList
:
#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
name
=
None
for
obj
in
G
.
ObjList
:
if
obj
.
id
==
record
[
0
]:
name
=
obj
.
objName
print
job
.
name
,
"got into"
,
name
,
"at"
,
record
[
1
]
print
"-"
*
30
dream/simulation/Examples/JobShop2RPC.py
0 → 100644
View file @
635f593b
from
SimPy.Simulation
import
simulate
,
activate
,
initialize
,
infinity
,
now
from
simulation.MachineJobShop
import
MachineJobShop
from
simulation.QueueJobShop
import
QueueJobShop
from
simulation.ExitJobShop
import
ExitJobShop
from
simulation.Job
import
Job
from
simulation.Globals
import
G
#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
)
M1
=
MachineJobShop
(
'M1'
,
'Machine1'
)
M2
=
MachineJobShop
(
'M2'
,
'Machine2'
)
M3
=
MachineJobShop
(
'M3'
,
'Machine3'
)
E
=
ExitJobShop
(
'E'
,
'Exit'
)
G
.
ObjList
=
[
M1
,
M2
,
M3
,
Q1
,
Q2
,
Q3
,
E
]
#add all the objects in G.ObjList so that they can be easier accessed later
#define predecessors and successors for the objects
Q1
.
defineRouting
(
successorList
=
[
M1
])
Q2
.
defineRouting
(
successorList
=
[
M2
])
Q3
.
defineRouting
(
successorList
=
[
M3
])
M1
.
defineRouting
(
predecessorList
=
[
Q1
])
M2
.
defineRouting
(
predecessorList
=
[
Q2
])
M3
.
defineRouting
(
predecessorList
=
[
Q3
])
#define the Jobs
J1
=
Job
(
'J1'
,
'Job1'
,[[
'Q1'
,
1
],[
'Q3'
,
3
],[
'Q2'
,
2
],[
'E'
,
0
]],
priority
=
0
,
dueDate
=
100
)
J2
=
Job
(
'J2'
,
'Job2'
,[[
'Q1'
,
2
],[
'Q2'
,
4
],[
'Q3'
,
6
],[
'E'
,
0
]],
priority
=
0
,
dueDate
=
90
)
J3
=
Job
(
'J3'
,
'Job3'
,[[
'Q1'
,
10
],[
'Q3'
,
3
],[
'E'
,
0
]],
priority
=
5
,
dueDate
=
110
)
G
.
JobList
=
[
J1
,
J2
,
J3
]
G
.
maxSimTime
=
1440.0
#set G.maxSimTime 1440.0 minutes (1 day)
initialize
()
#initialize the simulation (SimPy method)
#initialize all the objects
for
object
in
G
.
ObjList
:
object
.
initialize
()
#initialize all the jobs
for
job
in
G
.
JobList
:
job
.
initialize
()
#set the WIP for all the jobs
for
job
in
G
.
JobList
:
Q1
.
getActiveObjectQueue
().
append
(
job
)
job
.
remainingRoute
[
0
][
0
]
=
''
#remove data from the remaining route.
job
.
schedule
.
append
([
'Q1'
,
now
()])
#add the data in the schedule that the Job entered Q1 at time=0
#activate all the objects
for
object
in
G
.
ObjList
:
activate
(
object
,
object
.
run
())
simulate
(
until
=
G
.
maxSimTime
)
#run the simulation
#output the schedule of every job
for
job
in
G
.
JobList
:
#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
name
=
None
for
obj
in
G
.
ObjList
:
if
obj
.
id
==
record
[
0
]:
name
=
obj
.
objName
print
job
.
name
,
"got into"
,
name
,
"at"
,
record
[
1
]
print
"-"
*
30
dream/simulation/Job.py
View file @
635f593b
...
...
@@ -33,12 +33,13 @@ from Entity import Entity
class
Job
(
Entity
):
type
=
"Job"
def
__init__
(
self
,
id
,
name
,
route
,
priority
=
0
,
dueDate
=
0
,
orderDate
=
0
):
def
__init__
(
self
,
id
,
name
,
route
=
[]
,
priority
=
0
,
dueDate
=
0
,
orderDate
=
0
):
Entity
.
__init__
(
self
,
name
,
priority
=
priority
,
dueDate
=
dueDate
,
orderDate
=
orderDate
)
self
.
id
=
id
self
.
fullR
oute
=
route
#the route that the job follows, also contains the processing times in each station
self
.
r
oute
=
route
#the route that the job follows, also contains the processing times in each station
self
.
remainingRoute
=
route
#the remaining route. in the beginning this should be the same as the full route
self
.
currentStop
=
route
[
0
][
0
]
#the starting stop should be the first in the route
self
.
schedule
=
[]
#keeps the result of the simulation. A list with the stations and time of entrance
#outputs results to JSON File
def
outputResultsJSON
(
self
):
...
...
@@ -59,7 +60,7 @@ class Job(Entity):
#initializes all the Entity for a new simulation replication
def
initialize
(
self
):
self
.
remainingRoute
=
self
.
fullR
oute
self
.
currentStop
=
self
.
fullR
oute
[
0
][
0
]
self
.
remainingRoute
=
self
.
r
oute
self
.
currentStop
=
self
.
r
oute
[
0
][
0
]
\ No newline at end of file
dream/simulation/LineGenerationJSON.py
View file @
635f593b
...
...
@@ -392,7 +392,7 @@ def setWIP():
for
obj
in
G
.
ObjList
:
if
obj
.
id
==
objectId
:
object
=
obj
object
.
Res
.
activeQ
.
append
(
entity
)
object
.
getActiveObjectQueue
()
.
append
(
entity
)
entity
.
remainingRoute
[
0
][
0
]
=
""
#remove data from the remaining route.
entity
.
schedule
.
append
([
object
.
id
,
now
()])
#append the time to schedule so that it can be read in the result
...
...
dream/simulation/Queue.py
View file @
635f593b
...
...
@@ -220,7 +220,7 @@ class Queue(CoreObject):
#if the schedulingRule is first in first out
if
criterion
==
"FIFO"
:
pass
#if the schedulingRule is based on a pre-defined prioriy
#if the schedulingRule is based on a pre-defined priori
t
y
elif
criterion
==
"Priority"
:
activeObjectQ
.
sort
(
key
=
lambda
x
:
x
.
priority
,
reverse
=
True
)
#if the schedulingRule is earliest due date
...
...
@@ -248,7 +248,7 @@ class Queue(CoreObject):
RPT
+=
step
[
1
]
entity
.
remainingProcessingTime
=
RPT
activeObjectQ
.
sort
(
key
=
lambda
x
:
(
x
.
dueDate
-
x
.
remainingProcessingTime
))
#if the schedulingRule is to sort Entities based on the
minimum slackness
#if the schedulingRule is to sort Entities based on the
length of the following Queue
elif
criterion
==
"NextStage"
:
from
Globals
import
G
for
entity
in
activeObjectQ
:
...
...
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