Optimist
0.0.0
A C++ library for optimization
|
Class container for the cost function. More...
#include <CostFunction.hh>
Inherits Optimist::Function< Real, N, 1, DerivedFunction >.
Public Types | |
using | Vector = typename Function<Real, N, 1, DerivedFunction>::InputType |
using | RowVector = typename Function<Real, N, 1, DerivedFunction>::FirstDerivativeType |
using | Matrix = typename Function<Real, N, 1, DerivedFunction>::SecondDerivativeType |
![]() | |
using | InputType |
using | OutputType |
using | FirstDerivativeType |
using | SecondDerivativeType |
Public Member Functions | |
CostFunction () | |
std::string | name () const |
void | evaluate (const Vector &x, Vector &out) const |
void | gradient (const Vector &x, RowVector &out) const |
void | hessian (const Vector &x, Matrix &out) const |
![]() | |
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 |
Public Attributes | |
friend | Function< Real, N, 1, CostFunction< Real, N, DerivedFunction > > |
Additional Inherited Members | |
![]() | |
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.
N | The dimension of the cost function input. |
DerivedFunction | Derived cost function class. |
using Optimist::CostFunction< Real, N, DerivedFunction >::Matrix = typename Function<Real, N, 1, DerivedFunction>::SecondDerivativeType |
Hessian matrix type.
using Optimist::CostFunction< Real, N, DerivedFunction >::RowVector = typename Function<Real, N, 1, DerivedFunction>::FirstDerivativeType |
Gradient (row) vector type.
using Optimist::CostFunction< Real, N, DerivedFunction >::Vector = typename Function<Real, N, 1, DerivedFunction>::InputType |
Vector type.
|
inline |
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 |
Compute the function second derivative at the input point.
[in] | x | Input point. |
[out] | out | The function second derivative. |
|
inline |
Get the function name.
friend Optimist::CostFunction< Real, N, DerivedFunction >::Function< Real, N, 1, CostFunction< Real, N, DerivedFunction > > |