enum OrderType {PARTIAL, TOTAL};
typedef enum OrderType OrderType;
+enum HappenedBefore {UNORDERED, FIRST, SECOND};
+typedef enum HappenedBefore HappenedBefore;
+
/**
* FLAGFORCESOVERFLOW forces the operation to overflow if the boolean flag is true
* OVERFLOWSETSFLAG -- sets the flag if the operation overflows
}
static inline Edge constraintNegate(Edge e) {
+ if(edgeIsNull(e))
+ return e;
Edge enew = { (Node *) (((uintptr_t) e.node_ptr) ^ NEGATE_EDGE)};
return enew;
}
int index = getEdgeVar( ((BooleanVar*) boolean)->var );
return This->satEncoder->cnf->solver->solution[index] == true;
}
+
+HappenedBefore getOrderConstraintValueSATTranslator(CSolver* This, BooleanOrder* boolOrder){
+ ASSERT(boolOrder->order->orderPairTable!= NULL);
+ OrderPair pair={boolOrder->first, boolOrder->second, E_NULL};
+ Edge var = getOrderConstraint(boolOrder->order->orderPairTable, & pair);
+ if(edgeIsNull(var))
+ return UNORDERED;
+ int index = getEdgeVar( var );
+ return This->satEncoder->cnf->solver->solution[index] ? FIRST: SECOND;
+}
+
#define SATTRANSLATOR_H
#include "classlist.h"
+#include "ops.h"
+
bool getBooleanVariableValueSATTranslator( CSolver* This , Boolean* boolean);
+HappenedBefore getOrderConstraintValueSATTranslator(CSolver* This, BooleanOrder* boolOrder);
uint64_t getElementValueBinaryIndexSATTranslator(CSolver* This, ElementEncoding* elemEnc);
uint64_t getElementValueBinaryValueSATTranslator(CSolver* This, ElementEncoding* elemEnc);
uint64_t getElementValueOneHotSATTranslator(CSolver* This, ElementEncoding* elemEnc);
}
exit(-1);
}
+
+HappenedBefore getOrderConstraintValue(CSolver* This, Boolean* orderConstr){
+ switch(GETBOOLEANTYPE(orderConstr)){
+ case ORDERCONST:
+ return getOrderConstraintValueSATTranslator(This, (BooleanOrder*)orderConstr);
+ default:
+ ASSERT(0);
+ }
+ exit(-1);
+}
+
/** After getting the solution from the SAT solver, client can get the value of a boolean via this function*/
bool getBooleanValue( CSolver* , Boolean* boolean);
+HappenedBefore getOrderConstraintValue(CSolver*, Boolean* orderConstr);
+
#endif