summaryrefslogtreecommitdiff
path: root/src/theory/arith/theory_arith.cpp
diff options
context:
space:
mode:
authorMorgan Deters <mdeters@gmail.com>2012-07-31 20:40:14 +0000
committerMorgan Deters <mdeters@gmail.com>2012-07-31 20:40:14 +0000
commit24072d4b0f33abbbe1e468e5b62eb25928f7da25 (patch)
tree1ba758d66c407a2d965dd2a43d902996d27e49ec /src/theory/arith/theory_arith.cpp
parent485c03a323911142e460bd0a7c428759496dc631 (diff)
Options merge. This commit:
1. changes the way options are declared (see http://church.cims.nyu.edu/wiki/Options) 2. moves module-specific options enumerations (SimplificationMode, DecisionMode, ArithUnateLemmaMode, etc.) to their own header files, also they are no longer inside the Options:: class namespace. 3. includes many SMT-LIBv2 compliance fixes, especially to (set-option..) and (get-option..) The biggest syntactical changes (outside of adding new options) you'll notice are in accessing and setting options: * to access an option, write (e.g.) options::unconstrainedSimp() instead of Options::current()->unconstrainedSimp. * to determine if an option value was set by the user, check (e.g.) options::unconstrainedSimp.wasSetByUser(). * ensure that you have the option available (you have to #include the right module's options.h file, e.g. #include "theory/uf/options.h" for UF options) *** this point is important. If you access an option and it tells you the option doesn't exist, you aren't #including the appropriate options.h header file *** Note that if you want an option to be directly set (i.e., other than via command-line parsing or SmtEngine::setOption()), you need to mark the option :read-write in its options file (otherwise it's read-only), and you then write (e.g.) options::unconstrainedSimp.set(true). Adding new options is incredibly simple for primitive types (int, unsigned, bool, string, double). For option settings that you need to turn into a member of an enumerated type, you write a custom "handler" for the option---this is no additional work than it was before, and there are many examples to copy from (a good one is stringToSimplificationMode() in src/smt/options_handlers.h). Benefits of the new options system include: 1. changes to options declarations don't require a full-source rebuild (you only have to rebuild those sources that depend on the set of options that changed). 2. lots of sanity checks (that the same option isn't declared twice, that option values are in range for their type, that all options are documented properly, etc.) 3. consistency: Boolean-valued option --foo gets a --no-foo automatically, documentation is generated consistently, the option-parsing matches the documented option name, etc. 4. setting options programmatically via SmtEngine::setOption() is enabled, and behaves the same as command-line equivalents (including checking the value is in range, etc.) 5. the notion of options being "set by the user" is now primitive; you can use (e.g.) options::unconstrainedSimp.wasSetByUser() instead of having to use (and maintain) a separate Boolean option for the purpose I've taken lots of care not to break anything. Hopefully, I've succeeded in that.
Diffstat (limited to 'src/theory/arith/theory_arith.cpp')
-rw-r--r--src/theory/arith/theory_arith.cpp34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/theory/arith/theory_arith.cpp b/src/theory/arith/theory_arith.cpp
index c68e9cf54..d55860c41 100644
--- a/src/theory/arith/theory_arith.cpp
+++ b/src/theory/arith/theory_arith.cpp
@@ -42,6 +42,8 @@
#include "theory/arith/normal_form.h"
#include "theory/model.h"
+#include "theory/arith/options.h"
+
#include <stdint.h>
using namespace std;
@@ -651,7 +653,7 @@ Node TheoryArith::ppRewrite(TNode atom) {
<< a << endl;
}
- if (a.getKind() == kind::EQUAL && Options::current()->arithRewriteEq) {
+ if (a.getKind() == kind::EQUAL && options::arithRewriteEq()) {
Node leq = NodeBuilder<2>(kind::LEQ) << a[0] << a[1];
Node geq = NodeBuilder<2>(kind::GEQ) << a[0] << a[1];
Node rewritten = Rewriter::rewrite(leq.andNode(geq));
@@ -1536,8 +1538,8 @@ void TheoryArith::check(Effort effortLevel){
// This should be fine if sat or unknown
if(!emmittedConflictOrSplit &&
- (Options::current()->arithPropagationMode == Options::UNATE_PROP ||
- Options::current()->arithPropagationMode == Options::BOTH_PROP)){
+ (options::arithPropagationMode() == UNATE_PROP ||
+ options::arithPropagationMode() == BOTH_PROP)){
TimerStat::CodeTimer codeTimer(d_statistics.d_newPropTime);
Assert(d_qflraStatus != Result::UNSAT);
@@ -1600,7 +1602,7 @@ void TheoryArith::check(Effort effortLevel){
if(!emmittedConflictOrSplit && fullEffort(effortLevel) && !hasIntegerModel()){
Node possibleConflict = Node::null();
- if(!emmittedConflictOrSplit && Options::current()->arithDioSolver){
+ if(!emmittedConflictOrSplit && options::arithDioSolver()){
possibleConflict = callDioSolver();
if(possibleConflict != Node::null()){
revertOutOfConflict();
@@ -1610,7 +1612,7 @@ void TheoryArith::check(Effort effortLevel){
}
}
- if(!emmittedConflictOrSplit && d_hasDoneWorkSinceCut && Options::current()->arithDioSolver){
+ if(!emmittedConflictOrSplit && d_hasDoneWorkSinceCut && options::arithDioSolver()){
Node possibleLemma = dioCutting();
if(!possibleLemma.isNull()){
Debug("arith") << "dio cut " << possibleLemma << endl;
@@ -1791,8 +1793,8 @@ Node TheoryArith::explain(TNode n) {
void TheoryArith::propagate(Effort e) {
// This uses model values for safety. Disable for now.
if(d_qflraStatus == Result::SAT &&
- (Options::current()->arithPropagationMode == Options::BOUND_INFERENCE_PROP ||
- Options::current()->arithPropagationMode == Options::BOTH_PROP)
+ (options::arithPropagationMode() == BOUND_INFERENCE_PROP ||
+ options::arithPropagationMode() == BOTH_PROP)
&& hasAnyUpdates()){
propagateCandidates();
}else{
@@ -2039,21 +2041,21 @@ void TheoryArith::presolve(){
}
vector<Node> lemmas;
- switch(Options::current()->arithUnateLemmaMode){
- case Options::NO_PRESOLVE_LEMMAS:
+ switch(options::arithUnateLemmaMode()){
+ case NO_PRESOLVE_LEMMAS:
break;
- case Options::INEQUALITY_PRESOLVE_LEMMAS:
+ case INEQUALITY_PRESOLVE_LEMMAS:
d_constraintDatabase.outputUnateInequalityLemmas(lemmas);
break;
- case Options::EQUALITY_PRESOLVE_LEMMAS:
+ case EQUALITY_PRESOLVE_LEMMAS:
d_constraintDatabase.outputUnateEqualityLemmas(lemmas);
break;
- case Options::ALL_PRESOLVE_LEMMAS:
+ case ALL_PRESOLVE_LEMMAS:
d_constraintDatabase.outputUnateInequalityLemmas(lemmas);
d_constraintDatabase.outputUnateEqualityLemmas(lemmas);
break;
default:
- Unhandled(Options::current()->arithUnateLemmaMode);
+ Unhandled(options::arithUnateLemmaMode());
}
vector<Node>::const_iterator i = lemmas.begin(), i_end = lemmas.end();
@@ -2063,7 +2065,7 @@ void TheoryArith::presolve(){
d_out->lemma(lem);
}
- // if(Options::current()->arithUnateLemmaMode == Options::ALL_UNATE){
+ // if(options::arithUnateLemmaMode() == Options::ALL_UNATE){
// vector<Node> lemmas;
// d_constraintDatabase.outputAllUnateLemmas(lemmas);
// vector<Node>::const_iterator i = lemmas.begin(), i_end = lemmas.end();
@@ -2187,7 +2189,7 @@ void TheoryArith::propagateCandidates(){
for(; i != end; ++i){
ArithVar var = *i;
if(d_tableau.isBasic(var) &&
- d_tableau.getRowLength(d_tableau.basicToRowIndex(var)) <= Options::current()->arithPropagateMaxLength){
+ d_tableau.getRowLength(d_tableau.basicToRowIndex(var)) <= options::arithPropagateMaxLength()){
d_candidateBasics.softAdd(var);
}else{
Tableau::ColIterator basicIter = d_tableau.colIterator(var);
@@ -2197,7 +2199,7 @@ void TheoryArith::propagateCandidates(){
ArithVar rowVar = d_tableau.rowIndexToBasic(ridx);
Assert(entry.getColVar() == var);
Assert(d_tableau.isBasic(rowVar));
- if(d_tableau.getRowLength(ridx) <= Options::current()->arithPropagateMaxLength){
+ if(d_tableau.getRowLength(ridx) <= options::arithPropagateMaxLength()){
d_candidateBasics.softAdd(rowVar);
}
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback