59 : myBegin(begin), myEnd(end), myAdditiveTraffic(additiveTraffic), myAdaptionFactor(adaptionFactor), myNet(net), myMatrix(matrix), myRouter(router) {
79 }
else if (roadClass == 0 || roadClass == 1) {
95 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeedLimit() <= 5.) {
113 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeedLimit() > 26.) {
132 }
else if (roadClass == 0 || roadClass == 1) {
148 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeedLimit() <= 5.) {
166 }
else if ((roadClass >= 4 || roadClass == -1) && edge->
getSpeedLimit() > 26.) {
175 std::vector<RORoute*>::iterator p;
176 for (p = paths.begin(); p != paths.end(); p++) {
177 if (edges == (*p)->getEdgeVector()) {
181 if (p == paths.end()) {
182 paths.push_back(
new RORoute(routeId, 0., prob, edges, 0, std::vector<SUMOVehicleParameter::Stop>()));
185 (*p)->addProbability(prob);
186 std::iter_swap(paths.end() - 1, p);
196 for (
int k = 0; k < kPaths; k++) {
199 for (ConstROEdgeVector::iterator e = edges.begin(); e != edges.end(); e++) {
223 std::vector<int> intervals;
226 if ((*i)->begin != lastBegin) {
227 intervals.push_back(count);
228 lastBegin = (*i)->begin;
233 for (std::vector<int>::const_iterator offset = intervals.begin(); offset != intervals.end(); offset++) {
235 if (offset != intervals.end() - 1) {
242 std::map<const ROMAEdge*, double> loadedTravelTimes;
249 for (
int t = 0; t < numIter; t++) {
253 std::string lastOrigin =
"";
255 for (std::vector<ODCell*>::const_iterator i =
myMatrix.
getCells().begin() + (*offset); i != cellsEnd; i++) {
260 if (
myNet.getThreadPool().size() > 0) {
261 if (lastOrigin != c->
origin) {
263 if (workerIndex ==
myNet.getThreadPool().size()) {
266 myNet.getThreadPool().add(
new RONet::BulkmodeTask(
false), workerIndex);
268 myNet.getThreadPool().add(
new RoutingTask(*
this, c, begin, linkFlow), workerIndex);
269 myNet.getThreadPool().add(
new RONet::BulkmodeTask(
true), workerIndex);
271 myNet.getThreadPool().add(
new RoutingTask(*
this, c, begin, linkFlow), workerIndex);
276 if (lastOrigin != c->
origin) {
286 if (
myNet.getThreadPool().size() > 0) {
287 myNet.getThreadPool().waitAll();
290 for (std::vector<ODCell*>::const_iterator i =
myMatrix.
getCells().begin() + (*offset); i != cellsEnd; i++) {
295 const double intervalLengthInHours =
STEPS2TIME(end - begin) / 3600.;
297 for (ConstROEdgeVector::const_iterator e = edges.begin(); e != edges.end(); e++) {
303 if (loadedTravelTimes.count(edge) != 0) {
313 lastBegin = intervalStart;
319 ROMAAssignments::sue(
const int maxOuterIteration,
const int maxInnerIteration,
const int kPaths,
const double penalty,
const double tolerance,
const std::string ) {
321 std::map<const double, double> intervals;
329 for (
int outer = 0; outer < maxOuterIteration; outer++) {
330 for (
int inner = 0; inner < maxInnerIteration; inner++) {
355 int unstableEdges = 0;
356 for (std::map<const double, double>::const_iterator i = intervals.begin(); i != intervals.end(); ++i) {
357 const double intervalLengthInHours =
STEPS2TIME(i->second - i->first) / 3600.;
360 const double oldFlow = edge->
getFlow(i->first);
361 double newFlow = oldFlow;
362 if (inner == 0 && outer == 0) {
365 newFlow += (edge->
getHelpFlow(i->first) - oldFlow) / (inner + 1);
369 if (fabs(newFlow - oldFlow) / newFlow > tolerance) {
372 }
else if (newFlow == 0.) {
373 if (oldFlow != 0. && (fabs(newFlow - oldFlow) / oldFlow > tolerance)) {
380 edge->
setFlow(i->first, i->second, newFlow);
387 if (unstableEdges == 0) {
394 bool newRoute =
false;
426 const std::map<const ROEdge* const, double>::const_iterator i =
myPenalties.find(e);
433 const std::map<const ROEdge* const, double>::const_iterator i =
myPenalties.find(e);
451 static_cast<RONet::WorkerThread*
>(context)->getVehicleRouter().compute(myAssign.myNet.getEdge(myCell->origin +
"-source"), myAssign.myNet.getEdge(myCell->destination +
"-sink"), myAssign.myDefaultVehicle,
myBegin, edges);
452 myAssign.addRoute(edges, myCell->pathsVector, myCell->origin + myCell->destination +
toString(myCell->pathsVector.size()), myLinkFlow);
double getFlow(const double time) const
void setProbability(double prob)
Sets the probability of the route.
const std::vector< ODCell * > & getCells()
double getSpeedLimit() const
Returns the speed allowed on this edge.
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
double getLength() const
Returns the length of the edge.
ROEdge * getEdge(const std::string &name) const
Retrieves an edge from the network.
double capacityConstraintFunction(const ROEdge *edge, const double flow) const
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.
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
bool isTazConnector() const
double getTravelTime(const ROVehicle *const veh, double time) const
Returns the travel time for this edge.
std::vector< const ROEdge * > ConstROEdgeVector
std::vector< RORoute * > pathsVector
the list of paths / routes
const bool myAdditiveTraffic
double getEffort(const ROVehicle *const veh, double time) const
Returns the effort for this edge.
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.
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)
bool addRoute(ConstROEdgeVector &edges, std::vector< RORoute * > &paths, std::string routeId, double prob)
add a route and check for duplicates
int getNumLanes() const
Returns the number of lanes this edge has.
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.
bool hasLoadedTravelTime(double time) const
Returns whether a travel time for this edge was loaded.
IDMap::const_iterator begin() const
Returns a reference to the begin iterator for the internal map.
static double getPenalizedEffort(const ROEdge *const e, const ROVehicle *const v, double t)
Returns the effort to pass an edge including penalties.
double getHelpFlow(const double time) const
const NamedObjectCont< ROEdge * > & getEdgeMap() const
The router's network representation.
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.
int getPriority() const
get edge priority (road class)
ROVehicle * myDefaultVehicle
virtual double recomputeCosts(const std::vector< const E * > &edges, const V *const v, SUMOTime msTime) const =0
void setCosts(double costs)
Sets the costs of the route.
IDMap::const_iterator end() const
Returns a reference to the end iterator for the internal map.
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()
double getProbability() const
Returns the probability the driver will take this route with.
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)