53 : myBegin(begin), myEnd(end), myAdditiveTraffic(additiveTraffic), myAdaptionFactor(adaptionFactor), myNet(net), myMatrix(matrix), myRouter(router) {
73 }
else if (roadClass == 0 || roadClass == 1) {
89 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeedLimit() <= 5.) {
107 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeedLimit() > 26.) {
126 }
else if (roadClass == 0 || roadClass == 1) {
142 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeedLimit() <= 5.) {
160 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeedLimit() > 26.) {
169 std::vector<RORoute*>::iterator p;
170 for (p = paths.begin(); p != paths.end(); p++) {
171 if (edges == (*p)->getEdgeVector()) {
175 if (p == paths.end()) {
176 paths.push_back(
new RORoute(routeId, 0., prob, edges,
nullptr, std::vector<SUMOVehicleParameter::Stop>()));
179 (*p)->addProbability(prob);
180 std::iter_swap(paths.end() - 1, p);
190 for (
int k = 0; k < kPaths; k++) {
193 for (ConstROEdgeVector::iterator e = edges.begin(); e != edges.end(); e++) {
217 std::vector<int> intervals;
220 if ((*i)->begin != lastBegin) {
221 intervals.push_back(count);
222 lastBegin = (*i)->begin;
227 for (std::vector<int>::const_iterator offset = intervals.begin(); offset != intervals.end(); offset++) {
229 if (offset != intervals.end() - 1) {
236 std::map<const ROMAEdge*, double> loadedTravelTimes;
243 for (
int t = 0; t < numIter; t++) {
247 std::string lastOrigin =
"";
249 for (std::vector<ODCell*>::const_iterator i =
myMatrix.
getCells().begin() + (*offset); i != cellsEnd; i++) {
254 if (
myNet.getThreadPool().size() > 0) {
255 if (lastOrigin != c->
origin) {
257 if (workerIndex ==
myNet.getThreadPool().size()) {
260 myNet.getThreadPool().add(
new RONet::BulkmodeTask(
false), workerIndex);
262 myNet.getThreadPool().add(
new RoutingTask(*
this, c, begin, linkFlow), workerIndex);
263 myNet.getThreadPool().add(
new RONet::BulkmodeTask(
true), workerIndex);
265 myNet.getThreadPool().add(
new RoutingTask(*
this, c, begin, linkFlow), workerIndex);
270 if (lastOrigin != c->
origin) {
280 if (
myNet.getThreadPool().size() > 0) {
281 myNet.getThreadPool().waitAll();
284 for (std::vector<ODCell*>::const_iterator i =
myMatrix.
getCells().begin() + (*offset); i != cellsEnd; i++) {
289 const double intervalLengthInHours =
STEPS2TIME(end - begin) / 3600.;
291 for (ConstROEdgeVector::const_iterator e = edges.begin(); e != edges.end(); e++) {
297 if (loadedTravelTimes.count(edge) != 0) {
307 lastBegin = intervalStart;
313 ROMAAssignments::sue(
const int maxOuterIteration,
const int maxInnerIteration,
const int kPaths,
const double penalty,
const double tolerance,
const std::string ) {
315 std::map<const double, double> intervals;
323 for (
int outer = 0; outer < maxOuterIteration; outer++) {
324 for (
int inner = 0; inner < maxInnerIteration; inner++) {
349 int unstableEdges = 0;
350 for (std::map<const double, double>::const_iterator i = intervals.begin(); i != intervals.end(); ++i) {
351 const double intervalLengthInHours =
STEPS2TIME(i->second - i->first) / 3600.;
354 const double oldFlow = edge->
getFlow(i->first);
355 double newFlow = oldFlow;
356 if (inner == 0 && outer == 0) {
359 newFlow += (edge->
getHelpFlow(i->first) - oldFlow) / (inner + 1);
363 if (fabs(newFlow - oldFlow) / newFlow > tolerance) {
366 }
else if (newFlow == 0.) {
367 if (oldFlow != 0. && (fabs(newFlow - oldFlow) / oldFlow > tolerance)) {
374 edge->
setFlow(i->first, i->second, newFlow);
381 if (unstableEdges == 0) {
388 bool newRoute =
false;
420 const std::map<const ROEdge* const, double>::const_iterator i =
myPenalties.find(e);
427 const std::map<const ROEdge* const, double>::const_iterator i =
myPenalties.find(e);
445 static_cast<RONet::WorkerThread*
>(context)->getVehicleRouter().compute(myAssign.myNet.getEdge(myCell->origin +
"-source"), myAssign.myNet.getEdge(myCell->destination +
"-sink"), myAssign.myDefaultVehicle,
myBegin, edges);
446 myAssign.addRoute(edges, myCell->pathsVector, myCell->origin + myCell->destination +
toString(myCell->pathsVector.size()), myLinkFlow);
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)
virtual bool compute(const E *from, const E *to, const V *const vehicle, SUMOTime msTime, std::vector< const E *> &into)=0
Builds the route between the given edges using the minimum effort at the given time The definition of...
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
ROMAAssignments(const SUMOTime begin, const SUMOTime end, const bool additiveTraffic, const double adaptionFactor, RONet &net, ODMatrix &matrix, SUMOAbstractRouter< ROEdge, ROVehicle > &router)
Constructor.
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.
void setHelpFlow(const double begin, const double end, const double flow)
double getProbability() const
Returns the probability the driver will take this route with.
An O/D (origin/destination) matrix.
void setFlow(const double begin, const double end, const double flow)
~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.
bool addRoute(ConstROEdgeVector &edges, std::vector< RORoute *> &paths, std::string routeId, double prob)
add a route and check for duplicates
int getPriority() const
get edge priority (road class)
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.
double getHelpFlow(const double time) const
double getFlow(const double time) const
std::string destination
Name of the destination district.
double recomputeCosts(const std::vector< const E *> &edges, const V *const v, SUMOTime msTime) const
SUMOVTypeParameter * getVehicleTypeSecure(const std::string &id)
Retrieves the named vehicle type.
A thread repeatingly calculating incoming tasks.
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.
#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.