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

compute_fr_split_ratios(densities, flows, frflows, celldata, outflow, ts)
function betas = compute_fr_split_ratios(densities, flows, frflows, celldata, outflow, ts)
% COMPUTE_FR_SPLIT_RATIOS - compute off-ramp split ratios from the vector of flows
%                    and off-ramp flows.
%
% Call:   frf = compute_fr_split_ratios(densities, flows, celldata, outflow, ts)
%
% Parameters:
%             densities - vector of densities;
%             flows     - vector of flows, must have the same size as 'densities';
%             frflows   - vector of off-ramp flows, must have the same size as 'densities';
%             celldata - array of freeway cell data structures, whose length
%                        must be the same as the size of 'flows' vector;
%             outflow  - how much can be allowed through the right boundary;
%             ts       - sampling period.
%
%
% Returns:   betas - array of off-ramp split ratios.
%
% Last modified:   10/06/2006.

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

K = size(densities, 1);
L = size(flows, 1);
M = size(frflows, 1);
N = size(celldata, 2);  % number of cells

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

if L ~= N
  error('COMPUTE_FR_SPLIT_RATIOS: number of flows does not match number of cells.');
end

if M ~= N
  error('COMPUTE_FR_SPLIT_RATIOS: number of off-ramp flows does not match number of cells.');
end

betas = [];

for i = 1:N
  if i == N
    b = frflows(N, 1) / get_rbflow_2(densities(N, 1), flows(N, 1), frflows(N, 1), celldata(N), outflow, ts);
  else
    b = frflows(i, 1) / (flows(i+1, 1) + frflows(i, 1));
  end

  betas = [betas; b];
end

return;

Contact us at files@mathworks.com