crease_ga.utils

utils.initial_pop(nloci, numvars)

Produce a generation of (binary) chromosomes.

Parameters:
popnumber: int

Number of individuals in a population.

nloci: int

Number of binary bits to represent each parameter in a chromosome.

numvars: int

Number of parameters in a chromosome.

Returns:
pop: np.array of size (popnumber,`nloci`*`numvars`)

A numpy array of binary bits representing the entire generation, with each row representing a chromosome.

utils.decode(indiv, nloci, minvalu, maxvalu)

Convert a binary chromosome from a generation back to decimal parameter values.

Parameters:
pop: np.array.

A numpy array of binary bits representing the entire generation, with each row representing a chromosome.

indiv: int.

The row ID of the chromosome of interest.

nloci: int

Number of binary bits used to represent each parameter in a chromosome.

minvalu, maxvalu: list-like.

The minimum/maximum boundaries (in decimal value) of each parameter. “All-0s” in binary form will be converted to the minimum for a parameter, and “all-1s” will be converted to the maximum.

Returns:
param: np.array.

A 1D array containing the decimal values of the input parameters.