PANOC-ALM  quadratic-penalty
Nonconvex constrained optimization
problem.cpp
Go to the documentation of this file.
2 
3 namespace pa {
4 
6  wc.f = [&wc, f{std::move(wc.f)}](crvec x) {
7  ++wc.evaluations.f;
8  return f(x);
9  };
10  wc.grad_f = [&wc, grad_f{std::move(wc.grad_f)}](crvec x, rvec grad) {
11  ++wc.evaluations.grad_f;
12  grad_f(x, grad);
13  };
14  wc.g = [&wc, g{std::move(wc.g)}](crvec x, rvec gx) {
15  ++wc.evaluations.g;
16  g(x, gx);
17  };
18  wc.grad_g_prod = [&wc, grad_g_prod{std::move(wc.grad_g_prod)}](
19  crvec x, crvec y, rvec grad) {
21  grad_g_prod(x, y, grad);
22  };
23  wc.grad_gi = [&wc, grad_gi{std::move(wc.grad_gi)}](crvec x, unsigned i,
24  rvec grad) {
26  grad_gi(x, i, grad);
27  };
28  wc.hess_L_prod = [&wc, hess_L_prod{std::move(wc.hess_L_prod)}](
29  crvec x, crvec y, crvec v, rvec Hv) {
31  hess_L_prod(x, y, v, Hv);
32  };
33  wc.hess_L = [&wc, hess_L{std::move(wc.hess_L)}](crvec x, crvec y, rmat H) {
34  ++wc.evaluations.hess_L;
35  hess_L(x, y, H);
36  };
37 }
38 
40  work.resize(original.m);
41  this->n = original.n;
42  this->m = original.m + original.n;
43  this->f = [this](crvec x) { return original.f(x); };
44  this->grad_f = [this](crvec x, rvec grad) { original.grad_f(x, grad); };
45  this->g = [this](crvec x, rvec gg) {
46  original.g(x, work);
47  gg.topRows(original.m) = work;
48  gg.bottomRows(original.n) = x;
49  };
50  this->grad_g_prod = [this](crvec x, crvec y, rvec gg) {
51  work = y.topRows(original.m);
52  original.grad_g_prod(x, work, gg);
53  gg += y.bottomRows(original.n);
54  };
55  this->grad_gi = [](crvec, unsigned, rvec) {
56  throw std::logic_error("ProblemOnlyD::grad_gi: Not implemented");
57  };
58  this->hess_L_prod = [](crvec, crvec, crvec, rvec) {
59  throw std::logic_error("ProblemOnlyD::hess_L_prod: Not implemented");
60  };
61  this->hess_L = [](crvec, crvec, rmat) {
62  throw std::logic_error("ProblemOnlyD::hess_L: Not implemented");
63  };
64  this->C.lowerbound = vec::Constant(original.n, -inf);
65  this->C.upperbound = vec::Constant(original.n, +inf);
66  this->D.lowerbound.resize(this->m);
67  this->D.upperbound.resize(this->m);
68  this->D.lowerbound.topRows(original.m) = original.D.lowerbound;
69  this->D.lowerbound.bottomRows(original.n) = original.C.lowerbound;
70  this->D.upperbound.topRows(original.m) = original.D.upperbound;
71  this->D.upperbound.bottomRows(original.n) = original.C.upperbound;
72 }
73 
74 } // namespace pa
pa::Problem::n
unsigned int n
Number of decision variables, dimension of x.
Definition: include/panoc-alm/util/problem.hpp:25
pa::rvec
Eigen::Ref< vec > rvec
Default type for mutable references to vectors.
Definition: vec.hpp:16
panocpy.test.y
y
Definition: test.py:76
pa::Problem::D
Box D
Other constraints, .
Definition: include/panoc-alm/util/problem.hpp:28
pa::EvalCounter::f
unsigned f
Definition: include/panoc-alm/util/problem.hpp:138
pa::Problem::hess_L
std::function< hess_L_sig > hess_L
Hessian of the Lagrangian function .
Definition: include/panoc-alm/util/problem.hpp:106
pa::rmat
Eigen::Ref< mat > rmat
Default type for mutable references to matrices.
Definition: vec.hpp:22
pa::Problem::f
std::function< f_sig > f
Cost function .
Definition: include/panoc-alm/util/problem.hpp:93
pa::Problem::hess_L_prod
std::function< hess_L_prod_sig > hess_L_prod
Hessian of the Lagrangian function times vector .
Definition: include/panoc-alm/util/problem.hpp:104
pa::Problem::m
unsigned int m
Number of constraints, dimension of g(x) and z.
Definition: include/panoc-alm/util/problem.hpp:26
panocpy.test.v
v
Definition: test.py:42
pa::Problem::grad_gi
std::function< grad_gi_sig > grad_gi
Gradient of a specific constraint .
Definition: include/panoc-alm/util/problem.hpp:101
pa
Definition: alm.hpp:10
panocpy.test.x
x
Definition: test.py:40
pa::Box::lowerbound
vec lowerbound
Definition: box.hpp:9
pa::EvalCounter::grad_f
unsigned grad_f
Definition: include/panoc-alm/util/problem.hpp:139
pa::inf
constexpr real_t inf
Definition: vec.hpp:26
pa::ProblemWithCounters::evaluations
EvalCounter evaluations
Definition: include/panoc-alm/util/problem.hpp:178
pa::crvec
Eigen::Ref< const vec > crvec
Default type for immutable references to vectors.
Definition: vec.hpp:18
pa::ProblemWithCounters::attach_counters
static void attach_counters(ProblemWithCounters &)
Definition: problem.cpp:5
pa::Problem::grad_f
std::function< grad_f_sig > grad_f
Gradient of the cost function .
Definition: include/panoc-alm/util/problem.hpp:95
pa::EvalCounter::g
unsigned g
Definition: include/panoc-alm/util/problem.hpp:140
pa::EvalCounter::grad_g_prod
unsigned grad_g_prod
Definition: include/panoc-alm/util/problem.hpp:141
pa::Problem::grad_g_prod
std::function< grad_g_prod_sig > grad_g_prod
Gradient of the constraint function times vector .
Definition: include/panoc-alm/util/problem.hpp:99
pa::ProblemWithCounters
Definition: include/panoc-alm/util/problem.hpp:162
pa::EvalCounter::hess_L_prod
unsigned hess_L_prod
Definition: include/panoc-alm/util/problem.hpp:143
pa::ProblemOnlyD::work
vec work
Definition: include/panoc-alm/util/problem.hpp:195
pa::Problem::g
std::function< g_sig > g
Constraint function .
Definition: include/panoc-alm/util/problem.hpp:97
pa::Box::upperbound
vec upperbound
Definition: box.hpp:8
pa::EvalCounter::hess_L
unsigned hess_L
Definition: include/panoc-alm/util/problem.hpp:144
problem.hpp
pa::ProblemOnlyD::transform
void transform()
Definition: problem.cpp:39
pa::ProblemOnlyD::original
Problem original
Definition: include/panoc-alm/util/problem.hpp:194
main.H
H
Definition: main.py:8
pa::Problem::C
Box C
Constraints of the decision variables, .
Definition: include/panoc-alm/util/problem.hpp:27