Ultra 0.9.4
Loading...
Searching...
No Matches
ultra::src::basic_search< ES, E > Class Template Reference

#include <search.h>

Inheritance diagram for ultra::src::basic_search< ES, E >:
ultra::basic_search< ES, E >

Public Types

using individual_t = typename ultra::basic_search<ES, E>::individual_t
using fitness_t = typename ultra::basic_search<ES, E>::fitness_t

Public Member Functions

 basic_search (problem &, metric_flags=metric_flags::accuracy)
auto predictor (const individual_t &) const
bool is_valid () const override

Protected Member Functions

model_measurements< fitness_t > calculate_metrics (const individual_t &) const override
void tune_parameters () override

Friends

template<Individual>
class search

Additional Inherited Members

Detailed Description

template<template< class > class ES, Evaluator E>
class ultra::src::basic_search< ES, E >

Drives the search for solutions of symbolic regression / classification tasks.

Constructor & Destructor Documentation

◆ basic_search()

template<template< class > class ES, Evaluator E>
basic_search::basic_search ( problem & p,
metric_flags m = metric_flags::accuracy )
explicit

Builds a new search class, user chooses the evaluator.

Parameters
[in]pthe problem we're working on. The lifetime of p must exceed the lifetime of this class
[in]ma bit field used to specify metrics we have to calculate while searching

Member Function Documentation

◆ calculate_metrics()

template<template< class > class ES, Evaluator E>
model_measurements< typename basic_search< ES, E >::fitness_t > basic_search::calculate_metrics ( const individual_t & prg) const
nodiscardoverrideprotectedvirtual

Calculates various performance metrics.

Parameters
[in]prgbest individual from the evolution run just finished
Returns
measurements about the individual

Fitness and accuracy are calculated by default. Additional metrics must be explicitly requested in the basic_search constructor.

Warning
Can be very time consuming.

Reimplemented from ultra::basic_search< ES, E >.

◆ is_valid()

template<template< class > class ES, Evaluator E>
bool ultra::src::basic_search< ES, E >::is_valid ( ) const
nodiscardoverridevirtual
Returns
true if the object passes the internal consistency check

Reimplemented from ultra::basic_search< ES, E >.

◆ predictor()

template<template< class > class ES, Evaluator E>
auto basic_search::predictor ( const individual_t & ind) const
nodiscard

Creates a predictor associated with a given individual.

Parameters
[in]indindividual used as building block for the predictor
Returns
the evaluator-specific predictor, or no_predictor if the active evaluator does not provide one

The returned object depends on the evaluator used during training:

  • if the evaluator exposes a predictor() method, its result is forwarded;
  • otherwise, a no_predictor sentinel is returned.

This function is always well-formed: lack of predictor support is handled at compile time via the no_predictor fallback rather than via runtime errors.

◆ tune_parameters()

template<template< class > class ES, Evaluator E>
void ultra::src::basic_search< ES, E >::tune_parameters ( )
overrideprotectedvirtual

Tries to tune search parameters for the current problem.

Parameter tuning is a typical approach to algorithm design. Such tuning is done by experimenting with different values and selecting the ones that give the best results on the test problems at hand.

However, the number of possible parameters and their different values means that this is a very complex and time-consuming task; it is something we do not want users to worry about (power users can force many parameters, but our idea is "simple by default").

So if user sets an environment parameter he will force the search class to use it as is. Otherwise this function will try to guess a good starting point and changes its hint after every run. The code is a mix of black magic, experience, common logic and randomness but it seems reasonable.

Note
It has been formally proven, in the No-Free-Lunch theorem, that it is impossible to tune a search algorithm such that it will have optimal settings for all possible problems, but parameters can be properly set for a given problem.
See also

Reimplemented from ultra::basic_search< ES, E >.


The documentation for this class was generated from the following files: