SUMO - Simulation of Urban MObility
NBRequest Class Reference

#include <NBRequest.h>

Collaboration diagram for NBRequest:
Collaboration graph

Public Member Functions

void buildBitfieldLogic ()
 builds the bitset-representation of the logic More...
 
void computeLogic (const bool checkLaneFoes)
 writes the XML-representation of the logic as a bitset-logic XML representation More...
 
bool foes (const NBEdge *const from1, const NBEdge *const to1, const NBEdge *const from2, const NBEdge *const to2) const
 Returns the information whether the given flows cross. More...
 
bool forbids (const NBEdge *const possProhibitorFrom, const NBEdge *const possProhibitorTo, const NBEdge *const possProhibitedFrom, const NBEdge *const possProhibitedTo, bool regardNonSignalisedLowerPriority) const
 Returns the information whether "prohibited" flow must let "prohibitor" flow pass. More...
 
const std::string & getFoes (int linkIndex) const
 
const std::string & getResponse (int linkIndex) const
 
std::pair< int, int > getSizes () const
 returns the number of the junction's lanes and the number of the junction's links in respect. More...
 
bool mergeConflict (const NBEdge *from, const NBEdge::Connection &con, const NBEdge *prohibitorFrom, const NBEdge::Connection &prohibitorCon, bool foes) const
 whether multple connections from the same edge target the same lane More...
 
bool mustBrake (const NBEdge *const possProhibitorFrom, const NBEdge *const possProhibitorTo, const NBEdge *const possProhibitedFrom, const NBEdge *const possProhibitedTo) const
 Returns the information whether "prohibited" flow must let "prohibitor" flow pass. More...
 
bool mustBrake (const NBEdge *const from, const NBEdge *const to, int fromLane, int toLane, bool includePedCrossings) const
 Returns the information whether the described flow must let any other flow pass. More...
 
 NBRequest (const NBEdgeCont &ec, NBNode *junction, const EdgeVector &all, const EdgeVector &incoming, const EdgeVector &outgoing, const NBConnectionProhibits &loadedProhibits)
 
bool oppositeLeftTurnConflict (const NBEdge *from, const NBEdge::Connection &con, const NBEdge *prohibitorFrom, const NBEdge::Connection &prohibitorCon, bool foes) const
 whether opposite left turns intersect More...
 
void writeLogic (OutputDevice &into) const
 
 ~NBRequest ()
 destructor More...
 

Static Public Member Functions

static bool mustBrakeForCrossing (const NBNode *node, const NBEdge *const from, const NBEdge *const to, const NBNode::Crossing &crossing)
 Returns the information whether the described flow must brake for the given crossing. More...
 
static void reportWarnings ()
 reports warnings if any occurred More...
 

Private Types

typedef std::vector< LinkInfoContCombinationsCont
 definition of a container for link(edge->edge) X link(edge->edge) combinations (size = |myIncoming|*|myOutgoing|) More...
 
typedef std::vector< bool > LinkInfoCont
 definition of a container to store boolean informations about a link into More...
 

Private Member Functions

bool checkLaneFoesByClass (const NBEdge::Connection &con, const NBEdge *prohibitorFrom, const NBEdge::Connection &prohibitorCon) const
 whether the given connections must be checked for lane conflicts due to the vClasses involved More...
 
bool checkLaneFoesByCooperation (const NBEdge *from, const NBEdge::Connection &con, const NBEdge *prohibitorFrom, const NBEdge::Connection &prohibitorCon) const
 whether the given connections must be checked for lane conflicts due to disjunct target lanes More...
 
int computeCrossingResponse (const NBNode::Crossing &crossing, int pos)
 computes the response of a certain crossing Returns the next link index within the junction More...
 
int computeLaneResponse (NBEdge *from, int lane, int pos, const bool checkLaneFoes)
 computes the response of a certain lane Returns the next link index within the junction More...
 
void computeLeftOutgoingLinkCrossings (NBEdge *from, NBEdge *to)
 computes the relationships between links outgoing left of the given link More...
 
void computeRightOutgoingLinkCrossings (NBEdge *from, NBEdge *to)
 computes the relationships between links outgoing right of the given link */ More...
 
