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