#include <problem.h>
|
| | problem ()=default |
| | problem (dataframe, symbol_init=def_terminal_init) |
| | problem (const std::filesystem::path &, const dataframe::params &={}) |
| | problem (std::istream &, const dataframe::params &={}) |
| | problem (ultra::problem &&, dataframe) |
|
bool | classification () const noexcept |
| | Just a shorthand for checking number of classes.
|
| std::size_t | categories () const noexcept |
| std::size_t | classes () const noexcept |
| std::size_t | variables () const noexcept |
| std::expected< void, readiness_error > | ready () const |
| void | setup_symbols (symbol_init=symbol_init::all) |
| void | setup_terminals (symbol_init=def_terminal_init) |
| bool | is_valid () const override |
template<Symbol S, symbol_set::weight_t = symbol_set::default_weight, class ... Args>
requires std::constructible_from<S, Args...> |
| std::add_pointer_t< S > | insert (Args &&...) |
|
template<std::derived_from< function > F, symbol_set::weight_t W = symbol_set::default_weight, std::convertible_to< symbol::category_t > C = symbol::category_t> |
| std::add_pointer_t< F > | insert (symbol::category_t, std::initializer_list< C >) |
|
template<std::derived_from< function > F, symbol_set::weight_t W = symbol_set::default_weight, std::convertible_to< symbol::category_t > C = symbol::category_t> |
| std::add_pointer_t< F > | insert (std::initializer_list< C >) |
A specialization of the generic problem class for symbolic regression and classification problems.
- Examples
- sonar.cc, symbolic_regression.cc, symbolic_regression01.cc, and symbolic_regression02.cc.
◆ readiness_error
| Enumerator |
|---|
| invalid_problem | Internal consistency check failed.
|
| empty_training_set | No examples available for training.
|
| insufficient_terminals | Not enough terminals to build individuals.
|
| missing_functions | No functions available for evolution.
|
| missing_category_terminals | A used category has no terminals.
|
◆ problem() [1/5]
| ultra::src::problem::problem |
( |
| ) |
|
|
default |
New empty instance of src_problem.
- Warning
- The user must initialise:
- the training dataset;
- the complete symbol set (functions and terminals) before starting the evolution.
◆ problem() [2/5]
Initialises the problem with a dataset and a specified set of symbols
- Parameters
-
| [in] | d | input dataframe |
| [in] | init_flags | initialisation type (see symbol_init enum) |
By default, terminals directly derived from the data (variables / labels) are automatically inserted; any additional terminals (ephemeral random constants, problem-specific constants...) and functions must be inserted manually.
◆ problem() [3/5]
| ultra::src::problem::problem |
( |
const std::filesystem::path & | ds, |
|
|
const dataframe::params & | p = {} ) |
|
explicit |
Initialises the problem dataset with examples loaded from a file.
- Parameters
-
| [in] | ds | name of the dataset file (CSV or XRFF format) |
| [in] | p | additional optional parameters (see dataframe::params structure) |
- Warning
- Users must also specify the functions to be used.
◆ problem() [4/5]
Initialises the problem dataset with examples loaded from a file.
- Parameters
-
- Warning
- Users must also specify the functions to be used.
◆ problem() [5/5]
Constructs a src::problem from an existing base problem by transferring configuration and symbol set ownership.
- Parameters
-
| [in,out] | base | source problem to consume (moved-from on return) |
| [in] | d | training dataset for the new problem |
- Postcondition
- this->params and this->sset are taken from base
- base remains valid but its params/sset are in a moved-from state
- Warning
- This constructor does not prove semantic compatibility between d and the moved symbol set. The caller must ensure categories/domains are coherent.
◆ categories()
| std::size_t ultra::src::problem::categories |
( |
| ) |
const |
|
nodiscardnoexcept |
- Returns
- number of categories of the problem (>= 1)
◆ classes()
| std::size_t ultra::src::problem::classes |
( |
| ) |
const |
|
nodiscardnoexcept |
- Returns
- number of classes of the problem (== 0 for a symbolic regression problem, > 1 for a classification problem)
◆ is_valid()
| bool ultra::src::problem::is_valid |
( |
| ) |
const |
|
nodiscardoverridevirtual |
- Returns
- true if the object passes the internal consistency check
Reimplemented from ultra::problem.
◆ ready()
Checks whether the problem can be used to start an evolutionary run.
- Returns
- success if the problem is ready, otherwise the first detected reason it is not ready
A problem is considered ready when:
- a non-empty training dataset is available;
- the symbol set contains a sufficient number of terminals.
- the symbol set contains functions.
- each category used by the training data has at least one terminal.
◆ setup_symbols()
Automatically sets up the symbol set.
- Parameters
-
| [in] | init_flags | initialisation type (see symbol_init enum) |
A predefined set is created, which is useful for simple problems (e.g. single category regression or classification).
- Warning
- Data must be loaded before creating symbols, as without data it is impossible to determine, among other things, the dataset's features.
- Multi-category tasks are supported, but the result may be suboptimal.
- Examples
- sonar.cc.
◆ setup_terminals()
Initialises the terminal set according to a given initialisation type.
- Parameters
-
| [in] | init_flags | initialisation type (see symbol_init enum) |
- Exceptions
-
| `std::insufficient_data` | not enough data to generate a terminal set |
There is a variable for each feature. The names used for variables, if not specified in the dataset, are in the X1, ... Xn form.
◆ variables()
| std::size_t ultra::src::problem::variables |
( |
| ) |
const |
|
nodiscardnoexcept |
- Returns
- dimension of the input vectors (i.e. the number of variables in the problem)
The documentation for this class was generated from the following files: