---
# System prepended metadata

title: Linearity Multi-Car Simulator

---

# Linearity Multi-Car Simulator
This is a simple interactive simulator for experimenting with multi-car linear motor elevators. It is a property of Linearity Co. Ltd., copyrighted in December 2018.

## Usage

After starting the application, the initial screen shows the basic settings: number of shafts, number of elevators in each shaft, and number of floors. Each parameter can be set as required, within the limits of the system:
* Shafts: 1 to 8
* Cages: 1 to 6
* Floors: 8 to 40
* Rate: 1 to 100

The checkboxes control the behavior:

* Fast: the simulation will proceed quickly
* Trav: the travel of the cars will be traced
* Rand: random shaft allocation instead of nearest-cage

![](https://i.imgur.com/Env33ah.png)

Clicking on the START button starts the simulator, showing the main screen.

It is recommended to set the number of floors to an integer multiple of the number of cages, to have equal service zones for each elevator.

![](https://i.imgur.com/1H3Ta2Y.png)

The 3 main parts are:
1. Left: buttons for manipulation
2. Center: passenger display
3. Right: elevator display

### Buttons

* ALL: generate a random passenger and assign randomly to a shaft.
* UP: generate a passenger at the main floor
* STEP: advance the simulation by one elementary step.
* GO: run the simulation until no more passengers remain in the system, or until the button is pressed again. A red indicator dot near to the button shows that the simulator is active.
* RESET: reset the simulator to the initial empty state.
* EXIT: terminate the simulation.

### Passenger pane

Each new passenger is represented by a circle at the origin floor and by a line pointing to the destination floor. The number near to the origin floor indicates the assigned shaft, and the color of the passenger shows the assigned car in that shaft.

When a passenger boards an elevator, the origin floor circle changes color. When the passenger is delivered to the destination floor, the line changes color.

Passengers can be generated by clicking in the passenger pane at the origin floor, and dragging to the destination floor. The passenger will be randomly assigned to a shaft.

### Elevator pane

Elevators in each shaft are represented by colored squares. The lowest spaces are the "garage floors", where elevators can wait.

Passengers can be generated by clicking in one of the shafts at the origin floor, and dragging to the destination floor. The passenger will be assigned to that shaft.

### Travel pane

When started with the "TRAV" checkbox enabled, the travel of the elevators is traced in the right-hand plane.


![](https://i.imgur.com/oFpoxXN.png)


## Limitations

The simulator uses very simple algorithms for control, thus severely limiting its efficiency. Some of the limitations:
* Passengers are assigned to elevators in a shaft according to "service zones". If the number of floors is N and the number of elevators in the shaft is M, each elevator has a service zone of Z=N/M floors. The lowest elevator serves floors 0...(Z-1), the next one Z...(2Z-1), etc. Passengers are assigned by the destination floor for UP travel, and the origin floor for DOWN travel.
* Assignment to shafts is random or user-defined, not by any heuristic or optimal algorithm.
* When an elevator blocks the travel of another one, it is requested to move ahead to free the travel. The blocked elevator starts only when the full path becomes free, not together with the blocking elevator.
* Blocking elevators move only for the shortest needed distance, not anticipating the next request.

## Environment and development

The simulator is written in Common Lisp. It is confirmed to run under Clozure Common Lisp (CCL) on the Mac, and under Steel Bank Common Lisp (SBCL) on the Mac, Ubuntu Linux, and Windows 7.

The GUI uses the Linux Toolkit (LTK), with the Wish graphical interpreter from Tcl/Tk. To run the program, it is necessary to install Tcl/Tk.

The source code consists of the LTK library (ltk.lisp), the main program mce.lisp and the graphics interface mcg.lisp. It can be run from source by executing 

```
sbcl --load ltk.lisp --load mce.lisp --load mcg.lisp
```

and at the prompt of SBCL entering

```
(main)
```

To create an executable, instead of calling (start-ltk), at the SBCL prompt enter
```
(sb-ext:save-lisp-and-die "mce.exe" :toplevel #'main :executable t)
```
which will generate the executable file "start-ltk.exe" in the current directory.

## Installing on Windows

First, install two needed programs:

1. SBCL
   Install from SourceForge
   https://sourceforge.net/projects/sbcl/
   
2. Wish
   Easiest way is to use ActiveTcl
   https://www.activestate.com/products/tcl/
   
If correctly installed, sbcl and wish will be available at the command prompt.

Now go into the directory with the source code and execute

```
sbcl --load ltk.lisp --load mce.lisp --load mcg.lisp
```
then on the SBCL command prompt try

```
(main)
```

If the simulator works in the interpreter, we can generate the stand-alone executable file that can be distributed (but will still need Wish to be installed).
   
   
## Bugs and deficiencies

- The Travel pane is not correctly synchronised with the simulation, it lags behind
- The Reset is not working yet correctly
- The door status is not shown graphically
- Cars travel in discrete steps by jumping to next floor, instead of showing their correct physical position

