DijkstraRouterEffort_ByProxi< E, V, PF, EC > Class Template Reference

#include <DijkstraRouterEffort.h>

Inheritance diagram for DijkstraRouterEffort_ByProxi< E, V, PF, EC >:

DijkstraRouterEffortBase< E, V, PF > SUMOAbstractRouter< E, V > PF

Detailed Description

template<class E, class V, class PF, class EC>
class DijkstraRouterEffort_ByProxi< E, V, PF, EC >

Definition at line 233 of file DijkstraRouterEffort.h.


Public Types

typedef SUMOReal(EC::* Operation )(const E *const, const V *const, SUMOReal) const
 Type of the function that is used to retrieve the edge effort.

Public Member Functions

void buildPathFrom (EdgeInfo *rbegin, std::vector< const E * > &edges)
 Builds the path from marked edges.
virtual void compute (const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E * > &into)
 Builds the route between the given edges using the minimum afford at the given time The definition of the afford depends on the wished routing scheme.
 DijkstraRouterEffort_ByProxi (size_t noE, bool unbuildIsWarningOnly, EC *receiver, Operation effortOperation, Operation ttOperation)
SUMOReal getEffort (const E *const e, const V *const v, SUMOReal t)
SUMOReal getTravelTime (const E *const e, const V *const v, SUMOReal t)
SUMOReal recomputeCosts (const std::vector< const E * > &edges, const V *const v, SUMOTime msTime) throw ()

Protected Attributes

EdgeInfoByEffortComparator myComparator
std::vector< EdgeInfomyEdgeInfos
 The container of edge information.
std::vector< EdgeInfo * > myFrontierList
 A container for reusage of the min edge heap.
bool myUnbuildIsWarningOnly

Private Attributes

Operation myEffortOperation
 The object's operation to perform for obtaining the effort.
EC * myReceiver
 The object the action is directed to.
Operation myTTOperation
 The object's operation to perform for obtaining the travel time.

Member Typedef Documentation

template<class E, class V, class PF, class EC>
typedef SUMOReal(EC::* DijkstraRouterEffort_ByProxi< E, V, PF, EC >::Operation)(const E *const, const V *const, SUMOReal) const

Type of the function that is used to retrieve the edge effort.


Constructor & Destructor Documentation

template<class E, class V, class PF, class EC>
DijkstraRouterEffort_ByProxi< E, V, PF, EC >::DijkstraRouterEffort_ByProxi ( size_t  noE,
bool  unbuildIsWarningOnly,
EC *  receiver,
Operation  effortOperation,
Operation  ttOperation 
) [inline]

Definition at line 238 of file DijkstraRouterEffort.h.

00239             : DijkstraRouterEffortBase<E, V, PF>(noE, unbuildIsWarningOnly),
00240             myReceiver(receiver), myEffortOperation(effortOperation), myTTOperation(ttOperation) {}


Member Function Documentation

template<class E, class V, class PF>
void DijkstraRouterEffortBase< E, V, PF >::buildPathFrom ( EdgeInfo rbegin,
std::vector< const E * > &  edges 
) [inline, inherited]

Builds the path from marked edges.

Definition at line 209 of file DijkstraRouterEffort.h.

References DijkstraRouterEffortBase< E, V, PF >::EdgeInfo::edge, and DijkstraRouterEffortBase< E, V, PF >::EdgeInfo::prev.

Referenced by DijkstraRouterEffortBase< E, V, PF >::compute().

00209                                                                       {
00210         std::deque<const E*> tmp;
00211         while (rbegin!=0) {
00212             tmp.push_front((E *) rbegin->edge); // !!!
00213             rbegin = rbegin->prev;
00214         }
00215         std::copy(tmp.begin(), tmp.end(), std::back_inserter(edges));
00216     }

template<class E, class V, class PF>
virtual void DijkstraRouterEffortBase< E, V, PF >::compute ( const E *  from,
const E *  to,
const V *const   vehicle,
SUMOTime  msTime,
std::vector< const E * > &  into 
) [inline, virtual, inherited]

