include/BoltzmannSampler.hpp

Go to the documentation of this file.
00001 // BoltzmannSampler.hpp: this file is part of the REGAL project.
00002 //
00003 // REGAL : Random and Exhaustive Generators for Automata - Library
00004 //
00005 // Copyright (C) 2007 Julien DAVID.
00006 //
00007 // This program is free software; you can redistribute it and/or
00008 // modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2
00010 // of the License, or (at your option) any later version.
00011 //
00012 // The complete GNU General Public Licence Notice can be found as the
00013 // `COPYING' file in the root directory.
00014 //
00015 //
00016 #ifndef BOLTZMANNSAMPLER
00017 #define BOLTZMANNSAMPLER
00018 
00019 #include <cmath>
00020 #include<ctime>
00021 #include<cstdlib>
00022 #include "VerboseOption.hpp"
00023 #include "plaws/NonZeroPoissonLaw.hpp"
00024 
00025 
00026 #include <iostream>
00027 
00028 
00029 namespace regal{
00030   
00031   using namespace plaws;
00032 
00033   class BoltzmannSampler{
00034   private:
00035     DiscreteProbabilityLaw * nzpl;
00036     long double dzetaK; 
00037     double p;
00038     int * partition; 
00039     int setSize; 
00040     int subsetNumber; 
00041     long double meanSize; 
00042     int rejectCounter;
00043 
00044     
00045     void computeDzetaK(long double sum,long double z);
00046     
00047     
00048   public:
00049     int getRejectCounter(){return rejectCounter;}
00050     int * sample();
00051     
00057     BoltzmannSampler(const int & size=2,const int & subset=2){
00058       time_t t;
00059       partition=new int[subset];
00060       setSize=size;
00061       subsetNumber=subset;
00062       meanSize=size/(long double)subsetNumber;
00063       computeDzetaK(meanSize,-meanSize*expl(-(long double)meanSize));
00064       nzpl=new NonZeroPoissonLaw(dzetaK);
00065       srand(time(&t));
00066       verbose("Creation of a Boltzmann Sampler");
00067     }
00068     
00072     ~BoltzmannSampler(){
00073       delete [] partition;
00074       delete nzpl;
00075       verbose("Destruction of a Boltzmann Sampler");
00076     }
00077   };
00078   
00079 }
00080   
00081 #endif
00082   

Generated on Mon Sep 29 16:33:58 2008 for REGAL by  doxygen 1.5.1