pub struct TestSparseProblem {}
Expand description

A struct representing the following sparse problem.

Example 1: x = [1, 1, 0, 0], y = 1 Example 2: x = [0, 0, 1, 1], y = -1 Example 3: x = [1, 0, 0, 0], y = 1 Example 4: x = [0, 0, 1, 0], y = -1

cost = Σ (w^T x - y)^2

Implements CostFunction and Gradient.

Implementations

Create an instance of TestSparseProblem.

Example
use argmin::core::test_utils::TestSparseProblem;

let problem = TestSparseProblem::new();

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Returns a sum of squared errors.

Example
use argmin::core::test_utils::TestSparseProblem;
use argmin::core::CostFunction;

let problem = TestSparseProblem::new();

let param = vec![1.0, 2.0, 3.0, 4.0];

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

Type of the parameter vector

Tyope of the return value of the cost function

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.

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.

Formats the value using the given formatter. Read more

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

Deserialize this value from the given Serde deserializer. Read more

Returns a gradient of the cost function.

Example
use argmin::core::test_utils::TestSparseProblem;
use argmin::core::Gradient;

let problem = TestSparseProblem::new();

let param = vec![1.0, 2.0, 3.0, 4.0];

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

Type of the parameter vector

Type of the gradient

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.

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.

Feeds this value into the given Hasher. Read more

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

This method tests for self and other values to be equal, and is used by ==. Read more

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

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.