Boost logo

Boost Users :

Subject: Re: [Boost-users] Mersenne twister problem
From: Matthias Troyer (troyer_at_[hidden])
Date: 2009-09-11 15:02:25


On 11 Sep 2009, at 11:19, ruya wrote:

>
> Hello
>
> I've built a meta-heuristics library in which I use the boost random
> library. I am using several independent generators through the
> application.
> The problem is in the core of my library. The tricky part is that I
> have
> three different algorithms using the core, all of them using the
> class where
> a segmentation fault happens, but only one of them crashes when it
> tries to
> use the class, the others run as expected. Gdb points to the boost
> library,
> as you can see in the snippet bellow. I couldn't find any
> information on
> this issue, and I cannot see something wrong with my code (the
> relevant part
> is bellow).
>
> The parent class where generators are declared:
>
> template< class SType, typename MemP >
> class SearchFunctor{
> (...)
> public:
>
> virtual SPtr operator()( SPtr s, int iter ) = 0;
>
> SearchFunctor(){
> (...)
> //This is how I initialize teh generators, being MASTER SEED 666
> generator1 = base_generator_type(MASTER_SEED*13);
> uni_dist1 = boost::uniform_real<>(0,1);
> uniEmp = new GeneratorI(generator1, uni_dist1);
> generator2 = base_generator_type(MASTER_SEED*17);
> uni_dist2 = boost::uniform_real<>(0,1);
> uniRes = new GeneratorI(generator2, uni_dist2);
> }
> protected:
> base_generator_type generator1, generator2;
> boost::uniform_real<> uni_dist1, uni_dist2;
> GeneratorI* uniEmp;
> GeneratorI* uniRes;
> };

I would write this very differently, and can give you a better version
that should have no problems, but could you please send me the
definition of GeneratorI first?

Matthias


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net