forked from RobotLocomotion/drake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsolve.cc
35 lines (30 loc) · 1.11 KB
/
solve.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "drake/solvers/solve.h"
#include <memory>
#include "drake/common/nice_type_name.h"
#include "drake/common/text_logging.h"
#include "drake/solvers/choose_best_solver.h"
#include "drake/solvers/solver_interface.h"
namespace drake {
namespace solvers {
MathematicalProgramResult Solve(
const MathematicalProgram& prog,
const std::optional<Eigen::VectorXd>& initial_guess,
const std::optional<SolverOptions>& solver_options) {
const SolverId solver_id = ChooseBestSolver(prog);
drake::log()->debug("solvers::Solve will use {}", solver_id);
std::unique_ptr<SolverInterface> solver = MakeSolver(solver_id);
MathematicalProgramResult result{};
solver->Solve(prog, initial_guess, solver_options, &result);
return result;
}
MathematicalProgramResult Solve(
const MathematicalProgram& prog,
const Eigen::Ref<const Eigen::VectorXd>& initial_guess) {
const Eigen::VectorXd initial_guess_xd = initial_guess;
return Solve(prog, initial_guess_xd, {});
}
MathematicalProgramResult Solve(const MathematicalProgram& prog) {
return Solve(prog, {}, {});
}
} // namespace solvers
} // namespace drake