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++) {
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;
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.;
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());
void setProbability(double prob)
Sets the probability of the route.
const std::vector< ODCell * > & getCells()
SUMOAbstractRouter< ROEdge, ROVehicle > & myRouter
bool isTazConnector() const
void addTravelTime(double value, double timeBegin, double timeEnd)
Adds a travel time value.
void getKPaths(const int kPaths, const double penalty)
get the k shortest paths
int getNumLanes() const
Returns the number of lanes this edge has.
void incremental(const int numIter, const bool verbose)
std::string time2string(SUMOTime t)
static std::map< const ROEdge *const, double > myPenalties
double getEffort(const ROVehicle *const veh, double time) const
Returns the effort for this edge.
double getLength() const
Returns the length of the edge.
std::vector< const ROEdge * > ConstROEdgeVector
std::vector< RORoute * > pathsVector
the list of paths / routes
const bool myAdditiveTraffic
const std::string DEFAULT_VTYPE_ID
double vehicleNumber
The number of vehicles.
const double myAdaptionFactor
bool hasLoadedTravelTime(double time) const
Returns whether a travel time for this edge was loaded.
A vehicle as used by router.
A single O/D-matrix cell.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
std::string origin
Name of the origin district.
ROMAAssignments(const SUMOTime begin, const SUMOTime end, const bool additiveTraffic, const double adaptionFactor, const int maxAlternatives, RONet &net, ODMatrix &matrix, SUMOAbstractRouter< ROEdge, ROVehicle > &router)
Constructor.
void setHelpFlow(const double begin, const double end, const double flow)
double getProbability() const
Returns the probability the driver will take this route with.
double recomputeCosts(const std::vector< const E *> &edges, const V *const v, SUMOTime msTime, double *lengthp=nullptr) const
An O/D (origin/destination) matrix.
bool destinationIsEdge
the destination "district" is an edge id
void setFlow(const double begin, const double end, const double flow)
virtual bool compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E *> &into, bool silent=false)=0
Builds the route between the given edges using the minimum effort at the given time The definition of...
~ROMAAssignments()
Destructor.
SUMOTime begin
The begin time this cell describes.
static double getCapacity(const ROEdge *edge)
A basic edge for routing applications.
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's network representation.
int getPriority() const
get edge priority (road class)
bool originIsEdge
the origin "district" is an edge id
Structure representing possible vehicle parameter.
const NamedObjectCont< ROEdge * > & getEdgeMap() const
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.
void setCosts(double costs)
Sets the costs of the route.
const ConstROEdgeVector & getEdgeVector() const
Returns the list of edges this route consists of.
double getSpeedLimit() const
Returns the speed allowed on this edge.
const int myMaxAlternatives
double getHelpFlow(const double time) const
bool addRoute(const ConstROEdgeVector &edges, std::vector< RORoute *> &paths, std::string routeId, double prob)
add a route and check for duplicates
double getFlow(const double time) const
std::string destination
Name of the destination district.
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
A thread repeatingly calculating incoming tasks.
void addProbability(double prob)
add additional vehicles/probability
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.
SUMOTime end
The end time this cell describes.
const ConstROEdgeVector computePath(ODCell *cell, const SUMOTime time=0, const double probability=0., SUMOAbstractRouter< ROEdge, ROVehicle > *router=nullptr)
#define WRITE_MESSAGE(msg)
A basic edge for routing applications.
A complete router's route.
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.