RODFDetectorFlows Class Reference

#include <RODFDetectorFlow.h>


Detailed Description

A container for flows.

Definition at line 72 of file RODFDetectorFlow.h.


Public Member Functions

void addFlow (const std::string &detector_id, int timestamp, const FlowDef &fd)
const std::vector< FlowDef > & getFlowDefs (const std::string &id) const
SUMOReal getFlowSumSecure (const std::string &id) const
SUMOReal getMaxDetectorFlow () const
bool knows (const std::string &det_id, SUMOTime time) const
bool knows (const std::string &det_id) const
void mesoJoin (const std::string &nid, const std::vector< std::string > &oldids)
void printAbsolute () const
void removeFlow (const std::string &detector_id)
 RODFDetectorFlows (SUMOTime startTime, SUMOTime endTime, SUMOTime stepOffset)
void setFlows (const std::string &detector_id, std::vector< FlowDef > &)
 ~RODFDetectorFlows ()

Protected Attributes

SUMOTime myBeginTime
SUMOTime myEndTime
std::map< std::string,
std::vector< FlowDef > > 
myFastAccessFlows
SUMOReal myMaxDetectorFlow
SUMOTime myStepOffset

Private Member Functions

RODFDetectorFlowsoperator= (const RODFDetectorFlows &src)
 Invalidated assignment operator.
 RODFDetectorFlows (const RODFDetectorFlows &src)
 Invalidated copy constructor.

Constructor & Destructor Documentation

RODFDetectorFlows::RODFDetectorFlows ( SUMOTime  startTime,
SUMOTime  endTime,
SUMOTime  stepOffset 
)

Definition at line 42 of file RODFDetectorFlow.cpp.

00044         : myBeginTime(startTime), myEndTime(endTime), myStepOffset(stepOffset),
00045         myMaxDetectorFlow(-1) {}

RODFDetectorFlows::~RODFDetectorFlows (  ) 

Definition at line 48 of file RODFDetectorFlow.cpp.

00048 {}

RODFDetectorFlows::RODFDetectorFlows ( const RODFDetectorFlows src  )  [private]

Invalidated copy constructor.


Member Function Documentation

void RODFDetectorFlows::addFlow ( const std::string &  detector_id,
int  timestamp,
const FlowDef fd 
)

Definition at line 52 of file RODFDetectorFlow.cpp.

References FlowDef::firstSet, FlowDef::fLKW, FlowDef::isLKW, myBeginTime, myEndTime, myFastAccessFlows, myStepOffset, FlowDef::qLKW, FlowDef::qPKW, size, FlowDef::vLKW, and FlowDef::vPKW.

Referenced by mesoJoin(), and RODFDetFlowLoader::read().

00052                                                                         {
00053     if (myFastAccessFlows.find(id)==myFastAccessFlows.end()) {
00054         size_t noItems = (size_t)((myEndTime-myBeginTime)/myStepOffset);
00055         myFastAccessFlows[id] = std::vector<FlowDef>(noItems);
00056         std::vector<FlowDef> &cflows = myFastAccessFlows.find(id)->second;
00057         // initialise
00058         for (std::vector<FlowDef>::iterator i=cflows.begin(); i<cflows.end(); ++i) {
00059             (*i).qPKW = 0;
00060             (*i).qLKW = 0;
00061             (*i).vPKW = 0;
00062             (*i).vLKW = 0;
00063             (*i).fLKW = 0;
00064             (*i).isLKW = 0;
00065             (*i).firstSet = true;
00066         }
00067     }
00068     assert(t<(int) myFastAccessFlows[id].size());
00069     FlowDef &ofd = myFastAccessFlows[id][t];
00070     if (ofd.firstSet) {
00071         ofd = fd;
00072         ofd.firstSet = false;
00073     } else {
00074         ofd.qLKW = ofd.qLKW + fd.qLKW;
00075         ofd.qPKW = ofd.qPKW + fd.qPKW;
00076         ofd.vLKW = ofd.vLKW + fd.vLKW;
00077         ofd.vPKW = ofd.vPKW + fd.vPKW;
00078     }
00079     if (ofd.qLKW!=0 && ofd.qPKW!=0) {
00080         ofd.fLKW = ofd.qLKW / ofd.qPKW ;
00081     } else if (ofd.qPKW!=0) {
00082         ofd.fLKW = 0;
00083     } else {
00084         ofd.fLKW = 1;
00085         ofd.isLKW = 1;
00086     }
00087 }

const std::vector< FlowDef > & RODFDetectorFlows::getFlowDefs ( const std::string &  id  )  const

SUMOReal RODFDetectorFlows::getFlowSumSecure ( const std::string &  id  )  const

Definition at line 139 of file RODFDetectorFlow.cpp.

References getFlowDefs(), knows(), and SUMOReal.

Referenced by RODFDetectorCon::writeEmitterPOIs().

00139                                                              {
00140     SUMOReal ret = 0;
00141     if (knows(id)) {
00142         const std::vector<FlowDef> &flows = getFlowDefs(id);
00143         for (std::vector<FlowDef>::const_iterator i=flows.begin(); i!=flows.end(); ++i) {
00144             ret += (*i).qPKW;
00145             ret += (*i).qLKW;
00146         }
00147     }
00148     return ret;
00149 }

SUMOReal RODFDetectorFlows::getMaxDetectorFlow (  )  const

Definition at line 153 of file RODFDetectorFlow.cpp.

