alpaqa 0.0.1
Nonconvex constrained optimization
CUTEstLoader.hpp
Go to the documentation of this file.
1#pragma once
2
4
5#include <iosfwd>
6#include <memory>
7#include <string>
8
9/// Wrapper for CUTEst problems loaded from an external shared library.
10///
11/// @warning The lifetime of the wrapper should be at least as long as the
12/// lifetime of the @ref CUTEstProblem::problem member. Do not make
13/// a copy of the problem that could outlive the wrapper.
14///
15/// @ingroup grp_ExternalProblemLoaders
17
18 public:
19 /// Load a CUTEst problem from the given shared library and OUTSDIF.d file.
20 CUTEstProblem(const char *so_fname, const char *outsdif_fname);
21 /// @copydoc CUTEstProblem::CUTEstProblem(const char*, const char *)
22 CUTEstProblem(const std::string &so_fname,
23 const std::string &outsdif_fname);
27
28 public:
29 /// The report generated by CUTEst.
30 ///
31 /// @see `man CUTEST_creport` and `man CUTEST_ureport`
32 struct Report {
33 /// Name of the problem.
34 std::string name;
35
36 /// Number of independent variables.
37 unsigned nvar = 0;
38 /// Number of constraints.
39 unsigned ncon = 0;
40
41 /// Status returned by CUTEst.
42 /// @todo I don't think this is useful, remove it.
43 enum Status {
44 Success = 0, ///< Successful call.
45 AllocationError = 1, ///< Array allocation/deallocation error.
46 ArrayBoundError = 2, ///< Array bound error.
47 EvaluationError = 3, ///< Evaluation error.
48 } status = Status::Success; ///< Exit status.
49
50 /// Function call counters.
51 ///
52 /// @note Note that hessian_times_vector, constraints and constraints_grad
53 /// may account for codes which allow the evaluation of a
54 /// selection of constraints only and may thus be much smaller
55 /// than the number of constraints times the number of
56 /// iterations.
57 struct {
58 /// Number of calls to the objective function.
59 unsigned objective = 0;
60 /// Number of calls to the objective gradient.
61 unsigned objective_grad = 0;
62 /// Number of calls to the objective Hessian.
63 unsigned objective_hess = 0;
64 /// Number of Hessian times vector products.
65 unsigned hessian_times_vector = 0;
66 /// Number of calls to the constraint functions.
67 unsigned constraints = 0;
68 /// Number of calls to the constraint gradients.
69 unsigned constraints_grad = 0;
70 /// Number of calls to the constraint Hessians.
71 unsigned constraints_hess = 0;
72 } calls; ///< Function call counters.
73
74 /// CPU time (in seconds) for CUTEST_csetup.
75 double time_setup = 0;
76 /// CPU time (in seconds) since the end of CUTEST_csetup.
77 double time = 0;
78 };
79
80 Report get_report() const;
81
82 public:
83 alpaqa::Problem problem; ///< Problem statement (bounds, objective, constraints)
84 std::string name = "<UNKNOWN>"; ///< Problem name
85 unsigned number_box_constraints = 0; ///< The number of box constraints on x
86 alpaqa::vec x0; ///< Initial value of decision variables
87 alpaqa::vec y0; ///< Initial value of Lagrange multipliers
88
89 private:
90 std::unique_ptr<class CUTEstLoader> implementation;
91};
92
93/// @related CUTEstProblem::Report
94std::ostream &operator<<(std::ostream &, const CUTEstProblem::Report &);
95/// @related CUTEstProblem::Report::Status
97/// @related CUTEstProblem::Report::Status
98std::ostream &operator<<(std::ostream &, CUTEstProblem::Report::Status);
const char * enum_name(CUTEstProblem::Report::Status s)
Wrapper for CUTEst problems loaded from an external shared library.
alpaqa::vec x0
Initial value of decision variables.
unsigned number_box_constraints
The number of box constraints on x.
std::string name
Problem name.
CUTEstProblem(const char *so_fname, const char *outsdif_fname)
Load a CUTEst problem from the given shared library and OUTSDIF.d file.
alpaqa::vec y0
Initial value of Lagrange multipliers.
Report get_report() const
alpaqa::Problem problem
Problem statement (bounds, objective, constraints)
std::unique_ptr< class CUTEstLoader > implementation
CUTEstProblem & operator=(CUTEstProblem &&)
CUTEstProblem(CUTEstProblem &&)
realvec vec
Default type for vectors.
Definition: vec.hpp:14
The report generated by CUTEst.
double time_setup
CPU time (in seconds) for CUTEST_csetup.
std::ostream & operator<<(std::ostream &, const CUTEstProblem::Report &)
struct CUTEstProblem::Report::@1 calls
Function call counters.
Status
Status returned by CUTEst.
@ EvaluationError
Evaluation error.
@ ArrayBoundError
Array bound error.
@ AllocationError
Array allocation/deallocation error.
@ Success
Successful call.
std::string name
Name of the problem.
unsigned ncon
Number of constraints.
double time
CPU time (in seconds) since the end of CUTEST_csetup.
unsigned nvar
Number of independent variables.
enum CUTEstProblem::Report::Status status
Exit status.
Problem description for minimization problems.