MSDevice_HBEFA Class Reference

#include <MSDevice_HBEFA.h>

Inheritance diagram for MSDevice_HBEFA:

MSDevice

Detailed Description

A device which collects vehicular emissions (using HBEFA-reformulation).

Each device collects the vehicular emissions / fuel consumption by being called each time step, computing the current values using HelpersHBEFA, and aggregating them into internal storages over the whol journey.

See also:
MSDevice

HelpersHBEFA

Definition at line 61 of file MSDevice_HBEFA.h.


Public Member Functions

MSVehiclegetHolder () const throw ()
 Returns the vehicle that holds this device.
const std::string & getID () throw ()
 Returns the id of this device.
void tripInfoOutput (OutputDevice &os) const throw (IOError)
 Called on writing tripinfo output.
SUMOTime wrappedComputeCommandExecute (SUMOTime currentTime) throw (ProcessError)
 Performs rerouting after a period.
Methods called on vehicle movement / state change, overwriting MSDevice
void enterLaneAtEmit (MSLane *enteredLane, const MSVehicle::State &state)
 Computes a new route on vehicle emission.
Methods called on vehicle movement / state change
virtual void enterLaneAtLaneChange (MSLane *enteredLane)
 Update of members if vehicle enters a new lane in the laneChange step.
virtual void enterLaneAtMove (MSLane *enteredLane, SUMOReal driven)
 Update if vehicle enters a new lane in the move step.
virtual void leaveLane ()
 Update of members if vehicle leaves a new lane in the lane change step.
virtual void leaveLaneAtMove (SUMOReal driven)
 Update of members if vehicle leaves a new lane in the move step.
virtual void onRemovalFromNet ()
 Called when the vehicle leaves the lane.
virtual void onTryEmit ()
 Called when the vehicle tries to get into the net.

Static Public Member Functions

static void buildVehicleDevices (MSVehicle &v, std::vector< MSDevice * > &into) throw ()
 Build devices for the given vehicle, if needed.
static void insertOptions () throw ()
 Inserts MSDevice_HBEFA-options.

Protected Attributes

MSVehiclemyHolder
 The vehicle that stores the device.

Private Member Functions

 MSDevice_HBEFA (const MSDevice_HBEFA &)
 Invalidated copy constructor.
 MSDevice_HBEFA (MSVehicle &holder, const std::string &id) throw ()
 Constructor.
MSDevice_HBEFAoperator= (const MSDevice_HBEFA &)
 Invalidated assignment operator.
 ~MSDevice_HBEFA () throw ()
 Destructor.

Private Attributes

WrappingCommand< MSDevice_HBEFA > * myComputeAndCollectCommand
 The (optional) command responsible for rerouting.
Internal storages for pollutant/fuel sum
SUMOReal myCO
SUMOReal myCO2
SUMOReal myFuel
SUMOReal myHC
SUMOReal myNOx
SUMOReal myPMx

Static Private Attributes

static int myVehicleIndex = 0
 A static vehicle index for computing deterministic vehicle fractions.

Constructor & Destructor Documentation

MSDevice_HBEFA::MSDevice_HBEFA ( MSVehicle holder,
const std::string &  id 
) throw () [private]

Constructor.

Parameters:
[in] holder The vehicle that holds this device
[in] id The ID of the device

Definition at line 100 of file MSDevice_HBEFA.cpp.

Referenced by buildVehicleDevices().

00101         : MSDevice(holder, id), myComputeAndCollectCommand(0),
00102         myCO2(0), myCO(0), myHC(0), myPMx(0), myNOx(0), myFuel(0) {
00103 }

MSDevice_HBEFA::~MSDevice_HBEFA (  )  throw () [private]

Destructor.

Definition at line 106 of file MSDevice_HBEFA.cpp.

References WrappingCommand< T >::deschedule(), and myComputeAndCollectCommand.