References max, myFastAccessFlows, myMaxDetectorFlow, and SUMOReal.

Referenced by RODFDetectorCon::writeEmitterPOIs().

00153                                             {
00154     if (myMaxDetectorFlow<0) {
00155         SUMOReal max = 0;
00156         std::map<std::string, std::vector<FlowDef> >::const_iterator j;
00157         for (j=myFastAccessFlows.begin(); j!=myFastAccessFlows.end(); ++j) {
00158             SUMOReal curr = 0;
00159             const std::vector<FlowDef> &flows = (*j).second;
00160             for (std::vector<FlowDef>::const_iterator i=flows.begin(); i!=flows.end(); ++i) {
00161                 curr += (*i).qPKW;
00162                 curr += (*i).qLKW;
00163             }
00164             if (max<curr) {
00165                 max = curr;
00166             }
00167         }
00168         myMaxDetectorFlow = max;
00169     }
00170     return myMaxDetectorFlow;
00171 }

bool RODFDetectorFlows::knows ( const std::string &  det_id,
SUMOTime  time 
) const

!!

Definition at line 122 of file RODFDetectorFlow.cpp.

References myFastAccessFlows.

00122                                                                          {
00123     if (myFastAccessFlows.find(det_id)==myFastAccessFlows.end()) {
00124         return false;
00125     }
00126     return true;
00127 }

bool RODFDetectorFlows::knows ( const std::string &  det_id  )  const

void RODFDetectorFlows::mesoJoin ( const std::string &  nid,
const std::vector< std::string > &  oldids 
)

Definition at line 175 of file RODFDetectorFlow.cpp.

References addFlow(), knows(), myBeginTime, myEndTime, myFastAccessFlows, and myStepOffset.

Referenced by RODFNet::mesoJoin().

00176                                                                 {
00177     for (std::vector<std::string>::const_iterator i=oldids.begin(); i!=oldids.end(); ++i) {
00178         if (!knows(*i)) {
00179             continue;
00180         }
00181         std::map<std::string, std::vector<FlowDef> >::iterator j = myFastAccessFlows.find(*i);
00182         std::vector<FlowDef> &flows = (*j).second;
00183         size_t index = 0;
00184         for (SUMOTime t=myBeginTime; t!=myEndTime; t+=myStepOffset) {
00185             addFlow(nid, t/myStepOffset, flows[index++]); // !!!
00186         }
00187         myFastAccessFlows.erase(j);
00188     }
00189 }

RODFDetectorFlows& RODFDetectorFlows::operator= ( const RODFDetectorFlows src  )  [private]

Invalidated assignment operator.

void RODFDetectorFlows::printAbsolute (  )  const

Definition at line 193 of file RODFDetectorFlow.cpp.

References myFastAccessFlows, and SUMOReal.

Referenced by startComputation().

00193                                        {
00194     for (std::map<std::string, std::vector<FlowDef> >::const_iterator i=myFastAccessFlows.begin(); i!=myFastAccessFlows.end(); ++i) {
00195         std::cout << (*i).first << ":";
00196         const std::vector<FlowDef> &flows = (*i).second;
00197         SUMOReal qPKW = 0;
00198         SUMOReal qLKW = 0;
00199         for (std::vector<FlowDef>::const_iterator j=flows.begin(); j!=flows.end(); ++j) {
00200             qPKW += (*j).qPKW;
00201             qLKW += (*j).qLKW;
00202         }
00203         std::cout << qPKW << "/" << qLKW << std::endl;
00204     }
00205 }

void RODFDetectorFlows::removeFlow ( const std::string &  detector_id  ) 

Definition at line 108 of file RODFDetectorFlow.cpp.

References myFastAccessFlows.

Referenced by RODFNet::removeEmptyDetectors().

00108                                                           {
00109     if (myFastAccessFlows.find(detector_id)!=myFastAccessFlows.end()) {
00110         myFastAccessFlows.erase(myFastAccessFlows.find(detector_id));
00111     }
00112 }

void RODFDetectorFlows::setFlows ( const std::string &  detector_id,
std::vector< FlowDef > &  flows 
)

Definition at line 93 of file RODFDetectorFlow.cpp.

References FlowDef::fLKW, myFastAccessFlows, FlowDef::qLKW, and FlowDef::qPKW.

Referenced by RODFNet::revalidateFlows().

00094                                                        {
00095     for (std::vector<FlowDef>::iterator i=flows.begin(); i<flows.end(); ++i) {
00096         FlowDef &ofd = *i;
00097         if (ofd.qLKW!=0 && ofd.qPKW!=0) {
00098             ofd.fLKW = ofd.qLKW / ofd.qPKW ;
00099         } else {
00100             ofd.fLKW = 0;
00101         }
00102     }
00103     myFastAccessFlows[detector_id] = flows;
00104 }


Field Documentation

Definition at line 93 of file RODFDetectorFlow.h.

Referenced by addFlow(), and mesoJoin().

Definition at line 93 of file RODFDetectorFlow.h.

Referenced by addFlow(), and mesoJoin().

std::map<std::string, std::vector<FlowDef> > RODFDetectorFlows::myFastAccessFlows [protected]

SUMOReal RODFDetectorFlows::myMaxDetectorFlow [mutable, protected]

Definition at line 94 of file RODFDetectorFlow.h.

Referenced by getMaxDetectorFlow().

Definition at line 93 of file RODFDetectorFlow.h.

Referenced by addFlow(), and mesoJoin().


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

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