return d_posVector.size();
}
+ void clear(){
+ d_list.clear();
+ d_posVector.clear();
+ }
+
void increaseSize(ArithVar max){
Assert(max >= allocated());
d_posVector.resize(max+1, ARITHVAR_SENTINEL);
*/
}
+void ReducedRowVector::enqueueNonBasicVariablesAndCoefficients(std::vector< ArithVar >& variables,std::vector< Rational >& coefficients) const{
+ for(const_iterator i=begin(), endEntries=end(); i != endEntries; ++i){
+ ArithVar var = (*i).getArithVar();
+ const Rational& q = (*i).getCoefficient();
+ if(var != basic()){
+ variables.push_back(var);
+ coefficients.push_back(q);
+ }
+ }
+}
const std::vector< Rational >& coefficients,
std::vector<uint32_t>& count,
std::vector<ArithVarSet>& columnMatrix);
-
~ReducedRowVector();
+ void enqueueNonBasicVariablesAndCoefficients(std::vector< ArithVar >& variables,
+ std::vector< Rational >& coefficients) const;
+
/** Returns the basic variable.*/
ArithVar basic() const{
Assert(basicIsSet());
#include "theory/arith/tableau.h"
+using namespace std;
using namespace CVC4;
using namespace CVC4::theory;
using namespace CVC4::theory::arith;
-using namespace std;
+
+Tableau::Tableau(const Tableau& tab){
+ internalCopy(tab);
+}
+
+void Tableau::internalCopy(const Tableau& tab){
+ uint32_t N = tab.d_rowsTable.size();
+
+ Debug("tableau::copy") << "tableau copy "<< N << endl;
+
+ if(N > 1){
+ d_columnMatrix.insert(d_columnMatrix.end(), N, ArithVarSet());
+ d_rowsTable.insert(d_rowsTable.end(), N, NULL);
+ d_basicVariables.increaseSize(N-1);
+
+ Assert(d_basicVariables.allocated() == tab.d_basicVariables.allocated());
+
+ d_rowCount.insert(d_rowCount.end(), N, 0);
+ }
+
+ ColumnMatrix::iterator i_colIter = d_columnMatrix.begin();
+ ColumnMatrix::iterator end_colIter = d_columnMatrix.end();
+ for(; i_colIter != end_colIter; ++i_colIter){
+ Column& col = *i_colIter;
+ col.increaseSize(d_columnMatrix.size());
+ }
+
+ ArithVarSet::iterator i_basicIter = tab.d_basicVariables.begin();
+ ArithVarSet::iterator i_basicEnd = tab.d_basicVariables.end();
+ for(; i_basicIter != i_basicEnd; ++i_basicIter){
+ ArithVar basicVar = *i_basicIter;
+ const ReducedRowVector* otherRow = tab.d_rowsTable[basicVar];
+
+ Assert(otherRow != NULL);
+
+ std::vector< ArithVar > variables;
+ std::vector< Rational > coefficients;
+ otherRow->enqueueNonBasicVariablesAndCoefficients(variables, coefficients);
+
+ ReducedRowVector* copy = new ReducedRowVector(basicVar, variables, coefficients, d_rowCount, d_columnMatrix);
+
+ Debug("tableau::copy") << "copying " << basicVar << endl;
+ copy->printRow();
+
+ d_basicVariables.add(basicVar);
+ d_rowsTable[basicVar] = copy;
+ }
+}
+
+Tableau& Tableau::operator=(const Tableau& other){
+ clear();
+ internalCopy(other);
+ return (*this);
+}
Tableau::~Tableau(){
+ clear();
+}
+
+void Tableau::clear(){
while(!d_basicVariables.empty()){
ArithVar curr = *(d_basicVariables.begin());
ReducedRowVector* vec = removeRow(curr);
delete vec;
}
+
+ d_rowsTable.clear();
+ d_basicVariables.clear();
+ d_rowCount.clear();
+ d_columnMatrix.clear();
}
void Tableau::addRow(ArithVar basicVar,
d_rowCount(),
d_columnMatrix()
{}
+
+ /** Copy constructor. */
+ Tableau(const Tableau& tab);
~Tableau();
+ Tableau& operator=(const Tableau& tab);
+
size_t getNumRows() const {
return d_basicVariables.size();
}
return *(d_rowsTable[var]);
}
-public:
uint32_t getRowCount(ArithVar x){
Assert(x < d_rowCount.size());
AlwaysAssert(d_rowCount[x] == getColumn(x).size());
void printTableau();
ReducedRowVector* removeRow(ArithVar basic);
+
+
+private:
+ /** Copies the datastructures in tab to this.*/
+ void internalCopy(const Tableau& tab);
+
+ /** Clears the structures in the tableau. */
+ void clear();
};
}; /* namespace arith */
}
+void TheoryArith::notifyRestart(){
+ if(Debug.isOn("paranoid:check_tableau")){ d_simplex.checkTableau(); }
+}
+
bool TheoryArith::entireStateIsConsistent(){
typedef std::vector<Node>::const_iterator VarIter;
for(VarIter i = d_variables.begin(), end = d_variables.end(); i != end; ++i){
static int callCount = 0;
Debug("arith::presolve") << "TheoryArith::presolve #" << (callCount++) << endl;
+
check(FULL_EFFORT);
}
*/
std::map<ArithVar, Node> d_removedRows;
- /**
- * Priority Queue of the basic variables that may be inconsistent.
- *
- * This is required to contain at least 1 instance of every inconsistent
- * basic variable. This is only required to be a superset though so its
- * contents must be checked to still be basic and inconsistent.
- */
- std::priority_queue<ArithVar> d_possiblyInconsistent;
-
/** Stores system wide constants to avoid unnessecary reconstruction. */
ArithConstants d_constants;
void shutdown(){ }
void presolve();
-
+ void notifyRestart();
void staticLearning(TNode in, NodeBuilder<>& learned);
std::string identify() const { return std::string("TheoryArith"); }