alpaqa 0.0.1
Nonconvex constrained optimization
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Functions
alpaqa::detail Namespace Reference

Functions

void project_y (rvec y, crvec z_lb, crvec z_ub, real_t M)
 
void update_penalty_weights (const ALMParams &params, real_t Δ, bool first_iter, rvec e, rvec old_e, real_t norm_e, real_t old_norm_e, crvec Σ_old, rvec Σ)
 
void initialize_penalty (const Problem &p, const ALMParams &params, crvec x0, rvec Σ)
 
void apply_preconditioning (const Problem &problem, Problem &prec_problem, crvec x, real_t &prec_f, vec &prec_g)
 
real_t calc_ψ_ŷ (const Problem &p, crvec x, crvec y, crvec Σ, rvec ŷ)
 Calculate both ψ(x) and the vector ŷ that can later be used to compute ∇ψ. More...
 
void calc_grad_ψ_from_ŷ (const Problem &p, crvec x, crvec ŷ, rvec grad_ψ, rvec work_n)
 Calculate ∇ψ(x) using ŷ. More...
 
real_t calc_ψ_grad_ψ (const Problem &p, crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m)
 Calculate both ψ(x) and its gradient ∇ψ(x). More...
 
void calc_grad_ψ (const Problem &p, crvec x, crvec y, crvec Σ, rvec grad_ψ, rvec work_n, rvec work_m)
 Calculate the gradient ∇ψ(x). More...
 
void calc_err_z (const Problem &p, crvec x̂, crvec y, crvec Σ, rvec err_z)
 Calculate the error between ẑ and g(x). More...
 
auto projected_gradient_step (const Box &C, real_t γ, crvec x, crvec grad_ψ)
 Projected gradient step. More...
 
void calc_x̂ (const Problem &prob, real_t γ, crvec x, crvec grad_ψ, rvec x̂, rvec p)
 
bool stop_crit_requires_grad_̂ψₖ (PANOCStopCrit crit)
 
real_t calc_error_stop_crit (const Box &C, PANOCStopCrit crit, crvec pₖ, real_t γ, crvec xₖ, crvec x̂ₖ, crvec ŷₖ, crvec grad_ψₖ, crvec grad_̂ψₖ)
 Compute the ε from the stopping criterion, see PANOCStopCrit. More...
 
real_t descent_lemma (const Problem &problem, real_t rounding_tolerance, real_t L_max, crvec xₖ, real_t ψₖ, crvec grad_ψₖ, crvec y, crvec Σ, rvec x̂ₖ, rvec pₖ, rvec ŷx̂ₖ, real_t &ψx̂ₖ, real_t &norm_sq_pₖ, real_t &grad_ψₖᵀpₖ, real_t &Lₖ, real_t &γₖ)
 Increase the estimate of the Lipschitz constant of the objective gradient and decrease the step size until quadratic upper bound or descent lemma is satisfied: More...
 
template<class ParamsT , class DurationT >
SolverStatus check_all_stop_conditions (const ParamsT &params, DurationT time_elapsed, unsigned iteration, const AtomicStopSignal &stop_signal, real_t ε, real_t εₖ, unsigned no_progress)
 Check all stop conditions (required tolerance reached, out of time, maximum number of iterations exceeded, interrupted by user, infinite iterate, no progress made) More...
 
void calc_augmented_lagrangian_hessian (const Problem &problem, crvec xₖ, crvec ŷxₖ, crvec y, crvec Σ, rvec g, mat &H, rvec work_n)
 Compute the Hessian matrix of the augmented Lagrangian function. More...
 
void calc_augmented_lagrangian_hessian_prod_fd (const Problem &problem, crvec xₖ, crvec y, crvec Σ, crvec grad_ψ, crvec v, rvec Hv, rvec work_n1, rvec work_n2, rvec work_m)
 Compute the Hessian matrix of the augmented Lagrangian function multiplied by the given vector, using finite differences. More...
 
real_t initial_lipschitz_estimate (const Problem &problem, crvec xₖ, crvec y, crvec Σ, real_t ε, real_t δ, real_t L_min, real_t L_max, real_t &ψ, rvec grad_ψ, rvec work_n1, rvec work_n2, rvec work_n3, rvec work_m)
 Estimate the Lipschitz constant of the gradient ψ using finite differences. More...
 
real_t initial_lipschitz_estimate (const Problem &problem, crvec xₖ, crvec y, crvec Σ, real_t ε, real_t δ, real_t L_min, real_t L_max, rvec grad_ψ, rvec work_n1, rvec work_n2, rvec work_n3, rvec work_m)
 Estimate the Lipschitz constant of the gradient ψ using finite differences. More...
 
template<class ObjFunT , class ObjGradFunT >
real_t initial_lipschitz_estimate (const ObjFunT &ψ, const ObjGradFunT &grad_ψ, crvec xₖ, real_t ε, real_t δ, real_t L_min, real_t L_max, real_t &ψₖ, rvec grad_ψₖ, vec_allocator &alloc)
 Estimate the Lipschitz constant of the gradient ψ using finite differences. More...
 
void calc_x̂ (real_t γ, crvec x, const Box &C, crvec grad_ψ, rvec x̂, rvec p)
 
template<class ObjFunT >
real_t descent_lemma (const ObjFunT &ψ, const Box &C, real_t rounding_tolerance, real_t L_max, crvec xₖ, real_t ψₖ, crvec grad_ψₖ, rvec x̂ₖ, rvec pₖ, real_t &ψx̂ₖ, real_t &norm_sq_pₖ, real_t &grad_ψₖᵀpₖ, real_t &Lₖ, real_t &γₖ)
 Increase the estimate of the Lipschitz constant of the objective gradient and decrease the step size until quadratic upper bound or descent lemma is satisfied: More...
 
void print_progress (unsigned k, real_t ψₖ, crvec grad_ψₖ, real_t pₖᵀpₖ, real_t γₖ, real_t εₖ)
 

Function Documentation

◆ project_y()

void alpaqa::detail::project_y ( rvec  y,
crvec  z_lb,
crvec  z_ub,
real_t  M 
)
inline

Definition at line 8 of file alm-helpers.hpp.

+ Here is the caller graph for this function:

◆ update_penalty_weights()

void alpaqa::detail::update_penalty_weights ( const ALMParams params,
real_t  Δ,
bool  first_iter,
rvec  e,
rvec  old_e,
real_t  norm_e,
real_t  old_norm_e,
crvec  Σ_old,
rvec  Σ 
)
inline

Definition at line 25 of file alm-helpers.hpp.

+ Here is the caller graph for this function:

◆ initialize_penalty()

void alpaqa::detail::initialize_penalty ( const Problem p,
const ALMParams params,
crvec  x0,
rvec  Σ 
)
inline

Definition at line 53 of file alm-helpers.hpp.

+ Here is the caller graph for this function:

◆ apply_preconditioning()

void alpaqa::detail::apply_preconditioning ( const Problem problem,
Problem prec_problem,
crvec  x,
real_t prec_f,
vec prec_g 
)
inline

Definition at line 66 of file alm-helpers.hpp.

+ Here is the caller graph for this function:

◆ calc_ψ_ŷ()

real_t alpaqa::detail::calc_ψ_ŷ ( const Problem p,
crvec  x,
crvec  y,
crvec  Σ,
rvec  ŷ 
)
inline

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

ψ(xk)=f(xk)+12distΣ2(g(xk)+Σ1y,D)

y^

Parameters
[in]pProblem description
[in]xDecision variable x
[in]yLagrange multipliers y
[in]ΣPenalty weights Σ
[out]ŷy^

Definition at line 16 of file panoc-helpers.hpp.

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

◆ calc_grad_ψ_from_ŷ()

