Commit 3a38d684 authored by Georgios Dagkakis's avatar Georgios Dagkakis

Routers to be able to output results if need be

parent 8fa9940f
...@@ -47,6 +47,7 @@ class G: ...@@ -47,6 +47,7 @@ class G:
EntityList=[] #a list that holds all the Entities EntityList=[] #a list that holds all the Entities
ObjectResourceList=[] ObjectResourceList=[]
ObjectInterruptionList=[] ObjectInterruptionList=[]
RouterList=[]
numberOfReplications=1 #the number of replications default=1git numberOfReplications=1 #the number of replications default=1git
confidenceLevel=0.9 #the confidence level default=90% confidenceLevel=0.9 #the confidence level default=90%
......
...@@ -572,7 +572,7 @@ def setTopology(): ...@@ -572,7 +572,7 @@ def setTopology():
# initializes all the objects that are in the topology # initializes all the objects that are in the topology
# =========================================================================== # ===========================================================================
def initializeObjects(): def initializeObjects():
for element in G.ObjList + G.ObjectResourceList + G.EntityList + G.ObjectInterruptionList: for element in G.ObjList + G.ObjectResourceList + G.EntityList + G.ObjectInterruptionList+G.RouterList:
element.initialize() element.initialize()
# =========================================================================== # ===========================================================================
...@@ -655,13 +655,9 @@ def main(argv=[], input_data=None): ...@@ -655,13 +655,9 @@ def main(argv=[], input_data=None):
G.env.run(until=G.maxSimTime) G.env.run(until=G.maxSimTime)
#carry on the post processing operations for every object in the topology #carry on the post processing operations for every object in the topology
for element in G.ObjList: for element in G.ObjList+G.ObjectResourceList+G.RouterList:
element.postProcessing() element.postProcessing()
#carry on the post processing operations for every model resource in the topology
for model_resource in G.ObjectResourceList:
model_resource.postProcessing()
# added for debugging, print the Route of the Jobs on the same G.traceFile # added for debugging, print the Route of the Jobs on the same G.traceFile
PrintRoute.outputRoute() PrintRoute.outputRoute()
...@@ -682,7 +678,7 @@ def main(argv=[], input_data=None): ...@@ -682,7 +678,7 @@ def main(argv=[], input_data=None):
#output data to JSON for every object in the topology #output data to JSON for every object in the topology
for object in G.ObjectResourceList + G.EntityList + G.ObjList: for object in G.ObjectResourceList + G.EntityList + G.ObjList+G.RouterList:
object.outputResultsJSON() object.outputResultsJSON()
# output the trace as encoded if it is set on # output the trace as encoded if it is set on
......
...@@ -52,6 +52,8 @@ class Router(ObjectInterruption): ...@@ -52,6 +52,8 @@ class Router(ObjectInterruption):
self.preemptiveOperators=[] # list of preemptiveOperators that should preempt their machines self.preemptiveOperators=[] # list of preemptiveOperators that should preempt their machines
self.criticalQueues=[] self.criticalQueues=[]
self.pending=[] # list of entities that require operators now self.pending=[] # list of entities that require operators now
from Globals import G
G.RouterList.append(self)
#=========================================================================== #===========================================================================
# the initialize method # the initialize method
......
...@@ -42,12 +42,13 @@ class SkilledRouter(Router): ...@@ -42,12 +42,13 @@ class SkilledRouter(Router):
# TODO: we should maybe define a global schedulingRule criterion that will be # TODO: we should maybe define a global schedulingRule criterion that will be
# chosen in case of multiple criteria for different Operators # chosen in case of multiple criteria for different Operators
# ======================================================================= # =======================================================================
def __init__(self,sorting=False): def __init__(self,sorting=False, outputSolutions=False):
Router.__init__(self) Router.__init__(self)
# Flag used to notify the need for re-allocation of skilled operators to operatorPools # Flag used to notify the need for re-allocation of skilled operators to operatorPools
self.allocation=False self.allocation=False
# Flag used to notify the need to wait for endedLastProcessing signal # Flag used to notify the need to wait for endedLastProcessing signal
waitEndProcess=False waitEndProcess=False
self.outputSolutions=outputSolutions
#=========================================================================== #===========================================================================
# the initialize method # the initialize method
...@@ -59,6 +60,7 @@ class SkilledRouter(Router): ...@@ -59,6 +60,7 @@ class SkilledRouter(Router):
self.pendingQueues=[] self.pendingQueues=[]
self.pendingMachines=[] self.pendingMachines=[]
self.previousSolution={} self.previousSolution={}
self.solutionList=[]
# ======================================================================= # =======================================================================
# the run method # the run method
...@@ -163,6 +165,13 @@ class SkilledRouter(Router): ...@@ -163,6 +165,13 @@ class SkilledRouter(Router):
self.operators, previousAssignment=self.previousSolution) self.operators, previousAssignment=self.previousSolution)
# print '-------' # print '-------'
# print self.env.now, solution # print self.env.now, solution
if self.outputSolutions:
self.solutionList.append({
"time":self.env.now,
"allocation":solution
})
# XXX assign the operators to operatorPools # XXX assign the operators to operatorPools
# pendingStations/ available stations not yet given operator # pendingStations/ available stations not yet given operator
self.pendingStations=[] self.pendingStations=[]
...@@ -278,3 +287,21 @@ class SkilledRouter(Router): ...@@ -278,3 +287,21 @@ class SkilledRouter(Router):
self.allocation=False self.allocation=False
self.waitEndProcess=False self.waitEndProcess=False
def postProcessing(self):
if self.outputSolutions:
self.solutionList.append({
"time":self.env.now,
"allocation":{}
})
def outputResultsJSON(self):
if self.outputSolutions:
from Globals import G
json = {'_class': 'Dream.%s' % self.__class__.__name__,
'id': self.id,
'results': {}}
json['results']['solutionList'] = self.solutionList
G.outputJSON['elementList'].append(json)
\ No newline at end of file
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