Skip to content

Aimsun Next API Vehicle Entrance/Exit (Meso)

Disable Normal Vehicle Generation

In C++ and Python

Explanation

Disable generation based on the traffic demand. All simulated vehicles have to be added using an external entrance process, for example using the API functions.

Format
void AMesoDisableGeneration (void * simhandler)
Parameters
  • simhandler: simulator handler

Finish user defined demand generation

In C++ and Python

Explanation

This function has to be called once all vehicles have been inserted into the model. .

Format
    int AMesoFinishTripsConfiguration (void * simhandler)
Parameters
  • simhandler: simulator handler
Outputs
  • Number of trips in the demand

Add a Vehicle in Simulation

In C++ and Python

Explanation

Adds a new vehicle in the simulation. This function can be used when adding a small number of vehicles, or adding a vehicle during the simulation.

Format
int AMesoAddVehicle(void * simhandler, int vehTypePos, double time, int originId, int destinationId, int generationSeed, int selectionSeed)
Parameters
  • simhandler: simulator handler
  • vehTypePos: vehicle type index, from 0 to AMesoNumberVehicles()-1
  • time: entrance time
  • originId: origin centroid identifier
  • destinationId: destination centroid identifier
  • generationSeed: seed used to create vehicle properties, with -1 a automatic seed is created
  • selectionSeed: seed used to select the path, with -1 a automatic seed is created
Output
  • > 0: Correct vehicle id
  • < 0: Error

Add a Vehicle in a DUE Simulation

In C++ and Python

Explanation

Adds a new vehicle in the simulation. It’s an optimized version of the above function and can be used to add a large number of vehicles from the beginning or in the middle of the simulation.

Format
int AMesoAddTrip (void * simhandler, int vehTypePos, double time, int originIndex, int destinationIndex, int generationSeed, int selectionSeed, double valueOfTime)
Parameters
  • simhandler: simulator handler
  • vehTypePos: vehicle type index, from 0 to AMesoNumberVehicles()-1
  • time: entrance time
  • originIndex: origin centroid index, from 0 to AMesoGetNumberOriginCentroids -1
  • destinationIndex: destination centroid index, from 0 to AMesoGetNumberDestinationCentroids -1
  • generationSeed: seed used to create vehicle properties, with -1 a automatic seed is created
  • selectionSeed: seed used to select the path, with -1 a automatic seed is created
  • valueOfTime: value of time used by this vehicle
Output
  • > 0: Correct vehicle id
  • < 0: Error

Update vehicle entrance time

In C++ and Python

Explanation

Updates the vehicle entrance time

Format
int AMesoUpdateTripTime (void * simhandler, int id, double time)
Parameters
  • simhandler: simulator handler
  • id: vehicle identifier
  • time: entrance time
Output
  • ≥ 0: Correct
  • < 0: Error

Insert a new transit vehicle

In C++ and Python

Explanation

Inserts a new transit vehicle using a predefined transit line and location

Format
bool AMesoAddVehicleAsInitialStatePT(void * simhandler, int vehType, int idline, int currentSectionid)
Parameters
  • simhandler: simulator handler
  • vehType: vehicle type index, from 0 to AMesoNumberVehicles()-1
  • idline: transit line indentifier
  • currentSectionid: section identifier
Output
  • ≥ True: vehicle could be inserted
  • < False: vehicle couldn't be inserted

Remove vehicle from network

In C++ and Python

Explanation

Remove an existing vehicle from the network. There are some restrictions when using this function: - This function can't be called in the following callbacks: MesoAPINewVehicleSystem, MesoAPINewVehicleNetwork, MesoAPIFinishVehicleNetwork, MesoAPIEnterVehicleSection, MesoAPIExitVehicleSection, MesoAPIVehicleReadyForSection. So in any function where the vehicle handler is part of the input parameters. - Only vehicles that are inside the network can be removed. Those vehicles inside a virtual queue can't be removed. - Only those vehicles that are in place to move ahead (they are at front of the queue) can be removed. And finally when the vehicle is in a section it can be removed only when the vehicle is to be considered in queue. That means that its travel time in the section is higher than the precalculated arrival in queue time.

The vehicle handler input parameter is up to the user to keep it inside the api. For example it can declare a dictionary vehicles = dict() and then manage this dictionary when the vehicle is inserted in the network using MesoAPINewVehicleNetwork (vehicles[AMesoGetVehicleID(vehhandler)] = vehhandler) and when the vehicle exits the network, MesoAPIFinishVehicleNetwork

if normalOut and AMesoGetVehicleID(vehhandler) in vehicles:
    vehicles.pop(AMesoGetVehicleID(vehhandler))
the normalOut filter is used because when the vehicle is removed using this function, the MesoAPIFinishVehicleNetwork callback is called too with normalOut set to False.

Format
bool AMesoRemoveVehicle(void * simhandler, void * vehhandler)
Parameters
  • simhandler: simulator handler
  • vehhandler: vehicle handler
Output
  • ≥ True: vehicle was removed
  • < False: vehicle wasn't removed