MipBaselib::Roulette Class Reference

Allows the simulation of a weighted/unweighted roulette-like random process. More...

#include <Roulette.h>

List of all members.

Public Member Functions

 Roulette ()
 Default constructor.
 Roulette (const Roulette &r)
 Copy constructor.
const Rouletteoperator= (const Roulette &r)
 Assignment operator =.
void setCapacity (int s)
 Sets number of Pockets of the Roulette.
void addPocket (Pocket p)
 Add a pocket to the Roulette.
int getNumPockets () const
 Gets the number of Pockets in the Roulette.
int getSumPockets () const
 Gets the sum of the weights of the Pockets in the Roulette.
bool weigthedExtraction (int &extracted, bool rep=true)
 Perform an extraction with probability of Pockets proportional to weights.
bool unweigthedExtraction (int &extracted, bool rep=true)
 Perform an extraction with all Pockets with same probability.
void resetRepetitions ()
 Reset the repetitions in the extraction without repetition.
void clearAll ()
 Erase all pockets.
string print ()
 Print function.


Detailed Description

Allows the simulation of a weighted/unweighted roulette-like random process.

Author:
Paolo Stegagno

Constructor & Destructor Documentation

MipBaselib::Roulette::Roulette (  ) 

Default constructor.

MipBaselib::Roulette::Roulette ( const Roulette r  ) 

Copy constructor.


Member Function Documentation

const Roulette & MipBaselib::Roulette::operator= ( const Roulette r  ) 

Assignment operator =.

void MipBaselib::Roulette::setCapacity ( int  s  ) 

Sets number of Pockets of the Roulette.

void MipBaselib::Roulette::addPocket ( Pocket  p  ) 

Add a pocket to the Roulette.

Parameters:
[in] &p pocket to be added to the roulette. Call an exception and terminate the execution of the program if the weight of the Pocket p is negative.

int MipBaselib::Roulette::getNumPockets (  )  const

Gets the number of Pockets in the Roulette.

Returns:
The number of Pockets.

int MipBaselib::Roulette::getSumPockets (  )  const

Gets the sum of the weights of the Pockets in the Roulette.

Returns:
The numeber of Pockets.

bool MipBaselib::Roulette::weigthedExtraction ( int &  extracted,
bool  rep = true 
)

Perform an extraction with probability of Pockets proportional to weights.

Parameters:
[out] &extracted value in the extracted Pocket.
[in] rep Allow repetitions if true.
Returns:
false if extraction without repetition finished values, true otherwise.

bool MipBaselib::Roulette::unweigthedExtraction ( int &  extracted,
bool  rep = true 
)

Perform an extraction with all Pockets with same probability.

Parameters:
[out] &extracted value in the extracted Pocket.
[in] rep Allow repetitions if true.
Returns:
false if extraction without repetition finished values, true otherwise.
Note:
Performing unweighted extraction will ignore the weights of the pocket even if set.

void MipBaselib::Roulette::resetRepetitions (  ) 

Reset the repetitions in the extraction without repetition.

void MipBaselib::Roulette::clearAll (  ) 

Erase all pockets.

string MipBaselib::Roulette::print (  ) 

Print function.

Returns:
A printable string.


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

Generated on Mon Feb 20 07:01:11 2017 for MIP by  doxygen 1.5.6