alpaqa 1.1.0a1
Nonconvex constrained optimization
Loading...
Searching...
No Matches
TypeErasedProblem< Conf, Allocator > Class Template Reference

#include <alpaqa/problem/type-erased-problem.hpp>

Detailed Description

template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
class alpaqa::TypeErasedProblem< Conf, Allocator >

The main polymorphic minimization problem interface.

This class wraps the actual problem implementation class, filling in the missing member functions with sensible defaults, and providing a uniform interface that is used by the solvers.

The problem implementations do not inherit from an abstract base class. Instead, structural typing is used. The ProblemVTable constructor uses reflection to discover which member functions are provided by the problem implementation. See Problem formulations for more information, and C++/CustomCppProblem/main.cpp for an example.

Definition at line 237 of file type-erased-problem.hpp.

Inheritance diagram for TypeErasedProblem< Conf, Allocator >:
Collaboration diagram for TypeErasedProblem< Conf, Allocator >:

Problem dimensions

length_t get_num_variables () const
 [Required] Number of decision variables.
length_t get_num_constraints () const
 [Required] Number of constraints.

Required cost and constraint functions

real_t eval_objective (crvec x) const
 [Required] Function that evaluates the cost, \( f(x) \)
void eval_objective_gradient (crvec x, rvec grad_fx) const
 [Required] Function that evaluates the gradient of the cost, \( \nabla f(x) \)
void eval_constraints (crvec x, rvec gx) const
 [Required] Function that evaluates the constraints, \( g(x) \)
void eval_constraints_gradient_product (crvec x, crvec y, rvec grad_gxy) const
 [Required] Function that evaluates the gradient of the constraints times a vector, \( \nabla g(x)\,y = \tp{\jac_g(x)}y \)

Projections onto constraint sets and proximal mappings

void eval_projecting_difference_constraints (crvec z, rvec e) const
 [Required] Function that evaluates the difference between the given point \( z \) and its projection onto the constraint set \( D \).
void eval_projection_multipliers (rvec y, real_t M) const
 [Required] Function that projects the Lagrange multipliers for ALM.
real_t eval_proximal_gradient_step (real_t γ, crvec x, crvec grad_ψ, rvec x̂, rvec p) const
 [Required] Function that computes a proximal gradient step.
index_t eval_inactive_indices_res_lna (real_t γ, crvec x, crvec grad_ψ, rindexvec J) const
 [Optional] Function that computes the inactive indices \( \mathcal J(x) \) for the evaluation of the linear Newton approximation of the residual, as in [4].

Constraint sets

const Boxget_variable_bounds () const
 [Optional] Get the rectangular constraint set of the decision variables, \( x \in C \).
const Boxget_general_bounds () const
 [Optional] Get the rectangular constraint set of the general constraint function, \( g(x) \in D \).

Functions for second-order solvers

void eval_constraints_jacobian (crvec x, rvec J_values) const
 [Optional] Function that evaluates the nonzero values of the Jacobian matrix of the constraints, \( \jac_g(x) \)
Sparsity get_constraints_jacobian_sparsity () const
 [Optional] Function that returns (a view of) the sparsity pattern of the Jacobian of the constraints.
void eval_grad_gi (crvec x, index_t i, rvec grad_gi) const
 [Optional] Function that evaluates the gradient of one specific constraint, \( \nabla g_i(x) \)
void eval_lagrangian_hessian_product (crvec x, crvec y, real_t scale, crvec v, rvec Hv) const
 [Optional] Function that evaluates the Hessian of the Lagrangian multiplied by a vector, \( \nabla_{xx}^2L(x, y)\,v \)
void eval_lagrangian_hessian (crvec x, crvec y, real_t scale, rvec H_values) const
 [Optional] Function that evaluates the nonzero values of the Hessian of the Lagrangian, \( \nabla_{xx}^2L(x, y) \)
Sparsity get_lagrangian_hessian_sparsity () const
 [Optional] Function that returns (a view of) the sparsity pattern of the Hessian of the Lagrangian.
void eval_augmented_lagrangian_hessian_product (crvec x, crvec y, crvec Σ, real_t scale, crvec v, rvec Hv) const
 [Optional] Function that evaluates the Hessian of the augmented Lagrangian multiplied by a vector, \( \nabla_{xx}^2L_\Sigma(x, y)\,v \)
