RORDGenerator_ODAmounts::FlowDef Class Reference

#include <RORDGenerator_ODAmounts.h>


Detailed Description

The definition of a flow.

Definition at line 117 of file RORDGenerator_ODAmounts.h.


Public Member Functions

void addRoutes (RONet &net, SUMOTime time)
 Adds routes to start within the given time into the given net.
void addSingleRoute (RONet &net, SUMOTime time)
 Adds a single route to start within the given time into the given net.
bool applicableForTime (SUMOTime time) const
 Returns the information whether this flow includes the given time.
 FlowDef (ROVehicle *vehicle, SUMOVTypeParameter *type, RORouteDef *route, SUMOTime intBegin, SUMOTime intEnd, unsigned int vehicles2Emit, bool randomize)
 Constructor.
SUMOTime getIntervalEnd () const
 Returns the end of the period this FlowDef describes.
 ~FlowDef ()
 Destructor.

Private Attributes

std::vector< SUMOTimemyDepartures
 The list of generated departure times in the case randomized departures are used.
unsigned int myEmitted
 The number of vehicles already emitted.
SUMOTime myIntervalBegin
 The begin of the described interval.
SUMOTime myIntervalEnd
 The end of the described interval.
bool myRandom
 Information whether randomized departures are used.
RORouteDefmyRoute
 (description of) the route to use
ROVehiclemyVehicle
 (description of) the vehicle to emit
unsigned int myVehicle2EmitNumber
 The number of vehicles to emit within the described interval.
SUMOVTypeParametermyVehicleType
 (description of) the vehicle type to use

Constructor & Destructor Documentation

RORDGenerator_ODAmounts::FlowDef::FlowDef ( ROVehicle vehicle,
SUMOVTypeParameter type,
RORouteDef route,
SUMOTime  intBegin,
SUMOTime  intEnd,
unsigned int  vehicles2Emit,
bool  randomize 
)

Constructor.

Definition at line 60 of file RORDGenerator_ODAmounts.cpp.

References DELTA_T, myDepartures, myIntervalBegin, myIntervalEnd, myRandom, myVehicle2EmitNumber, and RandHelper::rand().

00067         : myVehicle(vehicle), myVehicleType(type), myRoute(route),
00068         myIntervalBegin(intBegin), myIntervalEnd(intEnd),
00069         myVehicle2EmitNumber(vehicles2Emit), myEmitted(0), myRandom(randomize) {
00070     assert(myIntervalBegin<myIntervalEnd);
00071     if (myRandom) {
00072         SUMOTime period = myIntervalEnd - myIntervalBegin;
00073         myDepartures.reserve(myVehicle2EmitNumber);
00074         for (size_t i=0; i<myVehicle2EmitNumber; ++i) {
00075             SUMOTime departure = ((int)(RandHelper::rand(period) / DELTA_T)) * DELTA_T;
00076             myDepartures.push_back(departure);
00077         }
00078         sort(myDepartures.begin(), myDepartures.end());
00079         reverse(myDepartures.begin(), myDepartures.end());
00080     }
00081 }

RORDGenerator_ODAmounts::FlowDef::~FlowDef (  ) 

Destructor.

Definition at line 84 of file RORDGenerator_ODAmounts.cpp.

References myVehicle.

00084                                          {
00085     delete myVehicle;
00086 }


Member Function Documentation

void RORDGenerator_ODAmounts::FlowDef::addRoutes ( RONet net,
SUMOTime  time 
)

Adds routes to start within the given time into the given net.

Definition at line 96 of file RORDGenerator_ODAmounts.cpp.

References addSingleRoute(), DELTA_T, myDepartures, myEmitted, myIntervalBegin, myIntervalEnd, myRandom, myVehicle2EmitNumber, and SUMOReal.

Referenced by RORDGenerator_ODAmounts::buildForTimeStep().

