diff --git a/src/components/archive.rs b/src/components/archive.rs index 198efa7..0f91e97 100644 --- a/src/components/archive.rs +++ b/src/components/archive.rs @@ -1,12 +1,14 @@ //! Archive for specified parts of population. +use better_any::{Tid, TidAble}; + +use serde::{Deserialize, Serialize}; +use std::cell::Ref; + use crate::{ component::ExecResult, components::Component, problems::SingleObjectiveProblem, state::StateReq, CustomState, Individual, Problem, State, }; -use better_any::{Tid, TidAble}; -use serde::{Deserialize, Serialize}; -use std::cell::Ref; /// An archive for storing elitist individuals. #[derive(Default, Tid)] diff --git a/src/components/measures/convergence.rs b/src/components/measures/convergence.rs index e8a9e97..df693dc 100644 --- a/src/components/measures/convergence.rs +++ b/src/components/measures/convergence.rs @@ -7,17 +7,21 @@ //! Artif Intell Rev 54, 2323–2409 (2021). //! DOI: -use crate::component::AnyComponent; -use crate::components::archive; -use crate::lens::{AnyLens, Lens, LensMap}; -use crate::logging::extractor::{EntryExtractor, EntryName}; -use crate::problems::{KnownOptimumProblem, VectorProblem}; -use crate::utils::SerializablePhantom; -use crate::{Component, CustomState, ExecResult, Problem, SingleObjectiveProblem, State}; +use std::{any::type_name, marker::PhantomData}; + use better_any::{Tid, TidAble}; use derivative::Derivative; use serde::Serialize; -use std::{any::type_name, marker::PhantomData}; + +use crate::{ + component::AnyComponent, + components::archive, + lens::{AnyLens, Lens, LensMap}, + logging::extractor::{EntryExtractor, EntryName}, + problems::{KnownOptimumProblem, VectorProblem}, + utils::SerializablePhantom, + Component, CustomState, ExecResult, Problem, SingleObjectiveProblem, State, +}; /// Trait for representing a component that measures the convergence rate. pub trait ConvergenceRateMeasure: AnyComponent { diff --git a/src/components/measures/improvement.rs b/src/components/measures/improvement.rs index b137398..bc6fb08 100644 --- a/src/components/measures/improvement.rs +++ b/src/components/measures/improvement.rs @@ -6,20 +6,21 @@ //! On the analysis, classification and prediction of metaheuristic algorithm behavior for combinatorial optimization problems. //! 24th European Modeling and Simulation Symposium, EMSS 1, (2012), 368-372 -use crate::component::AnyComponent; -use crate::components::archive; -use crate::lens::{AnyLens, Lens, LensMap}; -use crate::logging::extractor::{EntryExtractor, EntryName}; -use crate::problems::{LimitedVectorProblem, VectorProblem}; -use crate::utils::SerializablePhantom; -use crate::{ - Component, CustomState, ExecResult, Individual, Problem, SingleObjectiveProblem, State, -}; +use std::{any::type_name, marker::PhantomData}; + use better_any::{Tid, TidAble}; use derivative::Derivative; use serde::Serialize; -use std::any::type_name; -use std::marker::PhantomData; + +use crate::{ + component::AnyComponent, + components::archive, + lens::{AnyLens, Lens, LensMap}, + logging::extractor::{EntryExtractor, EntryName}, + problems::{LimitedVectorProblem, VectorProblem}, + utils::SerializablePhantom, + Component, CustomState, ExecResult, Individual, Problem, SingleObjectiveProblem, State, +}; /// Trait for representing a component that measures the improvement of the solutions an operator caused. pub trait ImprovementMeasure: AnyComponent { @@ -82,8 +83,8 @@ impl Improvement { /// Updates the improvement using the total and the percentage vectors. pub fn update(&mut self, improvement: (Vec, Vec)) { let (a, b) = improvement; - self.percent_improvement = a.clone(); - self.total_improvement = b.clone(); + self.percent_improvement.clone_from(&a); + self.total_improvement.clone_from(&b); } } diff --git a/src/components/measures/stepsize.rs b/src/components/measures/stepsize.rs index 911deb3..5b2342c 100644 --- a/src/components/measures/stepsize.rs +++ b/src/components/measures/stepsize.rs @@ -6,20 +6,23 @@ //! On the analysis, classification and prediction of metaheuristic algorithm behavior for combinatorial optimization problems. //! 24th European Modeling and Simulation Symposium, EMSS 1, (2012), 368-372 -use crate::component::AnyComponent; -use crate::components::archive; -use crate::lens::{AnyLens, Lens, LensMap}; -use crate::logging::extractor::{EntryExtractor, EntryName}; -use crate::population::AsSolutions; -use crate::problems::VectorProblem; -use crate::utils::{squared_euclidean, SerializablePhantom}; -use crate::{Component, CustomState, ExecResult, Problem, State}; +use std::{any::type_name, marker::PhantomData}; + use better_any::{Tid, TidAble}; use derivative::Derivative; use serde::Serialize; use statrs::statistics::Statistics; -use std::any::type_name; -use std::marker::PhantomData; + +use crate::{ + component::AnyComponent, + components::archive, + lens::{AnyLens, Lens, LensMap}, + logging::extractor::{EntryExtractor, EntryName}, + population::AsSolutions, + problems::VectorProblem, + utils::{squared_euclidean, SerializablePhantom}, + Component, CustomState, ExecResult, Problem, State, +}; /// Trait for representing a component that measures the step size of the change caused by an operator. pub trait StepSizeMeasure: AnyComponent { @@ -86,8 +89,8 @@ impl StepSize { /// Updates the step size using the step size vector. pub fn update(&mut self, all_steps: (Vec, Vec)) { let (a, b) = all_steps; - self.all_steps = a.clone(); - self.all_var = b.clone(); + self.all_steps.clone_from(&a); + self.all_var.clone_from(&b); self.variance = a.clone().variance(); self.step_size = a.mean(); }