Skip to main content

BEATensor

Module: opytimizer.optimizers.single_objective.evolutionary.bea

Tensorized (NumPy / CuPy) BlockEA: the same graph, run on the whole population.

Constructor​

BEATensor(params: 'Optional[Dict[str, Any]]' = None, exchange_size: 'int' = 2, crossover_size: 'int' = 3, tournament_sizes: 'Optional[Sequence[int]]' = None, exchange_probabilities: 'Optional[Any]' = None, crossover_scales: 'Optional[Any]' = None, crossover_shifts: 'Optional[Any]' = None, n_offspring: 'Optional[int]' = None, max_generations: 'Optional[int]' = None, de_start: 'float' = 0.7, de_scale: 'float' = 0.5, de_rate: 'float' = 0.9) -> 'None'

Parameters​

ParameterTypeDefaultDescription
paramsOptional[Dict[str, Any]]NoneContains key-value parameters to the meta-heuristics.
exchange_sizeint2Parents per Exchange offspring (nParents of Algorithm 2).
crossover_sizeint3Parents per Crossover offspring (nParents of Algorithm 3).
tournament_sizesOptional[Sequence[int]]Nonem of each of the 3 Tournament blocks, in [1, 10].
exchange_probabilitiesOptional[Any]NoneProbability of each parent in the Exchange blocks, shape (3, exchange_size) (broadcastable).
crossover_scalesOptional[Any]Nonew1 of each of the 2 Crossover blocks.
crossover_shiftsOptional[Any]Nonew2 of each of the 2 Crossover blocks.
n_offspringOptional[int]NoneMinimum number of offspring per generation (defaults to the population size); it is rounded up so that every division of the graph is exact.
max_generationsOptional[int]NoneNumber of generations of the run. When given, the late-stage DE is connected after de_start * max_generations.
de_startfloat0.7Fraction of the run after which the DE is connected.
de_scalefloat0.5Scaling factor F of the late-stage DE.
de_ratefloat0.9Crossover rate CR of the late-stage DE.

Methods​

compile​

compile(self, space: '_SingleObjectiveTensorSpace') -> 'None'

Prepares the block parameters on the space's backend.

Parameters​

ParameterTypeDefaultDescription
space_SingleObjectiveTensorSpace—

evaluate​

evaluate(self, space: '_SingleObjectiveTensorSpace', function: 'Function') -> 'None'

Evaluates the initial population (offspring are evaluated in update).

Parameters​

ParameterTypeDefaultDescription
space_SingleObjectiveTensorSpace—
functionFunction—

update​

update(self, space: '_SingleObjectiveTensorSpace', function: 'Function') -> 'None'

Performs one generation: offspring creation and environmental selection.

Parameters​

ParameterTypeDefaultDescription
space_SingleObjectiveTensorSpaceA tensorized SingleObjectiveSpace object.
functionFunctionA Function object that will be used as the objective function.