int distanceCounterClockwise (NBEdge *from, NBEdge *to)
 returns the distance between the incoming (from) and the outgoing (to) edge clockwise in edges More...
 
std::string getFoesString (NBEdge *from, NBEdge *to, int fromLane, int toLane, const bool checkLaneFoes) const
 
int getIndex (const NBEdge *const from, const NBEdge *const to) const
 Returns the index to the internal combination container for the given edge combination. More...
 
std::string getResponseString (const NBEdge *const from, const NBEdge::Connection &c, const bool checkLaneFoes) const
 Writes the response of a certain link. More...
 
bool laneConflict (const NBEdge *from, const NBEdge *to, int toLane, const NBEdge *prohibitorFrom, const NBEdge *prohibitorTo, int prohibitorToLane) const
 return whether the given laneToLane connections prohibit each other under the assumption that the edge2edge connections are in conflict More...
 
int numLinks () const
 return to total number of edge-to-edge connections of this request-logic More...
 
NBRequestoperator= (const NBRequest &s)=delete
 Invalidated assignment operator. More...
 
void resetCooperating ()
 reset foes it the number of lanes matches (or exceeds) the number of incoming connections for an edge More...
 
void resetSignalised ()
 
void setBlocking (NBEdge *from1, NBEdge *to1, NBEdge *from2, NBEdge *to2)
 

Private Attributes

const EdgeVectormyAll
 all (icoming and outgoing) of the junctions edges More...
 
CombinationsCont myDone
 the link X link is done-checks More...
 
std::vector< std::string > myFoes
 precomputed right-of-way matrices for each lane-to-lane link More...
 
CombinationsCont myForbids
 the link X link blockings More...
 
std::vector< bool > myHaveVia
 
const EdgeVectormyIncoming
 edges incoming to the junction More...
 
NBNodemyJunction
 the node the request is assigned to More...
 
const EdgeVectormyOutgoing
 edges outgoing from the junction More...
 
std::vector< std::string > myResponse
 

Static Private Attributes

static int myGoodBuilds = 0
 
static int myNotBuild = 0
 

Friends

std::ostream & operator<< (std::ostream &os, const NBRequest &r)
 prints the request More...
 

Detailed Description

Given a special node, this class builds the logic of this (junction) regarding the relationships between the incoming and outgoing edges and their priorities. The junction's logic is saved when it does not yet exist.

Definition at line 59 of file NBRequest.h.

Member Typedef Documentation

◆ CombinationsCont

typedef std::vector<LinkInfoCont> NBRequest::CombinationsCont
private

definition of a container for link(edge->edge) X link(edge->edge) combinations (size = |myIncoming|*|myOutgoing|)

Definition at line 257 of file NBRequest.h.

◆ LinkInfoCont

typedef std::vector<bool> NBRequest::LinkInfoCont
private

definition of a container to store boolean informations about a link into

Definition at line 254 of file NBRequest.h.

Constructor & Destructor Documentation

◆ NBRequest()

NBRequest::NBRequest ( const NBEdgeCont ec,
NBNode junction,
const EdgeVector all,
const EdgeVector incoming,
const EdgeVector outgoing,
const NBConnectionProhibits loadedProhibits 
)

constructor The parameter are the logic's lists of edges (all, incoming only and outgoing only edges). By now no further informations are needed to describe the junctions. These parameter must not be changed during the logic's building

Definition at line 58 of file NBRequest.cpp.

References NBConnection::check(), NBConnection::getFrom(), Named::getID(), getIndex(), NBConnection::getTo(), myDone, myForbids, myGoodBuilds, myIncoming, myNotBuild, myOutgoing, numLinks(), and WRITE_WARNING.

◆ ~NBRequest()

NBRequest::~NBRequest ( )

destructor

Definition at line 143 of file NBRequest.cpp.

Member Function Documentation

◆ buildBitfieldLogic()

void NBRequest::buildBitfieldLogic ( )

builds the bitset-representation of the logic

Definition at line 147 of file NBRequest.cpp.

