pub struct Nsga2 { /* private fields */ }Expand description
The optimizer’s settings: the variables, the number of goals, the population, the number of
generations, and the crossover’s and mutation’s parameters. It serializes as its fields, and
reads back through the same checks as Nsga2::new and its with_ methods.
Implementations§
Source§impl Nsga2
impl Nsga2
Sourcepub fn new(
variables: Vec<Variable>,
objectives: usize,
) -> Result<Self, AnalysisError>
pub fn new( variables: Vec<Variable>, objectives: usize, ) -> Result<Self, AnalysisError>
The optimizer over variables for objectives goals, with the paper’s settings: a
population of 100, 250 generations, crossover probability 0.9 and η_c = 20, mutation
probability 1/n and η_m = 20.
§Errors
AnalysisError::TooFew or AnalysisError::Count for no variables or more than
MAX_VARIABLES, or no goals or more than MAX_OBJECTIVES;
AnalysisError::DuplicateVariable for two variables of one name;
AnalysisError::Domain for a variable without two finite bounds, or with one beyond
MAX_BOUND; and
AnalysisError::Unsupported for an integer variable.
Sourcepub fn with_population(self, size: usize) -> Result<Self, AnalysisError>
pub fn with_population(self, size: usize) -> Result<Self, AnalysisError>
The same optimizer with a population of size: an even number, as children are bred two
at a time, from 4 to MAX_POPULATION.
§Errors
AnalysisError::TooFew below 4, AnalysisError::Count above MAX_POPULATION,
and AnalysisError::Domain for an odd size.
Sourcepub fn with_generations(self, generations: usize) -> Result<Self, AnalysisError>
pub fn with_generations(self, generations: usize) -> Result<Self, AnalysisError>
The same optimizer, run for generations generations, the first, random one included: it
evaluates the population that many times.
§Errors
AnalysisError::TooFew for none.
Sourcepub fn with_crossover(
self,
probability: f64,
index: f64,
) -> Result<Self, AnalysisError>
pub fn with_crossover( self, probability: f64, index: f64, ) -> Result<Self, AnalysisError>
The same optimizer with SBX crossing a pair of parents with probability, and
distribution index index: the larger, the closer children fall to their parents.
§Errors
AnalysisError::Domain for a probability outside [0, 1], or an index that is negative
or not finite.
Sourcepub fn with_mutation(
self,
probability: f64,
index: f64,
) -> Result<Self, AnalysisError>
pub fn with_mutation( self, probability: f64, index: f64, ) -> Result<Self, AnalysisError>
The same optimizer with polynomial mutation changing each variable of a child with
probability, and distribution index index: the larger, the smaller the changes.
§Errors
Sourcepub fn objectives(&self) -> usize
pub fn objectives(&self) -> usize
The number of goals.
Sourcepub fn population(&self) -> usize
pub fn population(&self) -> usize
The population’s size.
Sourcepub fn generations(&self) -> usize
pub fn generations(&self) -> usize
The number of generations.
Sourcepub fn start(&self, seed: u64) -> Run
pub fn start(&self, seed: u64) -> Run
Starts a run from seed: its first candidates are the random first population.
Sourcepub fn minimize_constrained(
&self,
seed: u64,
model: impl FnMut(&[f64]) -> Goals,
) -> Result<Front, AnalysisError>
pub fn minimize_constrained( &self, seed: u64, model: impl FnMut(&[f64]) -> Goals, ) -> Result<Front, AnalysisError>
Runs NSGA-II on model under constraints from seed, evaluating each candidate in turn.
§Errors
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Nsga2
impl<'de> Deserialize<'de> for Nsga2
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl StructuralPartialEq for Nsga2
Auto Trait Implementations§
impl Freeze for Nsga2
impl RefUnwindSafe for Nsga2
impl Send for Nsga2
impl Sync for Nsga2
impl Unpin for Nsga2
impl UnsafeUnpin for Nsga2
impl UnwindSafe for Nsga2
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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