void eval_augmented_lagrangian_hessian (crvec x, crvec y, crvec Σ, real_t scale, rvec H_values) const
 [Optional] Function that evaluates the nonzero values of the Hessian of the augmented Lagrangian, \( \nabla_{xx}^2L_\Sigma(x, y) \)
Sparsity get_augmented_lagrangian_hessian_sparsity () const
 [Optional] Function that returns (a view of) the sparsity pattern of the Hessian of the augmented Lagrangian.

Combined evaluations

real_t eval_objective_and_gradient (crvec x, rvec grad_fx) const
 [Optional] Evaluate both \( f(x) \) and its gradient, \( \nabla f(x) \).
real_t eval_objective_and_constraints (crvec x, rvec g) const
 [Optional] Evaluate both \( f(x) \) and \( g(x) \).
void eval_objective_gradient_and_constraints_gradient_product (crvec x, crvec y, rvec grad_f, rvec grad_gxy) const
 [Optional] Evaluate both \( \nabla f(x) \) and \( \nabla g(x)\,y \).
void eval_lagrangian_gradient (crvec x, crvec y, rvec grad_L, rvec work_n) const
 [Optional] Evaluate the gradient of the Lagrangian \( \nabla_x L(x, y) = \nabla f(x) + \nabla g(x)\,y \)

Augmented Lagrangian

real_t eval_augmented_lagrangian (crvec x, crvec y, crvec Σ, rvec ŷ) const
 [Optional] Calculate both ψ(x) and the vector ŷ that can later be used to compute ∇ψ.
void eval_augmented_lagrangian_gradient (crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m) const
 [Optional] Calculate the gradient ∇ψ(x).
real_t eval_augmented_lagrangian_and_gradient (crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m) const
 [Optional] Calculate both ψ(x) and its gradient ∇ψ(x).

Checks

void check () const
 [Optional] Check that the problem formulation is well-defined, the dimensions match, etc.

Metadata

std::string get_name () const
 [Optional] Get a descriptive name for the problem.

Querying specialized implementations

bool provides_eval_inactive_indices_res_lna () const
 Returns true if the problem provides an implementation of eval_inactive_indices_res_lna.
bool provides_eval_constraints_jacobian () const
 Returns true if the problem provides an implementation of eval_constraints_jacobian.
bool provides_get_constraints_jacobian_sparsity () const
 Returns true if the problem provides an implementation of get_constraints_jacobian_sparsity.
bool provides_eval_grad_gi () const
 Returns true if the problem provides an implementation of eval_grad_gi.
bool provides_eval_lagrangian_hessian_product () const
 Returns true if the problem provides an implementation of eval_lagrangian_hessian_product.
bool provides_eval_lagrangian_hessian () const
 Returns true if the problem provides an implementation of eval_lagrangian_hessian.
bool provides_get_lagrangian_hessian_sparsity () const
 Returns true if the problem provides an implementation of get_lagrangian_hessian_sparsity.
bool provides_eval_augmented_lagrangian_hessian_product () const
 Returns true if the problem provides an implementation of eval_augmented_lagrangian_hessian_product.
bool provides_eval_augmented_lagrangian_hessian () const
 Returns true if the problem provides an implementation of eval_augmented_lagrangian_hessian.
bool provides_get_augmented_lagrangian_hessian_sparsity () const
 Returns true if the problem provides an implementation of get_augmented_lagrangian_hessian_sparsity.
bool provides_eval_objective_and_gradient () const
 Returns true if the problem provides a specialized implementation of eval_objective_and_gradient, false if it uses the default implementation.
bool provides_eval_objective_and_constraints () const
 Returns true if the problem provides a specialized implementation of eval_objective_and_constraints, false if it uses the default implementation.
bool provides_eval_objective_gradient_and_constraints_gradient_product () const
 Returns true if the problem provides a specialized implementation of eval_objective_gradient_and_constraints_gradient_product, false if it uses the default implementation.
bool provides_eval_lagrangian_gradient () const
 Returns true if the problem provides a specialized implementation of eval_lagrangian_gradient, false if it uses the default implementation.
