INET Framework for OMNeT++/OMNEST
inet::httptools::rdExponential Class Reference

Exponential distribution random object. More...

#include <HttpRandom.h>

Inheritance diagram for inet::httptools::rdExponential:
inet::httptools::rdObject

Public Member Functions

 rdExponential (double mean)
 
 rdExponential (cXMLAttributeMap attributes)
 
virtual double draw () override
 
void setMinLimit (double min)
 
void resetMinLimit ()
 
void setMaxLimit (double max)
 
void resetMaxLimit ()
 
- Public Member Functions inherited from inet::httptools::rdObject
virtual ~rdObject ()
 
DISTR_TYPE getType ()
 
std::string typeStr ()
 
virtual std::string toString ()
 

Protected Attributes

double m_mean = NaN
 
double m_min = NaN
 
double m_max = NaN
 
bool m_bMinLimit = false
 
bool m_bMaxLimit = false
 
- Protected Attributes inherited from inet::httptools::rdObject
DISTR_TYPE m_type = dt_normal
 

Additional Inherited Members

- Protected Member Functions inherited from inet::httptools::rdObject
bool _hasKey (cXMLAttributeMap attributes, std::string key)
 

Detailed Description

Exponential distribution random object.

Wraps the OMNeT++ exponential distribution function, but adds min and max limits.

Constructor & Destructor Documentation

inet::httptools::rdExponential::rdExponential ( double  mean)
109 {
111  m_mean = mean;
112  m_min = 0.0;
113  m_max = 0.0;
114  m_bMinLimit = false;
115  m_bMaxLimit = false;
116 }
double m_max
Definition: HttpRandom.h:149
bool m_bMinLimit
Definition: HttpRandom.h:150
Definition: HttpRandom.h:33
double m_min
Definition: HttpRandom.h:148
double m_mean
Definition: HttpRandom.h:147
bool m_bMaxLimit
Definition: HttpRandom.h:151
DISTR_TYPE m_type
Definition: HttpRandom.h:49
inet::httptools::rdExponential::rdExponential ( cXMLAttributeMap  attributes)
119 {
121 
122  if (!_hasKey(attributes, "mean"))
123  throw "Undefined parameter for random distribution. Mean must be defined for an exponential distribution";
124  m_mean = atof(attributes["mean"].c_str());
125 
126  m_min = 0.0;
127  m_max = 0.0;
128  m_bMinLimit = _hasKey(attributes, "min");
129  m_bMaxLimit = _hasKey(attributes, "max");
130  if (m_bMinLimit)
131  m_min = atof(attributes["min"].c_str());
132  if (m_bMaxLimit)
133  m_max = atof(attributes["max"].c_str());
134 }
double m_max
Definition: HttpRandom.h:149
bool m_bMinLimit
Definition: HttpRandom.h:150
Definition: HttpRandom.h:33
double m_min
Definition: HttpRandom.h:148
double m_mean
Definition: HttpRandom.h:147
bool m_bMaxLimit
Definition: HttpRandom.h:151
DISTR_TYPE m_type
Definition: HttpRandom.h:49
bool _hasKey(cXMLAttributeMap attributes, std::string key)
Definition: HttpRandom.h:52

Member Function Documentation

double inet::httptools::rdExponential::draw ( )
overridevirtual

Implements inet::httptools::rdObject.

137 {
138  double val;
139  do
140  val = RNGCONTEXT exponential(m_mean);
141  while ((m_bMinLimit && val < m_min) || (m_bMaxLimit && val > m_max));
142  return val;
143 }
double m_max
Definition: HttpRandom.h:149
bool m_bMinLimit
Definition: HttpRandom.h:150
double m_min
Definition: HttpRandom.h:148
#define RNGCONTEXT
Definition: INETDefs.h:85
double m_mean
Definition: HttpRandom.h:147
bool m_bMaxLimit
Definition: HttpRandom.h:151
void inet::httptools::rdExponential::resetMaxLimit ( )
inline
174 { m_bMaxLimit = false; }
bool m_bMaxLimit
Definition: HttpRandom.h:151
void inet::httptools::rdExponential::resetMinLimit ( )
inline
172 { m_bMinLimit = false; }
bool m_bMinLimit
Definition: HttpRandom.h:150
void inet::httptools::rdExponential::setMaxLimit ( double  max)
inline
173 { m_max = max; m_bMaxLimit = true; }
double m_max
Definition: HttpRandom.h:149
double max(double a, double b)
Returns the greater of the given parameters.
Definition: INETMath.h:161
bool m_bMaxLimit
Definition: HttpRandom.h:151
void inet::httptools::rdExponential::setMinLimit ( double  min)
inline
171 { m_min = min; m_bMinLimit = true; }
bool m_bMinLimit
Definition: HttpRandom.h:150
double min(const double a, const double b)
Returns the minimum of a and b.
Definition: SCTPAssociation.h:270
double m_min
Definition: HttpRandom.h:148

Member Data Documentation

bool inet::httptools::rdExponential::m_bMaxLimit = false
protected
bool inet::httptools::rdExponential::m_bMinLimit = false
protected
double inet::httptools::rdExponential::m_max = NaN
protected
double inet::httptools::rdExponential::m_mean = NaN
protected
double inet::httptools::rdExponential::m_min = NaN
protected

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