dlinear  0.0.1
Delta-complete SMT solver for linear programming
Loading...
Searching...
No Matches
ExpressionEvaluator.h
1
8#pragma once
9
10#include <iosfwd>
11
12#include "dlinear/symbolic/GenericExpressionVisitor.h"
13#include "dlinear/symbolic/symbolic.h"
14#include "dlinear/util/Box.h"
15#include "dlinear/util/Interval.h"
16
17namespace dlinear {
18
25class ExpressionEvaluator : public GenericExpressionVisitor<Interval, const Box&> {
26 public:
33
35 [[nodiscard]] Interval Process(const Box& box) const;
36 [[nodiscard]] Interval operator()(const Box& box) const;
37
38 [[nodiscard]] const Variables& variables() const { return e_.GetVariables(); }
39 [[nodiscard]] const Expression& expression() const { return e_; }
40
41 private:
42 [[nodiscard]] Interval VisitVariable(const Expression& e, const Box& box) const override;
43 [[nodiscard]] Interval VisitConstant(const Expression& e, const Box& box) const override;
44 [[nodiscard]] Interval VisitRealConstant(const Expression& e, const Box& box) const;
45 [[nodiscard]] Interval VisitAddition(const Expression& e, const Box& box) const override;
46 [[nodiscard]] Interval VisitMultiplication(const Expression& e, const Box& box) const override;
47 [[nodiscard]] Interval VisitDivision(const Expression& e, const Box& box) const override;
48 [[nodiscard]] Interval VisitLog(const Expression& e, const Box& box) const override;
49 [[nodiscard]] Interval VisitAbs(const Expression& e, const Box& box) const override;
50 [[nodiscard]] Interval VisitExp(const Expression& e, const Box& box) const override;
51 [[nodiscard]] Interval VisitSqrt(const Expression& e, const Box& box) const override;
52 [[nodiscard]] Interval VisitPow(const Expression& e, const Box& box) const override;
53
54 // Evaluates `pow(e1, e2)` with the @p box.
55 [[nodiscard]] Interval VisitPow(const Expression& e1, const Expression& e2, const Box& box) const;
56 [[nodiscard]] Interval VisitSin(const Expression& e, const Box& box) const override;
57 [[nodiscard]] Interval VisitCos(const Expression& e, const Box& box) const override;
58 [[nodiscard]] Interval VisitTan(const Expression& e, const Box& box) const override;
59 [[nodiscard]] Interval VisitAsin(const Expression& e, const Box& box) const override;
60 [[nodiscard]] Interval VisitAcos(const Expression& e, const Box& box) const override;
61 [[nodiscard]] Interval VisitAtan(const Expression& e, const Box& box) const override;
62 [[nodiscard]] Interval VisitAtan2(const Expression& e, const Box& box) const override;
63 [[nodiscard]] Interval VisitSinh(const Expression& e, const Box& box) const override;
64 [[nodiscard]] Interval VisitCosh(const Expression& e, const Box& box) const override;
65 [[nodiscard]] Interval VisitTanh(const Expression& e, const Box& box) const override;
66 [[nodiscard]] Interval VisitMin(const Expression& e, const Box& box) const override;
67 [[nodiscard]] Interval VisitMax(const Expression& e, const Box& box) const override;
68 [[nodiscard]] Interval VisitIfThenElse(const Expression& e, const Box& box) const override;
69 [[nodiscard]] Interval VisitUninterpretedFunction(const Expression& e, const Box& box) const override;
70
71 const Expression e_;
72};
73
74std::ostream& operator<<(std::ostream& os, const ExpressionEvaluator& expression_evaluator);
75
76} // namespace dlinear
Collection of variables with associated intervals.
Definition Box.h:31
Simple dataclass used to store the configuration of the program.
Definition Config.h:38
Evaluate an expression with a given box.
ExpressionEvaluator(Expression e, const Config &config)
Construct a new ExpressionEvaluator object with the given expression and configuration.
Interval Process(const Box &box) const
Evaluates the expression with box.
Generic expression visitor implementing the visitor pattern.
Represents a symbolic form of an expression.
const Variables & GetVariables() const
Collects variables in expression.
Represents a set of variables.
Global namespace for the dlinear library.