22 #ifndef CHRouterWrapper_h 23 #define CHRouterWrapper_h 71 template<
class E,
class V,
class PF>
76 typedef double(*
Operation)(
const E*
const,
const V*
const, double);
93 for (
typename std::vector<CHRouterType*>::iterator j = i->second.begin(); j != i->second.end(); ++j) {
101 CHRouterWrapper<E, V, PF>*
clone =
new CHRouterWrapper<E, V, PF>(
myEdges,
myIgnoreErrors, this->
myOperation,
myBegin,
myEnd,
myWeightPeriod,
myMaxNumInstances);
103 for (
typename std::vector<CHRouterType*>::iterator j = i->second.begin(); j != i->second.end(); ++j) {
104 clone->
myRouters[i->first].push_back(static_cast<CHRouterType*>((*j)->clone()));
111 bool compute(
const E* from,
const E* to,
const V*
const vehicle,
112 SUMOTime msTime, std::vector<const E*>& into) {
113 const std::pair<const SUMOVehicleClass, const double> svc = std::make_pair(vehicle->getVClass(), vehicle->getMaxSpeed());
115 int numIntervals = 1;
120 if (numIntervals > 0) {
133 for (
int i = 0; i < numIntervals; i++) {
137 if (myThreadPool.size() > 0) {
143 if (myThreadPool.size() > 0) {
144 myThreadPool.waitAll();
148 return myRouters[svc][index]->compute(from, to, vehicle, msTime, into);
153 const V*
const v,
SUMOTime msTime)
const {
156 for (
typename std::vector<const E*>::const_iterator i = edges.begin(); i != edges.end(); ++i) {
157 if (PF::operator()(*i, v)) {
158 WRITE_WARNING(
"Vehicle '" + v->getID() +
"' is restricted from using its assigned route.");
161 costs += this->
getEffort(*i, v, time + costs);
174 ComputeHierarchyTask(CHRouterType* router,
const V*
const vehicle,
const SUMOTime msTime)
175 : myRouter(router), myVehicle(vehicle), myStartTime(msTime) {}
177 myRouter->buildContractionHierarchy(myStartTime, myVehicle);
180 CHRouterType* myRouter;
181 const V*
const myVehicle;
185 ComputeHierarchyTask&
operator=(
const ComputeHierarchyTask&);
195 typedef std::map<std::pair<const SUMOVehicleClass, const double>, std::vector<CHRouterType*> >
RouterMap;
Computes the shortest path through a contracted network.
double getEffort(const E *const e, const V *const v, double t) const
CHRouterWrapper(const std::vector< E *> &edges, const bool ignoreErrors, Operation operation, const SUMOTime begin, const SUMOTime end, const SUMOTime weightPeriod, const int numThreads)
Constructor.
bool 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 effort at the given time The definition of...
#define WRITE_WARNING(msg)
const SUMOTime myWeightPeriod
double(* Operation)(const E *const, const V *const, double)
Type of the function that is used to retrieve the edge effort.
Operation myOperation
The object's operation to perform.
SUMOAbstractRouter & operator=(const SUMOAbstractRouter &s)
Invalidated assignment operator.
const int myMaxNumInstances
const bool myIgnoreErrors
A pool of worker threads which distributes the tasks and collects the results.
CHRouter< E, V, noProhibitions< E, V > > CHRouterType
double recomputeCosts(const std::vector< const E *> &edges, const V *const v, SUMOTime msTime) const
const std::vector< E * > & myEdges
all edges with numerical ids
Abstract superclass of a task to be run with an index to keep track of pending tasks.
virtual SUMOAbstractRouter< E, V > * clone()
A thread repeatingly calculating incoming tasks.
std::map< std::pair< const SUMOVehicleClass, const double >, std::vector< CHRouterType * > > RouterMap
Computes the shortest path through a contracted network.