Index: configure.ac
===================================================================
--- configure.ac	(revision 1f91f4d142b3890c0ea0c60d27ff628498b897f0)
+++ configure.ac	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
@@ -229,4 +229,5 @@
 	src/LinearAlgebra/unittests/Makefile
 	src/Parser/unittests/Makefile
+  src/RandomNumbers/unittests/Makefile
   src/Shapes/unittests/Makefile
 	src/UIElements/Menu/unittests/Makefile
Index: src/Actions/Makefile.am
===================================================================
--- src/Actions/Makefile.am	(revision 1f91f4d142b3890c0ea0c60d27ff628498b897f0)
+++ src/Actions/Makefile.am	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
@@ -14,4 +14,5 @@
   ${MOLECULEACTIONSOURCE} \
   ${PARSERACTIONSOURCE} \
+  ${RANDONNUMBERSSOURCE} \
   ${SELECTIONATOMACTIONSOURCE} \
   ${SELECTIONMOLECULEACTIONSOURCE} \
@@ -29,4 +30,5 @@
   ${MOLECULEACTIONHEADER} \
   ${PARSERACTIONHEADER} \
+  ${RANDONNUMBERSHEADER} \
   ${SELECTIONATOMACTIONHEADER} \
   ${SELECTIONMOLECULEACTIONHEADER} \
@@ -124,4 +126,12 @@
   MoleculeAction/SuspendInWaterAction.hpp \
   MoleculeAction/VerletIntegrationAction.hpp
+
+RANDONNUMBERSSOURCE =\
+	RandomNumbersAction/SetRandomNumbersDistributionAction.cpp \
+	RandomNumbersAction/SetRandomNumbersEngineAction.cpp
+
+RANDONNUMBERSHEADER =\
+	RandomNumbersAction/SetRandomNumbersDistributionAction.hpp \
+	RandomNumbersAction/SetRandomNumbersEngineAction.hpp
                  
 SELECTIONATOMACTIONSOURCE = \
Index: src/Actions/RandomNumbersAction/SetRandomNumbersDistributionAction.cpp
===================================================================
--- src/Actions/RandomNumbersAction/SetRandomNumbersDistributionAction.cpp	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
+++ src/Actions/RandomNumbersAction/SetRandomNumbersDistributionAction.cpp	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
@@ -0,0 +1,83 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * SetRandomNumbersDistribution.cpp
+ *
+ *  Created on: Jan 01, 2011
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "CodePatterns/Log.hpp"
+#include "molecule.hpp"
+#include "CodePatterns/Verbose.hpp"
+#include "World.hpp"
+
+#include "RandomNumbers/RandomNumberGeneratorFactory.hpp"
+
+#include <iostream>
+#include <fstream>
+#include <string>
+
+using namespace std;
+
+#include "SetRandomNumbersDistributionAction.hpp"
+
+// and construct the stuff
+#include "SetRandomNumbersDistributionAction.def"
+#include "Action_impl_pre.hpp"
+/** =========== define the function ====================== */
+Action::state_ptr CommandSetRandomNumbersDistributionAction::performCall() {
+  // obtain information
+  getParametersfromValueStorage();
+
+  CommandSetRandomNumbersDistributionState *state =
+      new CommandSetRandomNumbersDistributionState(
+          RandomNumberGeneratorFactory::getInstance().getDistribution(),
+          params);
+  RandomNumberGeneratorFactory::getInstance().setDistribution(params.distribution_type);
+
+  DoLog(0) && (Log() << Verbose(0) << "Distribution of random number generator is now: "
+      << RandomNumberGeneratorFactory::getInstance().getDistribution() << std::endl);
+
+  return Action::state_ptr(state);
+}
+
+Action::state_ptr CommandSetRandomNumbersDistributionAction::performUndo(Action::state_ptr _state) {
+  CommandSetRandomNumbersDistributionState *state = assert_cast<CommandSetRandomNumbersDistributionState*>(_state.get());
+
+  CommandSetRandomNumbersDistributionState *newstate =
+      new CommandSetRandomNumbersDistributionState(
+          RandomNumberGeneratorFactory::getInstance().getDistribution(),
+          state->params);
+  RandomNumberGeneratorFactory::getInstance().setDistribution(state->old_distribution_type);
+
+  DoLog(0) && (Log() << Verbose(0) << "Distribution of random number generator is undone to: "
+      << RandomNumberGeneratorFactory::getInstance().getDistribution() << std::endl);
+
+  return Action::state_ptr(newstate);
+}
+
+Action::state_ptr CommandSetRandomNumbersDistributionAction::performRedo(Action::state_ptr _state){
+  return performUndo(_state);
+}
+
+bool CommandSetRandomNumbersDistributionAction::canUndo() {
+  return true;
+}
+
+bool CommandSetRandomNumbersDistributionAction::shouldUndo() {
+  return true;
+}
+/** =========== end of function ====================== */
Index: src/Actions/RandomNumbersAction/SetRandomNumbersDistributionAction.def
===================================================================
--- src/Actions/RandomNumbersAction/SetRandomNumbersDistributionAction.def	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
+++ src/Actions/RandomNumbersAction/SetRandomNumbersDistributionAction.def	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
@@ -0,0 +1,33 @@
+/*
+ * SetRandomNumbersDistributionAction.def
+ *
+ *  Created on: Jan 01, 2011
+ *      Author: heber
+ */
+
+// all includes and forward declarations necessary for non-integral types below
+class MoleculeListClass;
+
+// i.e. there is an integer with variable name Z that can be found in
+// ValueStorage by the token "Z" -> first column: int, Z, "Z"
+// "undefine" if no parameters are required, use (NODEFAULT) for each (undefined) default value
+#define paramtypes (std::string)
+#define paramtokens ("set-random-number-distribution")
+#define paramdescriptions ("name of the distribution from boost::random")
+#undef paramdefaults
+#define paramreferences (distribution_type)
+
+#define statetypes (std::string)
+#define statereferences (old_distribution_type)
+
+// some defines for all the names, you may use ACTION, STATE and PARAMS
+#define CATEGORY Command
+#define MENUNAME "command"
+#define MENUPOSITION 1
+#define ACTIONNAME SetRandomNumbersDistribution
+#define TOKEN "set-random-number-distribution"
+
+
+// finally the information stored in the ActionTrait specialization
+#define DESCRIPTION "specify the  distribution to use henceforth"
+#undef SHORTFORM
Index: src/Actions/RandomNumbersAction/SetRandomNumbersDistributionAction.hpp
===================================================================
--- src/Actions/RandomNumbersAction/SetRandomNumbersDistributionAction.hpp	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
+++ src/Actions/RandomNumbersAction/SetRandomNumbersDistributionAction.hpp	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
@@ -0,0 +1,22 @@
+/*
+ * SetRandomNumbersDistributionAction.hpp
+ *
+ *  Created on: Jan 01, 2011
+ *      Author: heber
+ */
+
+#ifndef SETRANDOMNUMBERSDISTRIBUTIONACTION_HPP
+#define SETRANDOMNUMBERSDISTRIBUTIONACTION_HPP
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include "Actions/Action.hpp"
+
+#include "SetRandomNumbersDistributionAction.def"
+#include "Action_impl_header.hpp"
+
+#endif // SETRANDOMNUMBERSDISTRIBUTIONACTION_HPP
Index: src/Actions/RandomNumbersAction/SetRandomNumbersEngineAction.cpp
===================================================================
--- src/Actions/RandomNumbersAction/SetRandomNumbersEngineAction.cpp	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
+++ src/Actions/RandomNumbersAction/SetRandomNumbersEngineAction.cpp	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
@@ -0,0 +1,83 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * SetRandomNumbersEngine.cpp
+ *
+ *  Created on: Jan 01, 2011
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include "CodePatterns/Log.hpp"
+#include "molecule.hpp"
+#include "CodePatterns/Verbose.hpp"
+#include "World.hpp"
+
+#include "RandomNumbers/RandomNumberGeneratorFactory.hpp"
+
+#include <iostream>
+#include <fstream>
+#include <string>
+
+using namespace std;
+
+#include "SetRandomNumbersEngineAction.hpp"
+
+// and construct the stuff
+#include "SetRandomNumbersEngineAction.def"
+#include "Action_impl_pre.hpp"
+/** =========== define the function ====================== */
+Action::state_ptr CommandSetRandomNumbersEngineAction::performCall() {
+  // obtain information
+  getParametersfromValueStorage();
+
+  CommandSetRandomNumbersEngineState *state =
+      new CommandSetRandomNumbersEngineState(
+          RandomNumberGeneratorFactory::getInstance().getEngine(),
+          params);
+  RandomNumberGeneratorFactory::getInstance().setEngine(params.engine_type);
+
+  DoLog(0) && (Log() << Verbose(0) << "Engine of random number generator is now: "
+      << RandomNumberGeneratorFactory::getInstance().getEngine() << std::endl);
+
+  return Action::state_ptr(state);
+}
+
+Action::state_ptr CommandSetRandomNumbersEngineAction::performUndo(Action::state_ptr _state) {
+  CommandSetRandomNumbersEngineState *state = assert_cast<CommandSetRandomNumbersEngineState*>(_state.get());
+
+  CommandSetRandomNumbersEngineState *newstate =
+      new CommandSetRandomNumbersEngineState(
+          RandomNumberGeneratorFactory::getInstance().getEngine(),
+          state->params);
+  RandomNumberGeneratorFactory::getInstance().setEngine(state->old_engine_type);
+
+  DoLog(0) && (Log() << Verbose(0) << "Engine of random number generator is undone to: "
+      << RandomNumberGeneratorFactory::getInstance().getEngine() << std::endl);
+
+  return Action::state_ptr(newstate);
+}
+
+Action::state_ptr CommandSetRandomNumbersEngineAction::performRedo(Action::state_ptr _state){
+  return performUndo(_state);
+}
+
+bool CommandSetRandomNumbersEngineAction::canUndo() {
+  return true;
+}
+
+bool CommandSetRandomNumbersEngineAction::shouldUndo() {
+  return true;
+}
+/** =========== end of function ====================== */
Index: src/Actions/RandomNumbersAction/SetRandomNumbersEngineAction.def
===================================================================
--- src/Actions/RandomNumbersAction/SetRandomNumbersEngineAction.def	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
+++ src/Actions/RandomNumbersAction/SetRandomNumbersEngineAction.def	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
@@ -0,0 +1,33 @@
+/*
+ * SetRandomNumbersEngineAction.def
+ *
+ *  Created on: Jan 01, 2011
+ *      Author: heber
+ */
+
+// all includes and forward declarations necessary for non-integral types below
+class MoleculeListClass;
+
+// i.e. there is an integer with variable name Z that can be found in
+// ValueStorage by the token "Z" -> first column: int, Z, "Z"
+// "undefine" if no parameters are required, use (NODEFAULT) for each (undefined) default value
+#define paramtypes (std::string)
+#define paramtokens ("set-random-number-engine")
+#define paramdescriptions ("name of the pseudo-random engine from boost::random")
+#undef paramdefaults
+#define paramreferences (engine_type)
+
+#define statetypes (std::string)
+#define statereferences (old_engine_type)
+
+// some defines for all the names, you may use ACTION, STATE and PARAMS
+#define CATEGORY Command
+#define MENUNAME "command"
+#define MENUPOSITION 1
+#define ACTIONNAME SetRandomNumbersEngine
+#define TOKEN "set-random-number-engine"
+
+
+// finally the information stored in the ActionTrait specialization
+#define DESCRIPTION "specify the (pseudo)-random number engine to use henceforth"
+#undef SHORTFORM
Index: src/Actions/RandomNumbersAction/SetRandomNumbersEngineAction.hpp
===================================================================
--- src/Actions/RandomNumbersAction/SetRandomNumbersEngineAction.hpp	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
+++ src/Actions/RandomNumbersAction/SetRandomNumbersEngineAction.hpp	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
@@ -0,0 +1,22 @@
+/*
+ * SetRandomNumbersEngineAction.hpp
+ *
+ *  Created on: Jan 01, 2011
+ *      Author: heber
+ */
+
+#ifndef SETRANDOMNUMBERSENGINEACTION_HPP
+#define SETRANDOMNUMBERSENGINEACTION_HPP
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include "Actions/Action.hpp"
+
+#include "SetRandomNumbersEngineAction.def"
+#include "Action_impl_header.hpp"
+
+#endif // SETRANDOMNUMBERSENGINEACTION_HPP
Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision 1f91f4d142b3890c0ea0c60d27ff628498b897f0)
+++ src/Makefile.am	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
@@ -121,4 +121,13 @@
   Descriptors/MoleculePtrDescriptor_impl.hpp \
   Descriptors/MoleculeSelectionDescriptor_impl.hpp
