CarSource is the block that generates cars and tries to put them into the specified location within a road network. This block has no buffer, so if the car is not generated at the appropriate time, it will not be generated later.
The car can appear on the specified road or in the specified parking lot (defined by the Appears parameter).
Car arrivals can be defined by:
- interarrival times,
- arrival rate,
- rate schedule,
- arrival schedule that defines the exact number of cars and times of their arrival,
- calling the inject() function of the CarSource block.
As in the Source block, you can limit the number of arrivals.
If you want cars to appear on a road, you should also specify the direction of the road. The 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 in the specified direction on the 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 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.
Demo model: CarSource Open the model page in AnyLogic Cloud. There you can run the model or download it (by clicking Model source files). Demo model: CarSourceOpen the model in your AnyLogic desktop installation.- Arrivals defined by
-
Specifies the mode of cars generation:
Rate — Cars are generated at the specified Arrival rate (which is equivalent to exponentially distributed interarrival time with mean = 1/Arrival rate).
Interarrival time — The time between two consecutive cars is defined by the specified expression.
Arrival table in Database — Agents are generated according to the records in the specified database table. You specify the table below in the Database table parameter, then select the table column containing the arrival moments in the Arrival date drop-down list. The block will generate one agent for each data record in the specified table.
Rate schedule — Cars are generated according to the schedule that defines how the Arrival rate of cars changes over time.
Arrival schedule — Cars are generated at exact times defined in the arrival schedule.
Calls of inject() function — Cars are not generated automatically, but only when the inject() function is called.Get value: arrivalType
Set new value at runtime: set_arrivalType(new value)
Valid values:
CarSource.RATE
CarSource.INTERARRIVAL_TIME
Source.DATABASE_ARRIVAL_TABLE
CarSource.RATE_SCHEDULE
CarSource.ARRIVAL_SCHEDULE
CarSource.MANUAL -
[Visible and applies only if Arrivals defined by: Interarrival time]
The expression used to evaluate the delay time for each arriving car.Value type: double - Arrival schedule
-
[Visible and applies only if Arrivals defined by: Arrival schedule]
The name of the schedule with integer value type that contains the arrival times of the cars. Typically, the value column would contain 1 as one car is generated at a time.Syntax: Schedule<Integer> arrivalSchedule
Set new value at runtime: set_arrivalSchedule(new value) - Database table
-
[Visible if Arrivals defined by: Arrival table in Database]
Specify the database table containing the data on agent arrivals. - Arrival date
-
[Visible if Arrivals defined by: Arrival table in Database]
Specify the column of the Database table that contains the agent arrival timestamps. - Arrival rate
-
[Visible and applies only if Arrivals defined by: Rate]
The arrival rate of cars. If Arrival rate is used and it becomes 0, no next arrival will be scheduled until the Arrival rate changes to a positive value.Syntax: double rate
Set new value at runtime: set_rate(new value) - Rate schedule
-
[Visible and applies only if Arrivals defined by: Rate schedule]
The name of the schedule defining how the Arrival rate of cars changes with time.Syntax: Schedule<Integer> rateSchedule
Set new value at runtime: set_rateSchedule(new value) - Modify rate
-
[Visible and applies only if Arrivals defined by: Rate schedule]
Toggles the expression that modifies Arrival rate. The expression is defined in the Rate expression parameter below.Syntax: boolean modifyRate
Set new value at runtime: set_modifyRate(new value) -
[Visible and applies only if the Modify rate option is selected]
The expression that modifies the arrival rate.Value type: double
Local variable: double baseRate — The current rate value taken from the specified rate schedule - Set agent parameters from DB
-
[Visible and applies if the Arrivals defined by option is not set to Arrival table in Database or Calls of inject() function]
If the option is selected (true), enables initialization of car parameters from the specified Database table.Syntax: boolean setAgentParametersFromDB
Set new value at runtime: set_setAgentParametersFromDB(new value) - Database table
-
[Visible and applies only if the Set agent parameters from DB option is selected]
Specify the database table containing the data on car arrivals.Syntax: TableInput databaseTable
Set new value at runtime: set_databaseTable(new value) - Limited number of arrivals
-
[Visible and applies if the Arrivals defined by option is not set to Calls of inject() function]
If true, the number of arrivals will be limited to Maximum number of arrivals.Syntax: boolean limitArrivals
Set new value at runtime: set_limitArrivals(new value) - Maximum number of arrivals
-
[Visible and applies only if the Limited number of arrivals]
The maximum number of cars to be generated by this block.Syntax: int maxArrivals
Set new value at runtime: set_maxArrivals(new value) - Appears
- Specifies where the cars generated by this block will appear: on a road or in a 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 of the parking lot specified below in the Parking lot parameter.Get value: appears
Set new value at runtime: set_appears(new value)
Valid values:
CarSource.ON_ROAD
CarSource.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 (forward lane or backward lane). The lane is specified by the Enters parameter below. The lane is picked randomly (if the Random lane option is enabled) or specified explicitly at the Lane index parameter below.Value type: Road
Local variable: car — The car that is being created by this block. - Enters
-
[Visible and applies only if Appears: on road]
Specifies the lane (forward lane or backward lane) of the road in which the car will be placed. If the road does not have the specified lane (that is, is one-way), the error is generated.Get value: laneDirection
Set new value at runtime: set_laneDirection(new value)
Valid values:
CarSource.FORWARD_LANE
CarSource.BACKWARD_LANE - Random lane
-
[Visible and applies only if Appears: on road]
Specifies whether the car will be placed in a random lane of the road. If this option is disabled, the lane will be specified by the 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 where 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 agent that is being created by this block. -
[Visible and applies only if Appears: in parking lot]
The parking lot where the car will be placed immediately after entering this block. If the parking lot has no free spaces, an error will be generated. The car will not move from the parking space until it is sent to a destination by the CarMoveTo block.Value type: ParkingLot
Local variable: car — The car that is being created by this block.
-
The car type created by this CarSource block. Use an agent type with the Use in flowchart as property set to Car.
Value type: Agent
-
The length of the generated car. The length must be greater than 0.
Value type: double
Local variable: car — The car that is being generated by this block -
The initial speed of the generated car. The initial speed must be greater than or equal to 0. If the initial speed is less than the preferred speed, 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 is being generated by this block -
The 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 is being generated by this block - The maximum acceleration of the generated car. The acceleration should be greater than 0.
Value type: double
Local variable: car — The car that is being generated by this block -
The maximum deceleration of the generated car. The maximum deceleration should be greater than 0. The car will use its maximum deceleration only in emergencies. At other times it will use a fraction of the maximum deceleration.
Value type: double
Local variable: car — The car that is being generated by this block
- Add cars to
-
This parameter specifies where the cars created by this block will be stored: in the default population of root agent or in some custom population (specified below in the Car population property).
Syntax: boolean addCarToCustomPopulation
Set new value at runtime: set_addCarToCustomPopulation(new value)
Valid values:
false
true -
[Visible and applies only if the Add cars to: custom population option is selected]
The name of the agent population where the cars created by this block will be stored.Value type: <Agent> List
Local variable: car — The agent that is being created by this block.
- On exit
- The code that is executed when car exits this block.
Local variable: car — The car that exits this block
- Generating cars
-
Function Description void inject() Generates a single car at the time of call. Can be applied if the Arrivals defined by: calls of inject() function option is selected. void inject(int n) Generates the specified number of cars (n) at the time of the call. Can be applied if the Arrivals defined by: calls of inject() function option is selected.
n — The number of cars to generate on each call.
- out
- The output port.
-
How can we improve this article?
-