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

adjust_or_flow_limits(densities, celldata, ts)
function flows = adjust_or_flow_limits(densities, celldata, ts)
% ADJUST_OR_FLOW_LIMITS - set maximum possible values for on-ramp flows.
%
% Call:   flows = adjust_or_data(densities, celldata, ts)
%
% Parameters:
%             densities - vector of densities;
%             celldata  - array of freeway cell structures whose length must be
%                         the same as size of 'densities';
%             ts        - sampling period.
%
% Returns:   flows - vector of adjusted on-ramp flows;
%
% Last modified:   09/17/2006.

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

K = size(densities, 1);
N = size(celldata, 2);

if K ~= N
  error('ADJUST_OR_FLOW_LIMITS: number of densities does not match number of cells.');
end

flows = [];

for i = 1:N
  % cell length
  l     = abs(celldata(i).PMend - celldata(i).PMstart);
  % available main line capacity
  dn    = celldata(i).ORxi * (celldata(i).FDrhojam - densities(i, 1)) * (l/ts);

  flows = [flows; min([dn celldata(i).ORfmax])];
end

return;

Contact us at files@mathworks.com