Commit 25e1efb4 authored by Jérome Perrin's avatar Jérome Perrin

Dynamically get the possible scheduling rules for queues

parent 82f22365
...@@ -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
......
...@@ -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
# ======================================================================= # =======================================================================
......
...@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment