Brush C++ API
A flexible interpretable machine learning framework
Loading...
Searching...
No Matches
archive.h
Go to the documentation of this file.
1#ifndef ARCHIVE_H
2#define ARCHIVE_H
3
4#include "../ind/individual.h"
5
8
9namespace Brush{
10
11using namespace Sel;
12
13namespace Pop{
14
24template<ProgramType T>
25struct Archive
26{
27 vector<Individual<T>> individuals;
31
35 Archive();
36
41 void init(Population<T>& pop);
42
48 void update(Population<T>& pop, const Parameters& params);
49
58 void set_objectives(vector<string> objectives);
59
69 static bool sortComplexity(const Individual<T>& lhs, const Individual<T>& rhs);
70
71 static bool sortLinearComplexity(const Individual<T>& lhs, const Individual<T>& rhs);
72
82 static bool sortObj1(const Individual<T>& lhs, const Individual<T>& rhs);
83
93 static bool sameFitComplexity(const Individual<T>& lhs, const Individual<T>& rhs);
94
104 static bool sameObjectives(const Individual<T>& lhs, const Individual<T>& rhs);
105};
106
107//serialization
108NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Archive<PT::Regressor>, individuals, sort_complexity, linear_complexity);
109NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Archive<PT::BinaryClassifier>, individuals, sort_complexity, linear_complexity);
110NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Archive<PT::MulticlassClassifier>, individuals, sort_complexity, linear_complexity);
111NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Archive<PT::Representer>, individuals, sort_complexity, linear_complexity);
112
113} // Pop
114} // Brush
115
116#endif
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Archive< PT::Regressor >, individuals, sort_complexity, linear_complexity)
< nsga2 selection operator for getting the front
Definition bandit.cpp:4
The Archive struct represents a collection of individual programs.
Definition archive.h:26
static bool sortLinearComplexity(const Individual< T > &lhs, const Individual< T > &rhs)
Definition archive.cpp:31
void set_objectives(vector< string > objectives)
Sets the objectives for the archive.
Definition archive.cpp:10
void update(Population< T > &pop, const Parameters &params)
Updates the archive with individuals from a population.
Definition archive.cpp:125
vector< Individual< T > > individuals
individual programs in the archive
Definition archive.h:27
bool sort_complexity
whether to sort archive by complexity
Definition archive.h:28
NSGA2< T > selector
using NSGA2 in survival mode (nsga2 does not implement selection)
Definition archive.h:30
void init(Population< T > &pop)
Initializes the archive with individuals from a population.
Definition archive.cpp:77
static bool sameFitComplexity(const Individual< T > &lhs, const Individual< T > &rhs)
Checks if two individuals have the same fitness complexity.
Definition archive.cpp:54
static bool sortObj1(const Individual< T > &lhs, const Individual< T > &rhs)
Sorts the population by the first objective.
Definition archive.cpp:38
static bool sortComplexity(const Individual< T > &lhs, const Individual< T > &rhs)
Sorts the population in increasing complexity.
Definition archive.cpp:20
static bool sameObjectives(const Individual< T > &lhs, const Individual< T > &rhs)
Checks if two individuals have the same objectives.
Definition archive.cpp:70
bool linear_complexity
Indicates if the user set linear_complexity instead of recursive complexity.
Definition archive.h:29
Archive()
Default constructor for the Archive struct.
Definition archive.cpp:7