alpaqa pantr
Nonconvex constrained optimization
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
FunctionalProblem< Conf > Class Template Reference

#include <alpaqa/include/alpaqa/problem/functional-problem.hpp>

Detailed Description

template<Config Conf = DefaultConfig>
class alpaqa::FunctionalProblem< Conf >

Problem class that allows specifying the basic functions as C++ std::functions.

Definition at line 12 of file functional-problem.hpp.

+ Inheritance diagram for FunctionalProblem< Conf >:
+ Collaboration diagram for FunctionalProblem< Conf >:

Public Types

using Box = alpaqa::Box< config_t >
 

Public Member Functions

real_t eval_f (crvec x) const
 
void eval_grad_f (crvec x, rvec grad_fx) const
 
void eval_g (crvec x, rvec gx) const
 
void eval_grad_g_prod (crvec x, crvec y, rvec grad_gxy) const
 
void eval_grad_gi (crvec x, index_t i, rvec grad_gix) const
 
void eval_hess_L_prod (crvec x, crvec y, real_t scale, crvec v, rvec Hv) const
 
void eval_hess_ψ_prod (crvec x, crvec y, crvec Σ, real_t scale, crvec v, rvec Hv) const
 
void eval_jac_g (crvec x, rindexvec, rindexvec, rvec J_values) const
 
void eval_hess_L (crvec x, crvec y, real_t scale, rindexvec, rindexvec, rvec H_values) const
 
void eval_hess_ψ (crvec x, crvec y, crvec Σ, real_t scale, rindexvec, rindexvec, rvec H_values) const
 
bool provides_eval_grad_gi () const
 
bool provides_eval_jac_g () const
 
bool provides_eval_hess_L_prod () const
 
bool provides_eval_hess_L () const
 
bool provides_eval_hess_ψ_prod () const
 
bool provides_eval_hess_ψ () const
 
 FunctionalProblem (const FunctionalProblem &)=default
 
FunctionalProblemoperator= (const FunctionalProblem &)=default
 
 FunctionalProblem (FunctionalProblem &&) noexcept=default
 
FunctionalProblemoperator= (FunctionalProblem &&) noexcept=default
 
length_t get_n () const
 Number of decision variables, n.
 
length_t get_m () const
 Number of constraints, m.
 
real_t eval_prox_grad_step (real_t γ, crvec x, crvec grad_ψ, rvec x̂, rvec p) const
 
void eval_proj_diff_g (crvec z, rvec p) const
 
void eval_proj_multipliers (rvec y, real_t M) const
 
const Boxget_box_C () const
 
const Boxget_box_D () const
 
index_t eval_inactive_indices_res_lna (real_t γ, crvec x, crvec grad_ψ, rindexvec J) const
 
void check () const
 

Static Public Member Functions

static real_t eval_proj_grad_step_box (const Box &C, real_t γ, crvec x, crvec grad_ψ, rvec x̂, rvec p)
 Projected gradient step for rectangular box C.
 
static void eval_prox_grad_step_box_l1_impl (const Box &C, const auto &λ, real_t γ, crvec x, crvec grad_ψ, rvec x̂, rvec p)
 Proximal gradient step for rectangular box C with ℓ₁-regularization.
 
static real_t eval_prox_grad_step_box_l1 (const Box &C, const auto &λ, real_t γ, crvec x, crvec grad_ψ, rvec x̂, rvec p)
 Proximal gradient step for rectangular box C with ℓ₁-regularization.
 
static real_t eval_prox_grad_step_box_l1_scal (const Box &C, real_t λ, real_t γ, crvec x, crvec grad_ψ, rvec x̂, rvec p)
 Proximal gradient step for rectangular box C with ℓ₁-regularization.
 
static void eval_proj_multipliers_box (const Box &D, rvec y, real_t M, index_t penalty_alm_split)
 

Public Attributes

std::function< real_t(crvec)> f
 
std::function< void(crvec, rvec)> grad_f
 
std::function< void(crvec, rvec)> g
 
std::function< void(crvec, crvec, rvec)> grad_g_prod
 
std::function< void(crvec, index_t, rvec)> grad_gi
 
std::function< void(crvec, rmat)> jac_g
 
