Search code examples
prologeclipse-clp

Getting the seed set by the ECLiPSe on loading


I would like to get the seed that is used by ECLiPSe when it loads. I know how to set it via seed/1 but I do not know how to query it if I have not set it: i.e. how to retrieve the seed set by ECLiPSe.

I know this is a strange request, but since it affects reproducibility, I'd like to reproduce a good search result when I see one with no seed set, and not being able to do so is frustrating.

I understand it is probably a dangerous set of mind, but my problem is large and I trying to learn about its behaviour.

Many thanks.


Solution

  • ECLiPSe initialises the pseudo-random generator seed by mangling the current time with the process id. There is no interface for retrieving it.

    The easiest way for reproducible sequences is to always initialise the seed yourself, and log it together with your computation results. That new seed can of course be randomly generated itself, e.g. via random(MySeed),seed(MySeed).

    By the way, ECLiPSe 7.1 introduced some new features related to randomness, see random/2, frandom/1 and the random_mode flag.