References computeLeftOutgoingLinkCrossings(), computeRightOutgoingLinkCrossings(), myIncoming, myOutgoing, resetCooperating(), and resetSignalised().

Referenced by NBNode::computeLogic().

◆ checkLaneFoesByClass()

bool NBRequest::checkLaneFoesByClass ( const NBEdge::Connection con,
const NBEdge prohibitorFrom,
const NBEdge::Connection prohibitorCon 
) const
private

whether the given connections must be checked for lane conflicts due to the vClasses involved

Definition at line 814 of file NBRequest.cpp.

References NBEdge::Connection::fromLane, NBEdge::getPermissions(), SVC_BICYCLE, SVC_PEDESTRIAN, NBEdge::Connection::toEdge, and NBEdge::Connection::toLane.

Referenced by getFoesString(), and getResponseString().

◆ checkLaneFoesByCooperation()

bool NBRequest::checkLaneFoesByCooperation ( const NBEdge from,
const NBEdge::Connection con,
const NBEdge prohibitorFrom,
const NBEdge::Connection prohibitorCon 
) const
private

whether the given connections must be checked for lane conflicts due to disjunct target lanes

Definition at line 827 of file NBRequest.cpp.

References NBEdge::getConnections(), and NBEdge::Connection::toEdge.

Referenced by getFoesString(), and getResponseString().

◆ computeCrossingResponse()

int NBRequest::computeCrossingResponse ( const NBNode::Crossing crossing,
int  pos 
)
private

computes the response of a certain crossing Returns the next link index within the junction

Definition at line 578 of file NBRequest.cpp.

References NBNode::Crossing::edges, foes(), NBEdge::getConnectionsFromLane(), NBNode::getCrossings(), NBEdge::getNumLanes(), mustBrakeForCrossing(), myFoes, myHaveVia, myIncoming, myJunction, and myResponse.

Referenced by computeLogic().

◆ computeLaneResponse()

int NBRequest::computeLaneResponse ( NBEdge from,
int  lane,
int  pos,
const bool  checkLaneFoes 
)
private

computes the response of a certain lane Returns the next link index within the junction

Definition at line 563 of file NBRequest.cpp.

References foes(), NBEdge::getConnectionsFromLane(), getFoesString(), getResponseString(), NBNode::getType(), myFoes, myHaveVia, myJunction, myResponse, and NODETYPE_ZIPPER.

Referenced by computeLogic().

◆ computeLeftOutgoingLinkCrossings()

void NBRequest::computeLeftOutgoingLinkCrossings ( NBEdge from,
NBEdge to 
)
private

computes the relationships between links outgoing left of the given link

Definition at line 181 of file NBRequest.cpp.

References myAll, myJunction, NBContHelper::nextCW(), and setBlocking().

Referenced by buildBitfieldLogic().

◆ computeLogic()

void NBRequest::computeLogic ( const bool  checkLaneFoes)

writes the XML-representation of the logic as a bitset-logic XML representation

Definition at line 413 of file NBRequest.cpp.

References computeCrossingResponse(), computeLaneResponse(), NBNode::getCrossings(), myFoes, myHaveVia, myIncoming, myJunction, and myResponse.

Referenced by NBNode::computeLogic2().

◆ computeRightOutgoingLinkCrossings()

void NBRequest::computeRightOutgoingLinkCrossings ( NBEdge from,
NBEdge to 
)
private

computes the relationships between links outgoing right of the given link */

Definition at line 163 of file NBRequest.cpp.

References myAll, myJunction, NBContHelper::nextCCW(), and setBlocking().

Referenced by buildBitfieldLogic().

◆ distanceCounterClockwise()

int NBRequest::distanceCounterClockwise ( NBEdge from,
NBEdge to 
)
private

returns the distance between the incoming (from) and the outgoing (to) edge clockwise in edges

Definition at line 361 of file NBRequest.cpp.

References myAll.

◆ foes()

bool NBRequest::foes ( const NBEdge *const  from1,
const NBEdge *const  to1,
const NBEdge *const  from2,
const NBEdge *const  to2 
) const

Returns the information whether the given flows cross.