std::function< void(crvec, crvec, real_t, crvec, rvec)> hess_L_prod
 
std::function< void(crvec, crvec, real_t, rmat)> hess_L
 
std::function< void(crvec, crvec, crvec, real_t, crvec, rvec)> hess_ψ_prod
 
std::function< void(crvec, crvec, crvec, real_t, rmat)> hess_ψ
 
length_t n
 Number of decision variables, dimension of x.
 
length_t m
 Number of constraints, dimension of g(x) and z.
 
index_t penalty_alm_split = 0
 Components of the constraint function with indices below this number are handled using a quadratic penalty method rather than using an augmented Lagrangian method.
 
Box C {this->n}
 Constraints of the decision variables, \( x \in C \).
 
Box D {this->m}
 Other constraints, \( g(x) \in D \).
 
vec l1_reg {}
 \( \ell_1 \) (1-norm) regularization parameter.
 

Member Typedef Documentation

◆ Box

using Box = alpaqa::Box<config_t>
inherited

Definition at line 13 of file box-constr-problem.hpp.

Constructor & Destructor Documentation

◆ FunctionalProblem() [1/2]

FunctionalProblem ( const FunctionalProblem< Conf > &  )
default

◆ FunctionalProblem() [2/2]

FunctionalProblem ( FunctionalProblem< Conf > &&  )
defaultnoexcept

Member Function Documentation

◆ eval_f()

real_t eval_f ( crvec  x) const
inline

Definition at line 29 of file functional-problem.hpp.

◆ eval_grad_f()

void eval_grad_f ( crvec  x,
rvec  grad_fx 
) const
inline

Definition at line 30 of file functional-problem.hpp.

◆ eval_g()

void eval_g ( crvec  x,
rvec  gx 
) const
inline

Definition at line 31 of file functional-problem.hpp.

◆ eval_grad_g_prod()

void eval_grad_g_prod ( crvec  x,
crvec  y,
rvec  grad_gxy 
) const
inline

Definition at line 32 of file functional-problem.hpp.

◆ eval_grad_gi()

void eval_grad_gi ( crvec  x,
index_t  i,
rvec  grad_gix 
) const
inline

Definition at line 33 of file functional-problem.hpp.

◆ eval_hess_L_prod()

void eval_hess_L_prod ( crvec  x,
crvec  y,
real_t  scale,
crvec  v,
rvec  Hv 
) const
inline

Definition at line 34 of file functional-problem.hpp.

◆ eval_hess_ψ_prod()

void eval_hess_ψ_prod ( crvec  x,
crvec  y,
crvec  Σ,
real_t  scale,
crvec  v,
rvec  Hv 
) const
inline

Definition at line 35 of file functional-problem.hpp.

◆ eval_jac_g()

void eval_jac_g ( crvec  x,
rindexvec  ,
rindexvec  ,
rvec  J_values 
) const
inline

Definition at line 37 of file functional-problem.hpp.

◆ eval_hess_L()

void eval_hess_L ( crvec  x,
crvec  y,
real_t  scale,
rindexvec  ,
rindexvec  ,
rvec  H_values 
) const
inline

Definition at line 42 of file functional-problem.hpp.

◆ eval_hess_ψ()

void eval_hess_ψ ( crvec  x,
crvec  y,
crvec  Σ,
real_t  scale,
rindexvec  ,
rindexvec  ,
rvec  H_values 
) const
inline

Definition at line 47 of file functional-problem.hpp.

◆ provides_eval_grad_gi()

bool provides_eval_grad_gi ( ) const
inline

◆ provides_eval_jac_g()

bool provides_eval_jac_g ( ) const
inline

◆ provides_eval_hess_L_prod()

bool provides_eval_hess_L_prod ( ) const
inline

◆ provides_eval_hess_L()

bool provides_eval_hess_L ( ) const
inline

◆ provides_eval_hess_ψ_prod()

bool provides_eval_hess_ψ_prod ( ) const
inline

◆ provides_eval_hess_ψ()

bool provides_eval_hess_ψ ( ) const
inline

◆ operator=() [1/2]

FunctionalProblem & operator= ( const FunctionalProblem< Conf > &  )
default

◆ operator=() [2/2]

