trigger#

Classes#

Set#

class Set : public ioh::logger::Trigger#

Interface to combine several triggers in a single one.

By default, the Logger class manage combine several triggers with a logical “or” (see trigger::Any), but you may want to do differently, in which case you can inherit from this class to enjoy the triggers list management, and just do what you want with operator().

Subclassed by ioh::trigger::All, ioh::trigger::Any

Public Functions

inline Set()#

Empty constructor.

Warning

You should probably not use this one.

inline Set(logger::Triggers triggers)#

Constructor.

Parameters:

triggers – the managed triggers.

inline virtual void reset() override#

Propagate the reset event to all managed triggers.

inline void push_back(logger::Trigger &trigger)#

Add a trigger to the set.

inline void insert(logger::Trigger &trigger)#

Add a trigger to the set.

inline size_t size()#

Get the number of managed triggers.

inline logger::Triggers triggers() const#

Get a copy of the triggers.

Protected Attributes

logger::Triggers triggers_#

Managed triggers.

Each#

class Each : public ioh::logger::Trigger#

A trigger that fire at a regular interval.

Public Functions

inline Each(const size_t interval, const size_t starting_at = 0)#

Constructor.

Parameters:
  • interval – number of evaluations between two triggering events.

  • starting_at – minimum time at which to start triggering events.

inline size_t interval() const#

Accessor for _interval.

inline size_t starting_at() const#

Accessor for _starting_at.

inline virtual bool operator()(const logger::Info &log_info, const problem::MetaData&) override#

Main call interface.

Protected Attributes

const size_t _interval#

Period of time between triggers.

const size_t _starting_at#

Minimum time at which to allow triggering.

At#

class At : public ioh::logger::Trigger#

A trigger that fire only at specific number of evaluations.

Public Functions

inline At(const std::set<size_t> time_points)#

Constructor.

Parameters:

time_points – the set of evaluations for which to trigger an event.

inline std::set<size_t> time_points() const#

Return the time points when to log.

inline virtual bool operator()(const logger::Info &log_info, const problem::MetaData&) override#

Main call interface.

Protected Functions

inline bool matches(const size_t evals)#

Check if time is in the managed set.

Protected Attributes

const std::set<size_t> _time_points#

Set of times at which to trigger events.

During#

class During : public ioh::logger::Trigger#

A trigger that fire only when the number of evaluations is within certain range(s).

Note

Ranges are closed intervals: with [start,end], the trigger will fire for start and end. Ranges may overlap with each other.

Public Functions

inline During(std::set<std::pair<size_t, size_t>> time_ranges)#

Constructor.

Parameters:

time_ranges – the set of [min_evals,max_evals] during which events will be triggered.

inline std::set<std::pair<size_t, size_t>> time_ranges() const#

Accessor for _time_ranges.

inline virtual bool operator()(const logger::Info &log_info, const problem::MetaData&) override#

Main call interface.

Protected Functions

inline bool matches(const size_t evals)#

Check if a time is in one of the ranges.

Protected Attributes

const std::set<std::pair<size_t, size_t>> _time_ranges#

Time ranges during which events are triggered.

Structs#

Any#

struct Any : public ioh::trigger::Set#

Combine several triggers in a single one with a logical “or”.

Note

This is use as the default combination when you pass several triggers to a logger.

Public Functions

inline Any()#

Empty constructor.

Warning

You should probably not use this one.

inline Any(logger::Triggers triggers)#

Constructor.

Parameters:

triggers – the managed triggers.

inline virtual bool operator()(const logger::Info &log_info, const problem::MetaData &pb_info) override#

Triggered if ANY the managed triggers are triggered.

All#

struct All : public ioh::trigger::Set#

Combine several triggers in a single one with a logical “and”.

Public Functions

inline All()#

Empty constructor.

Warning

You should probably not use this one directly.

inline All(logger::Triggers triggers)#

Constructor.

Parameters:

triggers – the set of Trigger to manage.

inline virtual bool operator()(const logger::Info &log_info, const problem::MetaData &pb_info) override#

Triggered if ALL the managed triggers are triggered.

Always#

struct Always : public ioh::logger::Trigger#

A trigger that always returns true.

Public Functions

inline virtual bool operator()(const logger::Info&, const problem::MetaData&) override#
Returns:

true if a log event is to be triggered given the passed state.

OnImprovement#

struct OnImprovement : public ioh::logger::Trigger#

A trigger that react to a strict improvement of the best transformed value.

Public Functions

inline virtual bool operator()(const logger::Info &log_info, const problem::MetaData&) override#
Returns:

true if a log event is to be triggered given the passed state.

OnDeltaImprovement#

struct OnDeltaImprovement : public ioh::logger::Trigger#

Public Functions

inline OnDeltaImprovement(const double delta = 1e-10)#
inline OnDeltaImprovement(const double delta, const double best_so_far)#
inline virtual bool operator()(const logger::Info &log_info, const problem::MetaData &pb_info) override#
Returns:

true if a log event is to be triggered given the passed state.

inline virtual void reset() override#

Reset any internal state.

Useful if, for instance, the trigger maintain its own “best value so far” (

See also

logger::OnImprovement).

Note

This is called when the logger is attached to a new problem/run/etc.

Public Members

double delta#
double best_so_far#

OnViolation#

struct OnViolation : public ioh::logger::Trigger#

Trigger when there is constraint violation.

Public Functions

inline virtual bool operator()(const logger::Info &log_info, const problem::MetaData&) override#

Call interface.

inline virtual void reset() override#

Reset the violations counter.

Public Members

int violations = {}#

Track the number of violations.

Functions#

all#

inline All &ioh::trigger::all(logger::Triggers triggers)#

Do log if ALL the given triggers are fired.

any#

inline Any &ioh::trigger::any(logger::Triggers triggers)#

Do log if ANY of the given triggers is fired.

at#

inline At &ioh::trigger::at(const std::set<size_t> time_points)#

Do log at the given number of evaluations.

during#

inline During &ioh::trigger::during(const std::set<std::pair<size_t, size_t>> time_ranges)#

Do log if the number of evaluations falls in at least one of the given ranges.

Note

Ranges are closed intervals [start,end], the trigger will fire for start and end. Ranges may overlap with each other.

each#

inline Each &ioh::trigger::each(const size_t interval, const size_t starting_at = 0)#

Do log every given number of function evaluations.

Starts counting at zero by default.

Variables#

always#

Always ioh::trigger::always#

Do log at every call of the objective function.

on_improvement#

OnImprovement ioh::trigger::on_improvement#

Do log only if the transformed best objective function value found so far has strictly improved.

on_violation#

OnViolation ioh::trigger::on_violation#

Log when there are violations.