[gecode-users] How to set an arbitrary RandomGenerator for randomized branching?!?

Martin Mann mmann at informatik.uni-freiburg.de
Sat May 16 00:37:15 CEST 2009


Hi everybody,

I digged a bit into the Gecode source about the randomized branching 
supported since version 3.

In line 124 in gecode/support/random.hpp I found the definition of 
RandomGenerator internally used in the view selection:

http://www.gecode.org/doc-latest/reference/group__FuncSupport.html#g02fe942f90a57a25639f09960dab4459

As given there, it is just a typedef onto the 
LinearCongruentialGenerator provided by Gecode but I would like to set 
up my own random number generator...

Is there a possibility to support user defined generators? e.g. in 
coming versions?

If not available right now, maybe you like the following suggestion:

A possibility would be a super class 'RNG' that has to be implemented by 
every generator plus a kind of factory class 'RNF' with static members only.
The RNF would be a wrapper around the current RNG instance to use 
(stored in a static internal member). Thus, all Gecode internals that 
need a random number use a static interface of RNF instead of some RNG 
instance members. So the library gets independent of the concrete RNG 
used and you get the possibility to register a user defined RNG within 
the RNF. Per default the RNF can use the linear congruential generator 
provided. The static interface and data member would avoid annoying 
copies of RNGs all around and won't complicate your Gecode internals/source.


Just a suggestion... if it is already possible just ignore and please 
let me know how to do with the current Gecode version. :)


Have a nice weekend,

Martin





More information about the gecode-users mailing list