void alpaqa::detail::calc_grad_ψ_from_ŷ ( const Problem p,
crvec  x,
crvec  ŷ,
rvec  grad_ψ,
rvec  work_n 
)
inline

Calculate ∇ψ(x) using ŷ.

Parameters
[in]pProblem description
[in]xDecision variable x
[in]ŷy^
[out]grad_ψψ(x)
work_nDimension n

Definition at line 44 of file panoc-helpers.hpp.

+ Here is the caller graph for this function:

◆ calc_ψ_grad_ψ()

real_t alpaqa::detail::calc_ψ_grad_ψ ( const Problem p,
crvec  x,
crvec  y,
crvec  Σ,
rvec  grad_ψ,
rvec  work_n,
rvec  work_m 
)
inline

Calculate both ψ(x) and its gradient ∇ψ(x).

ψ(xk)=f(xk)+12distΣ2(g(xk)+Σ1y,D)

ψ(x)=f(x)+g(x) y^(x)

Parameters
[in]pProblem description
[in]xDecision variable x
[in]yLagrange multipliers y
[in]ΣPenalty weights Σ
[out]grad_ψψ(x)
work_nDimension n
work_mDimension m

Definition at line 62 of file panoc-helpers.hpp.

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

◆ calc_grad_ψ()

void alpaqa::detail::calc_grad_ψ ( const Problem p,
crvec  x,
crvec  y,
crvec  Σ,
rvec  grad_ψ,
rvec  work_n,
rvec  work_m 
)
inline

Calculate the gradient ∇ψ(x).

ψ(x)=f(x)+g(x) y^(x)

Parameters
[in]pProblem description
[in]xDecision variable x
[in]yLagrange multipliers y
[in]ΣPenalty weights Σ
[out]grad_ψψ(x)
work_nDimension n
work_mDimension m

Definition at line 79 of file panoc-helpers.hpp.

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

◆ calc_err_z()

void alpaqa::detail::calc_err_z ( const Problem p,
crvec  ,
crvec  y,
crvec  Σ,
rvec  err_z 
)
inline

Calculate the error between ẑ and g(x).

z^k=ΠD(g(xk)+Σ1y)

Parameters
[in]pProblem description
[in]Decision variable x^
[in]yLagrange multipliers y
[in]ΣPenalty weights Σ
[out]err_zg(x^)z^

Definition at line 107 of file panoc-helpers.hpp.

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

◆ projected_gradient_step()

auto alpaqa::detail::projected_gradient_step ( const Box C,
real_t  γ,
crvec  x,
crvec  grad_ψ 
)
inline

Projected gradient step.

x^k=Tγk(xk)=ΠC(xkγkψ(xk))pk=x^kxk

Parameters
[in]CSet to project onto
[in]γStep size
[in]xDecision variable x
[in]grad_ψψ(xk)

Definition at line 131 of file panoc-helpers.hpp.

+ Here is the caller graph for this function:

◆ calc_x̂() [1/2]

void alpaqa::detail::calc_x̂ ( const Problem prob,
real_t  γ,
crvec  x,
crvec  grad_ψ,
rvec  ,
rvec  p 
)
inline
Parameters
[in]probProblem description
[in]γStep size
[in]xDecision variable x
[in]grad_ψψ(xk)
[out]x^k=Tγk(xk)
[out]px^kxk

Definition at line 142 of file panoc-helpers.hpp.

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

◆ stop_crit_requires_grad_̂ψₖ()

bool alpaqa::detail::stop_crit_requires_grad_̂ψₖ ( PANOCStopCrit  crit)
inline

Definition at line 153 of file panoc-helpers.hpp.

+ Here is the caller graph for this function:

◆ calc_error_stop_crit()

real_t alpaqa::detail::calc_error_stop_crit ( const Box C,
PANOCStopCrit  crit,
crvec  pₖ,
real_t  γ,
crvec  xₖ,
crvec  x̂ₖ,
crvec  ŷₖ,
crvec  grad_ψₖ,
crvec  grad_̂ψₖ 
)
inline

