smooth_feedback
Control and estimation on Lie groups
Loading...
Searching...
No Matches
nlp.hpp
Go to the documentation of this file.
1// Copyright (C) 2022 Petter Nilsson. MIT License.
2
3#pragma once
4
10#include <limits>
11#include <optional>
12
13#include <Eigen/Core>
14#include <Eigen/Sparse>
15
16namespace smooth::feedback {
17
30template<typename T>
31concept NLP = requires(
32 std::decay_t<T> & nlp, const Eigen::Ref<const Eigen::VectorXd> x, const Eigen::Ref<const Eigen::VectorXd> lambda)
33{
34 // clang-format off
35 {nlp.n()} -> std::convertible_to<std::size_t>;
36 {nlp.m()} -> std::convertible_to<std::size_t>;
37
38 // variable bounds
39 {nlp.xl()} -> std::convertible_to<Eigen::VectorXd>;
40 {nlp.xu()} -> std::convertible_to<Eigen::VectorXd>;
41
42 // objective and its derivatives
43 {nlp.f(x)} -> std::convertible_to<double>;
44 {nlp.df_dx(x)} -> std::convertible_to<Eigen::SparseMatrix<double>>;
45
46 // constraint, its bounds, and its derivatives
47 {nlp.g(x)} -> std::convertible_to<Eigen::VectorXd>;
48 {nlp.gl()} -> std::convertible_to<Eigen::VectorXd>;
49 {nlp.gu()} -> std::convertible_to<Eigen::VectorXd>;
50 {nlp.dg_dx(x)} -> std::convertible_to<Eigen::SparseMatrix<double>>;
51 // clang-format on
52};
53
57template<typename T>
58concept HessianNLP = NLP<T> && requires(std::decay_t<T> & nlp, Eigen::VectorXd x, Eigen::VectorXd lambda)
59{
60 // clang-format off
61 {nlp.d2f_dx2(x)} -> std::convertible_to<Eigen::SparseMatrix<double>>;
62 {nlp.d2g_dx2(x, lambda)} -> std::convertible_to<Eigen::SparseMatrix<double>>;
63 // clang-format on
64};
65
70{
72 enum class Status {
73 Optimal,
77 MaxTime,
78 Unknown,
79 };
80
83
85 std::size_t iter{0};
86
88 Eigen::VectorXd x;
89
92 Eigen::VectorXd zl, zu;
94
96 Eigen::VectorXd lambda;
97
99 double objective{0};
100};
101
102} // namespace smooth::feedback
Nonlinear Programming Problem with Hessian information.
Definition: nlp.hpp:58
Nonlinear Programming Problem.
Definition: nlp.hpp:31
@ PrimalInfeasible
Solution satisfies optimality condition but is not polished.
@ Unknown
Max time was reached, returned solution is not optimal.
@ MaxIterations
A certificate of dual infeasibility was found, no solution returned.
@ MaxTime
Max number of iterations was reached, returned solution is not optimal.
@ DualInfeasible
A certificate of primal infeasibility was found, no solution returned.
Solution to a Nonlinear Programming Problem.
Definition: nlp.hpp:70
Status
Solver status.
Definition: nlp.hpp:72
Eigen::VectorXd zl
Inequality multipliers.
Definition: nlp.hpp:92
double objective
Objective.
Definition: nlp.hpp:99
Eigen::VectorXd lambda
Constraint multipliers.
Definition: nlp.hpp:96
Eigen::VectorXd x
Variable values.
Definition: nlp.hpp:88
Status status
Solver status.
Definition: nlp.hpp:82
std::size_t iter
Number of iterations.
Definition: nlp.hpp:85
Eigen::VectorXd zu
Inequality multipliers.
Definition: nlp.hpp:92