forked from pz4kybsvg/Conception
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
901 B
29 lines
901 B
#include "drake/solvers/test/mathematical_program_test_util.h"
|
|
|
|
#include <stdexcept>
|
|
|
|
namespace drake {
|
|
namespace solvers {
|
|
namespace test {
|
|
MathematicalProgramResult RunSolver(
|
|
const MathematicalProgram& prog, const SolverInterface& solver,
|
|
const std::optional<Eigen::VectorXd>& initial_guess,
|
|
const std::optional<SolverOptions>& solver_options) {
|
|
if (!solver.available()) {
|
|
throw std::runtime_error("Solver " + solver.solver_id().name() +
|
|
" is not available");
|
|
}
|
|
|
|
MathematicalProgramResult result{};
|
|
solver.Solve(prog, initial_guess, solver_options, &result);
|
|
EXPECT_TRUE(result.is_success());
|
|
if (!result.is_success()) {
|
|
throw std::runtime_error("Solver " + solver.solver_id().name() +
|
|
" fails to find the solution");
|
|
}
|
|
return result;
|
|
}
|
|
} // namespace test
|
|
} // namespace solvers
|
|
} // namespace drake
|