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
9b842c80
Commit
9b842c80
authored
May 19, 2014
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
findCandidateStation() and findCandidateEntity() added to Operator for use by Router
parent
08306ac6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
1 deletion
+50
-1
dream/simulation/Operator.py
dream/simulation/Operator.py
+50
-1
No files found.
dream/simulation/Operator.py
View file @
9b842c80
...
...
@@ -104,11 +104,60 @@ class Operator(ObjectResource):
#=======================================================================
# findCandidateEntities method finding the candidateEntities of the operator
#=======================================================================
def
pickCandidateEntitiesFrom
(
self
,
pendingEntities
=
[]):
def
findCandidateEntities
(
self
,
pendingEntities
=
[]):
if
pendingEntities
:
for
entity
in
[
x
for
x
in
pendingEntities
if
x
.
canProceed
and
x
.
manager
==
self
]:
self
.
candidateEntities
.
append
(
entity
)
#===========================================================================
# method that finds a candidate entity for an operator
#===========================================================================
def
findCandidateStation
(
self
,
conflictingStations
=
[]):
conflicting
=
conflictingStations
from
Globals
import
G
candidateStation
=
next
(
x
for
x
in
self
.
candidateStations
if
not
x
in
conflicting
)
if
not
G
.
Router
.
sorting
:
if
not
candidateStation
:
candidateStation
=
next
(
x
for
x
in
self
.
candidateStations
)
conflicting
.
append
(
candidateStation
)
return
candidateStation
,
conflictingStations
#===========================================================================
# recursive method that searches for entities with available receivers
#===========================================================================
def
findAvailableEntity
(
self
):
from
Globals
import
G
router
=
G
.
Router
# if the candidateEntities and the entitiesWithOccupiedReceivers lists are identical then return None
if
len
(
set
(
self
.
candidateEntities
).
intersection
(
router
.
entitiesWithOccupiedReceivers
))
==
len
(
self
.
candidateEntities
):
return
None
availableEntity
=
next
(
x
for
x
in
self
.
candidateEntities
if
not
x
in
router
.
entitiesWithOccupiedReceivers
)
receiverAvailability
=
False
if
availableEntity
:
for
receiver
in
availableEntity
.
candidateReceivers
:
if
not
receiver
in
router
.
occupiedReceivers
:
receiverAvailability
=
True
break
# if there are no available receivers for the entity
if
not
receiverAvailability
:
router
.
entitiesWithOccupiedReceivers
.
append
(
availableEntity
)
return
self
.
findAvailableEntity
()
return
availableEntity
#===========================================================================
# method that finds a candidate entity for an operator
#===========================================================================
def
findCandidateEntity
(
self
):
from
Globals
import
G
router
=
G
.
Router
# pick a candidateEntity
candidateEntity
=
self
.
findAvailableEntity
()
if
not
router
.
sorting
:
if
not
candidateEntity
:
candidateEntity
=
next
(
x
for
x
in
self
.
candidateEntities
)
router
.
conflictingEntities
.
append
(
candidateEntity
)
return
candidateEntity
# =======================================================================
# sorts the candidateEntities of the Operator according to the scheduling rule
# TODO: find a way to sort machines or candidate entities for machines,
...
...
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