Code covered by the BSD License  

Highlights from
CTMSIM - an interactive freeway traffic macrosimulator

image thumbnail
from CTMSIM - an interactive freeway traffic macrosimulator by Alex Kurzhanskiy
Freeway traffic simulation based on Asymmetric Cell Transmission Model

get_rbflow(density, orflow, flow, celldata, outflow, ts)
function rbflow = get_rbflow(density, orflow, flow, celldata, outflow, ts)
% GET_RBFLOW - compute flow leaving given freeway cell.
%
% Call:   rbflow = get_rbflow(density, orflow, flow, celldata, outflow)
%
% Parameters:
%             density  - densitiy in the cell;
%             orflow   - on-ramp flow into the cell;
%             flow     - flow entering the cell;
%             celldata - cell data structure;
%             outflow  - how much can be allowed through the right boundary;
%             ts       - sampling period.
%
% Returns:   rbflow - flow leaving the cell through the right boundary.
%
% Last modified:   02/24/2008.

%
% Alex Kurzhanskiy   <akurzhan@eecs.berkeley.edu>
%

l = abs(celldata.PMend - celldata.PMstart);  % cell length
v = celldata.FDfmax / celldata.FDrhocrit;  % free-flow speed
n = density * l;  % number of vehicles in the cell
r = celldata.ORgamma * orflow * ts;  % number of vehicles from on-ramp
b = celldata.FRbeta;  % split ratio for the off-ramp in the cell

mlflow = min([((1-b)*(v/l)*(n+r)) outflow]);

if b < 1
  frflow = (b/(1-b)) * mlflow;
else
  frflow = (v/l) * (n + r);
end

frflow = min([frflow celldata.FRfmax]);

% consistency check: mlflow cannot exceed ((1-b)/b) * frflow
if b > 0
  mlflow = ((1-b)/b) * frflow;
end

rbflow = mlflow + frflow;  % main line flow + off-ramp flow

return;

Contact us at files@mathworks.com