A.	GPSS tabulates a lot of statistics for us in the listing file.
	We can use this to our advantage when we want some specific
	statistic.
	E.g.
		Parts are put on the start of a conveyor belt at the
		rate of one every 8+/-4 seconds.  They travel for 5
		seconds to an inspection station with two
		inspectors.  The first available inspector takes
		12 +/- 2 seconds to examine the part.  If neither
		inspector is available, the part drops onto another
		conveyor belt and is returned to the start of the
		first conveyor belt to go through the inspection
		station again.  The return trip takes 8 seconds.
		20% of all inspected parts are found
		to be defective and are tossed in the recycle
		container by the inspector.  The remainder are put on
		a third conveyor belt which takes 5 seconds to
		transport the part to the next part of the factory.
		Any part not examined drops onto another conveyor belt
		which returns the part to the start of the first
		conveyor belt.  Simulate for 500 parts going through
		the system.

		What is the average time a part spends in the system?


	SIMULATE

	GENERATE	8,4,,500
*	QUEUE		STATION
 CONV1	ADVANCE		5
	TRANSFER	BOTH,,CHK2
 CHK1	SEIZE		INSP1
 	ADVANCE		12,2
	RELEASE		INSP1
	TRANSFER	.2,CONV2,RECYC

 CHK2	TRANSFER	BOTH,,CONV3
	SEIZE		INSP2
	ADVANCE		12,2
	RELEASE		INSP2
	TRANSFER	.2,CONV2,RECYC

 CONV3	ADVANCE		8
	TRANSFER	,CONV1

 CONV2	ADVANCE		5
*RECYC	DEPART		STATION
	TERMINATE	1

	START		500
	END


B.	Cars leave a factory parking lot every 10+/-5 seconds and
	turn south onto Elm St and, after traveling for 20+/-5 seconds,
	they reach a T-intersection.  40% turn left and the rest turn
	right. After 40+/-30 seconds, 30% of the cars who turned left
	then turn right onto Oak St, while the rest carry on to an
	eastbound freeway.  After traveling on Oak for 20+-10 seconds
	these cars pass an intersection with Maple St and enter an
	on-ramp for a southbound freeway.  After 30+/-10 seconds, 15%
	of the cars that turned right off Elm St then turn left onto
	Maple St, while the remainder carry on to a westbound freeway.
	Cars on Maple take 60+-20 seconds to reach the intersection
	with Oak St, where they turn right and enter the on-ramp for the
	southbound freeway.  Cars spend 10+-5 seconds on the on-ramp
	before entering the southbound freeway.
	
	1) Model the system for 1000 cars entering the southbound freeway
		SIMULATE
	*RESULT	TABLE		M1,40,10,14

		GENERATE	10,5,,,
	 ELM	ADVANCE		20,5
		TRANSFER	.4,,LEFT
	 RIGHT	ADVANCE		30,10
		TRANSFER	.3,,MAPLE
	 WEST	TERMINATE

	 LEFT	ADVANCE		40,30
		TRANSFER	.3,,OAK
	 EAST	TERMINATE

	 MAPLE	ADVANCE		60,20
		TRANSFER	,ONRAMP

	 OAK	ADVANCE		20,10
	 ONRAMP ADVANCE		10,5
	*	TABULATE	RESULT
		TERMINATE	1

		START		1000
		END

	2) Tabulate how many cars take 40, 50, 60, ..., 160 seconds to
	   make it from the lot to the southbound freeway

	minimum time:
		15+10+10+5=45 seconds
	maximum time:
		25+40+80+15=160 seconds

	Want a table from 40 to 160 inclusive in intervals of 10
	seconds.
	
	add
		RESULT	TABLE		M1,40,10,14
	and
			TABULATE	RESULT

C.	Alternative interarrival distributions

	Parts arrive at an inspection station every 4+/-2 seconds
	and are queued for inspection by one of three inspectors.
	Inspection takes 12+/-2 seconds.  Model for 500 parts
	being inspected.

	Uniform distribution: Parts arrive every 4+/-2 seconds:


	SIMULATE
 INSP	STORAGE		3

	GENERATE	4,2,,,
	QUEUE		INSPQ
	ENTER		INSP
	DEPART		INSPQ
	ADVANCE		12,2
	LEAVE		INSP
	TERMINATE	1

	START		500
	END

	Nonuniform: Parts arrive with the following distribution:
		prob.	time		cumulative prob.
		------+-------------+--------------------
		05%	2 seconds	 .05
		10%	3 seconds	 .15
		40%	4 seconds	 .55
		30%	5 seconds	 .85
		15%	6 seconds	1.00


	How can we model this?

	ARRT	FUNCTION	RN1,D5
	.05,2/.15,3/.55,4/.85,5/1.0,6


	GENERATE	FN$ARRT,,,,

- - - - - - - - - MODEL - - - - - - - -

	SIMULATE
 INSP	STORAGE		3
 ARRT	FUNCTION	RN1,D5
 .05,2/.15,3/.55,4/.85,5/1.0,6


	GENERATE	FN$ARRT,,,,
	QUEUE		INSPQ
	ENTER		INSP
	DEPART		INSPQ
	ADVANCE		12,2
	LEAVE		INSP
	TERMINATE	1

	START		500
	END

