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

controller_q_override(demands, orflows, orqueues, celldata, ts, idx)
function new_orflows = controller_q_override(demands, orflows, orqueues, celldata, ts, idx)
% CONTROLLER_Q_OVERRIDE - implementation of Queue Override Queue Controller.
%
% Call:   new_orflows = controller_q_override(demands, orflows, orqueues, celldata, ts, idx)
%
% Parameters:
%             demands  - vector of on-ramp demands; 
%             orflows  - vector of on-ramp flows generated by ML controller,
%                        same size as 'demands';
%             orqueues - vector of current on-ramp queue sizes, same size as 'demands';
%             celldata - array of freeway cell data structures, whose length
%                        must be the same as size of 'demands';
%             ts       - sampling period;
%             idx      - index of the cell with given on-ramp.
%
% Returns:   new_orflows - vector of proposed on-ramp flows.
%
% Last modified:   10/06/2006.

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

K = size(demands, 1);
L = size(orflows, 1);
M = size(orqueues, 1);
N = size(celldata, 2);

if K ~= N
  error('CONTROLLER_Q_OVERRIDE: number of on-ramp demands does not match number of cells.');
end

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

if M ~= N
  error('CONTROLLER_Q_OVERRIDE: number of on-ramp queues does not match number of cells.');
end

if (idx < 1) | (idx > N)
  error('CONTROLLER_Q_OVERRIDE: invalid cell index.');
end

new_orflows = orflows;

if orqueues(idx, 1) > celldata(idx).ORqsize
  df                  = celldata(idx).ORqcontroller.delta * celldata(idx).ORlanes;
  new_orflows(idx, 1) = celldata(idx).ORflow + df;
end

return;

Contact us at files@mathworks.com