00096                                                                 {
00097     assert(myIntervalBegin<=t&&myIntervalEnd>=t);
00098     //
00099     if (!myRandom) {
00100         unsigned int absPerEachStep = myVehicle2EmitNumber / ((myIntervalEnd-myIntervalBegin) / DELTA_T);
00101         for (unsigned int i=0; i<absPerEachStep; i++) {
00102             addSingleRoute(net, t);
00103         }
00104         // fraction
00105         SUMOReal toEmit = (SUMOReal) myVehicle2EmitNumber / (SUMOReal)(myIntervalEnd-myIntervalBegin) * (SUMOReal)(t-myIntervalBegin+(SUMOReal)DELTA_T/2.);
00106         if (toEmit>myEmitted) {
00107             addSingleRoute(net, t);
00108         }
00109     } else {
00110         while (myDepartures.size()>0&&*(myDepartures.end()-1)<t+DELTA_T) {
00111             addSingleRoute(net, t);
00112             myDepartures.pop_back();
00113         }
00114     }
00115 }

void RORDGenerator_ODAmounts::FlowDef::addSingleRoute ( RONet net,
SUMOTime  time 
)

Adds a single route to start within the given time into the given net.

Definition at line 119 of file RORDGenerator_ODAmounts.cpp.

References RONet::addRouteDef(), RONet::addVehicle(), ROVehicle::copy(), RORouteDef::copy(), ROVehicle::getID(), myEmitted, myRoute, and myVehicle.

Referenced by addRoutes().

00119                                                                      {
00120     std::string id = myVehicle->getID() + "_" + toString<unsigned int>(myEmitted);
00121     RORouteDef *rd = myRoute->copy(id);
00122     net.addRouteDef(rd);
00123     ROVehicle *veh = myVehicle->copy(id, t, rd);
00124     net.addVehicle(id, veh);
00125     myEmitted++;
00126 }

bool RORDGenerator_ODAmounts::FlowDef::applicableForTime ( SUMOTime  time  )  const

Returns the information whether this flow includes the given time.

Definition at line 90 of file RORDGenerator_ODAmounts.cpp.

Referenced by RORDGenerator_ODAmounts::buildForTimeStep().

00090                                                                   {
00091     return myIntervalBegin<=t&&myIntervalEnd>t;
00092 }

SUMOTime RORDGenerator_ODAmounts::FlowDef::getIntervalEnd (  )  const

Returns the end of the period this FlowDef describes.

Definition at line 130 of file RORDGenerator_ODAmounts.cpp.

References myIntervalEnd.

Referenced by RORDGenerator_ODAmounts::buildForTimeStep().

00130                                                      {
00131     return myIntervalEnd;
00132 }


Field Documentation

The list of generated departure times in the case randomized departures are used.

Definition at line 162 of file RORDGenerator_ODAmounts.h.

Referenced by addRoutes(), and FlowDef().

The number of vehicles already emitted.

Definition at line 159 of file RORDGenerator_ODAmounts.h.

Referenced by addRoutes(), and addSingleRoute().

The begin of the described interval.

Definition at line 150 of file RORDGenerator_ODAmounts.h.

Referenced by addRoutes(), and FlowDef().

The end of the described interval.

Definition at line 153 of file RORDGenerator_ODAmounts.h.

Referenced by addRoutes(), FlowDef(), and getIntervalEnd().

Information whether randomized departures are used.

Definition at line 165 of file RORDGenerator_ODAmounts.h.

Referenced by addRoutes(), and FlowDef().

(description of) the route to use

Definition at line 147 of file RORDGenerator_ODAmounts.h.

Referenced by addSingleRoute().

(description of) the vehicle to emit

Definition at line 141 of file RORDGenerator_ODAmounts.h.

Referenced by addSingleRoute(), and ~FlowDef().

The number of vehicles to emit within the described interval.

Definition at line 156 of file RORDGenerator_ODAmounts.h.

Referenced by addRoutes(), and FlowDef().

(description of) the vehicle type to use

Definition at line 144 of file RORDGenerator_ODAmounts.h.


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

Generated on Wed May 5 00:07:00 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6