1 /********************* */
2 /*! \file infer_bounds.h
4 ** Top contributors (to current version):
6 ** This file is part of the CVC4 project.
7 ** Copyright (c) 2009-2019 by the authors listed in the file AUTHORS
8 ** in the top-level source directory) and their institutional affiliations.
9 ** All rights reserved. See the file COPYING in the top-level source
10 ** directory for licensing information.\endverbatim
12 ** \brief [[ Add one-line brief description here ]]
14 ** [[ Add lengthier description here ]]
15 ** \todo document this file
18 #include "cvc4_private.h"
24 #include "expr/node.h"
25 #include "theory/arith/delta_rational.h"
26 #include "theory/theory.h"
27 #include "util/integer.h"
28 #include "util/maybe.h"
29 #include "util/rational.h"
36 namespace inferbounds
{
37 enum Algorithms
{None
= 0, Lookup
, RowSum
, Simplex
};
38 enum SimplexParamKind
{ Unbounded
, NumVars
, Direct
};
40 class InferBoundAlgorithm
{
43 Maybe
<int> d_simplexRounds
;
44 InferBoundAlgorithm(Algorithms a
);
45 InferBoundAlgorithm(const Maybe
<int>& simplexRounds
);
48 InferBoundAlgorithm();
50 Algorithms
getAlgorithm() const;
51 const Maybe
<int>& getSimplexRounds() const;
53 static InferBoundAlgorithm
mkLookup();
54 static InferBoundAlgorithm
mkRowSum();
55 static InferBoundAlgorithm
mkSimplex(const Maybe
<int>& rounds
);
58 std::ostream
& operator<<(std::ostream
& os
, const Algorithms a
);
59 } /* namespace inferbounds */
61 class ArithEntailmentCheckParameters
: public EntailmentCheckParameters
{
63 typedef std::vector
<inferbounds::InferBoundAlgorithm
> VecInferBoundAlg
;
64 VecInferBoundAlg d_algorithms
;
67 typedef VecInferBoundAlg::const_iterator const_iterator
;
69 ArithEntailmentCheckParameters();
70 ~ArithEntailmentCheckParameters();
72 void addLookupRowSumAlgorithms();
73 void addAlgorithm(const inferbounds::InferBoundAlgorithm
& alg
);
75 const_iterator
begin() const;
76 const_iterator
end() const;
81 class InferBoundsResult
{
84 InferBoundsResult(Node term
, bool ub
);
86 void setBound(const DeltaRational
& dr
, Node exp
);
87 bool foundBound() const;
90 bool boundIsOptimal() const;
92 void setInconsistent();
93 bool inconsistentState() const;
95 const DeltaRational
& getValue() const;
96 bool boundIsRational() const;
97 const Rational
& valueAsRational() const;
98 bool boundIsInteger() const;
99 Integer
valueAsInteger() const;
101 Node
getTerm() const;
102 Node
getLiteral() const;
103 void setTerm(Node t
){ d_term
= t
; }
105 /* If there is a bound, this is a node that explains the bound. */
106 Node
getExplanation() const;
108 bool budgetIsExhausted() const;
109 void setBudgetExhausted();
111 bool thresholdWasReached() const;
112 void setReachedThreshold();
114 bool findUpperBound() const { return d_upperBound
; }
116 void setFindLowerBound() { d_upperBound
= false; }
117 void setFindUpperBound() { d_upperBound
= true; }
119 /* was a bound found */
122 /* was the budget exhausted */
123 bool d_budgetExhausted
;
125 /* does the bound have to be optimal*/
126 bool d_boundIsProvenOpt
;
128 /* was this started on an inconsistent state. */
129 bool d_inconsistentState
;
131 /* reached the threshold. */
132 bool d_reachedThreshold
;
134 /* the value of the bound */
135 DeltaRational d_value
;
137 /* The input term. */
140 /* Was the bound found an upper or lower bound.*/
143 /* Explanation of the bound. */
147 std::ostream
& operator<<(std::ostream
& os
, const InferBoundsResult
& ibr
);
149 class ArithEntailmentCheckSideEffects
: public EntailmentCheckSideEffects
{
151 ArithEntailmentCheckSideEffects();
152 ~ArithEntailmentCheckSideEffects();
154 InferBoundsResult
& getSimplexSideEffects();
157 InferBoundsResult
* d_simplexSideEffects
;
161 } /* namespace arith */
162 } /* namespace theory */
163 } /* namespace CVC4 */