Traffic Flow Dynamics Model
Street Class Reference

Street class. More...

#include <Street.hpp>

Public Member Functions

 Street (int, int, double, int)
 Create a new Street object. More...
 
int getOrigin () const noexcept
 Get the origin node index. More...
 
int getDestination () const noexcept
 Get the destination node index. More...
 
int getIndex () const noexcept
 Get the index of the street. More...
 
double getLength () const noexcept
 Get the length of the street. More...
 
bool isFull () const noexcept
 Tells if the street is full. More...
 
void setNLanes (int)
 Set the number of lanes. More...
 
int getNLanes () const noexcept
 
int getNVehicles () const noexcept
 Get the number of vehicles on the street. More...
 
void setVMax (double)
 Set the maximum velocity. More...
 
double getInputVelocity () const noexcept
 get instant input velocity for the street More...
 
double getVMax () const noexcept
 Get the maximum velocity. More...
 
double getDensity () const noexcept
 get instant density for the street (in percentage) More...
 
double getVehicleDensity () const noexcept
 get instant vehicle density for the stree More...
 
void addVehicle (std::shared_ptr< Vehicle >)
 add a vehicle to the street More...
 
void remVehicle ()
 remove a vehicle from the street More...
 

Detailed Description

Street class.

This class is used to represent a street. It contains the source and destination nodes, the length, the maximum capacity, the number of vehicles on the street, the number of lanes, the maximum velocity and the index of the street.

Constructor & Destructor Documentation

◆ Street()

Street::Street ( int  src,
int  dst,
double  length,
int  index 
)

Create a new Street object.

Parameters
srcThe source node.
dstThe destination node.
lengthThe length of the street.
indexThe index of the street.
Exceptions
std::invalid_argumentIf at least one of the parameters is negative.

Member Function Documentation

◆ addVehicle()

void Street::addVehicle ( std::shared_ptr< Vehicle vehicle)

add a vehicle to the street

Add a vehicle to the street. Adds a vehicle to the street and changes the vehicle's parameters.

Parameters
vehicleThe vehicle to add.

◆ getDensity()

double Street::getDensity ( ) const
noexcept

get instant density for the street (in percentage)

Get the density of the street.

◆ getDestination()

int Street::getDestination ( ) const
noexcept

Get the destination node index.

Returns
The destination node index.

◆ getIndex()

int Street::getIndex ( ) const
noexcept

Get the index of the street.

Returns
The index of the street.

◆ getInputVelocity()

double Street::getInputVelocity ( ) const
noexcept

get instant input velocity for the street

Get the input velocity.

Get the entering velocity of a new vehicle based on the instant vehicle density of this street. The used formula is \(v(t) = v_{max}\left( 1 - k\frac{\rho(t)}{\rho_{max}} \right)\)

Returns
The input velocity of a vehicle immediately after its arrival on the street.

◆ getLength()

double Street::getLength ( ) const
noexcept

Get the length of the street.

Returns
The length of the street.

◆ getNVehicles()

int Street::getNVehicles ( ) const
noexcept

Get the number of vehicles on the street.

Returns
The number of vehicles on the street.

◆ getOrigin()

int Street::getOrigin ( ) const
noexcept

Get the origin node index.

Returns
The origin node index.

◆ getVehicleDensity()

double Street::getVehicleDensity ( ) const
noexcept

get instant vehicle density for the stree

Get the vehicle density of the street.

◆ getVMax()

double Street::getVMax ( ) const
noexcept

Get the maximum velocity.

Returns
The maximum velocity.

◆ isFull()

bool Street::isFull ( ) const
noexcept

Tells if the street is full.

Returns
True if the street is full, false otherwise.

◆ remVehicle()

void Street::remVehicle ( )

remove a vehicle from the street

Remove a vehicle from the street. Removes a vehicle from the street and changes the vehicle's parameters.

Exceptions
std::runtime_errorIf the number of vehicles is negative.

◆ setNLanes()

void Street::setNLanes ( int  n)

Set the number of lanes.

Parameters
nLanesThe number of lanes.
Exceptions
std::invalid_argumentIf the number of lanes is not positive.

◆ setVMax()

void Street::setVMax ( double  v)

Set the maximum velocity.

Parameters
vMaxThe maximum velocity.
Exceptions
std::invalid_argumentIf the maximum velocity is negative.

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