forked from RobotLocomotion/drake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdreal_solver.h
72 lines (58 loc) · 2.44 KB
/
dreal_solver.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
66
67
68
69
70
71
72
#pragma once
#include <string>
#include <unordered_map>
#include <dreal/dreal.h>
#include "drake/common/drake_copyable.h"
#include "drake/common/drake_optional.h"
#include "drake/common/hash.h"
#include "drake/common/symbolic.h"
#include "drake/solvers/solver_base.h"
namespace drake {
namespace solvers {
class DrealSolver final : public SolverBase {
public:
using Interval = dreal::Box::Interval;
using IntervalBox = std::unordered_map<symbolic::Variable, Interval>;
/// Indicates whether to use dReal's --local-optimization option or not.
enum class LocalOptimization {
kUse, ///< Use "--local-optimization" option.
kNotUse, ///< Do not use "--local-optimization" option.
};
DRAKE_NO_COPY_NO_MOVE_NO_ASSIGN(DrealSolver)
DrealSolver();
~DrealSolver() final;
/// Checks the satisfiability of a given formula @p f with a given precision
/// @p delta.
///
/// @returns a model, a mapping from a variable to an interval, if @p f is
/// δ-satisfiable.
/// @returns a nullopt, if @p is unsatisfiable.
static optional<IntervalBox> CheckSatisfiability(const symbolic::Formula& f,
double delta);
/// Finds a solution to minimize @p objective function while satisfying a
/// given @p constraint using @p delta. When @p local_optimization is
/// Localoptimization::kUse, enable "--local-optimization" dReal option which
/// uses NLopt's local-optimization algorithms to refine counterexamples in
/// the process of global optimization.
///
/// @returns a model, a mapping from a variable to an interval, if a solution
/// exists.
/// @returns nullopt, if there is no solution.
static optional<IntervalBox> Minimize(const symbolic::Expression& objective,
const symbolic::Formula& constraint,
double delta,
LocalOptimization local_optimization);
/// @name Static versions of the instance methods with similar names.
//@{
static SolverId id();
static bool is_available();
static bool ProgramAttributesSatisfied(const MathematicalProgram&);
//@}
// A using-declaration adds these methods into our class's Doxygen.
using SolverBase::Solve;
private:
void DoSolve(const MathematicalProgram&, const Eigen::VectorXd&,
const SolverOptions&, MathematicalProgramResult*) const final;
};
} // namespace solvers
} // namespace drake