From 211ac8141e2e3d2c6d63533af1f9b7d1774b0b92 Mon Sep 17 00:00:00 2001 From: Benjamin BOUVIER Date: Fri, 7 Sep 2012 11:37:21 -0400 Subject: [PATCH] MPI Distrib exp: added exponential distribution --- eo/test/mpi/t-mpi-distrib-exp.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/eo/test/mpi/t-mpi-distrib-exp.cpp b/eo/test/mpi/t-mpi-distrib-exp.cpp index 72e934e52..bfee3d9fe 100644 --- a/eo/test/mpi/t-mpi-distrib-exp.cpp +++ b/eo/test/mpi/t-mpi-distrib-exp.cpp @@ -130,6 +130,33 @@ class NormalDistribution : public Distribution double _stddev; } normalDistribution; +class ExponentialDistribution : public Distribution +{ + public: + + ExponentialDistribution() : _rng( 0 ) + { + // empty + } + + void make_parser( eoParser & parser ) + { + _active = parser.createParam( false, "exponential", "Exponential distribution", '\0', "Exponential").value(); + _mean = parser.createParam( 0.0, "exponential-mean", "Mean for the exponential distribution (0 by default), in ms.", '\0', "Exponential").value(); + } + + int next_element() + { + return std::floor( _rng.negexp( _mean ) ); + } + + protected: + + eoRng _rng; + double _mean; + +} exponentialDistribution; + int main( int argc, char** argv ) { Node::init( argc, argv ); @@ -142,6 +169,7 @@ int main( int argc, char** argv ) std::vector distribs; distribs.push_back( &uniformDistribution ); distribs.push_back( &normalDistribution ); + distribs.push_back( &exponentialDistribution ); // for each available distribution, check if activated. // If no distribution is activated, show an error message