Parameter classes

class golem.core.optimisers.optimizer.AlgorithmParameters(multi_objective: bool = False, offspring_rate: float = 0.5, pop_size: int = 20, max_pop_size: Optional[int] = 55, adaptive_depth: bool = False, adaptive_depth_max_stagnation: int = 3, structural_diversity_frequency_check: int = 5)[source]

Bases: object

Base class for definition of optimizers-specific parameters. Can be extended for custom optimizers.

Parameters
  • multi_objective – defines if the optimizer must be multi-criterial

  • offspring_rate – offspring rate used on next population

  • pop_size – initial population size

  • max_pop_size – maximum population size; optional, if unspecified, then population size is unbound

  • adaptive_depth – flag to enable adaptive configuration of graph depth

  • adaptive_depth_max_stagnation – max number of stagnating populations before adaptive depth increment

multi_objective: bool = False
offspring_rate: float = 0.5
pop_size: int = 20
max_pop_size: Optional[int] = 55
adaptive_depth: bool = False
adaptive_depth_max_stagnation: int = 3
structural_diversity_frequency_check: int = 5
class golem.core.optimisers.genetic.gp_params.GPAlgorithmParameters(multi_objective: bool = False, offspring_rate: float = 0.5, pop_size: int = 20, max_pop_size: Optional[int] = 55, adaptive_depth: bool = False, adaptive_depth_max_stagnation: int = 3, structural_diversity_frequency_check: int = 5, crossover_prob: float = 0.8, mutation_prob: float = 0.8, variable_mutation_num: bool = True, max_num_of_operator_attempts: int = 100, mutation_strength: golem.core.optimisers.genetic.operators.base_mutations.MutationStrengthEnum = MutationStrengthEnum.mean, min_pop_size_with_elitism: int = 5, required_valid_ratio: float = 0.9, adaptive_mutation_type: golem.core.optimisers.adaptive.operator_agent.MutationAgentTypeEnum = MutationAgentTypeEnum.default, context_agent_type: Union[golem.core.optimisers.adaptive.context_agents.ContextAgentTypeEnum, Callable] = ContextAgentTypeEnum.nodes_num, selection_types: Optional[Sequence[Union[golem.core.optimisers.genetic.operators.selection.SelectionTypesEnum, Any]]] = None, crossover_types: Sequence[Union[golem.core.optimisers.genetic.operators.crossover.CrossoverTypesEnum, Any]] = (<CrossoverTypesEnum.one_point: 'one_point'>, ), mutation_types: Sequence[Union[golem.core.optimisers.genetic.operators.base_mutations.MutationTypesEnum, Any]] = (<MutationTypesEnum.tree_growth: 'tree_growth'>, <MutationTypesEnum.single_add: 'single_add'>, <MutationTypesEnum.single_change: 'single_change'>, <MutationTypesEnum.single_drop: 'single_drop'>, <MutationTypesEnum.single_edge: 'single_edge'>), elitism_type: golem.core.optimisers.genetic.operators.elitism.ElitismTypesEnum = ElitismTypesEnum.keep_n_best, regularization_type: golem.core.optimisers.genetic.operators.regularization.RegularizationTypesEnum = RegularizationTypesEnum.none, genetic_scheme_type: golem.core.optimisers.genetic.operators.inheritance.GeneticSchemeTypesEnum = GeneticSchemeTypesEnum.generational, decaying_factor: float = 1.0, window_size: Optional[int] = None)[source]

Bases: golem.core.optimisers.optimizer.AlgorithmParameters

Defines parameters of evolutionary operators and the algorithm of genetic optimizer.

Parameters
  • crossover_prob – crossover probability (chance that two individuals will be mated).

  • mutation_prob – mutation probability (chance that an individual will be mutated).

  • variable_mutation_num – flag to apply mutation one or few times for individual in each iteration.

  • max_num_of_operator_attempts – max number of unsuccessful evo operator attempts before continuing.

  • mutation_strength – strength of mutation in tree (using in certain mutation types)

  • min_pop_size_with_elitism – minimal population size with which elitism is applicable

  • required_valid_ratio – ratio of valid individuals on next population to continue optimization.

Used in ReproductionController to compensate for invalid individuals. See the class for details.

Parameters
  • adaptive_mutation_type – Experimental feature! Enables adaptive Mutation agent.

  • context_agent_type – Experimental feature! Enables graph encoding for Mutation agent.

