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_prodloss(densities, flows, celldata)
function pls = compute_prodloss(densities, flows, celldata)
% COMPUTE_PRODLOSS - computes and returns Productivity Loss based on densities,
%                    flows, and fundamental diagrams.
%
% Call:   pls = compute_prodloss(densities, flows, celldata)
%
% Parameters:
%             densities - vector of densities;
%             flows     - vector of flows, same size as 'densities';
%             celldata  - array of freeway cell structures, whose length
%                         must be the same as size of 'densities'.
%
% Returns:   pls - vector of Productivity Loss values.
%
% Last modified:   11/03/2006.

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

L = size(densities, 1);
M = size(flows, 1);
N = size(celldata, 2);

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

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

pls = [];

for i = 1:N
  l = abs(celldata(i).PMend - celldata(i).PMstart);  % i-th cell length

  if densities(i, 1) > celldata(i).FDrhocrit
    p = l * (1 - (flows(i, 1)/celldata(i).FDfmax));
  else
    p = 0;
  end

  pls = [pls; p];
end

return;

Contact us at files@mathworks.com