19 #ifndef CHRouterWrapper_h 20 #define CHRouterWrapper_h 64 template<
class E,
class V,
class BASE>
69 typedef double(*
Operation)(
const E*
const,
const V*
const, double);
73 CHRouterWrapper(
const std::vector<E*>& edges,
const bool ignoreErrors,
typename BASE::Operation operation,
75 BASE(
"CHRouterWrapper", operation),
86 for (
typename std::vector<CHRouterType*>::iterator j = i->second.begin(); j != i->second.end(); ++j) {
94 CHRouterWrapper<E, V, BASE>*
clone =
new CHRouterWrapper<E, V, BASE>(
myEdges,
myIgnoreErrors, this->myOperation,
myBegin,
myEnd,
myWeightPeriod,
myMaxNumInstances);
96 for (
typename std::vector<CHRouterType*>::iterator j = i->second.begin(); j != i->second.end(); ++j) {
97 clone->
myRouters[i->first].push_back(static_cast<CHRouterType*>((*j)->clone()));
104 bool compute(
const E* from,
const E* to,
const V*
const vehicle,
105 SUMOTime msTime, std::vector<const E*>& into) {
106 const std::pair<const SUMOVehicleClass, const double> svc = std::make_pair(vehicle->getVClass(), vehicle->getMaxSpeed());
108 int numIntervals = 1;
113 if (numIntervals > 0) {
126 for (
int i = 0; i < numIntervals; i++) {
130 if (myThreadPool.size() > 0) {
136 if (myThreadPool.size() > 0) {
137 myThreadPool.waitAll();
141 return myRouters[svc][index]->compute(from, to, vehicle, msTime, into);
152 ComputeHierarchyTask(CHRouterType* router,
const V*
const vehicle,
const SUMOTime msTime)
153 : myRouter(router), myVehicle(vehicle), myStartTime(msTime) {}
155 myRouter->buildContractionHierarchy(myStartTime, myVehicle);
158 CHRouterType* myRouter;
159 const V*
const myVehicle;
163 ComputeHierarchyTask& operator=(
const ComputeHierarchyTask&);
173 typedef std::map<std::pair<const SUMOVehicleClass, const double>, std::vector<CHRouterType*> >
RouterMap;
Computes the shortest path through a contracted network.
const int myMaxNumInstances
CHRouter< E, V, SUMOAbstractRouter< E, V > > CHRouterType
const bool myIgnoreErrors
bool compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E *> &into)
virtual SUMOAbstractRouter< E, V > * clone()
CHRouterWrapper(const std::vector< E *> &edges, const bool ignoreErrors, typename BASE::Operation operation, const SUMOTime begin, const SUMOTime end, const SUMOTime weightPeriod, const int numThreads)
Constructor.
std::map< std::pair< const SUMOVehicleClass, const double >, std::vector< CHRouterType * > > RouterMap
double(* Operation)(const E *const, const V *const, double)
Type of the function that is used to retrieve the edge effort.
A pool of worker threads which distributes the tasks and collects the results.
const SUMOTime myWeightPeriod
Abstract superclass of a task to be run with an index to keep track of pending tasks.
A thread repeatingly calculating incoming tasks.
const std::vector< E * > & myEdges
all edges with numerical ids
Computes the shortest path through a contracted network.