From 0dcc43005c23c3d6f6cbd1c864fee36e7ea7c2ab Mon Sep 17 00:00:00 2001 From: SimpleArt <71458112+SimpleArt@users.noreply.github.com> Date: Thu, 12 Nov 2020 14:28:08 -0500 Subject: [PATCH] Target fitness type converter --- src/attributes.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/attributes.py b/src/attributes.py index e998ff6..9af579e 100644 --- a/src/attributes.py +++ b/src/attributes.py @@ -34,6 +34,19 @@ class Attributes: been set then they will fall back onto the default attribute. All attributes have been catigorized to explain sections in the ga process.""" + target_fitness_type_dict = { + 'min' : 'min', + 'minimize' : 'min', + 'minimise' : 'min', + 'minimization' : 'min', + 'minimisation' : 'min', + 'max' : 'max', + 'maximize' : 'max', + 'maximise' : 'max', + 'maximization' : 'max', + 'maximisation' : 'max' + } + def __init__(self, chromosome_length = 10, population_size = 10, @@ -170,3 +183,21 @@ class Attributes: if(not isinstance(value_input, int) or value_input <= 0): raise ValueError("Population length must be integer greater then 0") self._population_size = value_input + + + @property + def target_fitness_type(self): + """Getter function for target fitness type.""" + + return self._target_fitness_type + + + @target_fitness_type.setter + def target_fitness_type(self, value_input): + """Setter function for target fitness type for + converting input to min/max.""" + + if value_input in self.target_fitness_type_dict.keys(): + self._target_fitness_type = target_fitness_type_dict[value_input] + else: + self._target_fitness_type = value_input