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_demands(demands, celldata)
function new_demands = adjust_or_demands(demands, celldata)
% ADJUST_OR_DEMANDS - multiplies demand by on-ramp demand coefficient.
%
% Call:   new_demands = adjust_or_demands(demands, celldata)
%
% Parameters:
%             demands  - vector of on-ramp demands;
%             celldata - array of freeway cell structures, whose length must be
%                        the same as size of 'demands'.
%
% Returns:   new_demands - adjusted demand vector.
%
% Last modified:   09/29/2006.

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

M = size(demands, 1);
N = size(celldata, 2);

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

new_demands = [];

for i = 1:N
  if isempty(celldata(i).ORname)
    d = 0;
  else
    d = max([0 (celldata(i).ORknob * demands(i, 1))]);
  end

  new_demands = [new_demands; d];
end

return;

Contact us at files@mathworks.com