17#include <Eigen/Cholesky>
18#include <Eigen/Eigenvalues>
46template <Config Conf = DefaultConfig>
71 throw std::invalid_argument(
72 "Structured Newton only supports box-constrained problems");
75 throw std::invalid_argument(
"Structured Newton requires hess_ψ");
86 throw std::logic_error(
"Sparse hessians not yet implemented");
110 for (
index_t i = 0; i < n; ++i) {
112 if (
gd <= C.lowerbound(i)) {
114 }
else if (C.upperbound(i) <=
gd) {
139 Eigen::SelfAdjointEigenSolver<mat>
eig{
H,
140 Eigen::ComputeEigenvectors};
142 auto λ_min =
eig.eigenvalues().minCoeff(),
143 λ_max =
eig.eigenvalues().maxCoeff();
151 qₖ =
eig.eigenvectors().transpose() *
qₖ;
152 qₖ =
eig.eigenvalues().cwiseMax(ε).asDiagonal().inverse() *
qₖ;
178 Eigen::SelfAdjointEigenSolver<mat>
eig{
HJ, Eigen::ComputeEigenvectors};
180 auto λ_min =
eig.eigenvalues().minCoeff(),
181 λ_max =
eig.eigenvalues().maxCoeff();
189 auto qJ =
H.col(0).topRows(nJ);
191 qJ =
eig.eigenvectors().transpose() *
qJ;
192 qJ =
eig.eigenvalues().cwiseMax(ε).asDiagonal().inverse() *
qJ;
206 return "StructuredNewtonDirection<" +
207 std::string(config_t::get_name()) +
'>';
215 std::optional<crvec>
y = std::nullopt;
216 std::optional<crvec>
Σ = std::nullopt;
218 std::optional<vec>
y = std::nullopt;
219 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 ,...
typename Conf::indexvec indexvec
real_t min_eig
Minimum eigenvalue of the Hessian, scaled by , enforced by regularization using a multiple of identit...
typename Conf::real_t real_t
typename Conf::rindexvec rindexvec
typename Conf::index_t index_t
typename Conf::crvec crvec
bool print_eig
Print the minimum and maximum eigenvalue of the Hessian.
std::string float_to_str(F value, int precision)
typename Conf::crindexvec crindexvec
Parameters for the StructuredNewtonDirection class.
Parameters for the StructuredNewtonDirection class.
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)