49 const double adaptionFactor,
const int maxAlternatives,
RONet& net,
ODMatrix& matrix,
51 : myBegin(begin), myEnd(end), myAdditiveTraffic(additiveTraffic), myAdaptionFactor(adaptionFactor),
52 myMaxAlternatives(maxAlternatives), myNet(net), myMatrix(matrix), myRouter(router) {
72 }
else if (roadClass == 0 || roadClass == 1) {
88 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeedLimit() <= 5.) {
106 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeedLimit() > 26.) {
125 }
else if (roadClass == 0 || roadClass == 1) {
141 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeedLimit() <= 5.) {
159 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeedLimit() > 26.) {
168 std::vector<RORoute*>::iterator p;
169 for (p = paths.begin(); p != paths.end(); p++) {
170 if (edges == (*p)->getEdgeVector()) {
174 if (p == paths.end()) {
175 paths.push_back(
new RORoute(routeId, 0., prob, edges,
nullptr, std::vector<SUMOVehicleParameter::Stop>()));
178 (*p)->addProbability(prob);
179 std::iter_swap(paths.end() - 1, p);
187 if (from ==
nullptr) {
195 if (router ==
nullptr) {
204 double minCost = std::numeric_limits<double>::max();
208 if (cost < minCost) {
223 for (
int k = 0; k < kPaths; k++) {
247 std::vector<int> intervals;
250 if (c->begin != lastBegin) {
251 intervals.push_back(count);
252 lastBegin = c->begin;
257 for (std::vector<int>::const_iterator offset = intervals.begin(); offset != intervals.end(); offset++) {
259 if (offset != intervals.end() - 1) {
266 std::map<const ROMAEdge*, double> loadedTravelTimes;
273 for (
int t = 0; t < numIter; t++) {
277 std::string lastOrigin =
"";
279 for (std::vector<ODCell*>::const_iterator i =
myMatrix.
getCells().begin() + (*offset); i != cellsEnd; i++) {
284 if (
myNet.getThreadPool().size() > 0) {
285 if (lastOrigin != c->
origin) {
287 if (workerIndex ==
myNet.getThreadPool().size()) {
290 myNet.getThreadPool().add(
new RONet::BulkmodeTask(
false), workerIndex);
292 myNet.getThreadPool().add(
new RoutingTask(*
this, c, begin, linkFlow), workerIndex);
293 myNet.getThreadPool().add(
new RONet::BulkmodeTask(
true), workerIndex);
295 myNet.getThreadPool().add(
new RoutingTask(*
this, c, begin, linkFlow), workerIndex);
300 if (lastOrigin != c->
origin) {
308 if (
myNet.getThreadPool().size() > 0) {
309 myNet.getThreadPool().waitAll();
312 for (std::vector<ODCell*>::const_iterator i =
myMatrix.
getCells().begin() + (*offset); i != cellsEnd; i++) {
317 const double intervalLengthInHours =
STEPS2TIME(end - begin) / 3600.;
319 for (ConstROEdgeVector::const_iterator e = edges.begin(); e != edges.end(); e++) {
325 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.;
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(
SVC_IGNORING));
#define WRITE_MESSAGE(msg)
std::vector< const ROEdge * > ConstROEdgeVector
std::string time2string(SUMOTime t)
convert SUMOTime to string
@ SVC_IGNORING
vehicles ignoring classes
const std::string DEFAULT_VTYPE_ID
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
A thread repeatingly calculating incoming tasks.
IDMap::const_iterator begin() const
Returns a reference to the begin iterator for the internal map.
IDMap::const_iterator end() const
Returns a reference to the end iterator for the internal map.
An O/D (origin/destination) matrix.
const std::vector< ODCell * > & getCells()
A basic edge for routing applications.
bool hasLoadedTravelTime(double time) const
Returns whether a travel time for this edge was loaded.
int getNumLanes() const
Returns the number of lanes this edge has.
int getPriority() const
get edge priority (road class)
bool isTazConnector() const
double getSpeedLimit() const
Returns the speed allowed on this edge.
double getTravelTime(const ROVehicle *const veh, double time) const
Returns the travel time for this edge.
void addTravelTime(double value, double timeBegin, double timeEnd)
Adds a travel time value.
double getEffort(const ROVehicle *const veh, double time) const
Returns the effort for this edge.
double getLength() const
Returns the length of the edge.
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.
const double myAdaptionFactor
void sue(const int maxOuterIteration, const int maxInnerIteration, const int kPaths, const double penalty, const double tolerance, const std::string routeChoiceMethod)
void getKPaths(const int kPaths, const double penalty)
get the k shortest paths
static double getPenalizedEffort(const ROEdge *const e, const ROVehicle *const v, double t)
Returns the effort to pass an edge including penalties.
void incremental(const int numIter, const bool verbose)
double capacityConstraintFunction(const ROEdge *edge, const double flow) const
const bool myAdditiveTraffic
static double getCapacity(const ROEdge *edge)
const int myMaxAlternatives
ROVehicle * myDefaultVehicle
static double getPenalizedTT(const ROEdge *const e, const ROVehicle *const v, double t)
Returns the traveltime on an edge including penalties.
static double getTravelTime(const ROEdge *const e, const ROVehicle *const v, double t)
Returns the traveltime on an edge without penalties.
static std::map< const ROEdge *const, double > myPenalties
SUMOAbstractRouter< ROEdge, ROVehicle > & myRouter
bool addRoute(const ConstROEdgeVector &edges, std::vector< RORoute * > &paths, std::string routeId, double prob)
add a route and check for duplicates
const ConstROEdgeVector computePath(ODCell *cell, const SUMOTime time=0, const double probability=0., SUMOAbstractRouter< ROEdge, ROVehicle > *router=nullptr)
~ROMAAssignments()
Destructor.
A basic edge for routing applications.
double getHelpFlow(const double time) const
void setFlow(const double begin, const double end, const double flow)
double getFlow(const double time) const
void setHelpFlow(const double begin, const double end, const double flow)
The router's network representation.
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
const NamedObjectCont< ROEdge * > & getEdgeMap() const
A complete router's route.
void setProbability(double prob)
Sets the probability of the route.
double getProbability() const
Returns the probability the driver will take this route with.
void addProbability(double prob)
add additional vehicles/probability
const ConstROEdgeVector & getEdgeVector() const
Returns the list of edges this route consists of.
void setCosts(double costs)
Sets the costs of the route.
A vehicle as used by router.
static RouteCostCalculator< R, E, V > & getCalculator()
double recomputeCosts(const std::vector< const E * > &edges, const V *const v, SUMOTime msTime, double *lengthp=nullptr) const
virtual void reset(const V *const vehicle)
reset internal caches, used by CHRouter
void setBulkMode(const bool mode)
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...
Structure representing possible vehicle parameter.
A single O/D-matrix cell.
std::string destination
Name of the destination district.
std::string origin
Name of the origin district.
std::vector< RORoute * > pathsVector
the list of paths / routes
double vehicleNumber
The number of vehicles.
bool originIsEdge
the origin "district" is an edge id
SUMOTime end
The end time this cell describes.
SUMOTime begin
The begin time this cell describes.
bool destinationIsEdge
the destination "district" is an edge id