12 this->sort_complexity =
in(objectives, std::string(
"complexity"));
16template<ProgramType T>
25 return lhs.fitness.complexity <
rhs.fitness.complexity;
28template<ProgramType T>
44template<ProgramType T>
51 return (
lhs.fitness ==
rhs.fitness &&
52 lhs.fitness.complexity ==
rhs.fitness.complexity);
55template<ProgramType T>
59 return (
lhs.fitness ==
rhs.fitness);
63template<ProgramType T>
69 individuals.resize(0);
75 selector.fast_nds(pop,
indices);
91 if (
t.fitness.rank ==1){
96 individuals.push_back(
t);
100 if (this->sort_complexity)
101 std::sort(individuals.begin(),individuals.end(), &sortComplexity);
103 std::sort(individuals.begin(),individuals.end(), &sortObj1);
107template<ProgramType T>
110 individuals.resize(0);
117 vector<vector<int>>
front = selector.fast_nds(pop,
indices);
118 for (
const auto&
i :
front[0])
124 if (this->sort_complexity)
125 std::sort(individuals.begin(), individuals.end(), &sortComplexity);
127 std::sort(individuals.begin(), individuals.end(), &sortObj1);
130 auto it = std::unique(individuals.begin(),individuals.end(),
133 individuals.resize(std::distance(individuals.begin(),
it));
void bind_engine(py::module &m, string name)
vector< size_t > get_island_indexes(int island)
vector< std::shared_ptr< Individual< T > > > individuals
bool in(const V &v, const T &i)
check if element is in vector.
< nsga2 selection operator for getting the front
void set_objectives(vector< string > objectives)
Sets the objectives for the archive.
void update(Population< T > &pop, const Parameters ¶ms)
Updates the archive with individuals from a population.
void init(Population< T > &pop)
Initializes the archive with individuals from a population.
static bool sameFitComplexity(const Individual< T > &lhs, const Individual< T > &rhs)
Checks if two individuals have the same fitness complexity.
static bool sortObj1(const Individual< T > &lhs, const Individual< T > &rhs)
Sorts the population by the first objective.
static bool sortComplexity(const Individual< T > &lhs, const Individual< T > &rhs)
Sorts the population in increasing complexity.
static bool sameObjectives(const Individual< T > &lhs, const Individual< T > &rhs)
Checks if two individuals have the same objectives.
Archive()
Default constructor for the Archive struct.