Ultra 0.9.4
Loading...
Searching...
No Matches
ultra::test_evaluator< I > Class Template Reference

#include <evaluator.h>

Public Member Functions

 test_evaluator (test_evaluator_type=test_evaluator_type::random)
void delay (std::chrono::milliseconds) noexcept
double operator() (const I &) const

Detailed Description

template<Individual I>
class ultra::test_evaluator< I >

A configurable fitness evaluator intended for testing and debugging.

Template Parameters
Ian Individual type

test_evaluator provides several simple, deterministic or stochastic fitness strategies that are useful for:

  • validating the behaviour of evolutionary operators;
  • benchmarking infrastructure components (e.g. parallel evaluation, caching, scheduling);
  • debugging population dynamics without relying on a real problem domain.

The evaluator can optionally introduce a fixed delay for each evaluation, allowing simulation of expensive fitness computations.

Note
This evaluator is primarily intended for testing and debugging purposes. It makes no guarantees about fitness meaningfulness or collision resistance.
Remarks
The class is not thread-safe if delay is called concurrently with evaluation. Concurrent evaluation without modifying the delay is safe provided that the underlying random generator is thread-safe.

Constructor & Destructor Documentation

◆ test_evaluator()

template<Individual I>
test_evaluator::test_evaluator ( test_evaluator_type et = test_evaluator_type::random)
explicit

Constructs a test evaluator with the specified evaluation strategy.

Parameters
[in]etthe evaluation strategy to use

Member Function Documentation

◆ delay()

template<Individual I>
void test_evaluator::delay ( std::chrono::milliseconds ms)
noexcept

Adds a fixed delay to each evaluation.

Parameters
[in]msthe delay duration in applied to every evaluation

This is useful for simulating computationally expensive fitness functions when testing scheduling, parallelism, or caching behaviour.

◆ operator()()

template<Individual I>
double test_evaluator::operator() ( const I & prg) const
nodiscard

Evaluates the fitness of an individual.

Parameters
[in]prgthe individual whose fitness is to be computed
Returns
the fitness value

The returned value depends on the evaluator type selected at construction:

  • a fixed, time-invariant value for all individuals (fixed);
  • a random, time-variant value (random);
  • a deterministic value derived from the individual's signature (realistic);
  • the age of the individual (age).

If a delay has been configured via delay, the evaluation blocks for the specified duration before computing the fitness.


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