-
Notifications
You must be signed in to change notification settings - Fork 1
Home
TraSMAPI is a generic API used as bridge for microscopic traffic simulators (what is a microscopic simulator?) that allows real-time communication between agents in the urban traffic context (such as vehicles, traffic lights and pedestrians) and the environment created by various simulators. This tool was developed at LIACC (Artificial Intelligence and Computer Science Laboratory), University of Porto.
This API offers a higher level of abstraction than most microscopic traffic simulators, in such a way that the solution is independent from the simulator in use.
- Supported Simulators
- Usage
- Basics and Ad-hoc Systems
- Multi-Agent System Support
- Integrating TraSMAPI with JADE
- Statistics Module
- Contributing
- Published papers
- License
Currently, TraSMAPI only works with three microscopic simulators: SUMO, AIMSUN and ITSUMO. To learn how to run the TraSMAPI API for the available simulators please have a look at their respective repository:
TraSMAPI is written in Java. To use it in your project, create a trasmapi folder/package and clone the genAPI folder into there. After that simply implement the methods specified in the API according to the simulator you are using. As previously mentioned, this specialisation already exists for some simulators.
As TraSMAPI was developed with object oriented design at its core, both the simulation objects and the simulator itself are objects of the language.
Any system developed based on this tool will have an instance of the class TraSMAPI. Inside the application, it represents the simulator and any communication with the simulator in general will be made through this instance. A typical setup of the system would be the following code:
TraSMAPI api = new TraSMAPI(simulatorParam);
List<String> params = new ArrayList<String>();
params.add(stringParam);
api.launch(params);
api.connect("localhost", 8820);
In this example, simulatorParam is used to specify the simulator TraSMAPI will use. Subsequently, the simulator is executed with parameters corresponding to a given stringParam. The parameters in particular change from simulator to simulator. In reality, the launch method is optional, as the simulator might be executed independently of TraSMAPI. After being executed, we request TraSMAPI to connect via sockets to the simulator using the method connect.
The basic operation in simulation control is the request to execute a new simulation step. That is achieved though the simulationStep method. A typical execution cycle would look like this:
while(true)
{
if(!api.simulationStep(0))
break;
}
api.close();
The close method is called with the objective of closing the connection to the simulator. If the simulator was launched though the framework, then it will also be closed
The majority of the simulation elements can be manipulated by associating them with objects of the language. Please look into the documentation of each supported simulator in order to understand how to achieve this.
The importance of a multi-agent system (MAS) in this domain has been extensively covered in the literature. You can use TraSMAPI's MAS module for developing these systems.
The multi-agent system is composed of a main controller (an instance of the Mas class) and a series of agents registered in it. (through the addAgent method) During the configuration of the system we need to instantiate several controlling elements, being the main cycle of the system similar to the one presented below:
Mas mas = new Mas();
mas.addAgent(new TrafficLightAgent());
mas.start();
while(true)
{
if(!api.simulationStep(0))
break;
mas.step(1);
}
mas.close();
api.close();
In the previous excerpt, please pay special attention to the use of the agent TrafficLightAgent. System agents correspond to classes derived of the superclass Agent and implement a set of specific methods. This would be a typical agent declaration:
public class TrafficLightAgent extends Agent
{
public void init()
{
(...)
}
public void action()
{
(...)
}
public void newMessage()
{
(...)
}
public void close()
{
(...)
}
}
There are four methods that must be implemented:
- init() is executed when Mas.start() is called. At this time, the developer must be declare the variables which correspond to simulation elements (traffic lights, lanes, induction loops, etc.). This is also where the agent should interacts with agents already in the simulation, exchanging messages relative to the strategy to be applied.
- action() is called at each simulation step; the agent usually queries the simulator and acts upon it.
- newMessage(). Although the agent might read his own inbox at the execution of the action() method, this method is called whenever a new message is delivered; urgent messages that need to be processed in this simulation step shall be treated here.
- close(): this method is executed at the end of the simulation, when Mas.close() is called. The agent must save any persistent information required for the next execution.
Agents may exchange objects of the type Message (or subclasses) between them, through the methods broadcast(Message) or sendMessage(Message, AgentId).
New messages may be read through the method getMessage(); a typical reading cycle will look like this:
public void newMessage()
{
while (getNumMessages() > 0)
{
Message m = getMessage();
(...)
}
}
An agent may obtain the sender through the getFrom() method. As the messages may be subclasses of the class Message, there is no need to parse them. The sender agent encapsulates the information in variables to be read by the receiver.
We are still working in this part of the documentation
We are still working in this part of the documentation
We appreciate any help you could give by improving our code, documention, or by simpling creating an issue. If you wish you can contact us at [email protected]
We don't have any instructions for this. For the understanding of how you could do a new extension to TraSMAPI, have a look in the supported simulators.
- Fork it.
- Create a branch (
git checkout -b my_trasmapi
) - Commit your changes (
git commit -am "Added message type"
) - Push to the branch (
git push origin my_trasmapi
) - Open a Pull Request
- Enjoy a refreshing Diet Coke and wait
- Timóteo, Ivo JPM, et al. "TraSMAPI: An API oriented towards Multi-Agent Systems real-time interaction with multiple Traffic Simulators." Intelligent Transportation Systems (ITSC), 2010 13th International IEEE Conference on. IEEE, 2010.
- Timóteo, Ivo JPM, et al. "Using TraSMAPI for Developing Multi-Agent Intelligent Traffic Management Solutions." Advances on Practical Applications of Agents and Multiagent Systems. Springer Berlin Heidelberg, 2011. 119-128.
- Timóteo, Ivo JPM, et al. "Using TraSMAPI for the assessment of multi-agent traffic management solutions." Progress in Artificial Intelligence 1.2 (2012): 157-164.
- Soares, Guilherme, et al. "An integrated framework for multi-agent traffic simulation using SUMO and JADE." SUMO2013, The first SUMO user conference. 2013.
- Vilarinho, C., Soares, G., Macedo, J., Tavares, J. P. & Rossetti, R. J. F. 2013. Capability-Enhanced AIMSUN with Real-Time Signal Timing Control. Procedia - Social and Behavioral Sciences, EWGT2013 – 16th Meeting of the EURO Working Group on Transportation, 262-221.
- Azevedo, Tiago, et al. "JADE, TraSMAPI and SUMO: a tool-chain for simulating traffic light control." Autonomous Agents and Multiagent Systems (AAMAS), 2014 8th International Workshop on Agents in Traffic and Transportation, ATT'14, held at the Thirteenth International Joint Conference on. 2014
- Vilarinho, C. & Tavares, J. P. 2014. Real-time traffic signal settings at an isolated signal control intersection Transportation Research Procedia (TRPRO264)
- Vilarinho, C., Tavares, J. P. & Rossetti, R. J. 2015. A Conceptual MAS Model for Real-Time Traffic Control. Progress in Artificial Intelligence. Springer.
Copyright 2016 STEMS-group
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.