+
+RANDOMSOURCE = \
+	RandomNumbers/RandomNumberGeneratorFactory.cpp
+
+RANDOMHEADER = \
+	RandomNumbers/RandomNumberGenerator.hpp \
+	RandomNumbers/TemplatePowerSetGenerator.hpp \
+	RandomNumbers/RandomNumberGenerator_Encapsulation.hpp \
+	RandomNumbers/RandomNumberGeneratorFactory.hpp
   
 THERMOSTATSOURCE = \
@@ -166,7 +175,6 @@
   ${ACTIONSSOURCE} \
   ${ATOMSOURCE} \
-  ${PATTERNSOURCE} \
-  ${SHAPESOURCE} \
   ${DESCRIPTORSOURCE} \
+  ${RANDOMSOURCE} \
   ${THERMOSTATSOURCE} \
   ${TESSELATIONSOURCE} \
@@ -203,8 +211,7 @@
   ${ACTIONSHEADER} \
   ${ATOMHEADER} \
-  ${PATTERNHEADER} \
-  ${SHAPEHEADER} \
   ${DESCRIPTORHEADER} \
   ${DESCRIPTORIMPLHEADER} \
+  ${RANDOMSOURCE} \
   ${THERMOSTATHEADER} \
   ${TESSELATIONHEADER} \
