gaft.components.binary_individual¶
Module for Individual with binary encoding.
-
class
gaft.components.binary_individual.BinaryIndividual(ranges, eps=0.001)¶ Bases:
gaft.components.individual.IndividualBaseClass for individual in population. Random solution will be initialized by default.
Parameters: - ranges (tuple list) – value ranges for all entries in solution.
- eps (float or float list (with the same length with ranges)) – decrete precisions for binary encoding, default is 0.001.
-
static
binarize(decimal, eps, length)¶ Helper function to convert a float to binary sequence.
Parameters:
-
clone()¶ Clone a new individual from current one.
-
static
decimalize(binary, eps, lower_bound)¶ Helper function to convert a binary sequence back to decimal number.
Parameters:
-
decode()¶ Decode gene sequence to solution of target function.
-
encode()¶ Encode solution to gene sequence in individual using different encoding.
-
init(chromsome=None, solution=None)¶ Initialize the individual by providing chromsome or solution.
Parameters: - chromsome (list of (float / int)) – chromesome sequence for the individual
- solution (list of float) – the variable vector of the target function.
Note
If both chromsome and solution are provided, only the chromsome would be used. If neither is provided, individual would be initialized randomly.