PANOC-ALM  quadratic-penalty
Nonconvex constrained optimization
himmelblau.cpp
Go to the documentation of this file.
1 #include <memory>
3 
4 namespace pa {
5 namespace problems {
6 
8  auto sq = [](auto x) { return x * x; };
9  Box C{vec(2), vec(2)};
10  C.lowerbound << -1, -1;
11  C.upperbound << 4, 1.8;
12  return Problem{
13  2,
14  0,
15  C,
16  Box{},
17  [sq](crvec x) {
18  return sq(sq(x(0)) + x(1) - 11) + sq(x(0) + sq(x(1)) - 7);
19  },
20  [sq](crvec x, rvec g) {
21  g(0) =
22  2 * (2 * x(0) * (sq(x(0)) + x(1) - 11) + x(0) + sq(x(1)) - 7);
23  g(1) =
24  2 * (sq(x(0)) + 2 * x(1) * (x(0) + sq(x(1)) - 7) + x(1) - 11);
25  },
26  [](crvec , rvec ) {},
27  [](crvec , crvec , rvec grad) { grad.setZero(); },
28  [](crvec , unsigned, rvec grad_gi) { grad_gi.setZero(); },
29  [sq](crvec x, crvec , crvec v, rvec Hv) {
30  real_t H00 = 4 * (sq(x(0)) + x(1) - 11) + 8 * sq(x(0)) + 2;
31  real_t H01 = 4 * x(0) + 4 * x(1);
32  real_t H10 = 4 * x(0) + 4 * x(1);
33  real_t H11 = 4 * (x(0) + sq(x(1)) - 7) + 8 * sq(x(1)) + 2;
34  Hv(0) = H00 * v(0) + H01 * v(1);
35  Hv(1) = H10 * v(0) + H11 * v(1);
36  },
37  [sq](crvec x, crvec , rmat H) {
38  H(0, 0) = 4 * (sq(x(0)) + x(1) - 11) + 8 * sq(x(0)) + 2;
39  H(0, 1) = 4 * x(0) + 4 * x(1);
40  H(1, 0) = 4 * x(0) + 4 * x(1);
41  H(1, 1) = 4 * (x(0) + sq(x(1)) - 7) + 8 * sq(x(1)) + 2;
42  },
43  };
44 }
45 
46 } // namespace problems
47 } // namespace pa
himmelblau.hpp
pa::rvec
Eigen::Ref< vec > rvec
Default type for mutable references to vectors.
Definition: vec.hpp:16
pa::vec
realvec vec
Default type for vectors.
Definition: vec.hpp:14
pa::rmat
Eigen::Ref< mat > rmat
Default type for mutable references to matrices.
Definition: vec.hpp:22
panocpy.test.v
v
Definition: test.py:42
pa
Definition: alm.hpp:10
panocpy.test.x
x
Definition: test.py:40
pa::Box
Definition: box.hpp:7
panocpy.test.grad_gi
grad_gi
Definition: test.py:53
pa::crvec
Eigen::Ref< const vec > crvec
Default type for immutable references to vectors.
Definition: vec.hpp:18
panocpy.test.C
C
Definition: test.py:204
panocpy.test.g
g
Definition: test.py:51
pa::problems::himmelblau_problem
Problem himmelblau_problem()
Definition: himmelblau.cpp:7
pa::real_t
double real_t
Default floating point type.
Definition: vec.hpp:8
pa::Problem
Problem description for minimization problems.
Definition: include/panoc-alm/util/problem.hpp:24
main.H
H
Definition: main.py:8