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

ctmsim(cfg_file, btch)
function ctmsim(cfg_file, btch)
% CTMSIM - starts CTM simulation application.
%
% Call:
%       ctmsim
%       ctmsim cfg_file
%       ctmsim cfg_file 1
%
% Parameters:
%             cfg_file - .mat configuration file that contains freeway cell data
%                         and, possibly, other CTM simulation parameters.
%                         This argument is optional, default config file is 'ctm.mat'.
%             1        - indicates that CTMSIM should work in the batch mode.
%                        This argument is optional.
%
% Returns:   none.
%
%
% Config file must contain 'celldata' variable - it is an array of freeway
% data structures with the following fields:
%    cell.PMstart         double (>= 0)            post mile at cell start;
%    cell.PMend           double (>= 0)            post mile at cell end;
%         Remark: if PMstart <= PMend, the flow goes from left to right,
%                 otherwise - from right to left;
%    cell.lanes           double (>= 0)            number of lanes;
%         Remark: number of lanes may be fractional - auxiliary lanes often
%                 are not counted as full lanes;
%    cell.FDfmax          double (>= 0)            maximal flow (vph);
%    cell.FDrhocrit       double (>= 0)            critical density (vpm);
%    cell.FDrhojam        double (>= FDrhocrit)    jam density (vpm);
%         Remark: all three fundamental diagram parameters are considered
%                 to be total and NOT(!) per lane;
%    cell.ORname          char                     on-ramp name;
%         Remark: if the cell has no on-ramp, then ORname = [];
%    cell.ORlanes         double (>= 0)            number of on-ramp lanes;
%    cell.ORflow          double (>= 0)            on-ramp flow (vph);
%    cell.ORfmax          double (>= 0)            on-ramp capacity (vph);
%         Remark: considered to be total and NOT (!) per lane;
%    cell.ORqsize         double (>= 0)            maximum on-ramp queue size;
%    cell.ORgamma         double (>= 0 and <= 1)   on-ramp flow blending coefficient (default = 1);
%    cell.ORxi            double (>= 0 and <= 1)   on-ramp flow allocation parameter (default = 1);
%    cell.ORknob          double (>= 0)            coefficient that adjusts on-ramp demand;
%    cell.ORmlcontroller  struct                   on-ramp main line controller structure;
%    cell.ORqcontroller   struct                   on-ramp queue controller structure;
%    cell.FRname          char                     off-ramp name;
%         Remark: if the cell has no off-ramp, then FRname = [];
%    cell.FRlanes         double (>= 0)            number of off-ramp lanes;
%    cell.FRbeta          double (>= 0 and <= 1)   off-ramp split ratio;
%    cell.FRfmax          double (>= 0)            off-ramp capacity (vph);
%         Remark: considered to be total and NOT (!) per lane.
%    cell.FRknob          double (>= 0)            coefficient that adjusts off-ramp flow;
%
% Config file may contain other (optional) variables:
% freeway           char                     string that contains freeway name;
% TS                double (>= 0)            sampling period, must be no greater than
%                                            min[(cell length)/(free-flow speed)];
% plotTS            double (>= 0)            how often the plots should refresh,
%                                            between two plots;
%                                            must be greater or equal than TS;
% initiaDensities   double (>= 0)            vector of initial densities, must be
%                                            of the same size as number of cells;
% inflow            double (>= 0)            flow that enters given freeway
%                                            section (vph);
% outflow           double (>= 0)            flow that is allowed to leave given
%                                            freeway section (vph);
% ifKnob            double (>= 0)            coefficient that adjusts mainline demand;
% ofKnob            double (>= 0)            coefficient that adjusts capacity downstream of the last cell;
% timeout           double (>= 0)            how many seconds to wait between
%                                            two plots;
% taxislim          double (>= 0)            limit for time axis in time series plots
%                                            measured in plotted time steps;
% densityCMF        double (1024 x 3)        color map for time series density contour;
% flowCMF           double (1024 x 3)        color map for time series flow contour;
% orflowCMF         double (1024 x 3)        color map for time series on-ramp flow contour;
% orqueueCMF        double (1024 x 3)        color map for time series on-ramp queue contour;
% frflowCMF         double (1024 x 3)        color map for time series off-ramp flow contour;
% frbetaCMF         double (1024 x 3)        color map for time series off-ramp split ratio contour;
% speedCMF          double (1024 x 3)        color map for time series speed contour;
% vhtCMF            double (1024 x 3)        color map for time series VHT contour;
% vmtCMF            double (1024 x 3)        color map for time series VMT contour;
%    Remark: for information on default color maps, type 'help graph3d';
% yoColorRatio      double (>= 0 and <= 1)   array of two numbers that indicate
%                                            fractions of maximum flow the flow must
%                                            achieve in free flow or congested mode
%                                            to make cell color yellow or orange;
% demandProfile     double (>= 0)            array of on-ramp demand values whose size is
%                                            (number of cells + 2) x (number of time samples);
% demandTS          double (>= 0)            sampling time for the demand in demandProfile,
%                                            must be greater or equal than TS;
% betaProfile       double (>= 0 and <= 1)   array of off-ramp split ratios whose size is
%                                            (number of cells) x (number of time samples);
% betaTS            double (>= 0)            sampling time for the split ratio in betaProfile,
%                                            must be greater or equal than TS;
% frflowProfile     double (>= 0 and <= 1)   array of off-ramp flow values whose size is
%                                            (number of cells) x (number of time samples);
% frflowTS          double (>= 0)            sampling time for the flow in frflowProfile,
%                                            must be greater or equal than TS;
% maxSimStep        double (>= 0)            maximum simulation step;
% maxSimTime        double (>= 0)            maximum simulation time:
%                                               number_of_steps * TS;
% dataFile          char                     string with a file name where the
%                                            simulation data is to be saved;
%    Remark: last three parameters make difference only in the batch mode.
% 
%
% See also:   FWCONFIG, PLOTSIM.
%
% Last modified:   03/18/2007.

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

global g_ctmGUI;

if nargin & isa(cfg_file, 'char')
  g_ctmGUI.configFile = cfg_file;
end

if nargin < 2
  ctmGUI;
else
  ctmBATCH;
end

return;

Contact us at files@mathworks.com