pub struct TestProblem {}
Expand description

Pseudo problem useful for testing

Implements CostFunction, Operator, Gradient, Jacobian, Hessian, and Anneal.

Implementations§

source§

impl TestProblem

source

pub fn new() -> Self

Create an instance of TestProblem.

§Example
use argmin::core::test_utils::TestProblem;

let problem = TestProblem::new();

Trait Implementations§

source§

impl Anneal for TestProblem

source§

fn anneal( &self, p: &Self::Param, _t: Self::Float ) -> Result<Self::Output, Error>

Returns a clone of parameter p.

§Example
use argmin::core::test_utils::TestProblem;
use argmin::solver::simulatedannealing::Anneal;

let problem = TestProblem::new();

let param = vec![1.0, 2.0];

let res = problem.anneal(&param, 1.0)?;
§

type Param = Vec<f64>

Type of the parameter vector
§

type Output = Vec<f64>

Return type of the anneal function
§

type Float = f64

Precision of floats
source§

impl Clone for TestProblem

source§

fn clone(&self) -> TestProblem

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl CostFunction for TestProblem

source§

fn cost(&self, _p: &Self::Param) -> Result<Self::Output, Error>

Returns 1.0f64.

§Example
use argmin::core::test_utils::TestProblem;
use argmin::core::CostFunction;

let problem = TestProblem::new();

let param = vec![1.0, 2.0];

let res = problem.cost(&param)?;
§

type Param = Vec<f64>

Type of the parameter vector
§

type Output = f64

Type of the return value of the cost function
source§

fn bulk_cost<P>(&self, params: &[P]) -> Result<Vec<Self::Output>, Error>
where P: Borrow<Self::Param> + SyncAlias, Self::Output: SendAlias, Self: SyncAlias,

Compute cost in bulk. If the rayon feature is enabled, multiple calls to cost will be run in parallel using rayon, otherwise they will execute sequentially. If the rayon feature is enabled, parallelization can still be turned off by overwriting parallelize to return false. This can be useful in cases where it is preferable to parallelize only certain parts. Note that even if parallelize is set to false, the parameter vectors and the problem are still required to be Send and Sync. Those bounds are linked to the rayon feature. This method can be overwritten.
source§

fn parallelize(&self) -> bool

Indicates whether to parallelize calls to cost when using bulk_cost. By default returns true, but can be set manually to false if needed. This allows users to turn off parallelization for certain traits implemented on their problem. Note that parallelization requires the rayon feature to be enabled, otherwise calls to cost will be executed sequentially independent of how parallelize is set.
source§

impl Debug for TestProblem

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for TestProblem

source§

fn default() -> TestProblem

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for TestProblem

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Gradient for TestProblem

source§

fn gradient(&self, p: &Self::Param) -> Result<Self::Param, Error>

Returns a clone of parameter p.

§Example
use argmin::core::test_utils::TestProblem;
use argmin::core::Gradient;

let problem = TestProblem::new();

let param = vec![1.0, 2.0];

let res = problem.gradient(&param)?;
§

type Param = Vec<f64>

Type of the parameter vector
§

type Gradient = Vec<f64>

Type of the gradient
source§

fn bulk_gradient<P>(&self, params: &[P]) -> Result<Vec<Self::Gradient>, Error>
where P: Borrow<Self::Param> + SyncAlias, Self::Gradient: SendAlias, Self: SyncAlias,

Compute gradient in bulk. If the rayon feature is enabled, multiple calls to gradient will be run in parallel using rayon, otherwise they will execute sequentially. If the rayon feature is enabled, parallelization can still be turned off by overwriting parallelize to return false. This can be useful in cases where it is preferable to parallelize only certain parts. Note that even if parallelize is set to false, the parameter vectors and the problem are still required to be Send and Sync. Those bounds are linked to the rayon feature. This method can be overwritten.
source§

fn parallelize(&self) -> bool

Indicates whether to parallelize calls to gradient when using bulk_gradient. By default returns true, but can be set manually to false if needed. This allows users to turn off parallelization for certain traits implemented on their problem. Note that parallelization requires the rayon feature to be enabled, otherwise calls to gradient will be executed sequentially independent of how parallelize is set.
source§

impl Hash for TestProblem

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Hessian for TestProblem

source§

fn hessian(&self, p: &Self::Param) -> Result<Self::Hessian, Error>

Returns vec![p, p].

§Example
use argmin::core::test_utils::TestProblem;
use argmin::core::Hessian;

let problem = TestProblem::new();

let param = vec![1.0, 2.0];

let res = problem.hessian(&param)?;
§

