Metrics#

namespace metrics#

Metrics that can be used to track certain attributes of GA throughout a run.

class MonitorBase#

#include <metrics/monitor_base.hpp>
class MonitorBase#

The base class used for the metrics.

Note

The Monitor class should be used as the base class of new metrics instead of directly inheriting from this class.

Subclassed by gapp::metrics::Monitor< NadirPoint, FitnessMatrix >, gapp::metrics::Monitor< Hypervolume, std::vector< double > >, gapp::metrics::Monitor< FitnessEvaluations, std::vector< size_t > >, gapp::metrics::Monitor< Derived, FitnessMatrix >, gapp::metrics::Monitor< AutoHypervolume, std::vector< double > >, gapp::metrics::Monitor< Derived, MetricData >

Public Functions

virtual void initialize(const GaInfo &ga) = 0#

Initialize the monitor. This method will be called exactly once at the start of a run.

Parameters:

ga – The GA that is being monitored.

virtual void update(const GaInfo &ga) = 0#

Update the metric data based on the current generation of the GA. This method will be called exactly once at the end of every generation.

Parameters:

ga – The GA that is being monitored.

virtual ~MonitorBase() = default#

Destructor.

class Monitor#

#include <metrics/monitor.hpp>
template<typename Derived, std::ranges::random_access_range MetricData>
class Monitor : public gapp::metrics::MonitorBase#

The base class used for all of the metrics. Metrics can be used to track certain attributes of the GAs in every generation throughout a run.

New metrics should be derived from this class, and they should implement the following methods:

  • initialize (optional) : Used to initialize the monitor at the start of a run.

  • update : Used to update the monitored attribute once every generation.

Note

The monitor doesn’t have access to any encoding specific information about a GA by default, so no such information can be tracked.

Template Parameters:
  • Derived – The type of the derived class.

  • MetricData – The type of the container used to store the monitored metrics (eg. std::vector).

Subclassed by gapp::metrics::FitnessMonitor< FitnessMin >, gapp::metrics::FitnessMonitor< FitnessVariance >, gapp::metrics::FitnessMonitor< FitnessStdDev >, gapp::metrics::FitnessMonitor< FitnessMean >, gapp::metrics::FitnessMonitor< FitnessMax >

Public Functions

inline constexpr auto operator[](size_t generation) const noexcept#
Returns:

The value of the tracked metric in the specified generation.

inline constexpr const MetricData &data() const noexcept#
Returns:

The data collected by the monitor throughout the run.

inline constexpr size_t size() const noexcept#
Returns:

The number of data points recorded. Equal to the number of generations the GA ran for.

inline constexpr auto begin() const noexcept#
Returns:

An iterator to the first element of the metric data.

inline constexpr auto end() const noexcept#
Returns:

An iterator to one past the last element of the metric data.

inline virtual void initialize(const GaInfo&) override#

Initialize the monitor. This method will be called exactly once at the start of a run.

Parameters:

ga – The GA that is being monitored.