44 #include <ilqgames/dynamics/multi_player_flat_system.h> 45 #include <ilqgames/utils/linear_dynamics_approximation.h> 46 #include <ilqgames/utils/types.h> 48 #include <glog/logging.h> 52 VectorXf MultiPlayerFlatSystem::Integrate(
53 Time time_interval,
const VectorXf& xi0,
54 const std::vector<VectorXf>& vs)
const {
56 constexpr
size_t kNumIntegrationSteps = 2;
57 const double dt = time::kTimeStep /
static_cast<Time
>(kNumIntegrationSteps);
59 CHECK_NOTNULL(continuous_linear_system_.get());
60 auto xi_dot = [
this, &vs](
const VectorXf& xi) {
61 VectorXf deriv = this->continuous_linear_system_->A * xi;
62 for (
size_t ii = 0; ii < NumPlayers(); ii++)
63 deriv += this->continuous_linear_system_->Bs[ii] * vs[ii];
71 for (Time t = 0.0; t < time_interval - 0.5 * dt; t += dt) {
72 const VectorXf k1 = dt * xi_dot(xi);
73 const VectorXf k2 = dt * xi_dot(xi + 0.5 * k1);
74 const VectorXf k3 = dt * xi_dot(xi + 0.5 * k2);
75 const VectorXf k4 = dt * xi_dot(xi + k3);
77 xi += (k1 + 2.0 * (k2 + k3) + k4) / 6.0;