Use references to pass arguments, to reduce memory allocations and copying around.
[PaGMO.git] / GOclasses / basic / population.h
blob888df5b747fa3b2eabe4a47bb26a6b6bd29752f2
1 /*
2 * population.h
3 * SeGMO, a Sequential Global Multiobjective Optimiser
5 * Created by Dario Izzo on 5/16/08.
6 * Copyright 2008 ¿dvanced Concepts Team (European Space Agency). All rights reserved.
8 */
10 #ifndef POPULATION_H
11 #define POPULATION_H
13 #include <vector>
15 #include "GOproblem.h"
16 #include "constants.h"
17 #include "individual.h"
18 #include "rng.h"
20 class Population{
21 public:
22 //Methods
23 // TODO: pass by reference here, why the copies?
24 void createRandomPopulation(const std::vector<double> &, const std::vector<double> &, int N, rng_double_type &);
25 void resetVelocities(const std::vector<double> &, const std::vector<double> &, rng_double_type &);
26 void evaluatePopulation(GOProblem &);
27 void addIndividual(const Individual &);
28 void substituteIndividual(const Individual &, int);
29 double evaluateMean() const;
30 double evaluateStd() const;
31 unsigned int size () const;
32 Individual extractBestIndividual() const;
33 Individual extractWorstIndividual() const;
34 Population extractRandomDeme(int, std::vector<int> &, rng_double_type &);
35 void insertDeme(const Population &, const std::vector<int> &);
36 void insertBestInDeme(const Population &, const std::vector<int> &);
37 void insertDemeForced(const Population &, const std::vector<int> &);
39 //Operators
40 Individual &operator[](int);
41 const Individual &operator[](int) const;
42 void operator=(const Population &newpop);
43 void operator=(const Individual &x);
45 //logging function
46 friend std::ostream& operator<<(std::ostream& s, Population& pop);
47 private:
48 std::vector<Individual> pop;
49 };//class Population
51 std::ostream& operator<<(std::ostream& s, Population& pop);
52 #endif