matchbin_regulators.hpp

Regulator structs that can be plugged into MatchBin.

template<typename set_t_, typename adj_t_, typename view_t_>
struct RegulatorBase
#include <matchbin_regulators.hpp>

Abstract base class for regulators.

Public Types

using set_t = set_t_
using adj_t = adj_t_
using view_t = view_t_

Public Functions

inline virtual ~RegulatorBase()
virtual bool Set(const set_t &set) = 0
virtual bool Adj(const adj_t &adj) = 0
virtual bool Decay(const int steps) = 0
virtual const view_t &View() const = 0
virtual double operator()(double raw_score) const = 0
virtual std::string name() const = 0
struct NopRegulator : public RegulatorBase<double, double, double>
#include <matchbin_regulators.hpp>

This regulator does nothing! Useful for control experiments.

Public Functions

inline virtual double operator()(const double raw_score) const override

Apply regulation to a raw match score.

inline virtual bool Set(const double &set) override

No-op set. Return whether MatchBin should be updated (never).

inline virtual bool Adj(const double &amt) override

No-op adjustment. Return whether MatchBin should be updated (never).

inline virtual bool Decay(const int steps) override

No-op decay. Return whether MatchBin should be updated (never).

inline virtual const double &View() const override

Return a default value.

inline virtual std::string name() const override
inline bool operator!=(const NopRegulator &other) const

Public Static Attributes

static constexpr double state = 0.0
struct LegacyRegulator : public RegulatorBase<double, double, double>
#include <matchbin_regulators.hpp>

Don’t use this regulator. It’s here so tests don’t break.

Public Functions

inline LegacyRegulator()
inline virtual double operator()(const double raw_score) const override

Apply regulation to a raw match score.

inline virtual bool Set(const double &set) override

A value between zero and one upregulates the item, a value of exactly one is neutral, and a value greater than one downregulates the item.

inline virtual bool Adj(const double &amt) override

A negative value upregulates the item, a value of exactly zero is neutral and a postive value the item.

inline virtual bool Decay(const int steps) override

No-op decay. Return whether MatchBin should be updated (never).

inline virtual const double &View() const override

Return a double representing the state of the regulator.

inline virtual std::string name() const override
inline bool operator!=(const LegacyRegulator &other) const

Public Members

double state
template<typename Slope = std::ratio<1, 10>>
struct AdditiveCountdownRegulator : public RegulatorBase<double, double, double>
#include <matchbin_regulators.hpp>

Public Functions

inline AdditiveCountdownRegulator()
inline virtual double operator()(const double raw_score) const override

Apply regulation to a raw match score. Returns a value between 0.0 and 1.0

inline virtual bool Set(const double &set) override

A positive value downregulates the item, a value of zero is neutral, and a negative value upregulates the item.

inline virtual bool Adj(const double &amt) override

A negative value upregulates the item, a value of exactly zero is neutral and a postive value downregulates the item.

inline virtual bool Decay(const int steps) override

Timer decay. Return whether MatchBin should be updated

inline virtual const double &View() const override

Return a double representing the state of the regulator.

inline virtual std::string name() const override
inline bool operator!=(const AdditiveCountdownRegulator &other) const

Public Members

double state
size_t timer

Public Static Attributes

static constexpr double slope = (static_cast<double>(Slope::num) / static_cast<double>(Slope::den))
template<typename Slope = std::ratio<1, 10>>
struct MultiplicativeCountdownRegulator : public RegulatorBase<double, double, double>
#include <matchbin_regulators.hpp>

Public Functions

inline MultiplicativeCountdownRegulator()
inline virtual double operator()(const double raw_score) const override

Apply regulation to a raw match score. Returns a value between 0 and 1.

inline virtual bool Set(const double &set) override

A positive value downregulates the item, a value of zero is neutral, and a negative value upregulates the item.

inline virtual bool Adj(const double &amt) override

A negative value upregulates the item, a value of exactly zero is neutral and a postive value downregulates the item.

inline virtual bool Decay(const int steps) override

Timer decay. Return whether MatchBin should be updated

inline virtual const double &View() const override

Return a double representing the state of the regulator.

inline virtual std::string name() const override
inline bool operator!=(const MultiplicativeCountdownRegulator &other) const

Public Members

double state
size_t timer

Public Static Attributes

static constexpr double slope = (static_cast<double>(Slope::num) / static_cast<double>(Slope::den))