50 const double adaptionFactor,
const int maxAlternatives,
RONet& net,
ODMatrix& matrix,
52 : myBegin(begin), myEnd(end), myAdditiveTraffic(additiveTraffic), myAdaptionFactor(adaptionFactor),
53 myMaxAlternatives(maxAlternatives), myNet(net), myMatrix(matrix), myRouter(router) {
73 }
else if (roadClass == 0 || roadClass == 1) {
89 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeedLimit() <= 5.) {
107 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeedLimit() > 26.) {
126 }
else if (roadClass == 0 || roadClass == 1) {
142 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeedLimit() <= 5.) {
160 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeedLimit() > 26.) {
169 std::vector<RORoute*>::iterator p;
170 for (p = paths.begin(); p != paths.end(); p++) {
171 if (edges == (*p)->getEdgeVector()) {
175 if (p == paths.end()) {
176 paths.push_back(
new RORoute(routeId, 0., prob, edges,
nullptr, std::vector<SUMOVehicleParameter::Stop>()));
179 (*p)->addProbability(prob);
180 std::iter_swap(paths.end() - 1, p);
188 if (from ==
nullptr) {
196 if (router ==
nullptr) {
205 double minCost = std::numeric_limits<double>::max();
209 if (cost < minCost) {
224 for (
int k = 0; k < kPaths; k++) {
238 ROMAEdge* edge = static_cast<ROMAEdge*>(i->second);
248 std::vector<int> intervals;
251 if (c->begin != lastBegin) {
252 intervals.push_back(count);
253 lastBegin = c->begin;
258 for (std::vector<int>::const_iterator offset = intervals.begin(); offset != intervals.end(); offset++) {
260 if (offset != intervals.end() - 1) {
267 std::map<const ROMAEdge*, double> loadedTravelTimes;
269 ROMAEdge* edge = static_cast<ROMAEdge*>(i->second);
274 for (
int t = 0; t < numIter; t++) {
278 std::string lastOrigin =
"";
280 for (std::vector<ODCell*>::const_iterator i =
myMatrix.
getCells().begin() + (*offset); i != cellsEnd; i++) {
285 if (
myNet.getThreadPool().size() > 0) {
286 if (lastOrigin != c->
origin) {
288 if (workerIndex ==
myNet.getThreadPool().size()) {
291 myNet.getThreadPool().add(
new RONet::BulkmodeTask(
false), workerIndex);
293 myNet.getThreadPool().add(
new RoutingTask(*
this, c, begin, linkFlow), workerIndex);
294 myNet.getThreadPool().add(
new RONet::BulkmodeTask(
true), workerIndex);
296 myNet.getThreadPool().add(
new RoutingTask(*
this, c, begin, linkFlow), workerIndex);
301 if (lastOrigin != c->
origin) {
309 if (
myNet.getThreadPool().size() > 0) {
310 myNet.getThreadPool().waitAll();
313 for (std::vector<ODCell*>::const_iterator i =
myMatrix.
getCells().begin() + (*offset); i != cellsEnd; i++) {
318 const double intervalLengthInHours =
STEPS2TIME(end - begin) / 3600.;
320 for (ConstROEdgeVector::const_iterator e = edges.begin(); e != edges.end(); e++) {
326 if (loadedTravelTimes.count(edge) != 0) {
336 lastBegin = intervalStart;
342 ROMAAssignments::sue(
const int maxOuterIteration,
const int maxInnerIteration,
const int kPaths,
const double penalty,
const double tolerance,
const std::string ) {
344 std::map<const double, double> intervals;
352 for (
int outer = 0; outer < maxOuterIteration; outer++) {
353 for (
int inner = 0; inner < maxInnerIteration; inner++) {
358 for (std::vector<RORoute*>::const_iterator j = c->pathsVector.begin(); j != c->pathsVector.end(); ++j) {
366 for (std::vector<RORoute*>::const_iterator j = c->pathsVector.begin(); j != c->pathsVector.end(); ++j) {
377 int unstableEdges = 0;
378 for (std::map<const double, double>::const_iterator i = intervals.begin(); i != intervals.end(); ++i) {
379 const double intervalLengthInHours =
STEPS2TIME(i->second - i->first) / 3600.;
381 ROMAEdge* edge = static_cast<ROMAEdge*>(e->second);
382 const double oldFlow = edge->
getFlow(i->first);
383 double newFlow = oldFlow;
384 if (inner == 0 && outer == 0) {
387 newFlow += (edge->
getHelpFlow(i->first) - oldFlow) / (inner + 1);
391 if (fabs(newFlow - oldFlow) / newFlow > tolerance) {
394 }
else if (newFlow == 0.) {
395 if (oldFlow != 0. && (fabs(newFlow - oldFlow) / oldFlow > tolerance)) {
402 edge->
setFlow(i->first, i->second, newFlow);
409 if (unstableEdges == 0) {
416 bool newRoute =
false;
427 for (std::vector<RORoute*>::const_iterator j = c->pathsVector.begin(); j != c->pathsVector.end(); ++j) {
434 for (std::vector<RORoute*>::const_iterator j = c->pathsVector.begin(); j != c->pathsVector.end(); ++j) {
444 const std::map<const ROEdge* const, double>::const_iterator i =
myPenalties.find(e);
451 const std::map<const ROEdge* const, double>::const_iterator i =
myPenalties.find(e);
468 myAssign.computePath(myCell, myBegin, myLinkFlow, &static_cast<RONet::WorkerThread*>(context)->getVehicleRouter());