Index: src/RandomNumbers/RandomNumberDistribution.hpp
===================================================================
--- src/RandomNumbers/RandomNumberDistribution.hpp	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
+++ src/RandomNumbers/RandomNumberDistribution.hpp	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
@@ -0,0 +1,36 @@
+/*
+ * RandomNumberDistribution.hpp
+ *
+ *  Created on: Jan 01, 2011
+ *      Author: heber
+ */
+
+#ifndef RANDOMNUMBERDISTRIBUTION_HPP_
+#define RANDOMNUMBERDISTRIBUTION_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+/** Abstract base class for a random number distribution.
+ *
+ *  This class represents the interface to the random number distribution.
+ *  Hence, they all can be accessed the same way.
+ *
+ * It is also the base class that is needed for RandomNumberGeneratorFactory.
+ */
+class RandomNumberDistribution
+{
+public:
+  /** Getter for the type name of the internal distribution.
+   *
+   */
+  virtual std::string name()=0;
+
+  RandomNumberDistribution() {};
+  virtual ~RandomNumberDistribution() {};
+
+};
+
+#endif /* RANDOMNUMBERDISTRIBUTION_HPP_ */
Index: src/RandomNumbers/RandomNumberDistribution_Encapsulation.hpp
===================================================================
--- src/RandomNumbers/RandomNumberDistribution_Encapsulation.hpp	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
+++ src/RandomNumbers/RandomNumberDistribution_Encapsulation.hpp	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
@@ -0,0 +1,90 @@
+/*
+ * RandomNumberDistribution_Encapsulation.hpp
+ *
+ *  Created on: Jan 01, 2011
+ *      Author: heber
+ */
+
+#ifndef RANDOMNUMBERDISTRIBUTION_ENCAPSULATION_HPP_
+#define RANDOMNUMBERDISTRIBUTION_ENCAPSULATION_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <typeinfo>
+
+#include "RandomNumberDistribution.hpp"
+#include "RandomNumberGeneratorFactory.hpp"
+
+#include <boost/nondet_random.hpp>
+#include <boost/random.hpp>
+#include <boost/random/bernoulli_distribution.hpp>
+#include <boost/random/binomial_distribution.hpp>
+#include <boost/random/cauchy_distribution.hpp>
+#include <boost/random/exponential_distribution.hpp>
+#include <boost/random/gamma_distribution.hpp>
+#include <boost/random/geometric_distribution.hpp>
+#include <boost/random/linear_congruential.hpp>
+#include <boost/random/lognormal_distribution.hpp>
+#include <boost/random/normal_distribution.hpp>
+#include <boost/random/poisson_distribution.hpp>
+#include <boost/random/triangle_distribution.hpp>
+#include <boost/random/uniform_01.hpp>
+#include <boost/random/uniform_int.hpp>
+#include <boost/random/uniform_on_sphere.hpp>
+#include <boost/random/uniform_real.hpp>
+#include <boost/random/uniform_smallint.hpp>
+
+#include "unittests/RandomNumberGeneratorFactoryUnitTest.hpp"
+
+/** Template class that encapsulates the random number distributions from
+ *  random::boost.
+ *
+ *
+ * We need one template parameters:
+ * -# the distribution - generates uniform random numbers
+ */
+template <class distribution>
+class RandomNumberDistribution_Encapsulation : public RandomNumberDistribution
+{
+  /**
+   * Factory is friend such that it can access private cstor.
+   */
+  friend class RandomNumberGeneratorFactory;
+  friend class RandomNumberGeneratorFactoryTest;
+
+public:
+
+  /** Getter for the type name of the internal distribution.
+   *
+   */
+  std::string name() {
+    return typeid(distribution_type).name();
+  }
+
+  /** Getter for the distribution instance.
+   *
+   * @return reference to instance
+   */
+  distribution& getDistribution() {
+    return distribution_type;
+  }
+
+  /** Constructor that instantiates a specific random number generator and
+   * distribution.
+   * @param _distribution_type instance of the desired distribution
+   */
+  RandomNumberDistribution_Encapsulation()
+  {}
+
+  /** Destructor of the class.
+   *
+   */
+  ~RandomNumberDistribution_Encapsulation() {}
+private:
+  distribution distribution_type;
+};
+
+#endif /* RANDOMNUMBERDISTRIBUTION_ENCAPSULATION_HPP_ */
Index: src/RandomNumbers/RandomNumberEngine.hpp
===================================================================
--- src/RandomNumbers/RandomNumberEngine.hpp	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
+++ src/RandomNumbers/RandomNumberEngine.hpp	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
@@ -0,0 +1,42 @@
+/*
+ * RandomNumberEngine.hpp
+ *
+ *  Created on: Jan 01, 2011
+ *      Author: heber
+ */
+
+#ifndef RANDOMNUMBERENGINE_HPP_
+#define RANDOMNUMBERENGINE_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+/** Abstract base class for a random number engine.
+ *
+ *  This class represents the interface to the random number engine.
+ *  Hence, they all can be accessed the same way.
+ *
+ * It is also the base class that is needed for RandomNumberGeneratorFactory.
+ */
+class RandomNumberEngine
+{
+public:
+  /** Set the generator's seed.
+   *
+   * @param _seed seed to set to
+   */
+  virtual void seed(unsigned int _seed)=0;
+
+  /** Getter for the type name of the internal engine.
+   *
+   */
+  virtual std::string name()=0;
+
+  RandomNumberEngine() {};
+  virtual ~RandomNumberEngine() {};
+
+};
+
+#endif /* RANDOMNUMBERENGINE_HPP_ */
Index: src/RandomNumbers/RandomNumberEngine_Encapsulation.hpp
===================================================================
--- src/RandomNumbers/RandomNumberEngine_Encapsulation.hpp	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
+++ src/RandomNumbers/RandomNumberEngine_Encapsulation.hpp	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
@@ -0,0 +1,93 @@
+/*
+ * RandomNumberEngine_Encapsulation.hpp
+ *
+ *  Created on: Jan 01, 2011
+ *      Author: heber
+ */
+
+#ifndef RANDOMNUMBERENGINE_ENCAPSULATION_HPP_
+#define RANDOMNUMBERENGINE_ENCAPSULATION_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <typeinfo>
+
+#include "RandomNumberEngine.hpp"
+#include "RandomNumberGeneratorFactory.hpp"
+
+#include <boost/nondet_random.hpp>
+#include <boost/random.hpp>
+#include <boost/random/additive_combine.hpp>
+#include <boost/random/discard_block.hpp>
+#include <boost/random/inversive_congruential.hpp>
+#include <boost/random/lagged_fibonacci.hpp>
+#include <boost/random/linear_congruential.hpp>
+#include <boost/random/linear_feedback_shift.hpp>
+#include <boost/random/mersenne_twister.hpp>
+#include <boost/random/random_number_generator.hpp>
+#include <boost/random/ranlux.hpp>
+#include <boost/random/shuffle_output.hpp>
+#include <boost/random/subtract_with_carry.hpp>
+#include <boost/random/xor_combine.hpp>
+
+#include "unittests/RandomNumberGeneratorFactoryUnitTest.hpp"
+
+/** Template class that encapsulates the random number engines from
+ *  random::boost.
+ *
+ *
+ * We need one template parameters:
+ * -# the engine - generates uniform random numbers
+ */
+template <class engine>
+class RandomNumberEngine_Encapsulation : public RandomNumberEngine
+{
+  /**
+   * Factory is friend such that it can access private cstor.
+   */
+  friend class RandomNumberGeneratorFactory;
+  friend class RandomNumberGeneratorFactoryTest;
+
+public:
+  /** Set the engine's seed.
+   *
+   * @param _seed seed to set to
+   */
+  void seed(unsigned int _seed) {
+    engine_type.seed(_seed);
+  }
+
+  /** Getter for the type name of the internal engine.
+   *
+   */
+  std::string name() {
+    return typeid(engine_type).name();
+  }
+
+  /** Getter for the engine instance.
+   *
+   * @return reference to instance
+   */
+  engine& getEngine() {
+    return engine_type;
+  }
+
+  /** Constructor that instantiates a specific random number generator and
+   * distribution.
+   * @param _engine_type instance of the desired engine
+   */
+  RandomNumberEngine_Encapsulation()
+  {}
+
+  /** Destructor of the class.
+   *
+   */
+  ~RandomNumberEngine_Encapsulation() {}
+private:
+  engine engine_type;
+};
+
+#endif /* RANDOMNUMBERENGINE_ENCAPSULATION_HPP_ */
Index: src/RandomNumbers/RandomNumberGenerator.cpp
===================================================================
--- src/RandomNumbers/RandomNumberGenerator.cpp	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
+++ src/RandomNumbers/RandomNumberGenerator.cpp	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
@@ -0,0 +1,20 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * RandomNumberGenerator.cpp
+ *
+ *  Created on: Dec 31, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
Index: src/RandomNumbers/RandomNumberGenerator.hpp
===================================================================
--- src/RandomNumbers/RandomNumberGenerator.hpp	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
+++ src/RandomNumbers/RandomNumberGenerator.hpp	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
@@ -0,0 +1,52 @@
+/*
+ * RandomNumberGenerator.hpp
+ *
+ *  Created on: Dec 31, 2010
+ *      Author: heber
+ */
+
+#ifndef RANDOMNUMBERGENERATOR_HPP_
+#define RANDOMNUMBERGENERATOR_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+/** Abstract base class for a random number generator.
+ *
+ *  This class represents the interface to the random number generators.
+ *  Hence, they all can be accessed the same way.
+ *
+ * It is also the base class that is needed for RandomNumberGeneratorFactory.
+ */
+class RandomNumberGenerator
+{
+public:
+  /** obtain a random number via generator and the specific distribution.
+   *
+   */
+  virtual double operator()() const =0;
+
+  /** Set the generator's seed.
+   *
+   * @param _seed seed to set to
+   */
+  virtual void seed(unsigned int _seed)=0;
+
+  /** Getter for the type name of the internal engine.
+   *
+   */
+  virtual std::string EngineName()=0;
+
+  /** Getter for the type name of the internal distribution.
+   *
+   */
+  virtual std::string DistributionName()=0;
+
+  RandomNumberGenerator() {};
+  virtual ~RandomNumberGenerator() {};
+
+};
+
+#endif /* RANDOMNUMBERGENERATOR_HPP_ */
Index: src/RandomNumbers/RandomNumberGeneratorFactory.cpp
===================================================================
--- src/RandomNumbers/RandomNumberGeneratorFactory.cpp	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
+++ src/RandomNumbers/RandomNumberGeneratorFactory.cpp	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
@@ -0,0 +1,220 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * RandomNumberGeneratorFactory.cpp
+ *
+ *  Created on: Dec 31, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/MemDebug.hpp"
+
+#include <utility>
+#include "CodePatterns/Singleton_impl.hpp"
+#include "CodePatterns/Assert.hpp"
+
+#include "TemplatePowerSetGenerator.hpp"
+
+#include "RandomNumberEngine_Encapsulation.hpp"
+#include "RandomNumberDistribution_Encapsulation.hpp"
+#include "RandomNumberGenerator_Encapsulation.hpp"
+
+#include <boost/preprocessor/facilities/empty.hpp>
+#include <boost/preprocessor/punctuation/paren.hpp>
+
+#include "RandomNumberGeneratorFactory.hpp"
+#include "RandomNumberGeneratorFactory.def"
+
+enum RandomNumberGeneratorFactory::Engine RandomNumberGeneratorFactory::engine = (enum RandomNumberGeneratorFactory::Engine) 0;
+enum RandomNumberGeneratorFactory::Distribution RandomNumberGeneratorFactory::distribution = (enum RandomNumberGeneratorFactory::Distribution) 0;
+RandomNumberGeneratorFactory::EngineMap RandomNumberGeneratorFactory::engines;
+RandomNumberGeneratorFactory::EngineNamesMap RandomNumberGeneratorFactory::engineNames;
+RandomNumberGeneratorFactory::DistributionMap RandomNumberGeneratorFactory::distributions;
+RandomNumberGeneratorFactory::DistributionNamesMap RandomNumberGeneratorFactory::distributionNames;
+RandomNumberGeneratorFactory::EngineTable RandomNumberGeneratorFactory::EnginePrototypeTable;
+RandomNumberGeneratorFactory::DistributionTable RandomNumberGeneratorFactory::DistributionPrototypeTable;
+RandomNumberGeneratorFactory::EngineDistributionTable RandomNumberGeneratorFactory::GeneratorPrototypeTable;
+
+
+RandomNumberGeneratorFactory::RandomNumberGeneratorFactory()
+{
+  // insert all known engines
+#define BOOST_PP_LOCAL_MACRO(n) seqitems_as_string_enum_map(~, n, engine_seq, engines)
+#define BOOST_PP_LOCAL_LIMITS  (0, BOOST_PP_SEQ_SIZE(engine_seq)-1 )
+#include BOOST_PP_LOCAL_ITERATE()
+#define BOOST_PP_LOCAL_MACRO(n) seqitems_as_string_enum_map(~, n, engine_seq_a, engines)
+#define BOOST_PP_LOCAL_LIMITS  (0, BOOST_PP_SEQ_SIZE(engine_seq_a)-1 )
+#include BOOST_PP_LOCAL_ITERATE()
+  for (EngineMap::const_iterator iter = engines.begin();
+      iter != engines.end();
+      ++iter) {
+    engineNames.insert(make_pair(iter->second, iter->first));
+  }
+
+	// insert all known distributions
+#define BOOST_PP_LOCAL_MACRO(n) seqitems_as_string_enum_map(~, n, distribution_seq, distributions)
+#define BOOST_PP_LOCAL_LIMITS  (0, BOOST_PP_SEQ_SIZE(distribution_seq)-1 )
+#include BOOST_PP_LOCAL_ITERATE()
+  for (DistributionMap::const_iterator iter = distributions.begin();
+      iter != distributions.end();
+      ++iter) {
+    distributionNames.insert(make_pair(iter->second, iter->first));
+  }
+
+	FillPrototypeTables();
+}
+
+/** Removes all pointers to instances from a table while free'ing memory.
+ *
+ * I.e. we assume class T to be a map of some key with its values pointers to
+ * some classes that have to be free'd.
+ *
+ * \param _PrototypeTable table to empty
+ */
+template <class T>
+void EmptyPrototypeTable(T &_PrototypeTable)
+{
+  for (typename T::iterator iter = _PrototypeTable.begin();
+      !_PrototypeTable.empty();
+      iter = _PrototypeTable.begin()) {
+    delete (iter->second);
+    _PrototypeTable.erase(iter);
+  }
+  _PrototypeTable.clear();
+}
+
+
+
+RandomNumberGeneratorFactory::~RandomNumberGeneratorFactory()
+{
+  // clear out factories map to allow boost::shared_ptr to do their work (i.e. to release mem)
+  // this is necessary as factories is a object
+  engines.clear();
+  engineNames.clear();
+  EmptyPrototypeTable<EngineTable> (EnginePrototypeTable);
+  distributions.clear();
+  distributionNames.clear();
+  EmptyPrototypeTable<DistributionTable> (DistributionPrototypeTable);
+  for (EngineDistributionTable::iterator iter = GeneratorPrototypeTable.begin();
+      !GeneratorPrototypeTable.empty();
+      iter = GeneratorPrototypeTable.begin()) {
+    EmptyPrototypeTable< std::map<enum Distribution,RandomNumberGenerator *> > (iter->second);
+    GeneratorPrototypeTable.erase(iter);
+  }
+  GeneratorPrototypeTable.clear();
+}
+
+void RandomNumberGeneratorFactory::FillPrototypeTables()
+{
+  // fill EnginePrototypeTable
+#define BOOST_PP_LOCAL_MACRO(n) seqitems_as_enum_key_map(~, n, engine_seq, EnginePrototypeTable, new RandomNumberEngine_Encapsulation, boost::, )
+#define BOOST_PP_LOCAL_LIMITS  (0, BOOST_PP_SEQ_SIZE(engine_seq)-1 )
+#include BOOST_PP_LOCAL_ITERATE()
+#define BOOST_PP_LOCAL_MACRO(n) seqitems_as_enum_key_map(~, n, engine_seq_a, EnginePrototypeTable, new RandomNumberEngine_Encapsulation, boost::, )
+#define BOOST_PP_LOCAL_LIMITS  (0, BOOST_PP_SEQ_SIZE(engine_seq_a)-1 )
+#include BOOST_PP_LOCAL_ITERATE()
+
+  // fill DistributionPrototypeTable
+#define BOOST_PP_LOCAL_MACRO(n) seqitems_as_enum_key_map(~, n, distribution_seq, DistributionPrototypeTable, new RandomNumberDistribution_Encapsulation, boost::, <>)
+#define BOOST_PP_LOCAL_LIMITS  (0, BOOST_PP_SEQ_SIZE(distribution_seq)-1 )
+#include BOOST_PP_LOCAL_ITERATE()
+
+  // fill GeneratorPrototypeTable
+#define DoubleElementSequenceElementizer(z,data,elem) ((data)(elem))
+
+#define seqseqiterate(z,n,seq) BOOST_PP_SEQ_FOR_EACH(DoubleElementSequenceElementizer, BOOST_PP_SEQ_ELEM(n,seq), distribution_seq)
+
+#define distributionengine_seqseq BOOST_PP_REPEAT( \
+  BOOST_PP_SEQ_SIZE(engine_seq), seqseqiterate, engine_seq )
+
+#define distributionengine_seqseq_a BOOST_PP_REPEAT( \
+  BOOST_PP_SEQ_SIZE(engine_seq_a), seqseqiterate, engine_seq_a )
+
+#define suffixseq ()(<>)
+#define tableseq (*EnginePrototypeTable)(*DistributionPrototypeTable)
+
+#define TableItemPrinter(z,n,sequence) \
+  BOOST_PP_COMMA_IF(n) \
+  boost:: \
+  BOOST_PP_SEQ_ELEM(n,sequence) \
+  BOOST_PP_SEQ_ELEM(n,suffixseq)
+
+#define ParamItemPrinter(z,n,sequence) \
+  BOOST_PP_COMMA_IF(n) \
+  BOOST_PP_SEQ_ELEM(n,tableseq) \
+  [ \
+  BOOST_PP_SEQ_ELEM(n,sequence) \
+  ]
+
+#define BOOST_PP_LOCAL_MACRO(n) seqitems_as_enum_key_multidimmap(~, n, distributionengine_seqseq, GeneratorPrototypeTable, new RandomNumberGenerator_Encapsulation, TableItemPrinter, ParamItemPrinter)
+#define BOOST_PP_LOCAL_LIMITS  (0, BOOST_PP_SEQ_SIZE(distributionengine_seqseq)-1 )
+#include BOOST_PP_LOCAL_ITERATE()
+
+#define BOOST_PP_LOCAL_MACRO(n) seqitems_as_enum_key_multidimmap(~, n, distributionengine_seqseq_a, GeneratorPrototypeTable, new RandomNumberGenerator_Encapsulation, TableItemPrinter, ParamItemPrinter)
+#define BOOST_PP_LOCAL_LIMITS  (0, BOOST_PP_SEQ_SIZE(distributionengine_seqseq_a)-1 )
+#include BOOST_PP_LOCAL_ITERATE()
+}
+
+RandomNumberGenerator& RandomNumberGeneratorFactory::makeRandomNumberGenerator() const
+{
+  // Instantiate and return (implicitly creates a copy of the stored prototype)
+  return *GeneratorPrototypeTable[engine][distribution];
+}
+
+RandomNumberGenerator& RandomNumberGeneratorFactory::makeRandomNumberGenerator(std::string engine_type, std::string distribution_type) const
+{
+  enum Engine eng_type;
+  enum Distribution dis_type;
+
+  // Instantiate and return (implicitly creates a copy of the stored prototype)
+  if (!engine_type.empty()) {
+    ASSERT(engines.count(engine_type) != 0,
+      "RandomNumberGeneratorFactory::makeRandomNumberGenerator() - Selected engine "+engine_type+"is not registered.");
+    eng_type = engines[engine_type];
+  } else
+    eng_type = engine;
+  if (!distribution_type.empty()) {
+    ASSERT(distributions.count(distribution_type) != 0,
+        "RandomNumberGeneratorFactory::makeRandomNumberGenerator() - Selected distribution "+distribution_type+"is not registered.");
+    dis_type = distributions[distribution_type];
+  } else
+    dis_type = distribution;
+  return *GeneratorPrototypeTable[ eng_type ][ dis_type ];
+}
+
+void RandomNumberGeneratorFactory::setEngine(std::string engine_type)
+{
+  ASSERT(engines.count(engine_type) != 0,"Selected engine "+engine_type+"is not registered.");
+  engine = engines[engine_type];
+}
+
+const std::string &RandomNumberGeneratorFactory::getEngine() const
+{
+  return engineNames[engine];
+}
+
+void RandomNumberGeneratorFactory::setDistribution(std::string distribution_type)
+{
+  ASSERT(distributions.count(distribution_type) != 0 ,"Selected distribution "+distribution_type+"is not registered.");
+  distribution = distributions[distribution_type];
+}
+
+const std::string &RandomNumberGeneratorFactory::getDistribution() const
+{
+  return distributionNames[distribution];
+}
+
+CONSTRUCT_SINGLETON(RandomNumberGeneratorFactory)
+
+#include "RandomNumberGeneratorFactory.undef"
+
Index: src/RandomNumbers/RandomNumberGeneratorFactory.def
===================================================================
--- src/RandomNumbers/RandomNumberGeneratorFactory.def	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
+++ src/RandomNumbers/RandomNumberGeneratorFactory.def	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
@@ -0,0 +1,68 @@
+#ifndef RANDOMNUMBERGENERATORFACTORY_DEF_
+#define RANDOMNUMBERGENERATORFACTORY_DEF_
+
+/** BOOST_PP_SEQ of all random::boost engine types,
+ * see see http://www.boost.org/doc/libs/1_45_0/doc/html/boost_random/reference.html#boost_random.reference.concepts
+ */
+#define engine_seq \
+(minstd_rand0)
+
+/*
+(minstd_rand)\
+(rand48)\
+(ecuyer1988)\
+(kreutzer1986)\
+(taus88)\
+(hellekalek1995)\
+(mt11213b)\
+(mt19937)
+*/
+#define engine_seq_a \
+(lagged_fibonacci607)
+
+/*
+(lagged_fibonacci1279)\
+(lagged_fibonacci2281)\
+(lagged_fibonacci3217)\
+(lagged_fibonacci4423)\
+(lagged_fibonacci9689)\
+(lagged_fibonacci19937)\
+(lagged_fibonacci23209)\
+(lagged_fibonacci44497)\
+(ranlux3)\
+(ranlux4)\
+(ranlux64_3)\
+(ranlux64_4)\
+(ranlux3_01)\
+(ranlux4_01)\
+(ranlux64_3_01)\
+(ranlux64_4_01)
+*/
+#define engine_seq_size BOOST_PP_SEQ_SIZE(engine_seq)
+#define engine_seq_a_size BOOST_PP_SEQ_SIZE(engine_seq_a)
+
+/** BOOST_PP_SEQ of all random::boost distribution types,
+ * see see http://www.boost.org/doc/libs/1_45_0/doc/html/boost_random/reference.html#boost_random.reference.concepts
+ */
+#define distribution_seq \
+(uniform_smallint)\
+(uniform_int)
+
+/*
+(uniform_01)\
+(uniform_real)\
+(bernoulli_distribution)\
+(binomial_distribution)\
+(cauchy_distribution)\
+(gamma_distribution)\
+(poisson_distribution)\
+(geometric_distribution)\
+(triangle_distribution)\
+(exponential_distribution)\
+(normal_distribution)\
+(lognormal_distribution)\
+(uniform_on_sphere)
+*/
+#define distribution_seq_size BOOST_PP_SEQ_SIZE(distribution_seq)
+
+#endif /* RANDOMNUMBERGENERATORFACTORY_DEF_ */
Index: src/RandomNumbers/RandomNumberGeneratorFactory.hpp
===================================================================
--- src/RandomNumbers/RandomNumberGeneratorFactory.hpp	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
+++ src/RandomNumbers/RandomNumberGeneratorFactory.hpp	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
@@ -0,0 +1,159 @@
+/*
+ * RandomNumberGeneratorFactory.hpp
+ *
+ *  Created on: Dec 31, 2010
+ *      Author: heber
+ */
+
+#ifndef RANDOMNUMBERGENERATORFACTORY_HPP_
+#define RANDOMNUMBERGENERATORFACTORY_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "CodePatterns/Singleton.hpp"
+
+#include "RandomNumberDistribution.hpp"
+#include "RandomNumberEngine.hpp"
+#include "RandomNumberGenerator.hpp"
+
+#include <map>
+
+#include "TemplatePowerSetGenerator.hpp"
+#include "RandomNumberGeneratorFactory.def"
+
+#include "unittests/RandomNumberGeneratorFactoryUnitTest.hpp"
+
+/** This is the abstract factory class for random number generators.
+ *
+ * The reason for creating the generators as this is that we would like to set
+ * the generator's parameters, via some Action, and then onward only have
+ * random number generator of this type using these parameters. Hence, we have
+ * a singleton factory that is controlled by the Action and can then create
+ * generators wherever we like in the code by having the factory create one.
+ *
+ */
+class RandomNumberGeneratorFactory : public Singleton<RandomNumberGeneratorFactory>
+{
+  friend class Singleton<RandomNumberGeneratorFactory>;
+  friend class RandomNumberGeneratorFactoryTest;
+public:
+
+protected:
+  RandomNumberGeneratorFactory();
+  virtual ~RandomNumberGeneratorFactory();
+
+public:
+  /** Enumeration of all (pseudo-)random number engines implemented in
+   *  boost::random, see
+   *  http://www.boost.org/doc/libs/1_45_0/doc/html/boost_random/reference.html#boost_random.reference.concepts
+   */
+  enum Engine {
+BOOST_PP_REPEAT( engine_seq_size, seqitems_as_enum, engine_seq)
+,
+BOOST_PP_REPEAT( engine_seq_a_size, seqitems_as_enum, engine_seq_a)
+  };
+
+  /** Enumeration of all distribution implemented in random::boost.
+   */
+  enum Distribution {
+BOOST_PP_REPEAT( distribution_seq_size, seqitems_as_enum, distribution_seq)
+  };
+
+  /** Create a Generator of previously set type.
+   *
+   * \return random number generator instance
+   */
+  RandomNumberGenerator& makeRandomNumberGenerator() const;
+
+  /** Create a Generator of desired combination of engine and distribution.
+   *
+   * Note that this does not affect the default setting of the engine or
+   * distribution type.
+   *
+   * \param engine_type name of engine, give empty string for current default
+   * \param distribution_type name of distribution, give empty string for current default
+   * \return random number generator instance
+   */
+  RandomNumberGenerator& makeRandomNumberGenerator(std::string engine_type, std::string distribution_type) const;
+
+  /** Specify the precise type of the engine to build
+   *
+   * @param name of engine
+   */
+  void setEngine(std::string engine_type);
+
+  /** Getter for current type of engine.
+   *
+   * @return name of engine
+   */
+  const std::string &getEngine() const;
+
+  /** Specify the precise type of the distribution to build
+   *
+   * @param name of distribution
+   */
+  void setDistribution(std::string distribution_type);
+
+  /** Getter for current type of distribution.
+   *
+   * @return name of distribution
+   */
+  const std::string &getDistribution() const;
+
+protected:
+private:
+  /** Creates instances of all possible (engine,distribution) combinations
+   *  and stores them in \a PrototypeTable.
+   */
+  void FillPrototypeTables();
+
+  typedef std::map<
+      std::string,
+      enum Engine
+      > EngineMap;
+  typedef std::map<
+      enum Engine,
+      RandomNumberEngine *
+      > EngineTable;
+  typedef std::map<
+      enum Engine,
+      std::string
+        > EngineNamesMap;
+
+  typedef std::map<
+      std::string,
+      enum Distribution
+      > DistributionMap;
+  typedef std::map<
+      enum Distribution,
+      RandomNumberDistribution *
+      > DistributionTable;
+  typedef std::map<
+      enum Distribution,
+      std::string
+      > DistributionNamesMap;
+
+  typedef std::map<
+      enum Engine,
+      std::map<
+        enum Distribution,
+        RandomNumberGenerator *>
+  > EngineDistributionTable;
+
+  static enum Engine engine;
+  static enum Distribution distribution;
+  static EngineMap engines;
+  static EngineTable EnginePrototypeTable;
+  static EngineNamesMap engineNames;
+  static DistributionMap distributions;
+  static DistributionTable DistributionPrototypeTable;
+  static DistributionNamesMap distributionNames;
+  static EngineDistributionTable GeneratorPrototypeTable;
+};
+
+#include "RandomNumberGeneratorFactory.undef"
+
+#endif /* RANDOMNUMBERGENERATORFACTORY_HPP_ */
Index: src/RandomNumbers/RandomNumberGeneratorFactory.undef
===================================================================
--- src/RandomNumbers/RandomNumberGeneratorFactory.undef	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
+++ src/RandomNumbers/RandomNumberGeneratorFactory.undef	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
@@ -0,0 +1,10 @@
+#ifdef RANDOMNUMBERGENERATORFACTORY_DEF_
+
+#undef distribution_seq
+#undef distribution_seq_size
+#undef generator_seq
+#undef generator_seq_size
+
+#undef RANDOMNUMBERGENERATORFACTORY_DEF_
+
+#endif /* RANDOMNUMBERGENERATORFACTORY_DEF_ */
Index: src/RandomNumbers/RandomNumberGenerator_Encapsulation.hpp
===================================================================
--- src/RandomNumbers/RandomNumberGenerator_Encapsulation.hpp	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
+++ src/RandomNumbers/RandomNumberGenerator_Encapsulation.hpp	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
@@ -0,0 +1,105 @@
+/*
+ * RandomNumberGenerator_Encapsulation.hpp
+ *
+ *  Created on: Dec 31, 2010
+ *      Author: heber
+ */
+
+#ifndef RANDOMNUMBERGENERATOR_ENCAPSULATION_HPP_
+#define RANDOMNUMBERGENERATOR_ENCAPSULATION_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "RandomNumberDistribution.hpp"
+#include "RandomNumberEngine.hpp"
+#include "RandomNumberGenerator.hpp"
+#include "RandomNumberGeneratorFactory.hpp"
+
+#include "unittests/RandomNumberGeneratorFactoryUnitTest.hpp"
+
+/** Template class that encapsulates the random number generators from
+ *  random::boost.
+ *
+ * We inherit the interface RandomNumberGenerator such that all are
+ * accessible in the same way (i.e. RandomNumberGeneratorFactory will
+ * spit out only references to RandomNumberGenerator).
+ *
+ * Note that we always returns double values although the distribution
+ * might be integer or even a discrete distribution of integers.
+ *
+ * We need three template parameters:
+ * -# the generator - generates uniform random numbers
+ * -# the distribution - transforms uniform into a desired distribution
+ */
+template <class engine, class distribution>
+class RandomNumberGenerator_Encapsulation : public RandomNumberGenerator
+{
+  /**
+   * Factory is friend such that it can access private cstor.
+   */
+  friend class RandomNumberGeneratorFactory;
+  friend class RandomNumberGeneratorFactoryTest;
+
+public:
+  /** obtain a random number via generator and the specific distribution.
+   *
+   */
+  double operator()() const {
+    return randomgenerator();
+  }
+
+  /** Set the generator's seed.
+   *
+   * @param _seed seed to set to
+   */
+  void seed(unsigned int _seed) {
+    engine_type.seed(_seed);
+  }
+
+  /** Getter for the type name of the internal engine.
+   *
+   */
+  std::string EngineName() {
+    return engine_type.name();
+  }
+
+  /** Getter for the type name of the internal distribution.
+   *
+   */
+  std::string DistributionName() {
+    return distribution_type.name();
+  }
+
+  /** Constructor that instantiates a specific random number generator and
+   * distribution.
+   * @param _generator_type instance of the desired generator
+   * @param _distribution_type instance of the desired distribution
+   */
+  RandomNumberGenerator_Encapsulation(
+      RandomNumberEngine &_engine_type,
+      RandomNumberDistribution &_distribution_type
+      ) :
+    engine_type(static_cast<RandomNumberEngine_Encapsulation<engine> &>(_engine_type)),
+    distribution_type(static_cast<RandomNumberDistribution_Encapsulation<distribution> &>(_distribution_type)),
+    randomgenerator(boost::variate_generator<engine, distribution> (
+        engine_type.getEngine(),
+        distribution_type.getDistribution()
+        ))
+  {
+    // note that we instantiate the variate_generator with the copied instances!
+  }
+
+  /** Destructor of the class.
+   *
+   */
+  ~RandomNumberGenerator_Encapsulation() {}
+private:
+  RandomNumberEngine_Encapsulation<engine> engine_type;
+  RandomNumberDistribution_Encapsulation<distribution> distribution_type;
+  mutable boost::variate_generator<engine, distribution> randomgenerator;
+};
+
+#endif /* RANDOMNUMBERGENERATOR_ENCAPSULATION_HPP_ */
Index: src/RandomNumbers/TemplatePowerSetGenerator.hpp
===================================================================
--- src/RandomNumbers/TemplatePowerSetGenerator.hpp	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
+++ src/RandomNumbers/TemplatePowerSetGenerator.hpp	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
@@ -0,0 +1,162 @@
+/*
+ * TemplatePowerSetGenerator.hpp
+ *
+ *  Created on: Dec 31, 2010
+ *      Author: heber
+ */
+
+#ifndef TEMPLATEPOWERSETGENERATOR_HPP_
+#define TEMPLATEPOWERSETGENERATOR_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+// this include is needed for BOOST_PP_LOCAL_ITERATE()
+#include <boost/preprocessor/iteration/local.hpp>
+
+// this include is needed for BOOST_PP_REPEAT
+#include <boost/preprocessor/repetition/repeat.hpp>
+
+#include <boost/preprocessor/punctuation/comma_if.hpp>
+#include <boost/preprocessor/seq/elem.hpp>
+#include <boost/preprocessor/seq/enum.hpp>
+#include <boost/preprocessor/seq/for_each.hpp>
+#include <boost/preprocessor/stringize.hpp>
+#include <boost/preprocessor/tuple/elem.hpp>
+
+/** Functions that prints the given elem as [elem].
+ *
+ * Use the funcione as follows:
+ * SquareBracketize(~,~,test)
+ *
+ * which would output:
+ * [test]
+ */
+#define SquareBracketize(r, data, elem)  \
+[ \
+elem \
+]
+
+/** Functions that allows to print a given seq of elements in the way of
+ *  enumeration declaration.
+ *
+ * Use the functions as follows:
+ * #define BOOST_PP_REPEAT(BOOST_PP_SEQ_SIZE(seq), n, seqitems_as_struct)
+ *
+ * where "seq" is your defined list, e.g.
+ * #define seq (1)(2)(3)(4)
+ *
+ * which would output:
+ * 1,
+ * 2,
+ * 3,
+ * 4
+ *
+ */
+#define seqitems_as_enum(z,n,seq_with_elements) \
+  BOOST_PP_COMMA_IF (n) \
+  BOOST_PP_SEQ_ELEM(n, seq_with_elements)
+
+/** Functions that allows to print a given seq of elements in the way of
+ *  variable declaration.
+ *
+ * Use the functions as follows:
+ * #define BOOST_PP_LOCAL_MACRO(n) seqitems_as_enum(seqsize, n, seq)
+ * #define BOOST_PP_LOCAL_LIMITS  (0, BOOST_PP_SEQ_SIZE(seq)-1 )
+ * #include BOOST_PP_LOCAL_ITERATE()
+ *
+ * where "seq" is your defined list, e.g.
+ * #define seq (1)(2)(3)(4)
+ *
+ * which would output:
+ * 1;
+ * 2;
+ * 3;
+ * 4;
+ *
+ */
+#define seqitems_as_struct(z,n,seq_with_elements ) \
+  BOOST_PP_SEQ_ELEM(n, seq_with_elements) ;
+
+/** Functions that allows to print a given seq of elements in the way of
+ *  std::map from strings to enums.
+ *
+ * e.g. let "seq" be defined as
+ * #define seq (one)(two)(three)(four)
+ *
+ * then we use
+ * #define BOOST_PP_LOCAL_MACRO(n) seqitems_as_string_enum_map(seqsize, n, seq, EnumMap)
+ * #define BOOST_PP_LOCAL_LIMITS  (0, BOOST_PP_SEQ_SIZE(seq)-1 )
+ * #include BOOST_PP_LOCAL_ITERATE()
+ *
+ * which expands by the preprocessor to:
+ * EnumMap["one"] = one;
+ * EnumMap["two"] = two;
+ * EnumMap["three"] = three;
+ * EnumMap["four"] = four;
+
+ */
+#define seqitems_as_string_enum_map(z,n,seq_with_elements, map) \
+  map [BOOST_PP_STRINGIZE( \
+  BOOST_PP_SEQ_ELEM(n, seq_with_elements) \
+  )] = BOOST_PP_SEQ_ELEM(n, seq_with_elements) \
+  ;
+
+/** Functions that allows to print a given seq of elements in the way of
+ *  std::map from strings to enums.
+ *
+ * e.g. let "seq" be defined as
+ * #define seq (one)(two)(three)(four)
+ *
+ * then we use
+ * #define BOOST_PP_LOCAL_MACRO(n) seqitems_as_enum_key_map(seqsize, n, seq, EnumMap, test::)
+ * #define BOOST_PP_LOCAL_LIMITS  (0, BOOST_PP_SEQ_SIZE(seq)-1 )
+ * #include BOOST_PP_LOCAL_ITERATE()
+ *
+ * which expands by the preprocessor to:
+ * EnumMap[one] = test::one;
+ * EnumMap[two] = test::two;
+ * EnumMap[three] = test::three;
+ * EnumMap[four] = test::four;
+
+ */
+#define seqitems_as_enum_key_map(z,n,seq_with_elements, map, keytype, name_space, suffix) \
+  map [ \
+  BOOST_PP_SEQ_ELEM(n, seq_with_elements) \
+  ] = keytype< name_space BOOST_PP_SEQ_ELEM(n, seq_with_elements) suffix > ();
+
+#define tupel_in_square_brackets(z,n,tupelelement) \
+[ \
+tupelelement \
+]\
+
+/** Functions that allows to print a given seq of elements in the way of
+ *  std::map from strings to enums.
+ *
+ * e.g. let "seqseq" be defined as
+ * #define seqseq ((d)(eins)(zwei)(drei))((e)(one)(two)(three))((f)(un)(deux)(troix))
+ *
+ * then we use
+ * #define tableprinter(z,n,seq) BOOST_PP_SEQ_ELEM(n,seq)
+ * #define BOOST_PP_LOCAL_MACRO(n) seqitems_as_enum_key_multidimmap(seqsize, n, seqseq, MultiMap, test::, tableprinter)
+ * #define BOOST_PP_LOCAL_LIMITS  (0, BOOST_PP_SEQ_SIZE(seqseq)-1 )
+ * #include BOOST_PP_LOCAL_ITERATE()
+ *
+ * which expands by the preprocessor to:
+ * MultiMap[eins][zwei][drei] = test:: d;
+ * MultiMap[one][two][three] = test:: e;
+ * MultiMap[un][deux][troix] = test:: f;
+
+ */
+#define seqitems_as_enum_key_multidimmap(z,n,seq_of_tupels, map, template_function, template_arg_printer, param_arg_printer) \
+  map \
+  BOOST_PP_SEQ_FOR_EACH(SquareBracketize, ~, BOOST_PP_SEQ_ELEM(n, seq_of_tupels)) \
+  = template_function \
+  < BOOST_PP_REPEAT(BOOST_PP_SEQ_SIZE(tableseq), template_arg_printer,  BOOST_PP_SEQ_ELEM(n, seq_of_tupels) ) > (\
+  BOOST_PP_REPEAT(BOOST_PP_SEQ_SIZE(tableseq), param_arg_printer,  BOOST_PP_SEQ_ELEM(n, seq_of_tupels) ) );
+
+
+#endif /* TEMPLATEPOWERSETGENERATOR_HPP_ */
Index: src/RandomNumbers/unittests/Makefile.am
===================================================================
--- src/RandomNumbers/unittests/Makefile.am	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
+++ src/RandomNumbers/unittests/Makefile.am	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
@@ -0,0 +1,41 @@
+# PLEASE adhere to the alphabetical ordering in this Makefile!
+# Also indentation by a single tab
+
+INCLUDES = -I$(top_srcdir)/src
+
+AM_LDFLAGS = ${CodePatterns_LIBS} $(CPPUNIT_LIBS) -ldl
+AM_CPPFLAGS = ${BOOST_CPPFLAGS} $(CPPUNIT_CFLAGS) ${CodePatterns_CFLAGS}
+
+TESTS = \
+  RandomNumberGeneratorFactoryUnitTest
+
+
+check_PROGRAMS = $(TESTS) 
+noinst_PROGRAMS = $(TESTS)
+
+BOOST_LIB = $(BOOST_LDFLAGS) $(BOOST_MPL_LIB) $(BOOST_PROGRAM_OPTIONS_LIB) $(BOOST_FILESYSTEM_LIB) $(BOOST_SYSTEM_LIB) $(BOOST_THREAD_LIB)
+GSLLIBS = \
+	../../Shapes/libMolecuilderShapes.la \
+	../../LinearAlgebra/libMolecuilderLinearAlgebra.la \
+	../../Exceptions/libMolecuilderExceptions.la \
+	${CodePatterns_LIBS} \
+	$(BOOST_LIB)
+
+ALLLIBS = \
+	../../UIElements/libMolecuilderUI.la \
+	../../Actions/libMolecuilderActions.la \
+	${PARSERLIBS} \
+	../../libMolecuilder.la \
+	${GSLLIBS}
+
+PARSERLIBS = ../../Parser/libMolecuilderParser.la
+
+RandomNumberGeneratorFactoryUnitTest_SOURCES = $(top_srcdir)/src/unittests/UnitTestMain.cpp \
+	RandomNumberGeneratorFactoryUnitTest.cpp \
+	RandomNumberGeneratorFactoryUnitTest.hpp \
+	$(srcdir)/../RandomNumberGeneratorFactory.cpp \
+	$(srcdir)/../RandomNumberGeneratorFactory.hpp
+RandomNumberGeneratorFactoryUnitTest_LDADD = ${GSLLIBS}
+
+
+#AUTOMAKE_OPTIONS = parallel-tests
Index: src/RandomNumbers/unittests/RandomNumberGeneratorFactoryUnitTest.cpp
===================================================================
--- src/RandomNumbers/unittests/RandomNumberGeneratorFactoryUnitTest.cpp	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
+++ src/RandomNumbers/unittests/RandomNumberGeneratorFactoryUnitTest.cpp	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
@@ -0,0 +1,140 @@
+/*
+ * Project: MoleCuilder
+ * Description: creates and alters molecular systems
+ * Copyright (C)  2010 University of Bonn. All rights reserved.
+ * Please see the LICENSE file or "Copyright notice" in builder.cpp for details.
+ */
+
+/*
+ * RandomNumberGeneratorFactoryUnitTest.cpp
+ *
+ *  Created on: Dec 31, 2010
+ *      Author: heber
+ */
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
+
+#include "CodePatterns/Assert.hpp"
+
+#include "RandomNumberGeneratorFactoryUnitTest.hpp"
+
+#include "RandomNumbers/RandomNumberDistribution_Encapsulation.hpp"
+#include "RandomNumbers/RandomNumberEngine_Encapsulation.hpp"
+#include "RandomNumbers/RandomNumberGenerator_Encapsulation.hpp"
+#include "RandomNumbers/RandomNumberGeneratorFactory.hpp"
+
+#include <boost/nondet_random.hpp>
+#include <boost/random.hpp>
+#include <boost/random/additive_combine.hpp>
+#include <boost/random/discard_block.hpp>
+#include <boost/random/inversive_congruential.hpp>
+#include <boost/random/lagged_fibonacci.hpp>
+#include <boost/random/linear_congruential.hpp>
+#include <boost/random/linear_feedback_shift.hpp>
+#include <boost/random/mersenne_twister.hpp>
+#include <boost/random/random_number_generator.hpp>
+#include <boost/random/ranlux.hpp>
+#include <boost/random/shuffle_output.hpp>
+#include <boost/random/subtract_with_carry.hpp>
+#include <boost/random/xor_combine.hpp>
+#include <boost/random/bernoulli_distribution.hpp>
+#include <boost/random/binomial_distribution.hpp>
+#include <boost/random/cauchy_distribution.hpp>
+#include <boost/random/exponential_distribution.hpp>
+#include <boost/random/gamma_distribution.hpp>
+#include <boost/random/geometric_distribution.hpp>
+#include <boost/random/linear_congruential.hpp>
+#include <boost/random/lognormal_distribution.hpp>
+#include <boost/random/normal_distribution.hpp>
+#include <boost/random/poisson_distribution.hpp>
+#include <boost/random/triangle_distribution.hpp>
+#include <boost/random/uniform_01.hpp>
+#include <boost/random/uniform_int.hpp>
+#include <boost/random/uniform_on_sphere.hpp>
+#include <boost/random/uniform_real.hpp>
+#include <boost/random/uniform_smallint.hpp>
+
+#include <typeinfo>
+
+#ifdef HAVE_TESTRUNNER
+#include "UnitTestMain.hpp"
+#endif /*HAVE_TESTRUNNER*/
+
+/********************************************** Test classes **************************************/
+
+// Registers the fixture into the 'registry'
+CPPUNIT_TEST_SUITE_REGISTRATION( RandomNumberGeneratorFactoryTest );
+
+void RandomNumberGeneratorFactoryTest::setUp()
+{
+  RandomNumberGeneratorFactory::getInstance();
+}
+
+void RandomNumberGeneratorFactoryTest::tearDown()
+{
+  RandomNumberGeneratorFactory::purgeInstance();
+}
+
+void RandomNumberGeneratorFactoryTest::EngineTest()
+{
+  // check default value
+  CPPUNIT_ASSERT_EQUAL(
+      std::string("minstd_rand0"),
+      RandomNumberGeneratorFactory::getInstance().getEngine());
+
+  // check one of the engines in the table
+  CPPUNIT_ASSERT_EQUAL(
+      std::string(typeid(boost::minstd_rand0).name()),
+      RandomNumberGeneratorFactory::getInstance().
+            EnginePrototypeTable[RandomNumberGeneratorFactory::minstd_rand0]->name()
+  );
+}
+
+void RandomNumberGeneratorFactoryTest::DistributionTest()
+{
+  // check default value
+  CPPUNIT_ASSERT_EQUAL(
+      std::string("uniform_smallint"),
+      RandomNumberGeneratorFactory::getInstance().getDistribution());
+
+  // check one of the distributions in the table
+  CPPUNIT_ASSERT_EQUAL(
+      std::string(typeid(boost::uniform_smallint<> ).name()),
+      RandomNumberGeneratorFactory::getInstance().
+            DistributionPrototypeTable[RandomNumberGeneratorFactory::uniform_smallint]->name()
+  );
+}
+
+void RandomNumberGeneratorFactoryTest::GeneratorTest()
+{
+  // check one of the engines and distributions
+  CPPUNIT_ASSERT_EQUAL(
+      std::string(typeid(boost::minstd_rand0).name()),
+      RandomNumberGeneratorFactory::getInstance().
+            GeneratorPrototypeTable[RandomNumberGeneratorFactory::minstd_rand0][RandomNumberGeneratorFactory::uniform_smallint]
+                                                                                ->EngineName()
+  );
+  CPPUNIT_ASSERT_EQUAL(
+      std::string(typeid(boost::uniform_smallint<> ).name()),
+      RandomNumberGeneratorFactory::getInstance().
+            GeneratorPrototypeTable[RandomNumberGeneratorFactory::minstd_rand0][RandomNumberGeneratorFactory::uniform_smallint]
+                                                                                ->DistributionName()
+  );
+
+  // obtain some random values for uniform_smallint
+  RandomNumberGeneratorFactory::getInstance().setDistribution("uniform_smallint");
+  RandomNumberGenerator &rng = RandomNumberGeneratorFactory::getInstance().makeRandomNumberGenerator();
+  for (size_t i=0; i < 1000; ++i) {
+    const int testint = rng();
+    CPPUNIT_ASSERT_MESSAGE("randon number from uniform_smallint is out of [0:9]!", testint >= 0);
+    CPPUNIT_ASSERT_MESSAGE("randon number from uniform_smallint is out of [0:9]!", testint <= 9);
+  }
+}
+
Index: src/RandomNumbers/unittests/RandomNumberGeneratorFactoryUnitTest.hpp
===================================================================
--- src/RandomNumbers/unittests/RandomNumberGeneratorFactoryUnitTest.hpp	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
+++ src/RandomNumbers/unittests/RandomNumberGeneratorFactoryUnitTest.hpp	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
@@ -0,0 +1,38 @@
+/*
+ * RandomNumberGeneratorFactoryUnitTest.hpp
+ *
+ *  Created on: Dec 31, 2010
+ *      Author: heber
+ */
+
+#ifndef RANDOMNUMBERGENERATORFACTORYUNITTEST_HPP_
+#define RANDOMNUMBERGENERATORFACTORYUNITTEST_HPP_
+
+// include config.h
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+
+#include <cppunit/extensions/HelperMacros.h>
+
+class RandomNumberGeneratorFactoryTest : public CppUnit::TestFixture
+{
+  CPPUNIT_TEST_SUITE( RandomNumberGeneratorFactoryTest );
+  CPPUNIT_TEST ( EngineTest );
+  CPPUNIT_TEST ( DistributionTest );
+  CPPUNIT_TEST ( GeneratorTest );
+  CPPUNIT_TEST_SUITE_END();
+
+public:
+  void setUp();
+  void tearDown();
+
+  void EngineTest();
+  void DistributionTest();
+  void GeneratorTest();
+
+private:
+};
+
+#endif /* RANDOMNUMBERGENERATORFACTORYUNITTEST_HPP_ */
Index: src/builder_init.cpp
===================================================================
--- src/builder_init.cpp	(revision 1f91f4d142b3890c0ea0c60d27ff628498b897f0)
+++ src/builder_init.cpp	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
@@ -42,4 +42,6 @@
 #include "Actions/ActionRegistry.hpp"
 #include "Actions/ActionHistory.hpp"