Compute the ε from the stopping criterion, see PANOCStopCrit.

Parameters
[in]CBox constraints on x
[in]critWhat stoppint criterion to use
[in]pₖProjected gradient step x^kxk
[in]γStep size
[in]xₖCurrent iterate
[in]x̂ₖCurrent iterate after projected gradient step
[in]ŷₖCandidate Lagrange multipliers
[in]grad_ψₖGradient in xk
[in]grad_̂ψₖGradient in x^k

Definition at line 169 of file panoc-helpers.hpp.

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

◆ descent_lemma() [1/2]

real_t alpaqa::detail::descent_lemma ( const Problem problem,
real_t  rounding_tolerance,
real_t  L_max,
crvec  xₖ,
real_t  ψₖ,
crvec  grad_ψₖ,
crvec  y,
crvec  Σ,
rvec  x̂ₖ,
rvec  pₖ,
rvec  ŷx̂ₖ,
real_t ψx̂ₖ,
real_t norm_sq_pₖ,
real_t grad_ψₖᵀpₖ,
real_t Lₖ,
real_t γₖ 
)
inline

Increase the estimate of the Lipschitz constant of the objective gradient and decrease the step size until quadratic upper bound or descent lemma is satisfied:

ψ(x+p)ψ(x)+ψ(x)p+L2p2

The projected gradient iterate x^k and step pk are updated with the new step size γk, and so are other quantities that depend on them, such as ψ(xk)pk and p2. The intermediate vector y^(xk) can be used to compute the gradient ψ(x^k) or to update the Lagrange multipliers.

Returns
The original step size, before it was reduced by this function.
Parameters
[in]problemProblem description
[in]rounding_toleranceTolerance used to ignore rounding errors when the function ψ(x) is relatively flat or the step size is very small, which could cause ψ(xk)<ψ(x^k), which is mathematically impossible but could occur in finite precision floating point arithmetic.
[in]L_maxMaximum allowed Lipschitz constant estimate (prevents infinite loop if function or derivatives are discontinuous, and keeps step size bounded away from zero).
[in]xₖCurrent iterate xk
[in]ψₖObjective function ψ(xk)
[in]grad_ψₖGradient of objective ψ(xk)
[in]yLagrange multipliers y
[in]ΣPenalty weights Σ
[out]x̂ₖProjected gradient iterate x^k
[out]pₖProjected gradient step pk
[out]ŷx̂ₖIntermediate vector y^(xk)
[in,out]ψx̂ₖObjective function ψ(x^k)
[in,out]norm_sq_pₖSquared norm of the step pk2
[in,out]grad_ψₖᵀpₖGradient of objective times step ψ(xk)pk
[in,out]LₖLipschitz constant estimate Lψk
[in,out]γₖStep size γk

Definition at line 242 of file panoc-helpers.hpp.

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

◆ check_all_stop_conditions()

SolverStatus alpaqa::detail::check_all_stop_conditions ( const ParamsT &  params,
DurationT  time_elapsed,
unsigned  iteration,
const AtomicStopSignal stop_signal,
real_t  ε,
real_t  εₖ,
unsigned  no_progress 
)
inline

Check all stop conditions (required tolerance reached, out of time, maximum number of iterations exceeded, interrupted by user, infinite iterate, no progress made)

Parameters
[in]paramsParameters including `max_iter`, `max_time` and `max_no_progress`
[in]time_elapsedTime elapsed since the start of the algorithm
[in]iterationThe current iteration number
[in]stop_signalA stop signal for the user to interrupt the algorithm
[in]εDesired primal tolerance
[in]εₖTolerance of the current iterate
[in]no_progressThe number of successive iterations no progress was made

Definition at line 307 of file panoc-helpers.hpp.

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

◆ calc_augmented_lagrangian_hessian()

void alpaqa::detail::calc_augmented_lagrangian_hessian ( const Problem problem,
crvec  xₖ,
crvec  ŷxₖ,
crvec  y,
crvec  Σ,
rvec  g,
mat H,
rvec  work_n 
)
inline

