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
fd62846b
Commit
fd62846b
authored
Feb 21, 2014
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update source to receive interarrivalTime as dict
parent
adfbf696
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
30 deletions
+22
-30
dream/simulation/BatchSource.py
dream/simulation/BatchSource.py
+3
-3
dream/simulation/LineGenerationJSON.py
dream/simulation/LineGenerationJSON.py
+5
-20
dream/simulation/Source.py
dream/simulation/Source.py
+14
-7
No files found.
dream/simulation/BatchSource.py
View file @
fd62846b
...
...
@@ -30,10 +30,10 @@ from SimPy.Simulation import Process
from
RandomNumberGenerator
import
RandomNumberGenerator
class
BatchSource
(
Source
):
def
__init__
(
self
,
id
,
name
,
distribution
=
'Fixed'
,
mean
=
1
,
def
__init__
(
self
,
id
,
name
,
interarrivalTime
=
None
,
item
=
'Dream.Batch'
,
batchNumberOfUnits
=
1
,
**
kw
):
Source
.
__init__
(
self
,
id
=
id
,
name
=
name
,
distribution
=
distribution
,
mean
=
mean
,
item
=
item
,
**
kw
)
Source
.
__init__
(
self
,
id
=
id
,
name
=
name
,
interarrivalTime
=
interarrivalTime
,
item
=
item
,
**
kw
)
self
.
numberOfUnits
=
batchNumberOfUnits
...
...
dream/simulation/LineGenerationJSON.py
View file @
fd62846b
...
...
@@ -265,29 +265,14 @@ def createObjects():
element
[
'id'
]
=
element_id
objClass
=
element
.
get
(
'_class'
,
'not found'
)
if
objClass
==
'Dream.Source'
:
id
=
element
.
get
(
'id'
,
'not found'
)
name
=
element
.
get
(
'name'
,
'not found'
)
interarrivalTime
=
element
.
get
(
'interarrivalTime'
,{})
distributionType
=
interarrivalTime
.
get
(
'distributionType'
,
'not found'
)
mean
=
float
(
interarrivalTime
.
get
(
'mean'
)
or
0
)
#entity=str_to_class(element['entity']) # initialize entity
entity
=
element
[
'entity'
]
S
=
Source
(
id
,
name
,
distributionType
,
mean
,
entity
)
# initialize Source
S
.
nextIds
=
getSuccessorList
(
id
)
S
=
Source
(
**
element
)
S
.
nextIds
=
getSuccessorList
(
element
[
'id'
])
G
.
SourceList
.
append
(
S
)
G
.
ObjList
.
append
(
S
)
if
objClass
==
'Dream.BatchSource'
:
id
=
element
.
get
(
'id'
,
'not found'
)
name
=
element
.
get
(
'name'
,
'not found'
)
interarrivalTime
=
element
.
get
(
'interarrivalTime'
,{})
distributionType
=
interarrivalTime
.
get
(
'distributionType'
,
'not found'
)
mean
=
float
(
interarrivalTime
.
get
(
'mean'
)
or
0
)
#entity=str_to_class(element['entity'])
entity
=
(
element
[
'entity'
])
batchNumberOfUnits
=
int
(
element
.
get
(
'batchNumberOfUnits'
,
'not found'
))
S
=
BatchSource
(
id
,
name
,
distributionType
,
mean
,
entity
,
batchNumberOfUnits
)
S
.
nextIds
=
getSuccessorList
(
id
)
S
=
BatchSource
(
**
element
)
S
.
nextIds
=
getSuccessorList
(
element
[
'id'
])
G
.
BatchSourceList
.
append
(
S
)
G
.
SourceList
.
append
(
S
)
G
.
ObjList
.
append
(
S
)
...
...
dream/simulation/Source.py
View file @
fd62846b
...
...
@@ -35,21 +35,28 @@ import Globals
# The Source object is a Process
#============================================================================
class
Source
(
CoreObject
):
def
__init__
(
self
,
id
,
name
,
distribution
=
'Fixed'
,
mean
=
1
,
item
=
'Dream.Part'
,
**
kw
):
CoreObject
.
__init__
(
self
,
id
,
name
)
def
__init__
(
self
,
id
,
name
,
interarrivalTime
=
None
,
item
=
'Dream.Part'
,
**
kw
):
# Default values
if
not
interarrivalTime
:
interarrivalTime
=
{
'distributionType'
:
'Fixed'
,
'mean'
:
1
}
self
.
distType
=
distribution
# label that sets the distribution type
CoreObject
.
__init__
(
self
,
id
,
name
)
self
.
distType
=
interarrivalTime
[
'distributionType'
]
# label that sets the distribution type
# properties used for statistics
self
.
totalInterArrivalTime
=
0
# the total interarrival time
self
.
numberOfArrivals
=
0
# the number of entities that were created
self
.
totalInterArrivalTime
=
0
# the total interarrival time
self
.
numberOfArrivals
=
0
# the number of entities that were created
# # list containing objects that follow in the routing
# self.next=[] # list with the next objects in the flow
# self.nextIds=[] # list with the ids of the next objects in the flow
# self.previousIds=[] # list with the ids of the previous objects in the flow.
# # For the source it is always empty!
self
.
type
=
"Source"
#String that shows the type of object
self
.
rng
=
RandomNumberGenerator
(
self
,
self
.
distType
)
self
.
rng
.
avg
=
mean
# XXX we could just initialize RandomNumberGenerator by passing
# interarrivalTime dict
self
.
rng
=
RandomNumberGenerator
(
self
,
self
.
distType
)
self
.
rng
.
avg
=
interarrivalTime
[
'mean'
]
self
.
item
=
Globals
.
getClassFromName
(
item
)
#the type of object that the Source will generate
def
initialize
(
self
):
...
...
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