Parameters
[in]from1The starting edge of the first stream
[in]to1The ending edge of the first stream
[in]from2The starting edge of the second stream
[in]to2The ending edge of the second stream
Returns
Whether both stream are foes (cross)

Definition at line 513 of file NBRequest.cpp.

References getIndex(), myForbids, myIncoming, and myOutgoing.

Referenced by computeCrossingResponse(), computeLaneResponse(), NBNode::foes(), getFoesString(), oppositeLeftTurnConflict(), and resetSignalised().

◆ forbids()

bool NBRequest::forbids ( const NBEdge *const  possProhibitorFrom,
const NBEdge *const  possProhibitorTo,
const NBEdge *const  possProhibitedFrom,
const NBEdge *const  possProhibitedTo,
bool  regardNonSignalisedLowerPriority 
) const

Returns the information whether "prohibited" flow must let "prohibitor" flow pass.

Parameters
[in]possProhibitorFromThe maybe prohibiting connection's begin
[in]possProhibitorToThe maybe prohibiting connection's end
[in]possProhibitedFromThe maybe prohibited connection's begin
[in]possProhibitedToThe maybe prohibited connection's end
[in]regardNonSignalisedLowerPriorityWhether the right of way rules without traffic lights shall be regarded
Returns
Whether the first flow prohibits the second one

Definition at line 532 of file NBRequest.cpp.

References getIndex(), NBEdge::hasSignalisedConnectionTo(), myForbids, myIncoming, and myOutgoing.

Referenced by NBNode::forbids().

◆ getFoes()

const std::string & NBRequest::getFoes ( int  linkIndex) const

Definition at line 375 of file NBRequest.cpp.

References myFoes.

Referenced by NBNode::getFoes().

◆ getFoesString()

std::string NBRequest::getFoesString ( NBEdge from,
NBEdge to,
int  fromLane,
int  toLane,
const bool  checkLaneFoes 
) const
private

◆ getIndex()

int NBRequest::getIndex ( const NBEdge *const  from,
const NBEdge *const  to 
) const
private

Returns the index to the internal combination container for the given edge combination.

If one of the edges is not known, -1 is returned.

Parameters
[in]fromThe starting edge (incoming to this logic)
[in]toThe destination edge (outgoing from this logic)
Returns
The index within the internal container

Definition at line 875 of file NBRequest.cpp.

References myIncoming, and myOutgoing.

Referenced by foes(), forbids(), getResponseString(), mustBrake(), NBRequest(), resetCooperating(), resetSignalised(), and setBlocking().

◆ getResponse()

const std::string & NBRequest::getResponse ( int  linkIndex) const

Definition at line 383 of file NBRequest.cpp.

References myResponse.

Referenced by NBNode::getResponse(), and mustBrake().

◆ getResponseString()

std::string NBRequest::getResponseString ( const NBEdge *const  from,
const NBEdge::Connection c,
const bool  checkLaneFoes 
) const
private

Writes the response of a certain link.

For the link (described by the connected edges and lanes), the response in dependence to all other links of this junction is computed. Herefor, the method goes through all links of this junction and writes a '0' if the link is not blocked by the currently investigated one, or '1' if it is.

In the case "mayDefinitelyPass" is true, the link will not be disturbed by any other (special case for on-ramps).

Parameters
[in]tlIndexThe tl index of the connection for which the responses shall be written
[in]fromThe link's starting edge
[in]toThe link's destination edge
[in]fromLaneThe link's starting lane
[in]toLaneThe link's destination lane
[in]mayDefinitelyPassWhether this link is definitely not disturbed
Returns
the response string
Exceptions
IOErrornot yet implemented

Definition at line 612 of file NBRequest.cpp.

References checkLaneFoesByClass(), checkLaneFoesByCooperation(), DEBUGCOND, NBEdge::Connection::fromLane, OptionsCont::getBool(), NBEdge::getConnection(), NBNode::getCrossings(), NBEdge::Connection::getDescription(), getIndex(), OptionsCont::getOptions(), laneConflict(), NBEdge::Connection::mayDefinitelyPass, mergeConflict(), mustBrakeForCrossing(), myForbids, myIncoming, myJunction, myOutgoing, oppositeLeftTurnConflict(), NBNode::rightOnRedConflict(), NBNode::rightTurnConflict(), NBEdge::Connection::tlLinkIndex, NBNode::tlsContConflict(), NBEdge::Connection::toEdge, and NBEdge::Connection::toLane.

