AnyLogic 9
Expand
Font size

Elevator

Elevator in the graphical editor

The Elevator is a space markup shape that visually defines the elevator in a pedestrian simulation model. You draw elevators in the graphical editor and configure them (setting the movement speed, accessible levels, etc.) in the shape’s properties. To simulate how pedestrians are transported by elevators, insert the Pedestrian Library block PedElevator into the flowchart.

The location of the elevator door is indicated by an additional line drawn inside the elevator’s shape (in the figure above, the door is located at the bottom of the shape).

Demo model: Pedestrian Elevator Open the model page in AnyLogic Cloud. There you can run the model or download it (by clicking Model source files). Demo model: Pedestrian ElevatorOpen the model in your AnyLogic desktop installation.

An elevator at model runtime, in 3D animation

Drawing an elevator

We will show how to draw an elevator in the pedestrian simulation model of the new Van Gogh museum entrance in Amsterdam.

The layout of the new museum entrance looks as follows:

New entrance to Van Gogh museum

You can drop this layout into the graphical editor using the  Image element from the Presentation palette. Consider locking it afterwards by selecting the Lock option in its properties, so that you do not accidentally move the image while drawing the elevator.

To draw an elevator

  1. If you are creating a pedestrian simulation model that uses the layout of the simulated building, prior to adding space markup shapes, check that the scale of the layout image in your model corresponds to the scale of the graphical diagram.
  2. Drag the  Elevator element from the  Space Markup section of the Pedestrian Library palette onto the graphical editor.

  3. Open the Properties of the elevator shape. In the Doors configuration property, specify whether the elevator has doors only on one side (the front option) or on both sides (the front/rear option).
  4. Before modifying the shape, if you need to adjust it with more precision, you can turn grid alignment off by selecting Scale > Snap to grid on the toolbar.
  5. Now check that the door drawn inside the elevator shape is located on the desired side of the elevator. For example, we want the door to be located on the right side. To rotate the shape, click it, then drag the round handle that appears above the selected shape by default clockwise.

    Drag the highlighted handle to rotate the elevator.

  6. After you have adjusted the door location, modify the shape to match your layout by dragging the boundary handles of the shape.

  7. When you are finished adjusting the shape, you can continue to configure it using the shape properties. Define which floors (levels) this elevator will serve. If the serves all the floors you defined in your pedestrian model, leave the default Stops at: all levels option selected. However, if the elevator only serves some specific levels (for example, it does not serve the basement and parking levels), you should select the Stops at: selected levels option and specify the levels this elevator serves in the Levels control below.
  8. When the setup is finished, you can add the logic of the pedestrian transfer by the elevator into your process flowchart composed of Pedestrian Library blocks. To do this, add the PedElevator block into the flowchart. If the elevator is used more than once in the simulated process, add the appropriate number of PedElevator blocks.

Properties

General

Name — The name of the shape. The name is used to refer to this shape from the PedElevator block properties and to access the elevator from code.

Show name — If selected, the name of the shape is displayed in the graphical editor.

Lock — If selected, the shape is locked. Locked elements do not respond to mouse clicks, and they cannot be selected in the graphical editor until you unlock them. This is often needed when you want to prevent the element from being edited while other elements are placed over it.

Ignore — If selected, the shape is excluded from the model.

Pedestrian type — The type of the pedestrian transported by this elevator. If you have created a custom pedestrian type, select its name here to easily access the fields of this type in the actions of this shape. If there are no custom pedestrian types in your model, leave the default Agent value here.

Doors configuration — Defines how many doors the elevator has on each level. Select one of the door configurations: front (the default configuration, the elevator has one door), or front/rear (two doors on opposite sides).

Capacity — The maximum number of pedestrians the elevator can carry.

Movement is defined by — Specifies how the elevator movement speed is defined: directly as speed, or by specifying time per level.

Speed — [Visible and applies if Movement is defined by: speed] The movement speed of the elevator.

Time per level — [Visible and applies if Movement is defined by: time per level] The time it takes for the elevator to move one level up or down.

Minimum stay time — The minimum amount of time the elevator must stay on the level when it stops there before continuing its movement to the next level. If loading and/or unloading is not completed by this time, the elevator will remain at the level until it is.

