alpaqa 1.0.0a12
Nonconvex constrained optimization
Loading...
Searching...
No Matches
cutest-loader.hpp
Go to the documentation of this file.
1#pragma once
2
4#include <alpaqa/cutest-interface-export.h>
8
9#include <iosfwd>
10#include <memory>
11#include <string>
12
13namespace alpaqa {
14
15/// Wrapper for CUTEst problems loaded from an external shared library.
16///
17/// @ingroup grp_Problems
19 : public BoxConstrProblem<alpaqa::EigenConfigd> {
20 public:
23
24 /// Load a CUTEst problem from the given shared library and OUTSDIF.d file.
25 CUTEstProblem(const char *so_fname, const char *outsdif_fname = nullptr,
26 bool sparse = false);
32
33 public:
34 /// The report generated by CUTEst.
35 ///
36 /// @see `man CUTEST_creport` and `man CUTEST_ureport`
38 /// Function call counters.
39 ///
40 /// @note Note that hessian_times_vector, constraints and constraints_grad
41 /// may account for codes which allow the evaluation of a
42 /// selection of constraints only and may thus be much smaller
43 /// than the number of constraints times the number of
44 /// iterations.
45 struct Calls {
46 /// Number of calls to the objective function.
47 unsigned objective = 0;
48 /// Number of calls to the objective gradient.
49 unsigned objective_grad = 0;
50 /// Number of calls to the objective Hessian.
51 unsigned objective_hess = 0;
52 /// Number of Hessian times vector products.
53 unsigned hessian_times_vector = 0;
54 /// Number of calls to the constraint functions.
55 unsigned constraints = 0;
56 /// Number of calls to the constraint gradients.
57 unsigned constraints_grad = 0;
58 /// Number of calls to the constraint Hessians.
59 unsigned constraints_hess = 0;
60 };
61 Calls calls; ///< Function call counters.
62
63 /// CPU time (in seconds) for CUTEST_csetup.
64 double time_setup = 0;
65 /// CPU time (in seconds) since the end of CUTEST_csetup.
66 double time = 0;
67 };
68
69 [[nodiscard]] Report get_report() const;
70 std::ostream &format_report(std::ostream &os, const Report &r) const;
71 std::ostream &format_report(std::ostream &os) const {
72 return format_report(os, get_report());
73 }
74
75 public:
76 std::string name = "<UNKNOWN>"; ///< Problem name
77 vec x0; ///< Initial value of decision variables
78 vec y0; ///< Initial value of Lagrange multipliers
79
80 private:
82 bool sparse = false;
83 mutable int nnz_H = -1;
84 mutable int nnz_J = -1;
86 Eigen::VectorX<int> rows, cols;
87 } mutable storage_jac_g, storage_hess_L;
88
89 public:
90 [[nodiscard]] real_t eval_f(crvec x) const;
91 void eval_grad_f(crvec x, rvec grad_fx) const;
92 void eval_g(crvec x, rvec gx) const;
93 void eval_grad_g_prod(crvec x, crvec y, rvec grad_gxy) const;
94
95 void eval_jac_g(crvec x, rvec J_values) const;
96 [[nodiscard]] Sparsity get_jac_g_sparsity() const;
97 void eval_grad_gi(crvec x, index_t i, rvec grad_gi) const;
98 void eval_hess_L_prod(crvec x, crvec y, real_t scale, crvec v,
99 rvec Hv) const;
100 void eval_hess_L(crvec x, crvec y, real_t scale, rvec H_values) const;
101 [[nodiscard]] Sparsity get_hess_L_sparsity() const;
102 void eval_hess_ψ_prod(crvec x, crvec y, crvec Σ, real_t scale, crvec v,
103 rvec Hv) const;
104 [[nodiscard]] real_t eval_f_grad_f(crvec x, rvec grad_fx) const;
105 [[nodiscard]] real_t eval_f_g(crvec x, rvec g) const;
106 void eval_grad_L(crvec x, crvec y, rvec grad_L, rvec work_n) const;
107};
108
109} // namespace alpaqa
Implements common problem functions for minimization problems with box constraints.
Wrapper for CUTEst problems loaded from an external shared library.
Calls calls
Function call counters.
CUTEstProblem(CUTEstProblem &&) noexcept
CUTEstProblem(const CUTEstProblem &)
util::copyable_unique_ptr< class CUTEstLoader > impl
vec y0
Initial value of Lagrange multipliers.
vec x0
Initial value of decision variables.
CUTEstProblem & operator=(const CUTEstProblem &)
std::ostream & format_report(std::ostream &os) const
The report generated by CUTEst.
#define USING_ALPAQA_CONFIG(Conf)
Definition config.hpp:56
typename Conf::real_t real_t
Definition config.hpp:65
typename Conf::index_t index_t
Definition config.hpp:77
constexpr const auto inf
Definition config.hpp:85
typename Conf::rvec rvec
Definition config.hpp:69
typename Conf::crvec crvec
Definition config.hpp:70
typename Conf::vec vec
Definition config.hpp:66
Double-precision double configuration.
Definition config.hpp:135
Stores any of the supported sparsity patterns.
Definition sparsity.hpp:105