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
7de1c5be
Commit
7de1c5be
authored
Oct 22, 2013
by
Georgios Dagkakis
Committed by
Sebastien Robin
Nov 06, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup in Source
parent
968ebb09
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
30 deletions
+16
-30
dream/simulation/Source.py
dream/simulation/Source.py
+16
-30
No files found.
dream/simulation/Source.py
View file @
7de1c5be
...
...
@@ -45,7 +45,6 @@ class Source(CoreObject):
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.waitToDispose=False
self
.
rng
=
RandomNumberGenerator
(
self
,
self
.
distType
)
self
.
rng
.
avg
=
mean
self
.
item
=
item
#the type of object that the Source will generate
...
...
@@ -86,39 +85,26 @@ class Source(CoreObject):
activeObjectQueue
=
self
.
getActiveObjectQueue
()
i
=
0
if
(
self
.
distType
==
"Fixed"
):
#if the distribution type is fixed
from
Globals
import
G
while
1
:
self
.
numberOfArrivals
+=
1
#we have one new arrival
entity
=
self
.
item
(
self
.
item
.
type
+
"_"
+
self
.
objName
+
"_"
+
str
(
i
))
#create the Entity object and assign its name
entity
.
creationTime
=
now
()
#assign the current simulation time as the Entity's creation time
entity
.
startTime
=
now
()
#assign the current simulation time as the Entity's start time
self
.
outputTrace
(
self
.
item
.
type
+
"_"
+
self
.
objName
+
"_"
+
str
(
i
))
#output the trace
activeObjectQueue
.
append
(
entity
)
#append the entity to the resource
i
+=
1
yield
hold
,
self
,
self
.
rng
.
generateNumber
()
elif
(
self
.
distType
==
"Exp"
):
#if the distribution type is exponential
from
Globals
import
G
while
1
:
self
.
numberOfArrivals
+=
1
#we have one new arrival
entity
=
self
.
item
(
self
.
item
.
type
+
str
(
i
))
#create the Entity object and assign its name
entity
.
creationTime
=
now
()
#assign the current simulation time as the Entity's creation time
entity
.
startTime
=
now
()
#assign the current simulation time as the Entity's start time
self
.
outputTrace
(
self
.
item
.
type
+
str
(
i
))
#output the trace
i
+=
1
activeObjectQueue
.
append
(
entity
)
#append the entity to the resource
timeTillNextArrival
=
G
.
Rnd
.
expovariate
(
1.0
/
(
self
.
interArrivalTime
))
#create a random number that follows the
#exponential distribution
yield
hold
,
self
,
self
.
rng
.
generateNumber
()
self
.
totalInterArrivalTime
+=
timeTillNextArrival
else
:
#if the distribution type is something else it is an error
print
"Distribution Error in "
+
str
(
self
.
objName
)
from
Globals
import
G
while
1
:
self
.
numberOfArrivals
+=
1
#we have one new arrival
entity
=
self
.
item
(
self
.
item
.
type
+
"_"
+
self
.
objName
+
"_"
+
str
(
i
))
#create the Entity object and assign its name
entity
.
creationTime
=
now
()
#assign the current simulation time as the Entity's creation time
entity
.
startTime
=
now
()
#assign the current simulation time as the Entity's start time
self
.
outputTrace
(
self
.
item
.
type
+
"_"
+
self
.
objName
+
"_"
+
str
(
i
))
#output the trace
activeObjectQueue
.
append
(
entity
)
#append the entity to the resource
i
+=
1
yield
hold
,
self
,
self
.
calculateInterarrivalTime
()
#wait until the next arrival
#sets the routing out element for the Source
def
defineRouting
(
self
,
successorList
=
[]):
self
.
next
=
successorList
#calculates the processing time
def
calculateInterarrivalTime
(
self
):
return
self
.
rng
.
generateNumber
()
#this is if we have a default interarrival time for all the entities
#outputs message to the trace.xls. Format is (Simulation Time | Entity Name | "generated")
#outputs message to the trace.xls. Format is (Simulation Time | Entity Name | "generated")
def
outputTrace
(
self
,
message
):
from
Globals
import
G
...
...
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