ilqgames
A new real-time solver for large-scale differential games.
augmented_lagrangian_solver.h
1 /*
2  * Copyright (c) 2020, The Regents of the University of California (Regents).
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above
13  * copyright notice, this list of conditions and the following
14  * disclaimer in the documentation and/or other materials provided
15  * with the distribution.
16  *
17  * 3. Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  *
33  * Please contact the author(s) of this library if you have any questions.
34  * Authors: David Fridovich-Keil ( dfk@eecs.berkeley.edu )
35  */
36 
37 ///////////////////////////////////////////////////////////////////////////////
38 //
39 // Solver that implements an augmented Lagrangian method. For reference on these
40 // methods, please refer to Chapter 17 of Nocedal and Wright or the ALTRO paper:
41 // https://bjack205.github.io/assets/ALTRO.pdf.
42 //
43 ///////////////////////////////////////////////////////////////////////////////
44 
45 #ifndef ILQGAMES_SOLVER_AUGMENTED_LAGRANGIAN_SOLVER_H
46 #define ILQGAMES_SOLVER_AUGMENTED_LAGRANGIAN_SOLVER_H
47 
48 #include <ilqgames/dynamics/multi_player_dynamical_system.h>
49 #include <ilqgames/dynamics/multi_player_integrable_system.h>
50 #include <ilqgames/solver/game_solver.h>
51 #include <ilqgames/solver/ilq_solver.h>
52 #include <ilqgames/solver/lq_feedback_solver.h>
53 #include <ilqgames/solver/lq_open_loop_solver.h>
54 #include <ilqgames/solver/lq_solver.h>
55 #include <ilqgames/solver/problem.h>
56 #include <ilqgames/solver/solver_params.h>
57 #include <ilqgames/utils/linear_dynamics_approximation.h>
58 #include <ilqgames/utils/loop_timer.h>
59 #include <ilqgames/utils/operating_point.h>
60 #include <ilqgames/utils/quadratic_cost_approximation.h>
61 #include <ilqgames/utils/solver_log.h>
62 #include <ilqgames/utils/strategy.h>
63 #include <ilqgames/utils/types.h>
64 
65 #include <glog/logging.h>
66 #include <chrono>
67 #include <limits>
68 #include <memory>
69 #include <utility>
70 #include <vector>
71 
72 namespace ilqgames {
73 
75  public:
77  AugmentedLagrangianSolver(const std::shared_ptr<Problem>& problem,
78  const SolverParams& params)
79  : GameSolver(problem, params) {
80  // Modify parameters for unconstrained solver.
81  SolverParams unconstrained_solver_params(params);
82  unconstrained_solver_params.max_solver_iters =
83  params.unconstrained_solver_max_iters;
84  unconstrained_solver_.reset(
85  new ILQSolver(problem, unconstrained_solver_params));
86  }
87 
88  // Solve this game. Returns true if converged. Defaults to 5 s runtime.
89  std::shared_ptr<SolverLog> Solve(bool* success = nullptr,
90  Time max_runtime = 5.0);
91 
92  private:
93  // Lower level (unconstrained) solver.
94  std::unique_ptr<ILQSolver> unconstrained_solver_;
95 }; // class AugmentedLagrangianSolver
96 
97 } // namespace ilqgames
98 
99 #endif