Aimsun Next Microscopic Simulator Scripts¶
The Aimsun Next Micro Plug-in offers services to simulate microscopic replications, to calculate the average of several replications, to retrieve from a database the simulation results or averages and to calculate a dynamic traversal.
Simulating a Replication¶
To simulate a replication:
- Get the micro replication (in this example, using its identifier).
- Call the "execute" kernel action.
replication = model.getCatalog().find( 1001 )
GKSystem.getSystem().executeAction( "execute", replication, [], "" )
To run a set of simulations in sequence, you just have to provide a list of replications as third argument. Note that you need to state one of the replications as the second argument even though only the ones in the list (third argument), if it is not empty, will be simulated. The second argument needs to be an object of the same type as the ones in the third argument.
replication1 = model.getCatalog().find( 1001 )
replication2 = model.getCatalog().find( 1002 )
GKSystem.getSystem().executeAction( "execute", replication1, [replication1, replication2], "" )
To run a microscopic simulation in animated mode you just have to replace the action execute with the action play.
Calculating an Average¶
To calculate the average of several microscopic replications:
- Get the average (in this example, using its identifier).
- Call the "execute" kernel action.
average = model.getCatalog().find( 1002 )
GKSystem.getSystem().executeAction( "execute", average, [], "" )
Retrieving simulation results from the database¶
To retrieve microscopic simulation results from the database:
- Get the micro replication (in this example, using its identifier).
- Call the "retrieve" kernel action.
replication = model.getCatalog().find( 1001 )
GKSystem.getSystem().executeAction( "retrieve", replication, [], "" )
Retrieving path results from an APA file¶
To retrieve microscopic simulation path results from an APA file:
- Get the micro replication (in this example, using its identifier).
- Call the "retrieve_paths" kernel action.
replication = model.getCatalog().find( 1001 )
GKSystem.getSystem().executeAction( "retrieve_paths", replication, [], "" )
Example: Dynamic traversal calculation¶
To perform a dynamic traversal calculation from a microscopic replication:
- Get the origin microscopic replication (in this example, using its identifier).
- Get the subnetwork from which the traversal will be created (in this example, using its identifier).
- Configure the traversal calculation parameters.
- Call the "generate_traversal" kernel action.
as shown in the example below:
```` replication = model.getCatalog().find( 720 ) subNet = model.getCatalog().find( 675 )
replication.setTraversalSubnet( subNet )
replication.setTraversalRoutes( True )
GKSystem::getSystem().executeAction( "generate_traversal", replication, [], "" )
replication.setTraversalSubnet( None )
```