Skip to main content
FRAMES NO FRAMES

Class IloRandom

Definition file: ilconcert/ilorandom.h
Map of IloRandomIloRandomIloRandom
This handle class produces streams of pseudo-random numbers.

You can use objects of this class to create a search with a random element. You can create any number of instances of this class; these instances ensure reproducible results in multithreaded applications, where the use of a single source for random numbers creates problems.

Method Summary
public voidend()
public IloEnvgetEnv() const
public IloNumgetFloat() const
public IloRandomI *getImpl() const
public IloIntgetInt(IloInt n) const
public const char *getName() const
public IloAnygetObject() const
public IloRandom()
public IloRandom(const IloEnv env, IloInt seed=0)
public IloRandom(IloRandomI * impl)
public IloRandom(const IloRandom & rand)
public voidreSeed(IloInt seed)
public voidsetLocation(const char * fileName, int lineNumber) const
public voidsetName(const char * name) const
public voidsetObject(IloAny obj) const
Method Detail

IloRandom

public IloRandom()

This constructor creates a random number generator; it is initially an empty handle. You must assign this handle before you use its member functions.


IloRandom

public IloRandom(const IloEnv env, IloInt seed=0)

This constructor creates an object that generates random numbers. You can seed the generator by supplying a value for the integer argument seed.


IloRandom

public IloRandom(IloRandomI * impl)

This constructor creates a handle object (an instance of the class IloRandom) from a pointer to an implementation object (an instance of the class IloRandomI).


IloRandom

public IloRandom(const IloRandom & rand)

This constructor creates a handle object from a reference to a random number generator. After execution, both the newly constructed handle and rand point to the same implementation object.


end

public void end()

This member function releases all memory used by the random number generator. After a call to this member function, you should not use the generator again.


getEnv

public IloEnv getEnv() const

This member function returns the environment associated with the implementation class of the invoking generator.


getFloat

public IloNum getFloat() const

This member function returns a floating-point number drawn uniformly from the interval [0..1).


getImpl

public IloRandomI * getImpl() const

This member function returns the implementation object of the invoking handle.


getInt

public IloInt getInt(IloInt n) const

This member function returns an integer drawn uniformly from the interval [0..n).


getName

public const char * getName() const

This member function returns a character string specifying the name of the invoking object (if there is one).


getObject

public IloAny getObject() const

This member function returns the object associated with the invoking object (if there is one). Normally, an associated object contains user data pertinent to the invoking object.


reSeed

public void reSeed(IloInt seed)

This member function re-seeds the random number generator with seed.


setLocation

public void setLocation(const char * fileName, int lineNumber) const

This member function stores the source code location (as a file name and line number) in the invoking object. Recommended arguments are the macros __FILE__ and __LINE__. The supplied location can be used for debugging. In particular CP Optimizer may include the location in error messages and in model dumps.

Note that the string pointed to by fileName argument is not copied. Therefore the pointer must be valid during the whole lifespan of the object.

Instead of using this function directly, it may be simpler to use macros ILOSETLOCATION and ILOADD.


setName

public void setName(const char * name) const

This member function assigns name to the invoking object.

When called on an already extracted extractable, notifications will be sent to the engine. When possible, this method should be called before the model is extracted.


setObject

public void setObject(IloAny obj) const

This member function associates obj with the invoking object. The member function getObject accesses this associated object afterward. Normally, obj contains user data pertinent to the invoking object.