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_2(density, orflow, flow, frflow, celldata, outflow, ts)
function rbflow = get_rbflow_2(density, orflow, flow, frflow, celldata, outflow, ts)
% GET_RBFLOW_2 - compute flow leaving given freeway cell using off-ramp flow.
%
% Call:   rbflow = get_rbflow_2(density, flow, frflow, celldata, outflow)
%
% Parameters:
%             density  - densitiy in the cell;
%             flow     - flow entering the cell;
%             orflow   - on-ramp flow into the cell;
%             frflow   - off-ramp flow;
%             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

mlflow = max([0 min([((v/l)*(n+r) - frflow) outflow])]);

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

return;

Contact us at files@mathworks.com