optimModels.optimization package

Submodules

optimModels.optimization.decoders module

class optimModels.optimization.decoders.Decoder

Bases: object

Abstract class with the abstract methods that must be implemented by all decoders.

decode_candidate(candidate)
get_override_simul_problem(candidate, simulProblem)
class optimModels.optimization.decoders.DecoderMedium(ids)

Bases: optimModels.optimization.decoders.Decoder

decode_candidate(candidate)

Convert the list of indexes into a list of identifiers.

Parameters:candidate (list) – indexes of parameters.

Returns: list of parameters identifiers.

decode_candidate_ids_to_index(identifiers)

Convert the list of identifiers into a list of integers (indexes).

Parameters:identifiers (list) – Ids of parameters

Returns: List of integers (parameters indexes)

get_override_simul_problem(candidate, simulProblem)

Build the override simulation problem which will contains the modifications that must be applied to the model in order to simulate the drains that will be open for uptake. :param candidate: indexes of reactions that will be open (drains). :type candidate: list :param simulProblem: all information required to perform a model simulation. :type simulProblem: SimulationProblem

Returns: OverrideSimulProblem instance with the modifications to be applied over the simulation Problem.

class optimModels.optimization.decoders.DecoderMediumLevels(ids, levels)

Bases: optimModels.optimization.decoders.Decoder

decode_candidate(candidate)

Convert the map of type {parameterIndex : levelIndex} to a map of type {parameterId: levelOfExpression}

Parameters:candidate (dict) – The key is the parameter index and the value is the level of expression index.
Returns: A dictionary where the key is the parameter id and the value is the level of expression with values between
0 and 1 to represent under expression or higher that 1 to represent the over expression.
decode_candidate_ids_to_index(identifiers)

Convert the list of tupples of identifiers into a list of tuples of integers (indexes).

Parameters:identifiers (list) – List of tuples whit the parameters and levels ids

Returns: List of tuples indexes of parameters.

get_override_simul_problem(candidate, simulProblem)

Function to create a instance of OverrideSimulationProblem based on the candidate given by argument. :param candidate: candidate to decode :type candidate: list :param simulProblem: Simulation problem instance.

Returns: OverrideStoicSimulProblem instance

class optimModels.optimization.decoders.DecoderMediumReacKO(idsDrains, idsReactions)

Bases: optimModels.optimization.decoders.Decoder

decode_candidate(candidate)

Convert the list of index into a list of identifiers. :param candidate: list of indexes of parameters :type candidate: list

Returns: list of parameters ids.

decode_candidate_ids_to_index(identifiers)

Convert the list of identifiers into a list of integers (indexes). :param identifiers: parameters identifiers :type identifiers: list

Returns: List of parameters indexes.

get_override_simul_problem(candidate, simulProblem)

Build the override simulation problem which will contains the modifications that must be applied to the model in order to simulate the drains that will be open for uptake and KO reactions. :param candidate: indexes of reactions that will be open (drains) or the flux will be 0 (internal reactions). :type candidate: list :param simulProblem: all information required to perform a model simulation. :type simulProblem: SimulationProblem

Returns: OverrideSimulProblem instance with the modifications to be applied over the simulation Problem.

class optimModels.optimization.decoders.DecoderProtKnockouts(ids)

Bases: optimModels.optimization.decoders.Decoder

decode_candidate(candidate)

Convert the list of indexes into a list of identifiers.

Parameters:candidate (list) – indexes of parameters.

Returns: list of parameters identifiers.

decode_candidate_ids_to_index(identifiers)

Convert the list of identifiers into a list of integers (indexes).

Parameters:identifiers (list) – Ids of proteins

Returns: List of integers (proteins indexes)

get_override_simul_problem(candidate, simulProblem)

Build the override simulation problem which will contains the modifications that must be applied to the model in order to simulate the protein knockouts.

Parameters:
  • candidate (list) – indexes of proteins.
  • simulProblem (SimulationProblem) – all information required to perform a model simulation.

Returns: OverrideSimulProblem instance with the modifications to be applied over the simulation Problem.

class optimModels.optimization.decoders.DecoderProtUnderOverExpression(ids, levels)

Bases: optimModels.optimization.decoders.Decoder

decode_candidate(candidate)

Convert the map of type {proteinIndex : levelIndex} to a map of type {proteinId: levelOfExpression}

Parameters:candidate (dict) – The key is the parameter index and the value is the level of expression index.
Returns: A dictionary where the key is the protein id and the value is the level of expression with values between
0 and 1 to represent under expression or higher that 1 to represent the over expression.
decode_candidate_ids_to_index(identifiers)

Convert the list of tupples of identifiers into a list of tuples of integers (indexes).

Parameters:identifiers (list) – List of tuples whit the proteins and levels ids

Returns: List of tuples indexes.

get_override_simul_problem(candidate, simulProblem)

Build the override simulation problem which will contains the modifications that must be applied to the model in order to simulate the under/over proteins expression. :param candidate: candidate represented using proteins and levels indexes. :type candidate: dict :param simulProblem: all information required to perform a model simulation. :type simulProblem: SimulationProblem

Returns: OverrideSimulProblem instance with the modifications to be applied over the simulation Problem.

class optimModels.optimization.decoders.DecoderReacKnockouts(ids)

Bases: optimModels.optimization.decoders.Decoder

decode_candidate(candidate)

Convert the list of indexes into a list of identifiers.

Parameters:candidate (list) – indexes of parameters/reactions.

Returns: list of parameters/reactions identifiers.

decode_candidate_ids_to_index(identifiers)

Convert the list of identifiers into a list of integers (indexes).

Parameters:identifiers (list) – Ids of parameters/reactions

Returns: List of integers (parameters indexes)

get_override_simul_problem(candidate, simulProblem)

Build the override simulation problem which will contains the modifications that must be applied to the model in order to simulate the reactions knockouts.

Parameters:
  • candidate (list) – indexes of reactions.
  • simulProblem (SimulationProblem) – all information required to perform a model simulation.

Returns: OverrideSimulProblem instance with the modifications to be applied over the simulation Problem.

class optimModels.optimization.decoders.DecoderReacUnderOverExpression(ids, levels)

Bases: optimModels.optimization.decoders.Decoder

decode_candidate(candidate)

Convert the map of type {parameterIndex : levelIndex} to a map of type {parameterId: levelOfExpression}

Parameters:candidate (dict) – The key is the parameter index and the value is the level of expression index.
Returns: A dictionary where the key is the parameter id and the value is the level of expression with values between
0 and 1 to represent under expression or higher that 1 to represent the over expression.
decode_candidate_ids_to_index(identifiers)

Convert the list of tuples of identifiers into a list of tuples of integers (indexes).

Parameters:identifiers (list) – List of tuples whit the parameters and levels ids

Returns: List of tuples indexes of reactions.

get_override_simul_problem(candidate, simulProblem)

Build the override simulation problem which will contains the modifications that must be applied to the model in order to simulate the under/over enzymes expression. :param candidate: candidate represented using reactions and levels indexes. :type candidate: dict :param simulProblem: all information required to perform a model simulation. :type simulProblem: SimulationProblem

Returns: OverrideSimulProblem instance with the modifications to be applied over the simulation Problem.

optimModels.optimization.evaluation_functions module

class optimModels.optimization.evaluation_functions.BPCY(biomassId, productId, uptakeId)

Bases: optimModels.optimization.evaluation_functions.EvaluationFunction

This class implements the “Biomass-Product Coupled Yield” objective function. The fitness is given by the equation: (biomass_flux * product_flux)/ uptake_flux

Parameters:
  • biomassId (str) – Biomass reaction identifier
  • productId (str) – Target product reaction identifier
  • uptakeId (str) – Reaction of uptake
get_fitness(simulResult, candidate)
static get_id()
static get_name()
static get_parameters_ids()
method_str()
class optimModels.optimization.evaluation_functions.BP_MinModifications(biomassId, productId)

Bases: optimModels.optimization.evaluation_functions.EvaluationFunction

This class is based the “Biomass-Product Coupled Yield” objective function but considering the candidate size. The fitness is given by the equation: (biomass_flux * product_flux)/ candidate_size)

Parameters:
  • biomassId (str) – biomass reaction identifier
  • productId (str) – target product reaction identifier
get_fitness(simulResult, candidate)
static get_id()
static get_name()
static get_parameters_ids()
method_str()
class optimModels.optimization.evaluation_functions.EvaluationFunction

Bases: object

This abstract class should be extended by all evaluation functions classes.

get_fitness(simulationResult, candidate)
method_str()
class optimModels.optimization.evaluation_functions.MinCandSize(maxCandidateSize, minFluxes)

Bases: optimModels.optimization.evaluation_functions.EvaluationFunction

This class implements the “minimization of number of reactions” objective function. The fitness is given by 1 - size(candidate)/ max_candidate_size, where the max_candidate_size is the maximum size that a candidate can have during optimization.

Parameters:
  • maxCandidateSize (int) – Maximum size allowed for candidate
  • minFluxes (dict) – Minimal value for fluxes to consider fitness different of 0 (key: reaction id, value: minimum of flux).
get_fitness(simulResult, candidate)
static get_id()
static get_name()
static get_parameters_ids()
method_str()
class optimModels.optimization.evaluation_functions.MinCandSizeAndMaxTarget(maxCandidateSize, maxTargetFlux)

Bases: optimModels.optimization.evaluation_functions.EvaluationFunction

This evaluation function finds the solution with the minimum candidate size and levels considering the maximization of the target flux.

Parameters:
  • maxCandidateSize (int) – maximum of candidate size
  • maxTargetFlux (str) – reaction id to maximize
get_fitness(simulResult, candidate)
static get_id()
static get_name()
static get_parameters_ids()
method_str()
class optimModels.optimization.evaluation_functions.MinCandSizeWithLevelsAndMaxTarget(maxCandidateSize, levels, maxTargetFlux)

Bases: optimModels.optimization.evaluation_functions.EvaluationFunction

get_fitness(simulResult, candidate)
static get_id()
static get_name()
static get_parameters_ids()
method_str()
class optimModels.optimization.evaluation_functions.TargetFlux(targetReactionId)

Bases: optimModels.optimization.evaluation_functions.EvaluationFunction

This class implements the “target flux” objective function. The fitness is given by the flux value of the target reaction.

Parameters:targetReactionId (str) – Reaction identifier of the target compound production.
get_fitness(simulResult, candidate)
static get_id()
static get_name()
static get_parameters_ids()
method_str()
optimModels.optimization.evaluation_functions.build_evaluation_function(id, *args)

Function to return an evaluation function instance.

Parameters:
  • id (str) – Name of the objective function. The implemented objective functions should be registed in constants.objFunctions class
  • *args (list of str) – The number of arguments depends of the objective function chosen by user.
Returns:

return an evaluation function instance.

Return type:

EvaluationFunction

optimModels.optimization.evaluators module

optimModels.optimization.evaluators.evaluator(candidates, args)

This function allows the evaluation of candidate solutions.

Parameters:
  • candidates (list) – A list of candidate solutions
  • args (dict) – A dictionary of keyword arguments
Returns:

a list of fitness values

Return type:

list of floats

optimModels.optimization.evaluators.parallel_evaluation_mp(candidates, args)

Evaluate the candidates in parallel using multiprocessing.

This function allows parallel evaluation of candidate solutions. It uses the standard multiprocessing library to accomplish the parallelization. The function assigns the evaluation of each candidate to its own job, all of which are then distributed to the available processing units.

Parameters:
  • candidates – list the candidate solutions
  • args – a dictionary of keyword arguments

Returns:

Notes: All arguments to the evaluation function must be pickleable. Those that are not will not be sent through the args variable and will be unavailable to your function. Required keyword arguments in args: - mp_evaluator – actual evaluation function to be used (This function

should have the same signature as any other inspyred evaluation function.)

Optional keyword arguments in args:

  • mp_nprocs – number of processors that will be used (default machine cpu count)

optimModels.optimization.evolutionary_computation module

class optimModels.optimization.evolutionary_computation.EAConfigurations

Bases: object

Basic configurations to Evolutionary Algorithm.

get_default_config()
class optimModels.optimization.evolutionary_computation.OptimProblemConfiguration(simulationProblem=None, type=None, decoder=None, evaluationFunc=None, EAConfig=None, scaleProblem=1)

Bases: object

This class contains all information to perform a strain optimization

get_decoder()
get_ea_configurations()
get_evaluation_function()
get_number_reactions()
get_simulation_problem()
optimModels.optimization.evolutionary_computation.run_optimization(optimProbConf, resultFile=None, isMultiProc=False, population=None)

Function to perform the optimization using the integer set representation to the candidates solutions.

Args: optimProbConf (OptimProblemConfiguration): This object contains all information to perform the strain optimization task. resultFile (str): The path file to store all the results obtained during the optimization (default results are not saved into a file) isMultiProc (bool): True, if the user wants parallelize the population evaluation. (default False)

Returns
list: the individuals of the last population.

optimModels.optimization.generators module

optimModels.optimization.generators.generator_single_int_set(random, args)

Function to generate a new individual using the integer set representation. The function returns a set of integer values with a maximum of candidate_max_size elements.

