RxDock 0.1.0
A fast, versatile, and open-source program for docking ligands to proteins and nucleic acids
Loading...
Searching...
No Matches
GPPopulation.h
1/***********************************************************************
2 * The rDock program was developed from 1998 - 2006 by the software team
3 * at RiboTargets (subsequently Vernalis (R&D) Ltd).
4 * In 2006, the software was licensed to the University of York for
5 * maintenance and distribution.
6 * In 2012, Vernalis and the University of York agreed to release the
7 * program as Open Source software.
8 * This version is licensed under GNU-LGPL version 3.0 with support from
9 * the University of Barcelona.
10 * http://rdock.sourceforge.net/
11 ***********************************************************************/
12
13// Population class. Defines a population of CGP genomes that represent
14// functions.
15
16#ifndef _RBTGPPOPULATION_H_
17#define _RBTGPPOPULATION_H_
18
19#include "rxdock/Error.h"
20#include "rxdock/geneticprogram/GPFFGold.h"
21#include "rxdock/geneticprogram/GPFitnessFunction.h"
22#include "rxdock/geneticprogram/GPGenome.h"
23
24namespace rxdock {
25
26namespace geneticprogram {
27
29public:
30 static const std::string _CT;
32 // Constructors
34 GPPopulation(int, int, GPFitnessFunctionPtr, ReturnTypeArray &,
35 ReturnTypeArray &);
36 void SetTrainingSets(ReturnTypeArray &it, ReturnTypeArray sf) {
37 ittrain = it;
38 sfttrain = sf;
39 }
40
42 // Destructors
45 virtual ~GPPopulation();
46 void Initialise(double, bool);
47 void ScaleFitness();
48 void Eval(double, bool);
49 GPGenomePtr Select(std::string) const;
50
51 void SelectionUpdate(std::string);
52
53 void GAstep(std::string, double, double, double, double, double, bool);
54 void EPstep(std::string, double, double, double, double, double, bool);
55 GPGenomePtr Best() const;
56 std::ostream &Print(std::ostream &) const;
57 friend std::ostream &operator<<(std::ostream &, const GPPopulation &);
58 void Swap(SmartPtr<GPPopulation>, int);
59 void QSort(GPGenomeList &);
60 void QSort();
61 void MergePops();
62 static bool Gen_eq(GPGenome *, GPGenome *);
63 int GetSize();
64 int GetNrepl();
65
66private:
67 GPGenomePtr RwSelect() const;
68 GPGenomePtr RkSelect() const;
69 GPGenomePtr TSelect(double) const;
70 GPGenomeList pop; // population: array to pointers of GPGenomes
71 GPGenomeList newpop; // array where the new individuals created are stored
72 int popsize; // size of population
73 int nrepl; // Number of new individuals that get
74 // created at each generation
75 double total; // total addition of the score values
76 double ave; // average
77 double stdev; // standard deviation
78 double c; // Sigma Truncation Multiplier
79 double *psum; // stores the partial sums of the fitness values. Used
80 // when selecting individuals from the population
81 Rand &m_rand; // keep a reference to the singleton
82 // random number generator
83 int bestInd; // keeps the index of the best individual
85 ReturnTypeArray ittrain, sfttrain;
86};
88typedef std::vector<GPPopulationPtr> GPPopulationList;
89typedef GPPopulationList::iterator GPPopulationListIter;
90
91// Compare class to compare different populations. Use to find the
92// genome with best scoring function between all the populations
93class PopCmp {
94public:
95 bool operator()(const GPPopulationPtr &x, const GPPopulationPtr &y) const {
96 return (x->Best()->GetFitness() < y->Best()->GetFitness());
97 }
98};
99
100} // namespace geneticprogram
101
102} // namespace rxdock
103
104#endif //_GPPopulation_H_
Definition Rand.h:32
Definition GPGenome.h:27
Definition GPPopulation.h:28
Definition GPPopulation.h:93