Commit bbe55023 authored by Georgios Dagkakis's avatar Georgios Dagkakis

cleanup and comments

parent ce655c47
......@@ -54,24 +54,26 @@ class CapacityStationsEnumeration(Enumeration):
scenarioList.append({'key':str(threshold),'threshold':threshold})
return scenarioList
# creates the ant scenario based on what ACO randomly selected
# creates the scenario. Here just set the dueDateThreshold
def createScenarioData(self,data,scenario):
scenarioData=deepcopy(data)
scenarioData['graph']['node']['CSC']['dueDateThreshold']=scenario['threshold']
return scenarioData
# checks if the algorithm should terminate.
# in this case terminate if the total delat is increased
# in this case terminate if the total delay is increased
def checkIfShouldTerminate(self,data,scenarioList):
# in the first scenario no need to terminate
if len(scenarioList)<2:
return False
# find the last scenario that is scored
index=0
for i in range(len(scenarioList)):
if scenarioList[i].get('score',None)==None:
index=i-1
break
# if the delay of the last scenario is bigger than the previous return true
if index:
if scenarioList[index]['score']>scenarioList[index-1]['score']:
scenarioList = scenarioList[:index+1]
return True
return False
......@@ -26,7 +26,7 @@ class Enumeration(plugin.ExecutionPlugin):
def createScenarioList(self,data):
raise NotImplementedError("Subclass must define 'createScenarioList' method")
# creates the ant scenario based on what ACO randomly selected
# create the scenario
def createScenarioData(self,data,scenario):
raise NotImplementedError("Subclass must define 'createScenarioData' method")
......@@ -48,11 +48,13 @@ class Enumeration(plugin.ExecutionPlugin):
assert numberOfSolutions >= 1
scenarioList=self.createScenarioList(data)
# run the scenario. Only synchronous for now
i=0
for scenario in scenarioList:
scenario['input']=self.createScenarioData(data, scenario)
scenario['result'] = self.runOneScenario(scenario['input'])['result']
scenario['score'] = self.calculateScenarioScore(scenario)
# it we should terminate remove the scenarios that are not scored yet
if self.checkIfShouldTerminate(data, scenarioList):
scenarioList = scenarioList[:i+1]
break
......
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