OMNeT++ Simulation Library  6.0.3
cRNG Class Referenceabstract

#include <crng.h>

Description

Abstract interface for random number generator classes.

Some known implementations are cMersenneTwister, cLCG32 and cAkaroaRNG. The actual RNG class to be used in simulations can be configured (a feature of the Envir library).

To switch to your own RNG, subclass cRNG, register your new class with the Register_Class() macro, then select it by adding the following to omnetpp.ini:

[General]
rng-class="MyClass"

See also cModule::getRNG().

Inheritance diagram for cRNG:
cObject cLCG32 cMersenneTwister

Public Member Functions

virtual void initialize (int seedSet, int rngId, int numRngs, int parsimProcId, int parsimNumPartitions, cConfiguration *cfg)=0
 
virtual void selfTest ()=0
 
virtual uint64_t getNumbersDrawn () const
 
virtual uint32_t intRand ()=0
 
virtual uint32_t intRandMax ()=0
 
virtual uint32_t intRand (uint32_t n)=0
 
virtual double doubleRand ()=0
 
virtual double doubleRandNonz ()=0
 
virtual double doubleRandIncl1 ()=0
 
double doubleRandNonzIncl1 ()
 
- Public Member Functions inherited from cObject
 cObject ()
 
 cObject (const cObject &other)=default
 
virtual ~cObject ()
 
virtual const char * getClassName () const
 
virtual const char * getName () const
 
bool isName (const char *s) const
 
virtual const char * getFullName () const
 
virtual std::string getFullPath () const
 
virtual std::string getClassAndFullName () const
 
virtual std::string getClassAndFullPath () const
 
const cObjectgetThisPtr () const
 
virtual std::string str () const
 
virtual std::ostream & printOn (std::ostream &os) const
 
virtual cObjectdup () const
 
virtual void parsimPack (cCommBuffer *buffer) const
 
virtual void parsimUnpack (cCommBuffer *buffer)
 
virtual cObjectgetOwner () const
 
virtual bool isOwnedObject () const
 
virtual bool isSoftOwner () const
 
virtual void forEachChild (cVisitor *v)
 
cObjectfindObject (const char *name, bool deep=true)
 
virtual cClassDescriptorgetDescriptor () const
 
void copyNotSupported () const
 

Additional Inherited Members

- Protected Member Functions inherited from cObject
virtual void take (cOwnedObject *obj)
 
virtual void drop (cOwnedObject *obj)
 
void dropAndDelete (cOwnedObject *obj)
 

Member Function Documentation

◆ initialize()

virtual void initialize ( int  seedSet,
int  rngId,
int  numRngs,
int  parsimProcId,
int  parsimNumPartitions,
cConfiguration cfg 
)
pure virtual

Called by the simulation framework to set up the RNG at the start of a simulation run. Seed selection should take place here.

Implemented in cLCG32, and cMersenneTwister.

◆ selfTest()

virtual void selfTest ( )
pure virtual

Coarse test for the correctness of the RNG algorithm. It should detect platform-dependent bugs (e.g. caused by different word size or compiler anomaly). The method should throw an exception if something is wrong. It is invoked only once, when the simulation program starts up.

Implemented in cLCG32, and cMersenneTwister.

◆ getNumbersDrawn()

virtual uint64_t getNumbersDrawn ( ) const
inlinevirtual

Returns how many random numbers have been drawn from this RNG. Subclasses should increment numDrawn in the intRand(), etc. methods.

◆ intRand() [1/2]

virtual uint32_t intRand ( )
pure virtual

Random integer in the range [0,intRandMax()]

Implemented in cLCG32, and cMersenneTwister.

Referenced by omnetpp::intrand().

◆ intRandMax()

virtual uint32_t intRandMax ( )
pure virtual

Maximum value that can be returned by intRand(), e.g. 2^31-2 with LCG32.

Implemented in cLCG32, and cMersenneTwister.

◆ intRand() [2/2]

virtual uint32_t intRand ( uint32_t  n)
pure virtual

Random integer in [0,n), n < intRandMax()

Implemented in cLCG32, and cMersenneTwister.

◆ doubleRand()

virtual double doubleRand ( )
pure virtual

Random double on the [0,1) interval

Implemented in cLCG32, and cMersenneTwister.

Referenced by omnetpp::bernoulli(), and omnetpp::dblrand().

◆ doubleRandNonz()

virtual double doubleRandNonz ( )
pure virtual

Random double on the (0,1) interval

Implemented in cLCG32, and cMersenneTwister.

◆ doubleRandIncl1()

virtual double doubleRandIncl1 ( )
pure virtual

Random double on the [0,1] interval

Implemented in cLCG32, and cMersenneTwister.

◆ doubleRandNonzIncl1()

double doubleRandNonzIncl1 ( )
inline

Random double on the (0,1] interval


The documentation for this class was generated from the following file: