46 #ifdef CHECK_MEMORY_LEAKS 48 #endif // CHECK_MEMORY_LEAKS 64 : myBegin(begin), myEnd(end), myAdditiveTraffic(additiveTraffic), myAdaptionFactor(adaptionFactor), myNet(net), myMatrix(matrix), myRouter(router) {
84 }
else if (roadClass == 0 || roadClass == 1) {
86 }
else if (roadClass == 2 && edge->
getSpeed() <= 11.) {
88 }
else if (roadClass == 2 && edge->
getSpeed() > 11. && edge->
getSpeed() <= 16.) {
90 }
else if (roadClass == 2 && edge->
getSpeed() > 16.) {
92 }
else if (roadClass == 3 && edge->
getSpeed() <= 11.) {
94 }
else if (roadClass == 3 && edge->
getSpeed() > 11. && edge->
getSpeed() <= 13.) {
96 }
else if (roadClass == 3 && edge->
getSpeed() > 13. && edge->
getSpeed() <= 16.) {
98 }
else if (roadClass == 3 && edge->
getSpeed() > 16.) {
100 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() <= 5.) {
102 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 5. && edge->
getSpeed() <= 7.) {
104 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 7. && edge->
getSpeed() <= 9.) {
106 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 9. && edge->
getSpeed() <= 11.) {
108 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 11. && edge->
getSpeed() <= 13.) {
110 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 13. && edge->
getSpeed() <= 16.) {
112 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 16. && edge->
getSpeed() <= 18.) {
114 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 18. && edge->
getSpeed() <= 22.) {
116 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 22. && edge->
getSpeed() <= 26.) {
118 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 26.) {
137 }
else if (roadClass == 0 || roadClass == 1) {
138 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 1.3)) * 2.);
139 }
else if (roadClass == 2 && edge->
getSpeed() <= 11.) {
140 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 0.9)) * 3.);
141 }
else if (roadClass == 2 && edge->
getSpeed() > 11. && edge->
getSpeed() <= 16.) {
142 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 1.)) * 2.);
143 }
else if (roadClass == 2 && edge->
getSpeed() > 16.) {
144 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 1.3)) * 2.);
145 }
else if (roadClass == 3 && edge->
getSpeed() <= 11.) {
146 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 0.9)) * 3.);
147 }
else if (roadClass == 3 && edge->
getSpeed() > 11. && edge->
getSpeed() <= 13.) {
148 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 0.9)) * 3.);
149 }
else if (roadClass == 3 && edge->
getSpeed() > 13. && edge->
getSpeed() <= 16.) {
150 return edge->
getLength() / edge->
getSpeed() * (1. + 1.7 * (flow / (capacity * 1.)) * 2.);
151 }
else if (roadClass == 3 && edge->
getSpeed() > 16.) {
152 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 1.3)) * 2.);
153 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() <= 5.) {
154 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 0.5)) * 3.);
155 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 5. && edge->
getSpeed() <= 7.) {
156 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 0.5)) * 3.);
157 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 7. && edge->
getSpeed() <= 9.) {
158 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 0.8)) * 3.);
159 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 9. && edge->
getSpeed() <= 11.) {
160 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 0.9)) * 3.);
161 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 11. && edge->
getSpeed() <= 13.) {
162 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 0.9)) * 3.);
163 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 13. && edge->
getSpeed() <= 16.) {
164 return edge->
getLength() / edge->
getSpeed() * (1. + 1.7 * (flow / (capacity * 1.)) * 2.);
165 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 16. && edge->
getSpeed() <= 18.) {
166 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 1.)) * 2.);
167 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 18. && edge->
getSpeed() <= 22.) {
168 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 1.)) * 2.);
169 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 22. && edge->
getSpeed() <= 26.) {
170 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 1.)) * 2.);
171 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeed() > 26.) {
172 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 1.)) * 2.);
174 return edge->
getLength() / edge->
getSpeed() * (1. + 1.*(flow / (capacity * 0.9)) * 3.);
180 std::vector<RORoute*>::iterator p;
181 for (p = paths.begin(); p != paths.end(); p++) {
182 if (edges == (*p)->getEdgeVector()) {
186 if (p == paths.end()) {
187 paths.push_back(
new RORoute(routeId, 0., prob, edges, 0, std::vector<SUMOVehicleParameter::Stop>()));
190 (*p)->addProbability(prob);
191 std::iter_swap(paths.end() - 1, p);
201 for (
int k = 0; k < kPaths; k++) {
204 for (ConstROEdgeVector::iterator e = edges.begin(); e != edges.end(); e++) {
227 std::vector<int> intervals;
230 if ((*i)->begin != lastBegin) {
231 intervals.push_back(count);
232 lastBegin = (*i)->begin;
237 for (std::vector<int>::const_iterator offset = intervals.begin(); offset != intervals.end(); offset++) {
239 if (offset != intervals.end() - 1) {
246 std::map<const ROMAEdge*, SUMOReal> loadedTravelTimes;
253 for (
int t = 0; t < numIter; t++) {
257 std::string lastOrigin =
"";
259 for (std::vector<ODCell*>::const_iterator i =
myMatrix.
getCells().begin() + (*offset); i != cellsEnd; i++) {
264 if (
myNet.getThreadPool().size() > 0) {
265 if (lastOrigin != c->
origin) {
267 if (workerIndex ==
myNet.getThreadPool().size()) {
270 myNet.getThreadPool().add(
new RONet::BulkmodeTask(
false), workerIndex);
272 myNet.getThreadPool().add(
new RoutingTask(*
this, c, begin, linkFlow), workerIndex);
273 myNet.getThreadPool().add(
new RONet::BulkmodeTask(
true), workerIndex);
275 myNet.getThreadPool().add(
new RoutingTask(*
this, c, begin, linkFlow), workerIndex);
280 if (lastOrigin != c->
origin) {
290 if (
myNet.getThreadPool().size() > 0) {
291 myNet.getThreadPool().waitAll();
294 for (std::vector<ODCell*>::const_iterator i =
myMatrix.
getCells().begin() + (*offset); i != cellsEnd; i++) {
301 for (ConstROEdgeVector::const_iterator e = edges.begin(); e != edges.end(); e++) {
307 if (loadedTravelTimes.count(edge) != 0) {
317 lastBegin = intervalStart;
325 std::map<const SUMOReal, SUMOReal> intervals;
333 for (
int outer = 0; outer < maxOuterIteration; outer++) {
334 for (
int inner = 0; inner < maxInnerIteration; inner++) {
359 int unstableEdges = 0;
360 for (std::map<const SUMOReal, SUMOReal>::const_iterator i = intervals.begin(); i != intervals.end(); ++i) {
366 if (inner == 0 && outer == 0) {
369 newFlow += (edge->
getHelpFlow(i->first) - oldFlow) / (inner + 1);
373 if (fabs(newFlow - oldFlow) / newFlow > tolerance) {
376 }
else if (newFlow == 0.) {
377 if (oldFlow != 0. && (fabs(newFlow - oldFlow) / oldFlow > tolerance)) {
384 edge->
setFlow(i->first, i->second, newFlow);
391 if (unstableEdges == 0) {
398 bool newRoute =
false;
430 const std::map<const ROEdge* const, SUMOReal>::const_iterator i =
myPenalties.find(e);
437 const std::map<const ROEdge* const, SUMOReal>::const_iterator i =
myPenalties.find(e);
455 static_cast<RONet::WorkerThread*
>(context)->getVehicleRouter().compute(myAssign.myNet.getEdge(myCell->origin +
"-source"), myAssign.myNet.getEdge(myCell->destination +
"-sink"), myAssign.myDefaultVehicle,
myBegin, edges);
456 myAssign.addRoute(edges, myCell->pathsVector, myCell->origin + myCell->destination +
toString(myCell->pathsVector.size()), myLinkFlow);
const std::vector< ODCell * > & getCells()
SUMOAbstractRouter< ROEdge, ROVehicle > & myRouter
SUMOReal getFlow(const SUMOReal time) const
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
ROMAAssignments(const SUMOTime begin, const SUMOTime end, const bool additiveTraffic, const SUMOReal adaptionFactor, RONet &net, ODMatrix &matrix, SUMOAbstractRouter< ROEdge, ROVehicle > &router)
Constructor.
void incremental(const int numIter, const bool verbose)
std::string time2string(SUMOTime t)
const ConstROEdgeVector & getEdgeVector() const
Returns the list of edges this route consists of.
void setProbability(SUMOReal prob)
Sets the probability of the route.
EdgeFunc getFunc() const
Returns the function of the edge.
void setFlow(const SUMOReal begin, const SUMOReal end, const SUMOReal flow)
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...
unsigned int getLaneNo() const
Returns the number of lanes this edge has.
std::vector< const ROEdge * > ConstROEdgeVector
std::vector< RORoute * > pathsVector
the list of paths / routes
const bool myAdditiveTraffic
const std::string DEFAULT_VTYPE_ID
void addTravelTime(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd)
Adds a travel time value.
const std::map< std::string, ROEdge * > & getEdgeMap() const
bool hasLoadedTravelTime(SUMOReal time) const
Returns whether a travel time for this edge was loaded.
A vehicle as used by router.
A single O/D-matrix cell.
void setHelpFlow(const SUMOReal begin, const SUMOReal end, const SUMOReal flow)
std::string origin
Name of the origin district.
static SUMOReal getPenalizedTT(const ROEdge *const e, const ROVehicle *const v, SUMOReal t)
Returns the traveltime on an edge including penalties.
void sue(const int maxOuterIteration, const int maxInnerIteration, const int kPaths, const SUMOReal penalty, const SUMOReal tolerance, const std::string routeChoiceMethod)
An O/D (origin/destination) matrix.
bool addRoute(ConstROEdgeVector &edges, std::vector< RORoute * > &paths, std::string routeId, SUMOReal prob)
add a route and check for duplicates
SUMOReal getProbability() const
Returns the probability the driver will take this route with.
void setCosts(SUMOReal costs)
Sets the costs of the route.
~ROMAAssignments()
Destructor.
SUMOReal vehicleNumber
The number of vehicles.
static std::map< const ROEdge *const, SUMOReal > myPenalties
static SUMOReal getTravelTime(const ROEdge *const e, const ROVehicle *const v, SUMOReal t)
Returns the traveltime on an edge without penalties.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
static SUMOReal getPenalizedEffort(const ROEdge *const e, const ROVehicle *const v, SUMOReal t)
Returns the effort to pass an edge including penalties.
SUMOTime begin
The begin time this cell describes.
A basic edge for routing applications.
SUMOReal getHelpFlow(const SUMOReal time) const
static SUMOReal getCapacity(const ROEdge *edge)
The router's network representation.
Structure representing possible vehicle parameter.
int getPriority() const
get edge priority (road class)
SUMOReal getLength() const
Returns the length of the edge.
ROVehicle * myDefaultVehicle
SUMOReal getEffort(const ROVehicle *const veh, SUMOReal time) const
Returns the effort for this edge.
void getKPaths(const int kPaths, const SUMOReal penalty)
get the k shortest paths
virtual SUMOReal recomputeCosts(const std::vector< const E * > &edges, const V *const v, SUMOTime msTime) const =0
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.
SUMOReal getTravelTime(const ROVehicle *const veh, SUMOReal time) const
Returns the travel time for this edge.
static RouteCostCalculator< R, E, V > & getCalculator()
SUMOTime end
The end time this cell describes.
An edge representing a whole district.
#define WRITE_MESSAGE(msg)
SUMOReal capacityConstraintFunction(const ROEdge *edge, const SUMOReal flow) const
A basic edge for routing applications.
SUMOReal getSpeed() const
Returns the speed allowed on this edge.
A complete router's route.
void setBulkMode(const bool mode)
const SUMOReal myAdaptionFactor