From 0e6d124eaa7c0d9644737ef3016902f06443c07c Mon Sep 17 00:00:00 2001 From: George Lacey Date: Thu, 21 Sep 2017 15:33:49 +0100 Subject: [PATCH] Convert to class --- src/individual.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/individual.py b/src/individual.py index c826fc7..947d3fc 100644 --- a/src/individual.py +++ b/src/individual.py @@ -1,6 +1,14 @@ from math import pow, sin, pi -def fitness_function(x, y): - n = 9 - return pow(15*x*y*(1-x)*(1-y)*sin(n*pi*x)*sin(n*pi*y), 2) \ No newline at end of file +class Individual(object): + + def __init__(self, x, y): + self.x = x + self.y = y + + def fitness_function(self): + x = self.x + y = self.y + n = 9 + return pow(15*x*y*(1-x)*(1-y)*sin(n*pi*x)*sin(n*pi*y), 2)