Optimist
0.0.0
A C++ library for optimization
|
Class container for the generic function. More...
#include <Function.hh>
Public Types | |
using | InputType = typename std::conditional_t<FunInDim == 1, Real, Eigen::Vector<Real, FunInDim>> |
using | OutputType = typename std::conditional_t<FunOutDim == 1, Real, Eigen::Vector<Real, FunOutDim>> |
using | FirstDerivativeType = std::conditional_t<FunInDim == 1 && FunOutDim == 1, Real, Eigen::Matrix<Real, FunOutDim, FunInDim>> |
using | SecondDerivativeType |
Public Member Functions | |
Function () | |
std::string | name () const |
void | evaluate (const InputType &x, OutputType &out) const |
void | first_derivative (const InputType &x, FirstDerivativeType &out) const |
void | second_derivative (const InputType &x, SecondDerivativeType &out) const |
constexpr Integer | input_dimension () const |
constexpr Integer | output_dimension () const |
const std::vector< InputType > & | solutions () const |
const std::vector< InputType > & | guesses () const |
const InputType & | solution (const Integer i) const |
const InputType & | guess (const Integer i) const |
bool | is_solution (const InputType &x, const Real tol=EPSILON_LOW) const |
Protected Attributes | |
std::vector< InputType > | m_solutions |
std::vector< InputType > | m_guesses |
The Function
class in Optimist
provides a common interface for representing and evaluating mathematical functions. This class is designed to handle a generic function \(\mathbf{f}(\mathbf{x}): \mathbb{R}^{n} \rightarrow \mathbb{R}^{m}\), where \(\mathbf{x}\) is a vector of input variables and \(\mathbf{f}(\mathbf{x})\) is a vector of output values.
The Function
class serves as a base class for developing specific function representations that can be used in various numerical algorithms. In general, the Function
class and its derived classes are designed to support:
\[ \mathbf{f}(\mathbf{x}) = \mathbf{0} \text{,} \quad \text{with} \quad \mathbf{f}: \mathbb{R}^{n} \rightarrow \mathbb{R}^{n} \text{,} \]
\[ \min_{\mathbf{x}} f(\mathbf{x}) \text{,} \quad f: \mathbb{R}^{n} \rightarrow \mathbb{R} \text{.} \]
If \(n > 1\), the function is multi-dimensional, otherwise, it is scalar. The linear algebra operations required for multi-dimensional functions are performed using the Eigen
library, which provides a high-level interface for matrix operations. For scalar functions ( \(n = 1\)), the base type changes to Real
, a scalar type defined in the Optimist
library.
Real | Scalar number type. |
FunInDim | The function problem input dimension. |
FunOutDim | The function problem output dimension. |
DerivedFunction | Derived function class. |
using Optimist::Function< Real, FunInDim, FunOutDim, DerivedFunction >::FirstDerivativeType = std::conditional_t<FunInDim == 1 && FunOutDim == 1, Real, Eigen::Matrix<Real, FunOutDim, FunInDim>> |
First derivative type.
using Optimist::Function< Real, FunInDim, FunOutDim, DerivedFunction >::InputType = typename std::conditional_t<FunInDim == 1, Real, Eigen::Vector<Real, FunInDim>> |
Basic constants. Input type.
using Optimist::Function< Real, FunInDim, FunOutDim, DerivedFunction >::OutputType = typename std::conditional_t<FunOutDim == 1, Real, Eigen::Vector<Real, FunOutDim>> |
Output type.
using Optimist::Function< Real, FunInDim, FunOutDim, DerivedFunction >::SecondDerivativeType |
Second derivative type.
|
inline |
Suggested initial guess used for testing. Class constructor for the function.
|
inline |
Compute the function value at the input point.
[in] | x | Input point. |
[out] | out | The function value. |
|
inline |
Compute the function first derivative at the input point.
[in] | x | Input point. |
[out] | out | The function first derivative. |
|
inline |
Retrieve the initial guess at the index.
[in] | i | The index of the initial guess. |
|
inline |
Get the vector of initial guesses.
|
inlineconstexpr |
Get the input dimension of the function.
|
inline |
Check if the input point is a known solution.
[in] | x | Input point. |
[in] | tol | Tolerance. |
|
inline |
Get the function name.
|
inlineconstexpr |
Get the output dimension of the function.
|
inline |
Compute the function second derivative at the input point.
[in] | x | Input point. |
[out] | out | The function second derivative. |
|
inline |
Retrieve the known solution at the index.
[in] | i | The index of the known solution. |
|
inline |
Get the vector of known solutions.
|
protected |
Known solutions used for test purposes.
|
protected |