34#define DEBUG_COND (veh.isSelected())
52#ifdef DEBUG_WANTS_CHANGE
55 std::cout <<
SIMTIME <<
" veh=" << veh.
getID() <<
" getRoundaboutDistBonus bonusParam=" << bonusParam
70 int roundaboutJunctionsAhead = 0;
71 bool enteredRoundabout =
false;
77 if (lane ==
nullptr) {
82#ifdef DEBUG_WANTS_CHANGE
84 std::cout <<
" noBonus: inner does not continue (lane=" << lane->
getID() <<
")\n";
91#ifdef DEBUG_WANTS_CHANGE
93 std::cout <<
" noBonus: seen=" << seen <<
" (lane=" << lane->
getID() <<
")\n";
100 enteredRoundabout =
true;
102 roundaboutJunctionsAhead++;
104 }
else if (enteredRoundabout) {
111 if (roundaboutJunctionsAhead < 2) {
112#ifdef DEBUG_WANTS_CHANGE
114 std::cout <<
" noBonus: roundaboutJunctionsAhead=" << roundaboutJunctionsAhead <<
"\n";
121 double occupancyOuter = 0;
122 double occupancyInner = 0;
123 double distanceInRoundabout = 0;
124 MSLane* prevNormal =
nullptr;
125 MSLane* prevInner =
nullptr;
126 enteredRoundabout =
false;
129 if (lane ==
nullptr) {
133 enteredRoundabout =
true;
134 }
else if (enteredRoundabout) {
139 if (prevNormal !=
nullptr) {
141 if (link->getLane() == lane) {
142 via = link->getViaLane();
146 if (enteredRoundabout) {
147 distanceInRoundabout += lane->
getLength();
148 if (via !=
nullptr) {
149 distanceInRoundabout += via->
getLength();
157#ifdef DEBUG_WANTS_CHANGE
159 std::cout <<
" lane=" << lane->
getID() <<
" occ=" << lane->
getBruttoVehLenSum() <<
" discount=" << upstreamDiscount <<
" outer=" << occupancyOuter <<
"\n";
162 if (via !=
nullptr) {
164#ifdef DEBUG_WANTS_CHANGE
166 std::cout <<
" via=" << via->
getID() <<
" occ=" << via->
getBruttoVehLenSum() <<
" outer=" << occupancyOuter <<
"\n";
173#ifdef DEBUG_WANTS_CHANGE
175 std::cout <<
" inner=" << innerLane->
getID() <<
" occ=" << innerLane->
getBruttoVehLenSum() <<
" discount=" << upstreamDiscount <<
" inner=" << occupancyInner <<
"\n";
178 if (prevInner !=
nullptr) {
180 if (link->getLane() == innerLane && link->getViaLane() !=
nullptr) {
181 occupancyInner += link->getViaLane()->getBruttoVehLenSum();
182#ifdef DEBUG_WANTS_CHANGE
184 std::cout <<
" innerVia=" << link->getViaLane()->getID() <<
" occ=" << link->getViaLane()->getBruttoVehLenSum() <<
" inner=" << occupancyInner <<
"\n";
190 prevInner = innerLane;
194#ifdef DEBUG_WANTS_CHANGE
196 std::cout <<
" distanceInRoundabout=" << distanceInRoundabout
197 <<
" roundaboutJunctionsAhead=" << roundaboutJunctionsAhead
198 <<
" occupancyInner=" << occupancyInner
199 <<
" occupancyOuter=" << occupancyOuter
206 const double leftSpace = distanceInRoundabout - reservation - veh.
getPositionOnLane();
207#ifdef DEBUG_WANTS_CHANGE
209 std::cout <<
" bGap=" << bGap <<
" reserving=" << reservation <<
" leftover=" << (leftSpace - bGap) <<
"\n";
212 if (bGap > leftSpace) {
217 const double maxOccupancy =
MAX2(occupancyInner, occupancyOuter);
219 const double bonus = roundaboutJunctionsAhead * 7.5;
220 const double relativeJam = (occupancyOuter - occupancyInner + bonus) / (maxOccupancy + bonus);
222 double jamFactor =
MAX2(0.0, relativeJam);
228 const double result = distanceInRoundabout * jamFactor * bonusParam * 9;
229#ifdef DEBUG_WANTS_CHANGE
231 std::cout <<
" relativeJam=" << relativeJam
232 <<
" jamFactor=" << jamFactor
233 <<
" distanceBonus=" << result
243#ifdef DEBUG_SAVE_BLOCKER_LENGTH
246 <<
" veh=" << veh.
getID()
259#ifdef DEBUG_SAVE_BLOCKER_LENGTH
262 <<
" veh=" << veh.
getID()
264 <<
" saving myLeadingBlockerLength=" << leadingBlockerLength
273#ifdef DEBUG_SAVE_BLOCKER_LENGTH
276 <<
" veh=" << veh.
getID()
279 <<
" potential=" << potential
280 <<
" myReserved=" << leadingBlockerLength
281 <<
" canReserve=" << canReserve
282 <<
" reliefConnection=" << reliefConnection
286 if (!canReserve && !reliefConnection) {
292#ifdef DEBUG_SAVE_BLOCKER_LENGTH
294 std::cout <<
" reserving anyway to avoid deadlock (will cause emergency braking)\n";
309#ifdef DEBUG_SAVE_BLOCKER_LENGTH
311 std::cout <<
SIMTIME <<
" canSaveBlockerLength veh=" << veh.
getID() <<
" requested=" << requested <<
" leftSpace=" << leftSpace <<
" potential=" << potential <<
"\n";
314 return potential >= requested;
332 const double nextGap = currentGap +
SPEED2DIST(leaderPlannedSpeed - follower.
getSpeed());
334 if (nextGap >= sGap) {
352 if (leader ==
nullptr) {
357 if (lane1 ==
nullptr && lane2 ==
nullptr) {
360 bool result = std::find(cont.begin(), cont.end(), lane1) != cont.end();
361 if (!result && lane1 != lane2 && lane2 !=
nullptr) {
362 result = std::find(cont.begin(), cont.end(), lane2) != cont.end();
370 if (follower ==
nullptr) {
377 if (lane1 !=
nullptr) {
378 result = std::find(route.begin(), route.end(), &lane1->
getEdge()) != route.end();
380 if (!result && lane1 != lane2 && lane2 !=
nullptr) {
381 result = std::find(route.begin(), route.end(), &lane2->
getEdge()) != route.end();
std::vector< const MSEdge * > ConstMSEdgeVector
LaneChangeAction
The state of a vehicle's lane-change behavior.
@ LCA_URGENT
The action is urgent (to be defined by lc-model)
@ LCA_STRATEGIC
The action is needed to follow the route (navigational lc)
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
virtual double getExtraReservation(int bestLaneOffset, double neighExtraDist=0) const
virtual bool saveBlockerLength(double, double)
reserve space at the end of the lane to avoid dead locks
virtual bool debugVehicle() const
whether the current vehicles shall be debugged
const MSRoute & getRoute() const
Returns the current route.
const MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
virtual double maxNextSpeed(double speed, const MSVehicle *const veh) const
Returns the maximum speed given the current speed.
virtual double minNextSpeed(double speed, const MSVehicle *const veh=0) const
Returns the minimum speed given the current speed (depends on the numerical update scheme and its ste...
virtual double getSecureGap(const MSVehicle *const veh, const MSVehicle *const, const double speed, const double leaderSpeed, const double leaderMaxDecel) const
Returns the minimum gap to reserve if the leader is braking at maximum (>=0)
double getMaxAccel() const
Get the vehicle type's maximum acceleration [m/s^2].
double brakeGap(const double speed) const
Returns the distance the vehicle needs to halt including driver's reaction time tau (i....
double getMaxDecel() const
Get the vehicle type's maximal comfortable deceleration [m/s^2].
virtual double followSpeed(const MSVehicle *const veh, double speed, double gap2pred, double predSpeed, double predMaxDecel, const MSVehicle *const pred=0, const CalcReason usage=CalcReason::CURRENT) const =0
Computes the vehicle's follow speed (no dawdling)
const MSJunction * getToJunction() const
const MSJunction * getFromJunction() const
bool isRoundabout() const
The base class for an intersection.
const ConstMSEdgeVector & getOutgoing() const
const ConstMSEdgeVector & getIncoming() const
static bool isBidiFollower(const MSVehicle *ego, const MSVehicle *follower)
static bool canSaveBlockerLength(const MSVehicle &veh, double requested, double leftSpace)
static double getSpeedPreservingSecureGap(const MSVehicle &leader, const MSVehicle &follower, double currentGap, double leaderPlannedSpeed)
static double getRoundaboutDistBonus(const MSVehicle &veh, double bonusParam, const MSVehicle::LaneQ &curr, const MSVehicle::LaneQ &neigh, const MSVehicle::LaneQ &best)
static bool isBidiLeader(const MSVehicle *leader, const std::vector< MSLane * > &cont)
static bool updateBlockerLength(const MSVehicle &veh, MSVehicle *blocker, int lcaCounter, double leftSpace, bool reliefConnection, double &leadingBlockerLength)
static bool divergentRoute(const MSVehicle &v1, const MSVehicle &v2)
return whether the vehicles are on the same junction but on divergent paths
Representation of a lane in the micro simulation.
const MSLane * getNormalSuccessorLane() const
get normal lane following this internal lane, for normal lanes, the lane itself is returned
double getBruttoVehLenSum() const
Returns the sum of lengths of vehicles, including their minGaps, which were on the lane during the la...
double getLength() const
Returns the lane's length.
int getIndex() const
Returns the lane's index.
MSLane * getBidiLane() const
retrieve bidirectional lane or nullptr
MSEdge & getEdge() const
Returns the lane's edge.
const MSLane * getNormalPredecessorLane() const
get normal lane leading to this internal lane, for normal lanes, the lane itself is returned
const std::vector< MSLink * > & getLinkCont() const
returns the container with all links !!!
const ConstMSEdgeVector & getEdges() const
Representation of a vehicle in the micro simulation.
MSAbstractLaneChangeModel & getLaneChangeModel()
double getActionStepLengthSecs() const
Returns the vehicle's action step length in secs, i.e. the interval between two action points.
const MSLane * getLane() const
Returns the lane the vehicle is on.
double getSpeed() const
Returns the vehicle's current speed.
const MSCFModel & getCarFollowModel() const
Returns the vehicle's car following model definition.
double getPositionOnLane() const
Get the vehicle's position along the lane.
double getLengthWithGap() const
Get vehicle's length including the minimum gap [m].
static std::string getIDSecure(const T *obj, const std::string &fallBack="NULL")
get an identifier for Named-like object which may be Null
const std::string & getID() const
Returns the id.
A structure representing the best lanes for continuing the current route starting at 'lane'.
std::vector< MSLane * > bestContinuations
MSLane * lane
The described lane.
int bestLaneOffset
The (signed) number of lanes to be crossed to get to the lane which allows to continue the drive.