def __call__(self, individual):
try:
# Transform the tree expression in a callable function
func = toolbox.compile(expr=individual)
error = numpy.fabs(func(*self.inVarValues) - self.targetVarValues) / self.targetVarValues
sumerror = numpy.sum(error)
return (sumerror,)
except NameError as ne:
print ne
print ne.message
except Exception as e:
return (sys.float_info.max,)
#This is a basic error function that finds the maximum of all the relative errors.
#Note that your data set should not contain any 0 values. That will cause a "divide by zero" error.
#At initialization time, it gets the data to compare against.
#
# The data is a list of lists, the labels give the names of interesting data.
# The config file defines which data lists are of use.
# All data lists are expected to be of equla length. Repeated values are perfectly OK.
# The config file defines a set of "inVars" which are the input variables. (e.g. rho, T)
# it also defines a single "targetVar" which is the array of function values.
评论列表
文章目录