FunctionalProblem & operator= ( FunctionalProblem< Conf > &&  )
defaultnoexcept

◆ get_n()

length_t get_n ( ) const
inlineinherited

Number of decision variables, n.

Definition at line 50 of file box-constr-problem.hpp.

◆ get_m()

length_t get_m ( ) const
inlineinherited

Number of constraints, m.

Definition at line 52 of file box-constr-problem.hpp.

◆ eval_proj_grad_step_box()

static real_t eval_proj_grad_step_box ( const Box C,
real_t  γ,
crvec  x,
crvec  grad_ψ,
rvec  ,
rvec  p 
)
inlinestaticinherited

Projected gradient step for rectangular box C.

\[ \begin{aligned} \hat x &= \Pi_C(x - \gamma\nabla\psi(x)) \\ p &= \hat x - x \\ &= \max(\underline x - x, \;\min(-\gamma\nabla\psi(x), \overline x - x) \end{aligned} \]

Definition at line 59 of file box-constr-problem.hpp.

+ Here is the caller graph for this function:

◆ eval_prox_grad_step_box_l1_impl()

static void eval_prox_grad_step_box_l1_impl ( const Box C,
const auto &  λ,
real_t  γ,
crvec  x,
crvec  grad_ψ,
rvec  ,
rvec  p 
)
inlinestaticinherited

Proximal gradient step for rectangular box C with ℓ₁-regularization.

\[ \begin{aligned} h(x) &= \|x\|_1 + \delta_C(x) \\ \hat x &= \prox_{\gamma h}(x - \gamma\nabla\psi(x)) \\ &= -\max\big( x - \overline x, \;\min\big( x - \underline x, \;\min\big( \gamma(\nabla\psi(x) + \lambda), \;\max\big( \gamma(\nabla\psi(x) - \lambda), x \big) \big) \big) \big) \end{aligned} \]

Definition at line 82 of file box-constr-problem.hpp.

+ Here is the caller graph for this function:

◆ eval_prox_grad_step_box_l1()

static real_t eval_prox_grad_step_box_l1 ( const Box C,
const auto &  λ,
real_t  γ,
crvec  x,
crvec  grad_ψ,
rvec  ,
rvec  p 
)
inlinestaticinherited

Proximal gradient step for rectangular box C with ℓ₁-regularization.

\[ \begin{aligned} h(x) &= \|x\|_1 + \delta_C(x) \\ \hat x &= \prox_{\gamma h}(x - \gamma\nabla\psi(x)) \\ &= -\max\big( x - \overline x, \;\min\big( x - \underline x, \;\min\big( \gamma(\nabla\psi(x) + \lambda), \;\max\big( \gamma(\nabla\psi(x) - \lambda), x \big) \big) \big) \big) \end{aligned} \]

Definition at line 91 of file box-constr-problem.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eval_prox_grad_step_box_l1_scal()

static real_t eval_prox_grad_step_box_l1_scal ( const Box C,
real_t  λ,
real_t  γ,
crvec  x,
crvec  grad_ψ,
rvec  ,
rvec  p 
)
inlinestaticinherited

Proximal gradient step for rectangular box C with ℓ₁-regularization.

\[ \begin{aligned} h(x) &= \|x\|_1 + \delta_C(x) \\ \hat x &= \prox_{\gamma h}(x - \gamma\nabla\psi(x)) \\ &= -\max\big( x - \overline x, \;\min\big( x - \underline x, \;\min\big( \gamma(\nabla\psi(x) + \lambda), \;\max\big( \gamma(\nabla\psi(x) - \lambda), x \big) \big) \big) \big) \end{aligned} \]

Definition at line 98 of file box-constr-problem.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eval_prox_grad_step()

real_t eval_prox_grad_step ( real_t  γ,
crvec  x,
crvec  grad_ψ,
rvec  ,
rvec  p 
) const
inlineinherited
See also
TypeErasedProblem::eval_prox_grad_step

Definition at line 107 of file box-constr-problem.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ eval_proj_diff_g()

void eval_proj_diff_g ( crvec  z,
rvec  p 
) const
inlineinherited
See also
TypeErasedProblem::eval_proj_diff_g

Definition at line 117 of file box-constr-problem.hpp.

+ Here is the call graph for this function:

◆ eval_proj_multipliers_box()

static void eval_proj_multipliers_box ( const Box D,
rvec  y,
real_t  M,
index_t  penalty_alm_split 
)
inlinestaticinherited

Definition at line 119 of file box-constr-problem.hpp.

+ Here is the caller graph for this function:

◆ eval_proj_multipliers()

void eval_proj_multipliers ( rvec  y,
real_t  M 
) const
inlineinherited
See also
TypeErasedProblem::eval_proj_multipliers

Definition at line 141 of file box-constr-problem.hpp.

+ Here is the call graph for this function:

◆ get_box_C()

const Box & get_box_C ( ) const
inlineinherited
See also
TypeErasedProblem::get_box_C

Definition at line 146 of file box-constr-problem.hpp.

◆ get_box_D()

const Box & get_box_D ( ) const
inlineinherited
See also
TypeErasedProblem::get_box_D

Definition at line 148 of file box-constr-problem.hpp.

◆ eval_inactive_indices_res_lna()

index_t eval_inactive_indices_res_lna ( real_t  γ,
crvec  x,
crvec  grad_ψ,
rindexvec  J 
) const
inlineinherited

◆ check()

void check ( ) const
inlineinherited
See also
TypeErasedProblem::check

Definition at line 188 of file box-constr-problem.hpp.

Member Data Documentation

◆ f

std::function<real_t(crvec)> f

Definition at line 17 of file functional-problem.hpp.

◆ grad_f

std::function<void(crvec, rvec)> grad_f

Definition at line 18 of file functional-problem.hpp.

◆ g

std::function<void(crvec, rvec)> g

Definition at line 19 of file functional-problem.hpp.

◆ grad_g_prod

std::function<void(crvec, crvec, rvec)> grad_g_prod

Definition at line 20 of file functional-problem.hpp.

◆ grad_gi

std::function<void(crvec, index_t, rvec)> grad_gi

Definition at line 21 of file functional-problem.hpp.

◆ jac_g

std::function<void(crvec, rmat)> jac_g

Definition at line 22 of file functional-problem.hpp.

◆ hess_L_prod

std::function<void(crvec, crvec, real_t, crvec, rvec)> hess_L_prod

Definition at line 23 of file functional-problem.hpp.

◆ hess_L

std::function<void(crvec, crvec, real_t, rmat)> hess_L

Definition at line 24 of file functional-problem.hpp.

◆ hess_ψ_prod

std::function<void(crvec, crvec, crvec, real_t, crvec, rvec)> hess_ψ_prod

Definition at line 25 of file functional-problem.hpp.

◆ hess_ψ

std::function<void(crvec, crvec, crvec, real_t, rmat)> hess_ψ

Definition at line 26 of file functional-problem.hpp.

◆ n

length_t n
inherited

Number of decision variables, dimension of x.

Examples
C++/CustomCppProblem/main.cpp.

Definition at line 16 of file box-constr-problem.hpp.

◆ m

length_t m
inherited

Number of constraints, dimension of g(x) and z.

Examples
C++/CustomCppProblem/main.cpp.

Definition at line 18 of file box-constr-problem.hpp.

◆ penalty_alm_split

index_t penalty_alm_split = 0
inherited

Components of the constraint function with indices below this number are handled using a quadratic penalty method rather than using an augmented Lagrangian method.

Specifically, the Lagrange multipliers for these components (which determine the shifts in ALM) are kept at zero.

Definition at line 24 of file box-constr-problem.hpp.

◆ C

Box C {this->n}
inherited

Constraints of the decision variables, \( x \in C \).

Examples
C++/CasADi/Rosenbrock/main.cpp.

Definition at line 40 of file box-constr-problem.hpp.

◆ D

Box D {this->m}
inherited

Other constraints, \( g(x) \in D \).

Definition at line 42 of file box-constr-problem.hpp.

◆ l1_reg

vec l1_reg {}
inherited

\( \ell_1 \) (1-norm) regularization parameter.

Possible dimensions are: \( 0 \) (no regularization), \( 1 \) (a single scalar factor), or \( n \) (a different factor for each variable).

Definition at line 47 of file box-constr-problem.hpp.


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