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
88f8b57e
Commit
88f8b57e
authored
Oct 10, 2013
by
Georgios Dagkakis
Committed by
Sebastien Robin
Nov 06, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
source, exit and CoreObject objects also updated so that they use the new methods
parent
e24f9ba5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
20 deletions
+37
-20
dream/simulation/CoreObject.py
dream/simulation/CoreObject.py
+5
-3
dream/simulation/Exit.py
dream/simulation/Exit.py
+25
-7
dream/simulation/Source.py
dream/simulation/Source.py
+7
-10
No files found.
dream/simulation/CoreObject.py
View file @
88f8b57e
...
...
@@ -71,8 +71,9 @@ class CoreObject(Process):
self
.
previous
=
p
#removes an entity from the Object
def
removeEntity
(
self
):
self
.
Res
.
activeQ
.
pop
(
0
)
def
removeEntity
(
self
):
activeObjectQueue
=
self
.
getActiveObjectQueue
()
activeObjectQueue
.
pop
(
0
)
#remove the Entity from the queue
#gets an entity from the predecessor that the predecessor index points to
def
getEntity
(
self
):
...
...
@@ -106,7 +107,8 @@ class CoreObject(Process):
#checks if the Object can dispose an entity to the following object
def
haveToDispose
(
self
,
callerObject
=
None
):
return
len
(
self
.
Res
.
activeQ
)
>
0
activeObjectQueue
=
self
.
getActiveObjectQueue
()
return
len
(
activeObjectQueue
)
>
0
#checks if the Object can accept an entity and there is an entity in some predecessor waiting for it
def
canAcceptAndIsRequested
(
self
):
...
...
dream/simulation/Exit.py
View file @
88f8b57e
...
...
@@ -102,22 +102,40 @@ class Exit(CoreObject):
#checks if the Exit can accept an entity and there is an entity waiting for it
def
canAcceptAndIsRequested
(
self
):
activeObject
=
self
.
getActiveObject
()
activeObjectQueue
=
self
.
getActiveObjectQueue
()
result
=
None
if
(
len
(
self
.
previous
)
==
1
):
return
self
.
previous
[
0
].
haveToDispose
(
self
)
if
(
len
(
activeObject
.
previous
)
==
1
):
object
=
activeObject
.
previous
[
0
]
return
object
.
haveToDispose
(
self
)
isRequested
=
False
for
i
in
range
(
len
(
self
.
previous
)):
if
(
self
.
previous
[
i
].
haveToDispose
(
self
)):
i
=
0
for
object
in
self
.
previous
:
if
(
object
.
haveToDispose
(
activeObject
)):
isRequested
=
True
self
.
predecessorIndex
=
i
i
+=
1
return
isRequested
#gets an entity from the predecessor
def
getEntity
(
self
):
name
=
self
.
previous
[
self
.
predecessorIndex
].
Res
.
activeQ
[
0
].
name
#get the name of the entity for the trace
self
.
totalLifespan
+=
now
()
-
self
.
previous
[
self
.
predecessorIndex
].
Res
.
activeQ
[
0
].
startTime
#Add the entity's lifespan to the total one.
self
.
previous
[
self
.
predecessorIndex
].
removeEntity
()
#remove the entity from the previous object
giverObject
=
self
.
getGiverObject
()
giverObject
.
sortEntities
()
#sort the Entities of the giver according to the scheduling rule if applied
activeObject
=
self
.
getActiveObject
()
giverObjectQueue
=
self
.
getGiverObjectQueue
()
activeEntity
=
giverObjectQueue
[
0
]
activeObjectQueue
=
self
.
getActiveObjectQueue
()
name
=
activeEntity
.
name
#get the name of the entity for the trace
activeObjectQueue
.
append
(
activeEntity
)
#get the entity from the previous object
#and put it in front of the activeQ
giverObject
.
removeEntity
()
#remove the entity from the previous object
activeEntity
.
schedule
.
append
([
activeObject
.
id
,
now
()])
#append the time to schedule so that it can be read in the result
self
.
totalLifespan
+=
now
()
-
activeEntity
.
startTime
#Add the entity's lifespan to the total one.
self
.
outputTrace
(
name
)
#actions to be taken after the simulation ends
...
...
dream/simulation/Source.py
View file @
88f8b57e
...
...
@@ -85,40 +85,37 @@ class Source(CoreObject):
self
.
waitToDispose
=
False
#shows if the object waits to dispose an entity
def
run
(
self
):
activeObject
=
self
.
getActiveObject
()
activeObjectQueue
=
self
.
getActiveObjectQueue
()
i
=
0
if
(
self
.
distType
==
"Fixed"
):
#if the distribution type is fixed
from
Globals
import
G
while
1
:
#self.waitToDispose=True
self
.
numberOfArrivals
+=
1
#we have one new arrival
#entity=Entity("Ent"+str(i))
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
self
.
Res
.
activeQ
.
append
(
entity
)
#append the entity to the resource
activeObjectQueue
.
append
(
entity
)
#append the entity to the resource
i
+=
1
#yield hold,self,self.interArrivalTime #one entity at every interArrivalTime
yield
hold
,
self
,
self
.
rng
.
generateNumber
()
elif
(
self
.
distType
==
"Exp"
):
#if the distribution type is exponential
from
Globals
import
G
while
1
:
#self.waitToDispose=True
self
.
numberOfArrivals
+=
1
#we have one new arrival
#entity=Entity("Ent"+str(i)) #create the Entity object and assign its name
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
self
.
Res
.
activeQ
.
append
(
entity
)
#append the entity to the resource
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,timeTillNextArrival #one entity at every interArrivalTime
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
Source "
+
str
(
self
.
id
)
print
"Distribution Error in
"
+
str
(
self
.
objName
)
#sets the routing out element for the Source
def
defineRouting
(
self
,
n
):
...
...
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