60 : myBegin(begin), myEnd(end), myAdditiveTraffic(additiveTraffic), myAdaptionFactor(adaptionFactor), myNet(net), myMatrix(matrix), myRouter(router) {
80 }
else if (roadClass == 0 || roadClass == 1) {
96 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeedLimit() <= 5.) {
114 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeedLimit() > 26.) {
133 }
else if (roadClass == 0 || roadClass == 1) {
149 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeedLimit() <= 5.) {
167 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeedLimit() > 26.) {
176 std::vector<RORoute*>::iterator p;
177 for (p = paths.begin(); p != paths.end(); p++) {
178 if (edges == (*p)->getEdgeVector()) {
182 if (p == paths.end()) {
183 paths.push_back(
new RORoute(routeId, 0., prob, edges, 0, std::vector<SUMOVehicleParameter::Stop>()));
186 (*p)->addProbability(prob);
187 std::iter_swap(paths.end() - 1, p);
197 for (
int k = 0; k < kPaths; k++) {
200 for (ConstROEdgeVector::iterator e = edges.begin(); e != edges.end(); e++) {
224 std::vector<int> intervals;
227 if ((*i)->begin != lastBegin) {
228 intervals.push_back(count);
229 lastBegin = (*i)->begin;
234 for (std::vector<int>::const_iterator offset = intervals.begin(); offset != intervals.end(); offset++) {
236 if (offset != intervals.end() - 1) {
243 std::map<const ROMAEdge*, double> loadedTravelTimes;
250 for (
int t = 0; t < numIter; t++) {
254 std::string lastOrigin =
"";
256 for (std::vector<ODCell*>::const_iterator i =
myMatrix.
getCells().begin() + (*offset); i != cellsEnd; i++) {
261 if (
myNet.getThreadPool().size() > 0) {
262 if (lastOrigin != c->
origin) {
264 if (workerIndex ==
myNet.getThreadPool().size()) {
267 myNet.getThreadPool().add(
new RONet::BulkmodeTask(
false), workerIndex);
269 myNet.getThreadPool().add(
new RoutingTask(*
this, c, begin, linkFlow), workerIndex);
270 myNet.getThreadPool().add(
new RONet::BulkmodeTask(
true), workerIndex);
272 myNet.getThreadPool().add(
new RoutingTask(*
this, c, begin, linkFlow), workerIndex);
277 if (lastOrigin != c->
origin) {
287 if (
myNet.getThreadPool().size() > 0) {
288 myNet.getThreadPool().waitAll();
291 for (std::vector<ODCell*>::const_iterator i =
myMatrix.
getCells().begin() + (*offset); i != cellsEnd; i++) {
296 const double intervalLengthInHours =
STEPS2TIME(end - begin) / 3600.;
298 for (ConstROEdgeVector::const_iterator e = edges.begin(); e != edges.end(); e++) {
304 if (loadedTravelTimes.count(edge) != 0) {
314 lastBegin = intervalStart;
320 ROMAAssignments::sue(
const int maxOuterIteration,
const int maxInnerIteration,
const int kPaths,
const double penalty,
const double tolerance,
const std::string ) {
322 std::map<const double, double> intervals;
330 for (
int outer = 0; outer < maxOuterIteration; outer++) {
331 for (
int inner = 0; inner < maxInnerIteration; inner++) {
356 int unstableEdges = 0;
357 for (std::map<const double, double>::const_iterator i = intervals.begin(); i != intervals.end(); ++i) {
358 const double intervalLengthInHours =
STEPS2TIME(i->second - i->first) / 3600.;
361 const double oldFlow = edge->
getFlow(i->first);
362 double newFlow = oldFlow;
363 if (inner == 0 && outer == 0) {
366 newFlow += (edge->
getHelpFlow(i->first) - oldFlow) / (inner + 1);
370 if (fabs(newFlow - oldFlow) / newFlow > tolerance) {
373 }
else if (newFlow == 0.) {
374 if (oldFlow != 0. && (fabs(newFlow - oldFlow) / oldFlow > tolerance)) {
381 edge->
setFlow(i->first, i->second, newFlow);
388 if (unstableEdges == 0) {
395 bool newRoute =
false;
427 const std::map<const ROEdge* const, double>::const_iterator i =
myPenalties.find(e);
434 const std::map<const ROEdge* const, double>::const_iterator i =
myPenalties.find(e);
452 static_cast<RONet::WorkerThread*
>(context)->getVehicleRouter().compute(myAssign.myNet.getEdge(myCell->origin +
"-source"), myAssign.myNet.getEdge(myCell->destination +
"-sink"), myAssign.myDefaultVehicle,
myBegin, edges);
453 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
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
virtual double recomputeCosts(const std::vector< const E *> &edges, const V *const v, SUMOTime msTime) const =0
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.
EdgeFunc getFunc() const
Returns the function of the edge.
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.
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 std::map< std::string, ROEdge * > & getEdgeMap() const
double getHelpFlow(const double time) const
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 sue(const int maxOuterIteration, const int maxInnerIteration, const int kPaths, const double penalty, const double tolerance, const std::string routeChoiceMethod)
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.
An edge representing a whole district.
#define WRITE_MESSAGE(msg)
A basic edge for routing applications.
int getLaneNo() const
Returns the number of lanes this edge has.
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)