Skip to main content

LocalSearchSolver

Struct LocalSearchSolver 

Source
pub struct LocalSearchSolver { /* private fields */ }
Expand description

Local search solver utilizing tabu search memory and move neighborhoods.

Implementations§

Source§

impl LocalSearchSolver

Source

pub fn new(tabu_tenure: usize) -> Self

Creates a local search solver with a specified tabu memory size.

Source

pub fn solve( &self, graph: &ValidatedGraph, options: &SolverOptions, ) -> SolveOutcome

Solves the COP problem using Local Search and Tabu memory.

If options.shared_incumbent is set (see crate::solver::SharedIncumbent, used by crate::solver::ParallelSolver), every improving solution found is also offered to it — write-only: unlike crate::solver::BranchAndBoundSolver, this solver has no bound-pruning to benefit from reading it back.

§Complexity

Time per step: O(D * (K + O)) while repairing a conflict (D is the chosen variable’s domain size, K its constraint degree, O the objective count), O(N * D * (K + O)) for a soft-improvement step over all N variables. Nothing is allocated per candidate. Space: O(N + C + T) for the assignment, the violated-constraint set and the tabu tenure.

Source

pub fn repair_from( &self, graph: &ValidatedGraph, baseline: &HashMap<VariableId, i64>, options: &SolverOptions, ) -> SolveOutcome

Repairs baseline instead of building a starting assignment.

The caller already holds a complete assignment and wants it improved, which is the situation every repair search is actually in — after a destroy step, after a model change, after another worker got close. Building a fresh starting assignment there would throw away what is known and cost a propagation pass plus a sweep over every variable, per call.

A value the baseline gives a variable is kept only while its domain still allows it; otherwise the variable is placed like any other. That is what lets a caller pin part of the model by narrowing domains and hand the rest over as-is.

Trait Implementations§

Source§

impl Debug for LocalSearchSolver

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for LocalSearchSolver

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.