Parameters:
  • random – the random number generator object
  • args (dict) – a dictionary of keyword arguments
Returns:

a new individual

Return type:

set

Notes

Required arguments in args: - candidate_max_size : number of integer values which compose a individual. - _ec : configuration of evolutionary computation. The argument bounder is required to get the maximum value allowed for the individual values.

optimModels.optimization.generators.generator_single_int_tuple(random, args)

Function to generate a new individual using the integer tuple representation. The function returns a set of tuples values with a maximum of candidate_max_size elements.

Parameters:
  • random – the random number generator object
  • args (dict) – keyword arguments
Returns:

a new individual where each element is composed by a tuple.

Return type:

set

Notes

Required arguments in args: - candidate_max_size : number of integer values which compose a individual. - _ec : configuration of evolutionary computation. The argument bounder is required to get the maximum value allowed for the individual values.

optimModels.optimization.generators.generator_tuple_int_set(random, args)

Function to generate a new individual using the integer representation. The function returns two integer sets.

Parameters:
  • random – the random number generator object
  • args (dict) – keyword arguments
Returns:

returns a tuple with two integer sets.

Return type:

tuple

optimModels.optimization.observers module

optimModels.optimization.observers.load_population(initPopFile=None, decoder=None)
Parameters:
  • initPopFile (str) – file name with the population to be loaded.
  • decoder (Decoder) – decoder to decode the candidates.
Returns:

number of the generation population (list): list of candidates fitness (list): fitness values for each candidate

Return type:

num_generations(str)

optimModels.optimization.observers.save_all_results(population, num_generations, num_evaluations, args)

Print the output of the evolutionary computation to a file with the follow fields: - number of generation - fitness of candidate - the solution candidates - the solution encoded candidates

Parameters:
  • population (list) – the population of Individuals
  • num_generations (int) – the number of elapsed generations
  • num_evaluations (int) – the number of evaluations already performed
  • args (dict) – a dictionary of keyword arguments

Notes

Optional keyword arguments in args: - results_file – the file path of the result file - configuration – the configuration of the EA algorithm

optimModels.optimization.replacers module

optimModels.optimization.replacers.new_candidates_no_duplicates_replacement(random, population, parents, offspring, args)

Performs replacement for the offspring.

This function performs a new candidates replacement, which means that the offspring replace the least fit individuals in the existing population, even if those offspring are less fit than the individuals that they replace.Moreover a new set of candidates random generated will be added to the population. The duplicated candidates are replaced by new ones randomly generated.

Parameters:
  • random – the random number generator object
  • population – the population of individuals
  • parents – the list of parent individuals
  • offspring – the list of offspring individuals
  • args – a dictionary of keyword arguments
Returns:

Returns the new population that will be used to next generation.

Return type:

list

optimModels.optimization.replacers.new_candidates_replacement(random, population, parents, offspring, args)

Performs replacement for the offspring.

This function performs a new candidates replacement, which means that the offspring replace the least fit individuals in the existing population, even if those offspring are less fit than the individuals that they replace. Moreover a new set of candidates random generated will be added to the population

Parameters:
  • random – the random number generator object
  • population – the population of individuals
  • parents – the list of parent individuals
  • offspring – the list of offspring individuals
  • args – a dictionary of keyword arguments
Returns:

Returns the new population that will be used to next generation.

Return type:

list

optimModels.optimization.run module

optimModels.optimization.run.cbm_strain_optim(simulProblem, evaluationFunc, levels, type=1, criticalReacs=[], isMultiProc=False, candidateSize=None, resultFile=None, initPopFile=None)

Function to run the optimization process :param simulProblem: Simulation problem :type simulProblem: StoicSimulationProblem :param evaluationFunc: evaluation function used in EA to calculate the fitness value of each candidate :param levels: List for under/expression of proteins (the levels should be set when type is *_UO :type levels: list :param type: type of optimization ( by default Reaction knockouts) :param criticalReacs: list of reactions that should not be considered in the optimization :type criticalReacs: list :param isMultiProc: use multiprocessing :type isMultiProc: bool :param candidateSize: (by default use the size defined in EAConfigurations.MAX_CANDIDATE_SIZE) :type candidateSize: int :param resultFile: File to store the solutions of each generation :type resultFile: string :param initPopFile: File with the initial population :type initPopFile: string

Returns (list): Returns the list of the best modifications.

optimModels.optimization.run.findBestSolutions(population, eaConfig)

Function to get the best individuals of a populations according to their fitness value. The number of individuals to return is given by EAConfigurations.NUM_BEST_SOLUTIONS parameter.

Parameters:
  • population (list) – list of individuals returned by EA
  • eaConfig (EAConfigurations) – EA configuration object

Returns: list of best individuals

optimModels.optimization.run.gecko_strain_optim(simulProblem, evaluationFunc, levels, type=10, criticalProteins=[], isMultiProc=False, candidateSize=None, resultFile=None, initPopFile=None)

Function to run the optimization process. :param simulProblem: Simulation problem :type simulProblem: GeckoSimulationProblem :param evaluationFunc: evaluation function used in EA to calculate the fitness value of each candidate :param levels: List for under/expression of proteins (the levels should be set when type is PROTEIN_UO :type levels: list :param type: type of optimization ( by default Protein knockouts) :param criticalProteins: list of proteins that should not be considered in the optimization :type criticalProteins: list :param isMultiProc: use multiprocessing :type isMultiProc: bool :param candidateSize: (by default use the size defined in EAConfigurations.MAX_CANDIDATE_SIZE) :type candidateSize: int :param resultFile: File to store the solutions of each generation :type resultFile: string :param initPopFile: File with the initial population :type initPopFile: string

Returns (list): Returns the list of the best modifications.

optimModels.optimization.run.kinetic_strain_optim(simulProblem, objFunc=None, levels=None, type=1, criticalParameters=[], isMultiProc=False, candidateSize=None, resultFile=None, initPopFile=None)

Function to run the optimization process :param simulProblem: Simulation problem :type simulProblem: KineticSimulationProblem :param evaluationFunc: evaluation function used in EA to calculate the fitness value of each candidate :param levels: List for under/expression of proteins (the levels should be set when type is *_UO :type levels: list :param type: type of optimization ( by default Reaction knockouts) :param criticalReacs: list of reactions that should not be considered in the optimization :type criticalReacs: list :param isMultiProc: use multiprocessing :type isMultiProc: bool :param candidateSize: (by default use the size defined in EAConfigurations.MAX_CANDIDATE_SIZE) :type candidateSize: int :param resultFile: File to store the solutions of each generation :type resultFile: string :param initPopFile: File with the initial population :type initPopFile: string

Returns (list): Returns the list of the best modifications.
The function returns the best solutions found in strain optimization. The kineticSimulationResults object has the flux distribution and metabolites concentration at steady-state, and the modifications made over the original model.
optimModels.optimization.run.print_results(fileName, population, optimConfig)
Save the results of a generation in the selected file.
Args:
fileName (string): file where the results are stored. If the file already exist append the new information. population: list of candidates optimConfig: optimization configuration object with the decoder of solutions

Returns:

optimModels.optimization.run.simplifySolutions(optimProbConf, population)

Simplify the solution by removing the modification that not affect the final fitness value. :param optimProbConf: The configuration problem. :type optimProbConf: optimProblemConfiguration :param population: List of individuals returned by EA algorithm. :type population: list

Returns: list of SimulationResults
The function returns the best solutions found in strain optimization. The SimulationResults object has the flux distribution, and the modifications made over the original model.

optimModels.optimization.variators module

optimModels.optimization.variators.grow_mutation_intSetRep(random, candidate, args)

Returns the mutant produced by a grow mutation on the candidate (when the representation is a set of integers). If a candidate solution has the maximum size candidate allowed, this function leaves it unchanged.

Parameters:
  • random – the random number generator object
  • candidate – the candidate solution
  • args – a dictionary of keyword arguments
Returns:

new candidate

Return type:

set

Notes

Optional keyword arguments in args: - mutation_rate – the rate at which mutation is performed (default 0.1)

optimModels.optimization.variators.grow_mutation_intTupleRep(random, candidate, args)

Returns the mutant produced by a grow mutation on the candidate (when the representation is a set of tuples). If a candidate solution has the maximum size candidate allowed, this function leaves it unchanged.

Parameters:
  • random – the random number generator object
  • candidate – the candidate solution
  • args – a dictionary of keyword arguments
Returns:

Returns a new candidate

Notes

Optional keyword arguments in args: - mutation_rate – the rate at which mutation is performed (default 0.1)

optimModels.optimization.variators.grow_mutation_tuple_intSetRep(random, candidate, args)

Returns the mutant produced by a grow mutation on the candidate (when the representation is a set of integers). If a candidate solution has the maximum size candidate allowed, this function leaves it unchanged.

Parameters:
  • random – the random number generator object
  • candidate – the candidate solution
  • args – a dictionary of keyword arguments
Returns:

Returns a new candidate

Notes

Optional keyword arguments in args: - mutation_rate – the rate at which mutation is performed (default 0.1)

optimModels.optimization.variators.shrink_mutation(random, candidate, args)

Returns the mutant produced by shrink mutation on the candidate. If a candidate solution has length of 1, this function leaves it unchanged.

Parameters:
  • random – the random number generator object
  • candidate – the candidate solution
  • args – a dictionary of keyword arguments
Returns:

new candidate

Return type:

set

Notes

Optional keyword arguments in args: - mutation_rate – the rate at which mutation is performed (default 0.1)

optimModels.optimization.variators.shrink_mutation_tuple(random, candidate, args)

Returns the mutant produced by shrink mutation on the candidate. If a candidate solution has length of 1, this function leaves it unchanged.

Parameters:
  • random – the random number generator object
  • candidate – the candidate solution
  • args – a dictionary of keyword arguments
Returns:

Returns a new candidate

Notes

Optional keyword arguments in args: - mutation_rate – the rate at which mutation is performed (default 0.1)

optimModels.optimization.variators.single_mutation_intSetRep(random, candidate, args)

Returns the mutant produced by a single mutation on the candidate (when the representation is a set of integers). The candidate size is maintained.

Parameters:
  • random (the random number generator object) –
  • candidate (the candidate solution) –
  • args (a dictionary of keyword arguments) –
Returns:

  • out (new candidate)
  • Optional keyword arguments in args
  • - *mutation_rate – the rate at which mutation is performed (default 0.1)*

optimModels.optimization.variators.single_mutation_intTupleRep(random, candidate, args)

Returns the mutant produced by a single mutation on the candidate (when the representation is a set of tuples). The candidate size is maintained.

Parameters:
  • random – the random number generator object
  • candidate – the candidate solution
  • args – a dictionary of keyword arguments
Returns:

Returns a new candidate

Optional keyword arguments in args:

  • mutation_rate – the rate at which mutation is performed (default 0.1)
optimModels.optimization.variators.single_mutation_tuple_intSetRep(random, candidate, args)

Returns the mutant produced by a single mutation on the candidate (when the representation is a set of integers). The candidate size is maintained.

Parameters:
  • random – the random number generator object
  • candidate – the candidate solution
  • args – a dictionary of keyword arguments
Returns:

Returns a new candidate

Notes

Optional keyword arguments in args: - mutation_rate – the rate at which mutation is performed (default 0.1)

optimModels.optimization.variators.uniform_crossover(random, mom, dad, args)

Return the offspring of the uniform crossover on the candidate. Based on two candidates (parents) build 2 children: - elements present in both parents will be present in both children; - both children have at least one element; - elements present in only one parent have equal probability to be present in child 1 or child 2 (after each child has at least one element).

Parameters:
  • random – the random number generator object
  • mom – the first parent candidate
  • dad – the second parent candidate
  • args – a dictionary of keyword arguments
Returns:

Return the offspring of the candidates given as argument.

Notes

Optional keyword arguments in args: - crossover_rate – the rate at which crossover is performed (default 1.0)

optimModels.optimization.variators.uniform_crossover_intTupleRep(random, mom, dad, args)

Return the offspring of the uniform crossover on the candidate. Based on two candidates (parents) build 2 children: - elements present in both parents will be present in both children; - both children have at least one element; - elements present in only one parent have equal probability to be present in child 1 or child 2 (after each child has at least one element).

Parameters:
  • random – the random number generator object
  • mom – the first parent candidate
  • dad – the second parent candidate
  • args – a dictionary of keyword arguments
Returns:

Returns the offspring of the candidates given as argument.

Notes

Optional keyword arguments in args: - crossover_rate – the rate at which crossover is performed (default 1.0)

optimModels.optimization.variators.uniform_crossover_tuple(random, mom, dad, args)

Return the offspring of the uniform crossover on the candidate. Based on two candidates (parents) build 2 children: - elements present in both parents will be present in both children; - both children have at least one element; - elements present in only one parent have equal probability to be present in child 1 or child 2 (after each child has at least one element).

Parameters:
  • random – the random number generator object
  • mom – the first parent candidate
  • dad – the second parent candidate
  • args – a dictionary of keyword arguments
Returns:

Return the offspring of the candidates given as argument.

Notes

Optional keyword arguments in args: - crossover_rate – the rate at which crossover is performed (default 1.0)

Module contents