From OpenCog

Reproducibility makes a number of things easier, like hunting a bug or comparing performances before and after a change.

Random Generator

OpenCog relies on a random generator defined in the cogutil library. It has a singleton factory


that one should call to perform all randomization. For now it inherits


One can set its random seed as follows


Often, using the same random seed may be enough to reproduce the behavior.

This random generator also has scheme bindings, thus one can use it in his/her scheme code, set the seed, etc.

Set compile flag to enforce a more reproducible AtomSpace

You may directly uncomment the following line


in file


which will have effects such as indexing atoms by content instead of memory addresses.


Set the logger to work synchronously


Address Space Layout Randomization

If all the above still doesn't produce something deterministic you may try the following. Beware that this is somewhat dangerous. See the comment in the end.

One can ask the OS to assign memory addresses deterministically. In Linux the following command should work

    sudo sysctl -w kernel.randomize_va_space=0

WARNING: This should never be done on a server, and certainly not for very long on a client machine (your laptop, desktop, etc) since this opens up your machine to malicious code delivered from web pages, email attachments and the like. The risk is fairly low, if you are not surfing the web on the same machine.

Dealing with multithreading

Of course in order for the above to work well, memory allocation must also run deterministically. Multithreads can create such indeterminism, either directly, by for instance creating atoms in different orders, or indirectly by performing memory allocation on the same memory space. One can however minimize or in some cases eliminate these effects, see below.