Compute the Hessian matrix of the augmented Lagrangian function.

xx2LΣ(x,y)=xx2L(x,y)|(x,y^(x,y))+iIΣigi(x)gi(x)

Parameters
[in]problemProblem description
[in]xₖCurrent iterate xk
[in]ŷxₖIntermediate vector y^(xk)
[in]yLagrange multipliers y
[in]ΣPenalty weights Σ
[out]gThe constraint values g(xk)
[out]HHessian matrix H(x,y)
work_nDimension n

Definition at line 342 of file panoc-helpers.hpp.

+ Here is the caller graph for this function:

◆ calc_augmented_lagrangian_hessian_prod_fd()

void alpaqa::detail::calc_augmented_lagrangian_hessian_prod_fd ( const Problem problem,
crvec  xₖ,
crvec  y,
crvec  Σ,
crvec  grad_ψ,
crvec  v,
rvec  Hv,
rvec  work_n1,
rvec  work_n2,
rvec  work_m 
)
inline

Compute the Hessian matrix of the augmented Lagrangian function multiplied by the given vector, using finite differences.

xx2LΣ(x,y)vxLΣ(x+hv,y)xLΣ(x,y)h

Parameters
[in]problemProblem description
[in]xₖCurrent iterate xk
[in]yLagrange multipliers y
[in]ΣPenalty weights Σ
[in]grad_ψGradient ψ(xk)
[in]vVector to multiply with the Hessian
[out]HvHessian-vector product
work_n1Dimension n
work_n2Dimension n
work_mDimension m

Definition at line 379 of file panoc-helpers.hpp.

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

◆ initial_lipschitz_estimate() [1/3]

real_t alpaqa::detail::initial_lipschitz_estimate ( const Problem problem,
crvec  xₖ,
crvec  y,
crvec  Σ,
real_t  ε,
real_t  δ,
real_t  L_min,
real_t  L_max,
real_t ψ,
rvec  grad_ψ,
rvec  work_n1,
rvec  work_n2,
rvec  work_n3,
rvec  work_m 
)
inline

Estimate the Lipschitz constant of the gradient ψ using finite differences.

Parameters
[in]problemProblem description
[in]xₖCurrent iterate xk
[in]yLagrange multipliers y
[in]ΣPenalty weights Σ
[in]εFinite difference step size relative to xₖ
[in]δMinimum absolute finite difference step size
[in]L_minMinimum allowed Lipschitz estimate.
[in]L_maxMaximum allowed Lipschitz estimate.
[out]ψψ(xk)
[out]grad_ψGradient ψ(xk)
work_n1Dimension n
work_n2Dimension n
work_n3Dimension n
work_mDimension m

Definition at line 412 of file panoc-helpers.hpp.

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

◆ initial_lipschitz_estimate() [2/3]

real_t alpaqa::detail::initial_lipschitz_estimate ( const Problem problem,
crvec  xₖ,
crvec  y,
crvec  Σ,
real_t  ε,
real_t  δ,
real_t  L_min,
real_t  L_max,
rvec  grad_ψ,
rvec  work_n1,
rvec  work_n2,
rvec  work_n3,
rvec  work_m 
)
inline

Estimate the Lipschitz constant of the gradient ψ using finite differences.

Parameters
[in]problemProblem description
[in]xₖCurrent iterate xk
[in]yLagrange multipliers y
[in]ΣPenalty weights Σ
[in]εFinite difference step size relative to xₖ
[in]δMinimum absolute finite difference step size
[in]L_minMinimum allowed Lipschitz estimate.
[in]L_maxMaximum allowed Lipschitz estimate.
[out]grad_ψGradient ψ(xk)
work_n1Dimension n
work_n2Dimension n
work_n3Dimension n
work_mDimension m

Definition at line 459 of file panoc-helpers.hpp.

+ Here is the call graph for this function:

◆ initial_lipschitz_estimate() [3/3]

