alpaqa 0.0.1
Nonconvex constrained optimization
CUTEst/Rosenbrock/main.cpp
Go to the documentation of this file.
1/**
2 * @example CUTEst/Rosenbrock/main.cpp
3 *
4 * This example shows how to load and solve CUTEst problems using alpaqa.
5 */
6
7#include <alpaqa/decl/alm.hpp>
10
12
13#include <iostream>
14
15int main() {
16 using alpaqa::vec;
17
18 // Paths to the files generated by CUTEst
19 const char *so_fname = "CUTEst/ROSENBR/libcutest-problem-ROSENBR.so";
20 const char *outsdif_fname = "CUTEst/ROSENBR/OUTSDIF.d";
21
22 // Load the problem
23 CUTEstProblem cutest_p(so_fname, outsdif_fname);
24 const alpaqa::Problem &p = cutest_p.problem;
25
26 // Settings for the outer augmented Lagrangian method
28 almparam.ε = 1e-8; // tolerance
29 almparam.δ = 1e-8;
30 almparam.Δ = 10;
31 almparam.max_iter = 20;
32 almparam.print_interval = 1;
33
34 // Settings for the inner PANOC solver
36 panocparam.max_iter = 500;
37 panocparam.print_interval = 10;
38 // Settings for the L-BFGS algorithm used by PANOC
40 lbfgsparam.memory = 10;
41
42 // Create an ALM solver using PANOC as inner solver
44 almparam, // params for outer solver
45 {panocparam, lbfgsparam}, // inner solver
46 };
47
48 // Initial guess
49 vec x = cutest_p.x0;
50 vec y = cutest_p.y0;
51
52 // Solve the problem
53 auto stats = solver(p, y, x);
54
55 // Print the results
56 std::cout << "status: " << stats.status << std::endl;
57 std::cout << "x = " << x.transpose() << std::endl;
58 std::cout << "y = " << y.transpose() << std::endl;
59 vec g(p.m);
60 p.g(x, g);
61 std::cout << "g = " << g.transpose() << std::endl;
62 std::cout << "f = " << p.f(x) << std::endl;
63 std::cout << "inner: " << stats.inner.iterations << std::endl;
64 std::cout << "outer: " << stats.outer_iterations << std::endl;
65}
int main()
Wrapper for CUTEst problems loaded from an external shared library.
alpaqa::vec x0
Initial value of decision variables.
alpaqa::vec y0
Initial value of Lagrange multipliers.
alpaqa::Problem problem
Problem statement (bounds, objective, constraints)
Augmented Lagrangian Method solver.
Definition: decl/alm.hpp:82
realvec vec
Default type for vectors.
Definition: vec.hpp:14
Parameters for the Augmented Lagrangian solver.
Definition: decl/alm.hpp:13
Parameters for the LBFGS and SpecializedLBFGS classes.
Definition: decl/lbfgs.hpp:12
Tuning parameters for the PANOC algorithm.
lbfgsparam
Definition: main.py:38
almparam
Definition: main.py:25
panocparam
Definition: main.py:33
Problem description for minimization problems.