PaGMO  1.1.5
base_stochastic.cpp
1 /*****************************************************************************
2  * Copyright (C) 2004-2015 The PaGMO development team, *
3  * Advanced Concepts Team (ACT), European Space Agency (ESA) *
4  * *
5  * https://github.com/esa/pagmo *
6  * *
7  * act@esa.int *
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  * This program is distributed in the hope that it will be useful, *
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
17  * GNU General Public License for more details. *
18  * *
19  * You should have received a copy of the GNU General Public License *
20  * along with this program; if not, write to the *
21  * Free Software Foundation, Inc., *
22  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
23  *****************************************************************************/
24 
25 #include "base_stochastic.h"
26 #include "../serialization.h"
27 
28 namespace pagmo { namespace problem {
29 
30 
32 
39 base_stochastic::base_stochastic(int dim, unsigned int seed) : base(dim), m_drng(seed), m_urng(seed), m_seed(seed)
40 {
41 }
42 
44 
53 base_stochastic::base_stochastic(int n, int ni, int nf, int nc, int nic, const double &c_tol, unsigned int seed): base((int)n, ni, nf, nc, nic, c_tol), m_drng(seed), m_urng(seed), m_seed(seed)
54 {
55 }
56 
58 
67 base_stochastic::base_stochastic(int n, int ni, int nf, int nc, int nic, const std::vector<double> &c_tol, unsigned int seed): base((int)n, ni, nf, nc, nic, c_tol), m_drng(seed), m_urng(seed), m_seed(seed)
68 {
69 }
70 
72 
77 void base_stochastic::set_seed(unsigned int seed) const {
78  m_seed = seed;
79  // As the problem is now muted we must reset the caches that contain the evaluations w.r.t. the old seed
80  reset_caches();
81 }
82 
84 
89 unsigned int base_stochastic::get_seed() const {
90  return m_seed;
91 }
92 
93 }} //namespaces
94 
95 //BOOST_CLASS_EXPORT_IMPLEMENT(pagmo::problem::base_stochastic);
Root PaGMO namespace.
unsigned int get_seed() const
Gets the pseudo random generator seed.
Base problem class.
Definition: problem/base.h:148
unsigned int m_seed
Seed of the random number generator.
void set_seed(unsigned int) const
Sets the pseudo random generator seed.
void reset_caches() const
Reset internal caches.
base_stochastic(int, unsigned int=0u)
Constructor from global dimension and random seed.