+
+#include "RandomNumbers/RandomNumberGeneratorFactory.hpp"
 
 #include "Parser/ChangeTracker.hpp"
@@ -167,4 +169,5 @@
 void cleanUp()
 {
+  RandomNumberGeneratorFactory::purgeInstance();
   FormatParserStorage::purgeInstance();
   ChangeTracker::purgeInstance();
Index: src/unittests/Makefile.am
===================================================================
--- src/unittests/Makefile.am	(revision 1f91f4d142b3890c0ea0c60d27ff628498b897f0)
+++ src/unittests/Makefile.am	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
@@ -7,4 +7,5 @@
 	../LinearAlgebra/unittests \
 	../Parser/unittests \
+	../RandomNumbers/unittests \
 	../Shapes/unittests \
 	../UIElements/Menu/unittests
Index: tests/regression/Makefile.am
===================================================================
--- tests/regression/Makefile.am	(revision 1f91f4d142b3890c0ea0c60d27ff628498b897f0)
+++ tests/regression/Makefile.am	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
@@ -11,4 +11,5 @@
 	Graph \
 	Molecules \
+	RandomNumbers \
 	Selection \
 	Simple_configuration \
@@ -34,4 +35,7 @@
 	$(srcdir)/testsuite-molecules.at \
 	$(srcdir)/testsuite-simple_configuration.at \
+	$(srcdir)/RandomNumbers/testsuite-randomnumbers.at \
+	$(srcdir)/RandomNumbers/Distribution/testsuite-set-random-number-distribution.at \
+	$(srcdir)/RandomNumbers/Engine/testsuite-set-random-number-engine.at \
 	$(srcdir)/Selection/testsuite-selection.at \
 	$(srcdir)/Selection/Atoms/testsuite-selection-all-atoms.at \
Index: tests/regression/RandomNumbers/Distribution/testsuite-set-random-number-distribution.at
===================================================================
--- tests/regression/RandomNumbers/Distribution/testsuite-set-random-number-distribution.at	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
+++ tests/regression/RandomNumbers/Distribution/testsuite-set-random-number-distribution.at	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
@@ -0,0 +1,12 @@
+### 1. set the distribution
+
+AT_SETUP([Random numbers - set the distribution with Undo/Redo])
+AT_KEYWORDS([random numbers])
+AT_CHECK([../../molecuilder -v 3 --set-random-number-distribution uniform_int], 0, [stdout], [stderr])
+AT_CHECK([fgrep "uniform_int" stdout], 0, [ignore], [ignore])
+AT_CHECK([../../molecuilder -v 3 --set-random-number-distribution uniform_int --undo], 0, [stdout], [stderr])
+AT_CHECK([fgrep "uniform_smallint" stdout], 0, [ignore], [ignore])
+AT_CHECK([../../molecuilder -v 3 --set-random-number-distribution uniform_int --undo --redo], 0, [stdout], [stderr])
+AT_CHECK([fgrep -c "uniform_int" stdout], 0, [stdout], [ignore])
+AT_CHECK([fgrep "2" stdout], 0, [stdout], [ignore])
+AT_CLEANUP
Index: tests/regression/RandomNumbers/Engine/testsuite-set-random-number-engine.at
===================================================================
--- tests/regression/RandomNumbers/Engine/testsuite-set-random-number-engine.at	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
+++ tests/regression/RandomNumbers/Engine/testsuite-set-random-number-engine.at	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
@@ -0,0 +1,12 @@
+### 1. set the engine
+
+AT_SETUP([Random numbers - set the engine with Undo/Redo])
+AT_KEYWORDS([random numbers])
+AT_CHECK([../../molecuilder -v 3 --set-random-number-engine lagged_fibonacci607], 0, [stdout], [stderr])
+AT_CHECK([fgrep "lagged_fibonacci607" stdout], 0, [ignore], [ignore])
+AT_CHECK([../../molecuilder -v 3 --set-random-number-engine lagged_fibonacci607 --undo], 0, [stdout], [stderr])
+AT_CHECK([fgrep "minstd_rand0" stdout], 0, [ignore], [ignore])
+AT_CHECK([../../molecuilder -v 3 --set-random-number-engine lagged_fibonacci607 --undo --redo], 0, [stdout], [stderr])
+AT_CHECK([fgrep -c "lagged_fibonacci607" stdout], 0, [stdout], [ignore])
+AT_CHECK([fgrep "2" stdout], 0, [stdout], [ignore])
+AT_CLEANUP
Index: tests/regression/RandomNumbers/testsuite-randomnumbers.at
===================================================================
--- tests/regression/RandomNumbers/testsuite-randomnumbers.at	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
+++ tests/regression/RandomNumbers/testsuite-randomnumbers.at	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
@@ -0,0 +1,7 @@
+AT_BANNER([MoleCuilder - Random numbers])
+
+# 1. set the engine
+m4_include(RandomNumbers/Engine/testsuite-set-random-number-engine.at)
+
+# 2. set the distribution
+m4_include(RandomNumbers/Distribution/testsuite-set-random-number-distribution.at)
Index: tests/regression/testsuite.at
===================================================================
--- tests/regression/testsuite.at	(revision 1f91f4d142b3890c0ea0c60d27ff628498b897f0)
+++ tests/regression/testsuite.at	(revision 3f9eba726fa6ba97ad9f47ad397aa83f8f1fc923)
@@ -18,4 +18,6 @@
 m4_include(Selection/testsuite-selection.at)
 
+m4_include(RandomNumbers/testsuite-randomnumbers.at)
+
 m4_include(testsuite-domain.at)
 
