pub enum Optimiser {
Nsga {
pop_size: usize,
crossover: SbxParams,
mutation: PmParams,
seed: Option<u64>,
},
Pso {
n_particles: usize,
params: PsoParams,
constraint_handler: Option<ConstraintHandler>,
seed: Option<u64>,
},
}Expand description
Represents the top-level configuration for an optimisation algorithm.
This enum acts as a factory for creating and running different optimisation strategies, such as NSGA-II or Particle Swarm Optimisation.
Variants§
Nsga
Configures the NSGA-II (Non-dominated Sorting Genetic Algorithm II) optimiser.
Fields
Pso
Configures the Particle Swarm Optimisation (PSO) optimiser.
Fields
params: PsoParamsParameters controlling the behaviour of the particles (e.g., inertia, social/cognitive factors).
constraint_handler: Option<ConstraintHandler>An optional constraint handler to apply to the solutions.
Implementations§
Source§impl Optimiser
impl Optimiser
Sourcepub fn solve<F>(
&self,
func: &mut F,
vars: &[Variable],
max_iter: usize,
) -> Result<OptimiserResult>
pub fn solve<F>( &self, func: &mut F, vars: &[Variable], max_iter: usize, ) -> Result<OptimiserResult>
Solves an optimisation problem using the configured algorithm (SERIAL VERSION).
This method is compiled by default. It accepts a mutable closure (FnMut),
allowing the objective function to maintain its own internal state between calls.
§Arguments
func- A mutable closure that takes a slice off64(the variables) and returns the objective values and optional constraint values.vars- A slice defining the bounds for each variable in the search space.max_iter- The maximum number of iterations or generations to run the optimiser for.
§Returns
A Result containing the OptimiserResult on success, or an error string on failure.
Sourcepub fn solve_par<F>(
&self,
func: &F,
vars: &[Variable],
max_iter: usize,
) -> Result<OptimiserResult>
pub fn solve_par<F>( &self, func: &F, vars: &[Variable], max_iter: usize, ) -> Result<OptimiserResult>
Solves an optimisation problem using the configured algorithm (PARALLEL VERSION).
This method is compiled only when the parallel feature is enabled.
It requires a thread-safe closure (Fn + Sync + Send).
See solve [Serial version] for more details
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Optimiser
impl RefUnwindSafe for Optimiser
impl Send for Optimiser
impl Sync for Optimiser
impl Unpin for Optimiser
impl UnwindSafe for Optimiser
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
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>
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>
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