pub struct MetropolisOptimizer { /* private fields */ }Expand description
Optimizer that implements the Metropolis algorithm with constant beta
Implementations§
Source§impl MetropolisOptimizer
impl MetropolisOptimizer
Sourcepub fn new(
patience: usize,
n_trials: usize,
return_iter: usize,
beta: f64,
) -> Self
pub fn new( patience: usize, n_trials: usize, return_iter: usize, beta: f64, ) -> Self
Constructor of MetropolisOptimizer
patience: the optimizer will give up if there is no improvement of the score after this number of iterationsn_trials: number of trial solutions to generate and evaluate at each iterationreturn_iter: returns to the best solution if there is no improvement after this number of iterations.beta: inverse temperature
Sourcepub fn step<M: OptModel<ScoreType = NotNan<f64>>>(
&self,
model: &M,
initial_solution: M::SolutionType,
initial_score: M::ScoreType,
n_iter: usize,
time_limit: Duration,
callback: &mut dyn OptCallbackFn<M::SolutionType, M::ScoreType>,
) -> StepResult<M::SolutionType, M::ScoreType>
pub fn step<M: OptModel<ScoreType = NotNan<f64>>>( &self, model: &M, initial_solution: M::SolutionType, initial_score: M::ScoreType, n_iter: usize, time_limit: Duration, callback: &mut dyn OptCallbackFn<M::SolutionType, M::ScoreType>, ) -> StepResult<M::SolutionType, M::ScoreType>
Perform one optimization step
Trait Implementations§
Source§impl Clone for MetropolisOptimizer
impl Clone for MetropolisOptimizer
Source§fn clone(&self) -> MetropolisOptimizer
fn clone(&self) -> MetropolisOptimizer
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<M: OptModel<ScoreType = NotNan<f64>>> LocalSearchOptimizer<M> for MetropolisOptimizer
impl<M: OptModel<ScoreType = NotNan<f64>>> LocalSearchOptimizer<M> for MetropolisOptimizer
Source§fn optimize(
&self,
model: &M,
initial_solution: <M as OptModel>::SolutionType,
initial_score: <M as OptModel>::ScoreType,
n_iter: usize,
time_limit: Duration,
callback: &mut dyn OptCallbackFn<<M as OptModel>::SolutionType, <M as OptModel>::ScoreType>,
) -> (<M as OptModel>::SolutionType, <M as OptModel>::ScoreType)
fn optimize( &self, model: &M, initial_solution: <M as OptModel>::SolutionType, initial_score: <M as OptModel>::ScoreType, n_iter: usize, time_limit: Duration, callback: &mut dyn OptCallbackFn<<M as OptModel>::SolutionType, <M as OptModel>::ScoreType>, ) -> (<M as OptModel>::SolutionType, <M as OptModel>::ScoreType)
Start optimization
model: the model to optimizeinitial_solution: the initial solution to start optimizationinitial_score: the initial score of the initial solutionn_iter: maximum iterationstime_limit: maximum iteration timecallback: callback function that will be invoked at the end of each iteration
Source§fn run(
&self,
model: &M,
initial_solution_and_score: Option<(M::SolutionType, M::ScoreType)>,
n_iter: usize,
time_limit: Duration,
) -> Result<(M::SolutionType, M::ScoreType), LocalsearchError>
fn run( &self, model: &M, initial_solution_and_score: Option<(M::SolutionType, M::ScoreType)>, n_iter: usize, time_limit: Duration, ) -> Result<(M::SolutionType, M::ScoreType), LocalsearchError>
generate initial solution if not given and run optimization
Source§fn run_with_callback(
&self,
model: &M,
initial_solution_and_score: Option<(M::SolutionType, M::ScoreType)>,
n_iter: usize,
time_limit: Duration,
callback: &mut dyn OptCallbackFn<M::SolutionType, M::ScoreType>,
) -> Result<(M::SolutionType, M::ScoreType), LocalsearchError>
fn run_with_callback( &self, model: &M, initial_solution_and_score: Option<(M::SolutionType, M::ScoreType)>, n_iter: usize, time_limit: Duration, callback: &mut dyn OptCallbackFn<M::SolutionType, M::ScoreType>, ) -> Result<(M::SolutionType, M::ScoreType), LocalsearchError>
generate initial solution if not given and run optimization with callback
impl Copy for MetropolisOptimizer
Auto Trait Implementations§
impl Freeze for MetropolisOptimizer
impl RefUnwindSafe for MetropolisOptimizer
impl Send for MetropolisOptimizer
impl Sync for MetropolisOptimizer
impl Unpin for MetropolisOptimizer
impl UnsafeUnpin for MetropolisOptimizer
impl UnwindSafe for MetropolisOptimizer
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more