44 #include <ilqgames/dynamics/multi_player_dynamical_system.h> 45 #include <ilqgames/utils/linear_dynamics_approximation.h> 46 #include <ilqgames/utils/types.h> 48 #include <glog/logging.h> 52 VectorXf MultiPlayerDynamicalSystem::Integrate(
53 Time t0, Time time_interval,
const VectorXf& x0,
54 const std::vector<VectorXf>& us)
const {
57 if (integrate_using_euler_) {
58 x += time_interval * Evaluate(t0, x0, us);
61 constexpr
size_t kNumIntegrationSteps = 2;
62 const double dt = time_interval /
static_cast<Time
>(kNumIntegrationSteps);
66 for (Time t = t0; t < t0 + time_interval - 0.5 * dt; t += dt) {
67 const VectorXf k1 = dt * Evaluate(t, x, us);
68 const VectorXf k2 = dt * Evaluate(t + 0.5 * dt, x + 0.5 * k1, us);
69 const VectorXf k3 = dt * Evaluate(t + 0.5 * dt, x + 0.5 * k2, us);
70 const VectorXf k4 = dt * Evaluate(t + dt, x + k3, us);
72 x += (k1 + 2.0 * (k2 + k3) + k4) / 6.0;