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;
};
The derived class using the generators:
template< class SType, typename MemP >
struct SwapSearch : public SearchFunctor