34#define DEBUG_COND (veh.isSelected())
52#ifdef DEBUG_WANTS_CHANGE
55 std::cout <<
SIMTIME <<
" veh=" << veh.
getID() <<
" getRoundaboutDistBonus bonusParam=" << bonusParam
66 int roundaboutJunctionsAhead = 0;
67 bool enteredRoundabout =
false;
73 if (lane ==
nullptr) {
78#ifdef DEBUG_WANTS_CHANGE
80 std::cout <<
" noBonus: inner does not continue (lane=" << lane->
getID() <<
")\n";
87#ifdef DEBUG_WANTS_CHANGE
89 std::cout <<
" noBonus: seen=" << seen <<
" (lane=" << lane->
getID() <<
")\n";
96 enteredRoundabout =
true;
98 roundaboutJunctionsAhead++;
100 }
else if (enteredRoundabout) {
107 if (roundaboutJunctionsAhead < 2) {
113 double occupancyOuter = 0;
114 double occupancyInner = 0;
115 double distanceInRoundabout = 0;
116 MSLane* prevNormal =
nullptr;
117 MSLane* prevInner =
nullptr;
118 enteredRoundabout =
false;
121 if (lane ==
nullptr) {
125 enteredRoundabout =
true;
126 }
else if (enteredRoundabout) {
131 if (prevNormal !=
nullptr) {
133 if (link->getLane() == lane) {
134 via = link->getViaLane();
138 if (enteredRoundabout) {
139 distanceInRoundabout += lane->
getLength();
140 if (via !=
nullptr) {
141 distanceInRoundabout += via->
getLength();
149#ifdef DEBUG_WANTS_CHANGE
151 std::cout <<
" lane=" << lane->
getID() <<
" occ=" << lane->
getBruttoVehLenSum() <<
" discount=" << upstreamDiscount <<
" outer=" << occupancyOuter <<
"\n";
154 if (via !=
nullptr) {
156#ifdef DEBUG_WANTS_CHANGE
158 std::cout <<
" via=" << via->
getID() <<
" occ=" << via->
getBruttoVehLenSum() <<
" outer=" << occupancyOuter <<
"\n";
165#ifdef DEBUG_WANTS_CHANGE
167 std::cout <<
" inner=" << innerLane->
getID() <<
" occ=" << innerLane->
getBruttoVehLenSum() <<
" discount=" << upstreamDiscount <<
" inner=" << occupancyInner <<
"\n";
170 if (prevInner !=
nullptr) {
172 if (link->getLane() == innerLane && link->getViaLane() !=
nullptr) {
173 occupancyInner += link->getViaLane()->getBruttoVehLenSum();
174#ifdef DEBUG_WANTS_CHANGE
176 std::cout <<
" innerVia=" << link->getViaLane()->getID() <<
" occ=" << link->getViaLane()->getBruttoVehLenSum() <<
" inner=" << occupancyInner <<
"\n";
182 prevInner = innerLane;
186#ifdef DEBUG_WANTS_CHANGE
188 std::cout <<
" distanceInRoundabout=" << distanceInRoundabout
189 <<
" roundaboutJunctionsAhead=" << roundaboutJunctionsAhead
190 <<
" occupancyInner=" << occupancyInner
191 <<
" occupancyOuter=" << occupancyOuter
196 const double maxOccupancy =
MAX2(occupancyInner, occupancyOuter);
197 if (maxOccupancy == 0) {
202 const double bonus = roundaboutJunctionsAhead * 7.5;
203 const double relativeJam = (occupancyOuter - occupancyInner + bonus) / (maxOccupancy + bonus);
205 const double jamFactor =
MAX2(0.0, relativeJam);
206 const double result = distanceInRoundabout * jamFactor * bonusParam * 9;
207#ifdef DEBUG_WANTS_CHANGE
209 std::cout <<
" relativeJam=" << relativeJam
210 <<
" jamFactor=" << jamFactor
211 <<
" distanceBonus=" << result
221#ifdef DEBUG_SAVE_BLOCKER_LENGTH
224 <<
" veh=" << veh.
getID()
237#ifdef DEBUG_SAVE_BLOCKER_LENGTH
240 <<
" veh=" << veh.
getID()
242 <<
" saving myLeadingBlockerLength=" << leadingBlockerLength
251#ifdef DEBUG_SAVE_BLOCKER_LENGTH
254 <<
" veh=" << veh.
getID()
257 <<
" potential=" << potential
258 <<
" myReserved=" << leadingBlockerLength
259 <<
" canReserve=" << canReserve
260 <<
" reliefConnection=" << reliefConnection
264 if (!canReserve && !reliefConnection) {
278#ifdef DEBUG_SAVE_BLOCKER_LENGTH
280 std::cout <<
SIMTIME <<
" canSaveBlockerLength veh=" << veh.
getID() <<
" requested=" << requested <<
" leftSpace=" << leftSpace <<
" potential=" << potential <<
"\n";
283 return potential >= requested;
LaneChangeAction
The state of a vehicle's lane-change behavior.
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
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 MSVehicleType & getVehicleType() const
Returns the vehicle's type definition.
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].
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 canSaveBlockerLength(const MSVehicle &veh, double requested, double leftSpace)
static double getRoundaboutDistBonus(const MSVehicle &veh, double bonusParam, const MSVehicle::LaneQ &curr, const MSVehicle::LaneQ &neigh, const MSVehicle::LaneQ &best)
static bool saveBlockerLength(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.
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.
MSEdge & getEdge() const
Returns the lane's edge.
const std::vector< MSLink * > & getLinkCont() const
returns the container with all links !!!
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.