SettingCombos.hpp
A tool for exploring all parameter combinations.
Note
Status: ALPHA
-
class SettingCombos
- #include <SettingCombos.hpp>
Class to take a set of value for each “setting” and then step through all combinations of those values for a factorial analysis.
Public Functions
-
SettingCombos() = default
-
inline ~SettingCombos()
-
inline size_t GetComboID() const
-
inline void Reset()
Start over stepping through all combinations of parameter values.
-
template<typename T>
inline const T &GetValue(const std::string &name) const Get the current value of a specified setting.
-
template<typename T>
inline T MaxValue(const std::string &name) const Scan through all values and return the maximum.
-
template<typename T>
inline vector<T> &AddSetting(const std::string &name, const std::string &desc = "", const char option_flag = '\0') Add a new setting of a specified type. Returns the (initially empty) vector of values to allow easy setting. Example: combos.AddSetting(“pop_size”) = {100,200,400,800};
-
template<typename T>
inline vector<T> &AddSetting(const std::string &name, const std::string &desc, const char option_flag, T &var, const std::string &args_label = "Values...", size_t cap = (size_t)-1) A setting can also be linked to a value that is kept up-to-date.
-
template<typename T>
inline vector<T> &AddSingleSetting(const std::string &name, const std::string &desc, const char option_flag, T &var, const std::string &args_label = "Value") A SingleSetting must have exactly one value, not multiple.
-
inline void AddAction(const std::string &name, const std::string &desc, const char flag, std::function<void()> fun)
-
template<typename T>
inline vector<T> &Values(const std::string &name) Access ALL values for a specified setting, to be modified freely.
-
template<typename T>
inline void AddValue(const std::string &name, T &&val) Add a single new value to the specified setting.
-
template<typename T1, typename ...Ts>
inline void SetValues(const std::string &name, T1 &&val1, Ts&&... vals) Set all values for the specified setting.
-
inline size_t CountCombos()
Determine how many unique combinations there currently are.
-
inline bool Next()
Set the next combination of settings to be active. Return true if successful or false if we ran through all combinations and reset.
-
inline std::string GetHeaders(const std::string &separator = ",", bool include_fixed = false)
Get the set of headers used for the CSV file. By default, don’t include settings capped at one value.
-
inline std::string CurString(const std::string &separator = ",", bool include_fixed = false) const
Convert all of the current values into a comma-separated string.
-
inline size_t FindOptionMatch(const std::string &option_name)
Scan through all settings for a match option and return ID.
-
inline size_t FindFlagMatch(const char symbol)
Scan through all settings for a match option and return ID.
Private Members
-
vector<Ptr<SettingBase>> settings
Order to be varied.
-
std::map<std::string, Ptr<SettingBase>> setting_map
Settings by name.
-
std::map<std::string, ActionFlag> action_map
Available flags.
-
size_t combo_id = 0
Unique value indicating which combination we are on.
-
struct ActionFlag
A setting that is just a flag with an action function to run if it’s called.
-
struct SettingBase
Base class to describe information about a single setting.
Public Functions
-
inline SettingBase(const std::string &_name, const std::string &_desc, const char _flag, const std::string &_args_label, const size_t _cap)
-
inline virtual ~SettingBase()
-
virtual size_t GetSize() const = 0
How many values are available?
-
virtual void SetValueID(size_t) = 0
Setup cur value in linked variable.
-
virtual bool OK() const = 0
Any problems with this setting?
-
inline bool IsFlagMatch(const char test_flag) const
-
inline SettingBase(const std::string &_name, const std::string &_desc, const char _flag, const std::string &_args_label, const size_t _cap)
-
template<typename T>
struct SettingInfo : public SettingCombos::SettingBase Full details about a single setting, including type information and values.
-
SettingCombos() = default