type Param = Vec<f64>

Type of the parameter vector
§

type Hessian = Vec<Vec<f64>>

Type of the Hessian
source§

fn bulk_hessian<P>(&self, params: &[P]) -> Result<Vec<Self::Hessian>, Error>
where P: Borrow<Self::Param> + SyncAlias, Self::Hessian: SendAlias, Self: SyncAlias,

Compute hessian in bulk. If the rayon feature is enabled, multiple calls to hessian will be run in parallel using rayon, otherwise they will execute sequentially. If the rayon feature is enabled, parallelization can still be turned off by overwriting parallelize to return false. This can be useful in cases where it is preferable to parallelize only certain parts. Note that even if parallelize is set to false, the parameter vectors and the problem are still required to be Send and Sync. Those bounds are linked to the rayon feature. This method can be overwritten.
source§

fn parallelize(&self) -> bool

Indicates whether to parallelize calls to hessian when using bulk_hessian. By default returns true, but can be set manually to false if needed. This allows users to turn off parallelization for certain traits implemented on their problem. Note that parallelization requires the rayon feature to be enabled, otherwise calls to hessian will be executed sequentially independent of how parallelize is set.
source§

impl Jacobian for TestProblem

source§

fn jacobian(&self, p: &Self::Param) -> Result<Self::Jacobian, Error>

Returns vec![p, p].

§Example
use argmin::core::test_utils::TestProblem;
use argmin::core::Jacobian;

let problem = TestProblem::new();

let param = vec![1.0, 2.0];

let res = problem.jacobian(&param)?;
§

type Param = Vec<f64>

Type of the parameter vector
§

type Jacobian = Vec<Vec<f64>>

Type of the Jacobian
source§

fn bulk_jacobian<P>(&self, params: &[P]) -> Result<Vec<Self::Jacobian>, Error>
where P: Borrow<Self::Param> + SyncAlias, Self::Jacobian: SendAlias, Self: SyncAlias,

Compute jacobian in bulk. If the rayon feature is enabled, multiple calls to jacobian will be run in parallel using rayon, otherwise they will execute sequentially. If the rayon feature is enabled, parallelization can still be turned off by overwriting parallelize to return false. This can be useful in cases where it is preferable to parallelize only certain parts. Note that even if parallelize is set to false, the parameter vectors and the problem are still required to be Send and Sync. Those bounds are linked to the rayon feature. This method can be overwritten.
source§

fn parallelize(&self) -> bool

Indicates whether to parallelize calls to jacobian when using bulk_jacobian. By default returns true, but can be set manually to false if needed. This allows users to turn off parallelization for certain traits implemented on their problem. Note that parallelization requires the rayon feature to be enabled, otherwise calls to jacobian will be executed sequentially independent of how parallelize is set.
source§

impl Operator for TestProblem

source§

fn apply(&self, p: &Self::Param) -> Result<Self::Output, Error>

Returns a clone of parameter p.

§Example
use argmin::core::test_utils::TestProblem;
use argmin::core::Operator;

let problem = TestProblem::new();

let param = vec![1.0, 2.0];

let res = problem.apply(&param)?;
§

type Param = Vec<f64>

Type of the parameter vector
§

type Output = Vec<f64>

Type of the return value of the operator
source§

fn bulk_apply<P>(&self, params: &[P]) -> Result<Vec<Self::Output>, Error>
where P: Borrow<Self::Param> + SyncAlias, Self::Output: SendAlias, Self: SyncAlias,

Compute apply in bulk. If the rayon feature is enabled, multiple calls to apply will be run in parallel using rayon, otherwise they will execute sequentially. If the rayon feature is enabled, parallelization can still be turned off by overwriting parallelize to return false. This can be useful in cases where it is preferable to parallelize only certain parts. Note that even if parallelize is set to false, the parameter vectors and the problem are still required to be Send and Sync. Those bounds are linked to the rayon feature. This method can be overwritten.
source§

fn parallelize(&self) -> bool

Indicates whether to parallelize calls to apply when using bulk_apply. By default returns true, but can be set manually to false if needed. This allows users to turn off parallelization for certain traits implemented on their problem. Note that parallelization requires the rayon feature to be enabled, otherwise calls to apply will be executed sequentially independent of how parallelize is set.
source§

impl PartialEq for TestProblem

source§

fn eq(&self, other: &TestProblem) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for TestProblem

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Copy for TestProblem

source§

impl Eq for TestProblem

source§

impl StructuralPartialEq for TestProblem

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

source§

impl<T> SendAlias for T

source§

impl<T> SyncAlias for T