Skip to content

Aimsun Next API Managing Transit

Read number of Transit Lines

In C++ and Python

Explanation

Read the number of transit lines loaded.

Format
int AKIPTGetNumberLines()
Parameters

None.

Output
  • ≥ 0: Number of transit lines.
  • < 0: Error.

Read the identifier of a Transit Line

In C++ and Python

Explanation

Read the identifier of a transit line.

Format
int AKIPTGetIdLine(int elem);
Parameters
  • elem: The number of the transit line in the range 0 ≤ elem < Number of Lines -1.
Output
  • ≥ 0: Transit line identifier.
  • < 0: Error.

Read the number of vehicles in a Transit Line

In C++ and Python

Explanation

Read the number of vehicles currently following the route of a transit line.

Format
int AKIGetNbVehiclesFollowingPTLine (int lineId)
Parameters
  • lineId: The transit line identifier.
Output
  • ≥ 0: Number of vehicles in the transit line route.
  • < 0: Error.

Read the identifier of a vehicle in a Transit Line

In C++ and Python

Explanation

Reads the vehicle identifier of the n-th vehicle in a transit line route.

Format
int AKIGetVehicleFollowingPTLine(int lineId, int vehPos);
Parameters
  • lineId: The transit line identifier.
  • vehPos: The position of the vehicle in the line. It must be in the range 0 ≤ vehPost < AKIGetNbVehiclesFollowingPTLine.
Output
  • ≥ 0: Identifier of the vehicle in the transit line route.
  • < 0: Error.

Read the number of sections in a Transit Line

In C++ and Python

Explanation

Read the number of sections that define the route of a transit line.

Format
int AKIPTGetNumberSectionsInLine (int lineId)
Parameters
  • lineId: The transit line identifier.
Output
  • ≥ 0: Number of sections that define the transit line route.
  • < 0: Error.

Read the identifier of a section in a Transit Line

In C++ and Python

Explanation

Reads the section identifier of the n-th section in a transit line route.

Format
int AKIPTGetIdSectionInLine(int lineId, int elem);
Parameters
  • lineId: The transit line identifier.
  • elem: The index of the section. It must be in the range 0 ≤ elem < Number of Sections -1.
Output
  • ≥ 0: Identifier of the elem-th section in the transit line route.
  • < 0: Error.

Read the number of stops in a Transit Line

In C++ and Python

Explanation

Read the number of stops in a transit line.

Format
int AKIPTGetNumberStopsInLine(int lineId)
Parameters
  • lineId: The transit line identifier.
Output
  • ≥ 0: Number of stops in the transit line with ID lineId.
  • < 0: Error.

Read the identifier of a stop in a Transit Line

In C++ and Python

Explanation

Read the stop identifier in a transit line.

Format
int AKIPTGetIdStopsInLine(int lineId, int elem);
Parameters
  • lineId: The transit line identifier.
  • elem: The position of the stop in the list of stops of the line between 0 to AKIPTGetNumberStopsInLine(for the transit line).
Output
  • ≥ 0: Identifier of elem-th stop in the transit line.
  • < 0: Error.

Introduce a Transit Vehicle

In C++ and Python

Explanation

Introduce a transit vehicle into the system.

Format
int AKIPTEnterVeh (int lineId, int vehTypePos, bool tracked);
Parameters
  • lineId: The transit line identifier.
  • vehTypePos: The position of the vehicle type in the list of vehicles types being used. A value from 1 to AKIVehGetNbVehTypes() must be used.
  • tracking: False when the vehicle has not to be tracked, true otherwise.
Output
  • ≥ 0: vehicle identifier for the vehicle entered.
  • 0: Error.

Read the Stop Time of a Transit Vehicle

In C++ and Python

Explanation

Read a stop time of a vehicle.

