51 const double adaptionFactor,
const int maxAlternatives,
RONet& net,
ODMatrix& matrix,
53 : myBegin(begin), myEnd(end), myAdditiveTraffic(additiveTraffic), myAdaptionFactor(adaptionFactor),
54 myMaxAlternatives(maxAlternatives), myNet(net), myMatrix(matrix), myRouter(router) {
74 }
else if (roadClass == 0 || roadClass == 1) {
90 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeedLimit() <= 5.) {
108 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeedLimit() > 26.) {
127 }
else if (roadClass == 0 || roadClass == 1) {
143 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeedLimit() <= 5.) {
161 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeedLimit() > 26.) {
170 std::vector<RORoute*>::iterator p;
171 for (p = paths.begin(); p != paths.end(); p++) {
172 if (edges == (*p)->getEdgeVector()) {
176 if (p == paths.end()) {
177 paths.push_back(
new RORoute(routeId, 0., prob, edges,
nullptr, std::vector<SUMOVehicleParameter::Stop>()));
180 (*p)->addProbability(prob);
181 std::iter_swap(paths.end() - 1, p);
189 if (from ==
nullptr) {
197 if (router ==
nullptr) {
206 double minCost = std::numeric_limits<double>::max();
210 if (cost < minCost) {
225 for (
int k = 0; k < kPaths; k++) {
239 ROMAEdge* edge = static_cast<ROMAEdge*>(i->second);
249 std::vector<int> intervals;
252 if (c->begin != lastBegin) {
253 intervals.push_back(count);
254 lastBegin = c->begin;
259 for (std::vector<int>::const_iterator offset = intervals.begin(); offset != intervals.end(); offset++) {
261 if (offset != intervals.end() - 1) {
268 std::map<const ROMAEdge*, double> loadedTravelTimes;
270 ROMAEdge* edge = static_cast<ROMAEdge*>(i->second);
275 for (
int t = 0; t < numIter; t++) {
279 std::string lastOrigin =
"";
281 for (std::vector<ODCell*>::const_iterator i =
myMatrix.
getCells().begin() + (*offset); i != cellsEnd; i++) {
286 if (
myNet.getThreadPool().size() > 0) {
287 if (lastOrigin != c->
origin) {
289 if (workerIndex ==
myNet.getThreadPool().size()) {
292 myNet.getThreadPool().add(
new RONet::BulkmodeTask(
false), workerIndex);
294 myNet.getThreadPool().add(
new RoutingTask(*
this, c, begin, linkFlow), workerIndex);
295 myNet.getThreadPool().add(
new RONet::BulkmodeTask(
true), workerIndex);
297 myNet.getThreadPool().add(
new RoutingTask(*
this, c, begin, linkFlow), workerIndex);
302 if (lastOrigin != c->
origin) {
310 if (
myNet.getThreadPool().size() > 0) {
311 myNet.getThreadPool().waitAll();
314 for (std::vector<ODCell*>::const_iterator i =
myMatrix.
getCells().begin() + (*offset); i != cellsEnd; i++) {
319 const double intervalLengthInHours =
STEPS2TIME(end - begin) / 3600.;
321 for (ConstROEdgeVector::const_iterator e = edges.begin(); e != edges.end(); e++) {
327 if (loadedTravelTimes.count(edge) != 0) {
337 lastBegin = intervalStart;
343 ROMAAssignments::sue(
const int maxOuterIteration,
const int maxInnerIteration,
const int kPaths,
const double penalty,
const double tolerance,
const std::string ) {
345 std::map<const double, double> intervals;
353 for (
int outer = 0; outer < maxOuterIteration; outer++) {
354 for (
int inner = 0; inner < maxInnerIteration; inner++) {
359 for (std::vector<RORoute*>::const_iterator j = c->pathsVector.begin(); j != c->pathsVector.end(); ++j) {
367 for (std::vector<RORoute*>::const_iterator j = c->pathsVector.begin(); j != c->pathsVector.end(); ++j) {
378 int unstableEdges = 0;
379 for (std::map<const double, double>::const_iterator i = intervals.begin(); i != intervals.end(); ++i) {
380 const double intervalLengthInHours =
STEPS2TIME(i->second - i->first) / 3600.;
382 ROMAEdge* edge = static_cast<ROMAEdge*>(e->second);
383 const double oldFlow = edge->
getFlow(i->first);
384 double newFlow = oldFlow;
385 if (inner == 0 && outer == 0) {
388 newFlow += (edge->
getHelpFlow(i->first) - oldFlow) / (inner + 1);
392 if (fabs(newFlow - oldFlow) / newFlow > tolerance) {
395 }
else if (newFlow == 0.) {
396 if (oldFlow != 0. && (fabs(newFlow - oldFlow) / oldFlow > tolerance)) {
403 edge->
setFlow(i->first, i->second, newFlow);
410 if (unstableEdges == 0) {
417 bool newRoute =
false;
428 for (std::vector<RORoute*>::const_iterator j = c->pathsVector.begin(); j != c->pathsVector.end(); ++j) {
435 for (std::vector<RORoute*>::const_iterator j = c->pathsVector.begin(); j != c->pathsVector.end(); ++j) {
445 const std::map<const ROEdge* const, double>::const_iterator i =
myPenalties.find(e);
452 const std::map<const ROEdge* const, double>::const_iterator i =
myPenalties.find(e);
469 myAssign.computePath(myCell, myBegin, myLinkFlow, &static_cast<RONet::WorkerThread*>(context)->getVehicleRouter());