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
0a0e0d1e
Commit
0a0e0d1e
authored
Oct 08, 2014
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
correction in RoutingQueue
parent
849bc6ca
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
24 deletions
+44
-24
dream/simulation/RoutingQueue.py
dream/simulation/RoutingQueue.py
+44
-24
No files found.
dream/simulation/RoutingQueue.py
View file @
0a0e0d1e
...
...
@@ -51,15 +51,14 @@ class RoutingQueue(Queue):
isInRouting
=
False
# for each entity in the buffer
for
entity
in
activeObjectQueue
:
# if the receiver is None then they can proceed
if
not
entity
.
receiver
:
isInRouting
=
True
break
# otherwise check if the calleObject is the receiver of the entity
elif
thecaller
==
entity
.
receiver
:
# if yes then that entity can proceed
if
thecaller
==
entity
.
receiver
:
isInRouting
=
True
break
if
not
isInRouting
:
for
entity
in
activeObjectQueue
:
if
not
entity
.
receiver
:
isInRouting
=
True
break
return
len
(
activeObjectQueue
)
>
0
and
(
thecaller
in
self
.
next
)
and
isInRouting
#===========================================================================
...
...
@@ -70,29 +69,50 @@ class RoutingQueue(Queue):
activeObjectQueue
=
self
.
getActiveObjectQueue
()
# find the entities that have None as receiver and update their receiver to the receiver provided as argument to the method
# the entities that have no receiver can proceed as none of their siblings have gone through the next of the activeObject
for
entity
in
activeObjectQueue
:
if
not
entity
.
receiver
:
entity
.
receiver
=
receiver
activeObjectQueue
.
sort
(
key
=
lambda
x
:
x
.
receiver
==
receiver
,
reverse
=
True
)
# for entity in activeObjectQueue:
# if not entity.receiver:
# entity.receiver=receiver
# print '='*10
# print '----------------- Before'
# print self.env.now, receiver.id
# for entity in activeObjectQueue:
# print entity.id, entity.receiver
# if entity.receiver:
# print entity.receiver.id
activeObjectQueue
.
sort
(
key
=
lambda
x
:
not
(
x
.
receiver
is
receiver
),
reverse
=
False
)
activeObjectQueue
.
sort
(
key
=
lambda
x
:
x
.
receiver
==
None
,
reverse
=
True
)
activeObjectQueue
.
sort
(
key
=
lambda
x
:
(
x
.
receiver
is
receiver
),
reverse
=
True
)
# print '----------------- After'
# print self.env.now, receiver.id
# for entity in activeObjectQueue:
# print entity.id, entity.receiver
# if entity.receiver:
# print entity.receiver.id
# =======================================================================
# gets an entity from the predecessor that
# the predecessor index points to
# =======================================================================
def
getEntity
(
self
):
activeEntity
=
Queue
.
getEntity
(
self
)
#run the default behavior
# update the receiver object of the entity just received according to the routing of the parent batch
route
=
activeEntity
.
parentBatch
.
routing
()
activeEntity
.
receiver
=
None
try
:
for
nextObj
in
self
.
next
:
if
nextObj
in
activeEntity
.
parentBatch
.
routing
():
activeEntity
.
receiver
=
nextObj
break
# if none of the siblings (same parentBatch) has gone through the buffer then the receiver should remain None
except
:
pass
def
removeEntity
(
self
,
entity
=
None
,
resetFlags
=
True
,
addBlockage
=
True
):
activeEntity
=
Queue
.
removeEntity
(
self
,
entity
)
parentBatch
=
activeEntity
.
parentBatch
for
subbatch
in
parentBatch
.
subBatchList
:
subbatch
.
receiver
=
activeEntity
.
currentStation
return
activeEntity
# activeEntity=Queue.getEntity(self) #run the default behavior
# # update the receiver object of the entity just received according to the routing of the parent batch
# route = activeEntity.parentBatch.routing()
# activeEntity.receiver=None
# try:
# for nextObj in self.next:
# if nextObj in activeEntity.parentBatch.routing():
# activeEntity.receiver=nextObj
# break
# # if none of the siblings (same parentBatch) has gone through the buffer then the receiver should remain None
# except:
# pass
# return activeEntity
# =======================================================================
# sorts the Entities of the Queue according to the scheduling rule
...
...
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