task-allocation
Decentralized multi-agent task allocation in Rust: agents decide among themselves who does which task, exchanging bids whenever they can communicate, without a central authority.
Scope
- Consensus-based bundle algorithm (CBBA) and its variants, converging to conflict-free assignments under delayed and intermittent communication
- Running teams that change: tasks added or retired, agents leaving, without allocating from scratch
- Coupled-constraint CBBA for tasks that depend on or exclude each other, and that must start within limits of each other
- Sequential and combinatorial auctions as baselines
- Task scores from user-supplied costs, such as travel time, deadlines or resource use
- A deterministic simulated network (seeded delays, losses and partitions) to test teams on
- Timed routes: a ready-made path score from travel times, service windows and rewards that decay with the finish time
- Greedy bundle construction from marginal gains, with a check for diminishing gains
- Centralized references: the sequential greedy assignment, and the exhaustive optimum for small instances
Who this is for
- Robot and rover teams, drone swarms and multi-agent simulations that split tasks without a central planner, over links that drop and delay messages. CBBA settles on a conflict-free assignment from whatever each agent hears, and the seeded network simulator tests that before deployment.
- Games and simulations that hand out jobs to workers, units or NPCs, where a job's value depends on what the agent already holds. Integer scores and the seeded simulator keep runs deterministic.
- Researchers comparing allocation algorithms: CBBA, auctions and sequential greedy run on the same valuations, next to an exhaustive optimum for small instances.
- For plain one-to-one assignment with all state in one process, the Hungarian algorithm
(for example
kuhn_munkresin the pathfinding crate) is enough. Timing constraints between agents fit temporal-control, shared resource budgets resource-timeline, and travel costs can come from heuristic-search or sampling-planning.
Usage
A valuation scores what a task is worth to one agent, given the tasks it already holds.
Agents bid with these scores, so a task that does not fit, such as one that would miss its
deadline, scores None and gets no bid. Here, a rover works through its bundle one task
after another.
use Valuation;
/// A task that takes `duration` minutes and must be done `deadline` minutes after the start.
/// A rover that works through its bundle in order.
;
let survey = Task ;
let sample = Task ;
assert_eq!;
// After the survey, the sample would be done at minute 50, past its deadline.
assert_eq!;
Allocation algorithms work on task identifiers. Each agent's valuation looks up what it needs, and an algorithm returns one bundle per agent. Here, two rovers on a line split three sites, each going for what is closest to its last stop:
use ;
/// Site positions along the line, in meters.
const SITES: = ;
/// A rover that earns 100 per site, minus the distance from its last stop.
let rovers = ;
let assignment = sequential_greedy;
assert!;
assert_eq!;
assert_eq!;
Decentralized, each rover runs a CBBA agent and exchanges messages with whoever it can reach. The simulated network here loses a third of all messages and delays the rest by up to four ticks; the rovers still agree on who does what:
use Agent;
use ;
use ;
/// The same rovers as above.
const SITES: = ;
let agents = vec!;
let network = Network ;
let mut simulation = new;
simulation.run_until_settled.expect;
let assignment = simulation.assignment;
assert!;
assert_eq!;
On real hardware, call build_bundle and message on every round and pass each message
that arrives to receive. Agents created with .with_replan(Replan::Full) rebuild their
bundles from scratch every round, which costs more computation, and settle on a sequential
greedy assignment: the centralized one, up to the order in which tied gains are resolved.
The crate is no_std, needs alloc, and has no runtime dependencies.
Examples
Each example pairs the allocation with a sibling crate, without making it a dependency of this one:
-
warehouse_grid: robots on a floor plan, with travel times from A* in heuristic-search, agreeing over a lossy network. -
relay_timing: rovers' plans checked against a handoff between them as a simple temporal network in temporal-control, and reallocated with a tighter deadline when they miss it. -
drone_battery: each drone's battery reserve checked inside its valuation with resource-timeline, and a shared uplink checked across all drones afterwards. -
field_rrt: travel around an obstacle from RRT* in sampling-planning, comparing CBBA with the auctions, sequential greedy and the optimum. -
colony_sim: 50 workers and 200 jobs with deadlines, comparing sequential greedy, a sequential auction and CBBA, then allocating again when a job appears or a worker leaves.
Run one with cargo run --release --example warehouse_grid.
Minimum supported Rust version
Rust 1.85 (edition 2024). The MSRV applies to the library; tests may need a newer toolchain. It may be raised in a minor release when a dependency or a language feature calls for it.
Contributing
See CONTRIBUTING.md.
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.