diff --git a/src/core/model/random-variable-stream.cc b/src/core/model/random-variable-stream.cc index e8ce8e44a..9099f3012 100644 --- a/src/core/model/random-variable-stream.cc +++ b/src/core/model/random-variable-stream.cc @@ -86,7 +86,6 @@ RandomVariableStream::RandomVariableStream() RandomVariableStream::~RandomVariableStream() { - NS_LOG_FUNCTION(this); delete m_rng; } @@ -100,15 +99,16 @@ RandomVariableStream::SetAntithetic(bool isAntithetic) bool RandomVariableStream::IsAntithetic() const { - NS_LOG_FUNCTION(this); return m_isAntithetic; } uint32_t RandomVariableStream::GetInteger() { - NS_LOG_FUNCTION(this); - return static_cast(GetValue()); + auto value = static_cast(GetValue()); + NS_LOG_DEBUG(GetInstanceTypeId().GetName() + << " integer value: " << value << " stream: " << GetStream()); + return value; } void @@ -124,6 +124,7 @@ RandomVariableStream::SetStream(int64_t stream) // number assignment. uint64_t nextStream = RngSeedManager::GetNextStreamIndex(); NS_ASSERT(nextStream <= ((1ULL) << 63)); + NS_LOG_INFO(GetInstanceTypeId().GetName() << " automatic stream: " << nextStream); m_rng = new RngStream(RngSeedManager::GetSeed(), nextStream, RngSeedManager::GetRun()); } else @@ -132,6 +133,7 @@ RandomVariableStream::SetStream(int64_t stream) // number assignment. uint64_t base = ((1ULL) << 63); uint64_t target = base + stream; + NS_LOG_INFO(GetInstanceTypeId().GetName() << " configured stream: " << stream); m_rng = new RngStream(RngSeedManager::GetSeed(), target, RngSeedManager::GetRun()); } m_stream = stream; @@ -140,14 +142,12 @@ RandomVariableStream::SetStream(int64_t stream) int64_t RandomVariableStream::GetStream() const { - NS_LOG_FUNCTION(this); return m_stream; } RngStream* RandomVariableStream::Peek() const { - NS_LOG_FUNCTION(this); return m_rng; } @@ -183,49 +183,50 @@ UniformRandomVariable::UniformRandomVariable() double UniformRandomVariable::GetMin() const { - NS_LOG_FUNCTION(this); return m_min; } double UniformRandomVariable::GetMax() const { - NS_LOG_FUNCTION(this); return m_max; } double UniformRandomVariable::GetValue(double min, double max) { - NS_LOG_FUNCTION(this << min << max); double v = min + Peek()->RandU01() * (max - min); if (IsAntithetic()) { v = min + (max - v); } + NS_LOG_DEBUG("value: " << v << " stream: " << GetStream() << " min: " << min + << " max: " << max); return v; } uint32_t UniformRandomVariable::GetInteger(uint32_t min, uint32_t max) { - NS_LOG_FUNCTION(this << min << max); NS_ASSERT(min <= max); - return static_cast(GetValue((double)(min), (double)(max) + 1.0)); + auto v = static_cast(GetValue((double)(min), (double)(max) + 1.0)); + NS_LOG_DEBUG("integer value: " << v << " stream: " << GetStream() << " min: " << min << " max " + << max); + return v; } double UniformRandomVariable::GetValue() { - NS_LOG_FUNCTION(this); return GetValue(m_min, m_max); } uint32_t UniformRandomVariable::GetInteger() { - NS_LOG_FUNCTION(this); - return static_cast(GetValue(m_min, m_max + 1)); + auto v = static_cast(GetValue(m_min, m_max + 1)); + NS_LOG_DEBUG("integer value: " << v << " stream: " << GetStream()); + return v; } NS_OBJECT_ENSURE_REGISTERED(ConstantRandomVariable); @@ -261,21 +262,20 @@ ConstantRandomVariable::GetConstant() const double ConstantRandomVariable::GetValue(double constant) { - NS_LOG_FUNCTION(this << constant); + NS_LOG_DEBUG("value: " << constant << " stream: " << GetStream()); return constant; } uint32_t ConstantRandomVariable::GetInteger(uint32_t constant) { - NS_LOG_FUNCTION(this << constant); + NS_LOG_DEBUG("integer value: " << constant << " stream: " << GetStream()); return constant; } double ConstantRandomVariable::GetValue() { - NS_LOG_FUNCTION(this); return GetValue(m_constant); } @@ -325,28 +325,24 @@ SequentialRandomVariable::SequentialRandomVariable() double SequentialRandomVariable::GetMin() const { - NS_LOG_FUNCTION(this); return m_min; } double SequentialRandomVariable::GetMax() const { - NS_LOG_FUNCTION(this); return m_max; } Ptr SequentialRandomVariable::GetIncrement() const { - NS_LOG_FUNCTION(this); return m_increment; } uint32_t SequentialRandomVariable::GetConsecutive() const { - NS_LOG_FUNCTION(this); return m_consecutive; } @@ -354,7 +350,6 @@ double SequentialRandomVariable::GetValue() { // Set the current sequence value if it hasn't been set. - NS_LOG_FUNCTION(this); if (!m_isCurrentSet) { // Start the sequence at its minimum value. @@ -373,6 +368,7 @@ SequentialRandomVariable::GetValue() m_current = m_min + (m_current - m_max); } } + NS_LOG_DEBUG("value: " << r << " stream: " << GetStream()); return r; } @@ -408,21 +404,18 @@ ExponentialRandomVariable::ExponentialRandomVariable() double ExponentialRandomVariable::GetMean() const { - NS_LOG_FUNCTION(this); return m_mean; } double ExponentialRandomVariable::GetBound() const { - NS_LOG_FUNCTION(this); return m_bound; } double ExponentialRandomVariable::GetValue(double mean, double bound) { - NS_LOG_FUNCTION(this << mean << bound); while (true) { // Get a uniform random variable in [0,1]. @@ -438,6 +431,8 @@ ExponentialRandomVariable::GetValue(double mean, double bound) // Use this value if it's acceptable. if (bound == 0 || r <= bound) { + NS_LOG_DEBUG("value: " << r << " stream: " << GetStream() << " mean: " << mean + << " bound: " << bound); return r; } } @@ -447,13 +442,15 @@ uint32_t ExponentialRandomVariable::GetInteger(uint32_t mean, uint32_t bound) { NS_LOG_FUNCTION(this << mean << bound); - return static_cast(GetValue(mean, bound)); + auto v = static_cast(GetValue(mean, bound)); + NS_LOG_DEBUG("integer value: " << v << " stream: " << GetStream() << " mean: " << mean + << " bound: " << bound); + return v; } double ExponentialRandomVariable::GetValue() { - NS_LOG_FUNCTION(this); return GetValue(m_mean, m_bound); } @@ -498,30 +495,24 @@ ParetoRandomVariable::ParetoRandomVariable() double ParetoRandomVariable::GetScale() const { - NS_LOG_FUNCTION(this); return m_scale; } double ParetoRandomVariable::GetShape() const { - NS_LOG_FUNCTION(this); return m_shape; } double ParetoRandomVariable::GetBound() const { - NS_LOG_FUNCTION(this); return m_bound; } double ParetoRandomVariable::GetValue(double scale, double shape, double bound) { - // Calculate the scale parameter. - NS_LOG_FUNCTION(this << scale << shape << bound); - while (true) { // Get a uniform random variable in [0,1]. @@ -537,6 +528,8 @@ ParetoRandomVariable::GetValue(double scale, double shape, double bound) // Use this value if it's acceptable. if (bound == 0 || r <= bound) { + NS_LOG_DEBUG("value: " << r << " stream: " << GetStream() << " scale: " << scale + << " shape: " << shape << " bound: " << bound); return r; } } @@ -545,14 +538,15 @@ ParetoRandomVariable::GetValue(double scale, double shape, double bound) uint32_t ParetoRandomVariable::GetInteger(uint32_t scale, uint32_t shape, uint32_t bound) { - NS_LOG_FUNCTION(this << scale << shape << bound); - return static_cast(GetValue(scale, shape, bound)); + auto v = static_cast(GetValue(scale, shape, bound)); + NS_LOG_DEBUG("integer value: " << v << " stream: " << GetStream() << " scale: " << scale + << " shape: " << shape << " bound: " << bound); + return v; } double ParetoRandomVariable::GetValue() { - NS_LOG_FUNCTION(this); return GetValue(m_scale, m_shape, m_bound); } @@ -596,21 +590,18 @@ WeibullRandomVariable::WeibullRandomVariable() double WeibullRandomVariable::GetScale() const { - NS_LOG_FUNCTION(this); return m_scale; } double WeibullRandomVariable::GetShape() const { - NS_LOG_FUNCTION(this); return m_shape; } double WeibullRandomVariable::GetBound() const { - NS_LOG_FUNCTION(this); return m_bound; } @@ -631,7 +622,6 @@ WeibullRandomVariable::GetMean() const double WeibullRandomVariable::GetValue(double scale, double shape, double bound) { - NS_LOG_FUNCTION(this << scale << shape << bound); double exponent = 1.0 / shape; while (true) { @@ -648,6 +638,8 @@ WeibullRandomVariable::GetValue(double scale, double shape, double bound) // Use this value if it's acceptable. if (bound == 0 || r <= bound) { + NS_LOG_DEBUG("value: " << r << " stream: " << GetStream() << " scale: " << scale + << " shape: " << shape << " bound: " << bound); return r; } } @@ -656,8 +648,10 @@ WeibullRandomVariable::GetValue(double scale, double shape, double bound) uint32_t WeibullRandomVariable::GetInteger(uint32_t scale, uint32_t shape, uint32_t bound) { - NS_LOG_FUNCTION(this << scale << shape << bound); - return static_cast(GetValue(scale, shape, bound)); + auto v = static_cast(GetValue(scale, shape, bound)); + NS_LOG_DEBUG("integer value: " << v << " stream: " << GetStream() << " scale: " << scale + << " shape: " << shape << " bound: " << bound); + return v; } double @@ -709,34 +703,32 @@ NormalRandomVariable::NormalRandomVariable() double NormalRandomVariable::GetMean() const { - NS_LOG_FUNCTION(this); return m_mean; } double NormalRandomVariable::GetVariance() const { - NS_LOG_FUNCTION(this); return m_variance; } double NormalRandomVariable::GetBound() const { - NS_LOG_FUNCTION(this); return m_bound; } double NormalRandomVariable::GetValue(double mean, double variance, double bound) { - NS_LOG_FUNCTION(this << mean << variance << bound); if (m_nextValid) { // use previously generated m_nextValid = false; double x2 = mean + m_v2 * m_y * std::sqrt(variance); if (std::fabs(x2 - mean) <= bound) { + NS_LOG_DEBUG("value: " << x2 << " stream: " << GetStream() << " mean: " << mean + << " variance: " << variance << " bound: " << bound); return x2; } } @@ -764,6 +756,8 @@ NormalRandomVariable::GetValue(double mean, double variance, double bound) m_nextValid = true; m_y = y; m_v2 = v2; + NS_LOG_DEBUG("value: " << x1 << " stream: " << GetStream() << " mean: " << mean + << " variance: " << variance << " bound: " << bound); return x1; } // otherwise try and return the other if it is valid @@ -771,6 +765,8 @@ NormalRandomVariable::GetValue(double mean, double variance, double bound) if (std::fabs(x2 - mean) <= bound) { m_nextValid = false; + NS_LOG_DEBUG("value: " << x2 << " stream: " << GetStream() << " mean: " << mean + << " variance: " << variance << " bound: " << bound); return x2; } // otherwise, just run this loop again @@ -781,14 +777,15 @@ NormalRandomVariable::GetValue(double mean, double variance, double bound) uint32_t NormalRandomVariable::GetInteger(uint32_t mean, uint32_t variance, uint32_t bound) { - NS_LOG_FUNCTION(this << mean << variance << bound); - return static_cast(GetValue(mean, variance, bound)); + auto v = static_cast(GetValue(mean, variance, bound)); + NS_LOG_DEBUG("integer value: " << v << " stream: " << GetStream() << " mean: " << mean + << " variance: " << variance << " bound: " << bound); + return v; } double NormalRandomVariable::GetValue() { - NS_LOG_FUNCTION(this); return GetValue(m_mean, m_variance, m_bound); } @@ -828,14 +825,12 @@ LogNormalRandomVariable::LogNormalRandomVariable() double LogNormalRandomVariable::GetMu() const { - NS_LOG_FUNCTION(this); return m_mu; } double LogNormalRandomVariable::GetSigma() const { - NS_LOG_FUNCTION(this); return m_sigma; } @@ -871,9 +866,10 @@ LogNormalRandomVariable::GetValue(double mu, double sigma) if (m_nextValid) { // use previously generated m_nextValid = false; - double normal = m_v2 * m_normal; - - return std::exp(sigma * normal + mu); + double v = std::exp(sigma * m_v2 * m_normal + mu); + NS_LOG_DEBUG("value: " << v << " stream: " << GetStream() << " mu: " << mu + << " sigma: " << sigma); + return v; } double v1; @@ -882,8 +878,6 @@ LogNormalRandomVariable::GetValue(double mu, double sigma) double normal; double x; - NS_LOG_FUNCTION(this << mu << sigma); - do { /* choose x,y in uniform square (-1,-1) to (+1,+1) */ @@ -909,6 +903,8 @@ LogNormalRandomVariable::GetValue(double mu, double sigma) m_v2 = v2; x = std::exp(sigma * normal + mu); + NS_LOG_DEBUG("value: " << x << " stream: " << GetStream() << " mu: " << mu + << " sigma: " << sigma); return x; } @@ -916,14 +912,15 @@ LogNormalRandomVariable::GetValue(double mu, double sigma) uint32_t LogNormalRandomVariable::GetInteger(uint32_t mu, uint32_t sigma) { - NS_LOG_FUNCTION(this << mu << sigma); - return static_cast(GetValue(mu, sigma)); + auto v = static_cast(GetValue(mu, sigma)); + NS_LOG_DEBUG("integer value: " << v << " stream: " << GetStream() << " mu: " << mu + << " sigma: " << sigma); + return v; } double LogNormalRandomVariable::GetValue() { - NS_LOG_FUNCTION(this); return GetValue(m_mu, m_sigma); } @@ -961,14 +958,12 @@ GammaRandomVariable::GammaRandomVariable() double GammaRandomVariable::GetAlpha() const { - NS_LOG_FUNCTION(this); return m_alpha; } double GammaRandomVariable::GetBeta() const { - NS_LOG_FUNCTION(this); return m_beta; } @@ -991,7 +986,6 @@ GammaRandomVariable::GetBeta() const double GammaRandomVariable::GetValue(double alpha, double beta) { - NS_LOG_FUNCTION(this << alpha << beta); if (alpha < 1) { double u = Peek()->RandU01(); @@ -999,6 +993,9 @@ GammaRandomVariable::GetValue(double alpha, double beta) { u = (1 - u); } + double v = GetValue(1.0 + alpha, beta) * std::pow(u, 1.0 / alpha); + NS_LOG_DEBUG("value: " << v << " stream: " << GetStream() << " alpha: " << alpha + << " beta: " << beta); return GetValue(1.0 + alpha, beta) * std::pow(u, 1.0 / alpha); } @@ -1038,26 +1035,29 @@ GammaRandomVariable::GetValue(double alpha, double beta) } } - return beta * d * v; + double value = beta * d * v; + NS_LOG_DEBUG("value: " << value << " stream: " << GetStream() << " alpha: " << alpha + << " beta: " << beta); + return value; } double GammaRandomVariable::GetValue() { - NS_LOG_FUNCTION(this); return GetValue(m_alpha, m_beta); } double GammaRandomVariable::GetNormalValue(double mean, double variance, double bound) { - NS_LOG_FUNCTION(this << mean << variance << bound); if (m_nextValid) { // use previously generated m_nextValid = false; double x2 = mean + m_v2 * m_y * std::sqrt(variance); if (std::fabs(x2 - mean) <= bound) { + NS_LOG_DEBUG("value: " << x2 << " stream: " << GetStream() << " mean: " << mean + << " variance: " << variance << " bound: " << bound); return x2; } } @@ -1085,6 +1085,8 @@ GammaRandomVariable::GetNormalValue(double mean, double variance, double bound) m_nextValid = true; m_y = y; m_v2 = v2; + NS_LOG_DEBUG("value: " << x1 << " stream: " << GetStream() << " mean: " << mean + << " variance: " << variance << " bound: " << bound); return x1; } // otherwise try and return the other if it is valid @@ -1092,6 +1094,8 @@ GammaRandomVariable::GetNormalValue(double mean, double variance, double bound) if (std::fabs(x2 - mean) <= bound) { m_nextValid = false; + NS_LOG_DEBUG("value: " << x2 << " stream: " << GetStream() << " mean: " << mean + << " variance: " << variance << " bound: " << bound); return x2; } // otherwise, just run this loop again @@ -1132,14 +1136,12 @@ ErlangRandomVariable::ErlangRandomVariable() uint32_t ErlangRandomVariable::GetK() const { - NS_LOG_FUNCTION(this); return m_k; } double ErlangRandomVariable::GetLambda() const { - NS_LOG_FUNCTION(this); return m_lambda; } @@ -1158,7 +1160,6 @@ ErlangRandomVariable::GetLambda() const double ErlangRandomVariable::GetValue(uint32_t k, double lambda) { - NS_LOG_FUNCTION(this << k << lambda); double mean = lambda; double bound = 0.0; @@ -1167,28 +1168,29 @@ ErlangRandomVariable::GetValue(uint32_t k, double lambda) { result += GetExponentialValue(mean, bound); } - + NS_LOG_DEBUG("value: " << result << " stream: " << GetStream() << " k: " << k + << " lambda: " << lambda); return result; } uint32_t ErlangRandomVariable::GetInteger(uint32_t k, uint32_t lambda) { - NS_LOG_FUNCTION(this << k << lambda); - return static_cast(GetValue(k, lambda)); + auto v = static_cast(GetValue(k, lambda)); + NS_LOG_DEBUG("integer value: " << v << " stream: " << GetStream() << " k: " << k + << " lambda: " << lambda); + return v; } double ErlangRandomVariable::GetValue() { - NS_LOG_FUNCTION(this); return GetValue(m_k, m_lambda); } double ErlangRandomVariable::GetExponentialValue(double mean, double bound) { - NS_LOG_FUNCTION(this << mean << bound); while (true) { // Get a uniform random variable in [0,1]. @@ -1204,6 +1206,8 @@ ErlangRandomVariable::GetExponentialValue(double mean, double bound) // Use this value if it's acceptable. if (bound == 0 || r <= bound) { + NS_LOG_DEBUG("value: " << r << " stream: " << GetStream() << " mean:: " << mean + << " bound: " << bound); return r; } } @@ -1248,21 +1252,18 @@ TriangularRandomVariable::TriangularRandomVariable() double TriangularRandomVariable::GetMean() const { - NS_LOG_FUNCTION(this); return m_mean; } double TriangularRandomVariable::GetMin() const { - NS_LOG_FUNCTION(this); return m_min; } double TriangularRandomVariable::GetMax() const { - NS_LOG_FUNCTION(this); return m_max; } @@ -1270,7 +1271,6 @@ double TriangularRandomVariable::GetValue(double mean, double min, double max) { // Calculate the mode. - NS_LOG_FUNCTION(this << mean << min << max); double mode = 3.0 * mean - min - max; // Get a uniform random variable in [0,1]. @@ -1283,25 +1283,32 @@ TriangularRandomVariable::GetValue(double mean, double min, double max) // Calculate the triangular random variable. if (u <= (mode - min) / (max - min)) { - return min + std::sqrt(u * (max - min) * (mode - min)); + double v = min + std::sqrt(u * (max - min) * (mode - min)); + NS_LOG_DEBUG("value: " << v << " stream: " << GetStream() << " mean: " << mean + << " min: " << min << " max: " << max); + return v; } else { - return max - std::sqrt((1 - u) * (max - min) * (max - mode)); + double v = max - std::sqrt((1 - u) * (max - min) * (max - mode)); + NS_LOG_DEBUG("value: " << v << " stream: " << GetStream() << " mean: " << mean + << " min: " << min << " max: " << max); + return v; } } uint32_t TriangularRandomVariable::GetInteger(uint32_t mean, uint32_t min, uint32_t max) { - NS_LOG_FUNCTION(this << mean << min << max); - return static_cast(GetValue(mean, min, max)); + auto v = static_cast(GetValue(mean, min, max)); + NS_LOG_DEBUG("integer value: " << v << " stream: " << GetStream() << " mean: " << mean + << " min: " << min << " max: " << max); + return v; } double TriangularRandomVariable::GetValue() { - NS_LOG_FUNCTION(this); return GetValue(m_mean, m_min, m_max); } @@ -1337,21 +1344,18 @@ ZipfRandomVariable::ZipfRandomVariable() uint32_t ZipfRandomVariable::GetN() const { - NS_LOG_FUNCTION(this); return m_n; } double ZipfRandomVariable::GetAlpha() const { - NS_LOG_FUNCTION(this); return m_alpha; } double ZipfRandomVariable::GetValue(uint32_t n, double alpha) { - NS_LOG_FUNCTION(this << n << alpha); // Calculate the normalization constant c. m_c = 0.0; for (uint32_t i = 1; i <= n; i++) @@ -1378,6 +1382,8 @@ ZipfRandomVariable::GetValue(uint32_t n, double alpha) break; } } + NS_LOG_DEBUG("value: " << zipf_value << " stream: " << GetStream() << " n: " << n + << " alpha: " << alpha); return zipf_value; } @@ -1385,13 +1391,15 @@ uint32_t ZipfRandomVariable::GetInteger(uint32_t n, uint32_t alpha) { NS_LOG_FUNCTION(this << n << alpha); - return static_cast(GetValue(n, alpha)); + auto v = static_cast(GetValue(n, alpha)); + NS_LOG_DEBUG("integer value: " << v << " stream: " << GetStream() << " n: " << n + << " alpha: " << alpha); + return v; } double ZipfRandomVariable::GetValue() { - NS_LOG_FUNCTION(this); return GetValue(m_n, m_alpha); } @@ -1422,14 +1430,12 @@ ZetaRandomVariable::ZetaRandomVariable() double ZetaRandomVariable::GetAlpha() const { - NS_LOG_FUNCTION(this); return m_alpha; } double ZetaRandomVariable::GetValue(double alpha) { - NS_LOG_FUNCTION(this << alpha); m_b = std::pow(2.0, alpha - 1.0); double u; @@ -1458,21 +1464,21 @@ ZetaRandomVariable::GetValue(double alpha) T = std::pow(1.0 + 1.0 / X, m_alpha - 1.0); test = v * X * (T - 1.0) / (m_b - 1.0); } while (test > (T / m_b)); - + NS_LOG_DEBUG("value: " << X << " stream: " << GetStream() << " alpha: " << alpha); return X; } uint32_t ZetaRandomVariable::GetInteger(uint32_t alpha) { - NS_LOG_FUNCTION(this << alpha); - return static_cast(GetValue(alpha)); + auto v = static_cast(GetValue(alpha)); + NS_LOG_DEBUG("integer value: " << v << " stream: " << GetStream() << " alpha: " << alpha); + return v; } double ZetaRandomVariable::GetValue() { - NS_LOG_FUNCTION(this); return GetValue(m_alpha); } @@ -1537,7 +1543,6 @@ DeterministicRandomVariable::SetValueArray(const double* values, std::size_t len double DeterministicRandomVariable::GetValue() { - NS_LOG_FUNCTION(this); // Make sure the array has been set. NS_ASSERT(m_count > 0); @@ -1545,7 +1550,9 @@ DeterministicRandomVariable::GetValue() { m_next = 0; } - return m_data[m_next++]; + double v = m_data[m_next++]; + NS_LOG_DEBUG("value: " << v << " stream: " << GetStream()); + return v; } NS_OBJECT_ENSURE_REGISTERED(EmpiricalRandomVariable); @@ -1585,8 +1592,7 @@ EmpiricalRandomVariable::SetInterpolate(bool interpolate) bool EmpiricalRandomVariable::PreSample(double& value) { - NS_LOG_FUNCTION(this); - + NS_LOG_FUNCTION(this << value); if (!m_validated) { Validate(); @@ -1618,8 +1624,6 @@ EmpiricalRandomVariable::PreSample(double& value) double EmpiricalRandomVariable::GetValue() { - NS_LOG_FUNCTION(this); - double value; if (PreSample(value)) { @@ -1635,6 +1639,7 @@ EmpiricalRandomVariable::GetValue() { value = DoSampleCDF(value); } + NS_LOG_DEBUG("value: " << value << " stream: " << GetStream()); return value; } @@ -1786,8 +1791,6 @@ BinomialRandomVariable::BinomialRandomVariable() double BinomialRandomVariable::GetValue(uint32_t trials, double probability) { - NS_LOG_FUNCTION(this << trials << probability); - double successes = 0; for (uint32_t i = 0; i < trials; ++i) @@ -1803,21 +1806,23 @@ BinomialRandomVariable::GetValue(uint32_t trials, double probability) successes += 1; } } - + NS_LOG_DEBUG("value: " << successes << " stream: " << GetStream() << " trials: " << trials + << " probability: " << probability); return successes; } uint32_t BinomialRandomVariable::GetInteger(uint32_t trials, uint32_t probability) { - NS_LOG_FUNCTION(this << trials << probability); - return static_cast(GetValue(trials, probability)); + auto v = static_cast(GetValue(trials, probability)); + NS_LOG_DEBUG("integer value: " << v << " stream: " << GetStream() << " trials: " << trials + << " probability: " << probability); + return v; } double BinomialRandomVariable::GetValue() { - NS_LOG_FUNCTION(this); return GetValue(m_trials, m_probability); } @@ -1848,28 +1853,30 @@ BernoulliRandomVariable::BernoulliRandomVariable() double BernoulliRandomVariable::GetValue(double probability) { - NS_LOG_FUNCTION(this << probability); - double v = Peek()->RandU01(); if (IsAntithetic()) { v = (1 - v); } - return (v <= probability) ? 1.0 : 0.0; + double value = (v <= probability) ? 1.0 : 0.0; + NS_LOG_DEBUG("value: " << value << " stream: " << GetStream() + << " probability: " << probability); + return value; } uint32_t BernoulliRandomVariable::GetInteger(uint32_t probability) { - NS_LOG_FUNCTION(this << probability); - return static_cast(GetValue(probability)); + auto v = static_cast(GetValue(probability)); + NS_LOG_DEBUG("integer value: " << v << " stream: " << GetStream() + << " probability: " << probability); + return v; } double BernoulliRandomVariable::GetValue() { - NS_LOG_FUNCTION(this); return GetValue(m_probability); }