Builds the route between the given edges using the minimum afford at the given time The definition of the afford depends on the wished routing scheme.

Implements SUMOAbstractRouter< E, V >.

Definition at line 128 of file DijkstraRouterEffort.h.

References DijkstraRouterEffortBase< E, V, PF >::buildPathFrom(), DijkstraRouterEffortBase< E, V, PF >::EdgeInfo::edge, DijkstraRouterEffortBase< E, V, PF >::EdgeInfo::effort, DijkstraRouterEffortBase< E, V, PF >::getEffort(), MsgHandler::getErrorInstance(), DijkstraRouterEffortBase< E, V, PF >::getTravelTime(), MsgHandler::inform(), DijkstraRouterEffortBase< E, V, PF >::EdgeInfo::leaveTime, max, DijkstraRouterEffortBase< E, V, PF >::myComparator, DijkstraRouterEffortBase< E, V, PF >::myEdgeInfos, DijkstraRouterEffortBase< E, V, PF >::myFrontierList, DijkstraRouterEffortBase< E, V, PF >::myUnbuildIsWarningOnly, DijkstraRouterEffortBase< E, V, PF >::EdgeInfo::prev, SUMOReal, DijkstraRouterEffortBase< E, V, PF >::EdgeInfo::visited, and WRITE_WARNING.

00129                                                                      {
00130 
00131         SUMOReal time = (SUMOReal) msTime / 1000.;
00132         for (typename std::vector<EdgeInfo>::iterator i=myEdgeInfos.begin(); i!=myEdgeInfos.end(); i++) {
00133             (*i).effort = std::numeric_limits<SUMOReal>::max();
00134             (*i).visited = false;
00135         }
00136         assert(from!=0&&to!=0);
00137         myFrontierList.clear();
00138         // add begin node
00139         EdgeInfo* const fromInfo = &(myEdgeInfos[from->getNumericalID()]);
00140         fromInfo->effort = 0;
00141         fromInfo->prev = 0;
00142         fromInfo->leaveTime = (SUMOReal) time;
00143         myFrontierList.push_back(fromInfo);
00144         // loop
00145         while (!myFrontierList.empty()) {
00146             // use the node with the minimal length
00147             EdgeInfo * const minimumInfo = myFrontierList.front();
00148             const E * const minEdge = minimumInfo->edge;
00149             pop_heap(myFrontierList.begin(), myFrontierList.end(), myComparator);
00150             myFrontierList.pop_back();
00151             // check whether the destination node was already reached
00152             if (minEdge == to) {
00153                 buildPathFrom(minimumInfo, into);
00154                 return;
00155             }
00156             minimumInfo->visited = true;
00157             const SUMOReal effort = minimumInfo->effort + getEffort(minEdge, vehicle, (SUMOTime) minimumInfo->leaveTime);
00158             const SUMOReal leaveTime = minimumInfo->leaveTime + getTravelTime(minEdge, vehicle, (SUMOTime)minimumInfo->leaveTime);
00159             // check all ways from the node with the minimal length
00160             unsigned int i = 0;
00161             unsigned int length_size = minEdge->getNoFollowing();
00162             for (i=0; i<length_size; i++) {
00163                 const E* const follower = minEdge->getFollower(i);
00164                 EdgeInfo* const followerInfo = &(myEdgeInfos[follower->getNumericalID()]);
00165                 // check whether it can be used
00166                 if (PF::operator()(follower, vehicle)) {
00167                     continue;
00168                 }
00169                 const SUMOReal oldEffort = followerInfo->effort;
00170                 if (!followerInfo->visited && effort < oldEffort) {
00171                     followerInfo->effort = effort;
00172                     followerInfo->leaveTime = leaveTime;
00173                     followerInfo->prev = minimumInfo;
00174                     if (oldEffort == std::numeric_limits<SUMOReal>::max()) {
00175                         myFrontierList.push_back(followerInfo);
00176                         push_heap(myFrontierList.begin(), myFrontierList.end(), myComparator);
00177                     } else {
00178                         push_heap(myFrontierList.begin(),
00179                                   find(myFrontierList.begin(), myFrontierList.end(), followerInfo) + 1,
00180                                   myComparator);
00181                     }
00182                 }
00183             }
00184         }
00185         if (!myUnbuildIsWarningOnly) {
00186             MsgHandler::getErrorInstance()->inform("No connection between '" + from->getID() + "' and '" + to->getID() + "' found.");
00187         } else {
00188             WRITE_WARNING("No connection between '" + from->getID() + "' and '" + to->getID() + "' found.");
00189         }
00190     }

