### Get Sample Vectors - Trial::x Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.Trial.html Retrieves a matrix view of sample vectors to be evaluated. The matrix has dimensions (dim, lamb) with sample vectors as columns. ```rust pub fn x(&self) -> DMatrixView<'_, f64> ``` -------------------------------- ### Optimizing Rosenbrock Function with CrfmnesOptimizer Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.CrfmnesOptimizer.html Example demonstrating how to use CrfmnesOptimizer to optimize the 40-dimensional Rosenbrock test function. It initializes the optimizer, iteratively asks for trial points, evaluates them using the Rosenbrock function, and updates the optimizer with the results. ```rust use rand::{thread_rng, Rng, SeedableRng}; use rand_xoshiro::Xoroshiro128PlusPlus; use nalgebra::DVector; use crfmnes::{rec_lamb, CrfmnesOptimizer, test_functions::rosenbrock}; let mut rng = Xoroshiro128PlusPlus::seed_from_u64(thread_rng().gen()); let dim = 40; let start_m = DVector::zeros(dim); let start_sigma = 10.0; let mut opt = CrfmnesOptimizer::new(start_m.clone(), start_sigma, rec_lamb(dim), &mut rng); let mut best = f64::INFINITY; let mut best_x = start_m; for i in 0..10000 { let mut trial = opt.ask(&mut rng); let mut evs = Vec::new(); for (i, x) in trial.x().column_iter().enumerate() { let eval = rosenbrock(x.as_slice(), 1.0, 100.0); evs.push(eval); if eval < best { best = eval; best_x = x.into_owned(); } } trial.tell(evs).unwrap(); if best < 0.001 { break; } } println!("best: {} best_x: {}", best, best_x); panic!(); ``` -------------------------------- ### Get Output Type - Same::Output Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.Trial.html Associated type representing the output type, which should always be Self for the Same trait. ```rust type Output = T ``` -------------------------------- ### Get Type ID - Any::type_id Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.Trial.html Gets the TypeId of the current type. This is part of the Any trait implementation. ```rust fn type_id(&self) -> TypeId ``` -------------------------------- ### CrfmnesOptimizer::ask Method Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.CrfmnesOptimizer.html Requests a new set of sample points from the optimizer for evaluation. Returns a `Trial` object containing the points. ```rust pub fn ask<'a, R: Rng>(&'a mut self, rand: &mut R) -> Trial<'a> ``` -------------------------------- ### CrfmnesOptimizer::with_v_D Initialization Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.CrfmnesOptimizer.html Creates a new CrfmnesOptimizer with explicit control over the principal vector 'v' and diagonal scaling matrix 'D'. This allows for more fine-grained control over the sampling distribution. ```rust pub fn with_v_D( m: DVector, sigma: f64, v: DVector, D: DVector, lamb: usize, ) -> Self ``` -------------------------------- ### Trial Struct Source: https://docs.rs/crfmnes/1.0.0/crfmnes/all.html Represents a trial in an optimization process. ```APIDOC ## Struct: Trial ### Description Represents a single trial or iteration within an optimization process. ### Fields (No specific fields documented in the source) ``` -------------------------------- ### CrfmnesOptimizer::new Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.CrfmnesOptimizer.html Creates a new CrfmnesOptimizer with provided parameters and state. Default initializations are used for D and v. ```APIDOC ## CrfmnesOptimizer::new ### Description Create a new optimiser with the provided parameters and state. Default initialisation is used for `D` and `v`. `D` is set to the identity matrix and `v` is set to a small random vector. See `with_v_D` for more details. ### Parameters * **m** (DVector) - The initial mean position vector. * **sigma** (f64) - The initial size, standard deviation, of the sampling distribution. * **lamb** (usize) - The number of sample vectors generated for each trial. * **rand** (&mut R) - A mutable reference to a random number generator. ``` -------------------------------- ### Trial::x Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.Trial.html Retrieves a matrix of sample vectors to be evaluated. ```APIDOC ## Trial::x ```rust pub fn x(&self) -> DMatrixView<'_, f64> ``` ### Description A matrix of shape (dim, lamb) containing sample vectors to be evaluated as columns. ``` -------------------------------- ### Trial::tell Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.Trial.html Reports the results of evaluating sample points and updates the optimiser's internal state. ```APIDOC ## Trial::tell ```rust pub fn tell(&mut self, evs: Vec) -> Result<(), TrialError> ``` ### Description Tell the optimiser the results of evaluating the sample points, updating its internal state based on the results of this trial. The user provided evaluations in `evs` should be in the same order as the columns of `x`. If an error is returned, the state of the parent optimiser is not updated, and a new trial can be attempted. ### Panics If `evs.len() != x.len()` this method will panic. ``` -------------------------------- ### CrfmnesOptimizer::ask Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.CrfmnesOptimizer.html Asks the optimizer to supply a new set of sample points for evaluation. ```APIDOC ## CrfmnesOptimizer::ask ### Description Ask the optimiser to supply a new set of sample points to be evaluated. ### Parameters * **rand** (&mut R) - A mutable reference to a random number generator. ### Returns * **Trial<'a>** - A `Trial` object containing the sample points. ``` -------------------------------- ### Ownership and Cloning Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.CrfmnesOptimizer.html Methods for managing data ownership and cloning. ```APIDOC ## type Owned = T ### Description The resulting type after obtaining ownership. ### Type Alias `Owned` ``` ```APIDOC ## fn to_owned(&self) -> T ### Description Creates owned data from borrowed data, usually by cloning. ### Method `to_owned` ``` ```APIDOC ## fn clone_into(&self, target: &mut T) ### Description Uses borrowed data to replace owned data, usually by cloning. ### Method `clone_into` ``` -------------------------------- ### CrfmnesOptimizer::lamb Method Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.CrfmnesOptimizer.html Returns the number of samples generated per `Trial`. ```rust pub fn lamb(&self) -> usize ``` -------------------------------- ### Report Trial Evaluations - Trial::tell Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.Trial.html Reports the results of evaluating sample points to the optimizer. The evaluations should be in the same order as the columns of `x`. Panics if the number of evaluations does not match the number of sample vectors. ```rust pub fn tell(&mut self, evs: Vec) -> Result<(), TrialError> ``` -------------------------------- ### Test Functions Source: https://docs.rs/crfmnes/1.0.0/crfmnes/all.html A collection of test functions for various optimization algorithms. ```APIDOC ## Module: test_functions ### Description Provides a suite of test functions, likely used for benchmarking or validating optimization algorithms. ### Functions - ackley - ackley_param - beale - booth - rastrigin - rastrigin_a - rosenbrock - rosenbrock_2d - rosenbrock_2d_derivative - rosenbrock_2d_hessian - schaffer_n2 - schaffer_n4 - sphere - sphere_derivative (No specific details on parameters or return types for these functions are provided in the source.) ``` -------------------------------- ### CrfmnesOptimizer CloneToUninit Trait Implementation Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.CrfmnesOptimizer.html A nightly-only experimental API for performing copy-assignment to uninitialized memory. ```rust unsafe fn clone_to_uninit(&self, dest: *mut u8) ``` -------------------------------- ### CrfmnesOptimizer::new Initialization Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.CrfmnesOptimizer.html Creates a new CrfmnesOptimizer with provided mean vector, initial standard deviation, lambda value, and a random number generator. Default initializations are used for internal state variables 'D' and 'v'. ```rust pub fn new( m: DVector, sigma: f64, lamb: usize, rand: &mut R, ) -> Self ``` -------------------------------- ### Trial Struct Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.Trial.html The Trial struct holds the next set of trial values to be evaluated by the user. ```APIDOC ## Struct Trial ```rust pub struct Trial<'a> ``` ### Description The next set of trial values to be evaluated by the user. ``` -------------------------------- ### Create from Subset - SupersetOf::from_subset Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.Trial.html Converts the subset element to the equivalent element of its superset. ```rust fn from_subset(element: &SS) -> SP ``` -------------------------------- ### CrfmnesOptimizer::with_v_D Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.CrfmnesOptimizer.html Creates a new CrfmnesOptimizer with specified parameters and state, allowing fine-grained control over the sampling distribution. ```APIDOC ## CrfmnesOptimizer::with_v_D ### Description Create a new optimiser with the provided parameters and state. The parameters in order of application when generating samples from a standard normal distribution: * `lamb` determines the number of sample vectors generated for each trial. If an odd number is provided, the next even number is used. For smooth, uni-modal problems use the value provided by `rec_lamb`. * `v` is a principal vector which stretches the sampling distribution in an arbitrary direction. * `D` is a diagonal matrix (stored as a vector) which scales the distribution along each axis of the problem. * `sigma` is the initial size, standard deviation, of the sampling distribution. * `m` is the initial mean position vector of the sampling distribution. ### Parameters * **m** (DVector) - The initial mean position vector. * **sigma** (f64) - The initial size, standard deviation, of the sampling distribution. * **v** (DVector) - A principal vector that stretches the sampling distribution. * **D** (DVector) - A diagonal matrix (stored as a vector) that scales the distribution along each axis. * **lamb** (usize) - The number of sample vectors generated for each trial. ### Panics * If `m.is_empty()` * If `lamb < 4` * If `sigma <= 0.0` * If `m.len() != v.len()` * If `m.len() != D.len()` ``` -------------------------------- ### CrfmnesOptimizer::dim Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.CrfmnesOptimizer.html Returns the dimensionality of the problem space. ```APIDOC ## CrfmnesOptimizer::dim ### Description The dimensions of the problem space. ### Returns * **usize** - The dimensionality of the problem space. ``` -------------------------------- ### Type Conversion Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.CrfmnesOptimizer.html Methods for attempting type conversions. ```APIDOC ## type Error = Infallible ### Description The type returned in the event of a conversion error. ### Type Alias `Error` ``` ```APIDOC ## fn try_from(value: U) -> Result>::Error> ### Description Performs the conversion. ### Method `try_from` ``` ```APIDOC ## type Error = >::Error ### Description The type returned in the event of a conversion error. ### Type Alias `Error` ``` ```APIDOC ## fn try_into(self) -> Result>::Error> ### Description Performs the conversion. ### Method `try_into` ``` -------------------------------- ### Subset Operations Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.CrfmnesOptimizer.html Methods for interacting with subsets and supersets. ```APIDOC ## fn to_subset(&self) -> Option ### Description The inverse inclusion map: attempts to construct `self` from the equivalent element of its superset. ### Method `to_subset` ``` ```APIDOC ## fn is_in_subset(&self) -> bool ### Description Checks if `self` is actually part of its subset `T` (and can be converted to it). ### Method `is_in_subset` ``` ```APIDOC ## fn to_subset_unchecked(&self) -> SS ### Description Use with care! Same as `self.to_subset` but without any property checks. Always succeeds. ### Method `to_subset_unchecked` ``` ```APIDOC ## fn from_subset(element: &SS) -> SP ### Description The inclusion map: converts `self` to the equivalent element of its superset. ### Method `from_subset` ``` -------------------------------- ### CrfmnesOptimizer::lamb Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.CrfmnesOptimizer.html Returns the number of samples used per trial. ```APIDOC ## CrfmnesOptimizer::lamb ### Description The number of samples per `Trial`. ### Returns * **usize** - The number of samples per trial. ``` -------------------------------- ### Create From Value - From::from Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.Trial.html Creates a value from another value. This is a blanket implementation of the From trait. ```rust fn from(t: T) -> T ``` -------------------------------- ### Format Trial for Debugging Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.Trial.html Implements the Debug trait for the Trial struct, allowing it to be formatted for debugging purposes. ```rust fn fmt(&self, f: &mut Formatter<'_>) -> Result ``` -------------------------------- ### Convert to Subset - SupersetOf::to_subset Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.Trial.html Attempts to construct the subset from the superset. Returns None if the conversion is not possible. ```rust fn to_subset(&self) -> Option ``` -------------------------------- ### CrfmnesOptimizer::dim Method Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.CrfmnesOptimizer.html Returns the dimensionality of the problem space the optimizer is working in. ```rust pub fn dim(&self) -> usize ``` -------------------------------- ### CrfmnesOptimizer::update_count Method Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.CrfmnesOptimizer.html Returns the number of successful updates that have been performed using the `Trial::tell` method. ```rust pub fn update_count(&self) -> usize ``` -------------------------------- ### CrfmnesOptimizer CloneFrom Implementation Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.CrfmnesOptimizer.html Enables efficient copying of state from one `CrfmnesOptimizer` to another. ```rust fn clone_from(&mut self, source: &Self) ``` -------------------------------- ### CrfmnesOptimizer Clone Implementation Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.CrfmnesOptimizer.html Provides the ability to create a duplicate of a `CrfmnesOptimizer` instance. ```rust fn clone(&self) -> CrfmnesOptimizer ``` -------------------------------- ### schaffer_n2 Source: https://docs.rs/crfmnes/1.0.0/crfmnes/test_functions/fn.schaffer_n2.html The Schaffer test function No. 2 is defined as `f(x_1, x_2) = 0.5 + (sin^2(x_1^2 - x_2^2) - 0.5) / (1 + 0.001*(x_1^2 + x_2^2))^2`. The input `param` is a slice of f64 representing the input variables (expected to be `[x_1, x_2]`), and the function returns a single f64 value which is the result of the function evaluation. The domain for `x_i` is `[-100, 100]`, and the global minimum is at `f(0, 0) = 0`. ```APIDOC ## Function schaffer_n2 ### Description Evaluates the Schaffer test function No. 2. ### Signature ```rust pub fn schaffer_n2(param: &[f64]) -> f64 ``` ### Parameters * `param` (*slice of f64*) - Input parameters for the function. Expected to contain two elements `[x_1, x_2]` where `x_i` are in the range `[-100, 100]`. ### Returns * (*f64*) - The result of the Schaffer N.2 function evaluation. ### Mathematical Definition `f(x_1, x_2) = 0.5 + (sin^2(x_1^2 - x_2^2) - 0.5) / (1 + 0.001*(x_1^2 + x_2^2))^2` ### Global Minimum The global minimum is at `f(0, 0) = 0`. ``` -------------------------------- ### beale Source: https://docs.rs/crfmnes/1.0.0/crfmnes/test_functions/fn.beale.html The Beale test function is defined as f(x1, x2) = (1.5 - x1 + x1*x2)^2 + (2.25 - x1 + x1*x2^2)^2 + (2.625 - x1 + x1*x2^3)^2. The function expects a slice of f64 as input and returns a single f64 value. The domain for x_i is [-4.5, 4.5], and the global minimum is at f(3, 0.5) = 0. ```APIDOC ## Function beale ### Description Beale test function. ### Signature ```rust pub fn beale(param: &[f64]) -> f64 ``` ### Mathematical Definition `f(x_1, x_2) = (1.5 - x_1 + x_1 * x_2)^2 + (2.25 - x_1 + x_1 * x_2^2)^2 + (2.625 - x_1 + x1 * x_2^3)^2` ### Domain `x_i \in [-4.5, 4.5]` ### Global Minimum At `f(x_1, x_2) = f(3, 0.5) = 0` ``` -------------------------------- ### VZip Operation Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.CrfmnesOptimizer.html Method for VZip operation. ```APIDOC ## fn vzip(self) -> V ### Description Performs the VZip operation. ### Method `vzip` ``` -------------------------------- ### CrfmnesOptimizer Struct Source: https://docs.rs/crfmnes/1.0.0/crfmnes/all.html Represents an optimizer within the crfmnes library. ```APIDOC ## Struct: CrfmnesOptimizer ### Description Represents an optimizer. This is a core data structure for managing optimization processes. ### Fields (No specific fields documented in the source) ``` -------------------------------- ### Try Convert From - TryFrom::try_from Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.Trial.html Performs a fallible conversion from one type to another. The associated Error type is Infallible. ```rust fn try_from(value: U) -> Result>::Error> ``` -------------------------------- ### rastrigin Source: https://docs.rs/crfmnes/1.0.0/crfmnes/test_functions/fn.rastrigin.html The Rastrigin function is a non-convex, multimodal function used as a performance test for optimization algorithms. It is known for its large number of local optima. ```APIDOC ## rastrigin ### Description Rastrigin test function. ### Signature ```rust pub fn rastrigin(param: &[f64]) -> f64 ``` ### Parameters * **param** (`&[f64]`) - A slice of f64 representing the input parameters to the function. ``` -------------------------------- ### TrialError Enum Source: https://docs.rs/crfmnes/1.0.0/crfmnes/all.html Defines possible errors that can occur during a trial. ```APIDOC ## Enum: TrialError ### Description Enumerates the different types of errors that can occur during an optimization trial. ### Variants (No specific variants documented in the source) ``` -------------------------------- ### rastrigin_a Source: https://docs.rs/crfmnes/1.0.0/crfmnes/test_functions/fn.rastrigin_a.html Calculates the Rastrigin test function with a customizable parameter 'a'. ```APIDOC ## rastrigin_a ### Description Rastrigin test function. The same as `rastrigin`; however, it allows to set the parameter a. ### Function Signature ```rust pub fn rastrigin_a(param: &[f64], a: f64) -> f64 ``` ### Parameters - **param** (`&[f64]`) - The input array of floating-point numbers. - **a** (`f64`) - The customizable parameter 'a'. ``` -------------------------------- ### CrfmnesOptimizer::update_count Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.CrfmnesOptimizer.html Returns the number of successful updates performed via the `Trial::tell` method. ```APIDOC ## CrfmnesOptimizer::update_count ### Description Returns the number of sucessful updates performed via the `Trial::tell` method. ### Returns * **usize** - The count of successful updates. ``` -------------------------------- ### rec_lamb Function Source: https://docs.rs/crfmnes/1.0.0/crfmnes/all.html A function named rec_lamb. ```APIDOC ## Function: rec_lamb ### Description This function is named rec_lamb. ### Signature (No specific signature documented in the source) ``` -------------------------------- ### Try Convert Into - TryInto::try_into Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.Trial.html Performs a fallible conversion into another type. The associated Error type is determined by the target type's TryFrom implementation. ```rust fn try_into(self) -> Result>::Error> ``` -------------------------------- ### Define Trial Struct Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.Trial.html Defines the Trial struct, which holds private fields and is used to represent a set of trial values for evaluation. ```rust pub struct Trial<'a> { /* private fields */ } ``` -------------------------------- ### Sphere Function Signature Source: https://docs.rs/crfmnes/1.0.0/crfmnes/test_functions/fn.sphere.html Defines the signature for the Sphere test function. It takes a slice of f64 as input and returns a single f64 value. ```rust pub fn sphere(param: &[f64]) -> f64 ``` -------------------------------- ### ackley_param Source: https://docs.rs/crfmnes/1.0.0/crfmnes/test_functions/fn.ackley_param.html Calculates the Ackley test function with customizable parameters a, b, and c. ```APIDOC ## Function ackley_param ### Description Calculates the Ackley test function. This is a variant of the standard `ackley` function that allows for the explicit setting of parameters a, b, and c. ### Signature ```rust pub fn ackley_param(param: &[f64], a: f64, b: f64, c: f64) -> f64 ``` ### Parameters * **param** (`&[f64]`) - The input parameters for the Ackley function. * **a** (`f64`) - The parameter 'a' for the Ackley function. * **b** (`f64`) - The parameter 'b' for the Ackley function. * **c** (`f64`) - The parameter 'c' for the Ackley function. ### Returns * (`f64`) - The result of the Ackley test function. ``` -------------------------------- ### CrfmnesOptimizer Struct Definition Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.CrfmnesOptimizer.html Defines the CrfmnesOptimizer struct, which is a high-dimension black-box optimizer with an ask-tell interface. It has private fields. ```rust pub struct CrfmnesOptimizer { /* private fields */ } ``` -------------------------------- ### rec_lamb Function Signature Source: https://docs.rs/crfmnes/1.0.0/crfmnes/fn.rec_lamb.html Calculates the recommended lambda value for a given dimension size. Higher values may be suitable for noisy or multi-modal objective functions. ```APIDOC ## rec_lamb ### Description Recommended lambda for a given dim size for typical problems. Noisy or highly multi-modal objective functions should use higher values, e.g. 4*dim. ### Signature ```rust pub fn rec_lamb(dim: usize) -> usize ``` ### Parameters #### Path Parameters - **dim** (usize) - The dimension size for which to calculate the recommended lambda. ``` -------------------------------- ### sphere_derivative Source: https://docs.rs/crfmnes/1.0.0/crfmnes/test_functions/fn.sphere_derivative.html Calculates the derivative of the sphere test function. The function is defined as f(x_1, x_2, ..., x_n) = (2 * x_1, 2 * x_2, ... 2 * x_n), where x_i are real numbers and n > 0. ```APIDOC ## Function sphere_derivative ### Description Calculates the derivative of the sphere test function. Defined as: `f(x_1, x_2, ..., x_n) = (2 * x_1, 2 * x_2, ... 2 * x_n)` where `x_i \in (-\infty, \infty)` and `n > 0`. ### Signature ```rust pub fn sphere_derivative(param: &[f64]) -> Vec ``` ### Parameters * `param` (`&[f64]`) - A slice of f64 representing the input vector x. ``` -------------------------------- ### rosenbrock_2d_hessian function signature Source: https://docs.rs/crfmnes/1.0.0/crfmnes/test_functions/fn.rosenbrock_2d_hessian.html This is the function signature for the rosenbrock_2d_hessian function. It takes a slice of f64 parameters and a scalar b, returning a Vec representing the Hessian. ```rust pub fn rosenbrock_2d_hessian(param: &[f64], _a: f64, b: f64) -> Vec ``` -------------------------------- ### Convert Into Value - Into::into Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.Trial.html Converts a value into another type. This is a blanket implementation of the Into trait. ```rust fn into(self) -> U ``` -------------------------------- ### ackley Source: https://docs.rs/crfmnes/1.0.0/crfmnes/test_functions/fn.ackley.html The ackley function computes the Ackley test function value for a given set of parameters. The function is defined mathematically and has a global minimum at zero. ```APIDOC ## ackley ### Description Computes the Ackley test function value. ### Signature ```rust pub fn ackley(param: &[f64]) -> f64 ``` ### Mathematical Definition `f(x_1, x_2, ..., x_n) = - a * exp( -b \sqrt{\frac{1}{d}\sum_{i=1}^n x_i^2 } ) - exp( \frac{1}{d} cos(c * x_i) ) + a + exp(1)` where `x_i \in [-32.768, 32.768]` and usually `a = 10`, `b = 0.2` and `c = 2*pi`. ### Global Minimum The global minimum is at `f(0, 0, ..., 0) = 0`. ``` -------------------------------- ### Convert to Subset Unchecked - SupersetOf::to_subset_unchecked Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.Trial.html Converts to the subset without property checks. Use with care as it always succeeds. ```rust fn to_subset_unchecked(&self) -> SS ``` -------------------------------- ### Define Enum TrialError Source: https://docs.rs/crfmnes/1.0.0/crfmnes/enum.TrialError.html Defines the possible error types that can be returned by `Trial::tell`. In all cases, the trial is discarded and can be retried. ```rust pub enum TrialError { NoFeasibleSolutions, DivByZero, DiagonalInverted, } ``` -------------------------------- ### Check if in Subset - SupersetOf::is_in_subset Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.Trial.html Checks if the current value is part of its subset and can be converted. ```rust fn is_in_subset(&self) -> bool ``` -------------------------------- ### rosenbrock_2d Source: https://docs.rs/crfmnes/1.0.0/crfmnes/test_functions/fn.rosenbrock_2d.html Calculates the value of the 2D Rosenbrock test function. The function is defined as f(x_1, x_2) = (a - x_1)^2 + b * (x_2 - x_1^2)^2. The global minimum is at f(1, 1) = 0. ```APIDOC ## Function rosenbrock_2d ### Description Calculates the value of the 2D Rosenbrock test function. Defined as `f(x_1, x_2) = (a - x_1)^2 + b * (x_2 - x_1^2)^2` where `x_i \in (-\infty, \infty)`. The parameters a and b usually are: `a = 1` and `b = 100`. For 2D problems, this function is much faster than `rosenbrock`. The global minimum is at `f(x_1, x_2) = f(1, 1) = 0`. ### Signature ```rust pub fn rosenbrock_2d(param: &[f64], a: f64, b: f64) -> f64 ``` ### Parameters * `param` (array of f64): The input parameters [x1, x2]. * `a` (f64): The parameter 'a' in the Rosenbrock function definition. * `b` (f64): The parameter 'b' in the Rosenbrock function definition. ### Returns * `f64`: The computed value of the Rosenbrock 2D function. ``` -------------------------------- ### rosenbrock_2d_derivative Source: https://docs.rs/crfmnes/1.0.0/crfmnes/test_functions/fn.rosenbrock_2d_derivative.html Calculates the derivative of the 2D Rosenbrock function. The function takes a slice of f64 as the first parameter, representing the input point, and two f64 values 'a' and 'b' as parameters for the Rosenbrock function. It returns a Vec representing the gradient. ```APIDOC ## rosenbrock_2d_derivative ### Description Derivative of 2D Rosenbrock function. ### Signature ```rust pub fn rosenbrock_2d_derivative(param: &[f64], a: f64, b: f64) -> Vec ``` ### Parameters * **param** (`&[f64]`) - The input point for the function. * **a** (`f64`) - Parameter 'a' for the Rosenbrock function. * **b** (`f64`) - Parameter 'b' for the Rosenbrock function. ### Returns * `Vec` - The gradient of the 2D Rosenbrock function at the given point. ``` -------------------------------- ### Borrow Value - Borrow::borrow Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.Trial.html Immutably borrows the value. This is part of the Borrow trait implementation. ```rust fn borrow(&self) -> &T ``` -------------------------------- ### sphere Source: https://docs.rs/crfmnes/1.0.0/crfmnes/test_functions/fn.sphere.html Calculates the value of the sphere test function. This function is defined as the sum of the squares of its input parameters. ```APIDOC ## sphere ### Description Calculates the value of the sphere test function. ### Function Signature ```rust pub fn sphere(param: &[f64]) -> f64 ``` ### Parameters * **param** (slice of f64) - The input parameters for the function. Each element `x_i` can be any real number. ### Returns * `f64` - The calculated value of the sphere function, which is the sum of the squares of the input parameters. ### Mathematical Definition `f(x_1, x_2, …, x_n) = \sum_{i=1}^n x_i^2` where `x_i \in (-\infty, \infty)` and `n > 0`. ### Global Minimum The global minimum is at `f(0, 0, ..., 0) = 0`. ``` -------------------------------- ### Vector Zip - VZip::vzip Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.Trial.html Performs a vector zip operation. This is part of the VZip trait implementation. ```rust fn vzip(self) -> V ``` -------------------------------- ### rosenbrock_2d_hessian Source: https://docs.rs/crfmnes/1.0.0/crfmnes/test_functions/fn.rosenbrock_2d_hessian.html Calculates the Hessian of the 2D Rosenbrock function. This function is part of the crfmnes::test_functions module. ```APIDOC ## Function rosenbrock_2d_hessian ### Description Hessian of 2D Rosenbrock function ### Signature ```rust pub fn rosenbrock_2d_hessian(param: &[f64], _a: f64, b: f64) -> Vec ``` ### Parameters * `param` (`&[f64]`) - Input parameters for the function. * `_a` (`f64`) - Parameter 'a' for the Rosenbrock function (unused in Hessian calculation). * `b` (`f64`) - Parameter 'b' for the Rosenbrock function. ### Returns * `Vec` - A vector representing the Hessian matrix. ``` -------------------------------- ### Mutably Borrow Value - BorrowMut::borrow_mut Source: https://docs.rs/crfmnes/1.0.0/crfmnes/struct.Trial.html Mutably borrows the value. This is part of the BorrowMut trait implementation. ```rust fn borrow_mut(&mut self) -> &mut T ``` -------------------------------- ### Rosenbrock Function Signature Source: https://docs.rs/crfmnes/1.0.0/crfmnes/test_functions/fn.rosenbrock.html The rosenbrock function calculates the value of the multidimensional Rosenbrock test function. It takes a slice of f64 values representing the coordinates and two f64 parameters, a and b, and returns a single f64 value. ```APIDOC ## rosenbrock ### Description Calculates the value of the multidimensional Rosenbrock test function. Defined as: `f(x_1, x_2, ..., x_n) = \sum_{i=1}^{n-1} \left[ (a - x_i)^2 + b * (x_{i+1} - x_i^2)^2 \right]` where `x_i \in (-\infty, \infty)`. The parameters a and b usually are: `a = 1` and `b = 100`. The global minimum is at `f(x_1, x_2, ..., x_n) = f(1, 1, ..., 1) = 0`. ### Function Signature ```rust pub fn rosenbrock(param: &[f64], a: f64, b: f64) -> f64 ``` ### Parameters - **param** (*&[f64]*) - Required - A slice of f64 values representing the coordinates (x_1, x_2, ..., x_n). - **a** (*f64*) - Required - The parameter 'a' in the Rosenbrock function definition. - **b** (*f64*) - Required - The parameter 'b' in the Rosenbrock function definition. ### Returns - **f64** - The calculated value of the Rosenbrock function. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.