task_allocation/cbba/warp.rs
1//! Bid warping: CBBA for valuations whose marginal gains do not diminish.
2//!
3//! CBBA's consensus assumes that an agent's bids never grow along its bundle. A valuation
4//! that rewards tasks for fitting together breaks that: a courier that already drives to
5//! one site may value a nearby site more than it valued the first one. Two agents can then
6//! outbid each other's first tasks with their second bids, both release everything, and the
7//! team repeats the same round forever (Example 2 of the paper below).
8//!
9//! With warping, an agent still ranks its candidate tasks by their true marginal gain, but
10//! bids at most what it bid on the task it added last:
11//!
12//! ```text
13//! bid = min(gain, last bid in the bundle)
14//! ```
15//!
16//! Shared bids then never grow along a bundle, so consensus behaves as if gains diminished.
17//! An agent can win a task only when its warped bid beats the best known bid, and its
18//! bundle records the warped bids: [`Bundle::value`](crate::Bundle::value) sums the bids,
19//! not the true value of the path.
20//!
21//! The method is bid-warped CBBA (BW-CBBA) from Johnson, Choi, Ponda and How,
22//! "Decentralized Task Allocation Using Local Information Consistency Assumptions", Journal
23//! of Aerospace Information Systems 14(2), 2017 (<https://doi.org/10.2514/1.I010461>),
24//! Sec. IV.B, Eqs. 11–12 and Algorithm 3. The paper proves convergence for its own task
25//! consensus ([`bwtc`](crate::bwtc)) in synchronous, reliable rounds. Here, warping sits on
26//! top of CBBA's conflict table and full-state messages; that it settles over delayed, lost
27//! and reordered messages is shown by property tests, not proven. CBBA's guarantee of half
28//! the optimal value assumes diminishing gains, and does not carry over.
29
30use super::Agent;
31use crate::bundle::Bundle;
32use crate::id::TaskId;
33use crate::valuation::Valuation;
34
35impl<V: Valuation<TaskId>> Agent<V> {
36 /// This agent, warping its bids so that they never grow along its bundle: for
37 /// valuations whose marginal gains do not diminish.
38 ///
39 /// The agent ranks tasks by their true marginal gain, but bids at most what it bid on
40 /// the task it added last; see the [module docs](self) for the method and its limits.
41 ///
42 /// With diminishing gains and [`Replan::Full`](super::Replan::Full), warping changes
43 /// nothing. With [`Replan::Keep`](super::Replan::Keep) it can: a task another agent held
44 /// while this one filled later slots may be worth more, once freed, than the last bid,
45 /// and is then bid at most that.
46 #[must_use]
47 pub const fn with_bid_warping(mut self) -> Self {
48 self.warping = true;
49 self
50 }
51}
52
53/// The most an agent may bid on its next task: with `warping`, the bid on the task it
54/// added last to `bundle`; otherwise, or for an empty bundle, no limit.
55pub(super) fn ceiling(bundle: &Bundle<TaskId>, warping: bool) -> u64 {
56 bundle
57 .entries()
58 .last()
59 .filter(|_| warping)
60 .map_or(u64::MAX, |(_, bid)| bid)
61}
62
63/// Unit tests for bid warping.
64#[cfg(test)]
65mod tests;