bool provides_eval_augmented_lagrangian () const
 Returns true if the problem provides a specialized implementation of eval_augmented_lagrangian, false if it uses the default implementation.
bool provides_eval_augmented_lagrangian_gradient () const
 Returns true if the problem provides a specialized implementation of eval_augmented_lagrangian_gradient, false if it uses the default implementation.
bool provides_eval_augmented_lagrangian_and_gradient () const
 Returns true if the problem provides a specialized implementation of eval_augmented_lagrangian_and_gradient, false if it uses the default implementation.
bool provides_get_variable_bounds () const
 Returns true if the problem provides an implementation of get_variable_bounds.
bool provides_get_general_bounds () const
 Returns true if the problem provides an implementation of get_general_bounds.
bool provides_check () const
 Returns true if the problem provides an implementation of check.
bool provides_get_name () const
 Returns true if the problem provides an implementation of get_name.

Querying available functions

bool supports_eval_augmented_lagrangian_hessian_product () const
 Returns true if eval_augmented_lagrangian_hessian_product can be called.
bool supports_eval_augmented_lagrangian_hessian () const
 Returns true if eval_augmented_lagrangian_hessian can be called.

Helpers

real_t calc_ŷ_dᵀŷ (rvec g_ŷ, crvec y, crvec Σ) const
 Given g(x), compute the intermediate results ŷ and dᵀŷ that can later be used to compute ψ(x) and ∇ψ(x).

Public Types

using Box = alpaqa::Box<config_t>
using VTable = ProblemVTable<config_t>
using allocator_type = Allocator
using TypeErased = guanaqo::TypeErased<VTable, allocator_type>

Static Public Member Functions

template<class T, class... Args>
static TypeErasedProblem make (Args &&...args)

Member Typedef Documentation

◆ Box

template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
using Box = alpaqa::Box<config_t>

Definition at line 240 of file type-erased-problem.hpp.

◆ VTable

template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
using VTable = ProblemVTable<config_t>

Definition at line 241 of file type-erased-problem.hpp.

◆ allocator_type

template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
using allocator_type = Allocator

Definition at line 242 of file type-erased-problem.hpp.

◆ TypeErased

template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
using TypeErased = guanaqo::TypeErased<VTable, allocator_type>

Definition at line 243 of file type-erased-problem.hpp.

Member Function Documentation

◆ make()

template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
template<class T, class... Args>
TypeErasedProblem make ( Args &&... args)
inlinestatic

Definition at line 253 of file type-erased-problem.hpp.

◆ get_num_variables()

template<Config Conf, class Allocator>
auto get_num_variables ( ) const
nodiscard

[Required] Number of decision variables.

Definition at line 763 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ get_num_constraints()

template<Config Conf, class Allocator>
auto get_num_constraints ( ) const
nodiscard

[Required] Number of constraints.

Definition at line 767 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ eval_objective()

template<Config Conf, class Allocator>
auto eval_objective ( crvec x) const
nodiscard

[Required] Function that evaluates the cost, \( f(x) \)

Parameters
[in]xDecision variable \( x \in \R^n \)

Definition at line 792 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ eval_objective_gradient()

template<Config Conf, class Allocator>
void eval_objective_gradient ( crvec x,
rvec grad_fx ) const

[Required] Function that evaluates the gradient of the cost, \( \nabla f(x) \)

Parameters
[in]xDecision variable \( x \in \R^n \)
[out]grad_fxGradient of cost function \( \nabla f(x) \in \R^n \)

Definition at line 796 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ eval_constraints()

template<Config Conf, class Allocator>
void eval_constraints ( crvec x,
rvec gx ) const

[Required] Function that evaluates the constraints, \( g(x) \)

Parameters
[in]xDecision variable \( x \in \R^n \)
[out]gxValue of the constraints \( g(x) \in \R^m \)

Definition at line 800 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ eval_constraints_gradient_product()

template<Config Conf, class Allocator>
void eval_constraints_gradient_product ( crvec x,
crvec y,
rvec grad_gxy ) const

[Required] Function that evaluates the gradient of the constraints times a vector, \( \nabla g(x)\,y = \tp{\jac_g(x)}y \)

Parameters
[in]xDecision variable \( x \in \R^n \)
[in]yVector \( y \in \R^m \) to multiply the gradient by
[out]grad_gxyGradient of the constraints \( \nabla g(x)\,y \in \R^n \)

Definition at line 804 of file type-erased-problem.hpp.

◆ eval_projecting_difference_constraints()

template<Config Conf, class Allocator>
void eval_projecting_difference_constraints ( crvec z,
rvec e ) const

[Required] Function that evaluates the difference between the given point \( z \) and its projection onto the constraint set \( D \).

Parameters
[in]zSlack variable, \( z \in \R^m \)
[out]eThe difference relative to its projection, \( e = z - \Pi_D(z) \in \R^m \)
Note
z and e can refer to the same vector.

Definition at line 772 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ eval_projection_multipliers()

template<Config Conf, class Allocator>
void eval_projection_multipliers ( rvec y,
real_t M ) const

[Required] Function that projects the Lagrange multipliers for ALM.

Parameters
[in,out]yMultipliers, \( y \leftarrow \Pi_Y(y) \in \R^m \)
[in]MThe radius/size of the set \( Y \). See max_multiplier.

Definition at line 777 of file type-erased-problem.hpp.

◆ eval_proximal_gradient_step()

template<Config Conf, class Allocator>
auto eval_proximal_gradient_step ( real_t γ,
crvec x,
crvec grad_ψ,
rvec ,
rvec p ) const

[Required] Function that computes a proximal gradient step.

Parameters
[in]γStep size, \( \gamma \in \R_{>0} \)
[in]xDecision variable \( x \in \R^n \)
[in]grad_ψGradient of the subproblem cost, \( \nabla\psi(x) \in \R^n \)
[out]Next proximal gradient iterate, \( \hat x = T_\gamma(x) = \prox_{\gamma h}(x - \gamma\nabla\psi(x)) \in \R^n \)
[out]pThe proximal gradient step, \( p = \hat x - x \in \R^n \)
Returns
The nonsmooth function evaluated at x̂, \( h(\hat x) \).
Note
The vector \( p \) is often used in stopping criteria, so its numerical accuracy is more important than that of \( \hat x \).

Definition at line 781 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ eval_inactive_indices_res_lna()

template<Config Conf, class Allocator>
auto eval_inactive_indices_res_lna ( real_t γ,
crvec x,
crvec grad_ψ,
rindexvec J ) const
nodiscard

[Optional] Function that computes the inactive indices \( \mathcal J(x) \) for the evaluation of the linear Newton approximation of the residual, as in [4].

