alpaqa 1.1.0a1
Nonconvex constrained optimization
Loading...
Searching...
No Matches
cutest-loader.cpp
Go to the documentation of this file.
2
6#include <guanaqo/dl-flags.hpp>
7#include <guanaqo/dl.hpp>
8
9#include <cassert>
10#include <filesystem>
11#include <iostream>
12#include <memory>
13#include <stdexcept>
14#include <string>
15#include <string_view>
16
17#include "cutest-functions.hpp"
18
19using namespace std::string_literals;
20
21namespace {
22void throw_error(std::string_view s, int code) {
24 std::string(s), static_cast<alpaqa::cutest::Status>(code));
25}
26void throw_if_error(std::string_view s, int code) {
27 if (code)
28 throw_error(s, code);
29}
30void log_if_error(std::string_view s, int code) {
31 if (code)
32 std::cerr << s << " (" << code << ")\n";
33}
34template <class F>
35auto checked(F &&func, std::string_view msg) {
36 return [msg, func{std::forward<F>(func)}]<class... Args>(
37 Args &&...args) mutable {
39 std::forward<F>(func)(&status, std::forward<Args>(args)...);
40 throw_if_error(msg, status);
41 };
42}
43} // namespace
44
45namespace alpaqa {
46
48 public:
49 USING_ALPAQA_CONFIG(CUTEstProblem::config_t);
51
52 private:
53 using cleanup_t = std::shared_ptr<void>;
54 template <class F>
55 cleanup_t cleanup(F &&func) {
56 return cleanup_t{nullptr,
57 [func{std::forward<F>(func)}](void *) { func(); }};
58 }
59
62
63 template <class F>
64 auto load() -> F::signature_t * {
65 return F::load(so_handle.get());
66 }
67
68 template <class F, class... Args>
69 decltype(auto) call(Args &&...args) {
70 return load<F>()(std::forward<Args>(args)...);
71 }
72
73 cleanup_t load_outsdif(const char *outsdif_fname) {
74 std::filesystem::path p = outsdif_fname;
75 if (!std::filesystem::is_regular_file(p))
76 throw std::invalid_argument("CUTEstLoader: OUTSDIF path does not "
77 "exist or is not a regular file: \"" +
78 std::string(outsdif_fname) + '"');
79 integer status;
80 auto fptr_close = load<cutest::fortran_close>();
81 call<cutest::fortran_open>(&funit, outsdif_fname, &status);
82 throw_if_error("Failed to open "s + outsdif_fname, status);
83 return cleanup([funit{this->funit}, fptr_close] {
84 integer status;
85 fptr_close(&funit, &status);
86 log_if_error("Failed to close OUTSDIF.d file", status);
87 });
88 }
89
91 auto fptr_cterminate = load<cutest::cterminate>();
92 return cleanup([fptr_cterminate] {
93 integer status;
94 fptr_cterminate(&status);
95 log_if_error("Failed to call cutest_cterminate", status);
96 });
97 }
98
99 public:
100 CUTEstLoader(const char *so_fname, const char *outsdif_fname,
101 DynamicLoadFlags dl_flags) {
102 namespace fs = std::filesystem;
103 auto path = fs::path(so_fname);
104 if (fs::is_directory(path))
105 path /= "PROBLEM.so";
106 // Open the shared library
107 so_handle = guanaqo::load_lib(path.c_str(), dl_flags);
108
109 // Open the OUTSDIF.d file
110 if (outsdif_fname && *outsdif_fname)
111 path = outsdif_fname;
112 else
113 path.replace_filename("OUTSDIF.d");
114 cleanup_outsdif = load_outsdif(path.c_str());
115
116 // Get the dimensions of the problem
117 integer status;
118 call<cutest::cdimen>(&status, &funit, &nvar, &ncon);
119 throw_if_error("Failed to call cutest_cdimen", status);
120 }
121
139
140 void setup_problem(rvec x0, rvec y0, Box &C, Box &D) {
141 assert(x0.size() == static_cast<length_t>(nvar));
142 assert(C.lower.size() == static_cast<length_t>(nvar));
143 assert(C.upper.size() == static_cast<length_t>(nvar));
144 assert(y0.size() == static_cast<length_t>(ncon));
145 assert(D.lower.size() == static_cast<length_t>(ncon));
146 assert(D.upper.size() == static_cast<length_t>(ncon));
147
148 // Variables returned and required by csetup
149 equatn.resize(static_cast<length_t>(ncon));
150 linear.resize(static_cast<length_t>(ncon));
151 integer e_order = 0; // no specific order of equality constraints
152 integer l_order = 0; // no specific order of linear constraints
153 integer v_order = 0; // no specific order of linear variables
154 integer status;
155
156 // Initialize the problem
158 x0.data(), C.lower.data(), C.upper.data(),
159 y0.data(), D.lower.data(), D.upper.data(),
160 equatn.data(), linear.data(), &e_order, &l_order,
161 &v_order);
162 throw_if_error("Failed to call cutest_csetup", status);
164
165 // Check the number of constraints
166 if (ncon == 0)
167 throw std::runtime_error(
168 "Unconstrained CUTEst problems are currently unsupported");
169
170 // Allocate workspaces
171 work.resize(std::max(nvar, ncon));
172 work2.resize(std::max(nvar, ncon));
173 // Convert bounds
174 std::ranges::replace(C.lower, -cutest::inf, -inf<config_t>);
175 std::ranges::replace(C.upper, +cutest::inf, +inf<config_t>);
176 std::ranges::replace(D.lower, -cutest::inf, -inf<config_t>);
177 std::ranges::replace(D.upper, +cutest::inf, +inf<config_t>);
178 // Load problem functions and gradients
179 funcs = {
180 .cfn = load<cutest::cfn>(),
181 .cofg = load<cutest::cofg>(),
182 .ccfg = load<cutest::ccfg>(),
183 .clfg = load<cutest::clfg>(),
184 .cjprod = load<cutest::cjprod>(),
185 .ccifg = load<cutest::ccifg>(),
186 .cigr = load<cutest::cigr>(),
187 .cdimsj = load<cutest::cdimsj>(),
188 .csjp = load<cutest::csjp>(),
189 .ccfsg = load<cutest::ccfsg>(),
190 .cdh = load<cutest::cdh>(),
191 .cdimsh = load<cutest::cdimsh>(),
192 .cshp = load<cutest::cshp>(),
193 .csh = load<cutest::csh>(),
194 .chprod = load<cutest::chprod>(),
195 };
196 }
197
198 std::string get_name() {
199 std::string name(cutest::fstring_len, ' ');
200 integer status;
201 call<cutest::probname>(&status, name.data());
202 throw_if_error("Failed to call CUTEST_probname", status);
203 if (auto last = name.find_last_not_of(' '); last != name.npos)
204 name.resize(last + 1);
205 return name;
206 }
207
208 void get_report(double *calls, double *time) {
209 integer status;
210 if (ncon > 0) {
211 call<cutest::creport>(&status, calls, time);
212 throw_if_error("Failed to call CUTEST_creport", status);
213 } else {
214 call<cutest::ureport>(&status, calls, time);
215 throw_if_error("Failed to call CUTEST_ureport", status);
216 }
217 }
218
219 // Order of cleanup is important!
220 std::shared_ptr<void> so_handle; ///< dlopen handle to shared library
221 cleanup_t cleanup_outsdif; ///< Responsible for closing the OUTSDIF.d file
222 cleanup_t cutest_terminate; ///< Responsible for calling CUTEST_xterminate
223
224 integer funit = 42; ///< Fortran Unit Number for OUTSDIF.d file
225 integer iout = 6; ///< Fortran Unit Number for standard output
226 integer io_buffer = 11; ///< Fortran Unit Number for internal IO
227
228 integer nvar; ///< Number of decision variabls
229 integer ncon; ///< Number of constraints
230 ConstrFuncs funcs; /// Pointers to loaded problem functions
231
232 using logical_vec = Eigen::VectorX<logical>;
233 logical_vec equatn; ///< whether the constraint is an equality
234 logical_vec linear; ///< whether the constraint is linear
235 mutable vec work, work2; ///< work vectors
236};
237
238CUTEstProblem::CUTEstProblem(const char *so_fname, const char *outsdif_fname,
239 bool sparse, DynamicLoadFlags flags)
240 : BoxConstrProblem<config_t>{0, 0}, sparse{sparse} {
241 impl = std::make_unique<CUTEstLoader>(so_fname, outsdif_fname, flags);
242 resize(static_cast<length_t>(impl->nvar),
243 static_cast<length_t>(impl->ncon));
244 x0.resize(num_variables);
245 y0.resize(num_constraints);
246 impl->setup_problem(x0, y0, variable_bounds, general_bounds);
247 name = impl->get_name();
248}
249
252CUTEstProblem::CUTEstProblem(CUTEstProblem &&) noexcept = default;
253CUTEstProblem &CUTEstProblem::operator=(CUTEstProblem &&) noexcept = default;
254CUTEstProblem::~CUTEstProblem() = default;
255
257 double calls[7]; // NOLINT(*-c-arrays)
258 double time[2]; // NOLINT(*-c-arrays)
259 impl->get_report(calls, time);
260 const bool constr = impl->ncon > 0;
261 return {
262 .calls{
263 .objective = static_cast<unsigned>(calls[0]),
264 .objective_grad = static_cast<unsigned>(calls[1]),
265 .objective_hess = static_cast<unsigned>(calls[2]),
266 .hessian_times_vector = static_cast<unsigned>(calls[3]),
267 .constraints = constr ? static_cast<unsigned>(calls[4]) : 0,
268 .constraints_grad = constr ? static_cast<unsigned>(calls[5]) : 0,
269 .constraints_hess = constr ? static_cast<unsigned>(calls[6]) : 0,
270 },
271 .time_setup = time[0],
272 .time = time[1],
273 };
274}
275
277 assert(x.size() == static_cast<length_t>(impl->nvar));
278 real_t f;
280 checked(impl->funcs.cofg, "eval_objective: CUTEST_cofg")(
281 &impl->nvar, x.data(), &f, nullptr, &grad);
282 return f;
283}
285 assert(x.size() == static_cast<length_t>(impl->nvar));
286 assert(grad_fx.size() == static_cast<length_t>(impl->nvar));
287 real_t f;
289 checked(impl->funcs.cofg, "eval_objective_gradient: CUTEST_cofg")(
290 &impl->nvar, x.data(), &f, grad_fx.data(), &grad);
291}
293 assert(x.size() == static_cast<length_t>(impl->nvar));
294 assert(gx.size() == static_cast<length_t>(impl->ncon));
296 cutest::integer zero = 0;
297 checked(impl->funcs.ccfg, "eval_constraints: CUTEST_ccfg")(
298 &impl->nvar, &impl->ncon, x.data(), gx.data(), &jtrans, &zero, &zero,
299 nullptr, &grad);
300}
302 rvec grad_gxy) const {
303 assert(x.size() == static_cast<length_t>(impl->nvar));
304 assert(y.size() == static_cast<length_t>(impl->ncon));
305 assert(grad_gxy.size() == static_cast<length_t>(impl->nvar));
306 auto lvector = static_cast<cutest::integer>(y.size()),
307 lresult = static_cast<cutest::integer>(grad_gxy.size());
309 checked(impl->funcs.cjprod,
310 "eval_constraints_gradient_product: CUTEST_cjprod")(
311 &impl->nvar, &impl->ncon, &gotj, &jtrans, x.data(), y.data(), &lvector,
312 grad_gxy.data(), &lresult);
313}
314
316 // Compute the nonzero values
317 assert(x.size() == static_cast<length_t>(impl->nvar));
318 // Sparse Jacobian
319 if (sparse) {
320 assert(nnz_J >= 0);
321 assert(J_values.size() == static_cast<length_t>(nnz_J));
322 assert(storage_jac_g.rows.size() == static_cast<length_t>(nnz_J));
323 assert(storage_jac_g.cols.size() == static_cast<length_t>(nnz_J));
324 const cutest::integer nnz = nnz_J;
326 checked(impl->funcs.ccfsg, "eval_constraints_jacobian: CUTEST_ccfsg")(
327 &impl->nvar, &impl->ncon, x.data(), impl->work.data(), &nnz_J, &nnz,
328 J_values.data(), storage_jac_g.cols.data(),
329 storage_jac_g.rows.data(), &grad);
330 }
331 // Dense Jacobian
332 else {
333 assert(J_values.size() == static_cast<length_t>(impl->nvar) *
334 static_cast<length_t>(impl->ncon));
336 checked(impl->funcs.ccfg, "eval_constraints_jacobian: CUTEST_ccfg")(
337 &impl->nvar, &impl->ncon, x.data(), impl->work.data(), &jtrans,
338 &impl->ncon, &impl->nvar, J_values.data(), &grad);
339 }
340}
342 if (!sparse)
343 return sparsity::Dense{
344 .rows = num_constraints,
345 .cols = num_variables,
346 .symmetry = sparsity::Symmetry::Unsymmetric,
347 };
348 if (nnz_J < 0) {
349 checked(impl->funcs.cdimsj,
350 "get_constraints_jacobian_sparsity: CUTEST_cdimsj")(&nnz_J);
351 nnz_J -= impl->nvar;
352 assert(nnz_J >= 0);
353 storage_jac_g.cols.resize(nnz_J);
354 storage_jac_g.rows.resize(nnz_J);
355 const cutest::integer nnz = nnz_J;
356 checked(impl->funcs.csjp, "eval_constraints_jacobian: CUTEST_csjp")(
357 &nnz_J, &nnz, storage_jac_g.cols.data(), storage_jac_g.rows.data());
358 }
359 using SparseCOO = sparsity::SparseCOO<int>;
360 return SparseCOO{
361 .rows = num_constraints,
362 .cols = num_variables,
363 .symmetry = sparsity::Symmetry::Unsymmetric,
364 .row_indices = as_span(storage_jac_g.rows),
365 .col_indices = as_span(storage_jac_g.cols),
366 .order = SparseCOO::Unsorted,
367 .first_index = 1, // Fortran-style indices
368 };
369}
371 assert(x.size() == static_cast<length_t>(impl->nvar));
372 assert(grad_gi.size() == static_cast<length_t>(impl->nvar));
373 auto iprob = static_cast<cutest::integer>(i + 1); // index zero is objective
374 checked(impl->funcs.cigr, "eval_grad_gi: CUTEST_cigr")(
375 &impl->nvar, &iprob, x.data(), grad_gi.data());
376}
378 real_t scale, crvec v,
379 rvec Hv) const {
380 assert(x.size() == static_cast<length_t>(impl->nvar));
381 assert(y.size() == static_cast<length_t>(impl->ncon));
382 assert(v.size() == static_cast<length_t>(impl->nvar));
383 assert(Hv.size() == static_cast<length_t>(impl->nvar));
384 const auto *mult = y.data();
385 if (scale != 1) {
386 impl->work = y * (real_t(1) / scale);
387 mult = impl->work.data();
388 }
390 checked(impl->funcs.chprod,
391 "eval_lagrangian_hessian_product: CUTEST_chprod")(
392 &impl->nvar, &impl->ncon, &goth, x.data(), mult,
393 const_cast<real_t *>(v.data()), Hv.data());
394 if (scale != 1)
395 Hv *= scale;
396}
398 crvec x, crvec y, crvec Σ, real_t scale, crvec v, rvec Hv) const {
399 assert(x.size() == static_cast<length_t>(impl->nvar));
400 assert(y.size() == static_cast<length_t>(impl->ncon));
401 assert(Σ.size() == static_cast<length_t>(impl->ncon));
402 assert(v.size() == static_cast<length_t>(impl->nvar));
403 assert(Hv.size() == static_cast<length_t>(impl->nvar));
404 auto &&ζ = impl->work.topRows(impl->ncon);
405 auto &&ŷ = impl->work2.topRows(impl->ncon);
406 // ζ = g(x) + Σ⁻¹y
407 eval_constraints(x, ζ);
408 ζ += y.cwiseQuotient(Σ);
409 // d = ζ - Π(ζ, D)
411 // ŷ = Σ d
412 ŷ.array() *= Σ.array();
413 // Hv = ∇²ℒ(x, ŷ) v
414 eval_lagrangian_hessian_product(x, ŷ, scale, v, Hv);
415 // Find active constraints
416 const auto &D = general_bounds;
417 for (index_t i = 0; i < impl->ncon; ++i)
418 ζ(i) = (ζ(i) <= D.lower(i)) || (D.upper(i) <= ζ(i)) ? Σ(i) : real_t(0);
419 // Jg(x) v
420 auto &&Jv = impl->work2.topRows(impl->ncon);
421 auto lvector = static_cast<cutest::integer>(v.size()),
422 lresult = static_cast<cutest::integer>(Jv.size());
424 checked(impl->funcs.cjprod,
425 "eval_augmented_lagrangian_hessian_product: CUTEST_cjprod-1")(
426 &impl->nvar, &impl->ncon, &gotj, &jtrans, x.data(), v.data(), &lvector,
427 Jv.data(), &lresult);
428 // Σ Jg v
429 Jv.array() *= ζ.array();
430 // Jgᵀ Σ Jg v
431 std::swap(lvector, lresult);
432 gotj = jtrans = cutest::True;
433 auto &&JΣJv = impl->work.topRows(impl->nvar);
434 checked(impl->funcs.cjprod,
435 "eval_augmented_lagrangian_hessian_product: CUTEST_cjprod-2")(
436 &impl->nvar, &impl->ncon, &gotj, &jtrans, x.data(), Jv.data(), &lvector,
437 JΣJv.data(), &lresult);
438 Hv += JΣJv;
439}
441 rvec H_values) const {
442 // Compute the nonzero values
443 assert(x.size() == static_cast<length_t>(impl->nvar));
444 assert(y.size() == static_cast<length_t>(impl->ncon));
445 const auto *mult = y.data();
446 if (scale != 1) {
447 impl->work = y * (real_t(1) / scale);
448 mult = impl->work.data();
449 }
450 // Sparse Hessian
451 if (sparse) {
452 assert(nnz_H >= 0);
453 assert(H_values.size() == static_cast<length_t>(nnz_H));
454 assert(storage_hess_L.rows.size() == static_cast<length_t>(nnz_H));
455 assert(storage_hess_L.cols.size() == static_cast<length_t>(nnz_H));
456 const cutest::integer nnz = nnz_H;
457 checked(impl->funcs.csh, "eval_lagrangian_hessian: CUTEST_csh")(
458 &impl->nvar, &impl->ncon, x.data(), y.data(), &nnz_H, &nnz,
459 H_values.data(), storage_hess_L.rows.data(),
460 storage_hess_L.cols.data());
461 }
462 // Dense Hessian
463 else {
464 assert(H_values.size() == static_cast<length_t>(impl->nvar) *
465 static_cast<length_t>(impl->nvar));
466 checked(impl->funcs.cdh, "eval_lagrangian_hessian: CUTEST_cdh")(
467 &impl->nvar, &impl->ncon, x.data(), mult, &impl->nvar,
468 H_values.data());
469 }
470 if (scale != 1)
471 H_values *= scale;
472}
474 if (!sparse)
475 return sparsity::Dense{
476 .rows = num_variables,
477 .cols = num_variables,
478 .symmetry = sparsity::Symmetry::Upper,
479 };
480 if (nnz_H < 0) {
481 checked(impl->funcs.cdimsh,
482 "get_lagrangian_hessian_sparsity: CUTEST_cdimsh")(&nnz_H);
483 assert(nnz_H >= 0);
484 storage_hess_L.rows.resize(nnz_H);
485 storage_hess_L.cols.resize(nnz_H);
486 const cutest::integer nnz = nnz_H;
487 checked(impl->funcs.cshp, "eval_lagrangian_hessian: CUTEST_cshp")(
488 &impl->nvar, &nnz_H, &nnz, storage_hess_L.rows.data(),
489 storage_hess_L.cols.data());
490 }
491 using SparseCOO = sparsity::SparseCOO<int>;
492 return SparseCOO{
493 .rows = num_variables,
494 .cols = num_variables,
495 .symmetry = sparsity::Symmetry::Upper,
496 .row_indices = as_span(storage_hess_L.rows),
497 .col_indices = as_span(storage_hess_L.cols),
498 .order = SparseCOO::Unsorted,
499 .first_index = 1, // Fortran-style indices
500 };
501}
503 rvec grad_fx) const -> real_t {
504 assert(x.size() == static_cast<length_t>(impl->nvar));
505 assert(grad_fx.size() == static_cast<length_t>(impl->nvar));
506 real_t f;
508 checked(impl->funcs.cofg, "eval_objective_and_gradient: CUTEST_cofg")(
509 &impl->nvar, x.data(), &f, grad_fx.data(), &grad);
510 return f;
511}
513 rvec g) const -> real_t {
514 assert(x.size() == static_cast<length_t>(impl->nvar));
515 assert(g.size() == static_cast<length_t>(impl->ncon));
516 real_t f;
517 checked(impl->funcs.cfn, "eval_objective_and_constraints: CUTEST_cfn")(
518 &impl->nvar, &impl->ncon, x.data(), &f, g.data());
519 return f;
520}
522 rvec) const {
523 assert(x.size() == static_cast<length_t>(impl->nvar));
524 assert(y.size() == static_cast<length_t>(impl->ncon));
525 assert(grad_L.size() == static_cast<length_t>(impl->nvar));
526 real_t L;
528 checked(impl->funcs.clfg, "eval_objective_and_constraints: CUTEST_clfg")(
529 &impl->nvar, &impl->ncon, x.data(), y.data(), &L, grad_L.data(), &grad);
530}
531
532std::ostream &CUTEstProblem::format_report(std::ostream &os,
533 const Report &r) const {
534 os << "CUTEst problem: " << name << "\r\n\n"
535 << "Number of variables: " << num_variables << "\r\n"
536 << "Number of constraints: " << num_constraints << "\r\n\n"
537 << "Objective function evaluations: " //
538 << r.calls.objective << "\r\n"
539 << "Objective function gradient evaluations: " //
540 << r.calls.objective_grad << "\r\n"
541 << "Objective function Hessian evaluations: " //
542 << r.calls.objective_hess << "\r\n"
543 << "Hessian times vector products: " //
544 << r.calls.objective_hess << "\r\n\n";
545 if (num_constraints > 0) {
546 os << "Constraint function evaluations: " //
547 << r.calls.constraints << "\r\n"
548 << "Constraint function gradients evaluations: " //
549 << r.calls.constraints_grad << "\r\n"
550 << "Constraint function Hessian evaluations: " //
551 << r.calls.constraints_hess << "\r\n\n";
552 }
553 return os << "Setup time: " << r.time_setup << "s\r\n"
554 << "Time since setup: " << r.time << "s";
555}
556
557} // namespace alpaqa
BoxConstrProblem(length_t num_variables, length_t num_constraints)
void eval_projecting_difference_constraints(crvec z, rvec p) const
cleanup_t cutest_terminate
Responsible for calling CUTEST_xterminate.
cutest::ccifg::signature_t * ccifg
cutest::cigr::signature_t * cigr
cutest::cfn::signature_t * cfn
integer ncon
Number of constraints.
cutest::logical logical
cutest::ccfsg::signature_t * ccfsg
std::shared_ptr< void > cleanup_t
cutest::csjp::signature_t * csjp
cleanup_t cleanup_outsdif
Responsible for closing the OUTSDIF.d file.
cutest::cdimsh::signature_t * cdimsh
CUTEstLoader(const char *so_fname, const char *outsdif_fname, DynamicLoadFlags dl_flags)
integer iout
Fortran Unit Number for standard output.
cutest::cdimsj::signature_t * cdimsj
integer funit
Fortran Unit Number for OUTSDIF.d file.
decltype(auto) call(Args &&...args)
cutest::csh::signature_t * csh
cutest::clfg::signature_t * clfg
cleanup_t load_outsdif(const char *outsdif_fname)
cutest::cofg::signature_t * cofg
cleanup_t cleanup(F &&func)
integer nvar
Number of decision variabls.
std::shared_ptr< void > so_handle
dlopen handle to shared library
cutest::integer integer
cutest::cjprod::signature_t * cjprod
alpaqa::Box< config_t > Box
cutest::cdh::signature_t * cdh
Eigen::VectorX< logical > logical_vec
Pointers to loaded problem functions.
cutest::chprod::signature_t * chprod
void setup_problem(rvec x0, rvec y0, Box &C, Box &D)
logical_vec equatn
whether the constraint is an equality
vec work2
work vectors
cutest::cshp::signature_t * cshp
auto load() -> F::signature_t *
void get_report(double *calls, double *time)
cutest::ccfg::signature_t * ccfg
logical_vec linear
whether the constraint is linear
integer io_buffer
Fortran Unit Number for internal IO.
Wrapper for CUTEst problems loaded from an external shared library.
void eval_constraints(crvec x, rvec gx) const
Sparsity get_lagrangian_hessian_sparsity() const
void eval_grad_gi(crvec x, index_t i, rvec grad_gi) const
void eval_lagrangian_hessian_product(crvec x, crvec y, real_t scale, crvec v, rvec Hv) const
Calls calls
Function call counters.
void eval_lagrangian_hessian(crvec x, crvec y, real_t scale, rvec H_values) const
unsigned constraints_grad
Number of calls to the constraint gradients.
real_t eval_objective_and_gradient(crvec x, rvec grad_fx) const
double time_setup
CPU time (in seconds) for CUTEST_csetup.
Report get_report() const
CUTEstProblem(const char *so_fname, const char *outsdif_fname=nullptr, bool sparse=false, DynamicLoadFlags dl_flags={})
Load a CUTEst problem from the given shared library and OUTSDIF.d file.
unsigned objective
Number of calls to the objective function.
struct alpaqa::CUTEstProblem::SparseStorage storage_hess_L
void eval_constraints_jacobian(crvec x, rvec J_values) const
real_t eval_objective(crvec x) const
void eval_augmented_lagrangian_hessian_product(crvec x, crvec y, crvec Σ, real_t scale, crvec v, rvec Hv) const
unsigned constraints
Number of calls to the constraint functions.
void eval_lagrangian_gradient(crvec x, crvec y, rvec grad_L, rvec work_n) const
std::string name
Problem name.
Sparsity get_constraints_jacobian_sparsity() const
real_t eval_objective_and_constraints(crvec x, rvec g) const
double time
CPU time (in seconds) since the end of CUTEST_csetup.
void eval_objective_gradient(crvec x, rvec grad_fx) const
unsigned objective_hess
Number of calls to the objective Hessian.
struct alpaqa::CUTEstProblem::SparseStorage storage_jac_g
std::ostream & format_report(std::ostream &os, const Report &r) const
void eval_constraints_gradient_product(crvec x, crvec y, rvec grad_gxy) const
guanaqo::copyable_unique_ptr< class CUTEstLoader > impl
unsigned constraints_hess
Number of calls to the constraint Hessians.
CUTEstProblem & operator=(const CUTEstProblem &)
unsigned objective_grad
Number of calls to the objective gradient.
The report generated by CUTEst.
#define USING_ALPAQA_CONFIG(Conf)
Definition config.hpp:77
constexpr logical True
constexpr logical False
constexpr size_t fstring_len
constexpr doublereal inf
auto as_span(Eigen::DenseBase< Derived > &v)
Convert an Eigen vector view to a std::span.
Definition span.hpp:21
typename Conf::real_t real_t
Definition config.hpp:86
typename Conf::index_t index_t
Definition config.hpp:104
typename Conf::length_t length_t
Definition config.hpp:103
constexpr const auto inf
Definition config.hpp:112
typename Conf::rvec rvec
Definition config.hpp:91
typename Conf::crvec crvec
Definition config.hpp:92
typename Conf::vec vec
Definition config.hpp:88
auto checked(F &&func, std::string_view msg)
void throw_error(std::string_view s, int code)
void throw_if_error(std::string_view s, int code)
void log_if_error(std::string_view s, int code)
void(integer *status, const integer *n, const integer *m, const doublereal *x, doublereal *f, doublereal *c) signature_t