Algorithms
pymoode.algorithms
- class pymoode.algorithms.DE(pop_size: int = 100, sampling: Sampling | None = None, variant: str = 'DE/rand/1/bin', CR: float = 0.7, F: Tuple[float, float] | float | None = (0.5, 1.0), gamma: float = 0.0001, de_repair: Callable | str = 'bounce-back', survival: Survival | None = None, advance_after_initial_infill: bool = True, output: Display | None = None, **kwargs)
Bases:
DifferentialEvolutionSingle-objective Differential Evolution proposed by Storn and Price (1997).
Storn, R. & Price, K., 1997. Differential evolution-a simple and efficient heuristic for global optimization over continuous spaces. J. Glob. Optim., 11(4), pp. 341-359.
Base class for Differential Evolution algorithms
- Parameters:
- pop_sizeint, optional
Population size. Defaults to 100.
- samplingSampling, optional
Sampling strategy of pymoo. Defaults to LHS().
- variantstr, optional
Differential evolution strategy. Must be a string in the format: “DE/selection/n/crossover”, in which, n in an integer of number of difference vectors, and crossover is either ‘bin’ or ‘exp’. Selection variants are:
‘ranked’
‘rand’
‘best’
‘current-to-best’
‘current-to-best’
‘current-to-rand’
‘rand-to-best’
The selection strategy ‘ranked’ might be helpful to improve convergence speed without much harm to diversity. Defaults to ‘DE/rand/1/bin’.
- CRfloat, optional
Crossover parameter. Defined in the range [0, 1] To reinforce mutation, use higher values. To control convergence speed, use lower values.
- Fiterable of float or float, optional
Scale factor or mutation parameter. Defined in the range (0, 2] To reinforce exploration, use higher values; for exploitation, use lower values.
- gammafloat, optional
Jitter deviation parameter. Should be in the range (0, 2). Defaults to 1e-4.
- de_repairstr, optional
Repair of DE mutant vectors. Is either callable or one of:
‘bounce-back’
‘midway’
‘rand-init’
‘to-bounds’
If callable, has the form fun(X, Xb, xl, xu) in which X contains mutated vectors including violations, Xb contains reference vectors for repair in feasible space, xl is a 1d vector of lower bounds, and xu a 1d vector of upper bounds. Defaults to ‘bounce-back’.
- genetic_mutation, optional
Pymoo’s genetic mutation operator after crossover. Defaults to NoMutation().
- survivalSurvival, optional
Replacement survival operator. Defaults to ImprovementReplacement().
- repairRepair, optional
Pymoo’s repair operator after mutation. Defaults to NoRepair().
- class pymoode.algorithms.GDE3(pop_size: int = 100, sampling: Sampling | None = None, variant: str = 'DE/rand/1/bin', CR: float = 0.5, F: Tuple[float, float] | float | None = None, gamma: float = 0.0001, de_repair: Callable | str = 'bounce-back', survival: Survival | None = None, output: Display | None = None, **kwargs)
Bases:
MODEGDE3 is an extension of DE to multi-objective problems using a mixed type survival strategy. It is implemented in this version with the same constraint handling strategy of NSGA-II by default.
Derived algorithms GDE3-MNN and GDE3-2NN use by default survival RankAndCrowding with metrics ‘mnn’ and ‘2nn’.
For many-objective problems, try using NSDE-R, GDE3-MNN, or GDE3-2NN.
For Bi-objective problems, survival = RankAndCrowding(crowding_func=’pcd’) is very effective.
Kukkonen, S. & Lampinen, J., 2005. GDE3: The third evolution step of generalized differential evolution. 2005 IEEE congress on evolutionary computation, Volume 1, pp. 443-450.
Base class for Differential Evolution algorithms
- Parameters:
- pop_sizeint, optional
Population size. Defaults to 100.
- samplingSampling, optional
Sampling strategy of pymoo. Defaults to LHS().
- variantstr, optional
Differential evolution strategy. Must be a string in the format: “DE/selection/n/crossover”, in which, n in an integer of number of difference vectors, and crossover is either ‘bin’ or ‘exp’. Selection variants are:
‘ranked’
‘rand’
‘best’
‘current-to-best’
‘current-to-best’
‘current-to-rand’
‘rand-to-best’
The selection strategy ‘ranked’ might be helpful to improve convergence speed without much harm to diversity. Defaults to ‘DE/rand/1/bin’.
- CRfloat, optional
Crossover parameter. Defined in the range [0, 1] To reinforce mutation, use higher values. To control convergence speed, use lower values.
- Fiterable of float or float, optional
Scale factor or mutation parameter. Defined in the range (0, 2] To reinforce exploration, use higher values; for exploitation, use lower values.
- gammafloat, optional
Jitter deviation parameter. Should be in the range (0, 2). Defaults to 1e-4.
- de_repairstr, optional
Repair of DE mutant vectors. Is either callable or one of:
‘bounce-back’
‘midway’
‘rand-init’
‘to-bounds’
If callable, has the form fun(X, Xb, xl, xu) in which X contains mutated vectors including violations, Xb contains reference vectors for repair in feasible space, xl is a 1d vector of lower bounds, and xu a 1d vector of upper bounds. Defaults to ‘bounce-back’.
- genetic_mutation, optional
Pymoo’s genetic mutation operator after crossover. Defaults to NoMutation().
- survivalSurvival, optional
Replacement survival operator. Defaults to ImprovementReplacement().
- repairRepair, optional
Pymoo’s repair operator after mutation. Defaults to NoRepair().
- class pymoode.algorithms.NSDE(pop_size: int = 100, variant: str = 'DE/rand/1/bin', CR: float = 0.7, F: Tuple[float, float] | float | None = None, gamma: float = 0.0001, de_repair: Callable | str = 'bounce-back', survival: Survival | None = None, **kwargs)
Bases:
MODENSDE is an algorithm that combines that combines NSGA-II sorting and survival strategies to DE mutation and crossover.
For many-objective problems, try using NSDE-R, GDE3-MNN, or GDE3-2NN.
For Bi-objective problems, survival = RankAndCrowding(crowding_func=’pcd’) is very effective.
Base class for Differential Evolution algorithms
- Parameters:
- pop_sizeint, optional
Population size. Defaults to 100.
- samplingSampling, optional
Sampling strategy of pymoo. Defaults to LHS().
- variantstr, optional
Differential evolution strategy. Must be a string in the format: “DE/selection/n/crossover”, in which, n in an integer of number of difference vectors, and crossover is either ‘bin’ or ‘exp’. Selection variants are:
‘ranked’
‘rand’
‘best’
‘current-to-best’
‘current-to-best’
‘current-to-rand’
‘rand-to-best’
The selection strategy ‘ranked’ might be helpful to improve convergence speed without much harm to diversity. Defaults to ‘DE/rand/1/bin’.
- CRfloat, optional
Crossover parameter. Defined in the range [0, 1] To reinforce mutation, use higher values. To control convergence speed, use lower values.
- Fiterable of float or float, optional
Scale factor or mutation parameter. Defined in the range (0, 2] To reinforce exploration, use higher values; for exploitation, use lower values.
- gammafloat, optional
Jitter deviation parameter. Should be in the range (0, 2). Defaults to 1e-4.
- de_repairstr, optional
Repair of DE mutant vectors. Is either callable or one of:
‘bounce-back’
‘midway’
‘rand-init’
‘to-bounds’
If callable, has the form fun(X, Xb, xl, xu) in which X contains mutated vectors including violations, Xb contains reference vectors for repair in feasible space, xl is a 1d vector of lower bounds, and xu a 1d vector of upper bounds. Defaults to ‘bounce-back’.
- genetic_mutation, optional
Pymoo’s genetic mutation operator after crossover. Defaults to NoMutation().
- survivalSurvival, optional
Replacement survival operator. Defaults to ImprovementReplacement().
- repairRepair, optional
Pymoo’s repair operator after mutation. Defaults to NoRepair().
- class pymoode.algorithms.NSDER(ref_dirs: ndarray, pop_size: int = 100, variant: str = 'DE/rand/1/bin', CR: float = 0.5, F: Tuple[float, float] | float | None = None, gamma: float = 0.0001, **kwargs)
Bases:
NSDENSDE-R is an extension of NSDE to many-objective problems (Reddy & Dulikravich, 2019) using NSGA-III survival.
S. R. Reddy and G. S. Dulikravich, “Many-objective differential evolution optimization based on reference points: NSDE-R,” Struct. Multidisc. Optim., vol. 60, pp. 1455-1473, 2019.
Base class for Differential Evolution algorithms
- Parameters:
- pop_sizeint, optional
Population size. Defaults to 100.
- samplingSampling, optional
Sampling strategy of pymoo. Defaults to LHS().
- variantstr, optional
Differential evolution strategy. Must be a string in the format: “DE/selection/n/crossover”, in which, n in an integer of number of difference vectors, and crossover is either ‘bin’ or ‘exp’. Selection variants are:
‘ranked’
‘rand’
‘best’
‘current-to-best’
‘current-to-best’
‘current-to-rand’
‘rand-to-best’
The selection strategy ‘ranked’ might be helpful to improve convergence speed without much harm to diversity. Defaults to ‘DE/rand/1/bin’.
- CRfloat, optional
Crossover parameter. Defined in the range [0, 1] To reinforce mutation, use higher values. To control convergence speed, use lower values.
- Fiterable of float or float, optional
Scale factor or mutation parameter. Defined in the range (0, 2] To reinforce exploration, use higher values; for exploitation, use lower values.
- gammafloat, optional
Jitter deviation parameter. Should be in the range (0, 2). Defaults to 1e-4.
- de_repairstr, optional
Repair of DE mutant vectors. Is either callable or one of:
‘bounce-back’
‘midway’
‘rand-init’
‘to-bounds’
If callable, has the form fun(X, Xb, xl, xu) in which X contains mutated vectors including violations, Xb contains reference vectors for repair in feasible space, xl is a 1d vector of lower bounds, and xu a 1d vector of upper bounds. Defaults to ‘bounce-back’.
- genetic_mutation, optional
Pymoo’s genetic mutation operator after crossover. Defaults to NoMutation().
- survivalSurvival, optional
Replacement survival operator. Defaults to ImprovementReplacement().
- repairRepair, optional
Pymoo’s repair operator after mutation. Defaults to NoRepair().
pymoode.algorithms.base
- class pymoode.algorithms.base.evolutionary.EvolutionaryAlgorithm(pop_size: int | None = None, sampling: Sampling | None = None, mating: Mating | None = None, survival: Survival | None = None, n_offsprings: int | None = None, eliminate_duplicates: bool = True, repair: Repair | None = None, advance_after_initial_infill: bool = False, **kwargs)
Base class for Evolutionary Algorithms
- Parameters:
- pop_sizeint, optional
Population size, by default None
- samplingSampling, optional
pymoo Sampling instance, by default None
- matingInfillCriterion, optional
pymoo mating operator, by default None
- survivalSurvival, optional
pymoo survival operator, by default None
- n_offspringsint, optional
Number of offspring individuals created at each generation, by default None
- eliminate_duplicatesDuplicateElimination | bool | None, optional
Eliminate duplicates in mating, by default True
- repairRepair, optional
pymoo repair operator. In the algorithm level it should be called when sampling. It is recommended that mating operators also have some repair associated with. By default None
- advance_after_initial_infillbool, optional
Either or not apply survival after initialization, by default False
- Attributes:
- n_gen
Methods
advance
ask
finalize
has_next
infill
next
result
run
setup
tell
- class pymoode.algorithms.base.genetic.GeneticAlgorithm(pop_size: int | None = None, sampling: Sampling | None = None, selection: Selection | None = None, crossover: Crossover | None = None, mutation: Mutation | None = None, survival: Survival | None = None, n_offsprings: int | None = None, eliminate_duplicates: bool | DefaultDuplicateElimination = True, repair: Repair | None = None, **kwargs)
Base class for Genetic Algorithms. A Mating operator is instantiated using selection, crossover, mutation, repair, and eliminate_duplicates arguments.
- Parameters:
- pop_sizeint, optional
Population size, by default None
- samplingSampling, optional
pymoo Sampling instance, by default None
- selectionSelection, optional
pymoo parent selection operator, by default None
- crossoverCrossover, optional
pymoo crossover operator, by default None
- genetic_mutation, optional
pymoo mutation operator, by default None
- survivalSurvival, optional
pymoo survival operator, by default None
- n_offspringsint, optional
Number of offspring individuals created at each generation, by default None
- eliminate_duplicatesDuplicateElimination | bool | None, optional
Eliminate duplicates in mating, by default True
- repairRepair, optional
pymoo repair operator which should be passed to Mating and self. By default None
- advance_after_initial_infillbool, optional
Either or not apply survival after initialization, by default False
- Attributes:
- n_gen
Methods
advance
ask
finalize
has_next
infill
next
result
run
setup
tell