Parameters
[in]γStep size, \( \gamma \in \R_{>0} \)
[in]xDecision variable \( x \in \R^n \)
[in]grad_ψGradient of the subproblem cost, \( \nabla\psi(x) \in \R^n \)
[out]JThe indices of the components of \( x \) that are in the index set \( \mathcal J(x) \). In ascending order, at most n.
Returns
The number of inactive constraints, \( \# \mathcal J(x) \).

For example, in the case of box constraints, we have

\[ \mathcal J(x) \defeq \defset{i \in \N_{[0, n-1]}}{\underline x_i \lt x_i - \gamma\nabla_{\!x_i}\psi(x) \lt \overline x_i}. \]

Definition at line 787 of file type-erased-problem.hpp.

◆ get_variable_bounds()

template<Config Conf, class Allocator>
auto get_variable_bounds ( ) const
nodiscard

[Optional] Get the rectangular constraint set of the decision variables, \( x \in C \).

Definition at line 894 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ get_general_bounds()

template<Config Conf, class Allocator>
auto get_general_bounds ( ) const
nodiscard

[Optional] Get the rectangular constraint set of the general constraint function, \( g(x) \in D \).

Definition at line 898 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ eval_constraints_jacobian()

template<Config Conf, class Allocator>
void eval_constraints_jacobian ( crvec x,
rvec J_values ) const

[Optional] Function that evaluates the nonzero values of the Jacobian matrix of the constraints, \( \jac_g(x) \)

Parameters
[in]xDecision variable \( x \in \R^n \)
[out]J_valuesNonzero values of the Jacobian \( \jac_g(x) \in \R^{m\times n} \)

Required for second-order solvers only.

Definition at line 813 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ get_constraints_jacobian_sparsity()

template<Config Conf, class Allocator>
auto get_constraints_jacobian_sparsity ( ) const
nodiscard

[Optional] Function that returns (a view of) the sparsity pattern of the Jacobian of the constraints.

Required for second-order solvers only.

Definition at line 817 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ eval_grad_gi()

template<Config Conf, class Allocator>
void eval_grad_gi ( crvec x,
index_t i,
rvec grad_gi ) const

[Optional] Function that evaluates the gradient of one specific constraint, \( \nabla g_i(x) \)

Parameters
[in]xDecision variable \( x \in \R^n \)
[in]iWhich constraint \( 0 \le i \lt m \)
[out]grad_giGradient of the constraint \( \nabla g_i(x) \in \R^n \)

Required for second-order solvers only.

Definition at line 809 of file type-erased-problem.hpp.

◆ eval_lagrangian_hessian_product()

template<Config Conf, class Allocator>
void eval_lagrangian_hessian_product ( crvec x,
crvec y,
real_t scale,
crvec v,
rvec Hv ) const

[Optional] Function that evaluates the Hessian of the Lagrangian multiplied by a vector, \( \nabla_{xx}^2L(x, y)\,v \)

Parameters
[in]xDecision variable \( x \in \R^n \)
[in]yLagrange multipliers \( y \in \R^m \)
[in]scaleScale factor for the cost function.
[in]vVector to multiply by \( v \in \R^n \)
[out]HvHessian-vector product \( \nabla_{xx}^2 L(x, y)\,v \in \R^{n} \)

Required for second-order solvers only.

Definition at line 821 of file type-erased-problem.hpp.

◆ eval_lagrangian_hessian()

template<Config Conf, class Allocator>
void eval_lagrangian_hessian ( crvec x,
crvec y,
real_t scale,
rvec H_values ) const

[Optional] Function that evaluates the nonzero values of the Hessian of the Lagrangian, \( \nabla_{xx}^2L(x, y) \)

Parameters
[in]xDecision variable \( x \in \R^n \)
[in]yLagrange multipliers \( y \in \R^m \)
[in]scaleScale factor for the cost function.
[out]H_valuesNonzero values of the Hessian \( \nabla_{xx}^2 L(x, y) \in \R^{n\times n} \).

Required for second-order solvers only.

Definition at line 827 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ get_lagrangian_hessian_sparsity()

template<Config Conf, class Allocator>
auto get_lagrangian_hessian_sparsity ( ) const
nodiscard

[Optional] Function that returns (a view of) the sparsity pattern of the Hessian of the Lagrangian.

Required for second-order solvers only.

Definition at line 832 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ eval_augmented_lagrangian_hessian_product()

template<Config Conf, class Allocator>
void eval_augmented_lagrangian_hessian_product ( crvec x,
crvec y,
crvec Σ,
real_t scale,
crvec v,
rvec Hv ) const

[Optional] Function that evaluates the Hessian of the augmented Lagrangian multiplied by a vector, \( \nabla_{xx}^2L_\Sigma(x, y)\,v \)

Parameters
[in]xDecision variable \( x \in \R^n \)
[in]yLagrange multipliers \( y \in \R^m \)
[in]ΣPenalty weights \( \Sigma \)
[in]scaleScale factor for the cost function.
[in]vVector to multiply by \( v \in \R^n \)
[out]HvHessian-vector product \( \nabla_{xx}^2 L_\Sigma(x, y)\,v \in \R^{n} \)

Required for second-order solvers only.

Definition at line 836 of file type-erased-problem.hpp.

◆ eval_augmented_lagrangian_hessian()

template<Config Conf, class Allocator>
void eval_augmented_lagrangian_hessian ( crvec x,
crvec y,
crvec Σ,
real_t scale,
rvec H_values ) const

[Optional] Function that evaluates the nonzero values of the Hessian of the augmented Lagrangian, \( \nabla_{xx}^2L_\Sigma(x, y) \)

Parameters
[in]xDecision variable \( x \in \R^n \)
[in]yLagrange multipliers \( y \in \R^m \)
[in]ΣPenalty weights \( \Sigma \)
[in]scaleScale factor for the cost function.
[out]H_valuesNonzero values of the Hessian \( \nabla_{xx}^2 L_\Sigma(x, y) \in \R^{n\times n} \)

Required for second-order solvers only.

Definition at line 841 of file type-erased-problem.hpp.

◆ get_augmented_lagrangian_hessian_sparsity()

template<Config Conf, class Allocator>
auto get_augmented_lagrangian_hessian_sparsity ( ) const
nodiscard

[Optional] Function that returns (a view of) the sparsity pattern of the Hessian of the augmented Lagrangian.

Required for second-order solvers only.

Definition at line 847 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ eval_objective_and_gradient()

template<Config Conf, class Allocator>
auto eval_objective_and_gradient ( crvec x,
rvec grad_fx ) const

[Optional] Evaluate both \( f(x) \) and its gradient, \( \nabla f(x) \).

Default implementation:
ProblemVTable::default_eval_objective_and_gradient

Definition at line 852 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ eval_objective_and_constraints()

template<Config Conf, class Allocator>
auto eval_objective_and_constraints ( crvec x,
rvec g ) const

[Optional] Evaluate both \( f(x) \) and \( g(x) \).

Default implementation:
ProblemVTable::default_eval_objective_and_constraints

Definition at line 857 of file type-erased-problem.hpp.

◆ eval_objective_gradient_and_constraints_gradient_product()

template<Config Conf, class Allocator>
void eval_objective_gradient_and_constraints_gradient_product ( crvec x,
crvec y,
rvec grad_f,
rvec grad_gxy ) const

[Optional] Evaluate both \( \nabla f(x) \) and \( \nabla g(x)\,y \).

Default implementation:
ProblemVTable::default_eval_objective_gradient_and_constraints_gradient_product

Definition at line 862 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ eval_lagrangian_gradient()

template<Config Conf, class Allocator>
void eval_lagrangian_gradient ( crvec x,
crvec y,
rvec grad_L,
rvec work_n ) const

[Optional] Evaluate the gradient of the Lagrangian \( \nabla_x L(x, y) = \nabla f(x) + \nabla g(x)\,y \)

Default implementation:
ProblemVTable::default_eval_lagrangian_gradient

Definition at line 868 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ eval_augmented_lagrangian()

template<Config Conf, class Allocator>
auto eval_augmented_lagrangian ( crvec x,
crvec y,
crvec Σ,
rvec ŷ ) const
nodiscard

[Optional] Calculate both ψ(x) and the vector ŷ that can later be used to compute ∇ψ.

\[ \psi(x) = f(x) + \tfrac{1}{2} \text{dist}_\Sigma^2\left(g(x) + \Sigma^{-1}y,\;D\right) \]

\[ \hat y = \Sigma\, \left(g(x) + \Sigma^{-1}y - \Pi_D\left(g(x) + \Sigma^{-1}y\right)\right) \]

Default implementation:
ProblemVTable::default_eval_augmented_lagrangian
Parameters
[in]xDecision variable \( x \)
[in]yLagrange multipliers \( y \)
[in]ΣPenalty weights \( \Sigma \)
[out]ŷ\( \hat y \)

Definition at line 873 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ eval_augmented_lagrangian_gradient()

template<Config Conf, class Allocator>
void eval_augmented_lagrangian_gradient ( crvec x,
crvec y,
crvec Σ,
rvec grad_ψ,
rvec work_n,
rvec work_m ) const

[Optional] Calculate the gradient ∇ψ(x).

\[ \nabla \psi(x) = \nabla f(x) + \nabla g(x)\,\hat y(x) \]

Default implementation:
ProblemVTable::default_eval_augmented_lagrangian_gradient
Parameters
[in]xDecision variable \( x \)
[in]yLagrange multipliers \( y \)
[in]ΣPenalty weights \( \Sigma \)
[out]grad_ψ\( \nabla \psi(x) \)
work_nDimension \( n \)
work_mDimension \( m \)

Definition at line 878 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ eval_augmented_lagrangian_and_gradient()

template<Config Conf, class Allocator>
auto eval_augmented_lagrangian_and_gradient ( crvec x,
crvec y,
crvec Σ,
rvec grad_ψ,
rvec work_n,
rvec work_m ) const
nodiscard

[Optional] Calculate both ψ(x) and its gradient ∇ψ(x).

\[ \psi(x) = f(x) + \tfrac{1}{2} \text{dist}_\Sigma^2\left(g(x) + \Sigma^{-1}y,\;D\right) \]

\[ \nabla \psi(x) = \nabla f(x) + \nabla g(x)\,\hat y(x) \]

Default implementation:
ProblemVTable::default_eval_augmented_lagrangian_and_gradient
Parameters
[in]xDecision variable \( x \)
[in]yLagrange multipliers \( y \)
[in]ΣPenalty weights \( \Sigma \)
[out]grad_ψ\( \nabla \psi(x) \)
work_nDimension \( n \)
work_mDimension \( m \)

Definition at line 885 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ check()

template<Config Conf, class Allocator>
void check ( ) const

[Optional] Check that the problem formulation is well-defined, the dimensions match, etc.

Throws an exception if this is not the case.

Definition at line 902 of file type-erased-problem.hpp.

◆ get_name()

template<Config Conf, class Allocator>
std::string get_name ( ) const
nodiscard

[Optional] Get a descriptive name for the problem.

Definition at line 906 of file type-erased-problem.hpp.

◆ provides_eval_inactive_indices_res_lna()

template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
bool provides_eval_inactive_indices_res_lna ( ) const
inlinenodiscard

Returns true if the problem provides an implementation of eval_inactive_indices_res_lna.

Definition at line 595 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ provides_eval_constraints_jacobian()

template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
bool provides_eval_constraints_jacobian ( ) const
inlinenodiscard

Returns true if the problem provides an implementation of eval_constraints_jacobian.

Definition at line 600 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ provides_get_constraints_jacobian_sparsity()

template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
bool provides_get_constraints_jacobian_sparsity ( ) const
inlinenodiscard

Returns true if the problem provides an implementation of get_constraints_jacobian_sparsity.

Definition at line 605 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ provides_eval_grad_gi()

template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
bool provides_eval_grad_gi ( ) const
inlinenodiscard

Returns true if the problem provides an implementation of eval_grad_gi.

Definition at line 611 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ provides_eval_lagrangian_hessian_product()

template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
bool provides_eval_lagrangian_hessian_product ( ) const
inlinenodiscard

Returns true if the problem provides an implementation of eval_lagrangian_hessian_product.

Definition at line 616 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ provides_eval_lagrangian_hessian()

template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
bool provides_eval_lagrangian_hessian ( ) const
inlinenodiscard

Returns true if the problem provides an implementation of eval_lagrangian_hessian.

Definition at line 622 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ provides_get_lagrangian_hessian_sparsity()

template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
bool provides_get_lagrangian_hessian_sparsity ( ) const
inlinenodiscard

Returns true if the problem provides an implementation of get_lagrangian_hessian_sparsity.

Definition at line 627 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ provides_eval_augmented_lagrangian_hessian_product()

template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
bool provides_eval_augmented_lagrangian_hessian_product ( ) const
inlinenodiscard

Returns true if the problem provides an implementation of eval_augmented_lagrangian_hessian_product.

Definition at line 633 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ provides_eval_augmented_lagrangian_hessian()

template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
bool provides_eval_augmented_lagrangian_hessian ( ) const
inlinenodiscard

Returns true if the problem provides an implementation of eval_augmented_lagrangian_hessian.

Definition at line 639 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ provides_get_augmented_lagrangian_hessian_sparsity()

template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
bool provides_get_augmented_lagrangian_hessian_sparsity ( ) const
inlinenodiscard

Returns true if the problem provides an implementation of get_augmented_lagrangian_hessian_sparsity.

Definition at line 645 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ provides_eval_objective_and_gradient()

template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
bool provides_eval_objective_and_gradient ( ) const
inlinenodiscard

Returns true if the problem provides a specialized implementation of eval_objective_and_gradient, false if it uses the default implementation.

Definition at line 651 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ provides_eval_objective_and_constraints()

template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
bool provides_eval_objective_and_constraints ( ) const
inlinenodiscard

Returns true if the problem provides a specialized implementation of eval_objective_and_constraints, false if it uses the default implementation.

Definition at line 656 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ provides_eval_objective_gradient_and_constraints_gradient_product()

template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
bool provides_eval_objective_gradient_and_constraints_gradient_product ( ) const
inlinenodiscard

Returns true if the problem provides a specialized implementation of eval_objective_gradient_and_constraints_gradient_product, false if it uses the default implementation.

Definition at line 662 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ provides_eval_lagrangian_gradient()

template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
bool provides_eval_lagrangian_gradient ( ) const
inlinenodiscard

Returns true if the problem provides a specialized implementation of eval_lagrangian_gradient, false if it uses the default implementation.

Definition at line 668 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ provides_eval_augmented_lagrangian()

template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
bool provides_eval_augmented_lagrangian ( ) const
inlinenodiscard

Returns true if the problem provides a specialized implementation of eval_augmented_lagrangian, false if it uses the default implementation.

Definition at line 673 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ provides_eval_augmented_lagrangian_gradient()

template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
bool provides_eval_augmented_lagrangian_gradient ( ) const
inlinenodiscard

Returns true if the problem provides a specialized implementation of eval_augmented_lagrangian_gradient, false if it uses the default implementation.

Definition at line 678 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ provides_eval_augmented_lagrangian_and_gradient()

template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
bool provides_eval_augmented_lagrangian_and_gradient ( ) const
inlinenodiscard

Returns true if the problem provides a specialized implementation of eval_augmented_lagrangian_and_gradient, false if it uses the default implementation.

Definition at line 684 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ provides_get_variable_bounds()

template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
bool provides_get_variable_bounds ( ) const
inlinenodiscard

Returns true if the problem provides an implementation of get_variable_bounds.

Definition at line 690 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ provides_get_general_bounds()

template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
bool provides_get_general_bounds ( ) const
inlinenodiscard

Returns true if the problem provides an implementation of get_general_bounds.

Definition at line 695 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ provides_check()

template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
bool provides_check ( ) const
inlinenodiscard

Returns true if the problem provides an implementation of check.

Definition at line 699 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ provides_get_name()

template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
bool provides_get_name ( ) const
inlinenodiscard

Returns true if the problem provides an implementation of get_name.

Definition at line 701 of file type-erased-problem.hpp.

Here is the caller graph for this function:

◆ supports_eval_augmented_lagrangian_hessian_product()

template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
bool supports_eval_augmented_lagrangian_hessian_product ( ) const
inlinenodiscard

Returns true if eval_augmented_lagrangian_hessian_product can be called.

Definition at line 711 of file type-erased-problem.hpp.

◆ supports_eval_augmented_lagrangian_hessian()

template<Config Conf = DefaultConfig, class Allocator = std::allocator<std::byte>>
bool supports_eval_augmented_lagrangian_hessian ( ) const
inlinenodiscard

Returns true if eval_augmented_lagrangian_hessian can be called.

Definition at line 716 of file type-erased-problem.hpp.

◆ calc_ŷ_dᵀŷ()

template<Config Conf, class Allocator>
auto calc_ŷ_dᵀŷ ( rvec g_ŷ,
crvec y,
crvec Σ ) const

Given g(x), compute the intermediate results ŷ and dᵀŷ that can later be used to compute ψ(x) and ∇ψ(x).

Computes the result using the following algorithm:

\[ \begin{aligned} \zeta &= g(x) + \Sigma^{-1} y \\[] d &= \zeta - \Pi_D(\zeta) = \operatorname{eval\_proj\_diff\_g}(\zeta, \zeta) \\[] \hat y &= \Sigma d \\[] \end{aligned} \]

See also
page_math
Parameters
[in,out]g_ŷInput \( g(x) \), outputs \( \hat y \)
[in]yLagrange multipliers \( y \)
[in]ΣPenalty weights \( \Sigma \)
Returns
The inner product \( d^\top \hat y \)

Definition at line 890 of file type-erased-problem.hpp.


The documentation for this class was generated from the following file: