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