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
8e47f2ba
Commit
8e47f2ba
authored
Aug 19, 2013
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'george3'
parents
1b6c0b9f
fa2b8625
Changes
33
Hide whitespace changes
Inline
Side-by-side
Showing
33 changed files
with
488 additions
and
396 deletions
+488
-396
dream/simulation/Assembly.py
dream/simulation/Assembly.py
+5
-22
dream/simulation/Conveyer.py
dream/simulation/Conveyer.py
+3
-17
dream/simulation/CoreObject.py
dream/simulation/CoreObject.py
+118
-0
dream/simulation/Dismantle.py
dream/simulation/Dismantle.py
+6
-5
dream/simulation/Entity.py
dream/simulation/Entity.py
+40
-0
dream/simulation/Exit.py
dream/simulation/Exit.py
+7
-13
dream/simulation/Failure.py
dream/simulation/Failure.py
+2
-5
dream/simulation/Frame.py
dream/simulation/Frame.py
+3
-1
dream/simulation/JSONInputs/Topology01.json
dream/simulation/JSONInputs/Topology01.json
+8
-11
dream/simulation/JSONInputs/Topology02.json
dream/simulation/JSONInputs/Topology02.json
+1
-3
dream/simulation/JSONInputs/Topology03.json
dream/simulation/JSONInputs/Topology03.json
+9
-12
dream/simulation/JSONInputs/Topology04.json
dream/simulation/JSONInputs/Topology04.json
+8
-11
dream/simulation/JSONInputs/Topology05.json
dream/simulation/JSONInputs/Topology05.json
+1
-3
dream/simulation/JSONInputs/Topology06.json
dream/simulation/JSONInputs/Topology06.json
+8
-11
dream/simulation/JSONInputs/Topology07.json
dream/simulation/JSONInputs/Topology07.json
+1
-3
dream/simulation/JSONInputs/Topology08.json
dream/simulation/JSONInputs/Topology08.json
+1
-3
dream/simulation/JSONInputs/Topology09.json
dream/simulation/JSONInputs/Topology09.json
+1
-3
dream/simulation/JSONInputs/Topology10.json
dream/simulation/JSONInputs/Topology10.json
+1
-3
dream/simulation/JSONInputs/Topology11.json
dream/simulation/JSONInputs/Topology11.json
+9
-13
dream/simulation/JSONInputs/Topology12.json
dream/simulation/JSONInputs/Topology12.json
+10
-14
dream/simulation/JSONInputs/Topology13.json
dream/simulation/JSONInputs/Topology13.json
+1
-3
dream/simulation/JSONInputs/Topology14.json
dream/simulation/JSONInputs/Topology14.json
+1
-3
dream/simulation/JSONInputs/Topology15.json
dream/simulation/JSONInputs/Topology15.json
+9
-12
dream/simulation/JSONInputs/Topology16.json
dream/simulation/JSONInputs/Topology16.json
+10
-16
dream/simulation/LineGenerationJSON.py
dream/simulation/LineGenerationJSON.py
+88
-100
dream/simulation/Machine.py
dream/simulation/Machine.py
+14
-32
dream/simulation/ObjectInterruption.py
dream/simulation/ObjectInterruption.py
+40
-0
dream/simulation/ObjectResource.py
dream/simulation/ObjectResource.py
+66
-0
dream/simulation/Part.py
dream/simulation/Part.py
+2
-1
dream/simulation/Queue.py
dream/simulation/Queue.py
+5
-30
dream/simulation/Repairman.py
dream/simulation/Repairman.py
+8
-22
dream/simulation/Source.py
dream/simulation/Source.py
+2
-24
dream/simulation/documents/ClassHierarchy.png
dream/simulation/documents/ClassHierarchy.png
+0
-0
No files found.
dream/simulation/Assembly.py
View file @
8e47f2ba
...
...
@@ -21,8 +21,6 @@ Created on 18 Feb 2013
@author: George
'''
'''
Models an assembly object
it gathers frames and parts which are loaded to the frames
...
...
@@ -32,9 +30,10 @@ from SimPy.Simulation import *
import
xlwt
from
RandomNumberGenerator
import
RandomNumberGenerator
import
scipy.stats
as
stat
from
CoreObject
import
CoreObject
#the Assembly object
class
Assembly
(
Process
):
class
Assembly
(
CoreObject
):
#initialize the object
def
__init__
(
self
,
id
,
name
,
dist
,
time
):
...
...
@@ -181,18 +180,12 @@ class Assembly(Process):
#checks if the Assembly can dispose an entity to the following object
def
haveToDispose
(
self
):
return
len
(
self
.
Res
.
activeQ
)
>
0
and
self
.
waitToDispose
#sets the routing in and out elements for the Assembly
def
defineRouting
(
self
,
p
,
n
):
self
.
next
=
n
self
.
previous
=
p
#removes an entity from the Assembly
def
removeEntity
(
self
):
self
.
outputTrace
(
self
.
Res
.
activeQ
[
0
].
name
,
"releases "
+
self
.
objName
)
self
.
Res
.
activeQ
.
pop
(
0
)
self
.
waitToDispose
=
False
#gets an entity from the predecessor
#it may handle both Parts and Frames
...
...
@@ -341,15 +334,5 @@ class Assembly(Process):
json
[
'results'
][
'waiting_ratio'
][
'avg'
]
=
self
.
Waiting
[
0
]
json
[
'results'
][
'waiting_ratio'
][
'max'
]
=
self
.
Waiting
[
0
]
G
.
outputJSON
[
'coreObject'
].
append
(
json
)
#takes the array and checks if all its values are identical (returns false) or not (returns true)
#needed because if somebody runs multiple runs in deterministic case it would crash!
def
checkIfArrayHasDifValues
(
self
,
array
):
difValuesFlag
=
False
for
i
in
range
(
1
,
len
(
array
)):
if
(
array
[
i
]
!=
array
[
1
]):
difValuesFlag
=
True
return
difValuesFlag
G
.
outputJSON
[
'elementList'
].
append
(
json
)
\ No newline at end of file
dream/simulation/Conveyer.py
View file @
8e47f2ba
...
...
@@ -29,9 +29,10 @@ it gathers entities and transfers them with a certain speed
from
SimPy.Simulation
import
*
import
xlwt
import
scipy.stats
as
stat
from
CoreObject
import
CoreObject
#The conveyer object
class
Conveyer
(
Process
):
class
Conveyer
(
CoreObject
):
def
__init__
(
self
,
id
,
name
,
length
,
speed
):
self
.
id
=
id
...
...
@@ -223,11 +224,6 @@ class Conveyer(Process):
#only when an entity is at the end of it
else
:
return
False
#sets the routing in and out elements for the Conveyer
def
defineRouting
(
self
,
p
,
n
):
self
.
next
=
n
self
.
previous
=
p
#checks if the conveyer is full to count the blockage. for some reason Plant regards
#the conveyer full even when it has one place
...
...
@@ -252,7 +248,6 @@ class Conveyer(Process):
return
self
.
canAcceptAndIsRequested
()
else
:
return
self
.
canAcceptAndIsRequested
()
#actions to be taken after the simulation ends
def
postProcessing
(
self
,
MaxSimtime
):
...
...
@@ -382,16 +377,7 @@ class Conveyer(Process):
json
[
'results'
][
'waiting_ratio'
][
'min'
]
=
self
.
Waiting
[
0
]
json
[
'results'
][
'waiting_ratio'
][
'avg'
]
=
self
.
Waiting
[
0
]
json
[
'results'
][
'waiting_ratio'
][
'max'
]
=
self
.
Waiting
[
0
]
G
.
outputJSON
[
'coreObject'
].
append
(
json
)
#takes the array and checks if all its values are identical (returns false) or not (returns true)
#needed because if somebody runs multiple runs in deterministic case it would crash!
def
checkIfArrayHasDifValues
(
self
,
array
):
difValuesFlag
=
False
for
i
in
range
(
1
,
len
(
array
)):
if
(
array
[
i
]
!=
array
[
1
]):
difValuesFlag
=
True
return
difValuesFlag
G
.
outputJSON
[
'elementList'
].
append
(
json
)
#Process that handles the moves of the conveyer
class
ConveyerMover
(
Process
):
...
...
dream/simulation/CoreObject.py
0 → 100644
View file @
8e47f2ba
# ===========================================================================
# Copyright 2013 Georgios Dagkakis
#
# This file is part of DREAM.
#
# DREAM is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DREAM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with DREAM. If not, see <http://www.gnu.org/licenses/>.
# ===========================================================================
'''
Created on 12 Jul 2012
@author: George
'''
'''
Class that acts as an abstract. It should have no instances. All the core-objects should inherit from it
'''
from
SimPy.Simulation
import
Process
,
Resource
#the core object
class
CoreObject
(
Process
):
def
initilize
(
self
):
Process
.
__init__
(
self
)
self
.
predecessorIndex
=
0
#holds the index of the predecessor from which the Machine will take an entity next
self
.
successorIndex
=
0
#holds the index of the successor where the Machine will dispose an entity next
self
.
Up
=
True
#Boolean that shows if the machine is in failure ("Down") or not ("up")
self
.
currentEntity
=
None
self
.
totalBlockageTime
=
0
#holds the total blockage time
self
.
totalFailureTime
=
0
#holds the total failure time
self
.
totalWaitingTime
=
0
#holds the total waiting time
self
.
totalWorkingTime
=
0
#holds the total working time
self
.
completedJobs
=
0
#holds the number of completed jobs
self
.
timeLastEntityEnded
=
0
#holds the last time that an entity ended processing in the object
self
.
nameLastEntityEnded
=
""
#holds the name of the last entity that ended processing in the object
self
.
timeLastEntityEntered
=
0
#holds the last time that an entity entered in the object
self
.
nameLastEntityEntered
=
""
#holds the name of the last entity that entered in the object
self
.
timeLastFailure
=
0
#holds the time that the last failure of the object started
self
.
timeLastFailureEnded
=
0
#holds the time that the last failure of the object Ended
self
.
downTimeProcessingCurrentEntity
=
0
#holds the time that the machine was down while processing the current entity
self
.
downTimeInTryingToReleaseCurrentEntity
=
0
#holds the time that the object was down while trying
#to release the current entity
self
.
downTimeInCurrentEntity
=
0
#holds the total time that the object was down while holding current entity
self
.
timeLastEntityLeft
=
0
#holds the last time that an entity left the object
self
.
processingTimeOfCurrentEntity
=
0
#holds the total processing time that the current entity required
self
.
waitToDispose
=
False
#shows if the object waits to dispose an entity
#the main process of the core object
#this is dummy, every object must have its own implementation
def
run
(
self
):
raise
NotImplementedError
(
"Subclass must define 'run' method"
)
#sets the routing in and out elements for the Object
def
defineRouting
(
self
,
p
,
n
):
self
.
next
=
n
self
.
previous
=
p
#removes an entity from the Object
def
removeEntity
(
self
):
self
.
Res
.
activeQ
.
pop
(
0
)
#gets an entity from the predecessor that the predecessor index points to
def
getEntity
(
self
):
self
.
Res
.
activeQ
=
[
self
.
previous
[
self
.
predecessorIndex
].
Res
.
activeQ
[
0
]]
+
self
.
Res
.
activeQ
#get the entity from the previous object
#and put it in front of the activeQ
self
.
previous
[
self
.
predecessorIndex
].
removeEntity
()
#remove the entity from the previous object
#actions to be taken after the simulation ends
def
postProcessing
(
self
,
MaxSimtime
):
pass
#outputs message to the trace.xls
def
outputTrace
(
self
,
message
):
pass
#outputs data to "output.xls"
def
outputResultsXL
(
self
,
MaxSimtime
):
pass
#outputs results to JSON File
def
outputResultsJSON
(
self
):
pass
#checks if the Object can dispose an entity to the following object
def
haveToDispose
(
self
):
return
len
(
self
.
Res
.
activeQ
)
>
0
#checks if the Object can accept an entity and there is an entity in some predecessor waiting for it
def
canAcceptAndIsRequested
(
self
):
pass
#checks if the Object can accept an entity
def
canAccept
(
self
):
pass
#takes the array and checks if all its values are identical (returns false) or not (returns true)
#needed because if somebody runs multiple runs in deterministic case it would crash!
def
checkIfArrayHasDifValues
(
self
,
array
):
difValuesFlag
=
False
for
i
in
range
(
1
,
len
(
array
)):
if
(
array
[
i
]
!=
array
[
1
]):
difValuesFlag
=
True
return
difValuesFlag
\ No newline at end of file
dream/simulation/Dismantle.py
View file @
8e47f2ba
...
...
@@ -30,9 +30,10 @@ from SimPy.Simulation import *
import
xlwt
from
RandomNumberGenerator
import
RandomNumberGenerator
import
scipy.stats
as
stat
from
CoreObject
import
CoreObject
#the Dismantle object
class
Dismantle
(
Process
):
class
Dismantle
(
CoreObject
):
#initialize the object
def
__init__
(
self
,
id
,
name
,
dist
,
time
):
...
...
@@ -52,6 +53,7 @@ class Dismantle(Process):
self
.
nextIds
=
[]
#list with the ids of the next objects in the flow
self
.
nextPartIds
=
[]
#list with the ids of the next objects that receive parts
self
.
nextFrameIds
=
[]
#list with the ids of the next objects that receive frames
self
.
next
=
[]
#lists to hold statistics of multiple runs
self
.
Waiting
=
[]
...
...
@@ -131,9 +133,8 @@ class Dismantle(Process):
def
canAccept
(
self
):
return
len
(
self
.
Res
.
activeQ
)
==
0
#sets the routing in and out elements for the Dismantle
def
defineRouting
(
self
,
p
,
np
,
nf
):
self
.
previous
=
p
#defines where parts and frames go after they leave the object
def
definePartFrameRouting
(
self
,
np
,
nf
):
self
.
nextPart
=
np
self
.
nextFrame
=
nf
...
...
@@ -339,7 +340,7 @@ class Dismantle(Process):
json
[
'results'
][
'waiting_ratio'
][
'avg'
]
=
self
.
Waiting
[
0
]
json
[
'results'
][
'waiting_ratio'
][
'max'
]
=
self
.
Waiting
[
0
]
G
.
outputJSON
[
'
coreObjec
t'
].
append
(
json
)
G
.
outputJSON
[
'
elementLis
t'
].
append
(
json
)
#takes the array and checks if all its values are identical (returns false) or not (returns true)
#needed because if somebody runs multiple runs in deterministic case it would crash!
...
...
dream/simulation/Entity.py
0 → 100644
View file @
8e47f2ba
# ===========================================================================
# Copyright 2013 Georgios Dagkakis
#
# This file is part of DREAM.
#
# DREAM is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DREAM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with DREAM. If not, see <http://www.gnu.org/licenses/>.
# ===========================================================================
'''
Created on 18 Aug 2013
@author: George
'''
'''
Class that acts as an abstract. It should have no instances. All the Entities should inherit from it
'''
#The entity object
class
Entity
(
object
):
def
__init__
(
self
,
name
):
self
.
type
=
"Entity"
self
.
name
=
name
self
.
currentStop
=
None
#contains the current object that the material is in
self
.
creationTime
=
0
self
.
startTime
=
0
#holds the startTime for the lifespan
#dimension data
self
.
width
=
1.0
self
.
height
=
1.0
self
.
length
=
1.0
\ No newline at end of file
dream/simulation/Exit.py
View file @
8e47f2ba
...
...
@@ -28,9 +28,10 @@ models the exit of the model
from
SimPy.Simulation
import
*
import
xlwt
import
scipy.stats
as
stat
from
CoreObject
import
CoreObject
#The exit object
class
Exit
(
Process
):
class
Exit
(
CoreObject
):
def
__init__
(
self
,
id
,
name
):
Process
.
__init__
(
self
)
...
...
@@ -212,9 +213,10 @@ class Exit(Process):
json
[
'_class'
]
=
'Dream.Exit'
;
json
[
'id'
]
=
str
(
self
.
id
)
json
[
'results'
]
=
{}
json
[
'results'
][
'throughput'
]
=
self
.
numOfExits
json
[
'results'
][
'lifespan'
]
=
((
self
.
totalLifespan
)
/
self
.
numOfExits
)
/
G
.
Base
json
[
'results'
][
'takt_time'
]
=
((
self
.
totalTaktTime
)
/
self
.
numOfExits
)
/
G
.
Base
json
[
'results'
][
'throughput'
]
=
self
.
numOfExits
json
[
'results'
][
'lifespan'
]
=
self
.
Lifespan
[
0
]
json
[
'results'
][
'takt_time'
]
=
self
.
TaktTime
[
0
]
else
:
#if we had multiple replications we output confidence intervals to excel
#for some outputs the results may be the same for each run (eg model is stochastic but failures fixed
#so failurePortion will be exactly the same in each run). That will give 0 variability and errors.
...
...
@@ -251,13 +253,5 @@ class Exit(Process):
json
[
'results'
][
'taktTime'
][
'min'
]
=
self
.
TaktTime
[
0
]
json
[
'results'
][
'taktTime'
][
'avg'
]
=
self
.
TaktTime
[
0
]
json
[
'results'
][
'taktTime'
][
'max'
]
=
self
.
TaktTime
[
0
]
G
.
outputJSON
[
'
coreObjec
t'
].
append
(
json
)
G
.
outputJSON
[
'
elementLis
t'
].
append
(
json
)
#takes the array and checks if all its values are identical (returns false) or not (returns true)
#needed because if somebody runs multiple runs in deterministic case it would crash!
def
checkIfArrayHasDifValues
(
self
,
array
):
difValuesFlag
=
False
for
i
in
range
(
1
,
len
(
array
)):
if
(
array
[
i
]
!=
array
[
1
]):
difValuesFlag
=
True
return
difValuesFlag
\ No newline at end of file
dream/simulation/Failure.py
View file @
8e47f2ba
...
...
@@ -26,12 +26,12 @@ Created on 9 Nov 2012
models the failures that servers can have
'''
from
SimPy.Simulation
import
*
import
math
from
RandomNumberGenerator
import
RandomNumberGenerator
from
ObjectInterruption
import
ObjectInterruption
class
Failure
(
Process
):
class
Failure
(
ObjectInterruption
):
def
__init__
(
self
,
victim
,
dist
,
MTTF
,
MTTR
,
availability
,
index
,
repairman
):
Process
.
__init__
(
self
)
...
...
@@ -122,6 +122,3 @@ class Failure(Process):
G
.
sheetIndex
+=
1
G
.
traceSheet
=
G
.
traceFile
.
add_sheet
(
'sheet '
+
str
(
G
.
sheetIndex
),
cell_overwrite_ok
=
True
)
#outputs data to "output.xls"
def
outputResultsXL
(
self
,
MaxSimtime
):
pass
\ No newline at end of file
dream/simulation/Frame.py
View file @
8e47f2ba
...
...
@@ -28,13 +28,15 @@ models a frame entity. This can flow through the system and carry parts
from
SimPy.Simulation
import
*
from
Globals
import
G
from
Entity
import
Entity
#The entity object
class
Frame
(
object
):
class
Frame
(
Entity
):
type
=
"Frame"
numOfParts
=
4
#the number of parts that the frame can take
def
__init__
(
self
,
name
):
self
.
type
=
"Frame"
self
.
name
=
name
self
.
currentStop
=
None
#contains the current object that the material is in
self
.
creationTime
=
0
...
...
dream/simulation/JSONInputs/Topology01.json
View file @
8e47f2ba
...
...
@@ -6,14 +6,13 @@
"trace"
:
"No"
,
"confidenceLevel"
:
"0.95"
},
"
modelResource
"
:
[
{
"_class"
:
"Dream.Repairman"
,
"
elementList
"
:
[
{
"_class"
:
"Dream.Repairman"
,
"id"
:
"W1"
,
"name"
:
"W1"
,
"capacity"
:
"1"
}
],
"coreObject"
:
[
"name"
:
"W1"
,
"capacity"
:
"1"
,
"successorList"
:
[
"M1"
,
"M2"
]
},
{
"_class"
:
"Dream.Source"
,
"id"
:
"S1"
,
"name"
:
"Raw Material"
,
...
...
@@ -35,8 +34,7 @@
"failures"
:{
"failureDistribution"
:
"Fixed"
,
"MTTF"
:
"60"
,
"MTTR"
:
"5"
,
"repairman"
:
"W1"
"MTTR"
:
"5"
},
"successorList"
:
[
"Q1"
]
},
...
...
@@ -50,8 +48,7 @@
"failures"
:{
"failureDistribution"
:
"Fixed"
,
"MTTF"
:
"40"
,
"MTTR"
:
"10"
,
"repairman"
:
"W1"
"MTTR"
:
"10"
},
"successorList"
:
[
"E1"
]
},
...
...
dream/simulation/JSONInputs/Topology02.json
View file @
8e47f2ba
...
...
@@ -6,9 +6,7 @@
"trace"
:
"No"
,
"confidenceLevel"
:
"0.95"
},
"modelResource"
:
[
],
"coreObject"
:
[
"elementList"
:
[
{
"_class"
:
"Dream.Source"
,
"id"
:
"S1"
,
"name"
:
"Parts"
,
...
...
dream/simulation/JSONInputs/Topology03.json
View file @
8e47f2ba
...
...
@@ -6,14 +6,13 @@
"trace"
:
"No"
,
"confidenceLevel"
:
"0.95"
},
"modelResource"
:
[
{
"_class"
:
"Dream.Repairman"
,
"id"
:
"W1"
,
"name"
:
"W1"
,
"capacity"
:
"1"
}
],
"coreObject"
:
[
"elementList"
:
[
{
"_class"
:
"Dream.Repairman"
,
"id"
:
"W1"
,
"name"
:
"W1"
,
"capacity"
:
"1"
,
"successorList"
:
[
"M1"
,
"M2"
]
},
{
"_class"
:
"Dream.Source"
,
"id"
:
"S1"
,
"name"
:
"Raw Material"
,
...
...
@@ -35,8 +34,7 @@
"failures"
:{
"failureDistribution"
:
"Fixed"
,
"MTTF"
:
"60"
,
"MTTR"
:
"5"
,
"repairman"
:
"W1"
"MTTR"
:
"5"
},
"successorList"
:
[
"M2"
]
},
...
...
@@ -50,8 +48,7 @@
"failures"
:{
"failureDistribution"
:
"Fixed"
,
"MTTF"
:
"40"
,
"MTTR"
:
"10"
,
"repairman"
:
"W1"
"MTTR"
:
"10"
},
"successorList"
:
[
"E1"
]
},
...
...
dream/simulation/JSONInputs/Topology04.json
View file @
8e47f2ba
...
...
@@ -6,14 +6,13 @@
"trace"
:
"No"
,
"confidenceLevel"
:
"0.95"
},
"
modelResource
"
:
[
{
"_class"
:
"Dream.Repairman"
,
"
elementList
"
:
[
{
"_class"
:
"Dream.Repairman"
,
"id"
:
"W1"
,
"name"
:
"W1"
,
"capacity"
:
"1"
}
],
"coreObject"
:
[
"name"
:
"W1"
,
"capacity"
:
"1"
,
"successorList"
:
[
"M1"
,
"M2"
]
},
{
"_class"
:
"Dream.Source"
,
"id"
:
"S1"
,
"name"
:
"Raw Material"
,
...
...
@@ -35,8 +34,7 @@
"failures"
:{
"failureDistribution"
:
"Fixed"
,
"MTTF"
:
"60"
,
"MTTR"
:
"5"
,
"repairman"
:
"W1"
"MTTR"
:
"5"
},
"successorList"
:
[
"E1"
]
},
...
...
@@ -50,8 +48,7 @@
"failures"
:{
"failureDistribution"
:
"Fixed"
,
"MTTF"
:
"40"
,
"MTTR"
:
"10"
,
"repairman"
:
"W1"
"MTTR"
:
"10"
},
"successorList"
:
[
"Q1"
]
},
...
...
dream/simulation/JSONInputs/Topology05.json
View file @
8e47f2ba
...
...
@@ -6,9 +6,7 @@
"trace"
:
"No"
,
"confidenceLevel"
:
"0.95"
},
"modelResource"
:
[
],
"coreObject"
:
[
"elementList"
:
[
{
"_class"
:
"Dream.Source"
,
"id"
:
"S1"
,
"name"
:
"Parts"
,
...
...
dream/simulation/JSONInputs/Topology06.json
View file @
8e47f2ba
...
...
@@ -6,14 +6,13 @@
"trace"
:
"No"
,
"confidenceLevel"
:
"0.95"
},
"
modelResource
"
:
[
{
"_class"
:
"Dream.Repairman"
,
"
elementList
"
:
[
{
"_class"
:
"Dream.Repairman"
,
"id"
:
"W1"
,
"name"
:
"W1"
,
"capacity"
:
"1"
}
],
"coreObject"
:
[
"name"
:
"W1"
,
"capacity"
:
"1"
,
"successorList"
:
[
"M1"
,
"M2"
]
},
{
"_class"
:
"Dream.Source"
,
"id"
:
"S1"
,
"name"
:
"Raw Material"
,
...
...
@@ -35,8 +34,7 @@
"failures"
:{
"failureDistribution"
:
"Fixed"
,
"MTTF"
:
"60"
,
"MTTR"
:
"5"
,
"repairman"
:
"W1"
"MTTR"
:
"5"
},
"successorList"
:
[
"Q1"
]
},
...
...
@@ -50,8 +48,7 @@
"failures"
:{
"failureDistribution"
:
"Fixed"
,
"MTTF"
:
"40"
,
"MTTR"
:
"10"
,
"repairman"
:
"W1"
"MTTR"
:
"10"
},
"successorList"
:
[
"M3"
]
},
...
...
dream/simulation/JSONInputs/Topology07.json
View file @
8e47f2ba
...
...
@@ -6,9 +6,7 @@
"trace"
:
"No"
,
"confidenceLevel"
:
"0.95"
},
"modelResource"
:
[
],
"coreObject"
:
[
"elementList"
:
[
{
"_class"
:
"Dream.Source"
,
"id"
:
"S1"
,
"name"
:
"Raw Material 1"
,
...
...
dream/simulation/JSONInputs/Topology08.json
View file @
8e47f2ba
...
...
@@ -6,9 +6,7 @@
"trace"
:
"No"
,
"confidenceLevel"
:
"0.95"
},
"modelResource"
:
[
],
"coreObject"
:
[
"elementList"
:
[
{
"_class"
:
"Dream.Source"
,
"id"
:
"S1"
,
"name"
:
"Raw Material 1"
,
...
...
dream/simulation/JSONInputs/Topology09.json
View file @
8e47f2ba
...
...
@@ -6,9 +6,7 @@
"trace"
:
"No"
,
"confidenceLevel"
:
"0.95"
},
"modelResource"
:
[
],
"coreObject"
:
[
"elementList"
:
[
{
"_class"
:
"Dream.Source"
,
"id"
:
"S1"
,
"name"
:
"Raw Material"
,
...
...
dream/simulation/JSONInputs/Topology10.json
View file @
8e47f2ba
...
...
@@ -6,9 +6,7 @@
"trace"
:
"No"
,
"confidenceLevel"
:
"0.95"
},
"modelResource"
:
[
],
"coreObject"
:
[
"elementList"
:
[
{
"_class"
:
"Dream.Source"
,
"id"
:
"S1"
,
"name"
:
"Raw Material 1"
,
...
...
dream/simulation/JSONInputs/Topology11.json
View file @
8e47f2ba
...
...
@@ -7,15 +7,13 @@
"trace"
:
"No"
,
"confidenceLevel"
:
"0.95"
},
"modelResource"
:
[
{
"_class"
:
"Dream.Repairman"
,
"id"
:
"W1"
,
"name"
:
"W1"
,
"capacity"
:
"1"
}
],
"coreObject"
:
[
"elementList"
:
[
{
"_class"
:
"Dream.Repairman"
,
"id"
:
"W1"
,
"name"
:
"W1"
,
"capacity"
:
"1"
,
"successorList"
:
[
"M1"
,
"M2"
]
},
{
"_class"
:
"Dream.Source"
,
"id"
:
"S1"
,
...
...
@@ -38,8 +36,7 @@
"failures"
:
{
"failureDistribution"
:
"No"
,
"MTTF"
:
"60"
,
"MTTR"
:
"5"
,
"repairman"
:
"W1"
"MTTR"
:
"5"
},
"successorList"
:
[
"M3"
]
},
...
...
@@ -54,8 +51,7 @@
"failures"
:
{
"failureDistribution"
:
"No"
,
"MTTF"
:
"40"
,
"MTTR"
:
"10"
,
"repairman"
:
"W1"
"MTTR"
:
"10"
},
"successorList"
:
[
"M3"
]
},
...
...
dream/simulation/JSONInputs/Topology12.json
View file @
8e47f2ba
...
...
@@ -7,16 +7,14 @@
"trace"
:
"No"
,
"confidenceLevel"
:
"0.95"
},
"modelResource"
:
[
{
"_class"
:
"Dream.Repairman"
,
"id"
:
"W1"
,
"name"
:
"W1"
,
"capacity"
:
"1"
}
],
"coreObject"
:
[
{
"elementList"
:
[
{
"_class"
:
"Dream.Repairman"
,
"id"
:
"W1"
,
"name"
:
"W1"
,
"capacity"
:
"1"
,
"successorList"
:
[]
},
{
"_class"
:
"Dream.Source"
,
"id"
:
"S1"
,
"name"
:
"Raw Material"
,
...
...
@@ -38,8 +36,7 @@
"failures"
:
{
"failureDistribution"
:
"No"
,
"MTTF"
:
"60"
,
"MTTR"
:
"5"
,
"repairman"
:
"W1"
"MTTR"
:
"5"
},
"successorList"
:
[
"M3"
,
"M4"
]
},
...
...
@@ -54,8 +51,7 @@
"failures"
:
{
"failureDistribution"
:
"No"
,
"MTTF"
:
"40"
,
"MTTR"
:
"10"
,
"repairman"
:
"W1"
"MTTR"
:
"10"
},
"successorList"
:
[
"M3"
,
"M4"
]
},
...
...
dream/simulation/JSONInputs/Topology13.json
View file @
8e47f2ba
...
...
@@ -6,9 +6,7 @@
"trace"
:
"No"
,
"confidenceLevel"
:
"0.95"
},
"modelResource"
:
[
],
"coreObject"
:
[
"elementList"
:
[
{
"_class"
:
"Dream.Source"
,
"id"
:
"S1"
,
"name"
:
"Parts"
,
...
...
dream/simulation/JSONInputs/Topology14.json
View file @
8e47f2ba
...
...
@@ -6,9 +6,7 @@
"trace"
:
"No"
,
"confidenceLevel"
:
"0.95"
},
"modelResource"
:
[
],
"coreObject"
:
[
"elementList"
:
[
{
"_class"
:
"Dream.Source"
,
"id"
:
"S1"
,
"name"
:
"Parts"
,
...
...
dream/simulation/JSONInputs/Topology15.json
View file @
8e47f2ba
...
...
@@ -6,14 +6,13 @@
"trace"
:
"No"
,
"confidenceLevel"
:
"0.95"
},
"modelResource"
:
[
{
"_class"
:
"Dream.Repairman"
,
"id"
:
"W1"
,
"name"
:
"W1"
,
"capacity"
:
"1"
}
],
"coreObject"
:
[
"elementList"
:
[
{
"_class"
:
"Dream.Repairman"
,
"id"
:
"W1"
,
"name"
:
"W1"
,
"capacity"
:
"1"
,
"successorList"
:
[
"M1"
,
"M2"
]
},
{
"_class"
:
"Dream.Source"
,
"id"
:
"S1"
,
"name"
:
"Raw Material"
,
...
...
@@ -35,8 +34,7 @@
"failures"
:{
"failureDistribution"
:
"Fixed"
,
"MTTF"
:
"60"
,
"MTTR"
:
"5"
,
"repairman"
:
"W1"
"MTTR"
:
"5"
},
"successorList"
:
[
"C1"
]
},
...
...
@@ -50,8 +48,7 @@
"failures"
:{
"failureDistribution"
:
"Fixed"
,
"MTTF"
:
"40"
,
"MTTR"
:
"10"
,
"repairman"
:
"W1"
"MTTR"
:
"10"
},
"successorList"
:
[
"E1"
]
},
...
...
dream/simulation/JSONInputs/Topology16.json
View file @
8e47f2ba
...
...
@@ -6,14 +6,13 @@
"trace"
:
"No"
,
"confidenceLevel"
:
"0.95"
},
"modelResource"
:
[
{
"_class"
:
"Dream.Repairman"
,
"id"
:
"W1"
,
"name"
:
"W1"
,
"capacity"
:
"1"
}
],
"coreObject"
:
[
"elementList"
:
[
{
"_class"
:
"Dream.Repairman"
,
"id"
:
"W1"
,
"name"
:
"W1"
,
"capacity"
:
"1"
,
"successorList"
:
[
"M1"
,
"M2"
]
},
{
"_class"
:
"Dream.Source"
,
"id"
:
"S1"
,
"name"
:
"Raw Material"
,
...
...
@@ -35,8 +34,7 @@
"failures"
:{
"failureDistribution"
:
"Fixed"
,
"MTTF"
:
"60"
,
"MTTR"
:
"5"
,
"repairman"
:
"W1"
"MTTR"
:
"5"
},
"successorList"
:
[
"C1"
]
},
...
...
@@ -50,8 +48,7 @@
"failures"
:{
"failureDistribution"
:
"Fixed"
,
"MTTF"
:
"40"
,
"MTTR"
:
"10"
,
"repairman"
:
"W1"
"MTTR"
:
"10"
},
"successorList"
:
[
"M3"
]
},
...
...
@@ -77,10 +74,7 @@
"mean"
:
"3"
},
"failures"
:{
"failureDistribution"
:
"No"
,
"MTTF"
:
"40"
,
"MTTR"
:
"10"
,
"repairman"
:
"W1"
"failureDistribution"
:
"No"
},
"successorList"
:
[
"E1"
]
},
...
...
dream/simulation/LineGenerationJSON.py
View file @
8e47f2ba
...
...
@@ -16,6 +16,7 @@
# You should have received a copy of the GNU Lesser General Public License
# along with DREAM. If not, see <http://www.gnu.org/licenses/>.
# ===========================================================================
'''
Created on 7 May 2013
...
...
@@ -70,8 +71,8 @@ def readGeneralInput():
#creates the simulation objects
def
createObjects
():
#Read the json data
coreObjectList
=
G
.
JSONData
[
'coreObjec
t'
]
modelResourceList
=
G
.
JSONData
[
'modelResource'
]
elementList
=
G
.
JSONData
[
'elementLis
t'
]
#
modelResourceList = G.JSONData['modelResource']
#define the lists
G
.
SourceList
=
[]
...
...
@@ -83,92 +84,94 @@ def createObjects():
G
.
DismantleList
=
[]
G
.
ConveyerList
=
[]
#loop through all the model resources
#search for repairmen in order to create them
#read the data and create them
for
model_resource
in
modelResource
List
:
resourceClass
=
model_resource
.
get
(
'_class'
,
'not found'
)
for
element
in
element
List
:
resourceClass
=
element
.
get
(
'_class'
,
'not found'
)
if
resourceClass
==
'Dream.Repairman'
:
id
=
model_resource
.
get
(
'id'
,
'not found'
)
name
=
model_resource
.
get
(
'name'
,
'not found'
)
capacity
=
int
(
model_resource
.
get
(
'capacity'
,
'1'
))
id
=
element
.
get
(
'id'
,
'not found'
)
name
=
element
.
get
(
'name'
,
'not found'
)
capacity
=
int
(
element
.
get
(
'capacity'
,
'1'
))
successorList
=
element
.
get
(
'successorList'
,
'not found'
)
R
=
Repairman
(
id
,
name
,
capacity
)
G
.
RepairmanList
.
append
(
R
)
R
.
coreObjectIds
=
successorList
G
.
RepairmanList
.
append
(
R
)
#loop through all the
core objec
ts
#loop through all the
elemen
ts
#read the data and create them
for
core_object
in
coreObjec
tList
:
objClass
=
core_objec
t
.
get
(
'_class'
,
'not found'
)
for
element
in
elemen
tList
:
objClass
=
elemen
t
.
get
(
'_class'
,
'not found'
)
if
objClass
==
'Dream.Source'
:
id
=
core_objec
t
.
get
(
'id'
,
'not found'
)
name
=
core_objec
t
.
get
(
'name'
,
'not found'
)
interarrivalTime
=
core_objec
t
.
get
(
'interarrivalTime'
,
'not found'
)
id
=
elemen
t
.
get
(
'id'
,
'not found'
)
name
=
elemen
t
.
get
(
'name'
,
'not found'
)
interarrivalTime
=
elemen
t
.
get
(
'interarrivalTime'
,
'not found'
)
distributionType
=
interarrivalTime
.
get
(
'distributionType'
,
'not found'
)
mean
=
float
(
interarrivalTime
.
get
(
'mean'
,
'0'
))
entity
=
str_to_class
(
core_objec
t
.
get
(
'entity'
,
'not found'
))
successorList
=
core_object
.
get
(
'successorList'
,
'not found'
)
entity
=
str_to_class
(
elemen
t
.
get
(
'entity'
,
'not found'
))
successorList
=
element
.
get
(
'successorList'
,
'not found'
)
S
=
Source
(
id
,
name
,
distributionType
,
mean
,
entity
)
S
.
nextIds
=
successorList
G
.
SourceList
.
append
(
S
)
G
.
ObjList
.
append
(
S
)
elif
objClass
==
'Dream.Machine'
:
id
=
core_objec
t
.
get
(
'id'
,
'not found'
)
name
=
core_objec
t
.
get
(
'name'
,
'not found'
)
processingTime
=
core_objec
t
.
get
(
'processingTime'
,
'not found'
)
id
=
elemen
t
.
get
(
'id'
,
'not found'
)
name
=
elemen
t
.
get
(
'name'
,
'not found'
)
processingTime
=
elemen
t
.
get
(
'processingTime'
,
'not found'
)
distributionType
=
processingTime
.
get
(
'distributionType'
,
'not found'
)
mean
=
float
(
processingTime
.
get
(
'mean'
,
'0'
))
stdev
=
float
(
processingTime
.
get
(
'stdev'
,
'0'
))
min
=
float
(
processingTime
.
get
(
'min'
,
'0'
))
max
=
float
(
processingTime
.
get
(
'max'
,
'0'
))
failures
=
core_objec
t
.
get
(
'failures'
,
'not found'
)
failures
=
elemen
t
.
get
(
'failures'
,
'not found'
)
failureDistribution
=
failures
.
get
(
'failureDistribution'
,
'not found'
)
MTTF
=
float
(
failures
.
get
(
'MTTF'
,
'0'
))
MTTR
=
float
(
failures
.
get
(
'MTTR'
,
'0'
))
availability
=
float
(
failures
.
get
(
'availability'
,
'0'
))
needRepairman
=
failures
.
get
(
'repairman'
,
'None'
)
if
(
needRepairman
==
'None'
):
repairman
=
needRepairman
else
:
for
j
in
range
(
len
(
G
.
RepairmanList
)):
if
(
G
.
RepairmanList
[
j
].
id
==
needRepairman
):
repairman
=
G
.
RepairmanList
[
j
]
successorList
=
core_object
.
get
(
'successorList'
,
'not found'
)
r
=
'None'
for
repairman
in
G
.
RepairmanList
:
if
(
id
in
repairman
.
coreObjectIds
):
r
=
repairman
successorList
=
element
.
get
(
'successorList'
,
'not found'
)
M
=
Machine
(
id
,
name
,
1
,
distributionType
,
[
mean
,
stdev
,
min
,
max
],
failureDistribution
,
MTTF
,
MTTR
,
availability
,
r
epairman
)
MTTF
,
MTTR
,
availability
,
r
)
M
.
nextIds
=
successorList
G
.
MachineList
.
append
(
M
)
G
.
ObjList
.
append
(
M
)
elif
objClass
==
'Dream.Exit'
:
id
=
core_objec
t
.
get
(
'id'
,
'not found'
)
name
=
core_objec
t
.
get
(
'name'
,
'not found'
)
id
=
elemen
t
.
get
(
'id'
,
'not found'
)
name
=
elemen
t
.
get
(
'name'
,
'not found'
)
E
=
Exit
(
id
,
name
)
G
.
ExitList
.
append
(
E
)
G
.
ObjList
.
append
(
E
)
elif
objClass
==
'Dream.Queue'
:
id
=
core_objec
t
.
get
(
'id'
,
'not found'
)
name
=
core_objec
t
.
get
(
'name'
,
'not found'
)
successorList
=
core_objec
t
.
get
(
'successorList'
,
'not found'
)
capacity
=
int
(
core_objec
t
.
get
(
'capacity'
,
'1'
))
isDummy
=
bool
(
int
(
core_objec
t
.
get
(
'isDummy'
,
'0'
)))
id
=
elemen
t
.
get
(
'id'
,
'not found'
)
name
=
elemen
t
.
get
(
'name'
,
'not found'
)
successorList
=
elemen
t
.
get
(
'successorList'
,
'not found'
)
capacity
=
int
(
elemen
t
.
get
(
'capacity'
,
'1'
))
isDummy
=
bool
(
int
(
elemen
t
.
get
(
'isDummy'
,
'0'
)))
Q
=
Queue
(
id
,
name
,
capacity
,
isDummy
)
Q
.
nextIds
=
successorList
G
.
QueueList
.
append
(
Q
)
G
.
ObjList
.
append
(
Q
)
elif
objClass
==
'Dream.Assembly'
:
id
=
core_objec
t
.
get
(
'id'
,
'not found'
)
name
=
core_objec
t
.
get
(
'name'
,
'not found'
)
processingTime
=
core_objec
t
.
get
(
'processingTime'
,
'not found'
)
id
=
elemen
t
.
get
(
'id'
,
'not found'
)
name
=
elemen
t
.
get
(
'name'
,
'not found'
)
processingTime
=
elemen
t
.
get
(
'processingTime'
,
'not found'
)
distributionType
=
processingTime
.
get
(
'distributionType'
,
'not found'
)
mean
=
float
(
processingTime
.
get
(
'mean'
,
'0'
))
stdev
=
float
(
processingTime
.
get
(
'stdev'
,
'0'
))
min
=
float
(
processingTime
.
get
(
'min'
,
'0'
))
max
=
float
(
processingTime
.
get
(
'max'
,
'0'
))
#predecessorPartList=
core_objec
t.get('predecessorPartList', 'not found')
#predecessorFrameList=
core_objec
t.get('predecessorFrameList', 'not found')
successorList
=
core_objec
t
.
get
(
'successorList'
,
'not found'
)
#predecessorPartList=
elemen
t.get('predecessorPartList', 'not found')
#predecessorFrameList=
elemen
t.get('predecessorFrameList', 'not found')
successorList
=
elemen
t
.
get
(
'successorList'
,
'not found'
)
A
=
Assembly
(
id
,
name
,
distributionType
,
[
mean
,
stdev
,
min
,
max
])
#A.previousPartIds=predecessorPartList
#A.previousFrameIds=predecessorFrameList
...
...
@@ -177,17 +180,17 @@ def createObjects():
G
.
ObjList
.
append
(
A
)
elif
objClass
==
'Dream.Dismantle'
:
id
=
core_objec
t
.
get
(
'id'
,
'not found'
)
name
=
core_objec
t
.
get
(
'name'
,
'not found'
)
processingTime
=
core_objec
t
.
get
(
'processingTime'
,
'not found'
)
id
=
elemen
t
.
get
(
'id'
,
'not found'
)
name
=
elemen
t
.
get
(
'name'
,
'not found'
)
processingTime
=
elemen
t
.
get
(
'processingTime'
,
'not found'
)
distributionType
=
processingTime
.
get
(
'distributionType'
,
'not found'
)
mean
=
float
(
processingTime
.
get
(
'mean'
,
'0'
))
stdev
=
float
(
processingTime
.
get
(
'stdev'
,
'0'
))
min
=
float
(
processingTime
.
get
(
'min'
,
'0'
))
max
=
float
(
processingTime
.
get
(
'max'
,
'0'
))
successorList
=
core_objec
t
.
get
(
'successorList'
,
'not found'
)
successorPartList
=
core_objec
t
.
get
(
'successorPartList'
,
'not found'
)
successorFrameList
=
core_objec
t
.
get
(
'successorFrameList'
,
'not found'
)
successorList
=
elemen
t
.
get
(
'successorList'
,
'not found'
)
successorPartList
=
elemen
t
.
get
(
'successorPartList'
,
'not found'
)
successorFrameList
=
elemen
t
.
get
(
'successorFrameList'
,
'not found'
)
D
=
Dismantle
(
id
,
name
,
distributionType
,
[
mean
,
stdev
,
min
,
max
])
D
.
nextPartIds
=
successorPartList
D
.
nextFrameIds
=
successorFrameList
...
...
@@ -196,11 +199,11 @@ def createObjects():
G
.
ObjList
.
append
(
D
)
elif
objClass
==
'Dream.Conveyer'
:
id
=
core_objec
t
.
get
(
'id'
,
'not found'
)
name
=
core_objec
t
.
get
(
'name'
,
'not found'
)
length
=
float
(
core_objec
t
.
get
(
'length'
,
'10'
))
speed
=
float
(
core_objec
t
.
get
(
'speed'
,
'1'
))
successorList
=
core_objec
t
.
get
(
'successorList'
,
'not found'
)
id
=
elemen
t
.
get
(
'id'
,
'not found'
)
name
=
elemen
t
.
get
(
'name'
,
'not found'
)
length
=
float
(
elemen
t
.
get
(
'length'
,
'10'
))
speed
=
float
(
elemen
t
.
get
(
'speed'
,
'1'
))
successorList
=
elemen
t
.
get
(
'successorList'
,
'not found'
)
C
=
Conveyer
(
id
,
name
,
length
,
speed
)
C
.
nextIds
=
successorList
G
.
ObjList
.
append
(
C
)
...
...
@@ -208,51 +211,51 @@ def createObjects():
#loop through all the core objects
#to read predecessors
for
core_objec
t
in
G
.
ObjList
:
for
elemen
t
in
G
.
ObjList
:
#loop through all the nextIds of the object
for
nextId
in
core_objec
t
.
nextIds
:
for
nextId
in
elemen
t
.
nextIds
:
#loop through all the core objects to find the on that has the id that was read in the successorList
for
possible_successor
in
G
.
ObjList
:
if
possible_successor
.
id
==
nextId
:
possible_successor
.
previousIds
.
append
(
core_objec
t
.
id
)
possible_successor
.
previousIds
.
append
(
elemen
t
.
id
)
#defines the topology (predecessors and successors for all the objects)
def
setTopology
():
#loop through all the objects
for
core_objec
t
in
G
.
ObjList
:
for
elemen
t
in
G
.
ObjList
:
next
=
[]
previous
=
[]
for
j
in
range
(
len
(
core_objec
t
.
previousIds
)):
for
j
in
range
(
len
(
elemen
t
.
previousIds
)):
for
q
in
range
(
len
(
G
.
ObjList
)):
if
G
.
ObjList
[
q
].
id
==
core_objec
t
.
previousIds
[
j
]:
if
G
.
ObjList
[
q
].
id
==
elemen
t
.
previousIds
[
j
]:
previous
.
append
(
G
.
ObjList
[
q
])
for
j
in
range
(
len
(
core_objec
t
.
nextIds
)):
for
j
in
range
(
len
(
elemen
t
.
nextIds
)):
for
q
in
range
(
len
(
G
.
ObjList
)):
if
G
.
ObjList
[
q
].
id
==
core_objec
t
.
nextIds
[
j
]:
if
G
.
ObjList
[
q
].
id
==
elemen
t
.
nextIds
[
j
]:
next
.
append
(
G
.
ObjList
[
q
])
if
core_object
.
type
==
"Source"
:
core_object
.
defineRouting
(
next
)
elif
core_object
.
type
==
"Exit"
:
core_object
.
defineRouting
(
previous
)
if
element
.
type
==
"Source"
:
element
.
defineRouting
(
next
)
elif
element
.
type
==
"Exit"
:
element
.
defineRouting
(
previous
)
#Dismantle should be changed to identify what the the successor is.
#nextPart and nextFrame will become problematic
elif
core_objec
t
.
type
==
"Dismantle"
:
elif
elemen
t
.
type
==
"Dismantle"
:
nextPart
=
[]
nextFrame
=
[]
for
j
in
range
(
len
(
core_objec
t
.
nextPartIds
)):
for
j
in
range
(
len
(
elemen
t
.
nextPartIds
)):
for
q
in
range
(
len
(
G
.
ObjList
)):
if
G
.
ObjList
[
q
].
id
==
core_objec
t
.
nextPartIds
[
j
]:
if
G
.
ObjList
[
q
].
id
==
elemen
t
.
nextPartIds
[
j
]:
nextPart
.
append
(
G
.
ObjList
[
q
])
for
j
in
range
(
len
(
core_objec
t
.
nextFrameIds
)):
for
j
in
range
(
len
(
elemen
t
.
nextFrameIds
)):
for
q
in
range
(
len
(
G
.
ObjList
)):
if
G
.
ObjList
[
q
].
id
==
core_objec
t
.
nextFrameIds
[
j
]:
if
G
.
ObjList
[
q
].
id
==
elemen
t
.
nextFrameIds
[
j
]:
nextFrame
.
append
(
G
.
ObjList
[
q
])
core_object
.
defineRouting
(
previous
,
nextPart
,
nextFrame
)
element
.
defineRouting
(
previous
,
next
)
element
.
definePartFrameRouting
(
nextPart
,
nextFrame
)
else
:
core_objec
t
.
defineRouting
(
previous
,
next
)
elemen
t
.
defineRouting
(
previous
,
next
)
#used to convert a string read from the input to object type
def
str_to_class
(
str
):
...
...
@@ -260,16 +263,16 @@ def str_to_class(str):
#initializes all the objects that are in the topology
def
initializeObjects
():
for
core_objec
t
in
G
.
ObjList
:
core_objec
t
.
initialize
()
for
elemen
t
in
G
.
ObjList
:
elemen
t
.
initialize
()
for
repairman
in
G
.
RepairmanList
:
repairman
.
initialize
()
#activates all the objects
def
activateObjects
():
for
core_objec
t
in
G
.
ObjList
:
for
elemen
t
in
G
.
ObjList
:
try
:
activate
(
core_object
,
core_objec
t
.
run
())
activate
(
element
,
elemen
t
.
run
())
except
AttributeError
:
pass
...
...
@@ -314,39 +317,24 @@ def main(argv=[], input_data=None):
simulate
(
until
=
G
.
maxSimTime
)
#start the simulation
#carry on the post processing operations for every object in the topology
for
core_objec
t
in
G
.
ObjList
:
core_objec
t
.
postProcessing
(
G
.
maxSimTime
)
for
elemen
t
in
G
.
ObjList
:
elemen
t
.
postProcessing
(
G
.
maxSimTime
)
#carry on the post processing operations for every model resource in the topology
for
model_resource
in
G
.
RepairmanList
:
model_resource
.
postProcessing
(
G
.
maxSimTime
)
'''
#output trace to excel
if(G.trace=="Yes"):
G.traceFile.save('trace'+str(i+1)+'.xls')
G.traceIndex=0 #index that shows in what row we are
G.sheetIndex=1 #index that shows in what sheet we are
G.traceFile = xlwt.Workbook() #create excel file
G.traceSheet = G.traceFile.add_sheet('sheet '+str(G.sheetIndex), cell_overwrite_ok=True) #create excel sheet
G.outputSheet.write(G.outputIndex,0, "Execution Time")
G.outputSheet.write(G.outputIndex,1, str(time.time()-start)+" seconds")
G.outputIndex+=2
'''
model_resource
.
postProcessing
(
G
.
maxSimTime
)
G
.
outputJSONFile
=
open
(
'outputJSON.json'
,
mode
=
'w'
)
G
.
outputJSON
[
'_class'
]
=
'Dream.Simulation'
;
G
.
outputJSON
[
'general'
]
=
{};
G
.
outputJSON
[
'general'
][
'_class'
]
=
'Dream.Configuration'
;
G
.
outputJSON
[
'general'
][
'totalExecutionTime'
]
=
(
time
.
time
()
-
start
);
G
.
outputJSON
[
'modelResource'
]
=
[];
G
.
outputJSON
[
'coreObject'
]
=
[];
G
.
outputJSON
[
'elementList'
]
=
[];
#output data to JSON for every object in the topology
for
core_objec
t
in
G
.
ObjList
:
for
elemen
t
in
G
.
ObjList
:
try
:
core_objec
t
.
outputResultsJSON
()
elemen
t
.
outputResultsJSON
()
except
AttributeError
:
pass
...
...
@@ -375,7 +363,7 @@ def main(argv=[], input_data=None):
print
"execution time="
+
str
(
time
.
time
()
-
start
)
if
input_data
:
return
outputJSONString
if
__name__
==
'__main__'
:
main
()
dream/simulation/Machine.py
View file @
8e47f2ba
...
...
@@ -29,12 +29,14 @@ from SimPy.Simulation import Process, Resource
from
SimPy.Simulation
import
activate
,
passivate
,
waituntil
,
now
,
hold
from
Failure
import
Failure
from
CoreObject
import
CoreObject
from
RandomNumberGenerator
import
RandomNumberGenerator
import
scipy.stats
as
stat
import
sys
#the Machine object
class
Machine
(
Process
):
class
Machine
(
CoreObject
):
#initialize the id the capacity, of the resource and the distribution
def
__init__
(
self
,
id
,
name
,
capacity
,
dist
,
time
,
fDist
,
MTTF
,
MTTR
,
availability
,
repairman
):
...
...
@@ -185,13 +187,7 @@ class Machine(Process):
blockageTime
=
totalTime
-
(
tinMStart
+
failureTime
)
self
.
totalBlockageTime
+=
totalTime
-
(
tinMStart
+
failureTime
)
#the time of blockage is derived from
#the whole time in the machine
#minus the processing time and the failure time
#sets the routing in and out elements for the queue
def
defineRouting
(
self
,
p
,
n
):
self
.
next
=
n
self
.
previous
=
p
#minus the processing time and the failure time
#checks if the waitQ of the machine is empty
def
checkIfWaitQEmpty
(
self
):
return
len
(
self
.
M
.
waitQ
)
==
0
...
...
@@ -259,6 +255,14 @@ class Machine(Process):
def
ifCanDisposeOrHaveFailure
(
self
):
return
self
.
Up
==
False
or
self
.
next
[
0
].
canAccept
()
or
len
(
self
.
Res
.
activeQ
)
==
0
#the last part is added so that it is not removed and stack
#gotta think of it again
#removes an entity from the Machine
def
removeEntity
(
self
):
self
.
timeLastEntityLeft
=
now
()
self
.
outputTrace
(
"releases "
+
self
.
objName
)
self
.
waitToDispose
=
False
self
.
Res
.
activeQ
.
pop
(
0
)
self
.
downTimeInTryingToReleaseCurrentEntity
=
0
#checks if the Machine can dispose an entity to the following object
def
haveToDispose
(
self
):
...
...
@@ -295,19 +299,6 @@ class Machine(Process):
flag
=
True
return
len
(
self
.
Res
.
activeQ
)
>
0
and
self
.
waitToDispose
and
self
.
Up
and
flag
#removes an entity from the Machine
def
removeEntity
(
self
):
self
.
timeLastEntityLeft
=
now
()
self
.
outputTrace
(
"releases "
+
self
.
objName
)
self
.
waitToDispose
=
False
self
.
Res
.
activeQ
.
pop
(
0
)
self
.
downTimeInTryingToReleaseCurrentEntity
=
0
#gets an entity from the predecessor that the predecessor index points to
def
getEntity
(
self
):
self
.
Res
.
activeQ
.
append
(
self
.
previous
[
self
.
predecessorIndex
].
Res
.
activeQ
[
0
])
#get the entity from the predecessor
self
.
previous
[
self
.
predecessorIndex
].
removeEntity
()
#actions to be taken after the simulation ends
def
postProcessing
(
self
,
MaxSimtime
):
...
...
@@ -496,14 +487,5 @@ class Machine(Process):
json
[
'results'
][
'waiting_ratio'
][
'avg'
]
=
self
.
Waiting
[
0
]
json
[
'results'
][
'waiting_ratio'
][
'max'
]
=
self
.
Waiting
[
0
]
G
.
outputJSON
[
'coreObject'
].
append
(
json
)
#takes the array and checks if all its values are identical (returns false) or not (returns true)
#needed because if somebody runs multiple runs in deterministic case it would crash!
def
checkIfArrayHasDifValues
(
self
,
array
):
difValuesFlag
=
False
for
i
in
range
(
1
,
len
(
array
)):
if
(
array
[
i
]
!=
array
[
1
]):
difValuesFlag
=
True
return
difValuesFlag
\ No newline at end of file
G
.
outputJSON
[
'elementList'
].
append
(
json
)
\ No newline at end of file
dream/simulation/ObjectInterruption.py
0 → 100644
View file @
8e47f2ba
# ===========================================================================
# Copyright 2013 Georgios Dagkakis
#
# This file is part of DREAM.
#
# DREAM is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DREAM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with DREAM. If not, see <http://www.gnu.org/licenses/>.
# ===========================================================================
'''
Created on 18 Aug 2013
@author: George
'''
'''
Class that acts as an abstract. It should have no instances. All object interruptions (eg failures, breaks) should inherit from it
'''
from
SimPy.Simulation
import
Process
,
Resource
class
ObjectInterruption
(
Process
):
#the main process of the core object
#this is dummy, every object must have its own implementation
def
run
(
self
):
raise
NotImplementedError
(
"Subclass must define 'run' method"
)
#outputs data to "output.xls"
def
outputResultsXL
(
self
,
MaxSimtime
):
pass
\ No newline at end of file
dream/simulation/ObjectResource.py
0 → 100644
View file @
8e47f2ba
# ===========================================================================
# Copyright 2013 Georgios Dagkakis
#
# This file is part of DREAM.
#
# DREAM is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DREAM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with DREAM. If not, see <http://www.gnu.org/licenses/>.
# ===========================================================================
'''
Created on 18 Aug 2013
@author: George
'''
'''
Class that acts as an abstract. It should have no instances. All the Resources should inherit from it
'''
from
SimPy.Simulation
import
Resource
#the resource that repairs the machines
class
ObjectResource
(
object
):
def
initialize
(
self
):
self
.
totalWorkingTime
=
0
#holds the total working time
self
.
totalWaitingTime
=
0
#holds the total waiting time
self
.
timeLastRepairStarted
=
0
#holds the time that the last repair was started
self
.
Res
=
Resource
(
self
.
capacity
)
#checks if the worker is available
def
checkIfResourceIsAvailable
(
self
):
return
len
(
self
.
W
.
activeQ
)
<
self
.
capacity
#actions to be taken after the simulation ends
def
postProcessing
(
self
,
MaxSimtime
):
pass
#outputs message to the trace.xls
def
outputTrace
(
self
,
message
):
pass
#outputs data to "output.xls"
def
outputResultsXL
(
self
,
MaxSimtime
):
pass
#outputs results to JSON File
def
outputResultsJSON
(
self
):
pass
#takes the array and checks if all its values are identical (returns false) or not (returns true)
#needed because if somebody runs multiple runs in deterministic case it would crash!
def
checkIfArrayHasDifValues
(
self
,
array
):
difValuesFlag
=
False
for
i
in
range
(
1
,
len
(
array
)):
if
(
array
[
i
]
!=
array
[
1
]):
difValuesFlag
=
True
return
difValuesFlag
\ No newline at end of file
dream/simulation/Part.py
View file @
8e47f2ba
...
...
@@ -29,10 +29,11 @@ models a part entity that flows through the system
from
SimPy.Simulation
import
*
from
Globals
import
G
from
Entity
import
Entity
#The entity object
class
Part
(
object
):
class
Part
(
Entity
):
type
=
"Part"
def
__init__
(
self
,
name
):
...
...
dream/simulation/Queue.py
View file @
8e47f2ba
...
...
@@ -27,10 +27,12 @@ Models a FIFO queue where entities can wait in order to get into a server
from
SimPy.Simulation
import
*
from
CoreObject
import
CoreObject
#import sys
#the Queue object
class
Queue
(
Process
):
class
Queue
(
CoreObject
):
def
__init__
(
self
,
id
,
name
,
capacity
,
dummy
):
Process
.
__init__
(
self
)
...
...
@@ -77,7 +79,7 @@ class Queue(Process):
self
.
processingTimeOfCurrentEntity
=
0
#holds the total processing time that the current entity required
self
.
waitToDispose
=
False
#shows if the object waits to dispose an entity
def
run
(
self
):
while
1
:
yield
waituntil
,
self
,
self
.
canAcceptAndIsRequested
#wait until the Queue can accept an entity
...
...
@@ -86,12 +88,7 @@ class Queue(Process):
#if entity just got to the dummyQ set its startTime as the current time
if
self
.
isDummy
:
self
.
Res
.
activeQ
[
0
].
startTime
=
now
()
#sets the routing in and out elements for the queue
def
defineRouting
(
self
,
p
,
n
):
self
.
next
=
n
self
.
previous
=
p
self
.
Res
.
activeQ
[
0
].
startTime
=
now
()
#checks if the Q has one available place
def
checkIfQHasPlace
(
self
):
...
...
@@ -183,20 +180,6 @@ class Queue(Process):
self
.
predecessorIndex
=
i
maxTimeWaiting
=
timeWaiting
return
len
(
self
.
Res
.
activeQ
)
<
self
.
capacity
and
isRequested
#gets an entity from the predecessor that the predecessor index points to
def
getEntity
(
self
):
self
.
Res
.
activeQ
=
[
self
.
previous
[
self
.
predecessorIndex
].
Res
.
activeQ
[
0
]]
+
self
.
Res
.
activeQ
#get the entity from the previous object
#and put it in front of the activeQ
self
.
previous
[
self
.
predecessorIndex
].
removeEntity
()
#remove the entity from the previous object
#removes an entity from the Queue (this is FIFO for now)
def
removeEntity
(
self
):
self
.
Res
.
activeQ
.
pop
(
0
)
#actions to be taken after the simulation ends
def
postProcessing
(
self
,
MaxSimtime
):
pass
#no actions for the Queue
#outputs message to the trace.xls. Format is (Simulation Time | Entity Name | message)
def
outputTrace
(
self
,
message
):
...
...
@@ -212,11 +195,3 @@ class Queue(Process):
G
.
traceIndex
=
0
G
.
sheetIndex
+=
1
G
.
traceSheet
=
G
.
traceFile
.
add_sheet
(
'sheet '
+
str
(
G
.
sheetIndex
),
cell_overwrite_ok
=
True
)
#outputs data to "output.xls"
def
outputResultsXL
(
self
,
MaxSimtime
):
pass
#outputs results to JSON File
def
outputResultsJSON
(
self
):
pass
\ No newline at end of file
dream/simulation/Repairman.py
View file @
8e47f2ba
...
...
@@ -26,12 +26,13 @@ Created on 14 Nov 2012
models a repairman that can fix a machine when it gets failures
'''
from
SimPy.Simulation
import
*
from
SimPy.Simulation
import
Resource
import
xlwt
import
scipy.stats
as
stat
from
ObjectResource
import
ObjectResource
#the resource that repairs the machines
class
Repairman
(
object
):
class
Repairman
(
ObjectResource
):
def
__init__
(
self
,
id
,
name
,
capacity
):
self
.
id
=
id
...
...
@@ -42,17 +43,10 @@ class Repairman(object):
#lists to hold statistics of multiple runs
self
.
Waiting
=
[]
self
.
Working
=
[]
def
initialize
(
self
):
self
.
totalWorkingTime
=
0
#holds the total working time
self
.
totalWaitingTime
=
0
#holds the total waiting time
self
.
timeLastRepairStarted
=
0
#holds the time that the last repair was started
self
.
Res
=
Resource
(
self
.
capacity
)
#checks if the worker is available
def
checkIfWorkerIsAvailable
(
self
):
return
len
(
self
.
W
.
activeQ
)
<
self
.
capacity
self
.
coreObjectIds
=
[]
#list with the coreObjects that the repairman repairs
#actions to be taken after the simulation ends
def
postProcessing
(
self
,
MaxSimtime
):
#if the repairman is currently working we have to count the time of this work
...
...
@@ -140,13 +134,5 @@ class Repairman(object):
json
[
'results'
][
'waiting_ratio'
][
'avg'
]
=
self
.
Waiting
[
0
]
json
[
'results'
][
'waiting_ratio'
][
'max'
]
=
self
.
Waiting
[
0
]
G
.
outputJSON
[
'
coreObjec
t'
].
append
(
json
)
G
.
outputJSON
[
'
elementLis
t'
].
append
(
json
)
#takes the array and checks if all its values are identical (returns false) or not (returns true)
#needed because if somebody runs multiple runs in deterministic case it would crash!
def
checkIfArrayHasDifValues
(
self
,
array
):
difValuesFlag
=
False
for
i
in
range
(
1
,
len
(
array
)):
if
(
array
[
i
]
!=
array
[
1
]):
difValuesFlag
=
True
return
difValuesFlag
\ No newline at end of file
dream/simulation/Source.py
View file @
8e47f2ba
...
...
@@ -29,9 +29,10 @@ models the source object that generates the entities
from
SimPy.Simulation
import
*
from
Part
import
Part
from
RandomNumberGenerator
import
RandomNumberGenerator
from
CoreObject
import
CoreObject
#The Source object is a Process
class
Source
(
Process
):
class
Source
(
CoreObject
):
def
__init__
(
self
,
id
,
name
,
dist
,
time
,
item
):
Process
.
__init__
(
self
)
self
.
id
=
id
...
...
@@ -122,21 +123,6 @@ class Source(Process):
#sets the routing out element for the Source
def
defineRouting
(
self
,
n
):
self
.
next
=
n
#actions to be taken after the simulation ends
def
postProcessing
(
self
,
MaxSimtime
):
pass
#no actions for the Source
#checks if the Source can dispose an entity to the following object
def
haveToDispose
(
self
):
#return self.waitToDispose
return
len
(
self
.
Res
.
activeQ
)
>
0
#removes an entity from the Source
def
removeEntity
(
self
):
self
.
Res
.
activeQ
.
pop
(
0
)
#if(len(self.Res.activeQ)==0):
#self.waitToDispose=False
#outputs message to the trace.xls. Format is (Simulation Time | Entity Name | "generated")
def
outputTrace
(
self
,
message
):
...
...
@@ -153,11 +139,3 @@ class Source(Process):
G
.
traceIndex
=
0
G
.
sheetIndex
+=
1
G
.
traceSheet
=
G
.
traceFile
.
add_sheet
(
'sheet '
+
str
(
G
.
sheetIndex
),
cell_overwrite_ok
=
True
)
#outputs data to "output.xls"
def
outputResultsXL
(
self
,
MaxSimtime
):
pass
#outputs results to JSON File
def
outputResultsJSON
(
self
):
pass
dream/simulation/documents/ClassHierarchy.png
0 → 100644
View file @
8e47f2ba
50.2 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