|
ppforest2 v0.1.0
Projection Pursuit Decision Trees and Random Forests
|
#include "utils/Invariant.hpp"#include "utils/Types.hpp"#include <map>#include <memory>#include <optional>#include <set>#include <stdexcept>#include <string>#include <nlohmann/json.hpp>Go to the source code of this file.
Classes | |
| class | Strategy< Derived > |
| CRTP base class providing self-registration for strategy types. More... | |
Namespaces | |
| namespace | ppforest2 |
| Binarization strategies for multiclass-to-binary reduction. | |
| namespace | ppforest2::strategies |
Macros | |
| #define | PPFOREST2_REGISTER_PRIMARY_PARAM(strategy_name, param_name) |
| Declare the strategy's CLI positional-shorthand parameter. | |
| #define | PPFOREST2_REGISTER_STRATEGY(StrategyBase, name) |
| Auto-registration macro for strategy factories. | |
Functions | |
| std::optional< std::string > | ppforest2::strategies::primary_param_for (std::string const &strategy) |
| Look up a strategy's primary shorthand parameter by name. | |
| std::map< std::string, std::string > & | ppforest2::strategies::primary_params_registry () |
Cross-family registry for strategies that accept a CLI positional-shorthand value (e.g. min_size:5 instead of min_size:min_size=5). | |
| bool | ppforest2::strategies::register_primary_param (std::string const &strategy, std::string const ¶m) |
| Register a strategy's primary (shorthand) parameter name. | |
| #define PPFOREST2_REGISTER_PRIMARY_PARAM | ( | strategy_name, | |
| param_name ) |
Declare the strategy's CLI positional-shorthand parameter.
Optional companion to PPFOREST2_REGISTER_STRATEGY. When present, users can write --flag <name>:<value> instead of --flag <name>:<primary_param>=<value> on the CLI.
Usage (after PPFOREST2_REGISTER_STRATEGY, inside the class body):
Takes the strategy name as the first argument (redundant with PPFOREST2_REGISTER_STRATEGY, but the macro can't see that one's arguments) and the shorthand-parameter name as the second.
Only numeric primary parameters are exercised by the parser today — see cli::strategy_string_to_json. String-valued primary params would conflict with bare identifiers (e.g. pda:lambda is a typo, not a value), so shorthand gates on the post-: token being numeric. If a future strategy needs a string primary param, the parser needs a matching update.
Placement matters: put this macro inside the class body next to PPFOREST2_REGISTER_STRATEGY, not in the .cpp. Both macros expand to inline static members whose initializers fire at C++ global- init time. Co-located in the same header, they pull in together: the force-link block in TrainingSpec.cpp keeps the strategy's .cpp.o alive, which transitively keeps the header's inline statics alive as a unit. Split them across .hpp / .cpp and aggressive dead-stripping could drop one but not the other — symptom is "shorthand doesn't work for this strategy" with no other signal.
| #define PPFOREST2_REGISTER_STRATEGY | ( | StrategyBase, | |
| name ) |
Auto-registration macro for strategy factories.
Registers ConcreteStrategy::from_json as the factory for name in the given StrategyBase class.
Usage (inside the concrete strategy class, after from_json):