PaGMO
1.1.5
|
Racing mechanism for a population. More...
#include <race_pop.h>
Public Types | |
enum | termination_condition { MAX_BUDGET, MAX_DATA_COUNT } |
Method to stop the race. More... | |
Public Member Functions | |
race_pop (const population &, unsigned int seed=0) | |
Constructor. More... | |
race_pop (unsigned int seed=0) | |
Constructor. More... | |
std::pair< std::vector< population::size_type >, unsigned int > | run (const population::size_type n_final, const unsigned int min_trials, const unsigned int max_count, double delta, const std::vector< population::size_type > &, termination_condition term_cond, const bool race_best, const bool screen_output) |
Races some individuals in a population. More... | |
population::size_type | size () const |
Get the number of individuals in the registered population. | |
void | reset_cache () |
Clear all the cache. | |
void | register_population (const population &) |
Update the population on which the race will run. More... | |
void | inherit_memory (const race_pop &) |
Inherits the memory of another race_pop object. More... | |
std::vector< fitness_vector > | get_mean_fitness (const std::vector< population::size_type > &active_set=std::vector< population::size_type >()) const |
Returns mean fitness of the individuals based on past evaluation data. More... | |
void | set_seed (unsigned int) |
Set a new racing seed. More... | |
Racing mechanism for a population.
This class implements the racing routines that can be invoked to race all or some of the individuals in a population.
It contains a caching mechanism which allows the reuse of previously evaluated fitness and constraint vectors, in case an identical individual is raced more than once, for example each time with different sets of other individuals. The caching mechanism ensures that all the data points that are compared during the race correspond to the same seed.
Currently the racing is implemented based on F-Race, which invokes Friedman test iteratively during each race.
Definition at line 60 of file race_pop.h.
Method to stop the race.
Enumerator | |
---|---|
MAX_BUDGET |
Fixed number of function evaluations. |
MAX_DATA_COUNT |
Fixed number of iterations. |
Definition at line 68 of file race_pop.h.
pagmo::util::racing::race_pop::race_pop | ( | const population & | pop, |
unsigned int | seed = 0 |
||
) |
Constructor.
Construct a race_pop object from an external population and a seed. The seed will determine all racing conditions.
[in] | pop | population containing the individuals to race |
[in] | seed | seed of the race |
Definition at line 18 of file race_pop.cpp.
pagmo::util::racing::race_pop::race_pop | ( | unsigned int | seed = 0 | ) |
Constructor.
Construct a race_pop object from a seed. The seed will determine all racing conditions. The exact population on which race will run can be (and must be) supplied later via register_population().
[in] | seed | seed of the race |
Definition at line 31 of file race_pop.cpp.
std::vector< fitness_vector > pagmo::util::racing::race_pop::get_mean_fitness | ( | const std::vector< population::size_type > & | ind_list = std::vector<population::size_type>() | ) | const |
Returns mean fitness of the individuals based on past evaluation data.
[in] | ind_list | The indices of the individuals whose mean fitness vectors are to be extracted. If this is empty, mean data of all the individuals will be returned. |
value_error | if any of the requested individuals has not been raced before. |
Definition at line 532 of file race_pop.cpp.
void pagmo::util::racing::race_pop::inherit_memory | ( | const race_pop & | src | ) |
Inherits the memory of another race_pop object.
If compatible, inherits past evaluation data from another race_pop object. Useful in scenarios when racing individuals in a cross generation setting.
Definition at line 653 of file race_pop.cpp.
void pagmo::util::racing::race_pop::register_population | ( | const population & | pop | ) |
Update the population on which the race will run.
This also re-allocate the spaces required to the cache entries.
[in] | pop | The new population |
Definition at line 41 of file race_pop.cpp.
std::pair< std::vector< population::size_type >, unsigned int > pagmo::util::racing::race_pop::run | ( | const population::size_type | n_final, |
const unsigned int | min_trials, | ||
const unsigned int | max_f_evals, | ||
double | delta, | ||
const std::vector< population::size_type > & | active_set, | ||
termination_condition | term_cond, | ||
const bool | race_best, | ||
const bool | screen_output | ||
) |
Races some individuals in a population.
Performs an F-Race among certain individuals in a population. F-Races are based on the Friedman test, thus a routine to determine the ranking of individuals w.r.t. any given rng seed is needed. Here, population::get_best_idx() is used extending the whole racing concept to multi-objective and constrained optimization.
Specifically, racing contains the following steps:
(1) Re-evaluate the active individuals with the newest random seed (2) Assign ranks to the active individuals and append to the observation data (3) Perform statistical test based on Friedman test (thus obtain pair-wise comparison result with statistical significance) (4) Update three individual index lists: decided, discarded, in_race
[in] | n_final | Desired number of winners. |
[in] | min_trials | Minimum number of trials to be executed before dropping individuals. |
[in] | max_f_evals | Maximum number of objective function evaluation before the race ends. |
[in] | delta | Confidence level for statistical testing. |
[in] | active_set | Indices of individuals that should participate in the race. If empty, race on the whole population. |
[in] | term_cond | Termination condition (MAX_BUDGET, MAX_DATA_COUNT) |
[in] | race_best | When true races for the best individuals |
[in] | screen_output | Whether to log racing status on the console output. |
type_error | if the underlying problem is not stochastic |
index_error | if active_set is invalid (out of bound / repeated indices) |
value_error | if other specified racing parameters are not sensible |
Definition at line 303 of file race_pop.cpp.
void pagmo::util::racing::race_pop::set_seed | ( | unsigned int | seed | ) |
Set a new racing seed.
Internally, the list of seed is cleared, all cache entry get invalidated, and a new list of seeds will of be generated as required when racing starts subsequently.
[in] | seed | New seed to be set |
Definition at line 695 of file race_pop.cpp.