This project was developed for the "Introduction to Intelligent Autonomous Systems" course and aims to design and implement a decentralized waste collection system using Multi-Agent Systems (MAS) with SPADE. The system will simulate autonomous garbage trucks (agents) that collaborate to efficiently collect waste from various locations within a city, responding dynamically to changes in waste levels and traffic conditions. First Semester of the Third Year of the Bachelor's Degree in Artificial Intelligence and Data Science.
- python -> version 3.9.13
- prosody
- spade
- pygame (for the interface)
To configure Prosody, locate and open the config file 'prosody.cfg.lua', you can just copy what's on the 'prosody.txt' file.
As you can see, this project is a decentralized waste collection system that uses Multi-Agent Systems (MAS) enabled by SPADE, in which we have to take into account the following:
- Truck Agents: Each truck is represented by an agent responsible for collecting waste from assigned areas. Agents should be capable of detecting the fill level of waste bins in their vicinity and making decisions on whether to collect waste based on their current capacity, battery/fuel level, and proximity.
- Bin Agents: Waste bins can also be represented by agents that periodically report their fill levels to nearby truck agents. They will trigger a collection request when they reach a specified threshold.
- Decentralized Decision-Making: The system is decentralized, meaning each truck agent makes its own decisions about when to collect waste, where to go next, and how to optimize its route, without relying on a central controller. Agents communicate with each other to avoid overlapping collection areas and ensure city-wide coverage.
- Dynamic Environment: The environment should include dynamic elements like changing traffic conditions, roadblocks, and variable waste production levels. Truck agents need to adjust their routes in real time based on these conditions.
- Task Allocation and Collaboration: Implement a negotiation or task allocation protocol (e.g., Contract Net Protocol) that allows truck agents to share responsibilities, hand off tasks to nearby agents when overloaded, and ensure efficient coverage of all waste bins.
- Resource Management: Each truck has limited resources, such as fuel or battery life and waste capacity. Agents need to plan efficient routes to minimize fuel consumption and maximize waste collected per trip. They also need to return to a central depot to unload waste or recharge when needed.
- Optimization Metrics: The system should track the following metrics to evaluate performance:
- Total waste collected
- Average collection time for each bin
- Total fuel consumption or battery usage
- Distance traveled by each truck agent
- Efficiency of collaboration and task allocation between agents
- Fault Tolerance: The system should be able to handle scenarios where some agents fail or go offline (e.g., a truck breaking down). Remaining agents should redistribute tasks to ensure uninterrupted waste collection.
Bin Agent
- Waste Monitoring: Tracks and increases waste levels in bins.
- Collection Request: Sends a CFP to Truck Agents when bins are ≥70% full.
- Proposal Evaluation: Analyzes truck proposals to choose the best option based on cost, capacity, and availability.
- Problem Resolution: Resends CFPs if no truck responds. If a responding truck breaks down, it notifies the bin to wait for reassignment. After a delay, the bin resends CFPs if there aren’t trucks available.
Truck Agent
- Proposal Generation Responds to CFPs with cost, fuel, and capacity.
- Route Planning: Calculates the shortest path dynamically using Dijkstra’s algorithm, considering real-time traffic conditions.
- Waste Collection: Navigates to bins, collects waste, and updates its load status.
- Resource Management: Manages fuel, waste load, and capacity; returns to the depot when resources are low.
- Fault Tolerance: Reallocates tasks to other trucks during breakdowns or emergencies
- Exploration: A truck can choose to explore the environment and go to a bin
Between Trucks:
- Allocation of other trucks: If truck1 was on its way to collect the trash from a CFP and in the middle of the path it breaks down, the truck1 communicates with other trucks and they decide wich one should go, if they have availability to do so.
- Claims: When a truck shows interess to go to one bin, the truck sends a Claim to every other truck and he gets an answer from them to check if he is indeed the best truck to complete the collection. The winning truck claims the bin for himself.
- Decline Claim: A truck can deny the acessability of other trucks when they want to claim a bin.
- Release Bin: A truck can indicate to other trucks, after he collects the trash or if the truck for some reason was not able to reach the bin as he planned, that he released the bin that he once claimed .
Between Trucks and Bins:
We realized 3 tests beeing them:
- Test 1: Basic Environment with Constant Waste Accumulation
- Test 2: Basic Environment with Different Waste Accumulation
- Test 3: Dynamic Environment with Different Waste Accumulation In all tests the trucks could break down at anytime. With Dynamic Environment we mean that traffic conditions and road blocks were used. You can see the results of the test on the pdf file.
These were the two layouts we tested on:
When running 'interface.py' you will get to choose the size of the environment. Then you can do the following by pressing the controls: B + Click -> You create a bin on the square you clicked; T + Click -> You create a truck on the square you clicked; R + Click -> You create a roadblock on the square you clicked; 1 -> You set traffict level to 1; 2 -> You set traffict level to 2; 3 -> You set traffict level to 3; 4 -> You set traffict level to 4; 5 -> You set traffict level to 5; 0 -> You set traffict level to 0 (clear all traffic); S -> You START the program
Notes:
- When you create traffic you only define how much traffic is going to be created, you can't choose where as it is generated randomly.
- Traffic is represented as an orange line
- Roadblocks are red squares
- The truck with a semi red square on top of it is broken by a random time, when it is operational again the square will disappear.
- Trucks can break down at any time and randomly, you can't controle it.
- The blue square is the central
- On the right side you have the status were you can see de capacity of each bin (the color changes accordingly) and the capacity of trucks and its fuel
- Assignment.pdf ➡️Project statement
- bin_agent.py ➡️ The code of the bin agent;
- truck_agent.py ➡️ The code of the truck agent;
- environment.py ➡️ The code of the environment;
- interface.py ➡️ The code of the interface;
- prosody.txt ➡️ How your 'prosody.cfg.lua' should be;
- Multi-Agent-Autonomous-Waste-Collection-System.pdf ➡️ The tests and its results and more info about what was done.
This course is part of the first semester of the third year of the Bachelor's Degree in Artificial Intelligence and Data Science at FCUP and FEUP in the academic year 2024/2025. You can find more information about this course at the following link: