Commit a0466d64 authored by Georgios Dagkakis's avatar Georgios Dagkakis

enumeration to score the scenarios

parent 102a87d0
...@@ -45,18 +45,19 @@ class Enumeration(plugin.ExecutionPlugin): ...@@ -45,18 +45,19 @@ class Enumeration(plugin.ExecutionPlugin):
start = time.time() # start counting execution time start = time.time() # start counting execution time
numberOfSolutions = int(data['general'].get('numberOfSolutions',0)) numberOfSolutions = int(data['general'].get('numberOfSolutions',3))
assert numberOfSolutions >= 1 assert numberOfSolutions >= 1
scenarioList=self.createScenarioList(data) scenarioList=self.createScenarioList(data)
for scenario in scenarioList: for scenario in scenarioList:
scenario['input']=self.createScenarioData(data, scenario) scenario['input']=self.createScenarioData(data, scenario)
scenario['result'] = self.runOneScenario(scenario['input'])['result'] scenario['result'] = self.runOneScenario(scenario['input'])['result']
scenario['score'] = self.calculateScenarioScore(scenario)
if self.checkIfShouldTerminate(data, scenarioList): if self.checkIfShouldTerminate(data, scenarioList):
break break
# rand the scenarios based on their score and take only the numberOfSolutions best # rand the scenarios based on their score and take only the numberOfSolutions best
scenariosToReturn = sorted(scenarioList.values(),key=operator.itemgetter('score'))[:numberOfSolutions] scenariosToReturn = sorted(scenarioList,key=operator.itemgetter('score'))[:numberOfSolutions]
# return the number of scenarios that need to be returned # return the number of scenarios that need to be returned
data['result']['result_list'] = result_list = [] data['result']['result_list'] = result_list = []
......
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