Referenced by computeLaneResponse().

◆ getSizes()

std::pair< int, int > NBRequest::getSizes ( ) const

returns the number of the junction's lanes and the number of the junction's links in respect.

Note
: only connected lanes are counted

Definition at line 494 of file NBRequest.cpp.

References myIncoming.

Referenced by NBNode::numNormalConnections().

◆ laneConflict()

bool NBRequest::laneConflict ( const NBEdge from,
const NBEdge to,
int  toLane,
const NBEdge prohibitorFrom,
const NBEdge prohibitorTo,
int  prohibitorToLane 
) const
private

return whether the given laneToLane connections prohibit each other under the assumption that the edge2edge connections are in conflict

Definition at line 854 of file NBRequest.cpp.

References NBEdge::getAngleAtNode(), NBEdge::getFromNode(), NBEdge::getToNode(), NBEdge::isTurningDirectionAt(), and NBHelpers::relAngle().

Referenced by getFoesString(), and getResponseString().

◆ mergeConflict()

bool NBRequest::mergeConflict ( const NBEdge from,
const NBEdge::Connection con,
const NBEdge prohibitorFrom,
const NBEdge::Connection prohibitorCon,
bool  foes 
) const

◆ mustBrake() [1/2]

bool NBRequest::mustBrake ( const NBEdge *const  possProhibitorFrom,
const NBEdge *const  possProhibitorTo,
const NBEdge *const  possProhibitedFrom,
const NBEdge *const  possProhibitedTo 
) const

Returns the information whether "prohibited" flow must let "prohibitor" flow pass.

Parameters
[in]possProhibitorFromThe maybe prohibiting connection's begin
[in]possProhibitorToThe maybe prohibiting connection's end
[in]possProhibitedFromThe maybe prohibited connection's begin
[in]possProhibitedToThe maybe prohibited connection's end
Returns
Whether the first flow prohibits the second one

Definition at line 992 of file NBRequest.cpp.

References getIndex(), and myForbids.

Referenced by NBNode::mustBrake().

◆ mustBrake() [2/2]

bool NBRequest::mustBrake ( const NBEdge *const  from,
const NBEdge *const  to,
int  fromLane,
int  toLane,
bool  includePedCrossings 
) const

Returns the information whether the described flow must let any other flow pass.

Parameters
[in]fromThe connection's start edge
[in]toThe connection's end edge
[in]fromLaneThe connection starting lane
[in]includePedCrossingsWhether braking due to a pedestrian crossing counts
Returns
Whether the described connection must brake (has higher priorised foes)

Definition at line 906 of file NBRequest.cpp.

References NBEdge::getConnection(), NBNode::getConnectionIndex(), NBEdge::getConnections(), NBNode::getCrossings(), NBNode::getDirection(), getIndex(), getResponse(), NBNode::getType(), LINKDIR_PARTRIGHT, LINKDIR_RIGHT, mergeConflict(), mustBrakeForCrossing(), myDone, myForbids, myIncoming, myJunction, myOutgoing, myResponse, NODETYPE_ZIPPER, numLinks(), and NBNode::rightTurnConflict().

◆ mustBrakeForCrossing()

bool NBRequest::mustBrakeForCrossing ( const NBNode node,
const NBEdge *const  from,
const NBEdge *const  to,
const NBNode::Crossing crossing 
)
static

Returns the information whether the described flow must brake for the given crossing.

Parameters
[in]nodeThe parent node of this request
[in]fromThe connection's start edge
[in]toThe connection's end edge
[in]crossingThe pedestrian crossing to check
Returns
Whether the described connection must brake (has higher priorised foes)

Definition at line 976 of file NBRequest.cpp.

References NBNode::Crossing::edges, NBNode::getDirection(), LINKDIR_LEFT, LINKDIR_RIGHT, and NBNode::Crossing::priority.

