use std::fmt::Debug;
use crate::branching::Brancher;
use crate::branching::BrancherEvent;
use crate::branching::SelectionContext;
#[cfg(doc)]
use crate::branching::branchers::alternating::AlternatingBrancher;
use crate::results::SolutionReference;
pub trait AlternatingStrategy: Debug {
fn next_decision(&mut self, context: &mut SelectionContext) -> BrancherToUse;
fn on_solution(&mut self, _solution: SolutionReference) {}
fn on_restart(&mut self) {}
fn is_restart_pointless(
&mut self,
default_brancher: &mut impl Brancher,
other_brancher: &mut impl Brancher,
) -> bool {
if self.is_using_default_brancher() {
default_brancher.is_restart_pointless()
} else {
other_brancher.is_restart_pointless()
}
}
fn will_always_use_default(&self) -> bool {
false
}
fn is_using_default_brancher(&self) -> bool;
fn subscribe_to_events(&self) -> Vec<BrancherEvent>;
}
#[derive(Debug, Clone, Copy, Hash)]
pub enum BrancherToUse {
Default,
Other,
}
pub mod every_x_restarts;
pub mod every_x_solutions;
pub mod other_only;
pub mod until_solution;