pub fn bundle_bids<V>(
agent: AgentId,
valuation: &V,
tasks: usize,
max_size: usize,
limit: usize,
) -> Vec<BundleBid>Expand description
The limit most valuable bundles of at most max_size tasks out of 0..tasks, as bids of
agent, most valuable first.
A bundle’s value is the best total gain over every order in which the agent can build it,
inserting each task where Valuation::best_insertion puts it. Bundles worth nothing are
left out. Of equally valuable bundles, the one with the smaller tasks comes first.
The search tries every build order of up to max_size tasks: about tasks^max_size
calls to the valuation. Keep max_size small when there are many tasks.
§Examples
use task_allocation::{AgentId, TaskId, Valuation, auction::bundle_bids};
/// Tasks 0 and 1 are worth 3 alone and 10 together; task 2 is worth 4.
struct Pair;
impl Valuation<TaskId> for Pair {
fn marginal_score(&self, path: &[TaskId], task: &TaskId) -> Option<u64> {
let partner = TaskId(1 - task.index().min(1));
Some(match task.index() {
2 => 4,
_ if path.contains(&partner) => 7,
_ => 3,
})
}
}
let bids = bundle_bids(AgentId(0), &Pair, 3, 2, 2);
assert_eq!(bids[0].bundle.path(), [TaskId(0), TaskId(1)]);
assert_eq!(bids[0].value(), 10);
assert_eq!(bids[1].value(), 7);