00106                                         {
00107     // make the rerouting command invalid
00108     if (myComputeAndCollectCommand!=0) {
00109         myComputeAndCollectCommand->deschedule();
00110     }
00111 }

MSDevice_HBEFA::MSDevice_HBEFA ( const MSDevice_HBEFA  )  [private]

Invalidated copy constructor.


Member Function Documentation

void MSDevice_HBEFA::buildVehicleDevices ( MSVehicle v,
std::vector< MSDevice * > &  into 
) throw () [static]

Build devices for the given vehicle, if needed.

The options are read and evaluated whether hbefa-devices shall be built for the given vehicle.

When the first device is built, the static container of edge weights used for routing is initialised with the mean speed the edges allow. In addition, an event is generated which updates these weights is built and added to the list of events to execute at a simulation end.

For each seen vehicle, the global vehicle index is increased.

The built device is stored in the given vector.

Parameters:
[in] v The vehicle for which a device may be built
in,filled] into The vector to store the built device in

Definition at line 74 of file MSDevice_HBEFA.cpp.

References OptionsCont::getBool(), OptionsCont::getFloat(), OptionsCont::getOptions(), OptionsCont::isInStringVector(), OptionsCont::isSet(), MSDevice_HBEFA(), myVehicleIndex, and RandHelper::rand().

Referenced by MSVehicle::MSVehicle().

00074                                                                                     {
00075     OptionsCont &oc = OptionsCont::getOptions();
00076     if (oc.getFloat("device.hbefa.probability")==0&&!oc.isSet("device.hbefa.knownveh")) {
00077         // no route computation is modelled
00078         return;
00079     }
00080     // route computation is enabled
00081     bool haveByNumber = false;
00082     if (oc.getBool("device.hbefa.deterministic")) {
00083         haveByNumber = ((myVehicleIndex%1000) < (int)(oc.getFloat("device.hbefa.probability")*1000.));
00084     } else {
00085         haveByNumber = RandHelper::rand()<=oc.getFloat("device.hbefa.probability");
00086     }
00087     bool haveByName = oc.isSet("device.hbefa.knownveh") && OptionsCont::getOptions().isInStringVector("device.hbefa.knownveh", v.getID());
00088     if (haveByNumber||haveByName) {
00089         // build the device
00090         MSDevice_HBEFA* device = new MSDevice_HBEFA(v, "hbefa_" + v.getID());
00091         into.push_back(device);
00092     }
00093     myVehicleIndex++;
00094 }

void MSDevice_HBEFA::enterLaneAtEmit ( MSLane enteredLane,
const MSVehicle::State state 
) [virtual]

Computes a new route on vehicle emission.

An event is created and added to the list of simulation step end events which executes "wrappedComputeCommandExecute".

Parameters:
[in] enteredLane The lane the vehicle enters
[in] state The vehicle's state during the emission
See also:
MSVehicle::reroute

MSEventHandler

WrappingCommand

Reimplemented from MSDevice.

Definition at line 115 of file MSDevice_HBEFA.cpp.

References MSEventControl::ADAPT_AFTER_EXECUTION, MSEventControl::addEvent(), MSNet::getEndOfTimestepEvents(), MSNet::getInstance(), myComputeAndCollectCommand, and wrappedComputeCommandExecute().

virtual void MSDevice::enterLaneAtLaneChange ( MSLane enteredLane  )  [inline, virtual, inherited]

Update of members if vehicle enters a new lane in the laneChange step.

Parameters:
[in] enteredLane The lane the vehicle enters

Definition at line 121 of file MSDevice.h.

00121 { }

virtual void MSDevice::enterLaneAtMove ( MSLane enteredLane,
SUMOReal  driven 
) [inline, virtual, inherited]

Update if vehicle enters a new lane in the move step.

Parameters:
[in] enteredLane The lane the vehicle enters
[in] driven The distance driven by the vehicle within this time step

Definition at line 106 of file MSDevice.h.

00106 { }

