Line data Source code
1 : /*******************************************************************************
2 : * *
3 : * Cosmos:(C)oncept et (O)utils (S)tatistique pour les (Mo)deles *
4 : * (S)tochastiques *
5 : * *
6 : * Copyright (C) 2009-2012 LSV & LACL *
7 : * Authors: Paolo Ballarini BenoƮt Barbot & Hilal Djafri *
8 : * Website: http://www.lsv.ens-cachan.fr/Software/cosmos *
9 : * *
10 : * This program is free software; you can redistribute it and/or modify *
11 : * it under the terms of the GNU General Public License as published by *
12 : * the Free Software Foundation; either version 3 of the License, or *
13 : * (at your option) any later version. *
14 : * *
15 : * This program is distributed in the hope that it will be useful, *
16 : * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 : * GNU General Public License for more details. *
19 : * *
20 : * You should have received a copy of the GNU General Public License along *
21 : * with this program; if not, write to the Free Software Foundation, Inc., *
22 : * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
23 : * file timeGen.hpp created by Benoit Barbot on 25/01/12. *
24 : *******************************************************************************
25 : */
26 :
27 : #ifndef __Cosmos__File__
28 : #define __Cosmos__File__
29 :
30 : #include <iostream>
31 : #include <unordered_map>
32 : #include <random>
33 :
34 : #include "parameters.hpp"
35 : #include "DistributionDef.hpp"
36 : #include "Event.hpp"
37 :
38 :
39 : class VanDerCorputState{
40 : public:
41 : VanDerCorputState();
42 : void newTrajectory();
43 : double sample();
44 : void seed(unsigned long seed);
45 : private:
46 : unsigned long it;
47 : unsigned int baseId;
48 : };
49 :
50 : class KroneckerState {
51 : public:
52 : KroneckerState();
53 : void newTrajectory();
54 : double sample();
55 : void seed(unsigned long seed);
56 : private:
57 : double compute_gamma(unsigned long d);
58 : double phi_d;
59 :
60 : double seed_val;
61 : unsigned long it;
62 : unsigned int baseId;
63 : };
64 :
65 : double unif01ofint(unsigned long v);
66 :
67 26 : class timeGen {
68 : public:
69 :
70 : //! generate a time acording to the distribution d with parameters p
71 : double GenerateTime(DistributionType distribution,size_t trid, const std::array<double,PARAM_TBL_SIZE> ¶m, const CustomDistr&);
72 :
73 : /**
74 : * \brief Initialize the random number generator with the given seed
75 : * @param seed is an unsigned integer to be used as seed.
76 : */
77 : void initRandomGenerator(unsigned int seed);
78 : void reset();
79 :
80 : std::string string_of_dist(DistributionType d,const std::array<double,PARAM_TBL_SIZE> ¶m, const CustomDistr&)const;
81 :
82 : double current_weight=0.0;
83 : private:
84 :
85 : //!The random Generator Mersenne Twister from std librairy
86 : std::mt19937_64 RandomNumber;
87 : double sampleQuasiRandom(size_t);
88 : VanDerCorputState vanDerCorputSampler;
89 : KroneckerState kroneckerSampler;
90 : };
91 :
92 : //template<class DEDS>
93 : //void generateEvent(double ctime,Event& E,size_t Id,const abstractBinding& b,timeGen &,DEDS &);
94 :
95 : extern parameters P;
96 :
97 : #endif /* defined(__Cosmos__File__) */
|