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_swarm(densities, flows, celldata, ts, idx)
function new_flows = controller_swarm(densities, flows, celldata, ts, idx)
% CONTROLLER_SWARM - combination of SWARM1 and SWARM2B controllers,
%                    most restrictive is chosen.
%
% Call:   new_flows = controller_swarm(densities, flows, celldata, ts, idx)
%
% Parameters:
%             densities - vector of densities;
%             flows     - vector of on-ramp flows, same size as 'densities';
%             celldata  - array of freeway cell structures, whose length
%                         must be the same as size of 'densities';
%             ts        - sampling period;
%             idx       - index of the cell with our on-ramp.
%
% Returns:   new_flows - updated vector of on-ramp flows.
%
% REMARK: currently, we only do 1 time step forecast.
%
% Last modified:   11/10/2006.

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

f1                = controller_swarm1(densities, flows, celldata, ts, idx);
f2                = controller_swarm2b(densities, flows, celldata, ts, idx);

new_flows         = flows;
new_flows(idx, 1) = min([f1(idx, 1) f2(idx, 1)]);  % update flow vector

return;

Contact us at files@mathworks.com