pub struct SolverBuilder<S: PlanningSolution> { /* private fields */ }Expand description
Builder for constructing a complete solver from configuration.
Note: Phase building now requires typed move selectors, so phases must be constructed directly using the typed phase constructors.
§Example
use solverforge_solver::{SolverBuilder, StepCountTermination};
use solverforge_core::domain::PlanningSolution;
use solverforge_core::score::SimpleScore;
#[derive(Clone, Debug)]
struct MySolution { score: Option<SimpleScore> }
impl PlanningSolution for MySolution {
type Score = SimpleScore;
fn score(&self) -> Option<Self::Score> { self.score }
fn set_score(&mut self, score: Option<Self::Score>) { self.score = score; }
}
let solver = SolverBuilder::<MySolution>::new()
.with_termination(Box::new(StepCountTermination::new(100)))
.build();Implementations§
Source§impl<S: PlanningSolution> SolverBuilder<S>
impl<S: PlanningSolution> SolverBuilder<S>
Sourcepub fn with_phase(self, phase: Box<dyn Phase<S>>) -> Self
pub fn with_phase(self, phase: Box<dyn Phase<S>>) -> Self
Adds a phase to the builder.
Sourcepub fn with_phases(self, phases: Vec<Box<dyn Phase<S>>>) -> Self
pub fn with_phases(self, phases: Vec<Box<dyn Phase<S>>>) -> Self
Adds multiple phases to the builder.
Sourcepub fn with_termination(self, termination: Box<dyn Termination<S>>) -> Self
pub fn with_termination(self, termination: Box<dyn Termination<S>>) -> Self
Sets the termination condition.
Sourcepub fn with_time_limit(self, duration: Duration) -> Self
pub fn with_time_limit(self, duration: Duration) -> Self
Sets a time-based termination condition.
§Example
use solverforge_solver::SolverBuilder;
use solverforge_core::domain::PlanningSolution;
use solverforge_core::score::SimpleScore;
use std::time::Duration;
#[derive(Clone, Debug)]
struct MySolution { score: Option<SimpleScore> }
impl PlanningSolution for MySolution {
type Score = SimpleScore;
fn score(&self) -> Option<Self::Score> { self.score }
fn set_score(&mut self, score: Option<Self::Score>) { self.score = score; }
}
let solver = SolverBuilder::<MySolution>::new()
.with_time_limit(Duration::from_secs(30))
.build();Sourcepub fn with_step_limit(self, steps: u64) -> Self
pub fn with_step_limit(self, steps: u64) -> Self
Sets a step count termination condition.
Sourcepub fn with_termination_from_config(self, config: &TerminationConfig) -> Self
pub fn with_termination_from_config(self, config: &TerminationConfig) -> Self
Builds termination from the configuration.
Trait Implementations§
Source§impl<S: PlanningSolution> Default for SolverBuilder<S>
impl<S: PlanningSolution> Default for SolverBuilder<S>
Auto Trait Implementations§
impl<S> Freeze for SolverBuilder<S>
impl<S> !RefUnwindSafe for SolverBuilder<S>
impl<S> Send for SolverBuilder<S>
impl<S> !Sync for SolverBuilder<S>
impl<S> Unpin for SolverBuilder<S>
impl<S> !UnwindSafe for SolverBuilder<S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more