22. Process Oriented Simulation, take 1

Part of CS:2820 Object Oriented Software Development Notes, Fall 2015
by Douglas W. Jones
THE UNIVERSITY OF IOWA Department of Computer Science

 

Abstract Processes in Simulation

Another approach to simulation that is not universally applicable is to view the simulation as a set of interacting logical processes. This is not a universal view, but we can view some models in these terms. Specifically, of our two example simulation problems we have been working with this semester, the road network simulation problem can be easily converted to a process-centered model, while the other cannot.

In a road network, each vehicle can be viewed as a separate process that has a continuous identity. From a logical perspecive, a vehicle follows the following top-level algorithm:

new vehicle();
Intersection i = the creating intersection:
repeat
	wait for i.travelTime;
        Road r = pickRoad();
	Intersection.Exit();
	r.Enter();
	wait for r.travelTime;
        r.Exit();
	Intersection.Enter();
until Intersection is in class sink
crush vehicle();

The above is obviously not an executable algorithm, but it allows us to think about a vehicle-centered view of simulation, where intersections and roads are passive components of the model.

We will continue to think in event-centered terms, and we will revert back to the lambda-expression event scheduling framework, but now, our simulation model will focus on vehicles. Events in our new model will happen primarily to vehicles, the primary actors in our simulation model.

There will still be some events that apply to intersections. For example, source intersections must have a logical process to decide when to create vehicles, and intersections that have queueing disciplines must pick which vehicle is dequeued. This gets most complex when we introduce stoplights, where we might imagine the following as an outline of the operation of an intersection process:

repeat
	allow east-west travel;
        wait for light delay time;
	stop east-west travel;
	allow north-south travel;
        wait for light delay time;
	stop north-south travel;
forever

The above process outline is for a stoplight that allows equal service to each travel direction. Stoplights for secondary road intersections can allow longer green lights to the main road and shorter green lights to the secondary road. Stoplights can also incorporate vehicle sensors so that the light changes quickly to service vehicles waiting at a red light if either there is no traffic on the currently green-light path or if the wait on the red side has been long.

Class Vehicle

We can make this change to our road-network simulator using either the lambda-expression based simulation framework or the class-hierarchy-based simulation framework. In this case, let's start with the latter as we begin to think about how to re-engineer class Vehicle.

More to come