25 auto u(VecX &&
x)
const {
26 return x.segment(0,
nu);
29 auto s(VecX &&
x)
const {
30 return x.segment(
nu,
ns);
33 auto y(VecX &&
x)
const {
39 u(
C.lowerbound).fill(-10);
40 u(
C.upperbound).fill(10);
41 s(
C.lowerbound).fill(-
inf);
42 s(
C.upperbound).fill(
inf);
43 y(
C.lowerbound).fill(0);
44 y(
C.upperbound).fill(
inf);
50 D.lowerbound.fill(-
inf);
55 using Diag = Eigen::DiagonalMatrix<real_t, Eigen::Dynamic, Eigen::Dynamic>;
58 A = alpaqa::mat::Identity(
nx,
nx);
61 B = alpaqa::mat::Zero(
nx,
nu);
66 Q.diagonal().fill(10);
85 g_u(0) =
y(ux)(0) -
y(ux)(1) -
s(ux)(0);
88 g_u(2) =
x0.dot(
Q *
x0) +
u(ux).dot(
R *
u(ux)) -
89 (
y(ux)(0) -
y(ux)(1) -
y(ux)(2) -
s(ux)(1));
93 s(grad.col(0))(0) = -1;
94 y(grad.col(0))(0) = 1;
95 y(grad.col(0))(1) = -1;
97 u(grad.col(1)) = 2 *
B.transpose() * (
Q * (
A *
x0 +
B *
u(ux)));
98 s(grad.col(1))(1) = -1;
100 u(grad.col(2)) = 2 * (
R *
u(ux));
101 s(grad.col(2))(1) = 1;
102 y(grad.col(2))(0) = -1;
103 y(grad.col(2))(1) = 1;
104 y(grad.col(2))(2) = 1;
111 auto rptr = std::make_shared<RiskaverseProblem>();
118 [rptr](
crvec ux) {
return rptr->f(ux); },
119 [rptr](
crvec ux,
rvec g_u) { rptr->grad_f(ux, g_u); },
120 [rptr](
crvec ux,
rvec g_u) { rptr->g(ux, g_u); },
122 rptr->grad_g(ux,
v, grad_u_v);
Problem riskaverse_mpc_problem()
Eigen::Ref< const vec > crvec
Default type for immutable references to vectors.
realmat mat
Default type for matrices.
realvec vec
Default type for vectors.
double real_t
Default floating point type.
Eigen::Ref< vec > rvec
Default type for mutable references to vectors.
Problem description for minimization problems.
unsigned int n
Number of decision variables, dimension of x.
void grad_g(crvec ux, crvec v, rvec grad_u_v) const
Eigen::DiagonalMatrix< real_t, Eigen::Dynamic, Eigen::Dynamic > Diag
auto mpc_dynamics(crvec x, crvec u) const
void g(crvec ux, rvec g_u) const
void grad_f(crvec ux, rvec grad_f) const