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  for (std::map<std::string, ROEdge*>::const_iterator i = myNet.getEdgeMap().begin(); i != myNet.getEdgeMap().end(); ++i) {
217  ROMAEdge* edge = static_cast<ROMAEdge*>(i->second);
218  edge->setFlow(STEPS2TIME(myBegin), STEPS2TIME(myEnd), 0.);
220  }
221 }
222 
223 
224 void
225 ROMAAssignments::incremental(const int numIter, const bool verbose) {
226  SUMOTime lastBegin = -1;
227  std::vector<int> intervals;
228  int count = 0;
229  for (std::vector<ODCell*>::const_iterator i = myMatrix.getCells().begin(); i != myMatrix.getCells().end(); ++i) {
230  if ((*i)->begin != lastBegin) {
231  intervals.push_back(count);
232  lastBegin = (*i)->begin;
233  }
234  count++;
235  }
236  lastBegin = -1;
237  for (std::vector<int>::const_iterator offset = intervals.begin(); offset != intervals.end(); offset++) {
238  std::vector<ODCell*>::const_iterator cellsEnd = myMatrix.getCells().end();
239  if (offset != intervals.end() - 1) {
240  cellsEnd = myMatrix.getCells().begin() + (*(offset + 1));
241  }
242  const SUMOTime intervalStart = (*(myMatrix.getCells().begin() + (*offset)))->begin;
243  if (verbose) {
244  WRITE_MESSAGE(" starting interval " + time2string(intervalStart));
245  }
246  std::map<const ROMAEdge*, SUMOReal> loadedTravelTimes;
247  for (std::map<std::string, ROEdge*>::const_iterator i = myNet.getEdgeMap().begin(); i != myNet.getEdgeMap().end(); ++i) {
248  ROMAEdge* edge = static_cast<ROMAEdge*>(i->second);
249  if (edge->hasLoadedTravelTime(STEPS2TIME(intervalStart))) {
250  loadedTravelTimes[edge] = edge->getTravelTime(myDefaultVehicle, STEPS2TIME(intervalStart));
251  }
252  }
253  for (int t = 0; t < numIter; t++) {
254  if (verbose) {
255  WRITE_MESSAGE(" starting iteration " + toString(t));
256  }
257  std::string lastOrigin = "";
258  int workerIndex = 0;
259  for (std::vector<ODCell*>::const_iterator i = myMatrix.getCells().begin() + (*offset); i != cellsEnd; i++) {
260  ODCell* const c = *i;
261  const SUMOReal linkFlow = c->vehicleNumber / numIter;
262  const SUMOTime begin = myAdditiveTraffic ? myBegin : c->begin;
263 #ifdef HAVE_FOX
264  if (myNet.getThreadPool().size() > 0) {
265  if (lastOrigin != c->origin) {
266  workerIndex++;
267  if (workerIndex == myNet.getThreadPool().size()) {
268  workerIndex = 0;
269  }
270  myNet.getThreadPool().add(new RONet::BulkmodeTask(false), workerIndex);
271  lastOrigin = c->origin;
272  myNet.getThreadPool().add(new RoutingTask(*this, c, begin, linkFlow), workerIndex);
273  myNet.getThreadPool().add(new RONet::BulkmodeTask(true), workerIndex);
274  } else {
275  myNet.getThreadPool().add(new RoutingTask(*this, c, begin, linkFlow), workerIndex);
276  }
277  continue;
278  }
279 #endif
280  if (lastOrigin != c->origin) {
281  myRouter.setBulkMode(false);
282  lastOrigin = c->origin;
283  }
284  ConstROEdgeVector edges;
285  myRouter.compute(myNet.getEdge(c->origin + "-source"), myNet.getEdge(c->destination + "-sink"), myDefaultVehicle, begin, edges);
286  myRouter.setBulkMode(true);
287  addRoute(edges, c->pathsVector, c->origin + c->destination + toString(c->pathsVector.size()), linkFlow);
288  }
289 #ifdef HAVE_FOX
290  if (myNet.getThreadPool().size() > 0) {
291  myNet.getThreadPool().waitAll();
292  }
293 #endif
294  for (std::vector<ODCell*>::const_iterator i = myMatrix.getCells().begin() + (*offset); i != cellsEnd; i++) {
295  ODCell* const c = *i;
296  const SUMOReal linkFlow = c->vehicleNumber / numIter;
297  const SUMOTime begin = myAdditiveTraffic ? myBegin : c->begin;
298  const SUMOTime end = myAdditiveTraffic ? myEnd : c->end;
299  const SUMOReal intervalLengthInHours = STEPS2TIME(end - begin) / 3600.;
300  const ConstROEdgeVector& edges = c->pathsVector.back()->getEdgeVector();
301  for (ConstROEdgeVector::const_iterator e = edges.begin(); e != edges.end(); e++) {
302  ROMAEdge* edge = static_cast<ROMAEdge*>(myNet.getEdge((*e)->getID()));
303  const SUMOReal newFlow = edge->getFlow(STEPS2TIME(begin)) + linkFlow;
304  edge->setFlow(STEPS2TIME(begin), STEPS2TIME(end), newFlow);
305  SUMOReal travelTime = capacityConstraintFunction(edge, newFlow / intervalLengthInHours);
306  if (lastBegin >= 0 && myAdaptionFactor > 0.) {
307  if (loadedTravelTimes.count(edge) != 0) {
308  travelTime = loadedTravelTimes[edge] * myAdaptionFactor + (1. - myAdaptionFactor) * travelTime;
309  } else {
310  travelTime = edge->getTravelTime(myDefaultVehicle, STEPS2TIME(lastBegin)) * myAdaptionFactor + (1. - myAdaptionFactor) * travelTime;
311  }
312  }
313  edge->addTravelTime(travelTime, STEPS2TIME(begin), STEPS2TIME(end));
314  }
315  }
316  }
317  lastBegin = intervalStart;
318  }
319 }
320 
321 
322 void
323 ROMAAssignments::sue(const int maxOuterIteration, const int maxInnerIteration, const int kPaths, const SUMOReal penalty, const SUMOReal tolerance, const std::string /* routeChoiceMethod */) {
324  getKPaths(kPaths, penalty);
325  std::map<const SUMOReal, SUMOReal> intervals;
326  if (myAdditiveTraffic) {
327  intervals[STEPS2TIME(myBegin)] = STEPS2TIME(myEnd);
328  } else {
329  for (std::vector<ODCell*>::const_iterator i = myMatrix.getCells().begin(); i != myMatrix.getCells().end(); ++i) {
330  intervals[STEPS2TIME((*i)->begin)] = STEPS2TIME((*i)->end);
331  }
332  }
333  for (int outer = 0; outer < maxOuterIteration; outer++) {
334  for (int inner = 0; inner < maxInnerIteration; inner++) {
335  for (std::vector<ODCell*>::const_iterator i = myMatrix.getCells().begin(); i != myMatrix.getCells().end(); ++i) {
336  ODCell* const c = *i;
337  const SUMOTime begin = myAdditiveTraffic ? myBegin : c->begin;
338  const SUMOTime end = myAdditiveTraffic ? myEnd : c->end;
339  // update path cost
340  for (std::vector<RORoute*>::const_iterator j = c->pathsVector.begin(); j != c->pathsVector.end(); ++j) {
341  RORoute* r = *j;
343 // std::cout << std::setprecision(20) << r->getID() << ":" << r->getCosts() << std::endl;
344  }
345  // calculate route utilities and probabilities
347  // calculate route flows
348  for (std::vector<RORoute*>::const_iterator j = c->pathsVector.begin(); j != c->pathsVector.end(); ++j) {
349  RORoute* r = *j;
350  const SUMOReal pathFlow = r->getProbability() * c->vehicleNumber;
351  // assign edge flow deltas
352  for (ConstROEdgeVector::const_iterator e = r->getEdgeVector().begin(); e != r->getEdgeVector().end(); e++) {
353  ROMAEdge* edge = static_cast<ROMAEdge*>(myNet.getEdge((*e)->getID()));
354  edge->setHelpFlow(STEPS2TIME(begin), STEPS2TIME(end), edge->getHelpFlow(STEPS2TIME(begin)) + pathFlow);
355  }
356  }
357  }
358  // calculate new edge flows and check for stability
359  int unstableEdges = 0;
360  for (std::map<const SUMOReal, SUMOReal>::const_iterator i = intervals.begin(); i != intervals.end(); ++i) {
361  const SUMOReal intervalLengthInHours = STEPS2TIME(i->second - i->first) / 3600.;
362  for (std::map<std::string, ROEdge*>::const_iterator e = myNet.getEdgeMap().begin(); e != myNet.getEdgeMap().end(); ++e) {
363  ROMAEdge* edge = static_cast<ROMAEdge*>(e->second);
364  const SUMOReal oldFlow = edge->getFlow(i->first);
365  SUMOReal newFlow = oldFlow;
366  if (inner == 0 && outer == 0) {
367  newFlow += edge->getHelpFlow(i->first);
368  } else {
369  newFlow += (edge->getHelpFlow(i->first) - oldFlow) / (inner + 1);
370  }
371  // if not lohse:
372  if (newFlow > 0.) {
373  if (fabs(newFlow - oldFlow) / newFlow > tolerance) {
374  unstableEdges++;
375  }
376  } else if (newFlow == 0.) {
377  if (oldFlow != 0. && (fabs(newFlow - oldFlow) / oldFlow > tolerance)) {
378  unstableEdges++;
379  }
380  } else { // newFlow < 0.
381  unstableEdges++;
382  newFlow = 0.;
383  }
384  edge->setFlow(i->first, i->second, newFlow);
385  const SUMOReal travelTime = capacityConstraintFunction(edge, newFlow / intervalLengthInHours);
386  edge->addTravelTime(travelTime, i->first, i->second);
387  edge->setHelpFlow(i->first, i->second, 0.);
388  }
389  }
390  // if stable break
391  if (unstableEdges == 0) {
392  break;
393  }
394  // additional stability check from python script: if notstable < math.ceil(net.geteffEdgeCounts()*0.005) or notstable < 3: stable = True
395  }
396  // check for a new route, if none available, break
397  // several modifications about when a route is new and when to break are in the original script
398  bool newRoute = false;
399  for (std::vector<ODCell*>::const_iterator i = myMatrix.getCells().begin(); i != myMatrix.getCells().end(); ++i) {
400  ODCell* c = *i;
401  ConstROEdgeVector edges;
402  myRouter.compute(myNet.getEdge(c->origin + "-source"), myNet.getEdge(c->destination + "-sink"), myDefaultVehicle, 0, edges);
403  newRoute |= addRoute(edges, c->pathsVector, c->origin + c->destination + toString(c->pathsVector.size()), 0);
404  }
405  if (!newRoute) {
406  break;
407  }
408  }
409  // final round of assignment
410  for (std::vector<ODCell*>::const_iterator i = myMatrix.getCells().begin(); i != myMatrix.getCells().end(); ++i) {
411  ODCell* c = *i;
412  // update path cost
413  for (std::vector<RORoute*>::const_iterator j = c->pathsVector.begin(); j != c->pathsVector.end(); ++j) {
414  RORoute* r = *j;
416  }
417  // calculate route utilities and probabilities
419  // calculate route flows
420  for (std::vector<RORoute*>::const_iterator j = c->pathsVector.begin(); j != c->pathsVector.end(); ++j) {
421  RORoute* r = *j;
423  }
424  }
425 }
426 
427 
428 SUMOReal
429 ROMAAssignments::getPenalizedEffort(const ROEdge* const e, const ROVehicle* const v, SUMOReal t) {
430  const std::map<const ROEdge* const, SUMOReal>::const_iterator i = myPenalties.find(e);
431  return i == myPenalties.end() ? e->getEffort(v, t) : e->getEffort(v, t) + i->second;
432 }
433 
434 
435 SUMOReal
436 ROMAAssignments::getPenalizedTT(const ROEdge* const e, const ROVehicle* const v, SUMOReal t) {
437  const std::map<const ROEdge* const, SUMOReal>::const_iterator i = myPenalties.find(e);
438  return i == myPenalties.end() ? e->getTravelTime(v, t) : e->getTravelTime(v, t) + i->second;
439 }
440 
441 
442 SUMOReal
443 ROMAAssignments::getTravelTime(const ROEdge* const e, const ROVehicle* const v, SUMOReal t) {
444  return e->getTravelTime(v, t);
445 }
446 
447 
448 #ifdef HAVE_FOX
449 // ---------------------------------------------------------------------------
450 // ROMAAssignments::RoutingTask-methods
451 // ---------------------------------------------------------------------------
452 void
453 ROMAAssignments::RoutingTask::run(FXWorkerThread* context) {
454  ConstROEdgeVector edges;
455  static_cast<RONet::WorkerThread*>(context)->getVehicleRouter().compute(myAssign.myNet.getEdge(myCell->origin + "-source"), myAssign.myNet.getEdge(myCell->destination + "-sink"), myAssign.myDefaultVehicle, myBegin, edges);
456  myAssign.addRoute(edges, myCell->pathsVector, myCell->origin + myCell->destination + toString(myCell->pathsVector.size()), myLinkFlow);
457 }
458 #endif
const std::vector< ODCell * > & getCells()
Definition: ODMatrix.h:241
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
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:625
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:75
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
~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:54
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
virtual SUMOReal recomputeCosts(const std::vector< const E * > &edges, const V *const v, SUMOTime msTime) const =0
std::string destination
Name of the destination district.
Definition: ODCell.h:72
#define SUMOReal
Definition: config.h:213
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
Definition: RONet.cpp:255
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