Stops at — [Visible and applies if Define slope as: angle] — Specifies whether the elevator stops at all levels or only at selected levels. By default, the all levels option enables the elevator to stop at all levels defined in this agent type. This is the most commonly used option because elevators usually serve all levels (floors) in the simulated building. However, sometimes an elevator may not serve certain levels (such as parking levels). In this case, you should use the selected levels option and select the levels to be served in the Levels control below.

Levels — [Visible and applies if Stops at: selected levels] — Specifies the levels that are served by the elevator. Normally, all levels exist in the same agent, and you simply select the desired levels from the list. However, in some rare cases your model may be decomposed so that levels are defined as separate agents. The following demo model shows how to define levels in such case.

Demo model: Elevator Connecting Floors Defined by Different Agents Open the model page in AnyLogic Cloud. There you can run the model or download it (by clicking Model source files). Demo model: Elevator Connecting Floors Defined by Different AgentsOpen the model in your AnyLogic desktop installation.
Actions

On level arrival — The Java code that will be executed each time the elevator stops on a level.
Local variables:
Level level — the level the elevator has arrived to.
List<Agent> waitingAgents — the collection of agents waiting on the level to enter the elevator.

On level departure — The Java code that will be executed each time the elevator departs from a level where it had stopped.
Local variable:
Level level — the level the elevator is departing from.

On failed — The Java code that will be executed in case of the elevator failure.

On repaired —  The Java code that will be executed upon the elevator repair.

On state changed —  The Java code that will be executed after the elevator’s state has changed.
Local variable:
ElevatorState newState — the new state of the elevator.
Valid values:
ElevatorState.ELEVATOR_STATE_IDLE
ElevatorState.ELEVATOR_STATE_LOADING
ElevatorState.ELEVATOR_STATE_MOVING
ElevatorState.ELEVATOR_STATE_FAILED

Appearance

Platform color — The color of the elevator’s platform (cabin floor). Select No fill if you do not want the platform to be filled with a color.

Wall color — The color of the elevator’s cabin (and if the elevator shaft is drawn, the color of the shaft). The default color is semi-transparent. Select No fill if you do not want the elevator’s wall to be filled with a color.

Line width — The width of the line defining the elevator wall (and if the elevator shaft is drawn, the shaft wall), in pixels.

Cabin height — The height of the elevator’s cabin. The default value is 3 meters.

Draw shaft — If selected, the elevator shaft is drawn. The shaft is drawn in the color specified in the Wall color property.

Position and size

Level — The level where the elevator’s shape belongs to.

X — The X-coordinate of the shape.

Y — The Y-coordinate of the shape.

Width — The width of the elevator’s shape, in pixels.

Depth — The depth of the elevator’s shape, in pixels.

Rotation — The orientation of the shape.

Visibility and presentation

Visible — If selected, the shape is visible during animation at model runtime.

Show in — Select whether the shape is displayed in both 2D and 3D animation, 2D only, or 3D only.

Agent presentation — If selected, the shape is also visible on the upper-level agent that hosts the agent containing this shape.

Elevator control system

The standard control system is implemented, called Selective Collective Operation. It follows two rules:

  • The elevator moves in one direction and serves all requests on its way, as long as there are any requests for movement in this direction (either from pedestrians who are already inside the elevator’s cabin, or from those waiting for the elevator on the levels).
  • When the requests for the elevator to move in its current direction are satisfied, if there are any requests to move in the opposite direction, the elevator changes its direction and starts moving. If there are no requests, the elevator stops and waits for them.

If a request is placed in the elevator’s queue, it will definitely be fulfilled, that is, the elevator will stop at the floor and stay there for at least the specified minimum stay time, even if the pedestrian who originated the request is not there (has already left the PedElevator block via the ccl port, or could not enter the block because the elevator was full).

If a pedestrian could not enter the elevator because it was full, the request to transfer a pedestrian from that level will remain in the elevator queue.

If you need to implement other control system algorithms, switch your elevator to the manual control mode and control it using the moveTo(), pickUpPeds() and dropOffPeds() functions. These functions have higher priority than the automatic mode commands to allow the user to handle emergency situations.

To switch an elevator to the manual control mode, call its setManualMode() function.

Demo model: Elevator Manual Control Open the model page in AnyLogic Cloud. There you can run the model or download it (by clicking Model source files). Demo model: Elevator Manual ControlOpen the model in your AnyLogic desktop installation.

Defining different door locations on different levels

Normally, an elevator has one door. Sometimes (usually in high pedestrian traffic facilities such as airports, train stations, and so on) an elevator may have two doors located on the opposite sides of the elevator cabin. In either case, you can easily set up an elevator in your model by adjusting the Door configuration property of the Elevator element.

However, there is a rare case where different elevator doors open on different floors. In this case, you should “tune” your elevator by calling the corresponding functions of the Elevator shape: disableDoor() and enableDoor(). In the Door configuration property, select the front/rear option and then place the elevator’s disableDoor() function calls, disabling the desired doors on the desired levels, in the On startup action code of the top-level agent of your model (usually it is the Main agent type).

Failure and repair

If necessary, you can simulate elevator breakdowns and repairs using the corresponding elevator functions failure() and repair() (see the first section of elevator functions below). In the corresponding properties of the elevator in the Actions section, you can specify Java code to be executed when a failure occurs and when the elevator is repaired.

You can explore the approach using the provided sample model.

Demo model: Elevator Failure Open the model page in AnyLogic Cloud. There you can run the model or download it (by clicking Model source files). Demo model: Elevator FailureOpen the model in your AnyLogic desktop installation.

Functions

Failure/repair
Function Description
boolean fail() Initiates elevator failure. The elevator stops working. New pedestrians cannot enter the elevator and the pedestrians that were inside the elevator at the moment of failure remain inside until the elevator is repaired. The function call initiates the On failed action callback.
boolean repair() Repairs the elevator. The elevator becomes available again. Resumes elevator processing (continues to fulfil the queued movement requests in the automatic mode). The function call initiates the On repaired action callback.
boolean isFailed() Returns true if the elevator failed (broke down) and is not operating, returns false otherwise.
Current state and route
Function Description
ElevatorState getState() Returns current elevator state.
Valid values:
ElevatorState.ELEVATOR_STATE_IDLE
ElevatorState.ELEVATOR_STATE_LOADING
ElevatorState.ELEVATOR_STATE_MOVING
ElevatorState.ELEVATOR_STATE_FAILED
ElevatorDirection getCurrentDirection() Returns current movement direction of the elevator. If the elevator is not moving and waits for the pedestrians to leave/enter the elevator, returns direction the elevator will be moving in. If there is no task for the elevator, returns ELEVATOR_DIRECTION_NONE.

Possible return values:
ElevatorDirection.ELEVATOR_DIRECTION_UP
ElevatorDirection.ELEVATOR_DIRECTION_DOWN
ElevatorDirection.ELEVATOR_DIRECTION_NONE
Level getCurrentLevel() Returns the current level of the elevator. If the elevator is located between two levels, the function returns the lower level.
List<Elevator.Call> getCalls() Returns a list of elevator calls in the elevator's queue. Each call stores information about the level, which has sent this request, the requested movement direction (ElevatorDirection.ELEVATOR_DIRECTION_UP or ElevatorDirection.ELEVATOR_DIRECTION_DOWN) and the order of this request in the elevator's queue. The calls are sorted by levels that sent them, from the lowest to the highest level.
List<Level> getRoute() Returns the list of levels the elevator will visit and stop at. The list is formed based on the existing calls: the calls from the levels where pedestrians wait for the elevator, and the calls originated by the pedestrians who are currently inside the elevator and need to move to some specific level. The levels in the list are sorted according to the order in which the elevator will stop at those levels (the first level to stop at is the first item in the list). In the manual control mode, the list contains only one level where the elevator is currently moving to.
Pedestrians
Function Description
Set<Agent> getPeds() Returns the list of pedestrians that are currently inside the elevator.
Set<Agent> getWaitingPeds(Level level) Returns the list of pedestrians waiting for the elevator on the specified level.
Set<Agent> getWaitingPeds() Returns the list of pedestrians waiting for the elevator on all levels.
Level getPedTargetLevel(Agent ped) Returns the target level of a pedestrian, specified in the PedElevator block. If the target level is not specified in the block properties, returns null.

ped — pedestrian, whose target level will be returned
Statistics
Function Description
int nTransportedPeds() Returns the total number of pedestrians transported by the elevator.
double utilization() Returns the elevator utilization: the fraction of time the elevator was operating. The returned elevator utilization value lies in the range [0..1].
double timeInState(ElevatorState state) Returns time (in seconds) the elevator spent in the specified state since the model start or since the last resetStats() function call.

state — the state of the elevator
Valid values:
ElevatorState.ELEVATOR_STATE_IDLE
ElevatorState.ELEVATOR_STATE_LOADING
ElevatorState.ELEVATOR_STATE_MOVING
ElevatorState.ELEVATOR_STATE_FAILED
double timeInState(ElevatorState state, TimeUnits units) Returns time (in specified time units) the elevator spent in the specified state since the model start or since the last resetStats() function call.

state — the state of the elevator
Valid values:
ElevatorState.ELEVATOR_STATE_IDLE
ElevatorState.ELEVATOR_STATE_LOADING
ElevatorState.ELEVATOR_STATE_MOVING
ElevatorState.ELEVATOR_STATE_FAILED
units — a constant defining the time units.
double totalTravelTime() Returns the total time (in seconds) the elevator was moving since the model start (or since the last resetStats() function call).
double totalTravelTime(TimeUnits units) Returns the total time (in specified time units) the elevator was moving since the model start (or since the last resetStats() function call).

units — a constant defining the time units.
double meanWaitingTime() Returns mean time (in seconds) pedestrians spent waiting for the elevator on all levels.
double meanWaitingTime(TimeUnits units) Returns mean time (in specified time units) pedestrians spent waiting for the elevator on all levels.

units — a constant defining the time units.
double meanWaitingTime(Level level) Returns mean time (in seconds) pedestrians spent waiting for elevator on the specified level.

level — the level
double meanWaitingTime(Level level, TimeUnits units) Returns mean time (in specified time units) pedestrians spent waiting for the elevator on the specified level.

level — the level
units — a constant defining the time units.
int nPickedUpPeds(Level level) Returns the total number of pedestrians picked up at the specified level.
int nDroppedOffPeds(Level level) Returns the total number of pedestrians dropped off at the specified level.
void resetStats() Resets all statistics collected for the elevator.
Capacity
Function Description
int getCapacity() Returns the maximum number of pedestrians elevator can transfer at once.
void setCapacity(int capacity) Sets the maximum number of pedestrians elevator can transfer at once.

capacity — new capacity value
Speed, time per level
Function Description
double getSpeed() Returns the speed of the elevator (in meters per second).
double getSpeed(SpeedUnits units) Returns the speed of the elevator (in the units passed via the units argument).

units — one of the AnyLogic speed constants
void setSpeed(double speed) Sets the speed (in meters per second) for the elevator.

speed — new speed value
void setSpeed(double speed, SpeedUnits units) Sets the speed for the elevator (in the units passed via the units argument).

speed — the elevator’s speed
units — one of the AnyLogic speed constants
double getTimePerLevel() Returns time to move between two neighboring levels (in seconds).
double getTimePerLevel(TimeUnits units) Returns time to move between two neighboring levels (in specified units).

units — a constant defining the time units.
void setTimePerLevel(double timePerLevel) Sets the elevator’s time per level - the time the elevator takes to get to the next level (in seconds).

timePerLevel — time elevator takes to get to the next level
void setTimePerLevel(double timePerLevel, TimeUnits units) Sets the elevator’s time per level - the time the elevator takes to get to the next level (in specified time units).

timePerLevel — time elevator takes to get to the next level
units — a constant defining the time units.
Minimum stay time
Function Description
double minStayTime() Returns minimum time (in seconds) the elevator will spend on the level before moving further. If loading is not finished after this time, the elevator will depart immediately when the loading finishes.
double minStayTime(TimeUnits units) Returns minimum time (in specified time units) the elevator will spend on the level before moving further. If loading is not finished after this time, the elevator will depart immediately when the loading finishes.

units — a constant defining the time units.
Manual control mode
Function Description
boolean isManualMode() Returns true, if the elevator is in manual control mode, and false if it is controlled automatically.
void setManualMode(boolean on) Changes the current control mode of the elevator. When the manual mode is on, elevator will move, pickup and dropoff pedestrians only according to moveTo(), pickUpPeds() and dropOffPeds() calls.

on — if true, the manual control mode is set, if false - the automatic
void moveTo(Level level) Sends the elevator to the specified level. Automatically switches the elevator operation mode to the manual mode. If the elevator is currently in the loading state, all pedestrians planned for pick up or drop off will be processed first, and the elevator will start its movement afterwards. On arrival to the target level the elevator will stay in the manual control mode.

level — the target level
void moveTo(Level level, boolean stayInManualMode) Sends the elevator to the specified level. Automatically switches the elevator operation mode to the manual mode. If the elevator is currently in the loading state, all pedestrians planned for pick up or drop off will be processed first, and the elevator will start its movement afterwards. The elevator control mode after the movement completion is set by the user.

level — the target level
stayInManualMode — if true, after the movement, the elevator will stay in the manual control mode, if false - it will switch to the automatic mode
void pickUpPeds(List<Agent> peds) Is used only when the user controls the elevator operation in the manual mode. Starts picking up the pedestrians from the specified list. All the pedestrians in the list should be located on the same level where the elevator currently is at the function call moment. Throws an error if some pedestrian from the specified list is located on a different level, or if the elevator is located between levels.
void dropOffPeds(List<Agent> peds) Is used only when the user controls the elevator operation in the manual mode. Starts drop off for pedestrians in the specified list (makes the pedestrians leave the block via the standard output port out). All the pedestrians in the list should be inside the elevator at the function call moment. On leaving the block, pedestrians are placed on the level where the elevator is currently located.
Level getCurrentLevel() Returns the level where the elevator is currently located. If the elevator is located between levels, returns the lower level.
Level getTargetLevel() Returns the target level where the elevator is currently moving. If the elevator is not moving and does not have any tasks to complete, returns null.
Level getNearestLevel() Returns the nearest level served by the elevator. If the elevator is moving up, returns the next level. If it is going down, returns the current level.
void deleteCallsOnLevel(Level level) Removes all pickup tasks from the level. Pedestrian(s) will still be waiting for the elevator, use cancel() or remove() functions to manage them.

level — the level to remove all pickup tasks for
Doors
Function Description
void disableDoor(Level level, ElevatorDoor door) Disables the specified door at the specified level.

level — the level
door — constant, defining the door to disable: ELEVATOR_DOOR_FRONT, or ELEVATOR_DOOR_REAR
void enableDoor(Level level, ElevatorDoor door) Enables the specified door at the specified level.

level — the level
door — constant, defining the door to enable: ELEVATOR_DOOR_FRONT, or ELEVATOR_DOOR_REAR
boolean isDoorEnabled(Level level, ElevatorDoor door) Checks, whether the specified door at the specified level is enabled or disabled. Returns true, if the door is enabled, and false if the door is disabled.

level — the level
door — constant, defining the door to check: ELEVATOR_DOOR_FRONT, or ELEVATOR_DOOR_REAR
ElevatorDoorsConfiguration getDoorsConfiguration() Returns elevator doors configuration.

Possible return values:
ElevatorDoorsConfiguration.ELEVATOR_DOORS_FRONT
ElevatorDoorsConfiguration.ELEVATOR_DOORS_FRONT_REAR
void setDoorsConfiguration(ElevatorDoorsConfiguration doorsConfiguration) Sets elevator doors configuration.

doorsConfiguration — new doors configuration
Valid values:
ElevatorDoorsConfiguration.ELEVATOR_DOORS_FRONT
ElevatorDoorsConfiguration.ELEVATOR_DOORS_FRONT_REAR
Levels
Function Description
Level getLevel() Returns the level, where this shape is located.
boolean isAllLevels() Returns true if the elevator is set to serve all levels, false otherwise.
void setAllLevels(boolean allLevels) Defines whether the elevator should serve all levels.

allLevels — if true, the elevator is set to serve all levels, if false — only the selected levels
Level[] accessibleLevels() Returns the array of levels that can be served by elevator. The levels stored in the array are sorted according their Z-coordinate. If the elevator serves all levels, the array also contains all levels.
void addAccessibleLevels(Level[] levels) Sets levels that can be served by the elevator. Can be called only before the elevator initialization. When called, switches the elevator to the mode when it serves only the selected levels (isAllLevels() will return false).

levels — array of levels to be served by the elevator
Dimensions
Function Description
double getWidth(LengthUnits units) Returns the elevator cabin width in the specified units.