Adaptive mutation agent uses specified algorithm. ‘random’ type is the default non-adaptive version. Requires crossover_types to be CrossoverTypesEnum.none for correct adaptive learning, so that fitness changes depend only on agent’s actions (chosen mutations). MutationAgentTypeEnum.bandit uses Multi-Armed Bandit (MAB) learning algorithm. MutationAgentTypeEnum.contextual_bandit uses contextual MAB learning algorithm. MutationAgentTypeEnum.neural_bandit uses contextual MAB learning algorithm with Deep Neural encoding.

Parameter context_agent_type specifies implementation of graph/node encoder for adaptive mutation agent. It is relevant for contextual and neural bandits.

Parameters
  • selection_types – Sequence of selection operators types

  • crossover_types – Sequence of crossover operators types

  • mutation_types – Sequence of mutation operators types

  • elitism_type – type of elitism operator evolution

  • regularization_type – type of regularization operator

Regularization attempts to cut off the subtrees of the graph. If the truncated graph is not worse than the original, then it enters the new generation as a simpler solution. Regularization is not used by default, it must be explicitly enabled.

Parameters

genetic_scheme_type – type of genetic evolutionary scheme

The generational scheme is a standard scheme of the evolutionary algorithm. It specifies that at each iteration the entire generation is updated.

In the steady_state scheme at each iteration only one individual is updated.

The parameter_free scheme is an adaptive variation of the steady_state scheme. It specifies that the population size and the probability of mutation and crossover change depending on the success of convergence. If there are no improvements in fitness, then the size and the probabilities increase. When fitness improves, the size and the probabilities decrease. That is, the algorithm choose a more stable and conservative mode when optimization seems to converge.

Parameters
  • decaying_factor – decaying factor for Multi-Armed Bandits for managing the profit from operators The smaller the value of decaying_factor, the larger the influence for the best operator.

  • window_size – the size of sliding window for Multi-Armed Bandits to decrease variance. The window size is measured by the number of individuals to consider.

crossover_prob: float = 0.8
mutation_prob: float = 0.8
variable_mutation_num: bool = True
max_num_of_operator_attempts: int = 100
mutation_strength: golem.core.optimisers.genetic.operators.base_mutations.MutationStrengthEnum = 1.0
min_pop_size_with_elitism: int = 5
required_valid_ratio: float = 0.9
adaptive_mutation_type: golem.core.optimisers.adaptive.operator_agent.MutationAgentTypeEnum = 'default'
context_agent_type: Union[golem.core.optimisers.adaptive.context_agents.ContextAgentTypeEnum, Callable] = 'nodes_num'
selection_types: Optional[Sequence[Union[golem.core.optimisers.genetic.operators.selection.SelectionTypesEnum, Any]]] = None
crossover_types: Sequence[Union[golem.core.optimisers.genetic.operators.crossover.CrossoverTypesEnum, Any]] = (<CrossoverTypesEnum.one_point: 'one_point'>,)
mutation_types: Sequence[Union[golem.core.optimisers.genetic.operators.base_mutations.MutationTypesEnum, Any]] = (<MutationTypesEnum.tree_growth: 'tree_growth'>, <MutationTypesEnum.single_add: 'single_add'>, <MutationTypesEnum.single_change: 'single_change'>, <MutationTypesEnum.single_drop: 'single_drop'>, <MutationTypesEnum.single_edge: 'single_edge'>)
elitism_type: golem.core.optimisers.genetic.operators.elitism.ElitismTypesEnum = 'keep_n_best'
regularization_type: golem.core.optimisers.genetic.operators.regularization.RegularizationTypesEnum = 'none'
genetic_scheme_type: golem.core.optimisers.genetic.operators.inheritance.GeneticSchemeTypesEnum = 'generational'
decaying_factor: float = 1.0
window_size: Optional[int] = None
class golem.core.optimisers.optimization_parameters.OptimizationParameters(num_of_generations: Optional[int] = None, timeout: Optional[datetime.timedelta] = datetime.timedelta(seconds=300), early_stopping_iterations: Optional[int] = 50, early_stopping_timeout: Optional[float] = 5, keep_n_best: int = 1, max_graph_fit_time: Optional[datetime.timedelta] = None, n_jobs: int = 1, show_progress: bool = True, collect_intermediate_metric: bool = False, parallelization_mode: str = 'populational', static_individual_metadata: dict = <factory>, keep_history: bool = True, history_dir: Optional[str] = <factory>, agent_dir: Optional[str] = <factory>)[source]

Bases: object

Defines general algorithm-independent parameters of the composition process (like stop condition, validation, timeout, logging etc.)

Options related to stop condition:

Parameters
  • num_of_generations – maximum number of optimizer generations

  • timeout – max time in minutes available for composition process

  • early_stopping_iterations

    for early stopping.

    Optional max number of stagnating iterations for early stopping. If both early_stopping options are None, then do not use early stopping.

  • early_stopping_timeout

    for early stopping.

    Optional duration (in minutes) of stagnating optimization for early stopping. If both early_stopping options are None, then do not use early stopping.

