def currscript_gradient(sensorloc): #Same as above, i = 0 gradient = 0 for ele in avgspace_some: curr_obj = ops.optsenpmt(ele,no_sensors,dim,alpha,sigma) gradient+=curr_obj.gradient_score(sensorloc) i += 1 return 0-gradient/i
def currscript_score(sensorloc): #To give a score function handle to the PSOSOLVER so that it can just ask for the value at a given SENSORLOC # and not bother about the parameters. It also helps calculate the expectation. i = 0 print ('score called ') score = 0 gradient = 0 for ele in avgspace_some: curr_obj = ops.optsenpmt(ele,no_sensors,dim,alpha,sigma) score += curr_obj.score(sensorloc) # print(curr_obj.score(sensorloc)); i+=1 return 0 - score / i