pumpkin_core/branching/tie_breaking/
tie_breaker.rs

1#[cfg(doc)]
2use crate::branching::variable_selection::VariableSelector;
3
4/// The interface for a tie-breaker which considers additional elements with values; depending on
5/// the [`Direction`] it should only consider variables with the "best" value for selection.
6pub trait TieBreaker<Var, Value> {
7    /// Consider the next additional element with corresponding value
8    fn consider(&mut self, variable: Var, value: Value);
9
10    /// Get the final variable which was selected. After this method is called it resets the stored
11    /// values such that it can be used again. This resetting is done to prevent the tie-breaker
12    /// from returning a variable which has a value which is out-of-date.
13    fn select(&mut self) -> Option<Var>;
14
15    /// Returns whether the tie-breaker is attempting to find the minimum ([`Direction::Minimum`])
16    /// or maximum ([`Direction::Maximum`]) element.
17    fn get_direction(&self) -> Direction;
18}
19
20/// Whether the value comparison should find the maximum [`Direction::Maximum`] variable or the
21/// [`Direction::Minimum`] variable.
22#[derive(Copy, Clone, Debug, PartialEq)]
23pub enum Direction {
24    Maximum,
25    Minimum,
26}