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
25e1efb4
Commit
25e1efb4
authored
Jan 26, 2014
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dynamically get the possible scheduling rules for queues
parent
82f22365
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
10 deletions
+24
-10
dream/simulation/GUI/ACO.py
dream/simulation/GUI/ACO.py
+7
-7
dream/simulation/Globals.py
dream/simulation/Globals.py
+11
-1
dream/simulation/Queue.py
dream/simulation/Queue.py
+6
-2
No files found.
dream/simulation/GUI/ACO.py
View file @
25e1efb4
...
@@ -5,7 +5,8 @@ import random
...
@@ -5,7 +5,8 @@ import random
import
operator
import
operator
from
dream.simulation.GUI.Default
import
Simulation
as
DefaultSimulation
from
dream.simulation.GUI.Default
import
Simulation
as
DefaultSimulation
from
dream.simulation.Queue
import
Queue
from
dream.simulation.Globals
import
getClassFromName
class
Simulation
(
DefaultSimulation
):
class
Simulation
(
DefaultSimulation
):
...
@@ -32,8 +33,6 @@ class Simulation(DefaultSimulation):
...
@@ -32,8 +33,6 @@ class Simulation(DefaultSimulation):
def
_calculateAntScore
(
self
,
ant
):
def
_calculateAntScore
(
self
,
ant
):
"""Calculate the score of this ant.
"""Calculate the score of this ant.
XXX Maybe this can be based on other criterions, such as completion time ?
"""
"""
totalDelay
=
0
#set the total delay to 0
totalDelay
=
0
#set the total delay to 0
jsonData
=
ant
[
'result'
]
#read the result as JSON
jsonData
=
ant
[
'result'
]
#read the result as JSON
...
@@ -57,10 +56,11 @@ class Simulation(DefaultSimulation):
...
@@ -57,10 +56,11 @@ class Simulation(DefaultSimulation):
# the list of options collated into a dictionary for ease of referencing in
# the list of options collated into a dictionary for ease of referencing in
# ManPy
# ManPy
collated
=
{
'Q1'
:
[
'EDD'
,
'LPT'
,
],
'Q2'
:
[
'EDD'
,
'LPT'
,
'FIFO'
]}
collated
=
dict
()
# TODO: this list have to be defined in the GUI
for
node_id
,
node
in
data
[
'nodes'
].
items
():
# TODO: options should not be limited to scheduling rules. For example we
node_class
=
getClassFromName
(
node
[
'_class'
])
# want to try various machines of same technology
if
issubclass
(
node_class
,
Queue
):
collated
[
node_id
]
=
list
(
node_class
.
getSupportedSchedulingRules
())
ants
=
[]
#list of ants for keeping track of their performance
ants
=
[]
#list of ants for keeping track of their performance
...
...
dream/simulation/Globals.py
View file @
25e1efb4
...
@@ -91,7 +91,17 @@ def moveExcess(argumentDict={}):
...
@@ -91,7 +91,17 @@ def moveExcess(argumentDict={}):
receiver
.
previous
=
[]
receiver
.
previous
=
[]
else
:
else
:
print
"Giver and/or Receiver not defined"
print
"Giver and/or Receiver not defined"
# =======================================================================
# Import a class from a dotted name used in json.
# =======================================================================
def
getClassFromName
(
dotted_name
):
# XXX dotted name is always Dream.Something, but the real class lives in
# dream.simulation.Something.Something
dream
,
class_name
=
dotted_name
.
split
(
'.'
)
import
dream.simulation
as
ds
return
getattr
(
getattr
(
ds
,
class_name
),
class_name
)
# =======================================================================
# =======================================================================
# method finding objects by ID
# method finding objects by ID
# =======================================================================
# =======================================================================
...
...
dream/simulation/Queue.py
View file @
25e1efb4
...
@@ -71,11 +71,15 @@ class Queue(CoreObject):
...
@@ -71,11 +71,15 @@ class Queue(CoreObject):
self
.
multipleCriterionList
=
SRlist
# hold the criteria list in the property multipleCriterionList
self
.
multipleCriterionList
=
SRlist
# hold the criteria list in the property multipleCriterionList
for
scheduling_rule
in
SRlist
:
for
scheduling_rule
in
SRlist
:
if
scheduling_rule
not
in
(
"FIFO"
,
"Priority"
,
"EDD"
,
"EOD"
,
if
scheduling_rule
not
in
self
.
getSupportedSchedulingRules
():
"NumStages"
,
"RPC"
,
"LPT"
,
"SPT"
,
"MS"
,
"WINQ"
):
raise
ValueError
(
"Unknown scheduling rule %s for %s"
%
raise
ValueError
(
"Unknown scheduling rule %s for %s"
%
(
scheduling_rule
,
id
))
(
scheduling_rule
,
id
))
@
staticmethod
def
getSupportedSchedulingRules
():
return
(
"FIFO"
,
"Priority"
,
"EDD"
,
"EOD"
,
"NumStages"
,
"RPC"
,
"LPT"
,
"SPT"
,
"MS"
,
"WINQ"
)
def
initialize
(
self
):
def
initialize
(
self
):
# using the Process __init__ and not the CoreObject __init__
# using the Process __init__ and not the CoreObject __init__
CoreObject
.
initialize
(
self
)
CoreObject
.
initialize
(
self
)
...
...
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