Skip to main content

combinatorial

Function combinatorial 

Source
pub fn combinatorial<V>(
    agents: &[V],
    tasks: usize,
    capacity: usize,
    bids_per_agent: usize,
) -> Assignment
where V: Valuation<TaskId>,
Expand description

The combinatorial auction of tasks 0..tasks among agents: each agent bids on its bids_per_agent most valuable bundles of at most capacity tasks (see bundle_bids), and winner_determination picks the winners.

With enough bids per agent, this finds the optimal assignment; with few, it trades quality for a smaller search.

ยงExamples

use task_allocation::{TaskId, Valuation, auction::combinatorial};

/// Values each task at a fixed reward, for at most one task.
struct Single([u64; 2]);

impl Valuation<TaskId> for Single {
    fn marginal_score(&self, path: &[TaskId], task: &TaskId) -> Option<u64> {
        path.is_empty().then_some(self.0[task.index()])
    }
}

let agents = [Single([5, 0]), Single([6, 5])];

assert_eq!(combinatorial(&agents, 2, 1, 2).value(), 10);