Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
CHRouterWrapper.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
20// Wraps multiple CHRouters for different vehicle types
21/****************************************************************************/
22#pragma once
23#include <config.h>
24
25#include <string>
26#include <functional>
27#include <vector>
28#include <set>
29#include <limits>
30#include <algorithm>
31#include <iterator>
37#include "CHRouter.h"
38
39#ifdef HAVE_FOX
41#endif
42
43
44// ===========================================================================
45// class definitions
46// ===========================================================================
60template<class E, class V>
62
63public:
66 CHRouterWrapper(const std::vector<E*>& edges, const bool ignoreErrors, typename SUMOAbstractRouter<E, V>::Operation operation,
67 const SUMOTime begin, const SUMOTime end, const SUMOTime weightPeriod, bool havePermissions, const int numThreads) :
68 SUMOAbstractRouter<E, V>("CHRouterWrapper", ignoreErrors, operation, nullptr, havePermissions, false),
69 myEdges(edges),
70 myIgnoreErrors(ignoreErrors),
71 myBegin(begin),
72 myEnd(end),
73 myWeightPeriod(weightPeriod),
74 myMaxNumInstances(numThreads) {
75 }
76
78 for (typename RouterMap::iterator i = myRouters.begin(); i != myRouters.end(); ++i) {
79 delete i->second;
80 }
81 }
82
83 virtual void prohibit(const std::vector<E*>& toProhibit) {
84 if (toProhibit.size() > 0) {
85 WRITE_WARNINGF(TL("Routing algorithm CHWrapper does not support dynamic closing of edges%"), "");
86 }
87 }
88
91 for (const auto& item : myRouters) {
92 clone->myRouters[item.first] = static_cast<CHRouterType*>(item.second->clone());
93 }
94 return clone;
95 }
96
97
98 bool compute(const E* from, const E* to, const V* const vehicle,
99 SUMOTime msTime, std::vector<const E*>& into, bool silent = false) {
100 const std::pair<const SUMOVehicleClass, const double> svc = std::make_pair(vehicle->getVClass(), vehicle->getMaxSpeed());
101 if (myRouters.count(svc) == 0) {
102 // create new router for the given permissions and maximum speed
103 // XXX a new router may also be needed if vehicles differ in speed factor
104 myRouters[svc] = new CHRouterType(myEdges, myIgnoreErrors, this->myOperation, svc.first, myWeightPeriod, false, false);
105 }
106 return myRouters[svc]->compute(from, to, vehicle, msTime, into, silent);
107 }
108
109
110private:
112
113private:
114 typedef std::map<std::pair<const SUMOVehicleClass, const double>, CHRouterType*> RouterMap;
115
117
119 const std::vector<E*>& myEdges;
120
121 const bool myIgnoreErrors;
122
127};
long long int SUMOTime
Definition GUI.h:36
#define WRITE_WARNINGF(...)
Definition MsgHandler.h:296
#define TL(string)
Definition MsgHandler.h:315
Computes the shortest path through a contracted network.
Definition CHRouter.h:59
Computes the shortest path through a contracted network.
const SUMOTime myBegin
virtual SUMOAbstractRouter< E, V > * clone()
const SUMOTime myEnd
const SUMOTime myWeightPeriod
const int myMaxNumInstances
bool compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E * > &into, bool silent=false)
Builds the route between the given edges using the minimum effort at the given time The definition of...
CHRouter< E, V > CHRouterType
virtual void prohibit(const std::vector< E * > &toProhibit)
const bool myIgnoreErrors
CHRouterWrapper(const std::vector< E * > &edges, const bool ignoreErrors, typename SUMOAbstractRouter< E, V >::Operation operation, const SUMOTime begin, const SUMOTime end, const SUMOTime weightPeriod, bool havePermissions, const int numThreads)
Constructor.
std::map< std::pair< const SUMOVehicleClass, const double >, CHRouterType * > RouterMap
const std::vector< E * > & myEdges
all edges with numerical ids
const bool myHavePermissions
whether edge permissions need to be considered
Operation myOperation
The object's operation to perform.