Edge getPairConstraint(SATEncoder *This, HashTableOrderPair * table, OrderPair * pair) {
bool negate = false;
OrderPair flipped;
- if (pair->first > pair->second) {
+ if (pair->first < pair->second) {
negate=true;
flipped.first=pair->second;
flipped.second=pair->first;
Edge getOrderConstraint(HashTableOrderPair *table, OrderPair *pair){
ASSERT(pair->first!= pair->second);
- OrderPair* value = getOrderPair(table, pair);
- if(value == NULL)
+ bool negate = false;
+ OrderPair flipped;
+ if (pair->first < pair->second) {
+ negate=true;
+ flipped.first=pair->second;
+ flipped.second=pair->first;
+ pair = &flipped;
+ }
+ if (!containsOrderPair(table, pair)) {
return E_NULL;
- Edge constraint = value->constraint;
- model_print("Constraint:\n");
- printCNF(constraint);
- model_print("\n***********\n");
- if(pair->first > pair->second || edgeIsNull(constraint))
- return constraint;
- else
- return constraintNegate(constraint);
+ }
+ Edge constraint= getOrderPair(table, pair)->constraint;
+ ASSERT(!edgeIsNull(constraint));
+ return negate ? constraintNegate(constraint) : constraint;
}
Edge generateTransOrderConstraintSATEncoder(SATEncoder *This, Edge constIJ,Edge constJK,Edge constIK){
HappenedBefore getOrderConstraintValueSATTranslator(CSolver* This, Order * order, uint64_t first, uint64_t second){
ASSERT(order->orderPairTable!= NULL);
- model_print("Frist:%llu\tSecond:%llu\n", first, second);
OrderPair pair={first, second, E_NULL};
- Edge var = getOrderConstraint(order->orderPairTable, & pair);
+ Edge var = getOrderConstraint(order->orderPairTable, &pair);
if(edgeIsNull(var))
return UNORDERED;
return getValueCNF(This->satEncoder->cnf, var)? FIRST: SECOND;
addConstraint(solver, b1);
addConstraint(solver, b2);
if (startEncoding(solver)==1)
- printf("O(5,1)=%d O(1,4)=%d O(5,4)=%d O(1,5)=%d\n",
+ printf("O(5,1)=%d O(1,4)=%d O(5,4)=%d O(1,5)=%d O(1111,5)=%d\n",
getOrderConstraintValue(solver, order, 5, 1),
getOrderConstraintValue(solver, order, 1, 4),
getOrderConstraintValue(solver, order, 5, 4),
- getOrderConstraintValue(solver, order, 1, 5));
+ getOrderConstraintValue(solver, order, 1, 5),
+ getOrderConstraintValue(solver, order, 1111, 5));
else
printf("UNSAT\n");
deleteSolver(solver);