Skip to main content

SolutionCallback

Trait SolutionCallback 

Source
pub trait SolutionCallback<B, R>{
    type Stop;

    // Required method
    fn on_solution_callback(
        &mut self,
        solver: &Solver,
        solution: SolutionReference<'_>,
        brancher: &B,
        resolver: &R,
    ) -> ControlFlow<Self::Stop>;
}
Expand description

Called during optimisation with every encountered solution.

The callback can determine whether to proceed optimising or whether to stop by returning a ControlFlow value. When ControlFlow::Break is returned, a value of SolutionCallback::Stop can be supplied that will be forwarded to the result of the optimisation call.

Required Associated Types§

Source

type Stop

The type of value to return if optimisation should stop.

Required Methods§

Source

fn on_solution_callback( &mut self, solver: &Solver, solution: SolutionReference<'_>, brancher: &B, resolver: &R, ) -> ControlFlow<Self::Stop>

Called when a solution is encountered.

Implementations on Foreign Types§

Source§

impl<T, StopData, B, R> SolutionCallback<B, R> for Option<T>
where T: SolutionCallback<B, R, Stop = StopData>, B: Brancher, R: ConflictResolver,

Source§

type Stop = StopData

Source§

fn on_solution_callback( &mut self, solver: &Solver, solution: SolutionReference<'_>, brancher: &B, resolver: &R, ) -> ControlFlow<<Option<T> as SolutionCallback<B, R>>::Stop>

Implementors§

Source§

impl<T, B, R, StopData> SolutionCallback<B, R> for T
where T: FnMut(&Solver, SolutionReference<'_>, &B, &R) -> ControlFlow<StopData>, B: Brancher, R: ConflictResolver,

Source§

type Stop = StopData