real_t alpaqa::detail::initial_lipschitz_estimate ( const ObjFunT &  ψ,
const ObjGradFunT &  grad_ψ,
crvec  xₖ,
real_t  ε,
real_t  δ,
real_t  L_min,
real_t  L_max,
real_t ψₖ,
rvec  grad_ψₖ,
vec_allocator alloc 
)

Estimate the Lipschitz constant of the gradient ψ using finite differences.

Parameters
[in]ψObjective
[in]grad_ψGradient of
[in]xₖCurrent iterate xk
[in]εFinite difference step size relative to xₖ
[in]δMinimum absolute finite difference step size
[in]L_minMinimum allowed Lipschitz estimate.
[in]L_maxMaximum allowed Lipschitz estimate.
[out]ψₖψ(xk)
[out]grad_ψₖGradient ψ(xk)
[in]alloc

Definition at line 20 of file standalone/panoc.hpp.

+ Here is the call graph for this function:

◆ calc_x̂() [2/2]

void alpaqa::detail::calc_x̂ ( real_t  γ,
crvec  x,
const Box C,
crvec  grad_ψ,
rvec  ,
rvec  p 
)
inline
Parameters
[in]γStep size
[in]xDecision variable x
[in]CBox constraints C
[in]grad_ψψ(xk)
[out]x^k=Tγk(xk)
[out]px^kxk

Definition at line 58 of file standalone/panoc.hpp.

+ Here is the call graph for this function:

◆ descent_lemma() [2/2]

real_t alpaqa::detail::descent_lemma ( const ObjFunT &  ψ,
const Box C,
real_t  rounding_tolerance,
real_t  L_max,
crvec  xₖ,
real_t  ψₖ,
crvec  grad_ψₖ,
rvec  x̂ₖ,
rvec  pₖ,
real_t ψx̂ₖ,
real_t norm_sq_pₖ,
real_t grad_ψₖᵀpₖ,
real_t Lₖ,
real_t γₖ 
)

Increase the estimate of the Lipschitz constant of the objective gradient and decrease the step size until quadratic upper bound or descent lemma is satisfied:

ψ(x+p)ψ(x)+ψ(x)p+L2p2

The projected gradient iterate x^k and step pk are updated with the new step size γk, and so are other quantities that depend on them, such as ψ(xk)pk and p2. The intermediate vector y^(xk) can be used to compute the gradient ψ(x^k) or to update the Lagrange multipliers.

Returns
The original step size, before it was reduced by this function.
Parameters
[in]ψObjective.
[in]CBox constraints.
[in]rounding_toleranceTolerance used to ignore rounding errors when the function ψ(x) is relatively flat or the step size is very small, which could cause ψ(xk)<ψ(x^k), which is mathematically impossible but could occur in finite precision floating point arithmetic.
[in]L_maxMaximum allowed Lipschitz constant estimate (prevents infinite loop if function or derivatives are discontinuous, and keeps step size bounded away from zero).
[in]xₖCurrent iterate xk
[in]ψₖObjective function ψ(xk)
[in]grad_ψₖGradient of objective ψ(xk)
[out]x̂ₖProjected gradient iterate x^k
[out]pₖProjected gradient step pk
[in,out]ψx̂ₖObjective function ψ(x^k)
[in,out]norm_sq_pₖSquared norm of the step pk2
[in,out]grad_ψₖᵀpₖGradient of objective times step ψ(xk)pk
[in,out]LₖLipschitz constant estimate Lψk
[in,out]γₖStep size γk

Definition at line 82 of file standalone/panoc.hpp.

+ Here is the call graph for this function:

◆ print_progress()

void alpaqa::detail::print_progress ( unsigned  k,
real_t  ψₖ,
crvec  grad_ψₖ,
real_t  pₖᵀpₖ,
real_t  γₖ,
real_t  εₖ 
)
inline

Definition at line 139 of file standalone/panoc.hpp.

+ Here is the caller graph for this function: