49 const double adaptionFactor,
const int maxAlternatives,
const bool defaultCapacities,
52 : myBegin(begin), myEnd(end), myAdditiveTraffic(additiveTraffic), myAdaptionFactor(adaptionFactor),
53 myMaxAlternatives(maxAlternatives), myUseDefaultCapacities(defaultCapacities),
54 myNet(net), myMatrix(matrix), myRouter(router), myNetloadOutput(netloadOutput) {
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) {
209 double minCost = std::numeric_limits<double>::max();
213 if (cost < minCost) {
228 for (
int k = 0; k < kPaths; k++) {
258 const double speed = edge->
getLength() / traveltime;
260 const double timeGap =
STEPS2TIME(end - begin) / flow;
261 const double spaceGap = timeGap * speed;
262 const double density = 1000.0 / spaceGap;
263 const double laneDensity = density / edge->
getNumLanes();
282 std::vector<int> intervals;
285 if (c->begin != lastBegin) {
286 intervals.push_back(count);
287 lastBegin = c->begin;
292 for (std::vector<int>::const_iterator offset = intervals.begin(); offset != intervals.end(); offset++) {
293 std::vector<ODCell*>::const_iterator firstCell =
myMatrix.
getCells().begin() + (*offset);
295 if (offset != intervals.end() - 1) {
298 const SUMOTime intervalStart = (*firstCell)->begin;
302 std::map<const ROMAEdge*, double> loadedTravelTimes;
309 if (loadedTravelTimes.empty()) {
313 for (
int t = 0; t < numIter; t++) {
317 std::string lastOrigin =
"";
319 for (std::vector<ODCell*>::const_iterator i = firstCell; i != lastCell; i++) {
324 if (
myNet.getThreadPool().size() > 0) {
325 if (lastOrigin != c->
origin) {
327 if (workerIndex ==
myNet.getThreadPool().size()) {
330 myNet.getThreadPool().add(
new RONet::BulkmodeTask(
false), workerIndex);
332 myNet.getThreadPool().add(
new RoutingTask(*
this, c, begin, linkFlow), workerIndex);
334 myNet.getThreadPool().add(
new RoutingTask(*
this, c, begin, linkFlow), workerIndex);
339 if (lastOrigin != c->
origin) {
346 if (
myNet.getThreadPool().size() > 0) {
347 myNet.getThreadPool().waitAll();
350 for (std::vector<ODCell*>::const_iterator i = firstCell; i != lastCell; i++) {
355 const double intervalLengthInHours =
STEPS2TIME(end - begin) / 3600.;
357 for (ConstROEdgeVector::const_iterator e = edges.begin(); e != edges.end(); e++) {
363 if (loadedTravelTimes.count(edge) != 0) {
375 lastBegin = intervalStart;
381ROMAAssignments::sue(
const int maxOuterIteration,
const int maxInnerIteration,
const int kPaths,
const double penalty,
const double tolerance,
const std::string ) {
383 std::map<const SUMOTime, SUMOTime> intervals;
388 intervals[c->begin] = c->end;
391 for (
int outer = 0; outer < maxOuterIteration; outer++) {
392 for (
int inner = 0; inner < maxInnerIteration; inner++) {
397 for (std::vector<RORoute*>::const_iterator j = c->pathsVector.begin(); j != c->pathsVector.end(); ++j) {
405 for (std::vector<RORoute*>::const_iterator j = c->pathsVector.begin(); j != c->pathsVector.end(); ++j) {
416 int unstableEdges = 0;
417 for (
const auto& it : intervals) {
418 const double intervalLengthInHours =
STEPS2TIME(it.second - it.first) / 3600.;
423 const double oldFlow = edge->
getFlow(intBegin);
424 double newFlow = oldFlow;
425 if (inner == 0 && outer == 0) {
428 newFlow += (edge->
getHelpFlow(intBegin) - oldFlow) / (inner + 1);
432 if (fabs(newFlow - oldFlow) / newFlow > tolerance) {
435 }
else if (newFlow == 0.) {
436 if (oldFlow != 0. && (fabs(newFlow - oldFlow) / oldFlow > tolerance)) {
443 edge->
setFlow(intBegin, intEnd, newFlow);
450 if (unstableEdges == 0) {
457 bool newRoute =
false;
468 for (std::vector<RORoute*>::const_iterator j = c->pathsVector.begin(); j != c->pathsVector.end(); ++j) {
475 for (std::vector<RORoute*>::const_iterator j = c->pathsVector.begin(); j != c->pathsVector.end(); ++j) {
480 for (
const auto& it : intervals) {
488 const std::map<const ROEdge* const, double>::const_iterator i =
myPenalties.find(e);
495 const std::map<const ROEdge* const, double>::const_iterator i =
myPenalties.find(e);
512 myAssign.computePath(myCell, myBegin, myLinkFlow, &
static_cast<RONet::WorkerThread*
>(context)->getVehicleRouter(
SVC_IGNORING), mySetBulkMode);
#define WRITE_MESSAGE(msg)
std::vector< const ROEdge * > ConstROEdgeVector
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
const std::string DEFAULT_VTYPE_ID
@ SVC_IGNORING
vehicles ignoring classes
@ SUMO_TAG_INTERVAL
an aggreagated-output interval
@ SUMO_TAG_EDGE
begin/end of the description of an edge
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_END
weights: time range end
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
A thread repeatingly calculating incoming tasks.
const std::string & getID() const
Returns the id.
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()
Static storage of an output device and its base (abstract) implementation.
OutputDevice & writeAttr(const SumoXMLAttr attr, const T &val)
writes a named attribute
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
bool closeTag(const std::string &comment="")
Closes the most recently opened tag and optionally adds a comment.
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.
static void disableTimelineWarning()
SumoXMLEdgeFunc getFunction() const
Returns the function of the 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.
ROVehicle * getDefaultVehicle() const
const ConstROEdgeVector computePath(ODCell *cell, const SUMOTime time=0, const double probability=0., SUMOAbstractRouter< ROEdge, ROVehicle > *router=nullptr, bool setBulkMode=false)
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
double getCapacity(const ROEdge *edge) const
const bool myAdditiveTraffic
const int myMaxAlternatives
void writeInterval(const SUMOTime begin, const SUMOTime end)
ROMAAssignments(const SUMOTime begin, const SUMOTime end, const bool additiveTraffic, const double adaptionFactor, const int maxAlternatives, const bool defaultCapacities, RONet &net, ODMatrix &matrix, SUMOAbstractRouter< ROEdge, ROVehicle > &router, OutputDevice *netloadOutput)
Constructor.
ROVehicle * myDefaultVehicle
OutputDevice *const myNetloadOutput
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
const bool myUseDefaultCapacities
bool addRoute(const ConstROEdgeVector &edges, std::vector< RORoute * > &paths, std::string routeId, double prob)
add a route and check for duplicates
~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()
virtual void setBulkMode(const bool mode)
virtual void reset(const V *const vehicle)
reset internal caches, used by CHRouter
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...
virtual double recomputeCosts(const std::vector< const E * > &edges, const V *const v, SUMOTime msTime, double *lengthp=nullptr) const
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