44 #include <ilqgames/cost/player_cost.h> 45 #include <ilqgames/dynamics/multi_player_flat_system.h> 46 #include <ilqgames/dynamics/multi_player_integrable_system.h> 47 #include <ilqgames/utils/compute_strategy_costs.h> 48 #include <ilqgames/utils/operating_point.h> 49 #include <ilqgames/utils/quadratic_cost_approximation.h> 50 #include <ilqgames/utils/strategy.h> 51 #include <ilqgames/utils/types.h> 53 #include <glog/logging.h> 54 #include <Eigen/Dense> 61 std::vector<float> ComputeStrategyCosts(
62 const std::vector<PlayerCost>& player_costs,
63 const std::vector<Strategy>& strategies,
64 const OperatingPoint& operating_point,
65 const MultiPlayerIntegrableSystem& dynamics,
const VectorXf& x0,
72 std::vector<VectorXf> us(dynamics.NumPlayers());
73 std::vector<float> total_costs(dynamics.NumPlayers(), 0.0);
74 const size_t num_time_steps =
75 (open_loop) ? strategies[0].Ps.size() - 1 : strategies[0].Ps.size();
76 for (
size_t kk = 0; kk < num_time_steps; kk++) {
78 for (PlayerIndex ii = 0; ii < dynamics.NumPlayers(); ii++) {
80 us[ii] = strategies[ii](kk, VectorXf::Zero(x.size()),
81 operating_point.us[kk][ii]);
83 us[ii] = strategies[ii](kk, x - operating_point.xs[kk],
84 operating_point.us[kk][ii]);
87 const VectorXf next_x = dynamics.Integrate(t, time::kTimeStep, x, us);
88 const Time next_t = t + time::kTimeStep;
91 for (PlayerIndex ii = 0; ii < dynamics.NumPlayers(); ii++) {
93 (open_loop) ? player_costs[ii].EvaluateOffset(t, next_t, next_x, us)
94 : player_costs[ii].Evaluate(t, x, us);
96 total_costs[ii] += cost;
107 std::vector<float> ComputeStrategyCosts(
const Problem& problem,
109 return ComputeStrategyCosts(
110 problem.PlayerCosts(), problem.CurrentStrategies(),
111 problem.CurrentOperatingPoint(), *problem.Dynamics(),
112 problem.InitialState(), open_loop);