units — a constant defining the length units.
void setWidth(double width, LengthUnits units) Sets the elevator cabin width in the specified units.

width — a new width value.
units — a constant defining the length units.
double getDepth(LengthUnits units) Returns the elevator cabin depth in the specified units.

units — a constant defining the length units.
void setDepth(double depth, LengthUnits units) Sets the elevator cabin depth in the specified units.

depth — a new depth value.
units — a constant defining the length units.
double getCabinHeight(LengthUnits units) Returns the height of the elevator’s cabin (in specified length units).

units — a constant defining the length units.
void setCabinHeight(double cabinHeight, LengthUnits units) Sets the height of the elevator’s cabin (in specified length units).

width — new height of the cabin.
units — a constant defining the length units.
Position
Function Description
double getX() Returns the X coordinate of the shape.
void setX(double x) Sets the X coordinate of the shape.

x — a new X coordinate.
double getY() Returns the Y coordinate of the shape.
void setY(double y) Sets the Y coordinate of the shape.

y — a new Y coordinate.
Point getXYZ() Returns the (X, Y, Z) coordinates of the elevator.
void setXYZ(double x, double y, double z) Sets the (X, Y, Z) coordinates of the elevator.

x — a new X coordinate.
y — a new Y coordinate.
z — a new Z coordinate.
Rotation
Function Description
double getRotation() Returns the rotation of the shape in radians.
void setRotation(double rotation) Sets the rotation of the shape in radians.

rotation — a new rotation value.
Appearance
Function Description
Color getWallColor() Returns the wall color of the elevator, or null if the elevator has no color or uses a texture (in this case use getWallTexture() to get the elevator’s texture).
Texture getWallTexture() Returns the wall texture of the elevator or null if the elevator has no texture but uses a color (in this case use getWallColor() to get the elevator’s color).
void setWallColor(Paint wallColor) Sets the wall color (or texture) of the elevator.

wallColor — the new wall color
Color getPlatformColor() Returns the fill color of the elevator's platform, or null if the platform has no fill color or has textured fill (in this case getPlatformTexture() should be used instead).
Texture getPlatformTexture() Returns the fill texture of the elevator's platform if it has fill texture, or null if the elevator's platform has no texture but uses a color (in this case use getPlatformColor() to get the platform’s color).
void setPlatformColor(Paint platformColor) Sets the fill color (or Texture) of the elevator's platform.

platformColor — the new fill color, if null, the platform is not filled.
boolean isDrawShaft() Returns true if the elevator’s shaft is drawn, otherwise returns false.
void setDrawShaft(boolean drawShaft) Sets whether elevator’s shaft should be drawn.

drawShaft — visibility of the shaft. If true, the shaft is visible, if false — not visible.
double getLineWidth() Returns the elevator’s line width (in pixels).
void setLineWidth(double width) Sets the elevator’s line width (in pixels).
Visibility
Function Description
void setVisible(boolean v) Sets the visibility of the shape.

v — visibility of the shape. If true, the shape is visible, if false — not visible.
boolean isVisible() Returns the visibility of the shape. If it returns true, the shape is visible, if false — not visible.
Draw mode (2D / 3D)
Function Description
ShapeDrawMode getDrawMode() Returns the drawing mode of the shape (it defines where this shape is drawn: in 2D, 3D or 2D+3D animation).

Valid values:
SHAPE_DRAW_2D3D — show in 2D and 3D animation
SHAPE_DRAW_2D — show in 2D animation only
SHAPE_DRAW_3D — show in 3D animation only
void setDrawMode(ShapeDrawMode drawMode) Sets the drawing mode of the shape (where to draw this shape: 2D, 3D or 2D+3D animation).
This function may be called only once and only for the shape created using the constructor without arguments. The call, which changes the set draw mode, will throw the error.
drawMode — the new draw mode of the shape.
Valid values:
SHAPE_DRAW_2D3D — show in 2D and 3D animation
SHAPE_DRAW_2D — show in 2D animation only
SHAPE_DRAW_3D — show in 3D animation only
Removal
Function Description
void remove() Removes the elevator from the presentation. If the shape is not a part of presentation, the function does nothing.
Removal from the presentation does not necessarily mean removing from the model logic, since logical networks and routes may have been created before the removal and survive it.
How can we improve this article?