17#include <Eigen/Cholesky>
18#include <Eigen/Eigenvalues>
48template <Config Conf = DefaultConfig>
73 throw std::invalid_argument(
74 "Structured Newton only supports box-constrained problems");
77 throw std::invalid_argument(
"Structured Newton requires hess_ψ");
88 throw std::logic_error(
"Sparse hessians not yet implemented");
112 for (
index_t i = 0; i < n; ++i) {
114 if (
gd <= C.lowerbound(i)) {
116 }
else if (C.upperbound(i) <=
gd) {
141 Eigen::SelfAdjointEigenSolver<mat>
eig{
H,
142 Eigen::ComputeEigenvectors};
144 auto λ_min =
eig.eigenvalues().minCoeff(),
145 λ_max =
eig.eigenvalues().maxCoeff();
153 qₖ =
eig.eigenvectors().transpose() *
qₖ;
154 qₖ =
eig.eigenvalues().cwiseMax(ε).asDiagonal().inverse() *
qₖ;
180 Eigen::SelfAdjointEigenSolver<mat>
eig{
HJ, Eigen::ComputeEigenvectors};
182 auto λ_min =
eig.eigenvalues().minCoeff(),
183 λ_max =
eig.eigenvalues().maxCoeff();
191 auto qJ =
H.col(0).topRows(nJ);
193 qJ =
eig.eigenvectors().transpose() *
qJ;
194 qJ =
eig.eigenvalues().cwiseMax(ε).asDiagonal().inverse() *
qJ;
208 return "StructuredNewtonDirection<" +
209 std::string(config_t::get_name()) +
'>';
217 std::optional<crvec>
y = std::nullopt;
218 std::optional<crvec>
Σ = std::nullopt;
220 std::optional<vec>
y = std::nullopt;
221 std::optional<vec>
Σ = std::nullopt;
bool provides_get_box_C() const
Returns true if the problem provides an implementation of get_box_C.
Sparsity get_hess_ψ_sparsity() const
[Optional] Function that returns (a view of) the sparsity pattern of the Hessian of the augmented Lag...
length_t get_n() const
[Required] Number of decision variables.
void eval_hess_ψ(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,
bool provides_eval_hess_ψ() const
Returns true if the problem provides an implementation of eval_hess_ψ.
bool provides_get_box_D() const
Returns true if the problem provides an implementation of get_box_D.
const Box & get_box_C() const
[Optional] Get the rectangular constraint set of the decision variables, .
#define USING_ALPAQA_CONFIG(Conf)
#define ALPAQA_IF_QUADF(...)
#define ALPAQA_IF_LONGD(...)
#define ALPAQA_IF_FLOAT(...)
#define ALPAQA_EXPORT_EXTERN_TEMPLATE(...)
real_t hessian_vec_factor
Set this option to a nonzero value to include the Hessian-vector product from equation 12b in ,...
real_t min_eig
Minimum eigenvalue of the Hessian, scaled by , enforced by regularization using a multiple of identit...
bool print_eig
Print the minimum and maximum eigenvalue of the Hessian.
Parameters for the StructuredNewtonDirection class.
Parameters for the StructuredNewtonDirection class.
typename Conf::indexvec indexvec
typename Conf::real_t real_t
typename Conf::rindexvec rindexvec
typename Conf::index_t index_t
typename Conf::crvec crvec
std::string float_to_str(F value, int precision)
typename Conf::crindexvec crindexvec
Double-precision double configuration.
Single-precision float configuration.
long double configuration.
std::string get_name() const
void changed_γ(real_t γₖ, real_t old_γₖ)
StructuredNewtonDirection()=default
const auto & get_params() const
DirectionParams direction_params
DirectionParams direction
StructuredNewtonDirection(const AcceleratorParams ¶ms, const DirectionParams &directionparams={})
bool update(real_t γₖ, real_t γₙₑₓₜ, crvec xₖ, crvec xₙₑₓₜ, crvec pₖ, crvec pₙₑₓₜ, crvec grad_ψxₖ, crvec grad_ψxₙₑₓₜ)
StructuredNewtonDirection(const Params ¶ms)
AcceleratorParams reg_params
void initialize(const Problem &problem, crvec y, crvec Σ, real_t γ_0, crvec x_0, crvec x̂_0, crvec p_0, crvec grad_ψx_0)
bool apply(real_t γₖ, crvec xₖ, crvec x̂ₖ, crvec pₖ, crvec grad_ψxₖ, rvec qₖ) const
bool has_initial_direction() const
AcceleratorParams accelerator
static void compute_complement(std::span< const index_t > in, std::span< index_t > out)