GraphOptimizer

class golem.core.optimisers.optimizer.GraphOptimizer(objective: golem.core.optimisers.objective.objective.Objective, initial_graphs: Optional[Sequence[Union[golem.core.dag.graph.Graph, Any]]] = None, requirements: Optional[golem.core.optimisers.optimization_parameters.OptimizationParameters] = None, graph_generation_params: Optional[golem.core.optimisers.optimizer.GraphGenerationParams] = None, graph_optimizer_params: Optional[golem.core.optimisers.optimizer.AlgorithmParameters] = None, **custom_optimizer_params)[source]

Bases: object

Base class of graph optimizer. It allows to find the optimal solution using specified metric (one or several). To implement the specific optimisation method, the abstract method ‘optimize’ should be re-defined in the ancestor class (e.g. PopulationalOptimizer, RandomSearchGraphOptimiser, etc).

Parameters
  • objective – objective for optimisation

  • initial_graphs – graphs which were initialized outside the optimizer

  • requirements – implementation-independent requirements for graph optimizer

  • graph_generation_params – parameters for new graph generation

  • graph_optimizer_params – parameters for specific implementation of graph optimizer

Additional custom params can be specified with custom_optimizer_params.

property objective: golem.core.optimisers.objective.objective.Objective

Returns Objective of this optimizer with information about metrics used.

property history: Optional[golem.core.optimisers.opt_history_objects.opt_history.OptHistory]

Returns optimization history

abstract optimise(objective: golem.core.optimisers.objective.objective.GraphFunction[golem.core.optimisers.objective.objective.G, golem.core.optimisers.fitness.fitness.Fitness]) Sequence[golem.core.dag.graph_delegate.GraphDelegate][source]

Method for running of optimization using specified algorithm. :param objective: objective function that specifies optimization target :return: sequence of the best graphs

set_iteration_callback(callback: Optional[Callable])[source]

Set optimisation callback that is called at the end of each iteration, with the next generation passed as argument. Resets the callback if None is passed.

set_evaluation_callback(callback: Optional[golem.core.optimisers.objective.objective.GraphFunction])[source]

Set or reset (with None) post-evaluation callback that’s called on each graph after its evaluation.