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

get_mlc_default(cid)
function ctrl = get_mlc_default(cid)
% GET_MLC_DEFAULT - for the specified on-ramp main line controller,
%                   return corresponding controller structure with default values.
%
% Call:
%       ctrl = get_mlc_default(controller_name)
%       ctrl = get_mlc_default(controller_id)
%
% Parameters:
%             controller_name - name of the controller, e.g. 'alinea';
%             controller_id   - controller index in the controller list.
%
% Returns:   ctrl - controller structure.
% 
% Last modified:   09/09/2006.

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

if isa(cid, 'char')
  name = lower(cid);
elseif isa(cid, 'double')
  name = [];
else
  error('GET_MLC_DEFAULT: invalid input parameter.');
end

load ormlclist;  % ormlclist.mat file must exist - it contains list of controllers

N = size(mlclist, 1);  % number of controllers

if isempty(name)
  if (cid < 2) | (cid > N)
    error('GET_MLC_DEFAULT: invalid controller ID.');
  end
  name = lower(deblank(mlclist(cid, :)));
else
  cid = 0;
  for i = 1:N
    if strcmp(name, lower(deblank(mlclist(i, :))))   
      cid = i;
      break;
    end
  end
end

if cid < 2
  ctrl = [];
else
  ctrl = eval(name);
end

return;

Contact us at files@mathworks.com