Tunable

class Tunable

A tunable parameter attempts to reach a target value of acceptance by modifying it by a percentage.

The parameter value is changed by the following formula:

value *= 1 + percent_change*(actual - target)

where actual is the average trial acceptance and target is the target trial acceptance. The relationship between the target and the parameter is assumed by the sign of percent_change. By default, the precent_change = 1, which leads to an inverse relationship between the parameter value and the trial acceptance. For example, a maximum displacement parameter with an actual acceptance of 32% and a target acceptance of 25% would be increased by 7% in an attempt to bring the acceptance down to the target value.

Arguments

Tunable(argtype args = argtype())

args:

  • tunable_param: initial value of the tunable parameter (default: 0.1).

  • tunable_target_acceptance: optionally set target acceptance (default: 0.25).

  • tunable_percent_change: optionally set the percent change (default: 1).

Public Functions

void set_min_and_max(const double min, const double max)

By default, the value is not bound. This function sets the minimum and maximum bounds.

double max() const

Return the above parameter.

double min() const

Return the above parameter.

void set_value(const double value)

Set the value, optionally subject to bounds.

double value() const

Return the value.

void disable()

Disable tuning.

void enable()

Enable tuning.

bool is_enabled() const

Return if enabled.

void set_percent_change(const double percent = 1)

A positive percent change indicates that the value of the parameter and the target have an inverse relationship. Thus, if the actual value is greater than the target, the value will be increased upon tuning.

void set_target(const double target = 0.25)

Set the target to reach for tuning.

void tune(const double actual)

Change the value to attempt to reach a point where the actual is equal to the target.

void serialize(std::ostream &ostr) const

Serialize.

Tunable(std::istream &istr)

Construct from serialization.