36 const auto &f = functions.
functions.at(
"f");
37 wrap(
"f", [&] { f_eval::validate_num_args(f); });
38 auto n = f.size1_in(0);
39 auto p = f.size1_in(1);
40 wrap(
"f", [&] { f_eval::validate_dimensions(f,
dims(n, p),
dims(1)); });
43 auto x = casadi::SX::sym(
"x", n);
44 auto param = casadi::SX::sym(
"param", p);
45 auto fx = f(std::vector{x, param})[0];
46 auto grad_f = casadi::SX::gradient(
fx, x);
53 wrap(
"g", [&] { g_eval::validate_num_args(g); });
54 auto m = g.size1_out(0);
55 wrap(
"g", [&] { g_eval::validate_dimensions(g,
dims(n, p),
dims(m)); });
60 auto y = casadi::SX::sym(
"y", m);
61 auto gx = g(std::vector{x, param})[0];
62 auto grad_g_prod = casadi::SX::jtimes(
gx, x, y,
true);
67 auto grad_L = grad_f + grad_g_prod;