forked from RobotLocomotion/drake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
solver_interface.h
65 lines (52 loc) · 2.25 KB
/
solver_interface.h
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#pragma once
#include <Eigen/Core>
#include "drake/common/drake_copyable.h"
#include "drake/common/drake_deprecated.h"
#include "drake/solvers/mathematical_program_result.h"
#include "drake/solvers/solution_result.h"
#include "drake/solvers/solver_id.h"
#include "drake/solvers/solver_options.h"
#include "drake/solvers/solver_result.h"
namespace drake {
namespace solvers {
// TODO(jwnimmer-tri) Once MathematicalProgram no longer has a SolverInterface,
// we can change this to an include statement instead of forward declaration.
class MathematicalProgram;
/// Interface used by implementations of individual solvers.
class SolverInterface {
public:
DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN(SolverInterface)
virtual ~SolverInterface();
/// Returns true iff this solver was enabled at compile-time.
virtual bool available() const = 0;
/// Sets values for the decision variables on the given MathematicalProgram
/// @p prog, or:
/// * If no solver is available, throws std::runtime_error
/// * If the solver returns an error, returns a nonzero SolutionResult.
virtual SolutionResult Solve(
// NOLINTNEXTLINE(runtime/references)
MathematicalProgram& prog) const = 0;
/// Solves an optimization program with optional initial guess and solver
/// options. Note that these initial guess and solver options are not written
/// to @p prog.
/// If the @p prog has set an option for a solver, and @p solver_options
/// contains a different value for the same option on the same solver, then @p
/// solver_options takes priority.
virtual void Solve(const MathematicalProgram& prog,
const optional<Eigen::VectorXd>& initial_guess,
const optional<SolverOptions>& solver_options,
MathematicalProgramResult* result) const = 0;
/// Returns the identifier of this solver.
virtual SolverId solver_id() const = 0;
/// Returns true if the program attributes are satisfied by the solver's
/// capability.
virtual bool AreProgramAttributesSatisfied(
const MathematicalProgram& prog) const = 0;
protected:
SolverInterface();
};
using MathematicalProgramSolverInterface
DRAKE_DEPRECATED("2019-05-01", "Transitional alias.")
= SolverInterface;
} // namespace solvers
} // namespace drake