Aimsun Next Architecture¶
Aimsun Next is divided in two main parts: the Kernel and the UI. The Kernel contains all the classes that are part of the application domain. The UI contains all the classes needed to implement the user interface (as dialogs, drawers, controls…). In the Model-View-Controller paradigm, the Kernel holds the Model and the UI holds the View and the Controller.
Aimsun Next's application domain is transportation.The system has been designed to support transportation related applications (such as traffic simulators, location problems or assignment models). This specialization of the model offers to the developer facilities not found on other, more general, systems such as streets/roads, OD matrices, control plans, and topology information. It also offer support for general GIS applications (such as the ability to import shapefiles, to add semantic information to these graphic files using database queries or to represent any attribute of any object in the model in many ways). In any case, the objective of Aimsun Next is not to replace a GIS but to offer all the GIS functionalities that a traffic engineer will need, but in a more focused environment.
The Kernel¶
The Kernel is divided into three main components:
- Generic non graphical classes
- Generic graphical classes
- Transportation classes (both graphical and non-graphical).
The generic classes define the basic underpinnings of Aimsun Next. The transportation classes are built using these basic classes.
In particular, the generic classes offer:
- An extensible environment into which new plug-ins can be added in order to provide more functionalities (either adding new classes, new editors, new attributes, etc. or changing the available classes).
- Unlimited Undo and Redo.
- Store and restore of the model in a file.
- 2D and 3D graphical representation.
- Internationalization support.
- Multi-platform support.
Generic Non-Graphical Classes ¶
The figure below shows the main non graphical Kernel classes.
The base classes are:
- GKSystem: A singleton class (only one instance of this class exists) that holds data that is common to any document in a session, these being principally the types, the plug-ins, and the filters; this means that any two documents loaded in Aimsun Next can contain different data but they will share the same types.
- GKModel: A class that holds documents data.
- GKObject: A class inherited by any object in the system (either graphical or not).
In order to access the unique instance of GKSystem the following code is used:
system = GKSystem.getSystem();
The entire data model is organized around the GKModel class. This class contains all the data in a model - in this context a model is a document. For example, a CAD map of a city will be the document, or model, in a CAD application.
Each time a new document is created or opened, an instance of GKModel is created. Each time the document is saved to disk, all the data in the GKModel is saved.
The active model can be accessed using the variable model which is initialized automatically to reference the active model:
model = GKSystem.getSystem().getActiveModel()
A model is a collection of GKObject instances (in fact of subclasses of GKObject). A line, a road, an OD matrix, etc. are all instances of a subclass of GKObject. An instance of a GKObject has a type and a unique model identifier which is assigned when the object is first created and immutable during the life of the object.
The model holds all the data in a catalog (an instance of GKCatalog). This catalog keeps the data organized by type (class) and identifier (unique). Objects within the catalog can be accessed by iterating over objects of a given type, as shown using code such as:
for s in type.values():
print "ID: %i Name: %s" % (s.getId(), s.getName())
This is expanded further in the Basic Scripting Example.
Each instance of an object has a GKType that holds type information. An instance of GKType is shared between all the objects of the same type. This class contains information about the name of the class (an internal name used to uniquely identify the class and an external name to be presented to the user) and all the visible attributes.
Plug-ins¶
Plug-ins are DLLs (in Windows) or shared libraries (in UNIX/LINUX and MacOS X) that are loaded when Aimsun Next starts and that implement new functionalities. The microsimulator the mesosimulator are two examples of plug-ins. A plug-in is always a subclass of GKPlugin.
Filters¶
Filters are classes used to import and export data to or from an Aimsun model. They are instances of GKFilter. Examples of filter include those for DXF import and export, ESRI Shapefiles import, or HTML export.
Organization of Non Graphical Objects¶
Non graphical objects are organized in folders (instances of GKFolder), grouped by type or functionality. This organization appears in the Project Window. Each folder has an internal name used to uniquely identify it and an external name to be presented to the user. Use the internal name to locate a folder, for example when adding a new object.
Generic Graphical Classes¶
The next figure shows the main graphical Kernel classes. GKGeoObject is the class from which inherits any graphical class while GKGeoModel is a holder for all graphical objects.
The basic graphical classes are:
- GKDPoint for single points.
- GKPolyline for a collection of connected segments.
- GKPolygon for closed polylines.
- GKBezierCurve for Bezier curves.
How these objects are drawn is responsibility of the drawers defined in the UI code. However, data for a generic representation is stored using the classes GKViewMode and GKViewModeStyle. These classes hold modifications on how the points, lines, curves and polygons will be drawn based on the values of some of their attributes. They hold, for example, instructions for the drawers to draw a line in red when the length is lower than 20 meters.
Organization of Graphical Objects¶
Graphical objects are organized in layers (instances of GKLayer). A layer can contain one or more objects of any type. A layer can hold objects of different types but usually they will be used to group objects of the same type. Layers are also used in the 2D views to prioritize the draw order (what is drawn over what).
The layers are stored in the geo model. A graphical object will be in the geo model, but another reference to it is placed in the model catalog. If the user decides to hide a graphical object, one possible solution will be remove it from the geo model or more precisely from the layer which holds it. In order to delete a graphical object, it must be removed both from the layer and from the catalog.
Transportation classes¶
Transportation classes are built upon the generic classes. The figure below shows the main graphical transportation classes: sections (called links in other applications), nodes, turnings, centroids, and routes.
Both sections and turnings are Bezier curves. A node has a position but it also has a complex geometry (a set of polygons) that is defined by the geometry of its turnings.
A route is an ordered collection of sections, while a public line adds information for stops.
Aimsun Next also includes non-graphical transportation classes:
- OD matrices, traffic states (demand based on input flows and turning proportions).
- control plans.
- traffic management actions, etc.
Python modules¶
A subset of classes are made available for scripting through a set of Python modules. These provide Python bindings for the original C++ objects and methods.
At the beginning of each script, all the modules that provide the access to the classes that will be used must be imported. For example, to use the features of the Macroscopic modelling in a script, use the following code
from PyMacroToolPlugin import *
PyANGBasic, PyANGKernel, and PyANGGui are automatically imported during scripting environment initialization, so do not need to be listed again in scripts that will be executed from within Aimsun Next. They provide all the fundamental functions of the Aimsun Next Platform. This means that for model editing, no more imports are required.
Classes included in different Python modules ¶
Module | Classes | Functionality |
---|---|---|
PyANGBasic | Q* classes, PyQt, QtCore | Aimsun Next Platform |
PyANGKernel | GK* classes (except GKAimsunExtension and GKGuiSystem) | "" |
PyANGGui | GAnyObjectChooser, GAnyObjectChooser Editor, GDrawer, GDrawerHit, GEditor, GGui, GKGUISystem, , GView, G2DDrawer, G2DView, GViewWindow, G2DViewWindow, G2DViewLayer | "" |
PyANGDTA | DTAManager, DTASimulator, DTACentroid, DTAPossiblePath, DTASection, DTATurning, DTAUserClass, DTAVehicleType, DTAIterativeSimulationResultData | Dynamic Simulators |
PyMacroKernelPlugin | MacroExperiment, MacroScenario, CMacroStatsManager, MacroIterationInfo, MacroExperimentParams, CMacroSection, CMacroTurning, MacroModelPlugin, CMacroConnection, CMacroUserClass, MacroScenarioOutputData, CMacroTrajectory | Macroscopic Kernel |
PyMacroToolPlugin | MacroTraversalPars, MacroTraversal, MacroToolsPlugin, DetectorLocation | Macroscopic Tools |
PyFrankWolfe | CFrankWolfeParams | Frank&Wolfe |
PyMacroAdjustmentPlugin | MacroAdjustment, MacroAdjustmentExperiment, MacroAdjustmentPlugin, MacroAdjustmentScenario, MacroAdjustmentScenarioParams,MacroAdjustmentScenarioUserClassParams, PerCentroidData, PerVehData,ODMaxDeviation | Macroscopic Adjustment |
PyMacroPTPlugin | MacroPTStop, MacroPublicLine, MacroPTSection, MacroPTStation | Transit Assignment |
PyPTAdjustmentPlugin | MacroPTAdjustmentExperiment, MacroPTAdjustmentResult, AdjustmentMeasurementContextPT, PTResultObservation | Transit Adjustment |
PyLandUsePlugin | GKGenerationAttractionFactor, GKGenerationAttractionData, GKGenerationAttractionScenario, GKGenerationAttractionCentroidType, GKTimePeriod, GKTransportationMode, GKTimePeriodNewCmd, GKGenerationAttractionDataSet, CentroidGenerationAttractionData, ExternalData, CentroidDistributionData, GKDistributionDataSet, GenerationAttractionOutput, GKGenerationAttractionExperiment, GKDistributionCentroidType, GKParkingCentroidType, GKGenerationAttractionDataSetAttributeNewCmd | Travel Demand Modelling |
PyANGConsole | ANGConsole | Aimsun Next Console |
PyANGApp | ANGApp | Load Aimsun Next from Python |