The CarEnter block takes the car agent and attempts to place it as a car at the specified location within a road network. The car can appear on the specified road or in the specified parking lot (defined by the Appears parameter).
If cars are set to appear on a road, the direction of the road should also be specified. Cars will appear at the beginning of the specified road and start moving in the specified direction. By default, the Random lane parameter is selected, so the cars will appear at random lanes, if there is more than 1 lane on the specified road. You can explicitly specify the index of the lane where cars will appear by clearing the Random lane option and using the Lane index parameter.
If cars are set to appear on a road, they enter the road network only when there is enough distance in the lane ahead of the car. The greater the initial speed of the car, the greater the distance required for a car to safely enter the network. Cars that cannot enter the road network immediately are accumulated in a queue within the CarEnter block and are removed from the queue when there is enough space in the specified lane to place a car.
If cars are set to appear in a parking lot, they appear in free spaces of the specified parking lot and wait until they leave the road network or start moving by entering the CarMoveTo block. If all parking spaces are occupied, an error is generated.
Together with CarExit, this block is used to model part of the car movement at a higher abstraction level, that is, without detailed physical level road traffic modeling.
Demo model: CarEnter and CarExit Open the model page in AnyLogic Cloud. There you can run the model or download it (by clicking Model source files). Demo model: CarEnter and CarExitOpen the model in your AnyLogic desktop installation.- Appears
-
Specifies where the cars that enter this block will appear: on the road or in the parking lot.
on road — The cars will be placed at the beginning of the road specified below in the Road parameter.
in parking lot — The cars will be placed in a randomly chosen free parking space in the parking lot specified below in the Parking lot parameter.Syntax: RoadTrafficLibraryConstants.CarOriginType appears
Set new value at runtime: set_appears(new value)
Valid values:
CarEnter.ON_ROAD
CarEnter.IN_PARKING_LOT -
[Visible and applies only if Appears: on road]
The road on which the car will be placed after the start of the movement. The car enters the Road in the specified lane (backward lane or forward lane). The lane is specified by the Enters parameter below. The lane is chosen randomly (if the Random lane option is enabled) or specified explicitly in the Lane index parameter below.
The car does not immediately appear at the specified location. The car appears and starts movement only when:- there is enough space on the specified position of the road to avoid a collision, and
- the car is sent to a destination by the CarMoveTo block.
Value type: Road
Local variable: car — The car that enters the road network - Enters
-
[Visible and applies only if Appears: on road]
Specifies the lane (forward lane or backward lane) of the road on which the car will be placed. If the road does not have the specified lane (that is, is one-way), the error is generated.Syntax: RoadTrafficLibraryConstants.CarRoadDirection laneDirection
Set new value at runtime: set_laneDirection(new value)
Valid values:
CarEnter.FORWARD_LANE
CarEnter.BACKWARD_LANE - Random lane
-
[Visible and applies only if Appears: on road]
Specifies whether the car will be placed in a random lane on the road. If this option is disabled, the lane will be specified by Lane index parameter below.Syntax: boolean isRandomLane
Set new value at runtime: set_israndomlane(new value) -
[Visible and applies only if the Random lane option is not selected]
Specifies the index of the lane in which the car should be placed. Lane indices start with 0 (the outermost lane) and increase to the innermost lane. If the specified Road does not have a lane with the specified index, an error is generated.Value type: int
Local variable: car — The car that enters the road network -
[Visible and applies only if the option in parking lot is selected]
The parking lot where the car will be placed immediately after entering this block. If the parking lot does not have free parking spaces, an error will be generated. The car will not move from the parking space until it is sent to some destination by the CarMoveTo block.Value type: ParkingLot
Local variable: car — The car that enters the road network
- The length of the car. The length must be greater than 0.
Value type: double
Local variable: car — The car that enters the road network. -
The initial speed of the car. The initial speed must be greater than 0. If the initial speed is equal to 0, the car will start accelerating to its preferred speed when it is sent to a destination by the CarMoveTo block.
Value type: double
Local variable: car — The car that enters the road network -
TThe preferred speed of the generated car. The preferred speed must be greater than or equal to 0. If the preferred speed is equal to 0 and the initial speed is equal to 0, the car will not start movement even if it is sent to a destination by the CarMoveTo block. The car will not start accelerating until it is assigned a positive initial speed by the call of the setPreferredSpeed(speed) function.
The car will always try to move at a speed equal to its preferred speed. The following factors can prevent the car from moving at its preferred speed:- the inability to accelerate or decelerate immediately to the preferred speed,
- a car ahead that is moving slower than the preferred speed of the car,
- a stop line with a red light ahead,
- the proximity of a parking space or bus stop, where the car should slow down to park or stop,
- the speed limit.
Value type: double
Local variable: car — The car that enters the road network -
The maximum acceleration of the car. The maximum acceleration should be greater than 0.
Value type: double
Local variable: car — The car that enters the road network -
The maximum deceleration of the car. The maximum deceleration should be greater than 0. The car will only use its maximum deceleration in an emergency. At other times it uses a fraction of the maximum deceleration.
Value type: double
Local variable: car — The car that enters the road network
- On exit
-
The code to execute when a car exits this block.
Local variable: car — The car that exits this block
- Statistics
-
Function Description long count() Returns the number of cars that have entered the road network via this CarEnter block.
- in
- The input port.
- out
- The output port.
-
How can we improve this article?
-