Format
double AKIPTGetServiceTimeStopsInLine (int aidVeh, int nstop)
Parameters
  • aidVeh: The transit vehicle identifier.
  • nstop: Position of the stop to modify its stop time in the list of stops of the line. Value is from 0 to AKIPTGetNumberStopsInLine( for the vehicle's transit line).
Output
  • &gt = 0: Stop Time.
  • < 0: Error.

Modify a Stop Time of a Transit Vehicle

In C++ and Python

Explanation

Modify the stop time of a vehicle. When the new stop time is set to zero, the stop will be ignored by the vehicle.

Format
int AKIPTVehModifyStopTime (int aidVeh, int nstop, double stopTime);
Parameters
  • aidVeh: The transit vehicle identifier.
  • nstop: Position of the stop to modify its stop time in the list of stops of the line. Between 0 to AKIPTGetNumberStopsInLine( for the vehicle's transit line) .
  • stopTime: The new stop time for the vehicle at the stop (in seconds).
Output
  • = 0: No error occurred.
  • < 0: Error.

Read the information of a Transit Vehicle

In C++ and Python

Explanation

Read the information of a transit vehicle.

Format
InfPTVeh AKIPTVehGetInf(int aidVeh)
Parameters
  • aidVeh: Vehicle Identifier.
Output
struct InfPTVeh{
    int report;
    int idVeh;
    int type;
    // Information in Vehicle when it is in a section
    int idSection;
    int segment;
    int numberLane;
    // Information in Vehicle when it is in a node
    int idJunction;
    int idSectionFrom;
    int idLaneFrom;
    int idSectionTo;
    int idLaneTo;
    double CurrentPos; 
    double distance2End;
    double xCurrentPos, yCurrentPos, zCurrentPos;
    double xCurrentPosBack, yCurrentPosBack, zCurrentPosBack; 
    double CurrentSpeed, PreviousSpeed;
    double TotalDistance;
    double SystemGenerationT;
    double SystemEntranceT;
    double SectionEntranceT;
    double CurrentStopTime;
    bool stopped;
    uint mNbLostTurnings;
    double theoricalGenerationTime; 
    int nbStopsDone;
    double observedLastStopTime;
    double observedLastInitialStopTime;
    int nextStopId;
    double offsetInNextStop;
    double distanceNextStop;
    double nextServiceTime;
    double currentStoppedTmeInBusStop;
    int currentLoad;
    double energyState;
};

where:

  • report: 0, OK, otherwise an error code.
  • idVeh: The vehicle identifier.
  • type: The vehicle type (car, bus, truck, etc.).
  • idSection: The section identifier, when the vehicle is in a section.
  • numberLane: Lane number, when the vehicle is in a section.
  • idSectionFrom: Origin section identifier.
  • idLaneFrom: Origin section's lane where the vehicle enters the junction from. 1 being the rightmost lane and N the leftmost lane, being N the number of lanes in the origin section.
  • idSectionTo: Destination section identifier.
  • idLaneTo: Destination section's lane where the vehicle exits the junction to. 1 being the rightmost lane and N the leftmost lane, being N the number of lanes in the destination section.
  • CurrentPos: Position inside the section given by distance (meters or feet, depending on the units defined in the network) from the beginning of the section, or position inside the junction given by the distance from the entrance to the junction.
  • distance2End: Distance to end of the section (meters or feet, depending on the units defined in the network) when the vehicle is located in a section, or the distance to end of the turn when the vehicle is in a junction.
  • xCurrentPos, yCurrentPos, zCurrentPos: World coordinates of the middle point of the front bumper of the vehicle.
  • xCurrentPosBack, yCurrentPosBack, zCurrentPosBack: World coordinates of the middle point of the rear bumper of the vehicle.
  • CurrentSpeed: The current speed (in km/h or mph, depending on the units defined in the network.
  • PreviousSpeed: The speed in the previous simulation step (in km/h or mph, depending on the units defined in the network.
  • TotalDistance: The total distance traveled (meters or feet).
  • SystemGenerationT: The absolute generation time of the vehicle into the system. If no virtual queue was present in its entrance section, it will be the same as the SystemEntranceT.
  • SystemEntranceT: The absolute entrance time of the vehicle into the system, meaning into its entrance section. If no virtual queue is found in the entrance section it will be the same as the SystemGenerationT.
  • SectionEntranceT: The absolute entrance time of the vehicle in the current section.
  • CurrentStopTime: The current stop time.
  • stopped: True if the vehicle remains stopped.
  • mNbLostTurnings The number of lost turnings.
  • theoricalGenerationTime: The theoretical generation time according to the time table.
  • nbStopsDone: The number of completed stops.
  • observedLastStopTime: The total duration of the last stop.
  • observedLastInitialStopTime: The initial time of the last stop.
  • nextStopId: Identifier of the next stop if the vehicle is not currently stopping at a stop or the identifier of the current stop when it is at the stop.
  • offsetInNextStop: Offset assigned to the next stop
  • distanceNextStop: Distance to the next stop (meters or feet).
  • nextServiceTime: If the vehicle is at a stop: the current stop time. If the vehicle is not at a stop; the planned stop time at the next stop(seconds)
  • currentStoppedTimeInBusStop: The stop time so far at the current stop (seconds).
  • currentLoad: Current number of people inside the transit vehicle.
  • energyState Current fuel tank level in combustion vehicles (l) or current battery State of Charge in electric vehicles (kW)

Read the Static Information of a Transit Vehicle

In C++ and Python

Explanation

Read the static information of a transit vehicle. Static information means the characteristics of the vehicle have which were set when the vehicle entered the system.

Format
StaticInfPTVeh AKIPTVehGetStaticInf(int aidVeh);
Parameters
  • aidVeh: vehicle Identifier.
Output
struct StaticInfPTVeh{
    int report;
    int idVeh;
    int type;
    double length;
    double width;
    double maxDesiredSpeed;
    double maxAcceleration;
    double normalDeceleration;
    double maxDeceleration;
    double speedAcceptance;
    double minDistanceVeh;
    double giveWayTime;
    double guidanceAcceptance;
    int enrouted;
    int equipped;
    int tracked;
    bool keepfastLane;
    double safetyMarginFactor;
    double headwayMin;
    double sensitivityFactor;
    double reactionTime;
    double reactionTimeAtStop;
    double reactionTimeAtTrafficLight;
    bool laneChangingCooperation;
    double laneChangingAggressivenessLevel;
    double distanceZoneFactor;
    int maxCapacity;
    int idLine;
    int engineTypeId;
    int EUEmissionId;
    double energyCapacity;
};

where:

  • report: 0, OK, otherwise an error code.
  • idVeh: Vehicle identifier.
  • type: The vehicle type (car, bus, truck, etc.).
  • length: Vehicle length (m or feet, depending on the units defined in the network).
  • width: Vehicle width (m or feet, depending on the units defined in the network).
  • maxDesiredSpeed: Maximum desired speed of the vehicle (km/h or mph, depending on the units defined in the network).
  • maxAcceleration: Maximum acceleration of the vehicle (m/s2 or ft/ s2, depending on the units defined in the network).
  • normalDeceleration: Maximum deceleration of the vehicle that can apply under normal conditions (m/s2 or ft/ s2, depending on the units defined in the network).
  • maxDeceleration: Maximum deceleration of the vehicle that can apply under special conditions (m/s2 or ft/ s2, depending the units defined in the network).
  • speedAcceptance: Degree of acceptance of the speed limits.
  • minDistanceVeh: Distance that the vehicle keeps between itself and the preceding vehicle (meters or feed, depending the units defined in the network).
  • giveWayTime: The time after which the vehicle becomes more aggressive in yield situations (seconds).
  • guidanceAcceptance: The level of compliance of the vehicle to guidance indications.
  • enrouted: 0: vehicle will not update path en route. 1: vehicle will change path en route. This depends on the percentage of vehicles that update path en route defined for the vehicle type.
  • equipped: 0: vehicle is not equipped. 1: vehicle is equipped.
  • tracked: 0: vehicle is not tracked. 1 means vehicle is tracked.
  • keepfastLane: Vehicle keeps to the fast lane during overtaking.
  • safetyMarginFactor: Safety margin factor.
  • headwayMin: Minimum headway to maintain with its leader.
  • sensitivityFactor: Estimation factor of the acceleration of the leader.
  • reactionTime: Reaction time of the vehicle.
  • reactionTimeAtStop: Reaction time of the vehicle when stopped.
  • reactionTimeAtTrafficLight: Reaction time of the vehicle when it is the first in the queue at a traffic light.
  • laneChangingCooperation:
  • laneChangingAggressivenessLevel:
  • distanceZoneFactor:
  • maxCapacity: Maximum number of people inside a Transit vehicle.
  • idLine: Transit line identifier.
  • engineTypeId: Identifier of the engine type of the vehicle (emission, consumption, MFC acceleration models)
  • EUEmissionId: Identifier Standard Emission for LEM. Null= 0, Zero = 1, Euro 0 = 2, Euro 1 = 3, Euro 2 = 4, Euro 3= 5, Euro 4 = 6, Euro 5 = 7, Euro 6 = 8, Euro 6c = 9 (Light Duty vehicles (car, taxi, van) ), Euro I = 10, Euro II = 11, Euro III = 12, Euro IV = 13, Euro IV EGR = 14, Euro V = 15, Euro V EGR = 16, Euro V SCR = 17, Euro VI = 18 (Heavy Duty vehicles (LGV, HGV, Bus, Coach) ).
  • energyCapacity: Total Capacity of the tank (l) or battery (kW)

Modify the Static Information of a Transit Vehicle

In C++ and Python

Explanation

Modify some static parameters of a transit vehicle. Static parameters mean the characteristics of the vehicle which were set when the vehicle entered in the system. The static parameters which can be changed are: type, length, width, maxDesiredSpeed, maxAcceleration, normalDeceleration, maxDeceleration, speedAcceptance, minDistanceVeh, giveWayTime, guidanceAcceptance, enrouted, equipped, tracked, keepfastLane, safetyMarginFactor, headwayMin, sensitivityFactor, reactionTime, reactionTimeAtStop, and reactionTimeAtTrafficLight. Aimsun Next does not store the previous values, so it cannot subsequently recover them.

Format
int AKIPTVehSetStaticInf(int aidVeh, StaticInfPTVeh staticinfVeh)
Parameters
  • aidVeh: Vehicle Identifier.
  • staticinfVeh: New static parameters to be assigned.
Output
  • = 0: No Error.
  • < 0: Error.

Modify the current vehicle load

In C++ and Python

Explanation

Modify the number of people inside the transit vehicle. The new value cannot be greater than the maximum capacity.

Format
int AKIPTVehSetCurrentLoad (int aidVeh, int currentLoad);
Parameters
  • aidVeh: The transit vehicle identifier.
  • currentLoad: The new transit vehicle load.
Output
  • = 0: No error occurred.
  • < 0: Error.

Modify the current vehicle route

In C++ and Python

Explanation

Modify the route of the transit vehicle. This will cause a specified vehicle to divert from its prescribed route, visit bus stops on that diversion, and revert to its original route at the end of the diversion. This function is intended for use in incident handling to temporarily divert transit vehicles or in modeling dynamic interactions between buses and passengers with on-demand diversions.

Format
int     AKIPTVehReroute(int aidVeh, int nbsections, int *aSections, int *aNewstops, double *aDwellTime, double *aOffset);
Parameters
  • aidVeh: The transit vehicle identifier.
  • nbsections: Number of sections provided. Also used to give the size of new stops, dwell time, and offset arrays.
  • aSections: Array containing the section identifiers assigned to the new route. The first section and the last section must be a part of the original transit line.
  • aNewstops: Array containing the stop identifiers assigned to each new section of the route. If there is no stop on that section, set the value to 0.
  • aDwellTime: Array containing the dwell time assigned to the stop on each new section of the route. If there is no stop on that section, set the value to 0.
  • aOffset: Array containing the offset value giving the departure time assigned to the stop on each new section of the route. If there is no stop on that section, set the value to 0.
Output
  • = 0: No error occurred.
  • < 0: Error.

Modify the current transit route

In C++ and Python

Explanation

Modify the route of a transit line. This will add to the route adding a new set of sections after a designated divergence section. The proportion of transit vehicles that then use this route segment can be specified. At the end of the subpath, the route reverts to the original route of the transit line.

One application for this function would be at a halt on a tram line when there are multiple platforms for the same destination and the requirement is to select one. The multiple paths that can be added are shown below.


transit Sub Paths

Format
int     AKIActionAddNextSubPathPTAction(int ang_sectionId, int nbSections, int * aSections, int idline, int VehType, double acomplianceLevel, double visibilityDistance);
Parameters
  • ang_sectionId: The identifier of the last section before the diversion.
  • nbSections: The number of subsequent sections provided.
  • aSections: An array containing the identifiers of the new sections assigned to the new route. The last section in the sub path must also be a section in the transit route.
  • idline: Transit line identifier. Only transit vehicles following this transit line will be affected.
  • VehType: Transit vehicle type. Only transit vehicles of this type will be affected. A value of 0 implies all transit vehicle types following the transit line.
  • acomplianceLevel: The proportion of transit vehicles that will take the new route in the range 0 - 1.
  • visibilityDistance: The distance in meters where vehicles start to see the action.
Output
  • Action reference pointer.
  • NULL/None: Error

Modify the current transit route and associated transit stops

In C++ and Python

Explanation

Modify the route of a transit line adding new sections with associated transit stops.

Format
int     AKIActionAddNextSubPathAndStopsPTAction(int ang_sectionId, int nbSections, int * aSections, int *aStops, double *aDwellTime, double *aOffset, int idline, int VehType, double acomplianceLevel, double , double visibilityDistance);
Parameters
  • ang_sectionId: The identifier of the last section before the diversion.
  • nbSections: The number of subsequent sections provided. This also gives the size of new stops, dwell time, and offset arrays.
  • aSections: An array containing the identifiers of the new sections assigned to the new route. The last section in the sub path must also be a section in the transit route.
  • aStops: An array containing the identifiers of stops assigned in each new section of the route. Where no stop is defined, a zero value is set.
  • aDwellTime: An array containing the dwell time assigned to the stop on each new section of the route. If there is no stop on that section, set the value to 0..
  • aOffset: An array containing the offset value giving the departure time assigned to the stop on each new section of the route. If there is no stop on that section, set the value to 0..
  • idline: Transit line identifier. Only transit vehicles following this transit line are affected.
  • VehType: Transit vehicle type. 0 mean that affects any vehicle type following the transit Line.
  • acomplianceLevel: The proportion of vehicles that will take the new route in the range 0 - 1.
  • visibilityDistance: distance in meters where vehicles start to see the action.
Output
  • Action reference pointer.
  • NULL/None: Error