MSVehicle& MSDevice::getHolder (  )  const throw () [inline, inherited]

Returns the vehicle that holds this device.

Returns:
The vehicle that holds this device

Definition at line 81 of file MSDevice.h.

References MSDevice::myHolder.

Referenced by wrappedComputeCommandExecute().

00081                                          {
00082         return myHolder;
00083     }

const std::string& MSDevice::getID (  )  throw () [inline, inherited]

Returns the id of this device.

Returns:
The device's ID

Definition at line 89 of file MSDevice.h.

References MSDevice::myID.

00089                                      {
00090         return myID;
00091     }

void MSDevice_HBEFA::insertOptions (  )  throw () [static]

Inserts MSDevice_HBEFA-options.

!! describe

!! describe

!! describe

Definition at line 56 of file MSDevice_HBEFA.cpp.

References OptionsCont::addDescription(), OptionsCont::addOptionSubTopic(), OptionsCont::doRegister(), OptionsCont::getOptions(), and myVehicleIndex.

Referenced by MSFrame::fillOptions().

00056                                       {
00057     OptionsCont &oc = OptionsCont::getOptions();
00058     oc.addOptionSubTopic("Emissions");
00059 
00060     oc.doRegister("device.hbefa.probability", new Option_Float(0.));
00061     oc.addDescription("device.hbefa.probability", "Emissions", "The probability for a vehicle to have an emission logging device");
00062 
00063     oc.doRegister("device.hbefa.knownveh", new Option_String());
00064     oc.addDescription("device.hbefa.knownveh", "Emissions", "Assign a device to named vehicles");
00065 
00066     oc.doRegister("device.hbefa.deterministic", new Option_Bool(false)); 
00067     oc.addDescription("device.hbefa.deterministic", "Emissions", "The devices are set deterministic using a fraction of 1000");
00068 
00069     myVehicleIndex = 0;
00070 }

virtual void MSDevice::leaveLane (  )  [inline, virtual, inherited]

Update of members if vehicle leaves a new lane in the lane change step.

Definition at line 132 of file MSDevice.h.

00132 { }

virtual void MSDevice::leaveLaneAtMove ( SUMOReal  driven  )  [inline, virtual, inherited]

Update of members if vehicle leaves a new lane in the move step.

Parameters:
[in] driven The distance driven by the vehicle within this time step

Definition at line 128 of file MSDevice.h.

00128 { }

virtual void MSDevice::onRemovalFromNet (  )  [inline, virtual, inherited]

Called when the vehicle leaves the lane.

Definition at line 136 of file MSDevice.h.

00136 { }

virtual void MSDevice::onTryEmit (  )  [inline, virtual, inherited]

Called when the vehicle tries to get into the net.

Reimplemented in MSDevice_Routing.

Definition at line 98 of file MSDevice.h.

00098 { }

MSDevice_HBEFA& MSDevice_HBEFA::operator= ( const MSDevice_HBEFA  )  [private]

Invalidated assignment operator.

void MSDevice_HBEFA::tripInfoOutput ( OutputDevice os  )  const throw (IOError) [virtual]

Called on writing tripinfo output.

Parameters:
[in] os The stream to write the information into
Exceptions:
IOError not yet implemented
See also:
MSDevice::tripInfoOutput

Reimplemented from MSDevice.

Definition at line 145 of file MSDevice_HBEFA.cpp.

References myCO, myCO2, myFuel, myHC, myNOx, and myPMx.

00145                                                                     {
00146     os << resetiosflags(std::ios::floatfield);
00147     (os.openTag("emissions") <<
00148      " CO_abs=\"" << myCO <<
00149      "\" CO2_abs=\"" << myCO2 <<
00150      "\" HC_abs=\"" << myHC <<
00151      "\" PMx_abs=\""<< myPMx <<
00152      "\" NOx_abs=\""<< myNOx <<
00153      "\" fuel_abs=\""<< myFuel <<
00154      "\"").closeTag(true);
00155     os<<setiosflags(std::ios::fixed);
00156 }

