% Simulation model of a single server queue
% Adapted from Law and Kelton (1991)
% T.Trani and H. Baik (March 99)

% Initialization function

% Purpose: initializes all queueing counters to zero

% Q_LIMIT				= queue limit to terminate the simulation
% mean_interarrival		= interarrival time in units of time
% mean_service			= service time in time units
% mean_delays_required 	= numbers of entities simulated

% Function calls: 	expon.m (negative exponential distribution)

% Called from:		sim_queue.m (main function)

function init

global Q_LIMIT  mean_interarrival  mean_service mean_delays_required 
global next_event_type num_custs_delayed num_delays_required...
       num_events num_in_q server_status
global area_num_in_q area_server_status mean_interarrival...
       mean_service time time_arrival...
       time_last_event time_next_event total_of_delays std_interarrival

  time=0.0; 				% clock

  server_status=0; 			%idle
  num_in_q=0; 				% initial queue length
  time_last_event=0.0; 

  num_custs_delayed=0;		% initial number of customers
  total_of_delays=0.0;		% initialize total delay counter
  area_num_in_q=0.0;
  area_serve_status=0.0;

  time_next_event(1) = time+expon(mean_interarrival);
  % time_next_event(1) = time+expon(mean_interarrival)
  time_next_event(2) = 1.0*exp(30);
  %disp(['init'])
 
