C++ API Reference#
This page documents the C++ simulation core behind PyBTLS. The Python API Reference binds to these classes through pybind11 — users of the Python API do not normally need to read this section. It is intended for contributors extending the simulation core and researchers who want to understand the numerical behaviour in detail.
Note
C++ API documentation is being rolled out class by class on the
docs-overhaul branch. The currently documented classes are listed
below; additional classes will be added in subsequent commits.
Bridge and lanes#
-
class CBridge#
A single bridge carrying one or more lanes of traffic.
CBridge owns the lanes on a bridge, the load-effect event manager, and the set of vehicles currently on the bridge. It advances the simulation clock through Update(), stepping through load-effect calculations at a fixed interval until the next vehicle arrives at the bridge entry.
A BTLS simulation typically contains one or more bridges, each built from a CConfigDataCore describing the road layout, influence lines, and event thresholds. Bridges are independent of each other: a vehicle on the road is copied onto every bridge it interacts with.
See also
See also
Note
Units used throughout: length in metres, time in seconds, load effects in whatever units the influence line returns (typically kN·m for moments, kN for shears).
Public Functions
-
CBridge(CConfigDataCore &config)#
Construct a bridge from a road configuration.
Copies lane-count fields from the road configuration but does not initialize lanes; InitializeLanes() must be called before use.
- Parameters:
config – [in] Road configuration block shared by all bridges in the simulation.
-
void setCurrentSimTime(double curTime)#
Set the internal simulation clock.
Called at the start of Update(); rarely needs to be invoked directly.
- Parameters:
curTime – [in] Current simulation time in seconds.
-
void AddVehicle(const CVehicle_sp &pVeh)#
Add a vehicle to the bridge.
The vehicle is copied onto the heap so the same source vehicle can be added to multiple bridges in a multi-bridge simulation. The copy is routed to the lane whose index matches the vehicle’s global lane number.
- Parameters:
pVeh – [in] Shared pointer to the source vehicle.
-
void setCalcTimeStep(double calcTimeStep)#
Set the time step used for load-effect calculation.
Smaller steps give more accurate peak capture but scale the inner loop cost linearly. Typical values are 0.01–0.1 seconds for short-span bridges.
- Parameters:
calcTimeStep – [in] Time step in seconds.
-
void setLength(double length)#
Set the bridge length.
Must be called before InitializeLanes() and InitializeDataMgr().
- Parameters:
length – [in] Bridge length in metres.
-
void Update(double NextArrivalTime, double curTime)#
Advance the simulation to the next vehicle arrival.
Core inner loop of the simulation. Starting from
curTime, the method steps the clock forward bym_CalcTimeStepuntil eitherNextArrivalTimeis reached or a vehicle leaves the bridge, whichever is earlier. At each step it updates every lane, sums the per-lane load effects, and hands the result to the event manager. When a vehicle leaves or the next arrival is reached it closes the current event and begins a new one. The method returns when no vehicles remain on the bridge or the next arrival time is reached.The wall-clock cost of long simulations is dominated by this method.
See also
See also
See also
- Parameters:
NextArrivalTime – [in] Time of the next vehicle arrival, in seconds.
curTime – [in] Current simulation time, in seconds.
-
void setThresholds(std::vector<double> vThresholds)#
Set the peak-recording thresholds used by the event manager.
Each element corresponds to one load effect and controls which local maxima are recorded. A threshold of zero captures every local maximum.
- Parameters:
vThresholds – [in] Threshold per load effect; size must equal the value set by setNoLoadEffects().
-
void Finish()#
Flush remaining events and close the event manager.
Call once at the end of the simulation so that buffered peaks and block maxima are written out by their respective output managers.
-
size_t getIndex(void)#
Get the bridge index within the simulation.
-
void setIndex(size_t index)#
Set the bridge index within the simulation.
-
double getLength(void)#
Get the bridge length in metres.
-
void InitializeLanes(size_t NoLanes)#
Create
NoLaneslanes on the bridge.Each lane is constructed with the current bridge length and assigned a zero-based index. setLength() must be called first.
- Parameters:
NoLanes – [in] Number of lanes to create (across both directions).
-
void setNoLoadEffects(size_t nLE)#
Set the number of load effects tracked on this bridge.
- Parameters:
nLE – [in] Number of load effects.
-
size_t getNoLoadEffects(void)#
Get the number of load effects tracked on this bridge.
-
void InitializeDataMgr(double SimStartTime)#
Initialize the event-manager data stores.
Allocates per-load-effect buffers inside the event manager. Must be called after setLength(), setThresholds() and setNoLoadEffects().
- Parameters:
SimStartTime – [in] Simulation start time in seconds.
-
CBridgeLane &getBridgeLane(size_t iLane)#
Get a reference to the lane at index
iLane.- Parameters:
iLane – [in] Zero-based lane index.
- Returns:
Reference to the lane.
-
size_t getNoLanes()#
Get the number of lanes on the bridge.
Private Functions
-
bool lane_compare(const CBridgeLane *pL1, const CBridgeLane *pL2)#
Comparator ordering lanes by the time at which their next vehicle leaves the bridge.
-
double TimeNextVehOffBridge()#
Compute the earliest time at which any vehicle will leave the bridge, across all lanes.
-
const std::vector<CVehicle_sp> AssembleVehicles(void)#
Collect every vehicle currently on the bridge, across all lanes.
Private Members
-
CEventManager m_EventMgr#
Load-effect event manager for this bridge.
-
std::vector<double> m_vEffectValues#
Working buffer for per-step load-effect values, one per load effect.
-
std::vector<double> m_vThresholds#
Peak-recording thresholds, one per load effect.
-
std::vector<CBridgeLane> m_vLanes#
Lanes on the bridge (across both directions).
-
double m_CurTime#
Current simulation time in seconds.
-
double m_CalcTimeStep#
Load-effect calculation time step in seconds.
-
double m_Length#
Bridge length in metres.
-
size_t NO_LANES_DIR1#
Number of lanes in direction 1 (copied from config).
-
size_t NO_DIRS#
Number of traffic directions, 1 or 2 (copied from config).
-
size_t NO_LANES#
Total number of lanes across both directions (copied from config).
-
size_t m_Index#
Zero-based bridge index within the simulation.
-
size_t m_NoLanes#
Number of lanes on this bridge.
-
size_t m_NoLoadEffects#
Number of load effects tracked on this bridge.
-
size_t m_NoVehs#
Number of vehicles currently on the bridge.
-
CBridge(CConfigDataCore &config)#
-
class CBridgeLane#
A single lane on a bridge, holding the vehicles currently on it and computing per-lane load effects.
CBridgeLane owns a list of vehicles, a flattened axle vector derived from those vehicles, and the influence lines used to compute load effects. The axle vector is rebuilt whenever vehicles are added or removed, so that the time-stepping loop in CBridge::Update only has to advance axle positions cheaply through CAxle::UpdatePosition.
Lanes on the same bridge may carry traffic in opposite directions; the direction is recorded per vehicle, not per lane.
See also
See also
See also
Note
The default lane width is 3.65 m (set in the constructor). It is overwritten when an influence surface is registered with addLoadEffect().
Public Functions
-
CBridgeLane()#
Default-construct a zero-length lane with default lane width.
-
CBridgeLane(double length)#
Construct a lane of a given length.
- Parameters:
length – [in] Lane length in metres.
-
bool operator<(const CBridgeLane &other)#
Order lanes by the time at which their next vehicle leaves the bridge.
-
void Update(double curTime)#
Advance axle positions on the lane to
curTime.Every CAxle stored in the lane has its position updated via CAxle::UpdatePosition. The vehicle list itself is unchanged — purgeVehicles() is the corresponding operation that removes vehicles that have left the bridge.
- Parameters:
curTime – [in] Current simulation time in seconds.
-
void setLaneNo(size_t LaneNo)#
Set the global lane number (across the whole road layout).
-
size_t getLaneNo(void)#
Get the global lane number.
-
void addLoadEffect(CInfluenceLine IL, double weight)#
Register an influence line for one load effect on this lane.
The influence line is copied into the lane’s list of influence lines and scaled by
weight. If the influence line is a surface, the lane width is overwritten by the surface’s lane width so the transverse ordinate lookup is consistent with the surface definition.- Parameters:
IL – [in] Influence line or surface for this load effect.
weight – [in] Scaling factor applied to all ordinates (e.g. a girder distribution factor).
-
void AddVehicle(CVehicle_up pVeh)#
Add a vehicle to this lane and rebuild the axle vector.
Takes ownership of the vehicle, appends it to the vehicle list, rebuilds the flattened axle vector, and updates the time-of-next-vehicle-off cache.
- Parameters:
pVeh – [in] Unique pointer to the vehicle (ownership transferred).
-
size_t getIndex(void)#
Get the zero-based lane index within the bridge.
-
void setIndex(size_t indx)#
Set the zero-based lane index within the bridge.
-
size_t purgeVehicles(double curTime)#
Remove vehicles that have left the bridge.
A vehicle is removed when CVehicle::IsOnBridge returns false for
curTime. When vehicles are removed, the axle vector and time-of-next-vehicle-off cache are rebuilt. Emits a warning to stdout if two vehicles are leaving within 0.1 s of each other, which can indicate a potential overlap in the traffic model.- Parameters:
curTime – [in] Current simulation time in seconds.
- Returns:
Number of vehicles remaining on the lane after the purge.
-
double getLength(void)#
Get the lane length in metres.
-
void setLength(double length)#
Set the lane length in metres.
-
double getTimeNextVehOff(void) const#
Get the cached time at which the next vehicle will leave the bridge, in seconds.
-
double setTimeNextVehOff(void)#
Recompute and return the time at which the next vehicle will leave the bridge.
Updates the internal cache; subsequent calls to getTimeNextVehOff() return this value without recomputing. If the lane has no vehicles, a large sentinel value (1e300) is returned.
- Returns:
Time at which the next vehicle will leave, in seconds.
-
double getLoadEffect(size_t NoLE)#
Compute the current load effect for one influence line.
Sums the contribution of every axle on the lane using the influence line at index
NoLE. Returns zero if the lane has no vehicles.- Parameters:
NoLE – [in] Zero-based index of the load effect / influence line.
- Returns:
Current load effect value in the influence line’s native units.
-
double getLeadVehPosition(void)#
Get the position of the lead vehicle’s first axle.
Returns the position of the first axle in the internal axle vector. Axles are stored in the order they were added, so for a simply ordered traffic stream this is the front axle of the leading vehicle.
- Returns:
Position in metres, relative to the lane datum.
-
size_t getNoVehs(void)#
Get the number of vehicles currently on the lane.
-
const std::vector<CVehicle_sp> getVehicles(void)#
Get a copy of the current vehicle list.
Private Functions
-
void setAxleVector()#
Rebuild the flattened axle vector from all vehicles on the lane.
Private Members
-
std::vector<CInfluenceLine> m_vInfLine#
Influence lines, one per load effect.
-
std::vector<CVehicle_sp> m_vVehicles#
Vehicles currently on the lane.
-
size_t m_LaneNo#
Global lane number from the road layout.
-
double m_Length#
Lane length in metres.
-
size_t m_NoLE#
Number of load effects registered on this lane.
-
double m_TimeNextVehOff#
Cached time at which the next vehicle leaves, in seconds.
-
size_t m_Index#
Zero-based index of the lane within its bridge.
-
double m_LaneWidth#
Lane width in metres (default 3.65).
-
CBridgeLane()#
Vehicles and axles#
-
class CVehicle#
A single vehicle with axle geometry, lane, and kinematic state.
CVehicle is the core data structure carried through the traffic stream: it stores the vehicle’s identifier, arrival time, velocity, gross weight and classification, together with axle-level geometry (weights, cumulative spacings and per-axle track widths). When the vehicle is placed on a bridge lane, CBridgeLane flattens its axles into a set of CAxle instances for the inner simulation loop.
Vehicles can be parsed from any of four supported traffic data file formats (CASTOR, BeDIT, DITIS, MON) via create(), and serialised back with Write(). In the PyBTLS (pybind11) build the full vehicle state is also exposed to Python via a tuple interface (getPropInTuple() / setPropByTuple()), guarded by the
PyBTLSpreprocessor macro.See also
See also
See also
Classification
Note
Unit conventions: length in metres, velocity in metres per second, gross and axle weights in kN, axle spacings in metres. File-format parsers convert from the native on-disk units (typically decimetres, kg×100) during create().
Setters
-
void setTime(double time)#
Set the vehicle arrival time in seconds (updates the day/month/year/hour/min/sec fields).
-
void setLength(double length)#
Set the overall vehicle length in metres.
-
void setVelocity(double velocity)#
Set the vehicle velocity in metres per second.
-
void setLocalLane(size_t localLaneIndex)#
Set the local (per-direction) lane index, 1-based.
-
void setLocalFromGlobalLane(size_t globalLaneIndex, size_t nRoadLanes)#
Set the local lane index from a global lane index, given the total number of road lanes.
-
void setDirection(size_t d)#
Set the direction of travel (1 or 2).
-
void setGVW(double weight)#
Set the gross vehicle weight in kN.
-
void setNoAxles(size_t noAxle)#
Set the number of axles (resizes the internal axle vector).
-
void setAW(size_t i, double w)#
Set axle weight for axle
i.- Parameters:
i – [in] Zero-based axle index.
w – [in] Axle weight in kN.
-
void setAS(size_t i, double s)#
Set axle spacing for axle
i.- Parameters:
i – [in] Zero-based axle index.
s – [in] Cumulative spacing from the front axle, in metres.
-
void setAT(size_t i, double tw)#
Set axle track width for axle
i.- Parameters:
i – [in] Zero-based axle index.
tw – [in] Wheel separation in metres.
-
void setTrans(double trans)#
Set the transverse position of the vehicle within the lane, in metres from the lane centreline.
-
void setBridgeTimes(double BridgeLength)#
Compute and cache the on- and off-bridge times.
On-bridge time is the arrival time (the BTLS time datum is the bridge entry point); off-bridge time is the on-bridge time plus the time to traverse the bridge length plus the vehicle length at the vehicle’s velocity.
- Parameters:
BridgeLength – [in] Bridge length in metres.
-
void setTimeOnBridge()#
Set the on-bridge time to the vehicle’s current arrival time.
-
void setBridgeLaneNo(size_t BridgeLaneNo)#
Set the zero-based bridge lane index for this vehicle.
-
void setTrackWidth(double tw)#
Set the default track width in metres (used when per-axle widths are not supplied).
-
void setLaneEccentricity(double e)#
Set the transverse eccentricity from the lane centreline in metres.
-
void setClass(Classification cl)#
Set the vehicle classification.
Getters
-
std::string getTimeStr()#
Get the arrival time as a “DD/MM/YYYY HH:MM:SS.ss” string.
-
size_t getHead()#
Get the record identifier.
-
double getTime() const#
Get the arrival time in seconds since the simulation epoch.
-
double getLength()#
Get the overall vehicle length in metres.
-
double getVelocity()#
Get the velocity in metres per second.
-
size_t getLocalLane()#
Get the local (per-direction) lane index, 1-based.
-
size_t getGlobalLane(size_t nRoadLanes)#
Get the global (1-based) lane index across both directions.
-
size_t getDirection()#
Get the direction of travel (1 or 2).
-
double getGVW()#
Get the gross vehicle weight in kN.
-
size_t getNoAxles()#
Get the number of axles.
-
double getAW(size_t i)#
Get the axle weight at axle
i, in kN.
-
double getAS(size_t i)#
Get the cumulative axle spacing for axle
i, in metres.
-
double getAT(size_t i)#
Get the axle track width at axle
i, in metres.
-
double getTrans()#
Get the transverse position in the lane, in metres.
-
double getTimeOnBridge()#
Get the time at which the vehicle enters the bridge, in seconds.
-
double getTimeOffBridge()#
Get the time at which the vehicle leaves the bridge, in seconds.
-
bool IsOnBridge(double atTime)#
Return true if the vehicle is on the bridge at
atTime.
-
size_t getBridgeLaneNo(void)#
Get the zero-based bridge lane index.
-
double getTrackWidth(void)#
Get the default track width in metres.
-
double getLaneEccentricity(void)#
Get the transverse eccentricity from the lane centreline in metres.
-
Classification getClass()#
Get the vehicle classification.
Public Functions
-
bool IsCar()#
True if the vehicle’s classification ID is 0 (the default “car” class).
-
void setHead(int head)#
Set the vehicle’s record identifier.
- Parameters:
head – [in] Integer ID (typically a sequence number from the source file).
-
std::string Write(size_t file_type)#
Serialise the vehicle to a fixed-width string in the given format.
- Parameters:
file_type – [in] 1 = CASTOR, 2 = BeDIT, 3 = DITIS, 4 = MON.
- Returns:
Fixed-width string representation in the requested format.
-
void create(std::string str, size_t format)#
Populate the vehicle from a row of traffic file data.
- Parameters:
str – [in] One row of fixed-width data from the source file.
format – [in] 1 = CASTOR, 2 = BeDIT, 3 = DITIS, 4 = MON.
Private Members
-
Classification m_Class#
Vehicle classification (ID plus label).
-
size_t m_Dir#
Direction of travel (1 or 2).
-
size_t m_Lane#
Local (per-direction) lane number, 1-based.
-
double m_Velocity#
Velocity in metres per second.
-
size_t m_Head#
Record identifier from the source data row.
-
size_t m_Year#
Year of arrival.
-
size_t m_Month#
Month of arrival.
-
size_t m_Day#
Day of arrival.
-
size_t m_Hour#
Hour of arrival.
-
size_t m_Min#
Minute of arrival.
-
double m_Sec#
Seconds within the arrival minute (fractional).
-
double m_GVW#
Gross vehicle weight in kN.
-
double m_Trns#
Transverse position within the lane, in metres.
-
size_t m_NoAxles#
Number of axles.
-
size_t m_NoAxleGroups#
Number of axle groups (not used in the load-effect calculation).
-
double m_Length#
Overall vehicle length in metres.
-
double m_TrackWidth#
Default track width in metres (fallback when per-axle widths are absent).
-
double m_TimeOnBridge#
Cached time at which the vehicle enters the bridge, in seconds.
-
double m_TimeOffBridge#
Cached time at which the vehicle leaves the bridge, in seconds.
-
size_t m_BridgeLaneNo#
Zero-based bridge lane index.
-
double m_LaneEccentricity#
Transverse offset from the lane centreline, in metres.
-
size_t DAYS_PER_MT#
Days per month (from CConfigData::Time).
-
size_t MTS_PER_YR#
Months per year (from CConfigData::Time).
-
size_t HOURS_PER_DAY#
Hours per day (from CConfigData::Time).
-
size_t SECS_PER_HOUR#
Seconds per hour (from CConfigData::Time).
-
size_t MINS_PER_HOUR#
Minutes per hour (from CConfigData::Time).
-
size_t SECS_PER_MIN#
Seconds per minute (from CConfigData::Time).
-
double KG100_TO_KN#
Unit conversion: kg×100 → kN (0.981).
-
double KG_TO_KN#
Unit conversion: kg → kN (9.81e-3).
-
size_t CASTOR_MAX_AXLES#
Maximum axles supported by the CASTOR file format (9).
-
size_t BEDIT_MAX_AXLES#
Maximum axles supported by the BeDIT file format (20).
-
size_t DITIS_MAX_AXLES#
Maximum axles supported by the DITIS file format (20).
-
size_t MON_MAX_AXLES#
Maximum axles supported by the MON file format (99).
-
size_t MON_BASE_YEAR#
MON base year offset (2010) used to avoid year overflows.
-
struct Axle#
Per-axle geometry stored on the vehicle.
Spacing is cumulative from the front axle (the first axle has spacing 0).
-
void setTime(double time)#
-
class CAxle#
An individual axle carrying a wheel load, tracked independently of the vehicle it belongs to.
CBridgeLane flattens every axle from every vehicle on the lane into a vector of CAxle instances. This lets the time-stepping loop in CBridge::Update advance all axle positions cheaply with a linear sweep, rather than walking into each vehicle for each time step.
Position is measured along the bridge longitudinal axis, with the sign of motion determined by travel direction. Transverse position and eccentricity are used by influence surfaces to capture the wheel-path offset across the lane.
See also
See also
See also
Note
Data members are public by design: this class is used as a value container accessed directly by CBridgeLane and CInfluenceLine.
Public Functions
-
CAxle()#
Default constructor. Leaves all fields uninitialised.
-
CAxle(size_t i, double t, double v, double x, double w, double tw, int dirn)#
Construct an axle from explicit parameters.
- Parameters:
i – [in] Axle index (position in the flattened axle vector).
t – [in] Time at which the axle is at the datum, in seconds.
v – [in] Speed in metres per second.
x – [in] Initial longitudinal position in metres.
w – [in] Axle weight in kN.
tw – [in] Track width in metres.
dirn – [in] Direction of travel (1 or 2).
-
CAxle(size_t i, size_t iAxle, double t, double x, const CVehicle_sp pVeh)#
Construct an axle from a vehicle and an axle index on that vehicle.
Pulls weight, track width, speed, direction, transverse position, eccentricity and lane number from the source vehicle.
- Parameters:
i – [in] Axle index in the flattened per-lane axle vector.
iAxle – [in] Zero-based axle index within the vehicle.
t – [in] Time at which the axle is at the datum, in seconds.
x – [in] Initial longitudinal position in metres.
pVeh – [in] Source vehicle.
-
void UpdatePosition(double time)#
Advance the axle’s longitudinal position to
time.Linear update:
position= sign * speed * (time - timeAtDatum), wheresignis+1for direction 1 and-1for direction 2.- Parameters:
time – [in] Current simulation time in seconds.
Public Members
-
double m_TimeAtDatum#
Reference time in seconds at which this axle is at the position datum.
-
size_t m_Index#
Axle index in the flattened per-lane axle vector.
-
double m_Speed#
Speed in metres per second.
-
double m_Position#
Current longitudinal position along the bridge, in metres.
-
double m_AxleWeight#
Axle weight in kN.
-
size_t m_Dirn#
Direction of travel (1 or 2).
-
double m_TrackWidth#
Axle track width (wheel separation) in metres.
-
double m_TransPos#
Transverse position of the axle centreline in metres (from measured traffic).
-
double m_Eccentricity#
Transverse eccentricity from the lane centreline in metres (from generated traffic).
-
size_t m_Lane#
Zero-based bridge lane index this axle belongs to.
Private Members
-
int m_Sign#
Direction sign: +1 if m_Dirn == 1, -1 otherwise.
-
CAxle()#
Load effects#
-
class CInfluenceLine#
Influence line, discrete ordinate table, or influence surface used to compute a single load effect from a set of axles.
CInfluenceLine supports three underlying representations, selected at construction time:
Analytical expression (type 1): one of nine hard-coded closed-form influence lines for common simply-supported and multi-span bending/shear cases. See the individual
LoadEffect*functions below.Discrete ordinates (type 2): a user-supplied table of (distance, ordinate) pairs; the ordinate at any position is obtained by linear interpolation.
Influence surface (type 3): a two-dimensional influence surface delegating to CInfluenceSurface. For type-3 influence lines, each axle’s load is split equally between the two wheel paths at ±TrackWidth/2 from the axle centreline.
A per-effect scaling weight (e.g. a girder distribution factor) is applied to all ordinates via setWeight(). For type-1 expressions, a function pointer is cached in setIL() so the inner loop does not need to branch on the function index for each axle.
Available type-1 functions (see LoadEffect1–LoadEffect9):
Mid-span bending moment, simply-supported beam
Bending moment over central support, two-span beam
Left-hand shear, simply-supported beam
Right-hand shear, simply-supported beam
Left-hand shear, two-span beam
Right-hand shear, two-span beam
Total load on the beam (constant = 1)
Bending moment over second support, three-span beam
Bending moment over third support, three-span beam
See also
See also
See also
Public Functions
-
double getOrdinate(double x)#
Get the influence line ordinate at longitudinal position
x.For type-1 and type-2 influence lines, returns the ordinate times the scaling weight. For type-3 surfaces, callers should use getLoadEffect() or CInfluenceSurface directly — this method does not handle the transverse coordinate.
- Parameters:
x – [in] Longitudinal position along the influence line, in metres.
- Returns:
Ordinate times the configured weight.
-
size_t getNoPoints(void)#
Get the number of discrete points (type 2 only).
-
double getLoadEffect(std::vector<CAxle> &vAxle)#
Compute the total load effect for a set of axles.
Sums the per-axle contribution for every axle in
vAxle. For type-3 surfaces, each axle’s load is split across the two wheel paths at ±TrackWidth/2; for types 1 and 2 the full axle weight is applied at the axle’s longitudinal position.- Parameters:
vAxle – [inout] Axles contributing to the load effect.
- Returns:
Total load effect in the influence line’s native units (e.g. kN·m for a bending moment).
-
inline size_t getType()#
Get the type tag: 1 = analytical, 2 = discrete, 3 = surface.
-
CInfluenceSurface *getIS()#
Get a pointer to the influence surface (type 3 only).
-
void setIL(size_t nIL, double length)#
Configure the influence line as one of the built-in analytical expressions.
Sets the type tag to 1 and caches a function pointer to the corresponding
LoadEffectfunction so the inner loop does not branch on the function index.- Parameters:
nIL – [in] Function index in 1..9; see the class-level list.
length – [in] Span length in metres.
-
void setIL(std::vector<double> vDis, std::vector<double> vOrd)#
Configure the influence line as a discrete ordinate table.
Sets the type tag to 2. Values between tabulated points are linearly interpolated; values outside the tabulated range return zero.
- Parameters:
vDis – [in] Distances along the beam in metres; must be strictly increasing.
vOrd – [in] Ordinates at each distance, in the load effect’s native units.
-
void setIL(CInfluenceSurface IS)#
Configure the influence line as a two-dimensional surface.
Sets the type tag to 3. Ordinate lookups delegate to CInfluenceSurface.
- Parameters:
IS – [in] Influence surface.
-
double getLength(void)#
Get the length of the influence line in metres.
-
void setIndex(size_t n)#
Set a reference index for this influence line.
-
size_t getIndex(void)#
Get the reference index for this influence line.
-
void setWeight(double weight)#
Set the scaling weight applied to all ordinates.
Typically used to apply a girder distribution factor or a unit-conversion constant.
- Parameters:
weight – [in] Scaling factor; default is 1.0.
Private Types
-
typedef double (CInfluenceLine::* LEfptr)(double x)#
Pointer-to-member type for analytical load-effect functions.
Private Functions
-
double getEquationOrdinate(double x)#
Dispatch to the cached analytical ordinate function (type 1).
-
double getDiscreteOrdinate(double x)#
Interpolate the ordinate from the discrete table (type 2).
-
double LoadEffect1(double x)#
Mid-span bending moment, simply-supported beam.
-
double LoadEffect2(double x)#
Bending moment over central support, two-span beam.
-
double LoadEffect3(double x)#
Left-hand shear, simply-supported beam.
-
double LoadEffect4(double x)#
Right-hand shear, simply-supported beam.
-
double LoadEffect5(double x)#
Left-hand shear, two-span beam.
-
double LoadEffect6(double x)#
Right-hand shear, two-span beam.
-
double LoadEffect7(double x)#
Total load on the beam (constant = 1).
-
double LoadEffect8(double x)#
Bending moment over second support, three-span beam.
-
double LoadEffect9(double x)#
Bending moment over third support, three-span beam.
Private Members
-
size_t m_Type#
1 = expression, 2 = discrete, 3 = surface.
-
size_t m_ILFunctionNo#
Analytical function index (type 1 only).
-
size_t m_Index#
Reference index set by setIndex().
-
double m_Length#
Span length in metres.
-
size_t m_NoPoints#
Number of discrete ordinate points (type 2).
-
double m_Weight#
Scaling weight applied to all ordinates.
-
std::vector<double> m_vDistance#
Discrete distances in metres (type 2).
-
std::vector<double> m_vOrdinate#
Discrete ordinates (type 2).
-
CInfluenceSurface m_IS#
Influence surface (type 3).
-
class CCalcEffect#
Unused analytical load-effect calculator.
Provides closed-form load-effect functions (effect1–7, effect16, A1/A2, B1/B2, C1/C2, Beam1–5) for a point load on a beam of a given span. The class is instantiated as a member of CBridge but its methods are not invoked by the current simulation path in either the standalone BTLS binary or the PyBTLS extension; all load effects are routed through CInfluenceLine instead.
See also
Note
New code should use CInfluenceLine instead. The influence-line framework supports arbitrary discrete ordinates and influence surfaces, neither of which this class handles.
Public Functions
-
void setSpan(double span)#
Set the span of the beam.
- Parameters:
span – [in] Beam span in metres.
-
CCalcEffect(double span)#
Construct with a beam span.
- Parameters:
span – [in] Beam span in metres.
-
double giveEffect(int j, double X, double AW, int lane)#
Evaluate one of the analytical effect functions for a point load.
- Parameters:
j – [in] Effect-function index (selects give_effect1–16, A/B/C, Beam1–5).
X – [in] Longitudinal position of the load along the beam, in metres.
AW – [in] Axle weight in kN.
lane – [in] Lane index, passed through to functions that are lane-dependent.
- Returns:
Load effect value in the function’s native units.
Private Functions
-
double give_effect1(double x)#
Legacy analytical effect function.
-
double give_effect2(double x)#
Legacy analytical effect function.
-
double give_effect3(double x)#
Legacy analytical effect function.
-
double give_effect4(double x)#
Legacy analytical effect function.
-
double give_effect5(double x)#
Legacy analytical effect function.
-
double give_effect6(double x)#
Legacy analytical effect function.
-
double give_effect7(double x)#
Legacy analytical effect function.
-
double give_effectA1(double x)#
Legacy analytical effect function.
-
double give_effectA2(double x)#
Legacy analytical effect function.
-
double give_effectB1(double x)#
Legacy analytical effect function.
-
double give_effectB2(double x)#
Legacy analytical effect function.
-
double give_effectC1(double x)#
Legacy analytical effect function.
-
double give_effectC2(double x)#
Legacy analytical effect function.
-
double give_Beam1(double x)#
Legacy analytical beam function.
-
double give_Beam2(double x)#
Legacy analytical beam function.
-
double give_Beam3(double x)#
Legacy analytical beam function.
-
double give_Beam4(double x)#
Legacy analytical beam function.
-
double give_Beam5(double x)#
Legacy analytical beam function.
-
double give_effect16(double x)#
Legacy analytical effect function.
Private Members
-
double m_span#
Beam span in metres.
-
void setSpan(double span)#
Events#
-
class CEventManager#
Records load-effect events for one bridge and dispatches them to the output managers.
CEventManager sits between the simulation inner loop and the various output writers. CBridge::Update drives it through three calls:
AddNewEvent() at the start of a new vehicle configuration, passing the current set of vehicles on the bridge.
UpdateEffects() at every inner-loop time step, passing the current load-effect values and the lead vehicle position. This tracks the running maximum and minimum per load effect.
EndEvent() when a vehicle enters or leaves the bridge, closing the current event and handing the completed CEvent to the output managers (POT, block maxima, running statistics, fatigue rainflow, all-events buffer).
The four
WRITE_*flags andDO_FATIGUE_RAINFLOWflag control which outputs are actually produced; they are read from the configuration passed to the constructor.See also
See also
See also
See also
See also
See also
Public Functions
-
CEventManager(CConfigDataCore &config)#
Construct an event manager bound to a configuration.
Does not initialize output files — Initialize() must be called after the bridge length, thresholds and start time are known.
- Parameters:
config – [in] Shared configuration block.
-
void Initialize(double BridgeLength, std::vector<double> vThresholds, double SimStartTime)#
Initialize output managers and buffers.
Opens output files for each enabled writer (all-events, fatigue, block maxima, POT, statistics) and prepares the per-load-effect state.
- Parameters:
BridgeLength – [in] Bridge length in metres (used to stem output filenames).
vThresholds – [in] Peak-recording thresholds, one per load effect.
SimStartTime – [in] Simulation start time in seconds.
-
void EndEvent()#
Close the current event and dispatch it to the output managers.
Called when the vehicle configuration on the bridge changes (a vehicle enters or leaves). Hands the completed CEvent to the POT, block-max, statistics and fatigue managers, and appends it to the all-events buffer.
-
void Finish()#
Flush all output buffers and close output files.
Call once at the end of the simulation to ensure any partial buffers are written.
-
void UpdateEffects(std::vector<double> vEffs, double position, double time)#
Update the running maxima for the current event.
Called once per inner-loop time step by CBridge::Update. For each load effect, compares
vEffs[i] against the current maximum/minimum and updates if larger/smaller. Optionally writes a row to the time-history output file.- Parameters:
vEffs – [in] Current load-effect values, one per load effect.
position – [in] Position of the lead vehicle in metres.
time – [in] Current simulation time in seconds.
-
void AddNewEvent(std::vector<CVehicle> vVehs, double curTime)#
Begin a new event with a copy of the current vehicles.
- Parameters:
vVehs – [in] Vehicles currently on the bridge (value copies).
curTime – [in] Current simulation time in seconds.
-
void AddNewEvent(const std::vector<CVehicle_sp> vVehs, double curTime)#
Begin a new event with shared-pointer vehicles.
Overload used by CBridge::Update, which holds vehicles as shared pointers across lanes.
- Parameters:
vVehs – [in] Vehicles currently on the bridge.
curTime – [in] Current simulation time in seconds.
-
void setEventOutputFile(double BridgeLength)#
Open the event output file, stemming the filename by bridge length.
- Parameters:
BridgeLength – [in] Bridge length in metres.
Private Functions
-
void WriteEventBuffer()#
Flush the all-events buffer to disk when the threshold size is reached.
-
void UpdateEvent()#
Update m_CurEvent with the per-timestep maxima computed in UpdateEffects().
-
void DoTimeHistory(int i, std::vector<double> &vEff)#
Append one row to the time-history output stream for load effect
i.
Private Members
-
CConfigDataCore &m_Config#
Reference to the shared configuration block.
-
CEventBuffer m_AllEventBuffer#
Buffer of every completed event, flushed in batches.
-
CEventBuffer m_FatigueEventBuffer#
Buffer of events flagged for fatigue analysis.
-
CBlockMaxManager m_BlockMaxManager#
Block-maxima writer, one maximum per time block per load effect.
-
CPOTManager m_POTManager#
Peaks-over-threshold writer.
-
CStatsManager m_StatsManager#
Running statistics (mean, variance, etc.) writer.
-
CFatigueManager m_FatigueManager#
Fatigue damage accumulator (rainflow counting).
-
std::ofstream m_TimeHistoryFile#
Optional per-timestep time-history output stream.
-
long m_BlockSize#
Block size in seconds for block-maxima output.
-
int m_MaxNoVehsInEvent#
Largest number of vehicles observed in any completed event.
-
int m_CurEventType#
Dispatch type for the current event (used by multi-type outputs).
-
int m_NoEvents#
Running count of completed events since Initialize().
-
int m_CurBlockNo#
Zero-based index of the current time block.
-
double m_CurTime#
Most recent simulation time passed to UpdateEffects().
-
double m_BridgeLength#
Bridge length in metres (copied from Initialize).
-
size_t m_NoLoadEffects#
Number of load effects tracked.
-
std::vector<double> m_vThresholds#
Peak-recording thresholds, one per load effect.
-
bool WRITE_TIME_HISTORY#
If true, a time-history row is written every inner-loop step.
-
bool WRITE_EACH_EVENT#
If true, every completed event is written (not just peaks).
-
int WRITE_EVENT_BUFFER_SIZE#
Number of events buffered before flushing to disk.
-
bool WRITE_FATIGUE_EVENT#
If true, completed events feed the fatigue buffer.
-
bool WRITE_BM#
Enable block-maxima output.
-
bool WRITE_POT#
Enable peaks-over-threshold output.
-
bool WRITE_STATS#
Enable running-statistics output.
-
bool DO_FATIGUE_RAINFLOW#
Enable fatigue rainflow counting.
-
class CEvent#
A recorded load-effect event on a bridge, spanning one vehicle configuration.
A CEvent is opened when a new vehicle enters the bridge (or an existing one leaves) and closed when the next change happens. While open, the event tracks the running maximum and minimum of every load effect. On close it is handed to the output managers (CPOTManager, CBlockMaxManager, etc.) via the CEventManager.
The maximum and minimum are stored as per-effect vectors of CEffect, one slot per load effect configured for the bridge. Events are orderable by their load-effect value for sorting in the output buffers.
See also
See also
Public Functions
-
CEvent(size_t fileFormat)#
Construct an event with the given output file format.
- Parameters:
fileFormat – [in] File format tag used when writing this event.
-
CEvent(size_t fileFormat, size_t ID)#
Construct an event with a file format and ID.
- Parameters:
fileFormat – [in] File format tag used when writing this event.
ID – [in] Event identifier (monotonically increasing).
-
CEvent(size_t fileFormat, size_t ID, size_t noEffects)#
Construct an event with a file format, ID and effect count.
- Parameters:
fileFormat – [in] File format tag used when writing this event.
ID – [in] Event identifier.
noEffects – [in] Number of load effects tracked by this event.
-
bool operator<(const CEvent &x)#
Order events by the maximum value of their first load effect.
Used when sorting buffers of events for output writing.
-
void reset()#
Reset the event to an empty state with default values.
Zeros the running maxima/minima and clears the current effect index so the event can be reused.
-
CEffect &getMaxEffect(size_t effNo)#
Get the running maximum for load effect
effNo.- Parameters:
effNo – [in] Zero-based load-effect index.
- Returns:
Reference to the maximum CEffect observed so far.
-
CEffect &getMinEffect(size_t effNo)#
Get the running minimum for load effect
effNo.- Parameters:
effNo – [in] Zero-based load-effect index.
- Returns:
Reference to the minimum CEffect observed so far.
-
size_t getNoVehicles()#
Get the number of vehicles that contributed to this event.
-
size_t getNoTrucks() const#
Get the number of trucks (non-car vehicles) in this event.
-
size_t getID()#
Get the event identifier.
-
double getMaxTime()#
Get the time at which the overall maximum effect was recorded, in seconds.
-
double getMaxEffectTime()#
Get the time at which the current effect’s maximum was recorded, in seconds.
-
size_t getNoEffects()#
Get the number of load effects tracked.
-
double getStartTime()#
Get the event start time in seconds.
-
std::string getTimeStr()#
Get the event start time formatted as “DD/MM/YYYY HH:MM:SS.ss”.
-
void setStartTime(double StartTime)#
Set the event start time in seconds.
-
void setID(size_t id)#
Set the event identifier.
-
void setMaxEffect(CEffect Eff, size_t i)#
Replace the maximum effect for load effect
i.- Parameters:
Eff – [in] New maximum.
i – [in] Zero-based load-effect index.
-
void setMinEffect(CEffect Eff, size_t i)#
Replace the minimum effect for load effect
i.- Parameters:
Eff – [in] New minimum.
i – [in] Zero-based load-effect index.
-
void setNoEffects(size_t noEffects)#
Resize the per-effect max/min vectors to
noEffects.- Parameters:
noEffects – [in] Number of load effects to track.
-
void setCurEffect(size_t ce)#
Set the current load-effect index used by getMaxEffectTime().
-
void writeEffect(size_t k, std::string file, bool trucks)#
Write one load effect to an output file.
- Parameters:
k – [in] Zero-based load-effect index.
file – [in] Path to the output file.
trucks – [in] If true, include per-truck detail.
-
void writeToFile(std::string file)#
Write the full event to an output file in the configured format.
- Parameters:
file – [in] Path to the output file.
Public Members
Private Members
-
size_t m_CurEffect#
Index of the load effect currently being queried.
-
size_t m_NoEffects#
Number of load effects tracked.
-
size_t m_EventID#
Monotonically increasing event identifier.
-
double m_StartTime#
Event start time in seconds.
-
size_t DAYS_PER_MT#
Days per month (from CConfigData::Time).
-
size_t MTS_PER_YR#
Months per year (from CConfigData::Time).
-
size_t HOURS_PER_DAY#
Hours per day (from CConfigData::Time).
-
size_t SECS_PER_HOUR#
Seconds per hour (from CConfigData::Time).
-
size_t MINS_PER_HOUR#
Minutes per hour (from CConfigData::Time).
-
size_t SECS_PER_MIN#
Seconds per minute (from CConfigData::Time).
-
size_t FILE_FORMAT#
File format tag used by writeToFile() and writeEffect().
-
CEvent(size_t fileFormat)#
-
class CEffect#
A single recorded load-effect observation: value, time, position, and the vehicles that contributed to it.
CEffect is a lightweight value container used by CEvent to hold one max or min observation for one load effect. It remembers the load effect value, the simulation time and lead-vehicle position at which the value was observed, and the list of vehicles on the bridge at that moment (so that per-vehicle detail can be written out in event files).
Effects are orderable by value for sorting in the output buffers.
See also
See also
Public Functions
-
CEffect()#
Default-construct an empty effect with all fields zeroed.
-
CEffect(double value, double time, double distance)#
Construct an effect with an initial value, time and position.
- Parameters:
value – [in] Load-effect value, in the influence line’s native units.
time – [in] Simulation time in seconds at which the value was observed.
distance – [in] Lead vehicle position along the bridge, in metres.
-
double getPosition()#
Get the lead-vehicle position in metres.
-
double getTime()#
Get the observation time in seconds.
-
double getValue() const#
Get the load-effect value in the influence line’s native units.
-
void setTime(double time)#
Set the observation time in seconds.
-
void setValue(double time)#
Set the load-effect value.
-
void setPosition(double time)#
Set the lead-vehicle position in metres.
-
CVehicle giveVehicle(size_t i) const#
Get the i-th contributing vehicle.
- Parameters:
i – [in] Index into the stored vehicle list.
- Returns:
Copy of the vehicle at index
i.
-
void AddVehicles(std::vector<CVehicle> vVeh)#
Append all vehicles from
vVehto the contributing-vehicle list.
-
void sortVehicles()#
Sort the stored vehicles chronologically by arrival time.
-
CEffect()#
-
class CEventBuffer#
Buffered writer for a stream of CEvent records.
CEventBuffer accumulates completed events and flushes them to an output file in batches, amortising file I/O cost across many events. It runs in one of two modes selected at runtime:
ALLEVENTS: every completed event is serialised to the output file using its configured file format.
FATIGUE: only events flagged by CEventManager for fatigue analysis are written, in a format consumed by the fatigue rainflow post-processor.
See also
See also
Public Functions
-
CEventBuffer(size_t bufferSize)#
Construct a buffer with the given capacity.
- Parameters:
bufferSize – [in] Number of events to hold before auto-flushing.
-
void setMode(bool bFatigue)#
Select the output format mode.
- Parameters:
bFatigue – [in] If true, use FATIGUE mode; otherwise ALLEVENTS.
-
void FlushBuffer()#
Flush all buffered events to the output file now.
Called at end-of-simulation and whenever the buffer fills.
-
void SetBufferSize(int size)#
Change the buffer capacity.
- Parameters:
size – [in] New capacity in events.
-
void AddEvent(CEvent Ev)#
Append a completed event to the buffer.
Triggers an automatic FlushBuffer() when the buffer is full.
- Parameters:
Ev – [in] Completed event (copied into the buffer).
-
void setOutFile(double BridgeLength)#
Open the output file using the default stemmed filename.
- Parameters:
BridgeLength – [in] Bridge length in metres (used in the filename stem).
-
void setOutFile(std::string OutFile)#
Open a specific output file.
- Parameters:
OutFile – [in] Path to the output file.
Private Functions
-
void FlushAllEventsBuff()#
Flush helper: write every event in the buffer (ALLEVENTS mode).
-
void FlushFatigueBuff()#
Flush helper: write fatigue-flagged events only (FATIGUE mode).
Event output managers#
Both managers below derive from COutputManagerBase (see
cpp/include/OutputManagerBase.h), which factors out the shared file
handling. The shared base is documented inline in the header file and
is not rendered here as its own section — Breathe would emit inherited
symbols for each derived class, causing duplicate cross-references in
the same page.
-
class CPOTManager : public COutputManagerBase#
Records peaks-over-threshold (POT) events for each load effect.
CPOTManager inspects every completed CEvent and, for each load effect, retains the event if its peak value exceeds the configured threshold for that effect. Events above threshold are buffered and written in batches via the inherited COutputManagerBase file machinery.
In addition to the event stream, the manager optionally maintains a counter file: a running count of how many peaks exceeded each threshold in each time block. Block size is configured via
POT_COUNT_SIZE_DAYS/POT_COUNT_SIZE_SECS.Output files are named using the filestem from the base class and a suffix derived from the bridge length and load-effect index.
See also
COutputManagerBase
See also
-
class CBlockMaxManager : public COutputManagerBase#
Records block maxima of each load effect over fixed time blocks.
CBlockMaxManager splits the simulation timeline into fixed-length blocks (configured by
BLOCK_SIZE_DAYS, derived to seconds viaBLOCK_SIZE_SECS) and, within each block, tracks the maximum CEvent seen so far for each vehicle-count bucket. The per-vehicle-count resolution is stored in a CBlockMaxEvent container.When a block boundary is crossed, the completed block maxima are flushed via the inherited COutputManagerBase file machinery. A “mixed” output stream that combines maxima across vehicle counts is optionally maintained when
WRITE_BM_MIXEDis enabled.See also
See also
COutputManagerBase
See also
Public Functions
-
class CBlockMaxEvent#
Container holding one block’s worth of block-max events, indexed by vehicle count.
CBlockMaxManager tracks the maximum CEvent seen so far within the current time block, broken down by the number of vehicles contributing to each event (1-truck events, 2-truck events, etc.). CBlockMaxEvent is the underlying container: one slot per vehicle-count bucket, each holding the running maximum CEvent for that bucket.
The slot list is grown on demand via AddExtraEvents() when an event with more vehicles than any previously seen arrives.
See also
Public Functions
-
CBlockMaxEvent(size_t fileFormat)#
Construct a block-max container for the given output format.
- Parameters:
fileFormat – [in] File format tag used when writing contained events.
-
void AddExtraEvents(size_t nVehs)#
Grow the slot list to cover up to
nVehsvehicles.- Parameters:
nVehs – [in] Number of vehicles the new top bucket should handle.
-
void UpdateEvent(size_t iEvent, CEvent Ev)#
Update the running maximum for bucket
iEventwithEv.- Parameters:
iEvent – [in] Zero-based vehicle-count bucket index.
Ev – [in] Candidate event. Replaces the current maximum if larger.
-
CEvent &getEvent(size_t iEv)#
Get a reference to the event in bucket
iEv.- Parameters:
iEv – [in] Zero-based vehicle-count bucket index.
- Returns:
Reference to the stored CEvent.
-
void clear()#
Reset the container to an empty state.
-
void setID(size_t ID)#
Set the block identifier (typically the block index).
-
size_t getID()#
Get the block identifier.
-
size_t getSize()#
Get the number of buckets currently stored.
-
void setNoLoadEffects(size_t nLE)#
Set the number of load effects tracked per bucket.
-
CBlockMaxEvent(size_t fileFormat)#
-
class CEventStatistics#
Running statistics (mean, variance, skewness, kurtosis) of one load effect, accumulated over completed events.
CEventStatistics uses an online moment accumulator so that the full set of central moments can be updated one event at a time without storing the entire event history. Each call to update() folds one event’s max into the running moments; outputString() returns the formatted summary row for the output file.
In addition to the load-effect moments, the class tracks composition information — total number of vehicles and number of trucks seen, and a histogram of the number of trucks per event in
m_vNoTrucksInEvent.See also
Public Functions
-
void update(CEvent Ev, unsigned int iLE)#
Fold one event’s maximum for load effect
iLEinto the running moments.- Parameters:
Ev – [in] Completed event.
iLE – [in] Zero-based load-effect index.
-
std::string outputString()#
Format the current statistics as a single output row.
- Returns:
Tab/space-delimited row of moments and composition counts.
-
std::string headingsString()#
Get the column headings matching outputString().
- Returns:
Row of column headings.
Public Members
-
size_t m_N#
Number of events folded into the moments.
-
size_t m_ID#
Identifier (typically the load-effect index).
-
double m_Max#
Running maximum load-effect value seen.
-
double m_Min#
Running minimum load-effect value seen.
-
double m_Mean#
Running mean.
-
double m_Variance#
Running sample variance.
-
double m_StdDev#
Running sample standard deviation.
-
double m_Skewness#
Running sample skewness (third standardised moment).
-
double m_Kurtosis#
Running sample kurtosis (fourth standardised moment).
-
double m_M2#
Accumulator for second central moment (online algorithm).
-
double m_M3#
Accumulator for third central moment (online algorithm).
-
double m_M4#
Accumulator for fourth central moment (online algorithm).
-
size_t m_NoVehicles#
Total vehicles seen across all folded events.
-
size_t m_NoTrucks#
Total trucks (non-car vehicles) seen across all folded events.
-
std::vector<size_t> m_vNoTrucksInEvent#
Histogram of the number of trucks per event.
Private Functions
-
void accumulator(double x)#
Update the online moment accumulators with a single value.
-
void finalize()#
Derive mean/variance/skewness/kurtosis from the moment accumulators.
Private Members
-
size_t m_MaxNoTrucksInEvent#
Largest number of trucks observed in any single event.
-
void update(CEvent Ev, unsigned int iLE)#
Traffic streams (lanes)#
Both lane classes below derive from CLane (see
cpp/include/Lane.h), which defines the GetNextVehicle contract
and caches the next-arrival-time bookkeeping. The abstract base is
documented inline in its header only — rendering it alongside its
derived classes causes duplicate inherited-symbol targets.
-
class CLaneGenTraffic : public CLane#
A traffic lane that produces vehicles on demand using a flow generator and a vehicle generator.
CLaneGenTraffic couples a CFlowGenerator (which produces arrival times and gaps) with a CVehicleGenerator (which produces vehicle geometry and weights). Each call to GetNextVehicle() returns the currently cached next vehicle and then generates the following one, updating the cached arrival time and the reference vehicle used for headway calculation.
The per-lane state that couples successive vehicles —
m_pPrevVehandm_pNextVeh— carries over the minimum-gap constraint between consecutive arrivals, so the flow generator can honour car-following behaviour across the entire simulation.See also
CLane
See also
See also
See also
Public Functions
-
virtual CVehicle_sp GetNextVehicle()#
Pop and return the next generated vehicle, then generate the following one.
-
void setLaneData(CVehicleClassification_sp pVC, CLaneFlowComposition lfc, const double starttime)#
Configure the lane with a classification, flow composition, and start time.
This overload constructs the vehicle generator and flow generator internally based on the configuration’s
VEHICLE_MODELandHEADWAY_MODELtags.- Parameters:
pVC – [in] Vehicle classifier shared across the road.
lfc – [in] Lane flow composition (lane number, direction, flow rates).
starttime – [in] Simulation start time in seconds.
-
void setLaneData(CLaneFlowComposition lfc, CVehicleGenerator_sp pVehicleGen, CFlowGenerator_sp pFlowGen, const double startTime)#
Configure the lane with pre-built generators.
Used when the caller wants to share vehicle or flow generators across lanes instead of letting each lane construct its own.
- Parameters:
lfc – [in] Lane flow composition.
pVehicleGen – [in] Vehicle generator (shared pointer).
pFlowGen – [in] Flow (arrival/headway) generator (shared pointer).
startTime – [in] Simulation start time in seconds.
-
void initLane(CFlowModelData_sp pFlowModelData)#
Initialize the flow model data and prime the first arrival.
- Parameters:
pFlowModelData – [in] Flow model data supplied by the traffic configuration.
-
virtual CVehicle_sp GetNextVehicle()#
-
class CLaneFileTraffic : public CLane#
A traffic lane that replays a pre-recorded sequence of vehicles.
CLaneFileTraffic owns a vector of vehicles parsed from a traffic data file (via CVehicleTrafficFile) and hands them to the simulation loop in the order they were recorded. No statistical generation is involved — arrival times and vehicle properties are whatever the file contains.
Typically used for replaying observed traffic (e.g. WIM data) against a bridge to compute load-effect statistics for that exact traffic stream.
See also
CLane
See also
Public Functions
-
virtual CVehicle_sp GetNextVehicle()#
Pop and return the next vehicle from the stored vector.
Advances the internal cursor to the following vehicle and refreshes the cached
m_NextArrivalTime.
-
void setLaneData(int dirn, int laneNo)#
Configure the lane’s direction and lane number.
- Parameters:
dirn – [in] Travel direction (1 or 2).
laneNo – [in] Global lane index.
-
void addVehicle(CVehicle_sp pVeh)#
Append a vehicle to the stored sequence.
- Parameters:
pVeh – [in] Shared pointer to the vehicle.
-
void setFirstArrivalTime()#
Prime the cached next-vehicle / next-arrival-time fields from the first vehicle in the stored sequence.
Call once after all vehicles have been added via addVehicle().
-
inline size_t GetNoVehicles()#
Get the total number of stored vehicles still to be consumed.
-
virtual CVehicle_sp GetNextVehicle()#
-
class CVehicleTrafficFile#
Reads a traffic data file and produces a sequence of CVehicle instances.
CVehicleTrafficFile parses one of the four supported fixed-width traffic formats (CASTOR, BeDIT, DITIS, MON) into CVehicle objects with their timestamps, geometry and weights populated. It is used both by the standalone BTLS binary (to feed a replay-mode simulation) and by the PyBTLS Python layer (to load observed WIM data).
After Read() populates the internal vehicle list, the file’s metadata (number of days covered, number of lanes, directions, and the inclusive start/end times) can be queried via the getter accessors and the vehicles can be popped in order via getNextVehicle(), or retrieved in bulk via getVehicles().
The constructor accepts speed overrides:
UseConstSpeedreplaces every vehicle’s velocity withConstSpeed, andUseAveSpeedreplaces it with the average speed across the file. If both are false, the speeds read from the file are used as-is.See also
See also
Public Functions
-
CVehicleTrafficFile(CVehicleClassification_sp pVC, bool UseConstSpeed, bool UseAveSpeed, double ConstSpeed)#
Construct with a vehicle classifier and speed override flags.
- Parameters:
pVC – [in] Vehicle classifier used to tag each parsed vehicle.
UseConstSpeed – [in] If true, replace every vehicle’s velocity with
ConstSpeed.UseAveSpeed – [in] If true, replace every vehicle’s velocity with the file-average speed.
ConstSpeed – [in] Constant speed in m/s used when
UseConstSpeedis true.
-
void Read(std::filesystem::path file, int filetype)#
Parse a traffic file.
- Parameters:
file – [in] Path to the input file.
filetype – [in] File-format tag (1 = CASTOR, 2 = BeDIT, 3 = DITIS, 4 = MON).
-
void AssignTraffic(std::vector<CVehicle_sp> vVehicles)#
Replace the internal vehicle list with an externally-supplied vector.
Used by the PyBTLS Python layer when vehicles are constructed directly in Python rather than parsed from a file.
- Parameters:
vVehicles – [in] Vehicles to attach.
-
size_t getNoDays()#
Get the number of calendar days spanned by the file.
-
size_t getNoLanes()#
Get the total number of lanes in the file.
-
size_t getNoDirn()#
Get the number of traffic directions represented (1 or 2).
-
size_t getNoLanesDir1()#
Get the number of lanes in direction 1.
-
size_t getNoLanesDir2()#
Get the number of lanes in direction 2.
-
size_t getNoVehicles()#
Get the total number of vehicles parsed.
-
CVehicle_sp getNextVehicle()#
Pop and return the next vehicle from the internal cursor.
-
inline std::vector<CVehicle_sp> getVehicles() const#
Get a copy of all parsed vehicles.
-
double getStartTime()#
Get the timestamp of the first vehicle in the file, in seconds.
-
double getEndTime()#
Get the timestamp of the last vehicle in the file, in seconds.
Private Functions
-
void AnalyseTraffic()#
Scan the vehicle list to populate day/lane/direction counts and start/end times.
-
void UpdateProperties()#
Refresh derived properties after AssignTraffic() or Read().
-
void SetSpeed()#
Apply the speed-override flags to every vehicle.
Private Members
-
bool m_UseConstSpeed#
If true, overwrite vehicle velocities with
m_ConstSpeed.
-
bool m_UseAveSpeed#
If true, overwrite vehicle velocities with the file-average speed.
-
double m_ConstSpeed#
Constant speed used when
m_UseConstSpeedis true (m/s).
-
CVehicleClassification_sp m_pVehClassification#
Vehicle classifier applied during parsing.
-
size_t m_NoVehs#
Number of vehicles parsed.
-
size_t m_NoDays#
Number of calendar days spanned.
-
size_t m_NoLanes#
Total lanes represented.
-
size_t m_NoDirn#
Number of directions (1 or 2).
-
size_t m_NoLanesDir1#
Lanes in direction 1.
-
size_t m_NoLanesDir2#
Lanes in direction 2.
-
double m_Starttime#
Timestamp of the first vehicle, in seconds.
-
double m_Endtime#
Timestamp of the last vehicle, in seconds.
-
unsigned int m_iCurVehicle#
Cursor into the vehicle vector for getNextVehicle().
-
std::vector<CVehicle_sp> m_vVehicles#
Parsed vehicle stream.
-
CVehicleTrafficFile(CVehicleClassification_sp pVC, bool UseConstSpeed, bool UseAveSpeed, double ConstSpeed)#
-
class CVehicleBuffer#
Buffered writer for generated vehicles and per-hour flow statistics.
CVehicleBuffer accumulates vehicles emitted by CLaneGenTraffic (via its vehicle generator) and periodically flushes them to the configured vehicle output file in the current file format. It also maintains per-hour flow statistics — total vehicles, trucks, cars, and class histograms per lane per hour — that are written out alongside the vehicle file.
Both outputs are optional:
WRITE_VEHICLE_FILEenables the vehicle stream andWRITE_FLOW_STATSenables the flow statistics stream. Buffer size is controlled byWRITE_VEHICLE_BUFFER_SIZE.See also
See also
Public Functions
-
CVehicleBuffer(CConfigDataCore &config, CVehicleClassification_sp pVC, double starttime)#
Construct a buffer bound to the simulation configuration.
- Parameters:
config – [in] Shared configuration block.
pVC – [in] Vehicle classifier used to categorise buffered vehicles.
starttime – [in] Simulation start time in seconds (used to initialise the hour counter).
-
void AddVehicle(const CVehicle_sp &pVeh)#
Append a vehicle to the buffer and update the current hour’s flow counts.
If the buffer is full, it is flushed to the output file before the new vehicle is appended.
- Parameters:
pVeh – [in] Generated vehicle (shared pointer; the buffer takes a copy).
-
void FlushBuffer()#
Flush any buffered vehicles and flow data to disk immediately.
Private Functions
-
void writeFlowData()#
Write all buffered vehicles to the vehicle output file.
-
void updateFlowData(const CVehicle_sp &pVeh)#
Update the current hour’s flow-count record with
pVeh.
-
void flushFlowData()#
Flush the per-hour flow statistics to the flow output file.
Private Members
-
std::ofstream m_OutFileVeh#
Output stream for serialised vehicles.
-
std::ofstream m_OutFileFlow#
Output stream for per-hour flow stats.
-
std::vector<CVehicle_up> m_vVehicles#
Buffered vehicles awaiting flush.
-
size_t m_NoVehicles#
Running count of vehicles flushed to disk.
-
size_t m_FirstHour#
Hour index at which the simulation started.
-
size_t m_CurHour#
Current hour index.
-
std::vector<std::vector<CFlowRateData>> m_vFlowData#
Per-hour, per-lane flow counters.
-
size_t FILE_FORMAT#
Output file format tag (CASTOR/BeDIT/DITIS/MON).
-
bool WRITE_VEHICLE_FILE#
Enable the vehicle output stream.
-
std::string VEHICLE_FILENAME#
Output file path for vehicles.
-
size_t WRITE_VEHICLE_BUFFER_SIZE#
Buffer capacity in vehicles.
-
bool WRITE_FLOW_STATS#
Enable the flow-statistics output stream.
-
size_t NO_LANES_DIR1#
Lanes in direction 1 (from config).
-
size_t NO_LANES_DIR2#
Lanes in direction 2 (from config).
-
size_t NO_LANES#
Total lanes across both directions.
-
CVehicleClassification_sp m_pVehClassification#
Shared vehicle classifier.
-
CVehicleBuffer(CConfigDataCore &config, CVehicleClassification_sp pVC, double starttime)#
Vehicle generators#
The vehicle generator hierarchy roots at CGenerator (see
cpp/include/Generator.h), which carries the random-number generator
and a handful of numerical helpers used by all derived samplers. The
intermediate CVehicleGenerator defines the sampling contract; the
three concrete classes below implement different modelling philosophies
(pool-based, parametric French-traffic Grave model, or a user-supplied
nominal). Both base classes are documented inline in their headers —
rendering them here alongside their derived classes causes duplicate
inherited-symbol targets. Members on the derived classes are listed
explicitly for the same reason.
-
class CVehicleGenerator : public CGenerator#
Abstract base class for vehicle generators.
A CVehicleGenerator samples vehicle geometry — axle count, axle weights, axle spacings, overall length, and track widths — from a vehicle model. Concrete subclasses correspond to different modelling philosophies:
CVehicleGenGrave: Sam Grave’s French-traffic model used in Eurocode development. Samples axle weights as multi-modal normals conditional on vehicle class.
CVehicleGenNominal: produces a single user-supplied “nominal” vehicle with small random perturbations.
CVehicleGenGarage: draws vehicles by index from a pre-recorded “garage” of observed vehicles.
The base class also handles car generation separately from truck generation via GenerateCar(), driven by a per-hour car-percentage vector.
See also
CGenerator
See also
See also
See also
Subclassed by CVehicleGenGarage, CVehicleGenGrave, CVehicleGenNominal
Public Functions
-
CVehicle_sp Generate(size_t iHour)#
Sample one vehicle for the current hour.
Chooses between car and truck generation based on the car-percentage for
iHour, then dispatches to GenerateCar() or the subclass’s GenerateVehicle() override.- Parameters:
iHour – [in] Current hour of day (0–23).
- Returns:
Newly-sampled vehicle.
-
virtual void update(CFlowModelData_sp pFMD)#
Refresh the generator’s view of the flow model data.
Called by the lane when the flow model parameters change (e.g. at block boundaries).
- Parameters:
pFMD – [in] Flow model data.
Protected Functions
-
virtual void GenerateVehicle(CVehicle_sp pVeh)#
Populate
pVehwith truck geometry and weights.Subclasses implement this to supply the truck-generation strategy specific to their model.
-
virtual size_t GenVehClass() = 0#
Sample a truck-class index from the class distribution.
- Returns:
Zero-based class index.
-
void GenerateCar(CVehicle_sp pVeh)#
Populate
pVehas a car (lighter, shorter, fewer axles).
-
bool NextVehicleIsCar()#
Decide whether the next generated vehicle should be a car based on the current hour’s car percentage.
Private Functions
-
void SetKernelGenerator()#
Cache the kernel sampler function pointer based on the current model.
-
class CVehicleGenGarage : public CVehicleGenerator#
Vehicle generator that draws from a pre-recorded pool of vehicles.
CVehicleGenGarage (“garage” as in a stable of vehicles) replays observed vehicles in a round-robin or index-based manner rather than sampling from a parametric distribution. This is useful when the input data is trusted to be representative and the simulation wants to study load effects on a specific fleet, not a synthetic one.
Each call to GenerateVehicle() copies the geometry and weights from the next stored vehicle onto the target, with optional small perturbation via the randomize() helper.
See also
See also
Protected Functions
-
virtual void GenerateVehicle(CVehicle_sp pVeh)#
Populate
pVehfrom the next vehicle in the garage pool.
-
inline virtual size_t GenVehClass()#
Garage mode does not distinguish classes; always returns 0.
Private Functions
-
void randomize(CVehicle_sp pVeh)#
Apply small random perturbations to
pVeh'sweights and spacings.
-
virtual void GenerateVehicle(CVehicle_sp pVeh)#
-
class CVehicleGenGrave : public CVehicleGenerator#
Vehicle generator implementing Sam Grave’s model of French truck traffic.
The Grave model samples truck geometry from multi-modal normal distributions conditional on the number of axles and a vehicle class index. Trucks with 2 or 3 axles are generated via GenerateTruck23(), trucks with 4 or 5 axles via GenerateTruck45(); in both cases common properties (length, track width, speed) come from GenerateCommonProps().
This model was developed by Sam Grave for the French WIM data used in calibrating Eurocode EN 1991-2 traffic load models.
See also
See also
Protected Functions
-
virtual void GenerateVehicle(CVehicle_sp pVeh)#
Populate
pVehwith a sampled truck.Samples the number of axles from the class distribution, then dispatches to GenerateTruck23() or GenerateTruck45() based on whether the truck has 2–3 or 4–5 axles.
-
virtual size_t GenVehClass()#
Sample a vehicle-class index from the class distribution.
Private Functions
-
void GenerateTruck23(CVehicle_sp pVeh, size_t nAxles)#
Generate a 2- or 3-axle truck.
- Parameters:
pVeh – [inout] Vehicle to populate.
nAxles – [in] Number of axles (2 or 3).
-
void GenerateTruck45(CVehicle_sp pVeh, size_t nAxles)#
Generate a 4- or 5-axle truck.
- Parameters:
pVeh – [inout] Vehicle to populate.
nAxles – [in] Number of axles (4 or 5).
-
void GenerateCommonProps(CVehicle_sp pVeh, size_t nAxles)#
Populate length, track width, and other properties shared across the 23- and 45-axle paths.
- Parameters:
pVeh – [inout] Vehicle to populate.
nAxles – [in] Number of axles.
-
virtual void GenerateVehicle(CVehicle_sp pVeh)#
-
class CVehicleGenNominal : public CVehicleGenerator#
Vehicle generator that produces a single user-supplied nominal vehicle, optionally perturbed by small random variations.
CVehicleGenNominal is used when the simulation wants to study the load effect of one known vehicle — or a tightly-constrained family around it — rather than a representative fleet. A user-supplied
m_NominalVehiclecarries the baseline geometry and weights; each call to GenerateVehicle() copies it onto the target and then optionally applies small random perturbations via randomize(), bounded below bym_MinimumCOV(minimum coefficient of variation).See also
See also
Protected Functions
-
virtual void GenerateVehicle(CVehicle_sp pVeh)#
Populate
pVehwith a copy of the nominal vehicle, then randomize().
-
inline virtual size_t GenVehClass()#
Nominal mode does not distinguish classes; always returns 0.
Private Functions
-
void randomize(CVehicle_sp pVeh)#
Apply small random perturbations to
pVeh'sweights and spacings.
-
virtual void GenerateVehicle(CVehicle_sp pVeh)#
Axle distributions#
-
class CAxleSpacing#
Storage for axle-spacing distributions indexed by number of axles.
CAxleSpacing holds CMultiModalNormal distributions for the axle spacings of 2-, 3-, 4-, and 5-axle trucks. Each call to GetSpacingDist() returns the distribution for one spacing slot (e.g. the 3rd spacing of a 5-axle truck), from which the vehicle generator samples.
The four Add*AxleData() helpers load the per-bucket distribution sets at configuration time. Distributions are multi-modal normals because observed WIM axle-spacing histograms are often bimodal or trimodal (distinct vehicle sub-populations).
See also
See also
Public Functions
-
CMultiModalNormal GetSpacingDist(int iTruck, int iSpace)#
Get the spacing distribution for one axle slot of one truck type.
- Parameters:
iTruck – [in] Zero-based truck-axle-count bucket (0 = 2-axle, 1 = 3-axle, etc.).
iSpace – [in] Zero-based spacing slot (0 = between axles 1 and 2, and so on).
- Returns:
The multi-modal normal distribution for that slot.
-
void Add2AxleData(std::vector<CMultiModalNormal> vSpace)#
Load the 2-axle-truck spacing distributions.
-
void Add3AxleData(std::vector<CMultiModalNormal> vSpace)#
Load the 3-axle-truck spacing distributions.
-
void Add4AxleData(std::vector<CMultiModalNormal> vSpace)#
Load the 4-axle-truck spacing distributions.
-
void Add5AxleData(std::vector<CMultiModalNormal> vSpace)#
Load the 5-axle-truck spacing distributions.
Private Members
-
std::vector<CMultiModalNormal> m_v2AxleData#
Spacing distributions for 2-axle trucks.
-
std::vector<CMultiModalNormal> m_v3AxleData#
Spacing distributions for 3-axle trucks.
-
std::vector<CMultiModalNormal> m_v4AxleData#
Spacing distributions for 4-axle trucks.
-
std::vector<CMultiModalNormal> m_v5AxleData#
Spacing distributions for 5-axle trucks.
-
CMultiModalNormal GetSpacingDist(int iTruck, int iSpace)#
-
class CAxleWeight23#
Storage for axle-weight distributions of 2- and 3-axle trucks.
CAxleWeight23 holds CMultiModalNormal distributions for each individual axle of a 2- or 3-axle truck. Each call to GetAxleDist() returns the distribution for one axle of one truck type. The multi-modal-normal form captures the distinct sub-populations often observed in WIM axle-weight histograms (e.g. empty vs. loaded trucks).
See also
See also
See also
Public Functions
-
CMultiModalNormal GetAxleDist(int iTruck, int iAxle)#
Get the axle-weight distribution for one axle of one truck type.
- Parameters:
iTruck – [in] Zero-based truck-axle-count bucket (0 = 2-axle, 1 = 3-axle).
iAxle – [in] Zero-based axle index within that truck.
- Returns:
The multi-modal normal weight distribution.
-
void Add3AxleData(std::vector<CMultiModalNormal> vAxle)#
Load the per-axle weight distributions for 3-axle trucks.
-
void Add2AxleData(std::vector<CMultiModalNormal> vAxle)#
Load the per-axle weight distributions for 2-axle trucks.
Private Members
-
std::vector<CMultiModalNormal> m_v2AxleData#
Axle-weight distributions for 2-axle trucks.
-
std::vector<CMultiModalNormal> m_v3AxleData#
Axle-weight distributions for 3-axle trucks.
-
CMultiModalNormal GetAxleDist(int iTruck, int iAxle)#
-
class CAxleWeight45#
Storage for GVW-banded axle-weight distributions of 4- and 5-axle trucks.
Unlike CAxleWeight23, which holds per-axle multi-modal normal distributions, CAxleWeight45 stores GVW-conditioned weight bands: for each GVW range of each truck type, the mean and standard deviation of the front axle (W1), the rear axle group (W2), and the total weight (WT) are recorded. This lets the Grave model sample individual axle weights conditional on the overall truck weight.
The Dist struct holds (mean, standard deviation) for one weight slot; the GVWRange struct bundles three Dists (W1, W2, WT) for one GVW band.
See also
See also
Public Functions
-
std::vector<double> GetGVWRange(int iTruck, int iRange)#
Get the GVW-range distribution parameters for one truck and range.
Returns a flattened vector of (mean, std-dev) pairs for W1, W2, and WT in the requested range.
- Parameters:
iTruck – [in] Zero-based truck-axle-count bucket (0 = 4-axle, 1 = 5-axle).
iRange – [in] Zero-based GVW band index.
- Returns:
Flattened vector of distribution parameters.
-
void AddGVWRange(std::vector<double> data, int iTruck, int iRange)#
Load the distribution parameters for one GVW band.
- Parameters:
data – [in] Flattened (mean, std-dev) vector.
iTruck – [in] Truck bucket (0 = 4-axle, 1 = 5-axle).
iRange – [in] GVW band index.
Private Members
-
struct Dist#
A single distribution slot: mean and standard deviation.
-
struct GVWRange#
Weight parameters for one GVW band: front axle W1, rear axle group W2, and total WT.
-
std::vector<double> GetGVWRange(int iTruck, int iRange)#
Flow (headway / speed) generators#
The flow generator hierarchy roots at CFlowGenerator (also derived
from CGenerator), with four concrete subclasses for different
traffic regimes: HeDS (empirical headway distributions), congested
(narrow-normal gaps), Poisson (exponential arrivals), and constant
(deterministic). Members on the derived classes are listed explicitly
to avoid duplicate inherited-symbol targets.
-
class CFlowGenerator : public CGenerator#
Abstract base class for headway and speed generators.
A CFlowGenerator produces the inter-vehicle gap (in seconds) and speed (in metres per second) for the next vehicle on a lane. It decouples the when of vehicle arrivals from the what (handled by CVehicleGenerator).
The base class handles the shared bookkeeping:
Hourly blocks:
m_BlockSize(typically 3600 s) defines one block,m_BlockCount(typically 24) is the number of blocks in a day. The current block index is advanced in updateBlock(), which is what gives the simulation a natural daily seam.Minimum gap:
m_MinGapenforces a physically realistic spacing between vehicles, set in setMinGap() from the previous and next vehicle velocities and lengths.Bridge length:
m_MaxBridgeLengthlets the generator reason about multi-vehicle interactions on long spans.
Concrete subclasses implement GenerateGap() and GenerateSpeed() corresponding to different headway models:
CFlowGenHeDS: Headway Distribution Statistics model (empirical per-flow-rate headway distributions).
CFlowGenCongested: congested flow with a normally-distributed gap and constant speed.
CFlowGenPoisson: Poisson arrivals (exponential gaps) with a normal speed distribution.
CFlowGenConstant: deterministic headway and speed, used for testing and validation.
See also
CGenerator
See also
See also
Subclassed by CFlowGenCongested, CFlowGenConstant, CFlowGenHeDS, CFlowGenPoisson
Public Functions
-
double Generate()#
Generate the next vehicle’s gap and speed.
Calls the subclass’s GenerateGap() and GenerateSpeed() hooks, clamping the gap to
m_MinGap. Returns the combined gap as a scalar for the lane to add to the current arrival time.- Returns:
Gap in seconds.
-
virtual void prepareNextGen(double time, CVehicle_sp pPrevVeh, CVehicle_sp pNextVeh)#
Refresh the minimum-gap constraint from the previous and next vehicles.
Called by the lane before each Generate() so the generator can honour car-following: the next vehicle’s speed and length plus the previous vehicle’s length determine the physical minimum headway.
- Parameters:
time – [in] Simulation time in seconds.
pPrevVeh – [in] Most recently emitted vehicle.
pNextVeh – [in] Next vehicle about to be emitted.
-
void setMaxBridgeLength(double length)#
Record the maximum bridge length for minimum-gap reasoning.
- Parameters:
length – [in] Bridge length in metres.
-
inline size_t getCurBlock()#
Get the current hour-of-day block index (0-based, within one block cycle).
Protected Functions
-
virtual double GenerateGap() = 0#
Sample a gap from the subclass-specific headway model.
-
virtual double GenerateSpeed() = 0#
Sample a speed from the subclass-specific speed model.
-
virtual void updateProperties()#
Refresh block-dependent parameters at a block transition.
-
double genExponential()#
Sample from an exponential distribution with the current truck-flow rate.
-
class CFlowGenHeDS : public CFlowGenerator#
Flow generator using Headway Distribution Statistics (HeDS).
The HeDS model samples the inter-vehicle gap from an empirical cumulative distribution that is conditional on the current flow rate. The per-flow-rate distributions are carried in a matrix (
m_vHeDS); speeds are drawn from a normal distribution.See also
-
class CFlowGenCongested : public CFlowGenerator#
Flow generator for congested-flow conditions.
Models queued or congested traffic by drawing gaps from a normal distribution (typically narrow around the minimum safe gap) and speeds from a single constant value — representative of stop-and-go or free-flowing congested conditions.
See also
-
class CFlowGenPoisson : public CFlowGenerator#
Flow generator for Poisson (exponential-headway) arrivals.
Models free-flow traffic as a Poisson process: inter-vehicle gaps are drawn from an exponential distribution whose rate is set by the current truck-flow rate. Speeds come from a normal distribution. This is the classical assumption for light traffic.
See also
-
class CFlowGenConstant : public CFlowGenerator#
Deterministic (constant-headway, constant-speed) flow generator.
Produces perfectly regular traffic with fixed gap and speed. Used mainly for testing and validation, where stochastic variation would confuse the result.
See also
Configuration#
The configuration object is exposed in two flavours: CConfigDataCore
is the full settings tree and is the class documented below;
CConfigData is a thin singleton subclass that exposes a
process-wide instance via CConfigData::get() for classes that cannot
easily receive a reference through their constructor. CConfigData
itself is documented inline in its header only — rendering both
alongside each other triggers the Breathe duplicate-inherited-target
issue described above.
-
class CConfigDataCore#
Core simulation configuration block — the full settings tree driving a BTLS run.
CConfigDataCore holds every knob a BTLS simulation exposes, organised into a set of nested structs (Mode, Road, Gen, Read, Traffic, Sim, Output, Time) each of which groups related fields. When the standalone BTLS binary parses a
BTLSin.txtfile, the parsed values are written directly into these structs; the PyBTLS Python layer sets them programmatically via pybind11 bindings.The CConfigData singleton below exposes a single process-wide instance for classes that need configuration access without receiving a reference through their constructor.
See also
CConfigData
Subclassed by CConfigData
Public Functions
-
bool ReadData(std::string inFile)#
Parse a
BTLSin.txtconfiguration file into this object.- Parameters:
inFile – [in] Path to the BTLSin file.
- Returns:
True on success, false if the file could not be opened.
-
void setRoad(size_t noLanes, size_t noDirs, size_t noLanesDir1, size_t noLanesDir2)#
Populate Road_Config from externally-derived counts.
Used when the road layout is driven from a lane-flow file parsed outside of this class.
- Parameters:
noLanes – [in] Total number of lanes.
noDirs – [in] Number of directions (1 or 2).
noLanesDir1 – [in] Lanes in direction 1.
noLanesDir2 – [in] Lanes in direction 2.
Private Functions
-
void doDerivedConstants()#
Compute derived constants from the parsed configuration.
-
void ExtractData()#
Pull the parsed CSV rows into the struct fields.
-
std::string GetNextDataLine()#
Read the next non-comment, non-empty line from the CSV parser.
Private Members
-
CCSVParse m_CSV#
CSV parser used by ReadData().
-
std::string m_CommentString#
Comment prefix recognised in BTLSin.txt.
-
struct Gen_Config#
Traffic-generation settings (generation mode only).
Public Members
-
std::string TRAFFIC_FOLDER#
Folder containing the generation input files.
-
bool GEN_TRAFFIC#
If true, generate traffic rather than read from file.
-
size_t NO_DAYS#
Number of days to generate.
-
double TRUCK_TRACK_WIDTH#
Default truck track width in mm (input unit, not metres).
-
double LANE_ECCENTRICITY_STD#
Standard deviation of lane-eccentricity random perturbation.
-
int KERNEL_TYPE#
Kernel type for garage/nominal models (EKernelType enum).
-
double NO_OVERLAP_LENGTH#
Reference length for multi-vehicle no-overlap reasoning.
-
std::string TRAFFIC_FOLDER#
-
struct Mode_Config#
Top-level run-mode settings.
Public Members
-
size_t PROGRAM_MODE#
Program operating mode (simulation / generation / analysis).
-
size_t PROGRAM_MODE#
-
struct Output_Config#
Output configuration for every writer in the event pipeline.
Public Members
-
bool WRITE_TIME_HISTORY#
Enable per-timestep time-history file output.
-
bool WRITE_EACH_EVENT#
Enable all-events file output (every completed event).
-
size_t WRITE_EVENT_BUFFER_SIZE#
Buffer size for the all-events stream.
-
bool WRITE_FATIGUE_EVENT#
Enable the fatigue-events buffer.
-
struct BlockMax_Config#
Block-maxima writer configuration.
Public Members
-
bool WRITE_BM#
Enable the block-maxima writer.
-
bool WRITE_BM_VEHICLES#
Include per-vehicle detail in block-max files.
-
bool WRITE_BM_SUMMARY#
Include summary files.
-
bool WRITE_BM_MIXED#
Enable the mixed-stream (all-vehicle-counts) output.
-
size_t BLOCK_SIZE_DAYS#
Block size in days.
-
size_t BLOCK_SIZE_SECS#
Block size in seconds (derived).
-
size_t WRITE_BM_BUFFER_SIZE#
Buffer size in completed blocks.
-
bool WRITE_BM#
-
struct Fatigue_Config#
Fatigue rainflow-counting configuration.
-
struct POT_Config#
Peaks-over-threshold writer configuration.
Public Members
-
bool WRITE_POT#
Enable the POT writer.
-
bool WRITE_POT_VEHICLES#
Include per-vehicle detail in POT files.
-
bool WRITE_POT_SUMMARY#
Include summary files.
-
bool WRITE_POT_COUNTER#
Enable the per-block exceedance counter file.
-
size_t POT_COUNT_SIZE_DAYS#
Counter block size in days.
-
size_t POT_COUNT_SIZE_SECS#
Counter block size in seconds (derived).
-
size_t WRITE_POT_BUFFER_SIZE#
Buffer size in POT events.
-
bool WRITE_POT#
-
struct Stats_Config#
Running-statistics writer configuration.
Public Members
-
bool WRITE_STATS#
Enable the statistics writer.
-
bool WRITE_SS_CUMULATIVE#
Write cumulative statistics over the full run.
-
bool WRITE_SS_INTERVALS#
Write per-interval statistics.
-
size_t WRITE_SS_INTERVAL_SIZE#
Interval size in seconds.
-
size_t WRITE_SS_BUFFER_SIZE#
Buffer size in intervals.
-
bool WRITE_STATS#
-
struct VehicleFile_Config#
Generated vehicle output (for generation mode).
-
bool WRITE_TIME_HISTORY#
-
struct Read_Config#
Traffic-reading settings (replay mode only).
Public Members
-
bool READ_FILE#
If true, replay traffic from a file instead of generating.
-
std::string TRAFFIC_FILE#
Traffic data file path (CASTOR/BeDIT/DITIS/MON format).
-
std::string GARAGE_FILE#
Pre-recorded vehicle pool file (for the Garage model).
-
std::string KERNEL_FILE#
Kernel parameters file for randomisation.
-
std::string NOMINAL_FILE#
Nominal vehicle definition file.
-
size_t FILE_FORMAT#
File format tag (1=CASTOR, 2=BeDIT, 3=DITIS, 4=MON).
-
bool USE_CONSTANT_SPEED#
Override each vehicle’s speed with
CONST_SPEED.
-
bool USE_AVE_SPEED#
Override each vehicle’s speed with the file average.
-
double CONST_SPEED#
Constant speed used when USE_CONSTANT_SPEED is true.
-
bool READ_FILE#
-
struct Road_Config#
Road layout (number of lanes, directions) and lane-flow source file.
Public Members
-
std::string LANES_FILE#
CSV file describing per-lane flow rates.
-
size_t NO_LANES_DIR1#
Lanes in direction 1 (populated from LANES_FILE).
-
size_t NO_LANES_DIR2#
Lanes in direction 2 (populated from LANES_FILE).
-
size_t NO_LANES#
Total lanes across both directions.
-
size_t NO_DIRS#
Number of traffic directions (1 or 2).
-
std::string LANES_FILE#
-
struct Sim_Config#
Bridge load-effect calculation settings.
Public Members
-
bool CALC_LOAD_EFFECTS#
If true, run the bridge load-effect calculation at all.
-
std::string BRIDGE_FILE#
Bridge definitions file.
-
std::string INFLINE_FILE#
Influence lines file.
-
std::string INFSURF_FILE#
Influence surfaces file.
-
double CALC_TIME_STEP#
Inner-loop time step in seconds (typical 0.01–0.1).
-
size_t MIN_GVW#
Minimum GVW (in kN) below which vehicles are treated as cars.
-
bool CALC_LOAD_EFFECTS#
-
struct Time_Config#
Time-unit constants used throughout the simulation.
Public Members
-
size_t DAYS_PER_MT#
Days per “month” (simulation month, not calendar).
-
size_t MTS_PER_YR#
Months per year (simulation year).
-
size_t HOURS_PER_DAY#
Hours per day (24).
-
size_t SECS_PER_HOUR#
Seconds per hour (3600).
-
size_t MINS_PER_HOUR#
Minutes per hour (60).
-
size_t SECS_PER_MIN#
Seconds per minute (60).
-
size_t DAYS_PER_MT#
-
struct Traffic_Config#
Traffic model selection (which vehicle generator and headway model).
Public Members
-
int VEHICLE_MODEL#
Vehicle generator selector (EVehicleModel enum).
-
int HEADWAY_MODEL#
Flow/headway generator selector (EFlowModel enum).
-
int CLASSIFICATION#
Vehicle classification scheme to apply.
-
double CONGESTED_SPACING#
Mean spacing in congested mode, in metres.
-
double CONGESTED_SPEED#
Speed in congested mode, in m/s.
-
double CONGESTED_GAP#
Mean gap in congested mode (derived), in seconds.
-
double CONGESTED_GAP_COEF_VAR#
Coefficient of variation of the congested gap.
-
double CONSTANT_SPEED#
Speed used by the Constant flow model, in m/s.
-
double CONSTANT_GAP#
Gap used by the Constant flow model, in seconds.
-
int VEHICLE_MODEL#
-
bool ReadData(std::string inFile)#
Vehicle model data#
The vehicle-model-data hierarchy roots at CModelData (see
cpp/include/ModelData.h), which carries the shared configuration
reference and CSV parser. The intermediate CVehicleModelData
defines the fields common to all vehicle models; the three concrete
subclasses layer model-specific distributions on top. Both bases are
documented inline in their headers and are not rendered here to avoid
the duplicate-inherited-target pattern.
-
class CVehicleModelData : public CModelData#
Intermediate base class for vehicle-model data containers.
CVehicleModelData carries the fields that every vehicle model needs: the model selector, the classification scheme, the number of truck classes, the per-lane class composition matrix, and the lane eccentricity standard deviation. Concrete subclasses — CVehModelDataGrave, CVehModelDataGarage, CVehModelDataNominal — layer model-specific distribution data on top.
See also
CModelData
See also
Subclassed by CVehModelDataGarage, CVehModelDataGrave, CVehModelDataNominal
Public Functions
-
inline EVehicleModel getModel() const#
Get the model selector this container was constructed with.
-
inline size_t getTruckClassCount() const#
Get the number of truck classes supported.
-
inline CVehicleClassification_sp getVehClassification() const#
Get the vehicle classifier used by this model.
-
inline double getLaneEccStd() const#
Get the standard deviation of the lane eccentricity perturbation, in metres.
-
vec getComposition(size_t i) const#
Get the truck-class composition vector for lane
i.- Parameters:
i – [in] Zero-based lane index.
- Returns:
Probability vector over truck classes summing to 1.0.
-
inline EKernelType getKernelType() const#
Get the kernel shape used for randomisation (normal or triangle).
-
inline EVehicleModel getModel() const#
-
class CVehModelDataGarage : public CVehicleModelData#
Vehicle-model data holding a pre-recorded pool of vehicles (a “garage”) used by CVehicleGenGarage.
Loads a set of observed vehicles from the configuration’s
GARAGE_FILE(or is populated programmatically via the vector constructor from the PyBTLS Python layer). The pool is replayed in order by the garage vehicle generator, optionally with small randomisation parametrised by the GVW, axle-weight, and axle-spacing kernels loaded fromKERNEL_FILE.See also
See also
Public Functions
-
virtual void ReadDataIn()#
Read the garage and kernel input files.
-
inline size_t getGarageCount() const#
Get the number of vehicles in the garage pool.
-
CVehicle_sp getVehicle(size_t i)#
Get the i-th vehicle from the garage pool.
- Parameters:
i – [in] Zero-based pool index.
-
void getKernels(KernelParams &GVW, KernelParams &AW, KernelParams &AS)#
Get the randomisation kernels for GVW, axle weight, and axle spacing.
- Parameters:
GVW – [out] Kernel parameters for gross vehicle weight.
AW – [out] Kernel parameters for axle weight.
AS – [out] Kernel parameters for axle spacing.
Private Functions
-
void readGarage()#
Parse the garage file into
m_vVehicles.
-
void readKernels()#
Parse the kernel file into the
m_Kernel*fields.
-
void assignGarage(std::vector<CVehicle_sp> vVehicles)#
Assign the garage pool from a caller-supplied vector.
-
void assignKernels(std::vector<std::vector<double>> vKernelParams)#
Assign the kernel parameters from a caller-supplied vector-of-vectors.
-
virtual void ReadDataIn()#
-
class CVehModelDataGrave : public CVehicleModelData#
Vehicle-model data for the Grave model of French truck traffic.
CVehModelDataGrave holds the full set of conditional distributions that CVehicleGenGrave samples from: axle-spacing multi-modal normals by truck class, axle-weight multi-modal normals for 2- and 3-axle trucks, GVW-banded weight distributions for 4- and 5-axle trucks, per-direction GVW distributions, per-truck track-width distributions, and per-direction speed distributions.
Data is loaded from four input files — axle-weight-23, axle-weight-45, axle-spacing, and GVW — via the ReadFile_* helpers, or populated programmatically through the Add* setters called from the PyBTLS Python layer.
See also
See also
See also
Public Functions
-
virtual void ReadDataIn()#
Read all Grave-model input files.
-
std::vector<double> GetGVWRange(size_t iTruck, size_t iRange)#
Get the mean/std parameters for a GVW band.
- Parameters:
iTruck – [in] Truck bucket (0 = 4-axle, 1 = 5-axle).
iRange – [in] GVW band index.
- Returns:
Flattened (mean, std) pairs for W1, W2, WT.
-
CMultiModalNormal GetSpacingDist(size_t iTruck, size_t iSpace)#
Get the spacing distribution for one spacing slot of one truck type.
-
CMultiModalNormal GetAxleWeightDist(size_t iTruck, size_t iAxle)#
Get the axle-weight distribution for one axle of one truck type.
-
CMultiModalNormal GetTrackWidthDist(size_t iTruck, size_t iAxle)#
Get the axle track-width distribution for one axle of one truck type.
-
CMultiModalNormal GetGVW(size_t dir, size_t iTruck)#
Get the GVW distribution for one direction and truck type.
-
void Add2AxleSpacings(std::vector<CMultiModalNormal> vSpace)#
Load 2-axle truck spacing distributions.
-
void Add3AxleSpacings(std::vector<CMultiModalNormal> vSpace)#
Load 3-axle truck spacing distributions.
-
void Add4AxleSpacings(std::vector<CMultiModalNormal> vSpace)#
Load 4-axle truck spacing distributions.
-
void Add5AxleSpacings(std::vector<CMultiModalNormal> vSpace)#
Load 5-axle truck spacing distributions.
-
void Add2AxleTrackWidth(std::vector<CMultiModalNormal> vSpace)#
Load 2-axle track-width distributions.
-
void Add3AxleTrackWidth(std::vector<CMultiModalNormal> vSpace)#
Load 3-axle track-width distributions.
-
void Add4AxleTrackWidth(std::vector<CMultiModalNormal> vSpace)#
Load 4-axle track-width distributions.
-
void Add5AxleTrackWidth(std::vector<CMultiModalNormal> vSpace)#
Load 5-axle track-width distributions.
-
void Add2AxleWeight(std::vector<CMultiModalNormal> vAxle)#
Load 2-axle per-axle weight distributions.
-
void Add3AxleWeight(std::vector<CMultiModalNormal> vAxle)#
Load 3-axle per-axle weight distributions.
-
void Add45AxleWeight(std::vector<double> data, std::size_t iTruck, std::size_t iRange)#
Load one GVW band for 4- or 5-axle trucks.
- Parameters:
data – [in] Flattened (mean, std) parameters.
iTruck – [in] Truck bucket (0 = 4-axle, 1 = 5-axle).
iRange – [in] GVW band index.
-
void AddGVW(int dir, std::vector<CMultiModalNormal> vGVW)#
Load the per-truck GVW distributions for one direction.
- Parameters:
dir – [in] Direction (1 or 2).
vGVW – [in] One GVW distribution per truck type.
-
void AddSpeed(std::vector<CMultiModalNormal> vSpeed)#
Load the per-direction speed distributions.
Speed is kept here as part of the class modelling rather than in the flow-model data.
-
CMultiModalNormal GetSpeed(std::size_t dir)#
Get the speed distribution for one direction.
-
virtual void ReadDataIn()#
-
class CVehModelDataNominal : public CVehicleModelData#
Vehicle-model data for the nominal-vehicle model.
Holds a single user-supplied nominal vehicle along with the kernel parameters used to apply small random perturbations to its axle weights and axle spacings on each generation. Used by CVehicleGenNominal when the simulation studies the load effect of one specific vehicle type (e.g. a heavy permit load) rather than a representative fleet.
The vehicle can be loaded from
NOMINAL_FILEor supplied programmatically through the vector constructor from the PyBTLS Python layer.See also
See also
Public Functions
-
virtual void ReadDataIn()#
Read the nominal vehicle and perturbation kernels from disk.
-
void getKernels(KernelParams &AW, KernelParams &AS)#
Get the randomisation kernels for axle weight and spacing.
- Parameters:
AW – [out] Kernel parameters for axle weight.
AS – [out] Kernel parameters for axle spacing.
-
inline CVehicle_sp getNominalVehicle()#
Get the nominal vehicle template (shared).
-
virtual void ReadDataIn()#
Flow model data#
The flow-model-data hierarchy shares the same base CModelData.
CFlowModelData defines the per-block flow/speed fields; four
concrete subclasses map to the headway models in
FlowGenerator.h.
-
class CFlowModelData : public CModelData#
Intermediate base class for flow-model data containers.
CFlowModelData carries the shared per-block flow parameters used by every headway model: total flow, truck flow, car percentage, speed distribution, block size and block count. The four concrete subclasses add model-specific data read from their respective input files via ReadDataIn().
Blocks are the daily time slices within which the flow rate is taken to be constant. The default is 24 hourly blocks of 3600 s each; see CFlowGenerator for how the blocks drive the simulation cycle.
See also
CModelData
See also
See also
See also
See also
See also
Subclassed by CFlowModelDataCongested, CFlowModelDataConstant, CFlowModelDataHeDS, CFlowModelDataPoisson
Public Functions
-
inline vec getCarPercent() const#
Get the per-block car percentage vector (24 entries for 24 hours).
-
void getFlow(size_t i, double &totalFlow, double &truckFlow)#
Get the total and truck flow for block
i.- Parameters:
i – [in] Block index (0..23 for hourly blocks).
totalFlow – [out] Total flow rate for the block (veh/h).
truckFlow – [out] Truck flow rate for the block (truck/h).
-
void getSpeedParams(size_t i, Normal &speed)#
Get the speed distribution parameters for block
i.- Parameters:
i – [in] Block index.
speed – [out] Normal distribution with mean and std dev in m/s.
-
void getGapLimits(double &bridge, double &space, double &time)#
Get the buffer-gap parameters (additional safety spacing).
- Parameters:
bridge – [out] Bridge length reference in metres.
space – [out] Additional safety space in metres.
time – [out] Additional safety time in seconds.
-
inline EFlowModel getModel() const#
Get the flow-model selector.
-
inline bool getModelHasCars() const#
Return true if this model generates cars in addition to trucks.
-
void getBlockInfo(size_t &sz, size_t &n) const#
Get the block size and count.
- Parameters:
sz – [out] Block size in seconds.
n – [out] Number of blocks in one cycle.
-
inline vec getCarPercent() const#
-
class CFlowModelDataHeDS : public CFlowModelData#
Flow-model data for the Headway Distribution Statistics (HeDS) model.
Loads an empirical cumulative-distribution table of inter-vehicle gaps, indexed by flow rate, from the HeDS input file. The matrix
m_vHeDSholds one headway CDF per flow-rate row; the matching CFlowGenHeDS samples from the current-flow-rate row at each invocation.See also
Public Functions
-
virtual void ReadDataIn()#
Read the HeDS input file and populate
m_vHeDS.
-
matrix GetHeDS()#
Get a copy of the HeDS headway matrix.
Private Functions
-
void ReadFile_HeDS()#
Parse the HeDS input file into
m_vHeDS.
-
virtual void ReadDataIn()#
-
class CFlowModelDataCongested : public CFlowModelData#
Flow-model data for congested-flow conditions.
Holds a constant speed and a normally-distributed inter-vehicle gap (mean + standard deviation), representing queued or congested traffic where every vehicle travels at approximately the same slow speed and maintains a tight headway.
See also
Public Functions
-
virtual void ReadDataIn()#
Populate from the configuration’s Traffic.CONGESTED_* fields.
-
inline double getSpeed() const#
Get the congested-mode constant speed in m/s.
-
void getGapParams(double &mean, double &std)#
Get the gap distribution parameters.
- Parameters:
mean – [out] Gap mean in seconds.
std – [out] Gap standard deviation in seconds.
-
virtual void ReadDataIn()#
-
class CFlowModelDataPoisson : public CFlowModelData#
Flow-model data for Poisson (exponential-headway) arrivals.
No data beyond what the intermediate base class carries — the Poisson arrival rate is taken directly from
m_vTruckFlowfor the current block.See also
Public Functions
-
virtual void ReadDataIn()#
Read any Poisson-specific inputs (currently a no-op; flow rates come from the base).
-
virtual void ReadDataIn()#
-
class CFlowModelDataConstant : public CFlowModelData#
Flow-model data for deterministic (constant-gap, constant-speed) traffic.
Used for testing and validation where stochastic variation would confuse the result. The constant gap and speed come from the configuration’s Traffic.CONSTANT_* fields.
See also
Random number generation#
-
class CRNGWrapper#
Process-wide random number generator wrapper.
CRNGWrapper wraps a single static
std::mt19937instance shared across the entire BTLS process. Every CDistribution holds a CRNGWrapper by value, but because the underlying generator state isstatic, they all share the same stream.By default the static generator is seeded from
std::random_deviceat library-load time (non-reproducible). Calling seed() resets the generator to a deterministic state, enabling reproducible runs and day-level parallelism (see the Parallelisation Guide in the docs).In multiprocessing contexts (PyBTLS uses the
spawnstart method), each worker process loadslibbtlsindependently and gets its own copy of the static generator. Callingseed(master_seed + worker_id) in each worker produces independent, reproducible streams without any cross-process interference.See also
Public Functions
-
double rand()#
Sample a uniform [0, 1) value.
-
double norm()#
Sample a standard normal value.
Public Static Functions
-
static void seed(uint64_t s)#
Seed the process-wide Mersenne Twister generator.
If never called, the generator is seeded from
std::random_deviceat library load time (non-reproducible). Calling seed() makes subsequent random output deterministic for the given seed value and resets the cached distribution state so no stale values leak across reseeds.- Parameters:
s – [in] Seed value (unsigned 64-bit integer).
-
double rand()#
-
class CDistribution#
Wrapper exposing a family of random-variate generators with configurable location, scale, and shape parameters.
CDistribution is the sampling surface used by CGenerator and its subclasses. It exposes generators for every distribution family needed by the traffic and load-effect models: uniform, normal, multi-modal normal, exponential, lognormal, gamma, Gumbel, Poisson, GEV, and triangular. The active location/scale/shape parameters are accumulated on the instance and fed into whichever generator is invoked.
Randomness comes from the underlying CRNGWrapper, whose state is static — see the note in CRNGWrapper about seeding and reproducibility.
See also
See also
CGenerator
Public Functions
-
CDistribution(double loc, double sc, double sh)#
Construct with explicit location, scale, and shape parameters.
- Parameters:
loc – [in] Location parameter.
sc – [in] Scale parameter.
sh – [in] Shape parameter.
-
void setShape(double sh)#
Set the shape parameter.
-
void setScale(double sc)#
Set the scale parameter.
-
void setLocation(double loc)#
Set the location parameter.
-
double getShape() const#
Get the shape parameter.
-
double getScale() const#
Get the scale parameter.
-
double getLocation() const#
Get the location parameter.
-
double GenerateUniform()#
Sample a uniform [0, 1) value.
-
double GenerateNormal()#
Sample a standard normal value using the instance parameters.
-
double GenerateNormal(double mean, double stdev)#
Sample a normal value with explicit mean and standard deviation.
- Parameters:
mean – [in] Mean of the distribution.
stdev – [in] Standard deviation of the distribution.
-
double GenerateMultiModalNormal(CMultiModalNormal MMN)#
Sample from a multi-modal normal mixture.
- Parameters:
MMN – [in] Multi-modal normal distribution to sample from.
-
double GenerateExponential()#
Sample an exponential value with rate
1/getScale().
-
double GenerateLogNormal()#
Sample a lognormal value.
-
double GenerateGamma()#
Sample a gamma value.
-
double GenerateGumbel()#
Sample a Gumbel (extreme-value type I) value.
-
double GeneratePoisson()#
Sample a Poisson value.
-
double GenerateGEV()#
Sample from a Generalised Extreme Value distribution.
-
double GenerateTriangular()#
Sample a triangular value with the instance parameters.
-
double GenerateTriangular(double loc, double w)#
Sample a triangular value with explicit location and width.
- Parameters:
loc – [in] Central location (mode).
w – [in] Half-width of the triangular distribution.
Private Functions
-
double BoxMuller()#
Box-Muller transform producing a pair of standard normals.
-
CDistribution(double loc, double sc, double sh)#
-
class CMultiModalNormal#
A mixture of one or more normal distributions, each with its own weight, mean, and standard deviation.
CMultiModalNormal stores a weighted sum of
Modestructs, where each Mode is a (weight, mean, stddev) triple. The mixture is used throughout the traffic model layer to capture observed bi- and tri-modal WIM histograms — e.g. empty vs loaded trucks, or distinct vehicle sub-populations — that a single normal cannot represent.Sampling is performed by CDistribution::GenerateMultiModalNormal, which picks one mode weighted by
Weightand then draws from the correspondingNormal.See also
See also
Public Functions
-
void AddMode(double w, double m, double s)#
Append one mode to the mixture.
-
inline std::size_t getNoModes() const#
Get the number of modes in the mixture.
-
struct Mode#
One normal mode of the mixture.
-
void AddMode(double w, double m, double s)#
Output managers (fatigue, statistics)#
Both managers below derive from COutputManagerBase. Explicit
member lists are used to avoid the inherited-target duplication.
-
class CFatigueManager : public COutputManagerBase#
Accumulates load-effect time series and performs fatigue rainflow cycle counting.
CFatigueManager derives from COutputManagerBase but follows a different accumulation pattern than the peak/block-max managers: instead of consuming completed CEvent instances, it receives raw per-timestep load-effect values via addLoadEffectValues(). When enough values have accumulated (controlled by the event buffer size) or at the end of the simulation, it runs the ASTM E1049-85 rainflow algorithm on the accumulated series, counts cycles, and writes the result to the rainflow output file.
The
DO_FATIGUE_RAINFLOW,RAINFLOW_DECIMAL, andRAINFLOW_CUTOFFfields from the configuration control whether the analysis runs, the precision of the cycle-range binning, and the minimum amplitude below which cycles are ignored.See also
See also
COutputManagerBase
See also
Public Functions
-
inline virtual void Update(CEvent Ev)#
No-op event consumer (fatigue uses addLoadEffectValues instead).
-
void Update()#
Trigger a flush of the accumulated series through the rainflow algorithm.
-
void addLoadEffectValues(std::vector<double> vEffs)#
Append one timestep’s load-effect values to the accumulator.
- Parameters:
vEffs – [in] Current load-effect values, one per load effect.
Private Functions
-
void cleanLoadEffectValues()#
Reset the accumulated load-effect series.
-
virtual void CheckBuffer(bool bForceOutput)#
Flush if the accumulated series has reached the buffer threshold.
-
void doRainflow(bool bIsFinal)#
Run the rainflow algorithm on the accumulated series.
- Parameters:
bIsFinal – [in] If true, this is the final flush at end-of-simulation.
-
void writeRainflowBuffer()#
Write the current rainflow output buffer to disk.
-
void cleanRainflowOutCountValues()#
Zero the cycle counts in the rainflow output maps.
-
inline virtual void Update(CEvent Ev)#
-
class CStatsManager : public COutputManagerBase#
Accumulates running statistics (mean, variance, skewness, kurtosis) of load effects and writes interval/cumulative summary files.
CStatsManager receives completed events from CEventManager, folds each event’s maximum into a CEventStatistics accumulator, and periodically flushes the accumulated moments to disk. Two output modes are supported:
Cumulative: one set of statistics over the full simulation, written at the end (controlled by
WRITE_SS_CUMULATIVE).Interval: statistics reset every
WRITE_SS_INTERVAL_SIZEseconds, each interval’s summary written as a row in the output (controlled byWRITE_SS_INTERVALS).
Derives from COutputManagerBase for the shared file-handling plumbing.
See also
See also
COutputManagerBase
See also
Public Functions
Private Functions
-
virtual void WriteSummaryFiles()#
Write per-load-effect summary files at end-of-simulation.
-
virtual void CheckBuffer(bool bForceOutput)#
Flush the interval buffer if it has reached capacity.
-
virtual void WriteBuffer()#
Write buffered interval rows to disk.
-
void WriteCumulativeFile()#
Write the cumulative statistics file.
-
void WriteIntervalHeadings()#
Write the interval-file column headings.
-
void accumulateLE(unsigned int i, double x)#
Fold one value into the accumulator for load effect
i.
-
class CRainflow#
Rainflow cycle counter implementing ASTM E1049-85 (2011) §5.4.4.
CRainflow receives a load-effect time series via processData(), extracts reversals (peaks and troughs), identifies full and half cycles through the standard four-point algorithm, and accumulates cycle counts keyed by stress range in the output map.
The output is a map from rounded stress range to accumulated count (full cycles = 1.0, half cycles = 0.5). Rounding precision is set by
m_Decimal, and cycles belowm_Cutoffare discarded.See also
Public Functions
-
inline CRainflow(int decimal, double cutoff)#
Construct with rounding precision and amplitude cut-off.
- Parameters:
decimal – [in] Number of decimal places for range rounding.
cutoff – [in] Minimum range below which cycles are discarded.
-
void clearRainflowOutput()#
Clear the accumulated cycle-count output map.
-
void processData(const std::vector<double> &series)#
Feed a segment of load-effect time series into the reversal buffer.
- Parameters:
series – [in] Load-effect values over consecutive time steps.
-
void calcCycles(bool bIsFinal)#
Run the rainflow algorithm on the accumulated reversals.
- Parameters:
bIsFinal – [in] If true, extract residual half-cycles at the end of the series.
-
inline const std::map<double, double> &getRainflowOutput() const#
Get the accumulated rainflow output: map from rounded range to cycle count.
Private Functions
-
double doRoundUp(double x) const#
Round
xup tom_Decimaldecimal places.
-
ExtractCycleOut formatOutput(double point1, double point2, double count) const#
Format one cycle extraction into (range, mean, count).
-
template<typename T>
std::vector<std::pair<T, T>> mapToVector(const std::map<T, T> &inputMap) const# Convert a map to a vector of pairs.
-
std::vector<double> extractReversals(const std::vector<double> &series) const#
Extract local extrema (reversals) from the raw series.
-
std::vector<CRainflow::ExtractCycleOut> extractCycles() const#
Apply the four-point ASTM algorithm to extract cycles from the reversal buffer.
-
std::vector<std::pair<double, double>> countCycles(const std::vector<CRainflow::ExtractCycleOut> &cycles) const#
Aggregate extracted cycles by rounded range.
Private Members
-
std::vector<double> m_vReversals#
Accumulated reversal (extrema) buffer.
-
std::map<double, double> m_RainflowOutput#
Rounded range → accumulated cycle count.
-
int m_Decimal#
Decimal precision for range rounding.
-
double m_Cutoff#
Minimum range below which cycles are discarded.
-
struct ExtractCycleOut#
Result of extracting one cycle: range, mean, and count (0.5 or 1.0).
-
inline CRainflow(int decimal, double cutoff)#
Lane flow composition#
-
class CLaneFlowComposition#
Per-lane flow composition over a daily cycle of time blocks.
CLaneFlowComposition holds, for one lane, the per-block total flow, truck flow, car percentage, speed distribution, and class-composition matrix. It is loaded from the lane-flow CSV file by CLaneFlowData and passed to CLaneGenTraffic and the model data classes to parametrise one lane’s traffic stream.
Blocks are typically hours (3600 s), and there are typically 24 per daily cycle. The class carries both the block size and count so the downstream generators can compute absolute times from block indices.
See also
See also
Public Functions
-
CLaneFlowComposition(size_t lane, size_t dirn, size_t blockSize)#
Construct a composition for one lane.
- Parameters:
lane – [in] Global zero-based lane index.
dirn – [in] Direction of travel (1 or 2).
blockSize – [in] Block size in seconds (typically 3600).
-
inline size_t getGlobalLaneNo() const#
Get the global zero-based lane index.
-
inline size_t getDirn() const#
Get the direction of travel (1 or 2).
-
inline matrix getComposition() const#
Get the per-block class-composition matrix.
-
inline vec getCarPercent() const#
Get the per-block car percentage vector.
-
inline vec getTotalFlow() const#
Get the per-block total flow rates (veh/h).
-
inline vec getTruckFlow() const#
Get the per-block truck flow rates (truck/h).
-
inline std::vector<Normal> getSpeed() const#
Get the per-block speed distribution (Normal mean/stddev).
-
inline size_t getBlockCount() const#
Get the number of blocks in the daily cycle.
-
inline size_t getBlockSize() const#
Get the block size in seconds.
-
inline size_t getTruckClassCount() const#
Get the number of truck classes represented.
-
void addBlockData(vec vData)#
Append one block’s data row.
Each row contains: total flow, truck flow, car %, speed mean, speed std, and one class percentage per truck class.
- Parameters:
vData – [in] Flattened block data vector.
-
void completeData()#
Derive secondary fields (e.g. composition matrix) after all blocks have been added.
Private Members
-
matrix m_mComposition#
Per-block truck class composition matrix.
-
vec m_vCarP#
Per-block car percentage.
-
vec m_vTotalFlow#
Per-block total flow (veh/h).
-
vec m_vTruckFlow#
Per-block truck flow (truck/h).
-
std::vector<Normal> m_vSpeed#
Per-block speed distribution.
-
size_t m_GlobalLaneNo#
Global zero-based lane index.
-
size_t m_Dirn#
Direction (1 or 2).
-
size_t m_BlockSize#
Block size in seconds (typically 3600).
-
size_t m_NoBlocks#
Number of blocks in one cycle (typically 24).
-
size_t m_TruckClassCount#
Number of truck classes.
-
CLaneFlowComposition(size_t lane, size_t dirn, size_t blockSize)#
-
class CLaneFlowData : public CModelData#
Reads the lane-flow CSV file and builds a CLaneFlowComposition for each lane.
The lane-flow file defines the traffic stream for every lane in the road layout: per-block (typically hourly) flow rates, truck percentages, class percentages, and speed distributions. The file is named by
CConfigDataCore::Road::LANES_FILE.On ReadDataIn(), CLaneFlowData parses the CSV, determines the number of lanes, directions, and block structure, and populates the road-layout fields in the configuration via CConfigDataCore::setRoad().
See also
See also
CModelData
See also
Public Functions
-
virtual void ReadDataIn()#
Parse the lane-flow CSV and populate internal state.
-
CLaneFlowComposition getLaneComp(size_t i) const#
Get the composition for lane
i.- Parameters:
i – [in] Zero-based lane index.
-
inline size_t getNoDirn() const#
Get the number of directions represented (1 or 2).
-
inline size_t getNoLanes() const#
Get the total number of lanes.
-
inline size_t getNoLanesDir1() const#
Get the number of lanes in direction 1.
-
inline size_t getNoLanesDir2() const#
Get the number of lanes in direction 2.
-
virtual void ReadDataIn()#
-
class CLaneFlow#
Stores per-hour traffic data for a single lane: flow rate, speed distribution, and axle-class composition.
CLaneFlow holds one row per hour, each containing the flow rate (veh/h), speed mean and standard deviation, and the car/truck/class percentages. It is populated from the lane-flow CSV file and used internally by the lane-flow parsing pipeline.
See also
See also
Public Functions
-
CLaneFlow(int lane, int dirn)#
Construct for a specific lane and direction.
- Parameters:
lane – [in] Lane index.
dirn – [in] Direction (1 or 2).
-
void setHourData(std::vector<double> vHrData)#
Set one hour’s worth of data from a flattened vector.
The vector layout is: flow, speed mean, speed std, car%, 2-axle%, 3-axle%, 4-axle%, 5-axle%.
- Parameters:
vHrData – [in] Flattened hour data.
-
void setLaneNo(int lane)#
Set the lane index.
-
void setDirn(int dirn)#
Set the direction.
-
int getLaneNo(void) const#
Get the lane index.
-
int getDirn(void) const#
Get the direction.
-
double getFlow(int iHour)#
Get the flow rate for hour
iHour(veh/h).
-
double getSpeedMean(int iHour)#
Get the mean speed for hour
iHour(m/s).
-
double getSpeedStDev(int iHour)#
Get the speed standard deviation for hour
iHour(m/s).
-
double getCP_cars(int iHour)#
Get the car percentage for hour
iHour.
-
double getCP_2Axle(int iHour)#
Get the 2-axle truck percentage for hour
iHour.
-
double getCP_3Axle(int iHour)#
Get the 3-axle truck percentage for hour
iHour.
-
double getCP_4Axle(int iHour)#
Get the 4-axle truck percentage for hour
iHour.
-
double getCP_5Axle(int iHour)#
Get the 5-axle truck percentage for hour
iHour.
-
std::vector<double> getCP(int iHour)#
Get all class percentages for hour
iHouras a vector.
Private Functions
-
void Initialize(void)#
Reset to default (24 zero-filled hours).
-
struct CP#
Per-hour axle-class composition percentages.
-
struct HourData#
One hour’s data record.
-
struct Speed#
Per-hour speed distribution (mean, standard deviation).
-
CLaneFlow(int lane, int dirn)#
Bridge and IL file I/O#
-
class CBridgeFile#
Parses the bridge definitions file and constructs fully configured CBridge instances.
CBridgeFile reads the bridge file named in the configuration, creates one CBridge per bridge entry, and wires up the influence lines or surfaces for each load effect on each lane. The result is a vector of ready-to-simulate bridge shared pointers, retrieved via getBridges().
See also
See also
Public Functions
-
CBridgeFile(CConfigDataCore &config, std::vector<CInfluenceLine> vDiscreteIL, std::vector<CInfluenceLine> vInfSurf)#
Construct with a configuration and the pre-loaded discrete influence lines and surfaces.
- Parameters:
config – [in] Shared configuration block.
vDiscreteIL – [in] Discrete influence lines loaded from the IL file.
vInfSurf – [in] Influence surfaces loaded from the IS file.
-
void ReadBridges(std::string file, std::vector<CInfluenceLine> vDiscreteIL, std::vector<CInfluenceLine> vInfSurf)#
Parse the bridge definitions file.
- Parameters:
file – [in] Path to the bridge definitions file.
vDiscreteIL – [in] Discrete influence lines.
vInfSurf – [in] Influence surfaces.
-
std::vector<CBridge_sp> getBridges(void)#
Get the fully configured bridge instances.
-
double getMaxBridgeLength(void)#
Get the longest bridge length across all parsed bridges, in metres.
Private Functions
-
double ReadLoadEffect(CBridge_sp pBridge, std::vector<CInfluenceLine> vDiscreteIL, std::vector<CInfluenceLine> vInfSurf)#
Read one load-effect block for a single bridge.
-
int GetNextDataLine(std::string &str)#
Read the next non-comment, non-empty line from the bridge file.
-
CBridgeFile(CConfigDataCore &config, std::vector<CInfluenceLine> vDiscreteIL, std::vector<CInfluenceLine> vInfSurf)#
-
class CReadILFile#
Reads influence line and influence surface files and produces configured CInfluenceLine instances.
CReadILFile parses two kinds of input:
Influence line files (via ReadILFile()): a text file listing discrete (distance, ordinate) tables for one or more influence lines.
Influence surface files (via ReadInfSurfFile()): a CSV file containing a 2D ordinate grid for one or more influence surfaces, which are wrapped in CInfluenceLine objects with type 3.
The parsed influence lines are retrieved via getInfLines() and passed to CBridgeFile, which wires them onto the lanes of each bridge.
See also
See also
See also
Public Functions
-
CReadILFile(std::filesystem::path file)#
Construct and immediately parse a file.
- Parameters:
file – [in] Path to the influence line/surface file.
-
CReadILFile(std::filesystem::path file, unsigned int mode)#
Construct with a file and an interpretation mode.
- Parameters:
file – [in] Path to the file.
mode – [in] 0 = influence line file, 1 = influence surface CSV.
-
void ReadILFile(std::string file)#
Parse a text-format influence line file.
- Parameters:
file – [in] Path to the file.
-
void ReadInfSurfFile(std::string file)#
Parse a CSV-format influence surface file.
- Parameters:
file – [in] Path to the file.
-
std::vector<CInfluenceLine> getInfLines()#
Get the parsed influence lines.
-
std::vector<CInfluenceLine> getInfLines(std::filesystem::path file, unsigned int mode)#
Parse a file and return the influence lines directly.
- Parameters:
file – [in] Path to the file.
mode – [in] 0 = influence line, 1 = surface.
-
int getNoInfLines(void)#
Get the number of influence lines parsed.
-
class CInfluenceSurface#
A two-dimensional influence surface used to compute load effects that depend on both longitudinal position and transverse wheel placement.
CInfluenceSurface stores a regular grid of ordinates indexed by longitudinal (x) and transverse (y) coordinates. The ordinate at an arbitrary (x, y) is obtained by bilinear interpolation over the grid.
Used when CInfluenceLine is in type-3 (surface) mode: each axle’s load effect is computed by looking up the ordinate at both wheel paths (±TrackWidth/2 from the axle centreline) and averaging.
See also
Public Functions
-
CInfluenceSurface(std::vector<std::vector<double>> ISmat, std::vector<double> ylanes)#
Construct with a grid of ordinates and per-lane y-coordinates.
- Parameters:
ISmat – [in] Row-major ordinate grid (rows = x stations, cols = y stations).
ylanes – [in] Y-coordinates of lane centre-lines.
-
double giveOrdinate(double x, double laneEccentricity, std::size_t iLane)#
Get the ordinate at position (x, y) for a given lane.
- Parameters:
x – [in] Longitudinal position in metres.
laneEccentricity – [in] Transverse offset from the lane centreline in metres.
iLane – [in] Zero-based lane index.
- Returns:
Interpolated ordinate.
-
void setIS(std::vector<std::vector<double>> ISmat)#
Set the ordinate grid from a row-major matrix.
-
void setLanes(std::vector<double> ylanes)#
Set lane y-coordinates from a flat vector.
-
void setLanes(std::vector<std::pair<double, double>> ylanes)#
Set lane y-coordinates from (ymin, ymax) pairs.
-
double getLength()#
Get the longitudinal length of the surface in metres.
-
double getLaneWidth(std::size_t iLane)#
Get the lane width for lane
iLane, in metres.- Parameters:
iLane – [in] Zero-based lane index.
Private Members
-
std::vector<std::vector<double>> m_ISords#
Row-major ordinate grid.
-
std::vector<double> m_X#
Longitudinal station coordinates in metres.
-
std::vector<double> m_Y#
Transverse station coordinates in metres.
-
std::vector<std::pair<double, double>> m_Ylanes#
Per-lane (ymin, ymax) pairs.
-
double m_Xmax#
Longitudinal extents.
-
double m_Ymax#
Transverse extents.
-
double m_Length#
Surface length in metres.
-
std::size_t m_NoX#
Number of longitudinal stations.
-
std::size_t m_NoY#
Number of transverse stations.
-
std::size_t m_NoLanes#
Number of lanes on the surface.
-
CInfluenceSurface(std::vector<std::vector<double>> ISmat, std::vector<double> ylanes)#
Vehicle classification#
-
class CVehicleClassification#
Abstract base for vehicle classification schemes.
CVehicleClassification maintains a list of known classes and exposes a pure-virtual setClassification() that concrete subclasses override to tag each vehicle with the appropriate class based on its properties.
Two schemes are provided:
CVehClassAxle — classifies by number of axles (2/3/4/5).
CVehClassPattern — classifies by axle-spacing pattern.
See also
Subclassed by CVehClassAxle, CVehClassPattern
Public Functions
-
virtual void setClassification(CVehicle_sp pVeh) = 0#
Tag
pVehwith a class from this scheme.
-
inline size_t getNoClasses()#
Get the total number of known classes.
-
Classification getClass(size_t i)#
Get the i-th class.
- Parameters:
i – [in] Zero-based class index.
-
size_t getClassID(Classification cl)#
Look up the numeric ID for a classification label.
-
class CVehClassAxle : public CVehicleClassification#
Classifies vehicles by number of axles (2, 3, 4, or 5).
Public Functions
-
virtual void setClassification(CVehicle_sp pVeh) override#
Tag
pVehby its axle count.
-
virtual void setClassification(CVehicle_sp pVeh) override#
-
class CVehClassPattern : public CVehicleClassification#
Classifies vehicles by their axle-spacing pattern string.
Public Functions
-
virtual void setClassification(CVehicle_sp pVeh) override#
Tag
pVehby its derived spacing-pattern string.
Private Functions
-
std::string getPattern(CVehicle_sp pVeh)#
Derive the pattern string for
pVehfrom its axle spacings.
-
virtual void setClassification(CVehicle_sp pVeh) override#
Utilities#
-
class CCSVParse#
General-purpose CSV file reader with configurable separator.
CCSVParse reads a CSV file line by line, splits each line into fields using a configurable separator, and exposes the fields by index. It is used internally by CConfigDataCore, CModelData subclasses, CBridgeFile, and CReadILFile for all structured-text parsing.
Usage: call OpenFile() to attach to a file and set the separator, then call getline() in a loop. After each getline(), getfield() returns individual fields. GetVectorFromNextLine() and GetVectorFromCurrentLine() are helpers that parse an entire line of numeric fields into a double vector.
Public Functions
-
void CloseFile()#
Close the currently open file, if any.
-
bool OpenFile(std::string inFile, std::string sep)#
Open a file for parsing.
- Parameters:
inFile – [in] Path to the file.
sep – [in] Field separator (e.g. “,” or “\t”).
- Returns:
True on success.
-
int getline(std::string&)#
Read the next line from the file and split it into fields.
- Parameters:
s – [out] The raw line text (before splitting).
- Returns:
Number of fields, or
-1at EOF.
-
std::string getfield(size_t n)#
Get the n-th field from the most recently read line.
- Parameters:
n – [in] Zero-based field index.
- Returns:
Field text, or empty string if out of range.
-
inline size_t getnfield() const#
Get the number of fields in the most recently read line.
-
std::vector<double> GetVectorFromNextLine()#
Read the next line and parse all fields as doubles.
-
std::vector<double> GetVectorFromCurrentLine()#
Parse all fields of the current (already-read) line as doubles.
-
double stringToDouble(std::string line)#
Parse a string as a double.
-
int stringToInt(std::string line)#
Parse a string as an int.
-
bool stringToBool(std::string line)#
Parse a string as a bool (“0” / “1” or “false” / “true”).
Private Functions
-
size_t split()#
Split
lineintofieldusingfieldsep.
-
int endofline(char)#
Return true if the character is an end-of-line marker.
-
size_t advplain(const std::string &line, std::string &fld, size_t)#
Advance past a plain (unquoted) field.
-
size_t advquoted(const std::string &line, std::string &fld, size_t)#
Advance past a quoted field (handles embedded quotes).
-
void CloseFile()#
-
class CClassPercent#
Per-lane truck-class composition table.
CClassPercent holds, for each lane, the fractional composition of the truck stream by axle count: 2-axle, 3-axle, 4-axle, and 5-axle. The composition is used by the traffic generators to decide how many trucks of each axle class to sample on each lane.
See also
See also
Public Functions
-
int GetNoLanes()#
Get the number of lanes this table covers.
-
double GetClassPercent(int iLane, int iClass)#
Get the percentage of trucks in axle class
iClasson laneiLane.- Parameters:
iLane – [in] Zero-based lane index.
iClass – [in] Axle class (0 = 2-axle, 1 = 3-axle, 2 = 4-axle, 3 = 5-axle).
-
void AddClassPercent(int iLane, int iClass, double val)#
Set the percentage for one (lane, class) cell.
- Parameters:
iLane – [in] Zero-based lane index.
iClass – [in] Axle class (0..3).
val – [in] Fractional percentage (0..1).
Private Members
-
int m_NoLanes#
Number of lanes in the table.
-
struct CP#
Class-percentage row for one lane.
-
int GetNoLanes()#
-
template<class T>
class CMatrix# Simple 3-dimensional dynamic array with zero-based indexing.
CMatrix wraps a nested
std::vectoras a three-dimensional container with operator() access. Used internally for multi-dimensional data tables in the model-data and event layers. The template parameter T should be a numeric type.- Template Parameters:
T – Element type (must be default-constructible and assignable).
Public Functions
-
int dim(int a)#
Get the size of dimension
a(1, 2, or 3).
-
CMatrix(int a, int b, int c)#
Construct with specified dimensions.
- Parameters:
a – [in] Size of dimension 1.
b – [in] Size of dimension 2.
c – [in] Size of dimension 3.
-
CMatrix()#
Default-construct an empty matrix.
-
inline bool checkBounds(int a, int b, int c)#
Return true if (a, b, c) is within bounds.
-
void add(int a, int b, int c)#
Grow the matrix to accommodate index (a, b, c).
-
void init(int a, int b, int c)#
Allocate storage for dimensions (a, b, c) and zero-fill.
-
void clear()#
Clear all elements.
Standalone BTLS entry point#
The following free functions form the standalone BTLS binary’s
orchestration layer (compiled only with the Binary CMake option).
The PyBTLS Python layer reimplements the same orchestration in
simulation.py.
-
void run(std::string inFile)#
Main entry point for the standalone BTLS binary.
Parses the BTLSin configuration file, sets up bridges and lanes, runs the simulation, and prints a summary. Called from main() in
main.cpp.- Parameters:
inFile – [in] Path to the BTLSin.txt file.
-
void doSimulation(CVehicleClassification_sp pVC, std::vector<CBridge_sp> pBridges, std::vector<CLane_sp> pLanes, double SimStartTime, double SimEndTime)#
Run the core time-stepping simulation.
Pulls vehicles from lanes, places them on bridges, advances the bridges via CBridge::Update, and records events until the simulation end time is reached.
- Parameters:
pVC – [in] Vehicle classifier.
pBridges – [in] Bridges to simulate.
pLanes – [in] Traffic-lane streams.
SimStartTime – [in] Simulation start time in seconds.
SimEndTime – [in] Simulation end time in seconds.
-
std::vector<CBridge_sp> PrepareBridges()#
Read influence line/surface files and construct the bridge objects.
-
void preamble()#
Print the BTLS version and copyright preamble.