Infrastructure options (logging, performance)

Parameters
  • keep_n_best – number of the best individuals of previous generation to keep in next generation

  • max_graph_fit_time – time constraint for evaluation of each graph (datetime.timedelta)

  • n_jobs – num of n_jobs

  • show_progress – bool indicating whether to show progress using tqdm or not

  • collect_intermediate_metric – save metrics for intermediate (non-root) nodes in graph

  • parallelization_mode – identifies the way to parallelize population evaluation

History options:

Parameters
  • keep_history – if True, then save generations to history; if False, don’t keep history.

  • history_dir

    directory for saving optimization history, optional.

    If the path is relative, then save relative to default_data_dir. If absolute – then save directly by specified path. If None – do not save the history to disk and keep it only in-memory.

num_of_generations: Optional[int] = None
timeout: Optional[datetime.timedelta] = datetime.timedelta(seconds=300)
early_stopping_iterations: Optional[int] = 50
early_stopping_timeout: Optional[float] = 5
keep_n_best: int = 1
max_graph_fit_time: Optional[datetime.timedelta] = None
n_jobs: int = 1
show_progress: bool = True
collect_intermediate_metric: bool = False
parallelization_mode: str = 'populational'
static_individual_metadata: dict
keep_history: bool = True
history_dir: Optional[str]
agent_dir: Optional[str]
class golem.core.optimisers.optimization_parameters.GraphRequirements(num_of_generations: Optional[int] = None, timeout: Optional[datetime.timedelta] = datetime.timedelta(seconds=300), early_stopping_iterations: Optional[int] = 50, early_stopping_timeout: Optional[float] = 5, keep_n_best: int = 1, max_graph_fit_time: Optional[datetime.timedelta] = None, n_jobs: int = 1, show_progress: bool = True, collect_intermediate_metric: bool = False, parallelization_mode: str = 'populational', static_individual_metadata: dict = <factory>, keep_history: bool = True, history_dir: Optional[str] = <factory>, agent_dir: Optional[str] = <factory>, start_depth: int = 3, max_depth: int = 10, min_arity: int = 2, max_arity: int = 4)[source]

Bases: golem.core.optimisers.optimization_parameters.OptimizationParameters

Defines restrictions and requirements on final graphs.

Restrictions on final graphs:

Parameters
  • start_depth – start value of adaptive tree depth

  • max_depth – max depth of the resulting graph

  • min_arity – min number of parents for node

  • max_arity – max number of parents for node

start_depth: int = 3
max_depth: int = 10
min_arity: int = 2
max_arity: int = 4
class golem.core.optimisers.optimizer.GraphGenerationParams(adapter: Optional[golem.core.adapter.adapter.BaseOptimizationAdapter] = None, rules_for_constraint: Sequence[Callable[[...], bool]] = (<function has_root>, <function has_no_cycle>, <function has_no_isolated_components>, <function has_no_self_cycled_nodes>, <function has_no_isolated_nodes>), advisor: Optional[golem.core.optimisers.advisor.DefaultChangeAdvisor] = None, node_factory: Optional[golem.core.optimisers.opt_node_factory.OptNodeFactory] = None, random_graph_factory: Optional[Callable[[golem.core.optimisers.optimization_parameters.GraphRequirements, int], golem.core.dag.graph.Graph]] = None, available_node_types: Optional[Sequence[Any]] = None, remote_evaluator: Optional[golem.core.optimisers.genetic.evaluation.DelegateEvaluator] = None)[source]

Bases: object

This dataclass is for defining the parameters using in graph generation process

Parameters
  • adapter – instance of domain graph adapter for adaptation between domain and optimization graphs

  • rules_for_constraint – collection of constraints for graph verification

  • advisor – instance providing task and context-specific advices for graph changes

  • node_factory – instance for generating new nodes in the process of graph search

  • remote_evaluator – instance of delegate evaluator for evaluation of graphs

adapter: golem.core.adapter.adapter.BaseOptimizationAdapter
verifier: golem.core.dag.graph_verifier.GraphVerifier
advisor: golem.core.optimisers.advisor.DefaultChangeAdvisor
remote_evaluator: Optional[golem.core.optimisers.genetic.evaluation.DelegateEvaluator] = None
node_factory: golem.core.optimisers.opt_node_factory.OptNodeFactory
random_graph_factory: Callable[[golem.core.optimisers.optimization_parameters.GraphRequirements, int], golem.core.dag.graph.Graph]