SUMOTime MSDevice_HBEFA::wrappedComputeCommandExecute ( SUMOTime  currentTime  )  throw (ProcessError)

Performs rerouting after a period.

The current amounts of emitted pollutants / consumed fuel is computed using the according methods from "HelpersHBEFA" and are added to the internal sums.

This method is called from the event handler at the end of a simulation step.

Parameters:
[in] currentTime The current simulation time
Returns:
Always 1 (for being computed in the next step)
See also:
HelpersHBEFA

MSEventHandler

WrappingCommand

Definition at line 127 of file MSDevice_HBEFA.cpp.

References HelpersHBEFA::computeCO(), HelpersHBEFA::computeCO2(), HelpersHBEFA::computeFuel(), HelpersHBEFA::computeHC(), HelpersHBEFA::computeNOx(), HelpersHBEFA::computePMx(), DELTA_T, MSVehicleType::getEmissionClass(), MSDevice::getHolder(), MSVehicle::getPreDawdleAcceleration(), MSVehicle::getSpeed(), MSVehicle::getVehicleType(), myCO, myCO2, myFuel, myHC, myNOx, myPMx, and SUMOReal.

Referenced by enterLaneAtEmit().

00127                                                                                      {
00128     if (!getHolder().isOnRoad()) {
00129         return 1;
00130     }
00131     SUMOEmissionClass c = getHolder().getVehicleType().getEmissionClass();
00132     SUMOReal v = getHolder().getSpeed();
00133     SUMOReal a = getHolder().getPreDawdleAcceleration();
00134     myCO2 += HelpersHBEFA::computeCO2(c, v, a);
00135     myCO += HelpersHBEFA::computeCO(c, v, a);
00136     myHC += HelpersHBEFA::computeHC(c, v, a);
00137     myPMx += HelpersHBEFA::computePMx(c, v, a);
00138     myNOx += HelpersHBEFA::computeNOx(c, v, a);
00139     myFuel += HelpersHBEFA::computeFuel(c, v, a);
00140     return DELTA_T;
00141 }


Field Documentation

SUMOReal MSDevice_HBEFA::myCO [private]

Definition at line 158 of file MSDevice_HBEFA.h.

Referenced by tripInfoOutput(), and wrappedComputeCommandExecute().

SUMOReal MSDevice_HBEFA::myCO2 [private]

Definition at line 158 of file MSDevice_HBEFA.h.

Referenced by tripInfoOutput(), and wrappedComputeCommandExecute().

The (optional) command responsible for rerouting.

Definition at line 153 of file MSDevice_HBEFA.h.

Referenced by enterLaneAtEmit(), and ~MSDevice_HBEFA().

SUMOReal MSDevice_HBEFA::myFuel [private]

Definition at line 158 of file MSDevice_HBEFA.h.

Referenced by tripInfoOutput(), and wrappedComputeCommandExecute().

SUMOReal MSDevice_HBEFA::myHC [private]

Definition at line 158 of file MSDevice_HBEFA.h.

Referenced by tripInfoOutput(), and wrappedComputeCommandExecute().

MSVehicle& MSDevice::myHolder [protected, inherited]

SUMOReal MSDevice_HBEFA::myNOx [private]

Definition at line 158 of file MSDevice_HBEFA.h.

Referenced by tripInfoOutput(), and wrappedComputeCommandExecute().

SUMOReal MSDevice_HBEFA::myPMx [private]

Definition at line 158 of file MSDevice_HBEFA.h.

Referenced by tripInfoOutput(), and wrappedComputeCommandExecute().

int MSDevice_HBEFA::myVehicleIndex = 0 [static, private]

A static vehicle index for computing deterministic vehicle fractions.

Definition at line 150 of file MSDevice_HBEFA.h.

Referenced by buildVehicleDevices(), and insertOptions().


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

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