PANOC-ALM  quadratic-penalty
Nonconvex constrained optimization
CasADi/Rosenbrock/main.cpp
Go to the documentation of this file.
1 
12 #include <panoc-alm/decl/alm.hpp>
15 
17 
18 #include <iostream>
19 
20 int main(int argc, char *argv[]) {
21  using pa::inf;
22  using pa::vec;
23 
24  auto so_name = "examples/CasADi/Rosenbrock/librosenbrock_functions.so";
25  if (argc > 1)
26  so_name = argv[1];
27 
28  // Load the problem (with 3 decision variables and 1 general constraint)
29  pa::Problem p = pa::load_CasADi_problem(so_name, 3, 1);
30 
31  // Specify the bounds
32  p.C.upperbound = vec::Constant(3, inf);
33  p.C.lowerbound = vec::Constant(3, -inf);
34  p.D.upperbound = vec::Constant(1, 0.);
35  p.D.lowerbound = vec::Constant(1, 0.);
36 
37  // Settings for the outer augmented Lagrangian method
39  almparam.ε = 1e-8; // tolerance
40  almparam.δ = 1e-8;
41  almparam.Δ = 10;
42  almparam.max_iter = 20;
43  almparam.print_interval = 1;
44 
45  // Settings for the inner PANOC solver
47  panocparam.max_iter = 500;
48  panocparam.print_interval = 10;
49  // Settings for the L-BFGS algorithm used by PANOC
51  lbfgsparam.memory = 10;
52 
53  // Create an ALM solver using PANOC as inner solver
55  almparam, // params for outer solver
56  {panocparam, lbfgsparam}, // inner solver
57  };
58 
59  // Initial guess
60  vec x(3);
61  x << 2.5, 3.0, 0.75;
62  vec y(1);
63  y << 1;
64 
65  // Solve the problem
66  auto stats = solver(p, y, x);
67 
68  // Print the results
69  vec g(p.m);
70  p.g(x, g);
71  std::cout << "status: " << stats.status << std::endl;
72  std::cout << "x = " << x.transpose() << std::endl;
73  std::cout << "y = " << y.transpose() << std::endl;
74  std::cout << "g = " << g.transpose() << std::endl;
75  std::cout << "f = " << p.f(x) << std::endl;
76  std::cout << "inner: " << stats.inner.iterations << std::endl;
77  std::cout << "outer: " << stats.outer_iterations << std::endl;
78 }
panocpy.test.stats
stats
Definition: test.py:76
lbfgs.hpp
panocpy.test.y
y
Definition: test.py:76
main.panocparam
panocparam
Definition: main.py:33
alm.hpp
pa::vec
realvec vec
Default type for vectors.
Definition: vec.hpp:14
CasADiLoader.hpp
main.lbfgsparam
lbfgsparam
Definition: main.py:38
pa::ALMSolver
Augmented Lagrangian Method solver.
Definition: decl/alm.hpp:82
pa::PANOCParams
Tuning parameters for the PANOC algorithm.
Definition: inner/decl/panoc.hpp:20
panocpy.test.x
x
Definition: test.py:40
pa::ALMParams
Parameters for the Augmented Lagrangian solver.
Definition: decl/alm.hpp:13
pa::inf
constexpr real_t inf
Definition: vec.hpp:26
main.almparam
almparam
Definition: main.py:25
pa::LBFGSParams
Parameters for the LBFGS and SpecializedLBFGS classes.
Definition: decl/lbfgs.hpp:12
panoc.hpp
panocpy.test.solver
solver
Definition: test.py:8
panocpy.test.g
g
Definition: test.py:51
panocpy.test.p
p
Definition: test.py:57
main
int main(int argc, char *argv[])
Definition: CasADi/Rosenbrock/main.cpp:20
pa::Problem
Problem description for minimization problems.
Definition: include/panoc-alm/util/problem.hpp:24
pa::load_CasADi_problem
pa::Problem load_CasADi_problem(const std::string &filename, unsigned n, unsigned m, bool second_order=false)
Load a problem generated by CasADi (without parameters).
Definition: CasADiLoader.cpp:58