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<std::shared_ptr<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(std::make_shared<RORoute>(routeId, 0., prob, edges,
nullptr,
StopParVector()));
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();
210 std::shared_ptr<RORoute> minRoute =
nullptr;
211 for (
const std::shared_ptr<RORoute>& p : cell->
pathsVector) {
213 if (cost < minCost) {
218 minRoute->addProbability(probability);
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);
341 if (lastOrigin != c->
origin) {
348 if (
myNet.getThreadPool().size() > 0) {
349 myNet.getThreadPool().waitAll();
352 for (std::vector<ODCell*>::const_iterator i = firstCell; i != lastCell; i++) {
357 const double intervalLengthInHours =
STEPS2TIME(end - begin) / 3600.;
359 for (ConstROEdgeVector::const_iterator e = edges.begin(); e != edges.end(); e++) {
365 if (loadedTravelTimes.count(edge) != 0) {
377 lastBegin = intervalStart;
383ROMAAssignments::sue(
const int maxOuterIteration,
const int maxInnerIteration,
const int kPaths,
const double penalty,
const double tolerance,
const std::string ) {
385 std::map<const SUMOTime, SUMOTime> intervals;
390 intervals[c->begin] = c->end;
393 for (
int outer = 0; outer < maxOuterIteration; outer++) {
394 for (
int inner = 0; inner < maxInnerIteration; inner++) {
399 for (
const std::shared_ptr<RORoute>& r : c->pathsVector) {
406 for (
const std::shared_ptr<RORoute>& r : c->pathsVector) {
407 const double pathFlow = r->getProbability() * c->vehicleNumber;
409 for (ConstROEdgeVector::const_iterator e = r->getEdgeVector().begin(); e != r->getEdgeVector().end(); e++) {
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 (
const std::shared_ptr<RORoute>& r : c->pathsVector) {
474 for (
const std::shared_ptr<RORoute>& r : c->pathsVector) {
475 r->setProbability(r->getProbability() * c->vehicleNumber);
478 for (
const auto& it : intervals) {
486 const std::map<const ROEdge* const, double>::const_iterator i =
myPenalties.find(e);
493 const std::map<const ROEdge* const, double>::const_iterator i =
myPenalties.find(e);
510 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
std::vector< SUMOVehicleParameter::Stop > StopParVector
@ 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.
An O/D (origin/destination) matrix.
const std::vector< ODCell * > & getCells()
Static storage of an output device and its base (abstract) implementation.
OutputDevice & openTag(const std::string &xmlElement)
Opens an XML tag.
OutputDevice & writeAttr(const ATTR_TYPE &attr, const T &val, const bool isNull=false)
writes a named attribute
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.
static const ROEdgeVector & getAllEdges()
Returns all ROEdges.
ROVehicle * getDefaultVehicle() const
const ConstROEdgeVector computePath(ODCell *cell, const SUMOTime time=0, const double probability=0., SUMOAbstractRouter< ROEdge, ROVehicle > *router=nullptr, bool setBulkMode=false)
bool addRoute(const ConstROEdgeVector &edges, std::vector< std::shared_ptr< RORoute > > &paths, std::string routeId, double prob)
add a route and check for duplicates
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
~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.
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.
#define UNUSED_PARAMETER(x)
A single O/D-matrix cell.
std::string destination
Name of the destination district.
std::string origin
Name of the origin district.
double vehicleNumber
The number of vehicles.
bool originIsEdge
the origin "district" is an edge id
std::vector< std::shared_ptr< RORoute > > pathsVector
the list of paths / routes
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