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
b28b531f
Commit
b28b531f
authored
May 08, 2014
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
findCandidateReceivers method of Router updated. minor corrections
parent
0f5f3aef
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
3 deletions
+21
-3
dream/simulation/OperatorRouter.py
dream/simulation/OperatorRouter.py
+21
-3
No files found.
dream/simulation/OperatorRouter.py
View file @
b28b531f
...
...
@@ -625,7 +625,25 @@ class Router(ObjectInterruption):
#local method that finds a candidate entity for an operator
def
findCandidateEntity
():
candidateEntity
=
next
(
x
for
x
in
operator
.
candidateEntities
if
not
x
in
entitiesWithOccupiedReceivers
)
# local recursive method that searches for entities with available receivers
def
findAvailableEntity
():
# if the candidateEntities and the entitiesWithOccupiedReceivers lists are identical then return None
if
len
(
set
(
operator
.
candidateEntities
).
intersection
(
entitiesWithOccupiedReceivers
))
==
len
(
operator
.
candidateEntities
):
return
None
availableEntity
=
next
(
x
for
x
in
operator
.
candidateEntities
if
not
x
in
entitiesWithOccupiedReceivers
)
receiverAvailability
=
False
if
availableEntity
:
for
receiver
in
availableEntity
.
candidateReceivers
:
if
not
receiver
in
occupiedReceivers
:
receiverAvailability
=
True
break
# if there are no available receivers for the entity
if
not
receiverAvailability
:
entitiesWithOccupiedReceivers
.
append
(
availableEntity
)
return
findAvailableEntity
()
return
availableEntity
# pick a candidateEntity
candidateEntity
=
findAvailableEntity
()
if
not
self
.
sorting
:
if
not
candidateEntity
:
candidateEntity
=
next
(
x
for
x
in
operator
.
candidateEntities
)
...
...
@@ -682,7 +700,7 @@ class Router(ObjectInterruption):
for
operator
in
self
.
candidateOperators
:
if
operator
.
candidateEntity
in
conflictingEntities
:
conflictingOperators
.
append
(
operator
)
elif
operator
.
candidateEntity
.
candidateReceiver
in
[
x
.
candidateReceiver
for
x
in
confli
n
ctingEntities
]:
elif
operator
.
candidateEntity
.
candidateReceiver
in
[
x
.
candidateReceiver
for
x
in
conflictingEntities
]:
conflictingOperators
.
append
(
operator
)
self
.
conflictingOperators
=
conflictingOperators
# keep the sorting provided by the queues if there is conflict between operators
...
...
@@ -701,7 +719,7 @@ class Router(ObjectInterruption):
# the operator that can proceed is the manager of the entity as sorted by the queue that holds them
conflictingGroup
.
sort
(
key
=
lambda
x
:
x
.
ind
)
# the operators that are not first in the list cannot proceed
for
operator
in
conflitingGroup
:
for
operator
in
confli
c
tingGroup
:
if
conflictingGroup
.
index
(
operator
)
!=
0
:
self
.
candidateOperators
.
remove
(
operator
)
self
.
calledOperators
.
remove
(
operator
)
...
...
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