46 #ifdef CHECK_MEMORY_LEAKS 48 #endif // CHECK_MEMORY_LEAKS 64 : myBegin(begin), myEnd(end), myAdditiveTraffic(additiveTraffic), myAdaptionFactor(adaptionFactor), myNet(net), myMatrix(matrix), myRouter(router) {
84 }
else if (roadClass == 0 || roadClass == 1) {
86 }
else if (roadClass == 2 && edge->
getSpeed() <= 11.) {
88 }
else if (roadClass == 2 && edge->
getSpeed() > 11. && edge->
getSpeed() <= 16.) {
90 }
else if (roadClass == 2 && edge->
getSpeed() > 16.) {
92 }
else if (roadClass == 3 && edge->
getSpeed() <= 11.) {
94 }
else if (roadClass == 3 && edge->
getSpeed() > 11. && edge->
getSpeed() <= 13.) {
96 }
else if (roadClass == 3 && edge->
getSpeed() > 13. && edge->
getSpeed() <= 16.) {
98 }
else if (roadClass == 3 && edge->
getSpeed() > 16.) {
100 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() <= 5.) {
102 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 5. && edge->
getSpeed() <= 7.) {
104 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 7. && edge->
getSpeed() <= 9.) {
106 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 9. && edge->
getSpeed() <= 11.) {
108 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 11. && edge->
getSpeed() <= 13.) {
110 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 13. && edge->
getSpeed() <= 16.) {
112 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 16. && edge->
getSpeed() <= 18.) {
114 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 18. && edge->
getSpeed() <= 22.) {
116 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 22. && edge->
getSpeed() <= 26.) {
118 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 26.) {
137 }
else if (roadClass == 0 || roadClass == 1) {
138 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 1.3)) * 2.);
139 }
else if (roadClass == 2 && edge->
getSpeed() <= 11.) {
140 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 0.9)) * 3.);
141 }
else if (roadClass == 2 && edge->
getSpeed() > 11. && edge->
getSpeed() <= 16.) {
142 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 1.)) * 2.);
143 }
else if (roadClass == 2 && edge->
getSpeed() > 16.) {
144 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 1.3)) * 2.);
145 }
else if (roadClass == 3 && edge->
getSpeed() <= 11.) {
146 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 0.9)) * 3.);
147 }
else if (roadClass == 3 && edge->
getSpeed() > 11. && edge->
getSpeed() <= 13.) {
148 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 0.9)) * 3.);
149 }
else if (roadClass == 3 && edge->
getSpeed() > 13. && edge->
getSpeed() <= 16.) {
150 return edge->
getLength() / edge->
getSpeed() * (1. + 1.7 * (flow / (capacity * 1.)) * 2.);
151 }
else if (roadClass == 3 && edge->
getSpeed() > 16.) {
152 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 1.3)) * 2.);
153 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() <= 5.) {
154 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 0.5)) * 3.);
155 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 5. && edge->
getSpeed() <= 7.) {
156 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 0.5)) * 3.);
157 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 7. && edge->
getSpeed() <= 9.) {
158 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 0.8)) * 3.);
159 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 9. && edge->
getSpeed() <= 11.) {
160 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 0.9)) * 3.);
161 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 11. && edge->
getSpeed() <= 13.) {
162 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 0.9)) * 3.);
163 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 13. && edge->
getSpeed() <= 16.) {
164 return edge->
getLength() / edge->
getSpeed() * (1. + 1.7 * (flow / (capacity * 1.)) * 2.);
165 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 16. && edge->
getSpeed() <= 18.) {
166 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 1.)) * 2.);
167 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 18. && edge->
getSpeed() <= 22.) {
168 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 1.)) * 2.);
169 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 22. && edge->
getSpeed() <= 26.) {
170 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 1.)) * 2.);
171 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 26.) {
172 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 1.)) * 2.);
174 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 0.9)) * 3.);
180 std::vector<RORoute*>::iterator p;
181 for (p = paths.begin(); p != paths.end(); p++) {
182 if (edges == (*p)->getEdgeVector()) {
186 if (p == paths.end()) {
187 paths.push_back(
new RORoute(routeId, 0., prob, edges, 0, std::vector<SUMOVehicleParameter::Stop>()));
190 (*p)->addProbability(prob);
191 std::iter_swap(paths.end() - 1, p);
201 for (
int k = 0; k < kPaths; k++) {
204 for (ConstROEdgeVector::iterator e = edges.begin(); e != edges.end(); e++) {
228 std::vector<int> intervals;
231 if ((*i)->begin != lastBegin) {
232 intervals.push_back(count);
233 lastBegin = (*i)->begin;
238 for (std::vector<int>::const_iterator offset = intervals.begin(); offset != intervals.end(); offset++) {
240 if (offset != intervals.end() - 1) {
247 std::map<const ROMAEdge*, SUMOReal> loadedTravelTimes;
254 for (
int t = 0; t < numIter; t++) {
258 std::string lastOrigin =
"";
260 for (std::vector<ODCell*>::const_iterator i =
myMatrix.
getCells().begin() + (*offset); i != cellsEnd; i++) {
265 if (
myNet.getThreadPool().size() > 0) {
266 if (lastOrigin != c->
origin) {
268 if (workerIndex ==
myNet.getThreadPool().size()) {
271 myNet.getThreadPool().add(
new RONet::BulkmodeTask(
false), workerIndex);
273 myNet.getThreadPool().add(
new RoutingTask(*
this, c, begin, linkFlow), workerIndex);
274 myNet.getThreadPool().add(
new RONet::BulkmodeTask(
true), workerIndex);
276 myNet.getThreadPool().add(
new RoutingTask(*
this, c, begin, linkFlow), workerIndex);
281 if (lastOrigin != c->
origin) {
291 if (
myNet.getThreadPool().size() > 0) {
292 myNet.getThreadPool().waitAll();
295 for (std::vector<ODCell*>::const_iterator i =
myMatrix.
getCells().begin() + (*offset); i != cellsEnd; i++) {
302 for (ConstROEdgeVector::const_iterator e = edges.begin(); e != edges.end(); e++) {
308 if (loadedTravelTimes.count(edge) != 0) {
318 lastBegin = intervalStart;
326 std::map<const SUMOReal, SUMOReal> intervals;
334 for (
int outer = 0; outer < maxOuterIteration; outer++) {
335 for (
int inner = 0; inner < maxInnerIteration; inner++) {
360 int unstableEdges = 0;
361 for (std::map<const SUMOReal, SUMOReal>::const_iterator i = intervals.begin(); i != intervals.end(); ++i) {
367 if (inner == 0 && outer == 0) {
370 newFlow += (edge->
getHelpFlow(i->first) - oldFlow) / (inner + 1);
374 if (fabs(newFlow - oldFlow) / newFlow > tolerance) {
377 }
else if (newFlow == 0.) {
378 if (oldFlow != 0. && (fabs(newFlow - oldFlow) / oldFlow > tolerance)) {
385 edge->
setFlow(i->first, i->second, newFlow);
392 if (unstableEdges == 0) {
399 bool newRoute =
false;
431 const std::map<const ROEdge* const, SUMOReal>::const_iterator i =
myPenalties.find(e);
438 const std::map<const ROEdge* const, SUMOReal>::const_iterator i =
myPenalties.find(e);
456 static_cast<RONet::WorkerThread*
>(context)->getVehicleRouter().compute(myAssign.myNet.getEdge(myCell->origin +
"-source"), myAssign.myNet.getEdge(myCell->destination +
"-sink"), myAssign.myDefaultVehicle,
myBegin, edges);
457 myAssign.addRoute(edges, myCell->pathsVector, myCell->origin + myCell->destination +
toString(myCell->pathsVector.size()), myLinkFlow);
SUMOReal getLength() const
Returns the length of the edge.
const std::vector< ODCell * > & getCells()
SUMOAbstractRouter< ROEdge, ROVehicle > & myRouter
virtual SUMOReal recomputeCosts(const std::vector< const E *> &edges, const V *const v, SUMOTime msTime) const =0
ROMAAssignments(const SUMOTime begin, const SUMOTime end, const bool additiveTraffic, const SUMOReal adaptionFactor, RONet &net, ODMatrix &matrix, SUMOAbstractRouter< ROEdge, ROVehicle > &router)
Constructor.
void incremental(const int numIter, const bool verbose)
std::string time2string(SUMOTime t)
virtual bool compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E *> &into)=0
Builds the route between the given edges using the minimum effort at the given time The definition of...
void setProbability(SUMOReal prob)
Sets the probability of the route.
void setFlow(const SUMOReal begin, const SUMOReal end, const SUMOReal flow)
std::vector< const ROEdge * > ConstROEdgeVector
std::vector< RORoute * > pathsVector
the list of paths / routes
const bool myAdditiveTraffic
const std::string DEFAULT_VTYPE_ID
void addTravelTime(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd)
Adds a travel time value.
A vehicle as used by router.
SUMOReal getFlow(const SUMOReal time) const
A single O/D-matrix cell.
void setHelpFlow(const SUMOReal begin, const SUMOReal end, const SUMOReal flow)
std::string origin
Name of the origin district.
SUMOReal getTravelTime(const ROVehicle *const veh, SUMOReal time) const
Returns the travel time for this edge.
static SUMOReal getPenalizedTT(const ROEdge *const e, const ROVehicle *const v, SUMOReal t)
Returns the traveltime on an edge including penalties.
void sue(const int maxOuterIteration, const int maxInnerIteration, const int kPaths, const SUMOReal penalty, const SUMOReal tolerance, const std::string routeChoiceMethod)
EdgeFunc getFunc() const
Returns the function of the edge.
bool hasLoadedTravelTime(SUMOReal time) const
Returns whether a travel time for this edge was loaded.
An O/D (origin/destination) matrix.
void setCosts(SUMOReal costs)
Sets the costs of the route.
~ROMAAssignments()
Destructor.
SUMOReal vehicleNumber
The number of vehicles.
static std::map< const ROEdge *const, SUMOReal > myPenalties
static SUMOReal getTravelTime(const ROEdge *const e, const ROVehicle *const v, SUMOReal t)
Returns the traveltime on an edge without penalties.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
static SUMOReal getPenalizedEffort(const ROEdge *const e, const ROVehicle *const v, SUMOReal t)
Returns the effort to pass an edge including penalties.
SUMOTime begin
The begin time this cell describes.
A basic edge for routing applications.
bool addRoute(ConstROEdgeVector &edges, std::vector< RORoute *> &paths, std::string routeId, SUMOReal prob)
add a route and check for duplicates
SUMOReal getSpeed() const
Returns the speed allowed on this edge.
static SUMOReal getCapacity(const ROEdge *edge)
The router's network representation.
int getPriority() const
get edge priority (road class)
Structure representing possible vehicle parameter.
SUMOReal getProbability() const
Returns the probability the driver will take this route with.
ROVehicle * myDefaultVehicle
void getKPaths(const int kPaths, const SUMOReal penalty)
get the k shortest paths
const ConstROEdgeVector & getEdgeVector() const
Returns the list of edges this route consists of.
const std::map< std::string, ROEdge * > & getEdgeMap() const
SUMOReal getHelpFlow(const SUMOReal time) const
SUMOReal getEffort(const ROVehicle *const veh, SUMOReal time) const
Returns the effort for this edge.
std::string destination
Name of the destination district.
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
A thread repeatingly calculating incoming tasks.
static RouteCostCalculator< R, E, V > & getCalculator()
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
SUMOTime end
The end time this cell describes.
An edge representing a whole district.
#define WRITE_MESSAGE(msg)
A basic edge for routing applications.
SUMOReal capacityConstraintFunction(const ROEdge *edge, const SUMOReal flow) const
int getLaneNo() const
Returns the number of lanes this edge has.
A complete router's route.
void setBulkMode(const bool mode)
const SUMOReal myAdaptionFactor