alpaqa 1.0.0a10
Nonconvex constrained optimization
Loading...
Searching...
No Matches
cutest-loader.cpp
Go to the documentation of this file.
2
5
6#include <dlfcn.h>
7
8#include <cassert>
9#include <functional>
10#include <iostream>
11#include <memory>
12#include <stdexcept>
13#include <string>
14#include <string_view>
15#include <vector>
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
44std::shared_ptr<void> load_lib(const char *so_filename) {
45 assert(so_filename);
46 ::dlerror();
47 void *h = ::dlopen(so_filename, RTLD_LOCAL | RTLD_NOW);
48 if (auto *err = ::dlerror())
49 throw std::runtime_error(err);
50 return std::shared_ptr<void>{h, &::dlclose};
51}
52} // namespace
53
54namespace alpaqa {
55
57 public:
58 USING_ALPAQA_CONFIG(CUTEstProblem::config_t);
60
61 private:
62 using cleanup_t = std::shared_ptr<void>;
63 template <class F>
64 cleanup_t cleanup(F &&func) {
65 return cleanup_t{nullptr,
66 [func{std::forward<F>(func)}](void *) { func(); }};
67 }
68
71
72 template <class F>
73 auto load() -> F::signature_t * {
74 return F::load(so_handle.get());
75 }
76
77 template <class F, class... Args>
78 decltype(auto) call(Args &&...args) {
79 return load<F>()(std::forward<Args>(args)...);
80 }
81
82 cleanup_t load_outsdif(const char *outsdif_fname) {
83 integer status;
84 auto fptr_close = load<cutest::fortran_close>();
85 call<cutest::fortran_open>(&funit, outsdif_fname, &status);
86 throw_if_error("Failed to open "s + outsdif_fname, status);
87 return cleanup([funit{this->funit}, fptr_close] {
88 integer status;
89 fptr_close(&funit, &status);
90 log_if_error("Failed to close OUTSDIF.d file", status);
91 });
92 }
93
95 auto fptr_cterminate = load<cutest::cterminate>();
96 return cleanup([fptr_cterminate] {
97 integer status;
98 fptr_cterminate(&status);
99 log_if_error("Failed to call cutest_cterminate", status);
100 });
101 }
102
103 public:
104 CUTEstLoader(const char *so_fname, const char *outsdif_fname) {
105 // Open the shared library
106 so_handle = load_lib(so_fname);
107
108 // Open the OUTSDIF.d file
109 cleanup_outsdif = load_outsdif(outsdif_fname);
110
111 // Get the dimensions of the problem
112 integer status;
113 call<cutest::cdimen>(&status, &funit, &nvar, &ncon);
114 throw_if_error("Failed to call cutest_cdimen", status);
115 }
116
117 struct ConstrFuncs {
133 };
134
135 void setup_problem(rvec x0, rvec y0, Box &C, Box &D) {
136 assert(x0.size() == static_cast<length_t>(nvar));
137 assert(C.lowerbound.size() == static_cast<length_t>(nvar));
138 assert(C.upperbound.size() == static_cast<length_t>(nvar));
139 assert(y0.size() == static_cast<length_t>(ncon));
140 assert(D.lowerbound.size() == static_cast<length_t>(ncon));
141 assert(D.upperbound.size() == static_cast<length_t>(ncon));
142
143 // Variables returned and required by csetup
144 equatn.resize(static_cast<length_t>(ncon));
145 linear.resize(static_cast<length_t>(ncon));
146 integer e_order = 0; // no specific order of equality constraints
147 integer l_order = 0; // no specific order of linear constraints
148 integer v_order = 0; // no specific order of linear variables
149 integer status;
150
151 // Initialize the problem
152 call<cutest::csetup>(
153 &status, &funit, &iout, &io_buffer, &nvar, &ncon, x0.data(),
154 C.lowerbound.data(), C.upperbound.data(), y0.data(),
155 D.lowerbound.data(), D.upperbound.data(), equatn.data(),
156 linear.data(), &e_order, &l_order, &v_order);
157 throw_if_error("Failed to call cutest_csetup", status);
159
160 // Check the number of constraints
161 if (ncon == 0)
162 throw std::runtime_error(
163 "Unconstrained CUTEst problems are currently unsupported");
164
165 // Allocate workspaces
166 work.resize(std::max(nvar, ncon));
167 work2.resize(std::max(nvar, ncon));
168 // Convert bounds
169 std::ranges::replace(C.lowerbound, -cutest::inf, -inf<config_t>);
170 std::ranges::replace(C.upperbound, +cutest::inf, +inf<config_t>);
171 std::ranges::replace(D.lowerbound, -cutest::inf, -inf<config_t>);
172 std::ranges::replace(D.upperbound, +cutest::inf, +inf<config_t>);
173 // Load problem functions and gradients
174 funcs = {
175 .cfn = load<cutest::cfn>(),
176 .cofg = load<cutest::cofg>(),
177 .ccfg = load<cutest::ccfg>(),
178 .clfg = load<cutest::clfg>(),
179 .cjprod = load<cutest::cjprod>(),
180 .ccifg = load<cutest::ccifg>(),
181 .cigr = load<cutest::cigr>(),
182 .cdimsj = load<cutest::cdimsj>(),
183 .csjp = load<cutest::csjp>(),
184 .ccfsg = load<cutest::ccfsg>(),
185 .cdh = load<cutest::cdh>(),
186 .cdimsh = load<cutest::cdimsh>(),
187 .cshp = load<cutest::cshp>(),
188 .csh = load<cutest::csh>(),
189 .chprod = load<cutest::chprod>(),
190 };
191 }
192
193 std::string get_name() {
194 std::string name(cutest::fstring_len, ' ');
195 integer status;
196 call<cutest::probname>(&status, name.data());
197 throw_if_error("Failed to call CUTEST_probname", status);
198 if (auto last = name.find_last_not_of(' '); last != name.npos)
199 name.resize(last + 1);
200 return name;
201 }
202
203 void get_report(double *calls, double *time) {
204 integer status;
205 if (ncon > 0) {
206 call<cutest::creport>(&status, calls, time);
207 throw_if_error("Failed to call CUTEST_creport", status);
208 } else {
209 call<cutest::ureport>(&status, calls, time);
210 throw_if_error("Failed to call CUTEST_ureport", status);
211 }
212 }
213
214 template <class T>
215 T *dlfun(const char *name) {
216 (void)dlerror();
217 auto res = reinterpret_cast<T *>(::dlsym(so_handle.get(), name));
218 if (const char *error = dlerror())
219 throw std::runtime_error(error);
220 return res;
221 }
222
223 // Order of cleanup is important!
224 std::shared_ptr<void> so_handle; ///< dlopen handle to shared library
225 cleanup_t cleanup_outsdif; ///< Responsible for closing the OUTSDIF.d file
226 cleanup_t cutest_terminate; ///< Responsible for calling CUTEST_xterminate
227
228 integer funit = 42; ///< Fortran Unit Number for OUTSDIF.d file
229 integer iout = 6; ///< Fortran Unit Number for standard output
230 integer io_buffer = 11; ///< Fortran Unit Number for internal IO
231
232 integer nvar; ///< Number of decision variabls
233 integer ncon; ///< Number of constraints
234 ConstrFuncs funcs; /// Pointers to loaded problem functions
235
236 using logical_vec = Eigen::VectorX<logical>;
237 logical_vec equatn; ///< whether the constraint is an equality
238 logical_vec linear; ///< whether the constraint is linear
239 mutable vec work, work2; ///< work vectors
240};
241
242CUTEstProblem::CUTEstProblem(const char *so_fname, const char *outsdif_fname,
243 bool sparse)
244 : BoxConstrProblem<config_t>{0, 0}, sparse{sparse} {
245 impl = std::make_unique<CUTEstLoader>(so_fname, outsdif_fname);
246 resize(static_cast<length_t>(impl->nvar),
247 static_cast<length_t>(impl->ncon));
248 x0.resize(n);
249 y0.resize(m);
250 impl->setup_problem(x0, y0, C, D);
251 name = impl->get_name();
252}
253
254CUTEstProblem::CUTEstProblem(const CUTEstProblem &) = default;
255CUTEstProblem &CUTEstProblem::operator=(const CUTEstProblem &) = default;
256CUTEstProblem::CUTEstProblem(CUTEstProblem &&) noexcept = default;
257CUTEstProblem &CUTEstProblem::operator=(CUTEstProblem &&) noexcept = default;
258CUTEstProblem::~CUTEstProblem() = default;
259
260auto CUTEstProblem::get_report() const -> Report {
261 double calls[7]; // NOLINT(*-c-arrays)
262 double time[2]; // NOLINT(*-c-arrays)
263 impl->get_report(calls, time);
264 const bool constr = impl->ncon > 0;
265 return {
266 .calls{
267 .objective = static_cast<unsigned>(calls[0]),
268 .objective_grad = static_cast<unsigned>(calls[1]),
269 .objective_hess = static_cast<unsigned>(calls[2]),
270 .hessian_times_vector = static_cast<unsigned>(calls[3]),
271 .constraints = constr ? static_cast<unsigned>(calls[4]) : 0,
272 .constraints_grad = constr ? static_cast<unsigned>(calls[5]) : 0,
273 .constraints_hess = constr ? static_cast<unsigned>(calls[6]) : 0,
274 },
275 .time_setup = time[0],
276 .time = time[1],
277 };
278}
279
281 assert(x.size() == static_cast<length_t>(impl->nvar));
282 real_t f;
284 checked(impl->funcs.cofg, "eval_f: CUTEST_cofg")(&impl->nvar, x.data(), &f,
285 nullptr, &grad);
286 return f;
287}
288void CUTEstProblem::eval_grad_f(crvec x, rvec grad_fx) const {
289 assert(x.size() == static_cast<length_t>(impl->nvar));
290 assert(grad_fx.size() == static_cast<length_t>(impl->nvar));
291 real_t f;
293 checked(impl->funcs.cofg, "eval_grad_f: CUTEST_cofg")(
294 &impl->nvar, x.data(), &f, grad_fx.data(), &grad);
295}
297 assert(x.size() == static_cast<length_t>(impl->nvar));
298 assert(gx.size() == static_cast<length_t>(impl->ncon));
300 cutest::integer zero = 0;
301 checked(impl->funcs.ccfg, "eval_g: CUTEST_ccfg")(
302 &impl->nvar, &impl->ncon, x.data(), gx.data(), &jtrans, &zero, &zero,
303 nullptr, &grad);
304}
306 assert(x.size() == static_cast<length_t>(impl->nvar));
307 assert(y.size() == static_cast<length_t>(impl->ncon));
308 assert(grad_gxy.size() == static_cast<length_t>(impl->nvar));
309 auto lvector = static_cast<cutest::integer>(y.size()),
310 lresult = static_cast<cutest::integer>(grad_gxy.size());
312 checked(impl->funcs.cjprod, "eval_grad_g_prod: CUTEST_cjprod")(
313 &impl->nvar, &impl->ncon, &gotj, &jtrans, x.data(), y.data(), &lvector,
314 grad_gxy.data(), &lresult);
315}
316
317void CUTEstProblem::eval_jac_g(crvec x, [[maybe_unused]] rindexvec inner_idx,
318 [[maybe_unused]] rindexvec outer_ptr,
319 rvec J_values) const {
320 // Compute the nonzero values
321 if (J_values.size() > 0) {
322 assert(x.size() == static_cast<length_t>(impl->nvar));
323 // Sparse Jacobian
324 if (sparse) {
325 assert(nnz_J >= 0);
326 assert(J_values.size() == static_cast<length_t>(nnz_J));
327 assert(J_work.size() == static_cast<length_t>(nnz_J));
328 assert(inner_idx.size() == static_cast<length_t>(nnz_J));
329 assert(outer_ptr.size() == static_cast<length_t>(impl->nvar + 1));
330 const cutest::integer nnz = nnz_J;
332 checked(impl->funcs.ccfsg, "eval_jac_g: CUTEST_ccfsg")(
333 &impl->nvar, &impl->ncon, x.data(), impl->work.data(), &nnz_J,
334 &nnz, J_work.data(), J_col.data(), J_row.data(), &grad);
335 auto t0 = std::chrono::steady_clock::now();
336 J_values = J_work(J_perm);
337 auto t1 = std::chrono::steady_clock::now();
338 std::cout << "Permutation of J took: "
339 << std::chrono::duration<double>{t1 - t0}.count() * 1e6
340 << " µs\n";
341 }
342 // Dense Jacobian
343 else {
344 assert(J_values.size() == static_cast<length_t>(impl->nvar) *
345 static_cast<length_t>(impl->ncon));
347 checked(impl->funcs.ccfg, "eval_jac_g: CUTEST_ccfg")(
348 &impl->nvar, &impl->ncon, x.data(), impl->work.data(), &jtrans,
349 &impl->ncon, &impl->nvar, J_values.data(), &grad);
350 }
351 }
352 // Compute sparsity pattern without values
353 else {
354 assert(nnz_J >= 0);
355 assert(inner_idx.size() == static_cast<length_t>(nnz_J));
356 assert(outer_ptr.size() == static_cast<length_t>(impl->nvar + 1));
357 const cutest::integer nnz = nnz_J;
358 checked(impl->funcs.csjp, "eval_jac_g: CUTEST_csjp")(
359 &nnz_J, &nnz, J_col.data(), J_row.data());
360 std::iota(J_perm.begin(), J_perm.end(), index_t{0});
361 util::sort_triplets(J_row, J_col, J_perm);
362 util::convert_triplets_to_ccs<config_t>(J_row, J_col, inner_idx,
363 outer_ptr, 1);
364 }
365}
367 if (!sparse)
368 return -1;
369 if (nnz_J < 0) {
370 checked(impl->funcs.cdimsj,
371 "get_jac_g_num_nonzeros: CUTEST_cdimsj")(&nnz_J);
372 nnz_J -= impl->nvar;
373 assert(nnz_J >= 0);
374 J_col.resize(nnz_J);
375 J_row.resize(nnz_J);
376 J_perm.resize(nnz_J);
377 J_work.resize(nnz_J);
378 }
379 return nnz_J;
380}
382 assert(x.size() == static_cast<length_t>(impl->nvar));
383 assert(grad_gi.size() == static_cast<length_t>(impl->nvar));
384 auto iprob = static_cast<cutest::integer>(i + 1); // index zero is objective
385 checked(impl->funcs.cigr, "eval_grad_gi: CUTEST_cigr")(
386 &impl->nvar, &iprob, x.data(), grad_gi.data());
387}
389 rvec Hv) const {
390 assert(x.size() == static_cast<length_t>(impl->nvar));
391 assert(y.size() == static_cast<length_t>(impl->ncon));
392 assert(v.size() == static_cast<length_t>(impl->nvar));
393 assert(Hv.size() == static_cast<length_t>(impl->nvar));
394 const auto *mult = y.data();
395 if (scale != 1) {
396 impl->work = y * (real_t(1) / scale);
397 mult = impl->work.data();
398 }
400 checked(impl->funcs.chprod, "eval_hess_L_prod: CUTEST_chprod")(
401 &impl->nvar, &impl->ncon, &goth, x.data(), mult,
402 const_cast<real_t *>(v.data()), Hv.data());
403 if (scale != 1)
404 Hv *= scale;
405}
407 crvec v, rvec Hv) const {
408 assert(x.size() == static_cast<length_t>(impl->nvar));
409 assert(y.size() == static_cast<length_t>(impl->ncon));
410 assert(Σ.size() == static_cast<length_t>(impl->ncon));
411 assert(v.size() == static_cast<length_t>(impl->nvar));
412 assert(Hv.size() == static_cast<length_t>(impl->nvar));
413 auto &&ζ = impl->work.topRows(impl->ncon);
414 auto &&ŷ = impl->work2.topRows(impl->ncon);
415 // ζ = g(x) + Σ⁻¹y
416 eval_g(x, ζ);
417 ζ += Σ.asDiagonal().inverse() * y;
418 // d = ζ - Π(ζ, D)
419 this->eval_proj_diff_g(ζ, ŷ);
420 // ŷ = Σ d
421 ŷ.array() *= Σ.array();
422 // Hv = ∇²ℒ(x, ŷ) v
423 eval_hess_L_prod(x, ŷ, scale, v, Hv);
424 // Find active constraints
425 for (index_t i = 0; i < impl->ncon; ++i)
426 ζ(i) = (ζ(i) <= D.lowerbound(i)) || (D.upperbound(i) <= ζ(i))
427 ? Σ(i)
428 : real_t(0);
429 // Jg(x) v
430 auto &&Jv = impl->work2.topRows(impl->ncon);
431 auto lvector = static_cast<cutest::integer>(v.size()),
432 lresult = static_cast<cutest::integer>(Jv.size());
434 checked(impl->funcs.cjprod, "eval_hess_ψ_prod: CUTEST_cjprod-1")(
435 &impl->nvar, &impl->ncon, &gotj, &jtrans, x.data(), v.data(), &lvector,
436 Jv.data(), &lresult);
437 // Σ Jg v
438 Jv.array() *= ζ.array();
439 // Jgᵀ Σ Jg v
440 std::swap(lvector, lresult);
441 gotj = jtrans = cutest::True;
442 auto &&JΣJv = impl->work.topRows(impl->nvar);
443 checked(impl->funcs.cjprod, "eval_hess_ψ_prod: CUTEST_cjprod-2")(
444 &impl->nvar, &impl->ncon, &gotj, &jtrans, x.data(), Jv.data(), &lvector,
445 JΣJv.data(), &lresult);
446 Hv += JΣJv;
447}
449 rindexvec inner_idx, rindexvec outer_ptr,
450 rvec H_values) const {
451 // Compute the nonzero values
452 if (H_values.size() > 0) {
453 assert(x.size() == static_cast<length_t>(impl->nvar));
454 assert(y.size() == static_cast<length_t>(impl->ncon));
455 const auto *mult = y.data();
456 if (scale != 1) {
457 impl->work = y * (real_t(1) / scale);
458 mult = impl->work.data();
459 }
460 // Sparse Hessian
461 if (sparse) {
462 assert(nnz_H >= 0);
463 assert(H_values.size() == static_cast<length_t>(nnz_H));
464 assert(H_work.size() == static_cast<length_t>(nnz_H));
465 assert(inner_idx.size() == static_cast<length_t>(nnz_H));
466 assert(outer_ptr.size() == static_cast<length_t>(impl->nvar + 1));
467 const cutest::integer nnz = nnz_H;
468 checked(impl->funcs.csh, "eval_hess_L: CUTEST_csh")(
469 &impl->nvar, &impl->ncon, x.data(), y.data(), &nnz_H, &nnz,
470 H_work.data(), H_col.data(), H_row.data());
471 auto t0 = std::chrono::steady_clock::now();
472 H_values = H_work(H_perm);
473 auto t1 = std::chrono::steady_clock::now();
474 std::cout << "Permutation of H took: "
475 << std::chrono::duration<double>{t1 - t0}.count() * 1e6
476 << " µs\n";
477 }
478 // Dense Hessian
479 else {
480 assert(H_values.size() == static_cast<length_t>(impl->nvar) *
481 static_cast<length_t>(impl->nvar));
482 checked(impl->funcs.cdh, "eval_hess_L: CUTEST_cdh")(
483 &impl->nvar, &impl->ncon, x.data(), mult, &impl->nvar,
484 H_values.data());
485 }
486 if (scale != 1)
487 H_values *= scale;
488 }
489 // Compute sparsity pattern without values
490 else {
491 assert(nnz_H >= 0);
492 assert(inner_idx.size() == static_cast<length_t>(nnz_H));
493 assert(outer_ptr.size() == static_cast<length_t>(impl->nvar + 1));
494 const cutest::integer nnz = nnz_H;
495 checked(impl->funcs.cshp, "eval_hess_L: CUTEST_cshp")(
496 &impl->nvar, &nnz_H, &nnz, H_row.data(), H_col.data());
497 std::iota(H_perm.begin(), H_perm.end(), index_t{0});
498 util::sort_triplets(H_row, H_col, H_perm);
499 util::convert_triplets_to_ccs<config_t>(H_row, H_col, inner_idx,
500 outer_ptr, 1);
501 }
502}
504 if (!sparse)
505 return -1;
506 if (nnz_H < 0) {
507 checked(impl->funcs.cdimsh,
508 "get_hess_L_num_nonzeros: CUTEST_cdimsh")(&nnz_H);
509 assert(nnz_H >= 0);
510 H_col.resize(nnz_H);
511 H_row.resize(nnz_H);
512 H_perm.resize(nnz_H);
513 H_work.resize(nnz_H);
514 }
515 return nnz_H;
516}
518 assert(x.size() == static_cast<length_t>(impl->nvar));
519 assert(grad_fx.size() == static_cast<length_t>(impl->nvar));
520 real_t f;
522 checked(impl->funcs.cofg, "eval_f_grad_f: CUTEST_cofg")(
523 &impl->nvar, x.data(), &f, grad_fx.data(), &grad);
524 return f;
525}
527 assert(x.size() == static_cast<length_t>(impl->nvar));
528 assert(g.size() == static_cast<length_t>(impl->ncon));
529 real_t f;
530 checked(impl->funcs.cfn, "eval_f_g: CUTEST_cfn")(&impl->nvar, &impl->ncon,
531 x.data(), &f, g.data());
532 return f;
533}
534void CUTEstProblem::eval_grad_L(crvec x, crvec y, rvec grad_L, rvec) const {
535 assert(x.size() == static_cast<length_t>(impl->nvar));
536 assert(y.size() == static_cast<length_t>(impl->ncon));
537 assert(grad_L.size() == static_cast<length_t>(impl->nvar));
538 real_t L;
540 checked(impl->funcs.clfg, "eval_f_g: CUTEST_clfg")(
541 &impl->nvar, &impl->ncon, x.data(), y.data(), &L, grad_L.data(), &grad);
542}
543
544std::ostream &CUTEstProblem::format_report(std::ostream &os,
545 const Report &r) const {
546 os << "CUTEst problem: " << name << "\r\n\n"
547 << "Number of variables: " << n << "\r\n"
548 << "Number of constraints: " << m << "\r\n\n"
549 << "Objective function evaluations: " //
550 << r.calls.objective << "\r\n"
551 << "Objective function gradient evaluations: " //
552 << r.calls.objective_grad << "\r\n"
553 << "Objective function Hessian evaluations: " //
554 << r.calls.objective_hess << "\r\n"
555 << "Hessian times vector products: " //
556 << r.calls.objective_hess << "\r\n\n";
557 if (m > 0) {
558 os << "Constraint function evaluations: " //
559 << r.calls.constraints << "\r\n"
560 << "Constraint function gradients evaluations: " //
561 << r.calls.constraints_grad << "\r\n"
562 << "Constraint function Hessian evaluations: " //
563 << r.calls.constraints_hess << "\r\n\n";
564 }
565 return os << "Setup time: " << r.time_setup << "s\r\n"
566 << "Time since setup: " << r.time << "s";
567}
568
569} // namespace alpaqa
Implements common problem functions for minimization problems with box constraints.
length_t m
Number of constraints, dimension of g(x) and z.
length_t n
Number of decision variables, dimension of x.
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)
integer iout
Fortran Unit Number for standard output.
std::string get_name()
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.
T * dlfun(const char *name)
std::shared_ptr< void > so_handle
dlopen handle to shared library
cutest::integer integer
cutest::cjprod::signature_t * cjprod
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_grad_gi(crvec x, index_t i, rvec grad_gi) const
Calls calls
Function call counters.
unsigned constraints_grad
Number of calls to the constraint gradients.
real_t eval_f_g(crvec x, rvec g) const
double time_setup
CPU time (in seconds) for CUTEST_csetup.
CUTEstProblem(const char *so_fname, const char *outsdif_fname, bool sparse=false)
Load a CUTEst problem from the given shared library and OUTSDIF.d file.
unsigned objective
Number of calls to the objective function.
void eval_grad_L(crvec x, crvec y, rvec grad_L, rvec work_n) const
Eigen::VectorX< int > J_row
Eigen::VectorX< int > J_col
Eigen::VectorX< int > H_col
void eval_hess_L(crvec x, crvec y, real_t scale, rindexvec inner_idx, rindexvec outer_ptr, rvec H_values) const
unsigned constraints
Number of calls to the constraint functions.
std::string name
Problem name.
util::copyable_unique_ptr< class CUTEstLoader > impl
real_t eval_f_grad_f(crvec x, rvec grad_fx) const
double time
CPU time (in seconds) since the end of CUTEST_csetup.
void eval_grad_g_prod(crvec x, crvec y, rvec grad_gxy) const
void eval_hess_L_prod(crvec x, crvec y, real_t scale, crvec v, rvec Hv) const
Eigen::VectorX< int > H_row
void eval_grad_f(crvec x, rvec grad_fx) const
real_t eval_f(crvec x) const
void eval_g(crvec x, rvec gx) const
unsigned objective_hess
Number of calls to the objective Hessian.
length_t get_jac_g_num_nonzeros() const
std::ostream & format_report(std::ostream &os, const Report &r) const
unsigned constraints_hess
Number of calls to the constraint Hessians.
CUTEstProblem & operator=(const CUTEstProblem &)
void eval_jac_g(crvec x, rindexvec inner_idx, rindexvec outer_ptr, rvec J_values) const
unsigned objective_grad
Number of calls to the objective gradient.
void eval_hess_ψ_prod(crvec x, crvec y, crvec Σ, real_t scale, crvec v, rvec Hv) const
length_t get_hess_L_num_nonzeros() const
The report generated by CUTEst.
#define USING_ALPAQA_CONFIG(Conf)
Definition: config.hpp:54
constexpr logical True
constexpr logical False
constexpr size_t fstring_len
constexpr doublereal inf
typename Conf::real_t real_t
Definition: config.hpp:63
typename Conf::rindexvec rindexvec
Definition: config.hpp:77
typename Conf::index_t index_t
Definition: config.hpp:75
typename Conf::length_t length_t
Definition: config.hpp:74
typename Conf::rvec rvec
Definition: config.hpp:67
typename Conf::crvec crvec
Definition: config.hpp:68
typename Conf::vec vec
Definition: config.hpp:64
vec upperbound
Definition: box.hpp:28
vec lowerbound
Definition: box.hpp:27