Referenced by computeCrossingResponse(), getResponseString(), mustBrake(), and NBNode::mustBrakeForCrossing().

◆ numLinks()

int NBRequest::numLinks ( ) const
inlineprivate

return to total number of edge-to-edge connections of this request-logic

Definition at line 1042 of file NBRequest.cpp.

References NBNode::getCrossings(), myIncoming, myJunction, and myOutgoing.

Referenced by mustBrake(), NBRequest(), operator<<(), and writeLogic().

◆ operator=()

NBRequest& NBRequest::operator= ( const NBRequest s)
privatedelete

Invalidated assignment operator.

◆ oppositeLeftTurnConflict()

bool NBRequest::oppositeLeftTurnConflict ( const NBEdge from,
const NBEdge::Connection con,
const NBEdge prohibitorFrom,
const NBEdge::Connection prohibitorCon,
bool  foes 
) const

◆ reportWarnings()

void NBRequest::reportWarnings ( )
static

reports warnings if any occurred

Definition at line 1002 of file NBRequest.cpp.

References myGoodBuilds, myNotBuild, toString(), and WRITE_WARNING.

Referenced by NBNetBuilder::compute().

◆ resetCooperating()

void NBRequest::resetCooperating ( )
private

reset foes it the number of lanes matches (or exceeds) the number of incoming connections for an edge

Definition at line 1011 of file NBRequest.cpp.

References getIndex(), myForbids, and myIncoming.

Referenced by buildBitfieldLogic().

◆ resetSignalised()

void NBRequest::resetSignalised ( )
private

Definition at line 434 of file NBRequest.cpp.

References foes(), getIndex(), myForbids, and myIncoming.

Referenced by buildBitfieldLogic().

◆ setBlocking()

void NBRequest::setBlocking ( NBEdge from1,
NBEdge to1,
NBEdge from2,
NBEdge to2 
)
private

◆ writeLogic()

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const NBRequest r 
)
friend

prints the request

Definition at line 887 of file NBRequest.cpp.

Field Documentation

◆ myAll

const EdgeVector& NBRequest::myAll
private

all (icoming and outgoing) of the junctions edges

Definition at line 245 of file NBRequest.h.

Referenced by computeLeftOutgoingLinkCrossings(), computeRightOutgoingLinkCrossings(), distanceCounterClockwise(), and setBlocking().

◆ myDone

CombinationsCont NBRequest::myDone
private

the link X link is done-checks

Definition at line 263 of file NBRequest.h.

Referenced by mustBrake(), NBRequest(), and setBlocking().

◆ myFoes

std::vector<std::string> NBRequest::myFoes
private

precomputed right-of-way matrices for each lane-to-lane link

Definition at line 266 of file NBRequest.h.

Referenced by computeCrossingResponse(), computeLaneResponse(), computeLogic(), getFoes(), and writeLogic().

◆ myForbids

CombinationsCont NBRequest::myForbids
private

the link X link blockings

Definition at line 260 of file NBRequest.h.

Referenced by foes(), forbids(), getResponseString(), mustBrake(), NBRequest(), operator<<(), resetCooperating(), resetSignalised(), and setBlocking().

◆ myGoodBuilds

int NBRequest::myGoodBuilds = 0
staticprivate

Definition at line 271 of file NBRequest.h.

Referenced by NBRequest(), and reportWarnings().

◆ myHaveVia

std::vector<bool> NBRequest::myHaveVia
private

◆ myIncoming

◆ myJunction

◆ myNotBuild

int NBRequest::myNotBuild = 0
staticprivate

Definition at line 271 of file NBRequest.h.

Referenced by NBRequest(), and reportWarnings().

◆ myOutgoing

const EdgeVector& NBRequest::myOutgoing
private

edges outgoing from the junction

Definition at line 251 of file NBRequest.h.

Referenced by buildBitfieldLogic(), foes(), forbids(), getIndex(), getResponseString(), mergeConflict(), mustBrake(), NBRequest(), numLinks(), and setBlocking().

◆ myResponse

std::vector<std::string> NBRequest::myResponse
private

The documentation for this class was generated from the following files: