rollo.algorithm

Module Contents

class rollo.algorithm.Algorithm(deap_toolbox, constraint_obj, checkpoint_file, deap_creator, control_dict, output_dict, input_dict, start_time, parallel_method)

The Algorithm class contains methods to initialize and execute the genetic algorithm. It executes a general genetic algorithm framework that uses the hyperparameters defined in the deap_toolbox, applies constraints defined in the constraints_obj, evaluates fitness values using the evaluation function produced by Evaluation contained in the deap_toolbox, and saves all the results with BackEnd.

Parameters
  • deap_toolbox (deap.base.Toolbox object) – DEAP toolbox populated with user-defined genetic algorithm parameters

  • constraint_obj (rollo.constraints.Constraints) – Holds information about constraints for the problem and functions to apply the constraints

  • checkpoint_file (str) – Name of checkpoint file

  • deap_creator (deap.creator object) – DEAP meta-factory allowing to create classes that will fulfill the needs of the evolutionary algorithms

  • control_dict (OrderedDict) – Ordered dict of control variables as keys and a list of their solver and number of variables as each value

  • output_dict (OrderedDict) – Ordered dict of output variables as keys and solvers as values

toolbox

DEAP toolbox populated with user-defined genetic algorithm parameters

Type

deap.base.Toolbox object

constraint_obj

Holds information about constraints for the problem and functions to apply the constraints

Type

rollo.constraints.Constraints

cp_file

Name of checkpoint file

Type

str

backend

Contains and manipulates the output backend

Type

rollo.backend.Backend

parallel_method

parallelization method

Type

{‘none’, ‘multiprocessing’, ‘job_control’}

generate(self)

Executes the genetic algorithm and outputs the summarized results into an output file

Returns

list of deap.creator.Ind for final generation

Return type

list

initialize_pop(self, pop)

Initialize population for genetic algorithm

Parameters

pop (list) – list of deap.creator.Ind for previous generation

Returns

pop – list of deap.creator.Ind with fitnesses evaluated

Return type

list

apply_algorithm_ngen(self, pop, gen)

Apply genetic algorithm to a population

Parameters
  • pop (list) – list of deap.creator.Ind for previous generation

  • gen (int) – generation number

Returns

pop – list of deap.creator.Ind for new generation

Return type

list

apply_selection_operator(self, pop)

Applies selection operator to population

Parameters

pop (list) – list of deap.creator.Ind for that generation

Returns

new list of deap.creator.Ind after selection operator application

Return type

list

apply_mating_operator(self, pop)

Applies mating operator to population

Parameters

pop (list) – list of deap.creator.Ind for that generation

Returns

new list of deap.creator.Ind after mating operator application

Return type

list

apply_mutation_operator(self, pop)

Applies mutation operator to population

Parameters

pop (list) – list of deap.creator.Ind for that generation

Returns

new list of deap.creator.Ind after mutation operator application

Return type

list