Commit afb0fd3b authored by Georgios Dagkakis's avatar Georgios Dagkakis

plugin to score the solution based on the units throughput

parent db59ade7
...@@ -17,19 +17,20 @@ class BatchesACO(ACO): ...@@ -17,19 +17,20 @@ class BatchesACO(ACO):
def _calculateAntScore(self, ant): def _calculateAntScore(self, ant):
"""Calculate the score of this ant. """Calculate the score of this ant.
""" """
totalDelay=0 #set the total delay to 0
result, = ant['result']['result_list'] #read the result as JSON result, = ant['result']['result_list'] #read the result as JSON
#loop through the elements #loop through the elements
for element in result['elementList']: for element in result['elementList']:
element_family = element.get('family', None) element_family = element.get('family', None)
#id the class is Job #id the class is Exit get the unitsThroughput
if element_family == 'Job': if element_family == 'Exit':
results=element['results'] unitsThroughput=element['results'].get('unitsThroughput',None)
delay = float(results.get('delay', "0")) if unitsThroughput:
# A negative delay would mean we are ahead of schedule. This unitsThroughput=unitsThroughput[0]
# should not be considered better than being on time. if not unitsThroughput:
totalDelay += max(delay, 0) unitsThroughput=batchesThroughput
return totalDelay print 'score=',unitsThroughput
# return the negative value since they are ranked this way. XXX discuss this
return -unitsThroughput
# creates the collated scenarios, i.e. the list # creates the collated scenarios, i.e. the list
# of options collated into a dictionary for ease of referencing in ManPy # of options collated into a dictionary for ease of referencing in ManPy
...@@ -45,10 +46,10 @@ class BatchesACO(ACO): ...@@ -45,10 +46,10 @@ class BatchesACO(ACO):
collated[str(i)]=[float(staticValue)] collated[str(i)]=[float(staticValue)]
else: else:
collated[str(i)]=[] collated[str(i)]=[]
value=minValue value=float(minValue)
while 1: while 1:
collated[str(i)].append(round(float(value),2)) collated[str(i)].append(round(float(value),2))
value+=stepValue value+=float(stepValue)
if value>maxValue: if value>maxValue:
break break
return collated return collated
...@@ -70,7 +71,7 @@ class BatchesACO(ACO): ...@@ -70,7 +71,7 @@ class BatchesACO(ACO):
ant_data = copy(data) ant_data = copy(data)
# below provisional values, to be updated (should the user set those?) # below provisional values, to be updated (should the user set those?)
data['general']['numberOfSolutions']=1 data['general']['numberOfSolutions']=1
data["general"]["numberOfGenerations"]=1 data["general"]["numberOfGenerations"]=4
data["general"]["numberOfAntsPerGenerations"]=2 data["general"]["numberOfAntsPerGenerations"]=2
ACO.run(self, data) ACO.run(self, data)
return data return data
\ 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