template<class E, class V, class PF, class EC>
SUMOReal DijkstraRouterEffort_ByProxi< E, V, PF, EC >::getEffort ( const E *const   e,
const V *const   v,
SUMOReal  t 
) [inline, virtual]

template<class E, class V, class PF, class EC>
SUMOReal DijkstraRouterEffort_ByProxi< E, V, PF, EC >::getTravelTime ( const E *const   e,
const V *const   v,
SUMOReal  t 
) [inline, virtual]

template<class E, class V, class PF>
SUMOReal DijkstraRouterEffortBase< E, V, PF >::recomputeCosts ( const std::vector< const E * > &  edges,
const V *const   v,
SUMOTime  msTime 
) throw () [inline, virtual, inherited]

Implements SUMOAbstractRouter< E, V >.

Definition at line 193 of file DijkstraRouterEffort.h.

References DijkstraRouterEffortBase< E, V, PF >::getEffort(), DijkstraRouterEffortBase< E, V, PF >::getTravelTime(), and SUMOReal.

00193                                                                                                           {
00194         SUMOReal time = (SUMOReal) msTime / 1000.;
00195         SUMOReal costs = 0;
00196         SUMOReal t = (SUMOReal) time;
00197         for (typename std::vector<const E*>::const_iterator i=edges.begin(); i!=edges.end(); ++i) {
00198             if (PF::operator()(*i, v)) {
00199                 return -1;
00200             }
00201             costs += getEffort(*i, v, (SUMOTime) t);
00202             t += getTravelTime(*i, v, (SUMOTime) t);
00203         }
00204         return costs;
00205     }


Field Documentation

template<class E, class V, class PF>
EdgeInfoByEffortComparator DijkstraRouterEffortBase< E, V, PF >::myComparator [protected, inherited]

template<class E, class V, class PF>
std::vector<EdgeInfo> DijkstraRouterEffortBase< E, V, PF >::myEdgeInfos [protected, inherited]

template<class E, class V, class PF, class EC>
Operation DijkstraRouterEffort_ByProxi< E, V, PF, EC >::myEffortOperation [private]

The object's operation to perform for obtaining the effort.

Definition at line 255 of file DijkstraRouterEffort.h.

Referenced by DijkstraRouterEffort_ByProxi< E, V, PF, EC >::getEffort().

template<class E, class V, class PF>
std::vector<EdgeInfo*> DijkstraRouterEffortBase< E, V, PF >::myFrontierList [protected, inherited]

A container for reusage of the min edge heap.

Definition at line 223 of file DijkstraRouterEffort.h.

Referenced by DijkstraRouterEffortBase< E, V, PF >::compute().

template<class E, class V, class PF, class EC>
EC* DijkstraRouterEffort_ByProxi< E, V, PF, EC >::myReceiver [private]

template<class E, class V, class PF, class EC>
Operation DijkstraRouterEffort_ByProxi< E, V, PF, EC >::myTTOperation [private]

The object's operation to perform for obtaining the travel time.

Definition at line 258 of file DijkstraRouterEffort.h.

Referenced by DijkstraRouterEffort_ByProxi< E, V, PF, EC >::getTravelTime().

template<class E, class V, class PF>
bool DijkstraRouterEffortBase< E, V, PF >::myUnbuildIsWarningOnly [protected, inherited]


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

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