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;
30
34 Archive();
35
40 void init(Population<T>& pop);
41
47 void update(Population<T>& pop, const Parameters& params);
48
57 void set_objectives(vector<string> objectives);
58
68 static bool sortComplexity(const Individual<T>& lhs, const Individual<T>& rhs);
69
79 static bool sortObj1(const Individual<T>& lhs, const Individual<T>& rhs);
80
90 static bool sameFitComplexity(const Individual<T>& lhs, const Individual<T>& rhs);
91
101 static bool sameObjectives(const Individual<T>& lhs, const Individual<T>& rhs);
102};
103
104//serialization
109
110} // Pop
111} // Brush
112
113#endif
void bind_engine(py::module &m, string name)
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Archive< PT::Regressor >, individuals, sort_complexity)
< nsga2 selection operator for getting the front
Definition data.cpp:12
The Archive struct represents a collection of individual programs.
Definition archive.h:26
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:108
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:29
void init(Population< T > &pop)
Initializes the archive with individuals from a population.
Definition archive.cpp:64
static bool sameFitComplexity(const Individual< T > &lhs, const Individual< T > &rhs)
Checks if two individuals have the same fitness complexity.
Definition archive.cpp:45
static bool sortObj1(const Individual< T > &lhs, const Individual< T > &rhs)
Sorts the population by the first objective.
Definition archive.cpp:29
static bool sortComplexity(const Individual< T > &lhs, const Individual< T > &rhs)
Sorts the population in increasing complexity.
Definition archive.cpp:17
static bool sameObjectives(const Individual< T > &lhs, const Individual< T > &rhs)
Checks if two individuals have the same objectives.
Definition archive.cpp:56
Archive()
Default constructor for the Archive struct.
Definition archive.cpp:7