forqs module reference
Forward simulation of Recombination, Quantitative traits, and Selection
 All Classes Groups Pages
PopulationConfigGenerator.hpp
1 //
2 // PopulationConfigGenerator.hpp
3 //
4 // Created by Darren Kessner with John Novembre
5 //
6 // Copyright (c) 2013 Regents of the University of California
7 // All rights reserved.
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are met:
11 //
12 // * Redistributions of source code must retain the above copyright notice,
13 // this list of conditions and the following disclaimer.
14 //
15 // * Redistributions in binary form must reproduce the above copyright notice,
16 // this list of conditions and the following disclaimer in the documentation
17 // and/or other materials provided with the distribution.
18 //
19 // * Neither UCLA nor the names of its contributors may be used to endorse or
20 // promote products derived from this software without specific prior
21 // written permission.
22 //
23 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
24 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
25 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
27 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
29 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
31 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 //
34 
35 
36 #ifndef _POPULATIONCONFIGGENERATOR_HPP_
37 #define _POPULATIONCONFIGGENERATOR_HPP_
38 
39 
40 #include "Configurable.hpp"
41 #include "Population.hpp"
42 #include "shared_ptr.hpp"
43 
44 
45 //
46 // PopulationConfigGenerator
47 //
48 
52 
53 
55 {
56  public:
57 
58  virtual size_t generation_count() const {return generation_count_;}
59  virtual size_t population_count() const {return population_count_;}
60  virtual unsigned int id_offset_step() const {return id_offset_step_;}
61  virtual size_t chromosome_pair_count() const {return chromosome_pair_count_;}
62  virtual const std::vector<unsigned int>& chromosome_lengths() const {return chromosome_lengths_;}
63 
64  virtual Population::Configs population_configs(size_t generation_index) const = 0;
65 
66  unsigned int min_unused_id() const;
67 
68  // Configurable interface: base implementation
69 
70  virtual std::string class_name() const;
71  virtual Parameters parameters() const;
72  virtual void configure(const Parameters& parameters, const Registry& registry);
73 
74  virtual ~PopulationConfigGenerator() {}
75 
76  protected:
77 
78  PopulationConfigGenerator(const std::string& id);
79 
80  size_t generation_count_;
81  size_t population_count_;
82  unsigned int id_offset_step_;
83  size_t chromosome_pair_count_;
84  std::vector<unsigned int> chromosome_lengths_;
85 };
86 
87 
88 typedef shared_ptr<PopulationConfigGenerator> PopulationConfigGeneratorPtr;
89 
90 
91 #endif // _POPULATIONCONFIGGENERATOR_HPP_
92