A Simple Discrete-Event Simulation: Part 75

Today I expanded the capability of the Bag component to allow entities to reside there, spawn new sub-entities that undergo an external process of their own, and return to the “parked” entity. Delay times can be specified that control how long it takes the spawned sub-entity to start moving once the main entity parks, and how long it takes the before main entity transfers to the exit queue once the sub-entity returns. Think of the delays like this. You drive into a parking lot and park. Then you gather up your belongings, paperwork, and do whatever else you might have to before walking in to your next activity. The activity has its own duration, at which point you walk back to your parked car. Then you put all your stuff back in the car, get settled as you need to, and you finally drive out of the parking lot. The spawned entity is, in our example, colored orange. When it is waiting at the main entity within the Bag component is is displayed on top of the main entity that spawned it, a handful of pixels up and to the right.

The value for the Bag component’s process time has no meaning in this case, though perhaps it should double as one or both of the delay times.

Two new components were created to serve as the internal “entry” into the sub-process and “exit” back out of the sub-process. They have as little of the machinery common to the other component types as possible. When entities are forwarded to them they are immediately forwarded to their next component. The source component can only connect to a single, downstream component, but multiple upstream components can be connected to the destination component.

The external system can be made up of any types of components (except Entry or Exit components) but I’ve included only two paths so I didn’t have to think about reporting on top of everything else I did today. That will be tomorrow’s project. The process of traversing an external system is referred to as a “sub-journey” and the new components and processes are named accordingly.

Here’s the updated code for the Bag component:

Here are the new source and destination components:

Here’s the code that defines the entire system:

Some adjustments had to be made to the DisplayElement object as well, to handle drawing the 2D and 3D versions of the new components.

I also made the background transparent so it’ll look a bit nicer in an iframe and need to do something more explicit with the 3D versions of the sub-entities.

This entry was posted in Simulation and tagged . Bookmark the permalink.

Leave a Reply