User Manual, Developers Guide and API Documentation

wns::distribution::TimeDependent Class Reference

Configurable Distrubitions over time. More...

#include <distribution/TimeDependent.hpp>

Inheritance diagram for wns::distribution::TimeDependent:

Inheritance graph
[legend]
Collaboration diagram for wns::distribution::TimeDependent:

Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual double operator() ()
 Draw value from current Distribution.
virtual std::string paramString () const
 returns a string describing distribution and parameters
 TimeDependent (wns::rng::RNGen *rng, const wns::pyconfig::View &view)
 pyconfig::View Constructor with RNGen
 TimeDependent (const wns::pyconfig::View &view)
 pyconfig::View Constructor
virtual ~TimeDependent ()
 Destructor.

Private Types

typedef std::map< simTimeType,
DistributionEvent
EventContainer

Private Member Functions

void init ()
void queueNextDistribution ()
 Queue Event to create next Distribution (if events left).
void removeDistribution ()
 Deletes a Distribution and sets pointer to NULL.
void setDistribution (const wns::pyconfig::View &distConfig)
 Set new distribution according to pyconfig::View.

Private Attributes

wns::pyconfig::View config_
Distributiondistribution_
 Current distribution.
EventContainer events_
 Stores events with new distributions.

Classes

class  DistributionEvent
 Carries the View to create new Distribution from. More...


Detailed Description

Author:
Marc Schinnenburg <msg@comnets.rwth-aachen.de>
This class can be configured to change it's distribution over the time.

The class works as follows: It reads a list of Events from the pyconfig::View. The Events will be queued into the EventContainer "events". Each event holds a configuration for a distribution. At the time the event will be executed, it will set a new distribution in this class.

Here are two examples. One for configuration:

import openwns.distributio
dist = openwns.distribution.TimeDependent()
dist.eventList.append(openwns.distribution.Event(0.0, openwns.distribution.Fixed(47)))
dist.eventList.append(openwns.distribution.Event(2.0, openwns.distribution.Fixed(11)))
dist.eventList.append(openwns.distribution.Event(5.0, openwns.distribution.Fixed(8)))
dist.eventList.append(openwns.distribution.Event(11.0, openwns.distribution.Fixed(15)))

This will create values like this:

    |
    |
 47-|----|
    |    |
    |    |
 15-|    |                                 |---------------------
    |    |                                 |
 11-|    |---------|                       |
    |    |         |                       |
 8 -|    |         |-----------------------|
 ___|____|_________|_______________________|_____________________
    |    |         |                       |                   (t)
         2         5                       11

Usage in C++:

TimeDependent t(config.get("dist"));
WNS_ASSERT_MAX_REL_ERROR(47.0, t(), 1E-6);

wns::simulator::getEventScheduler()->processOneEvent();
WNS_ASSERT_MAX_REL_ERROR(11.0, t(), 1E-6);
WNS_ASSERT_MAX_REL_ERROR(simTimeType(2.0), wns::simulator::getEventScheduler()->getTime(), 1E-6);

wns::simulator::getEventScheduler()->processOneEvent();
WNS_ASSERT_MAX_REL_ERROR(8.0, t(), 1E-6);
WNS_ASSERT_MAX_REL_ERROR(simTimeType(5.0), wns::simulator::getEventScheduler()->getTime(), 1E-6);

wns::simulator::getEventScheduler()->processOneEvent();
WNS_ASSERT_MAX_REL_ERROR(15.0, t(), 1E-6);
WNS_ASSERT_MAX_REL_ERROR(simTimeType(11.0), wns::simulator::getEventScheduler()->getTime(), 1E-6);

Definition at line 75 of file TimeDependent.hpp.


Member Typedef Documentation

Definition at line 110 of file TimeDependent.hpp.


Constructor & Destructor Documentation

TimeDependent::TimeDependent ( const wns::pyconfig::View view  )  [explicit]

Definition at line 70 of file TimeDependent.cpp.

TimeDependent::TimeDependent ( wns::rng::RNGen rng,
const wns::pyconfig::View view 
) [explicit]

Definition at line 79 of file TimeDependent.cpp.

TimeDependent::~TimeDependent (  )  [virtual]

Definition at line 114 of file TimeDependent.cpp.


Member Function Documentation

void TimeDependent::init (  )  [private]

Definition at line 89 of file TimeDependent.cpp.

double TimeDependent::operator() (  )  [virtual]

Implements wns::distribution::Distribution.

Definition at line 120 of file TimeDependent.cpp.

std::string TimeDependent::paramString (  )  const [virtual]

Implements wns::distribution::Distribution.

Definition at line 127 of file TimeDependent.cpp.

void TimeDependent::queueNextDistribution (  )  [private]

Definition at line 135 of file TimeDependent.cpp.

void TimeDependent::removeDistribution (  )  [private]

Definition at line 155 of file TimeDependent.cpp.

void TimeDependent::setDistribution ( const wns::pyconfig::View distConfig  )  [private]

Definition at line 146 of file TimeDependent.cpp.


Member Data Documentation

Definition at line 172 of file TimeDependent.hpp.

Definition at line 162 of file TimeDependent.hpp.

Definition at line 170 of file TimeDependent.hpp.


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

Generated on Sat May 26 03:32:53 2012 for openWNS by  doxygen 1.5.5