SUMO - Simulation of Urban MObility
ROMAAssignments.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // Assignment methods
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
12 // Copyright (C) 2001-2016 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <vector>
34 #include <algorithm>
35 #include <router/ROEdge.h>
37 #include <router/RONet.h>
38 #include <router/RORoute.h>
40 #include <od/ODMatrix.h>
41 #include <utils/common/SUMOTime.h>
43 #include "ROMAEdge.h"
44 #include "ROMAAssignments.h"
45 
46 #ifdef CHECK_MEMORY_LEAKS
47 #include <foreign/nvwa/debug_new.h>
48 #endif // CHECK_MEMORY_LEAKS
49 
50 
51 // ===========================================================================
52 // static member variables
53 // ===========================================================================
54 std::map<const ROEdge* const, SUMOReal> ROMAAssignments::myPenalties;
55 
56 
57 // ===========================================================================
58 // method definitions
59 // ===========================================================================
60 
61 ROMAAssignments::ROMAAssignments(const SUMOTime begin, const SUMOTime end, const bool additiveTraffic,
62  const SUMOReal adaptionFactor, RONet& net, ODMatrix& matrix,
64  : myBegin(begin), myEnd(end), myAdditiveTraffic(additiveTraffic), myAdaptionFactor(adaptionFactor), myNet(net), myMatrix(matrix), myRouter(router) {
66 }
67 
68 
70  delete myDefaultVehicle;
71 }
72 
73 // based on the definitions in PTV-Validate and in the VISUM-Cologne network
76  if (edge->getFunc() == ROEdge::ET_DISTRICT) {
77  return 0;
78  }
79  const int roadClass = -edge->getPriority();
80  // TODO: differ road class 1 from the unknown road class 1!!!
81  if (edge->getLaneNo() == 0) {
82  // TAZ have no cost
83  return 0;
84  } else if (roadClass == 0 || roadClass == 1) {
85  return edge->getLaneNo() * 2000.; //CR13 in table.py
86  } else if (roadClass == 2 && edge->getSpeed() <= 11.) {
87  return edge->getLaneNo() * 1333.33; //CR5 in table.py
88  } else if (roadClass == 2 && edge->getSpeed() > 11. && edge->getSpeed() <= 16.) {
89  return edge->getLaneNo() * 1500.; //CR3 in table.py
90  } else if (roadClass == 2 && edge->getSpeed() > 16.) {
91  return edge->getLaneNo() * 2000.; //CR13 in table.py
92  } else if (roadClass == 3 && edge->getSpeed() <= 11.) {
93  return edge->getLaneNo() * 800.; //CR5 in table.py
94  } else if (roadClass == 3 && edge->getSpeed() > 11. && edge->getSpeed() <= 13.) {
95  return edge->getLaneNo() * 875.; //CR5 in table.py
96  } else if (roadClass == 3 && edge->getSpeed() > 13. && edge->getSpeed() <= 16.) {
97  return edge->getLaneNo() * 1500.; //CR4 in table.py
98  } else if (roadClass == 3 && edge->getSpeed() > 16.) {
99  return edge->getLaneNo() * 1800.; //CR13 in table.py
100  } else if ((roadClass >= 4 || roadClass == -1) && edge->getSpeed() <= 5.) {
101  return edge->getLaneNo() * 200.; //CR7 in table.py
102  } else if ((roadClass >= 4 || roadClass == -1) && edge->getSpeed() > 5. && edge->getSpeed() <= 7.) {
103  return edge->getLaneNo() * 412.5; //CR7 in table.py
104  } else if ((roadClass >= 4 || roadClass == -1) && edge->getSpeed() > 7. && edge->getSpeed() <= 9.) {
105  return edge->getLaneNo() * 600.; //CR6 in table.py
106  } else if ((roadClass >= 4 || roadClass == -1) && edge->getSpeed() > 9. && edge->getSpeed() <= 11.) {
107  return edge->getLaneNo() * 800.; //CR5 in table.py
108  } else if ((roadClass >= 4 || roadClass == -1) && edge->getSpeed() > 11. && edge->getSpeed() <= 13.) {
109  return edge->getLaneNo() * 1125.; //CR5 in table.py
110  } else if ((roadClass >= 4 || roadClass == -1) && edge->getSpeed() > 13. && edge->getSpeed() <= 16.) {
111  return edge->getLaneNo() * 1583.; //CR4 in table.py
112  } else if ((roadClass >= 4 || roadClass == -1) && edge->getSpeed() > 16. && edge->getSpeed() <= 18.) {
113  return edge->getLaneNo() * 1100.; //CR3 in table.py
114  } else if ((roadClass >= 4 || roadClass == -1) && edge->getSpeed() > 18. && edge->getSpeed() <= 22.) {
115  return edge->getLaneNo() * 1200.; //CR3 in table.py
116  } else if ((roadClass >= 4 || roadClass == -1) && edge->getSpeed() > 22. && edge->getSpeed() <= 26.) {
117  return edge->getLaneNo() * 1300.; //CR3 in table.py
118  } else if ((roadClass >= 4 || roadClass == -1) && edge->getSpeed() > 26.) {
119  return edge->getLaneNo() * 1400.; //CR3 in table.py
120  }
121  return edge->getLaneNo() * 800.; //CR5 in table.py
122 }
123 
124 
125 // based on the definitions in PTV-Validate and in the VISUM-Cologne network
126 SUMOReal
128  if (edge->getFunc() == ROEdge::ET_DISTRICT) {
129  return 0;
130  }
131  const int roadClass = -edge->getPriority();
132  const SUMOReal capacity = getCapacity(edge);
133  // TODO: differ road class 1 from the unknown road class 1!!!
134  if (edge->getLaneNo() == 0) {
135  // TAZ have no cost
136  return 0;
137  } else if (roadClass == 0 || roadClass == 1) {
138  return edge->getLength() / edge->getSpeed() * (1. + 1.*(flow / (capacity * 1.3)) * 2.); //CR13 in table.py
139  } else if (roadClass == 2 && edge->getSpeed() <= 11.) {
140  return edge->getLength() / edge->getSpeed() * (1. + 1.*(flow / (capacity * 0.9)) * 3.); //CR5 in table.py
141  } else if (roadClass == 2 && edge->getSpeed() > 11. && edge->getSpeed() <= 16.) {
142  return edge->getLength() / edge->getSpeed() * (1. + 1.*(flow / (capacity * 1.)) * 2.); //CR3 in table.py
143  } else if (roadClass == 2 && edge->getSpeed() > 16.) {
144  return edge->getLength() / edge->getSpeed() * (1. + 1.*(flow / (capacity * 1.3)) * 2.); //CR13 in table.py
145  } else if (roadClass == 3 && edge->getSpeed() <= 11.) {
146  return edge->getLength() / edge->getSpeed() * (1. + 1.*(flow / (capacity * 0.9)) * 3.); //CR5 in table.py
147  } else if (roadClass == 3 && edge->getSpeed() > 11. && edge->getSpeed() <= 13.) {
148  return edge->getLength() / edge->getSpeed() * (1. + 1.*(flow / (capacity * 0.9)) * 3.); //CR5 in table.py
149  } else if (roadClass == 3 && edge->getSpeed() > 13. && edge->getSpeed() <= 16.) {
150  return edge->getLength() / edge->getSpeed() * (1. + 1.7 * (flow / (capacity * 1.)) * 2.); //CR4 in table.py
151  } else if (roadClass == 3 && edge->getSpeed() > 16.) {
152  return edge->getLength() / edge->getSpeed() * (1. + 1.*(flow / (capacity * 1.3)) * 2.); //CR13 in table.py
153  } else if ((roadClass >= 4 || roadClass == -1) && edge->getSpeed() <= 5.) {
154  return edge->getLength() / edge->getSpeed() * (1. + 1.*(flow / (capacity * 0.5)) * 3.); //CR7 in table.py
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.); //CR7 in table.py
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.); //CR6 in table.py
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.); //CR5 in table.py
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.); //CR5 in table.py
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.); //CR4 in table.py
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.); //CR3 in table.py
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.); //CR3 in table.py
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.); //CR3 in table.py
171  } else if ((roadClass >= 4 || roadClass == -1) && edge->getSpeed() > 26.) {
172  return edge->getLength() / edge->getSpeed() * (1. + 1.*(flow / (capacity * 1.)) * 2.); //CR3 in table.py
173  }
174  return edge->getLength() / edge->getSpeed() * (1. + 1.*(flow / (capacity * 0.9)) * 3.); //CR5 in table.py
175 }
176 
177 
178 bool
179 ROMAAssignments::addRoute(ConstROEdgeVector& edges, std::vector<RORoute*>& paths, std::string routeId, SUMOReal prob) {
180  std::vector<RORoute*>::iterator p;
181  for (p = paths.begin(); p != paths.end(); p++) {
182  if (edges == (*p)->getEdgeVector()) {
183  break;
184  }
185  }
186  if (p == paths.end()) {
187  paths.push_back(new RORoute(routeId, 0., prob, edges, 0, std::vector<SUMOVehicleParameter::Stop>()));
188  return true;
189  }
190  (*p)->addProbability(prob);
191  std::iter_swap(paths.end() - 1, p);
192  return false;
193 }
194 
195 
196 void
197 ROMAAssignments::getKPaths(const int kPaths, const SUMOReal penalty) {
198  for (std::vector<ODCell*>::const_iterator i = myMatrix.getCells().begin(); i != myMatrix.getCells().end(); ++i) {
199  ODCell* c = *i;
200  myPenalties.clear();
201  for (int k = 0; k < kPaths; k++) {
202  ConstROEdgeVector edges;
203  myRouter.compute(myNet.getEdge(c->origin + "-source"), myNet.getEdge(c->destination + "-sink"), myDefaultVehicle, 0, edges);
204  for (ConstROEdgeVector::iterator e = edges.begin(); e != edges.end(); e++) {
205  myPenalties[*e] = penalty;
206  }
207  addRoute(edges, c->pathsVector, c->origin + c->destination + toString(c->pathsVector.size()), 0);
208  }
209  }
210  myPenalties.clear();
211 }
212 
213 
214 void
216  const SUMOReal begin = STEPS2TIME(MIN2(myBegin, myMatrix.getCells().front()->begin));
217  for (std::map<std::string, ROEdge*>::const_iterator i = myNet.getEdgeMap().begin(); i != myNet.getEdgeMap().end(); ++i) {
218  ROMAEdge* edge = static_cast<ROMAEdge*>(i->second);
219  edge->setFlow(begin, STEPS2TIME(myEnd), 0.);
220  edge->setHelpFlow(begin, STEPS2TIME(myEnd), 0.);
221  }
222 }
223 
224 
225 void
226 ROMAAssignments::incremental(const int numIter, const bool verbose) {
227  SUMOTime lastBegin = -1;
228  std::vector<int> intervals;
229  int count = 0;
230  for (std::vector<ODCell*>::const_iterator i = myMatrix.getCells().begin(); i != myMatrix.getCells().end(); ++i) {
231  if ((*i)->begin != lastBegin) {
232  intervals.push_back(count);
233  lastBegin = (*i)->begin;
234  }
235  count++;
236  }
237  lastBegin = -1;
238  for (std::vector<int>::const_iterator offset = intervals.begin(); offset != intervals.end(); offset++) {
239  std::vector<ODCell*>::const_iterator cellsEnd = myMatrix.getCells().end();
240  if (offset != intervals.end() - 1) {
241  cellsEnd = myMatrix.getCells().begin() + (*(offset + 1));
242  }
243  const SUMOTime intervalStart = (*(myMatrix.getCells().begin() + (*offset)))->begin;
244  if (verbose) {
245  WRITE_MESSAGE(" starting interval " + time2string(intervalStart));
246  }
247  std::map<const ROMAEdge*, SUMOReal> loadedTravelTimes;
248  for (std::map<std::string, ROEdge*>::const_iterator i = myNet.getEdgeMap().begin(); i != myNet.getEdgeMap().end(); ++i) {
249  ROMAEdge* edge = static_cast<ROMAEdge*>(i->second);
250  if (edge->hasLoadedTravelTime(STEPS2TIME(intervalStart))) {
251  loadedTravelTimes[edge] = edge->getTravelTime(myDefaultVehicle, STEPS2TIME(intervalStart));
252  }
253  }
254  for (int t = 0; t < numIter; t++) {
255  if (verbose) {
256  WRITE_MESSAGE(" starting iteration " + toString(t));
257  }
258  std::string lastOrigin = "";
259  int workerIndex = 0;
260  for (std::vector<ODCell*>::const_iterator i = myMatrix.getCells().begin() + (*offset); i != cellsEnd; i++) {
261  ODCell* const c = *i;
262  const SUMOReal linkFlow = c->vehicleNumber / numIter;
263  const SUMOTime begin = myAdditiveTraffic ? myBegin : c->begin;
264 #ifdef HAVE_FOX
265  if (myNet.getThreadPool().size() > 0) {
266  if (lastOrigin != c->origin) {
267  workerIndex++;
268  if (workerIndex == myNet.getThreadPool().size()) {
269  workerIndex = 0;
270  }
271  myNet.getThreadPool().add(new RONet::BulkmodeTask(false), workerIndex);
272  lastOrigin = c->origin;
273  myNet.getThreadPool().add(new RoutingTask(*this, c, begin, linkFlow), workerIndex);
274  myNet.getThreadPool().add(new RONet::BulkmodeTask(true), workerIndex);
275  } else {
276  myNet.getThreadPool().add(new RoutingTask(*this, c, begin, linkFlow), workerIndex);
277  }
278  continue;
279  }
280 #endif
281  if (lastOrigin != c->origin) {
282  myRouter.setBulkMode(false);
283  lastOrigin = c->origin;
284  }
285  ConstROEdgeVector edges;
286  myRouter.compute(myNet.getEdge(c->origin + "-source"), myNet.getEdge(c->destination + "-sink"), myDefaultVehicle, begin, edges);
287  myRouter.setBulkMode(true);
288  addRoute(edges, c->pathsVector, c->origin + c->destination + toString(c->pathsVector.size()), linkFlow);
289  }
290 #ifdef HAVE_FOX
291  if (myNet.getThreadPool().size() > 0) {
292  myNet.getThreadPool().waitAll();
293  }
294 #endif
295  for (std::vector<ODCell*>::const_iterator i = myMatrix.getCells().begin() + (*offset); i != cellsEnd; i++) {
296  ODCell* const c = *i;
297  const SUMOReal linkFlow = c->vehicleNumber / numIter;
298  const SUMOTime begin = myAdditiveTraffic ? myBegin : c->begin;
299  const SUMOTime end = myAdditiveTraffic ? myEnd : c->end;
300  const SUMOReal intervalLengthInHours = STEPS2TIME(end - begin) / 3600.;
301  const ConstROEdgeVector& edges = c->pathsVector.back()->getEdgeVector();
302  for (ConstROEdgeVector::const_iterator e = edges.begin(); e != edges.end(); e++) {
303  ROMAEdge* edge = static_cast<ROMAEdge*>(myNet.getEdge((*e)->getID()));
304  const SUMOReal newFlow = edge->getFlow(STEPS2TIME(begin)) + linkFlow;
305  edge->setFlow(STEPS2TIME(begin), STEPS2TIME(end), newFlow);
306  SUMOReal travelTime = capacityConstraintFunction(edge, newFlow / intervalLengthInHours);
307  if (lastBegin >= 0 && myAdaptionFactor > 0.) {
308  if (loadedTravelTimes.count(edge) != 0) {
309  travelTime = loadedTravelTimes[edge] * myAdaptionFactor + (1. - myAdaptionFactor) * travelTime;
310  } else {
311  travelTime = edge->getTravelTime(myDefaultVehicle, STEPS2TIME(lastBegin)) * myAdaptionFactor + (1. - myAdaptionFactor) * travelTime;
312  }
313  }
314  edge->addTravelTime(travelTime, STEPS2TIME(begin), STEPS2TIME(end));
315  }
316  }
317  }
318  lastBegin = intervalStart;
319  }
320 }
321 
322 
323 void
324 ROMAAssignments::sue(const int maxOuterIteration, const int maxInnerIteration, const int kPaths, const SUMOReal penalty, const SUMOReal tolerance, const std::string /* routeChoiceMethod */) {
325  getKPaths(kPaths, penalty);
326  std::map<const SUMOReal, SUMOReal> intervals;
327  if (myAdditiveTraffic) {
328  intervals[STEPS2TIME(myBegin)] = STEPS2TIME(myEnd);
329  } else {
330  for (std::vector<ODCell*>::const_iterator i = myMatrix.getCells().begin(); i != myMatrix.getCells().end(); ++i) {
331  intervals[STEPS2TIME((*i)->begin)] = STEPS2TIME((*i)->end);
332  }
333  }
334  for (int outer = 0; outer < maxOuterIteration; outer++) {
335  for (int inner = 0; inner < maxInnerIteration; inner++) {
336  for (std::vector<ODCell*>::const_iterator i = myMatrix.getCells().begin(); i != myMatrix.getCells().end(); ++i) {
337  ODCell* const c = *i;
338  const SUMOTime begin = myAdditiveTraffic ? myBegin : c->begin;
339  const SUMOTime end = myAdditiveTraffic ? myEnd : c->end;
340  // update path cost
341  for (std::vector<RORoute*>::const_iterator j = c->pathsVector.begin(); j != c->pathsVector.end(); ++j) {
342  RORoute* r = *j;
344 // std::cout << std::setprecision(20) << r->getID() << ":" << r->getCosts() << std::endl;
345  }
346  // calculate route utilities and probabilities
348  // calculate route flows
349  for (std::vector<RORoute*>::const_iterator j = c->pathsVector.begin(); j != c->pathsVector.end(); ++j) {
350  RORoute* r = *j;
351  const SUMOReal pathFlow = r->getProbability() * c->vehicleNumber;
352  // assign edge flow deltas
353  for (ConstROEdgeVector::const_iterator e = r->getEdgeVector().begin(); e != r->getEdgeVector().end(); e++) {
354  ROMAEdge* edge = static_cast<ROMAEdge*>(myNet.getEdge((*e)->getID()));
355  edge->setHelpFlow(STEPS2TIME(begin), STEPS2TIME(end), edge->getHelpFlow(STEPS2TIME(begin)) + pathFlow);
356  }
357  }
358  }
359  // calculate new edge flows and check for stability
360  int unstableEdges = 0;
361  for (std::map<const SUMOReal, SUMOReal>::const_iterator i = intervals.begin(); i != intervals.end(); ++i) {
362  const SUMOReal intervalLengthInHours = STEPS2TIME(i->second - i->first) / 3600.;
363  for (std::map<std::string, ROEdge*>::const_iterator e = myNet.getEdgeMap().begin(); e != myNet.getEdgeMap().end(); ++e) {
364  ROMAEdge* edge = static_cast<ROMAEdge*>(e->second);
365  const SUMOReal oldFlow = edge->getFlow(i->first);
366  SUMOReal newFlow = oldFlow;
367  if (inner == 0 && outer == 0) {
368  newFlow += edge->getHelpFlow(i->first);
369  } else {
370  newFlow += (edge->getHelpFlow(i->first) - oldFlow) / (inner + 1);
371  }
372  // if not lohse:
373  if (newFlow > 0.) {
374  if (fabs(newFlow - oldFlow) / newFlow > tolerance) {
375  unstableEdges++;
376  }
377  } else if (newFlow == 0.) {
378  if (oldFlow != 0. && (fabs(newFlow - oldFlow) / oldFlow > tolerance)) {
379  unstableEdges++;
380  }
381  } else { // newFlow < 0.
382  unstableEdges++;
383  newFlow = 0.;
384  }
385  edge->setFlow(i->first, i->second, newFlow);
386  const SUMOReal travelTime = capacityConstraintFunction(edge, newFlow / intervalLengthInHours);
387  edge->addTravelTime(travelTime, i->first, i->second);
388  edge->setHelpFlow(i->first, i->second, 0.);
389  }
390  }
391  // if stable break
392  if (unstableEdges == 0) {
393  break;
394  }
395  // additional stability check from python script: if notstable < math.ceil(net.geteffEdgeCounts()*0.005) or notstable < 3: stable = True
396  }
397  // check for a new route, if none available, break
398  // several modifications about when a route is new and when to break are in the original script
399  bool newRoute = false;
400  for (std::vector<ODCell*>::const_iterator i = myMatrix.getCells().begin(); i != myMatrix.getCells().end(); ++i) {
401  ODCell* c = *i;
402  ConstROEdgeVector edges;
403  myRouter.compute(myNet.getEdge(c->origin + "-source"), myNet.getEdge(c->destination + "-sink"), myDefaultVehicle, 0, edges);
404  newRoute |= addRoute(edges, c->pathsVector, c->origin + c->destination + toString(c->pathsVector.size()), 0);
405  }
406  if (!newRoute) {
407  break;
408  }
409  }
410  // final round of assignment
411  for (std::vector<ODCell*>::const_iterator i = myMatrix.getCells().begin(); i != myMatrix.getCells().end(); ++i) {
412  ODCell* c = *i;
413  // update path cost
414  for (std::vector<RORoute*>::const_iterator j = c->pathsVector.begin(); j != c->pathsVector.end(); ++j) {
415  RORoute* r = *j;
417  }
418  // calculate route utilities and probabilities
420  // calculate route flows
421  for (std::vector<RORoute*>::const_iterator j = c->pathsVector.begin(); j != c->pathsVector.end(); ++j) {
422  RORoute* r = *j;
424  }
425  }
426 }
427 
428 
429 SUMOReal
430 ROMAAssignments::getPenalizedEffort(const ROEdge* const e, const ROVehicle* const v, SUMOReal t) {
431  const std::map<const ROEdge* const, SUMOReal>::const_iterator i = myPenalties.find(e);
432  return i == myPenalties.end() ? e->getEffort(v, t) : e->getEffort(v, t) + i->second;
433 }
434 
435 
436 SUMOReal
437 ROMAAssignments::getPenalizedTT(const ROEdge* const e, const ROVehicle* const v, SUMOReal t) {
438  const std::map<const ROEdge* const, SUMOReal>::const_iterator i = myPenalties.find(e);
439  return i == myPenalties.end() ? e->getTravelTime(v, t) : e->getTravelTime(v, t) + i->second;
440 }
441 
442 
443 SUMOReal
444 ROMAAssignments::getTravelTime(const ROEdge* const e, const ROVehicle* const v, SUMOReal t) {
445  return e->getTravelTime(v, t);
446 }
447 
448 
449 #ifdef HAVE_FOX
450 // ---------------------------------------------------------------------------
451 // ROMAAssignments::RoutingTask-methods
452 // ---------------------------------------------------------------------------
453 void
454 ROMAAssignments::RoutingTask::run(FXWorkerThread* context) {
455  ConstROEdgeVector edges;
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);
458 }
459 #endif
const std::vector< ODCell * > & getCells()
Definition: ODMatrix.h:244
SUMOAbstractRouter< ROEdge, ROVehicle > & myRouter
long long int SUMOTime
Definition: SUMOTime.h:43
SUMOReal getFlow(const SUMOReal time) const
Definition: ROMAEdge.h:93
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
Definition: RONet.h:165
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)
Definition: SUMOTime.cpp:59
const SUMOTime myBegin
virtual SUMOReal recomputeCosts(const std::vector< const E * > &edges, const V *const v, SUMOTime msTime) const =0
const ConstROEdgeVector & getEdgeVector() const
Returns the list of edges this route consists of.
Definition: RORoute.h:162
void setProbability(SUMOReal prob)
Sets the probability of the route.
Definition: RORoute.cpp:83
EdgeFunc getFunc() const
Returns the function of the edge.
Definition: ROEdge.h:190
void setFlow(const SUMOReal begin, const SUMOReal end, const SUMOReal flow)
Definition: ROMAEdge.h:89
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...
unsigned int getLaneNo() const
Returns the number of lanes this edge has.
Definition: ROEdge.h:221
std::vector< const ROEdge * > ConstROEdgeVector
Definition: ROEdge.h:62
std::vector< RORoute * > pathsVector
the list of paths / routes
Definition: ODCell.h:78
const bool myAdditiveTraffic
const std::string DEFAULT_VTYPE_ID
void addTravelTime(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd)
Adds a travel time value.
Definition: ROEdge.cpp:125
const std::map< std::string, ROEdge * > & getEdgeMap() const
Definition: RONet.cpp:643
const SUMOTime myEnd
bool hasLoadedTravelTime(SUMOReal time) const
Returns whether a travel time for this edge was loaded.
Definition: ROEdge.cpp:153
A vehicle as used by router.
Definition: ROVehicle.h:60
A single O/D-matrix cell.
Definition: ODCell.h:58
void setHelpFlow(const SUMOReal begin, const SUMOReal end, const SUMOReal flow)
Definition: ROMAEdge.h:97
std::string origin
Name of the origin district.
Definition: ODCell.h:69
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)
An O/D (origin/destination) matrix.
Definition: ODMatrix.h:76
bool addRoute(ConstROEdgeVector &edges, std::vector< RORoute * > &paths, std::string routeId, SUMOReal prob)
add a route and check for duplicates
#define STEPS2TIME(x)
Definition: SUMOTime.h:65
SUMOReal getProbability() const
Returns the probability the driver will take this route with.
Definition: RORoute.h:130
void setCosts(SUMOReal costs)
Sets the costs of the route.
Definition: RORoute.cpp:77
T MIN2(T a, T b)
Definition: StdDefs.h:69
~ROMAAssignments()
Destructor.
SUMOReal vehicleNumber
The number of vehicles.
Definition: ODCell.h:60
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)
Definition: ToString.h:55
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.
Definition: ODCell.h:63
A basic edge for routing applications.
Definition: ROEdge.h:77
SUMOReal getHelpFlow(const SUMOReal time) const
Definition: ROMAEdge.h:101
static SUMOReal getCapacity(const ROEdge *edge)
The router&#39;s network representation.
Definition: RONet.h:76
Structure representing possible vehicle parameter.
int getPriority() const
get edge priority (road class)
Definition: ROEdge.h:418
SUMOReal getLength() const
Returns the length of the edge.
Definition: ROEdge.h:198
ROVehicle * myDefaultVehicle
SUMOReal getEffort(const ROVehicle *const veh, SUMOReal time) const
Returns the effort for this edge.
Definition: ROEdge.cpp:132
void getKPaths(const int kPaths, const SUMOReal penalty)
get the k shortest paths
std::string destination
Name of the destination district.
Definition: ODCell.h:72
#define SUMOReal
Definition: config.h:214
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
Definition: RONet.cpp:272
A thread repeatingly calculating incoming tasks.
SUMOReal getTravelTime(const ROVehicle *const veh, SUMOReal time) const
Returns the travel time for this edge.
Definition: ROEdge.cpp:159
static RouteCostCalculator< R, E, V > & getCalculator()
SUMOTime end
The end time this cell describes.
Definition: ODCell.h:66
An edge representing a whole district.
Definition: ROEdge.h:87
#define WRITE_MESSAGE(msg)
Definition: MsgHandler.h:201
SUMOReal capacityConstraintFunction(const ROEdge *edge, const SUMOReal flow) const
A basic edge for routing applications.
Definition: ROMAEdge.h:65
SUMOReal getSpeed() const
Returns the speed allowed on this edge.
Definition: ROEdge.h:213
A complete router&#39;s route.
Definition: RORoute.h:62
void setBulkMode(const bool mode)
const SUMOReal myAdaptionFactor
ODMatrix & myMatrix