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<ForceEigen || (FunInDim > 1), Eigen::Vector<Real, FunInDim>, Real> |
using | OutputType = typename std::conditional_t<ForceEigen || (FunOutDim > 1), Eigen::Vector<Real, FunOutDim>, Real> |
using | FirstDerivativeType = std::conditional_t<ForceEigen || (FunInDim > 1) || (FunOutDim > 1), Eigen::Matrix<Real, FunOutDim, FunInDim>, Real> |
using | SecondDerivativeType |
Public Member Functions | |
FunctionBase () | |
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. |
ForceEigen | Force the use of Eigen types for input and output. |
using Optimist::FunctionBase< Real, FunInDim, FunOutDim, DerivedFunction, ForceEigen >::FirstDerivativeType = std::conditional_t<ForceEigen || (FunInDim > 1) || (FunOutDim > 1), Eigen::Matrix<Real, FunOutDim, FunInDim>, Real> |
First derivative type.
using Optimist::FunctionBase< Real, FunInDim, FunOutDim, DerivedFunction, ForceEigen >::InputType = typename std::conditional_t<ForceEigen || (FunInDim > 1), Eigen::Vector<Real, FunInDim>, Real> |
Basic constants. Input type.
using Optimist::FunctionBase< Real, FunInDim, FunOutDim, DerivedFunction, ForceEigen >::OutputType = typename std::conditional_t<ForceEigen || (FunOutDim > 1), Eigen::Vector<Real, FunOutDim>, Real> |
Output type.
using Optimist::FunctionBase< Real, FunInDim, FunOutDim, DerivedFunction, ForceEigen >::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 |