Ultra 0.9.4
Loading...
Searching...
No Matches
ultra::src::aggregate_evaluator< P, F, D, A, M > Class Template Reference
Inheritance diagram for ultra::src::aggregate_evaluator< P, F, D, A, M >:
ultra::src::evaluator< D >

Public Member Functions

 aggregate_evaluator (D &) noexcept
bool set_parallel_evaluation (unsigned, std::size_t=0) noexcept
double operator() (const P &) const
double fast (const P &) const
auto predictor (const P &) const

Static Public Attributes

static constexpr std::ptrdiff_t fast_step = 5
Static Public Attributes inherited from ultra::src::evaluator< D >
static constexpr std::size_t default_min_samples_per_thread = 512

Additional Inherited Members

Protected Member Functions inherited from ultra::src::evaluator< D >
 evaluator (D &) noexcept
bool set_parallel_evaluation (unsigned, std::size_t=0) noexcept
const auto & data () const noexcept
std::size_t min_samples_per_thread () const noexcept
unsigned parallel_helpers () const noexcept

Constructor & Destructor Documentation

◆ aggregate_evaluator()

template<Individual P, class F, class D, aggregation_mode A, evaluation_mode M>
requires ExampleEvaluator<F, D, P>
aggregate_evaluator::aggregate_evaluator ( D & d)
explicitnoexcept

Constructs the evaluator.

Parameters
[in]dtraining dataset

Member Function Documentation

◆ fast()

template<Individual P, class F, class D, aggregation_mode A, evaluation_mode M>
requires ExampleEvaluator<F, D, P>
double aggregate_evaluator::fast ( const P & prg) const
nodiscard

Computes a (possibly approximate) fitness value using subsampling.

Parameters
[in]prgprogram to evaluate
Returns
fitness value (exact or approximate)

For sufficiently large datasets, the program is evaluated on a subset of the examples (one every step elements) to reduce computation time.

For smaller datasets, the full evaluation is performed, making this function equivalent to operator()().

For average-based evaluators, subsampling yields an estimate of the true average. For sum-based evaluators, the result is rescaled to remain comparable with operator()().

◆ operator()()

template<Individual P, class F, class D, aggregation_mode A, evaluation_mode M>
requires ExampleEvaluator<F, D, P>
double aggregate_evaluator::operator() ( const P & prg) const
nodiscard

Computes the fitness using all training examples.

Parameters
[in]prgprogram to evaluate
Returns
fitness value (greater is better)

◆ predictor()

template<Individual P, class F, class D, aggregation_mode A, evaluation_mode M>
requires internal::has_regression_predictor_v<F, P>
auto aggregate_evaluator::predictor ( const P & prg) const
nodiscard

Builds a regression predictor associated with a program.

Parameters
[in]prgprogram to transform into a predictor
Returns
predictor object associated with prg
Remarks
This member function is conditionally enabled only when the functor F used by the evaluator is known to support regression semantics (as indicated by has_regression_predictor<F, P>). It is not available for classification or generic score-based evaluators. Computes fitness from sampled examples.
Parameters
[in]prgprogram to evaluate
[in]stepsampling step (one example every step)
Returns
fitness value

Values from valid examples are averaged. Missing values incur a heuristic penalty based on the ratio of missing to valid examples. A partially valid program may still outrank a fully valid one. If all values are missing, the function returns std::numeric_limits<double>::lowest().

For opted-in functors and forward-range datasets with enough sampled examples, evaluation is divided into strips across the calling thread and configured helper threads. Each strip constructs its own example functor. Their means are combined by valid-example count before the missing-value penalty and sum scaling are applied. Parallel evaluation may change floating-point rounding. Sets up the environment for error measurement.

Parameters
[in]prgthe program to be measured

◆ set_parallel_evaluation()

template<Individual P, class F, class D, aggregation_mode A, evaluation_mode M>
requires parallel_safe_example_evaluator<F>
bool aggregate_evaluator::set_parallel_evaluation ( unsigned n,
std::size_t min_samples = 0 )
noexcept

Sets the number of helper threads and workload threshold for parallel evaluation.

Parameters
[in]nnumber of helper threads; zero disables parallel evaluation
[in]min_samplesminimum number of samples per thread; zero uses the default threshold
Returns
true after applying the configuration

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