- Adds 3 choices of heuristic variable orders to use in ArithPriorityQueue.
- Adds the pivot-rule command line option.
using namespace CVC4::theory::arith;
ArithPriorityQueue::ArithPriorityQueue(ArithPartialModel& pm, const Tableau& tableau):
- d_partialModel(pm), d_tableau(tableau), d_modeInUse(Collection), d_ZERO_DELTA(0,0)
+ d_pivotRule(MINIMUM),
+ d_partialModel(pm),
+ d_tableau(tableau),
+ d_modeInUse(Collection),
+ d_ZERO_DELTA(0,0)
{}
+void ArithPriorityQueue::setPivotRule(PivotRule rule){
+ Assert(!inDifferenceMode());
+ Debug("arith::setPivotRule") << "setting pivot rule " << rule << endl;
+ d_pivotRule = rule;
+}
+
ArithVar ArithPriorityQueue::dequeueInconsistentBasicVariable(){
AlwaysAssert(!inCollectionMode());
if(inDifferenceMode()){
while(!d_diffQueue.empty()){
ArithVar var = d_diffQueue.front().variable();
- pop_heap(d_diffQueue.begin(), d_diffQueue.end());
+ switch(d_pivotRule){
+ case MINIMUM:
+ pop_heap(d_diffQueue.begin(), d_diffQueue.end(), VarDRatPair::minimumRule);
+ break;
+ case BREAK_TIES:
+ pop_heap(d_diffQueue.begin(), d_diffQueue.end(), VarDRatPair::breakTiesRules);
+ break;
+ case MAXIMUM:
+ pop_heap(d_diffQueue.begin(), d_diffQueue.end(), VarDRatPair::maximumRule);
+ break;
+ }
d_diffQueue.pop_back();
Debug("arith_update") << "possiblyInconsistentGriggio var" << var << endl;
if(basicAndInconsistent(var)){
break;
case Difference:
d_diffQueue.push_back(computeDiff(basic));
- push_heap(d_diffQueue.begin(), d_diffQueue.end());
+ switch(d_pivotRule){
+ case MINIMUM:
+ push_heap(d_diffQueue.begin(), d_diffQueue.end(), VarDRatPair::minimumRule);
+ break;
+ case BREAK_TIES:
+ push_heap(d_diffQueue.begin(), d_diffQueue.end(), VarDRatPair::breakTiesRules);
+ break;
+ case MAXIMUM:
+ push_heap(d_diffQueue.begin(), d_diffQueue.end(), VarDRatPair::maximumRule);
+ break;
+ }
break;
default:
Unreachable();
d_diffQueue.push_back(computeDiff(var));
}
}
- make_heap(d_diffQueue.begin(), d_diffQueue.end());
+
+ switch(d_pivotRule){
+ case MINIMUM:
+ make_heap(d_diffQueue.begin(), d_diffQueue.end(), VarDRatPair::minimumRule);
+ break;
+ case BREAK_TIES:
+ make_heap(d_diffQueue.begin(), d_diffQueue.end(), VarDRatPair::breakTiesRules);
+ break;
+ case MAXIMUM:
+ make_heap(d_diffQueue.begin(), d_diffQueue.end(), VarDRatPair::maximumRule);
+ break;
+ }
+
d_candidates.clear();
d_modeInUse = Difference;
* The queue begins in Collection mode.
*/
class ArithPriorityQueue {
-private:
+public:
+ enum PivotRule {MINIMUM, BREAK_TIES, MAXIMUM};
+private:
class VarDRatPair {
private:
ArithVar d_variable;
return d_variable;
}
- bool operator<(const VarDRatPair& other){
- return d_orderBy > other.d_orderBy;
+ static bool minimumRule(const VarDRatPair& a, const VarDRatPair& b){
+ return a.d_orderBy > b.d_orderBy;
+ }
+ static bool maximumRule(const VarDRatPair& a, const VarDRatPair& b){
+ return a.d_orderBy < b.d_orderBy;
+ }
+
+ static bool breakTiesRules(const VarDRatPair& a, const VarDRatPair& b){
+ const Rational& nonInfA = a.d_orderBy.getNoninfinitesimalPart();
+ const Rational& nonInfB = b.d_orderBy.getNoninfinitesimalPart();
+ int cmpNonInf = nonInfA.cmp(nonInfB);
+ if(cmpNonInf == 0){
+ const Rational& infA = a.d_orderBy.getInfinitesimalPart();
+ const Rational& infB = b.d_orderBy.getInfinitesimalPart();
+ int cmpInf = infA.cmp(infB);
+ if(cmpInf == 0){
+ return a.d_variable > b.d_variable;
+ }else{
+ return cmpInf > 0;
+ }
+ }else{
+ return cmpNonInf > 0;
+ }
+
+ return a.d_orderBy > b.d_orderBy;
}
};
typedef std::vector<VarDRatPair> DifferenceArray;
typedef std::vector<ArithVar> ArithVarArray;
+ PivotRule d_pivotRule;
/**
* An unordered array with no heap structure for use during collection mode.
ArithPriorityQueue(ArithPartialModel& pm, const Tableau& tableau);
+ /** precondition: !inDifferenceMode() */
+ void setPivotRule(PivotRule rule);
+
ArithVar dequeueInconsistentBasicVariable();
void enqueueIfInconsistent(ArithVar basic);
#include "theory/arith/partial_model.h"
#include "theory/output_channel.h"
+#include "util/options.h"
+
#include "util/stats.h"
#include <queue>
Node generateConflictBelow(ArithVar conflictVar);
public:
+ void notifyOptions(const Options& opt){
+ switch(opt.pivotRule){
+ case Options::MINIMUM:
+ d_queue.setPivotRule(ArithPriorityQueue::MINIMUM);
+ break;
+ case Options::BREAK_TIES:
+ d_queue.setPivotRule(ArithPriorityQueue::BREAK_TIES);
+ break;
+ case Options::MAXIMUM:
+ d_queue.setPivotRule(ArithPriorityQueue::MAXIMUM);
+ break;
+ default:
+ Unhandled(opt.pivotRule);
+ }
+ }
+
/**
* Checks to make sure the assignment is consistent with the tableau.
* This code is for debugging.
std::string identify() const { return std::string("TheoryArith"); }
+ void notifyOptions(const Options& opt) {
+ d_simplex.notifyOptions(opt);
+ }
private:
ArithVar determineLeftVariable(TNode assertion, Kind simpleKind);
#include "context/context.h"
#include "context/cdlist.h"
#include "context/cdo.h"
+#include "util/options.h"
#include <string>
#include <iostream>
d_out(&out) {
}
+
+
/**
* This is called at shutdown time by the TheoryEngine, just before
* destruction. It is important because there are destruction
*/
virtual std::string identify() const = 0;
+ virtual void notifyOptions(const Options& opt) {}
+
//
// CODE INVARIANT CHECKING (used only with CVC4_ASSERTIONS)
//
d_hasShutDown(false),
d_incomplete(ctxt, false),
d_valuation(this),
+ d_opts(opts),
d_statistics() {
Rewriter::init();
*/
Node removeITEs(TNode t);
+ const Options& d_opts;
+
public:
/**
TheoryClass* theory = new TheoryClass(d_context, d_theoryOut);
d_theoryTable[theory->getId()] = theory;
d_sharedTermManager->registerTheory(static_cast<TheoryClass*>(theory));
+
+ theory->notifyOptions(d_opts);
}
SharedTermManager* getSharedTermManager() {
NO_TYPE_CHECKING,
LAZY_TYPE_CHECKING,
EAGER_TYPE_CHECKING,
- INCREMENTAL
+ INCREMENTAL,
+ PIVOT_RULE
};/* enum OptionValue */
/**
{ "lazy-type-checking", no_argument, NULL, LAZY_TYPE_CHECKING},
{ "eager-type-checking", no_argument, NULL, EAGER_TYPE_CHECKING},
{ "incremental", no_argument, NULL, INCREMENTAL},
+ { "pivot-rule" , required_argument, NULL, PIVOT_RULE },
{ NULL , no_argument , NULL, '\0' }
};/* if you add things to the above, please remember to update usage.h! */
incrementalSolving = true;
break;
+ case PIVOT_RULE:
+ if(!strcmp(optarg, "min")) {
+ pivotRule = MINIMUM;
+ break;
+ } else if(!strcmp(optarg, "min-break-ties")) {
+ pivotRule = BREAK_TIES;
+ break;
+ } else if(!strcmp(optarg, "max")) {
+ pivotRule = MAXIMUM;
+ break;
+ } else if(!strcmp(optarg, "help")) {
+ printf("Pivot rules available:\n");
+ printf("min\n");
+ printf("min-break-ties\n");
+ printf("max\n");
+ exit(1);
+ } else {
+ throw OptionException(string("unknown option for --pivot-rule: `") +
+ optarg + "'. Try --pivot-rule help.");
+ }
+ break;
+
case SHOW_CONFIG:
fputs(Configuration::about().c_str(), stdout);
printf("\n");
/** Whether incemental solving (push/pop) */
bool incrementalSolving;
+
+ typedef enum { MINIMUM, BREAK_TIES, MAXIMUM } ArithPivotRule;
+ ArithPivotRule pivotRule;
+
Options() :
binary_name(),
statistics(false),
produceAssignments(false),
typeChecking(DO_SEMANTIC_CHECKS_BY_DEFAULT),
earlyTypeChecking(USE_EARLY_TYPE_CHECKING_BY_DEFAULT),
- incrementalSolving(false) {
+ incrementalSolving(false),
+ pivotRule(MINIMUM)
+ {
}
/**