WPILibC++ 2027.0.0-alpha-5
Loading...
Searching...
No Matches
newton_matrix_callbacks.hpp
Go to the documentation of this file.
1// Copyright (c) Sleipnir contributors
2
3#pragma once
4
5#include <functional>
6
7#include <Eigen/Core>
8#include <Eigen/SparseCore>
9
10namespace slp {
11
12/// Matrix callbacks for the Newton's method solver.
13///
14/// @tparam Scalar Scalar type.
15template <typename Scalar>
17 /// Type alias for dense vector.
18 using DenseVector = Eigen::Vector<Scalar, Eigen::Dynamic>;
19 /// Type alias for sparse matrix.
20 using SparseMatrix = Eigen::SparseMatrix<Scalar>;
21 /// Type alias for sparse vector.
22 using SparseVector = Eigen::SparseVector<Scalar>;
23
24 /// Number of decision variables.
26
27 /// Cost function value f(x) getter.
28 ///
29 /// <table>
30 /// <tr>
31 /// <th>Variable</th>
32 /// <th>Rows</th>
33 /// <th>Columns</th>
34 /// </tr>
35 /// <tr>
36 /// <td>x</td>
37 /// <td>num_decision_variables</td>
38 /// <td>1</td>
39 /// </tr>
40 /// <tr>
41 /// <td>f(x)</td>
42 /// <td>1</td>
43 /// <td>1</td>
44 /// </tr>
45 /// </table>
46 std::function<Scalar(const DenseVector& x)> f;
47
48 /// Cost function gradient ∇f(x) getter.
49 ///
50 /// <table>
51 /// <tr>
52 /// <th>Variable</th>
53 /// <th>Rows</th>
54 /// <th>Columns</th>
55 /// </tr>
56 /// <tr>
57 /// <td>x</td>
58 /// <td>num_decision_variables</td>
59 /// <td>1</td>
60 /// </tr>
61 /// <tr>
62 /// <td>∇f(x)</td>
63 /// <td>num_decision_variables</td>
64 /// <td>1</td>
65 /// </tr>
66 /// </table>
67 std::function<SparseVector(const DenseVector& x)> g;
68
69 /// Lagrangian Hessian ∇ₓₓ²L(x) getter.
70 ///
71 /// L(x) = f(x)
72 ///
73 /// <table>
74 /// <tr>
75 /// <th>Variable</th>
76 /// <th>Rows</th>
77 /// <th>Columns</th>
78 /// </tr>
79 /// <tr>
80 /// <td>x</td>
81 /// <td>num_decision_variables</td>
82 /// <td>1</td>
83 /// </tr>
84 /// <tr>
85 /// <td>∇ₓₓ²L(x)</td>
86 /// <td>num_decision_variables</td>
87 /// <td>num_decision_variables</td>
88 /// </tr>
89 /// </table>
90 std::function<SparseMatrix(const DenseVector& x)> H;
91};
92
93} // namespace slp
Definition to_underlying.hpp:7
Matrix callbacks for the Newton's method solver.
Definition newton_matrix_callbacks.hpp:16
std::function< SparseMatrix(const DenseVector &x)> H
Lagrangian Hessian ∇ₓₓ²L(x) getter.
Definition newton_matrix_callbacks.hpp:90
std::function< SparseVector(const DenseVector &x)> g
Cost function gradient ∇f(x) getter.
Definition newton_matrix_callbacks.hpp:67
Eigen::SparseVector< Scalar > SparseVector
Type alias for sparse vector.
Definition newton_matrix_callbacks.hpp:22
std::function< Scalar(const DenseVector &x)> f
Cost function value f(x) getter.
Definition newton_matrix_callbacks.hpp:46
int num_decision_variables
Number of decision variables.
Definition newton_matrix_callbacks.hpp:25
Eigen::Vector< Scalar, Eigen::Dynamic > DenseVector
Type alias for dense vector.
Definition newton_matrix_callbacks.hpp:18
Eigen::SparseMatrix< Scalar > SparseMatrix
Type alias for sparse matrix.
Definition newton_matrix_callbacks.hpp:20