tmp->order=order;
tmp->first=first;
tmp->second=second;
+ tmp->var=NULL;
allocInlineDefVectorBoolean(GETBOOLEANPARENTS(tmp));
return & tmp -> base;
}
Order* order;
uint64_t first;
uint64_t second;
+ Constraint* var;
};
struct BooleanVar {
return order;
}
+void addOrderConstraint(Order* order, BooleanOrder* constraint){
+ pushVectorBoolean( &order->constraints, (Boolean) constraint);
+}
+
+void setOrderEncodingType(Order* order, OrderEncodingType type){
+ order->order.type = type;
+}
+
void deleteOrder(Order* order){
deleteVectorArrayBoolean(& order->constraints);
deleteOrderEncoding(& order->order);
#include "structs.h"
#include "ops.h"
#include "orderencoding.h"
+#include "boolean.h"
struct Order {
OrderType type;
};
Order* allocOrder(OrderType type, Set * set);
+void addOrderConstraint(Order* order, BooleanOrder* constraint);
+void setOrderEncodingType(Order* order, OrderEncodingType type);
void deleteOrder(Order* order);
#endif
#include "function.h"
#include "tableentry.h"
#include "table.h"
+#include "order.h"
SATEncoder * allocSATEncoder() {
}
Constraint * encodeOrderSATEncoder(SATEncoder *This, BooleanOrder * constraint) {
- //TO IMPLEMENT
- return NULL;
+ if(constraint->var== NULL){
+ constraint->var = getNewVarSATEncoder(This);
+ }
+ return constraint->var;
}
Constraint * encodePredicateSATEncoder(SATEncoder * This, BooleanPredicate * constraint) {
default:
ASSERT(0);
}
- //FIXME
return NULL;
}
default:
ASSERT(0);
}
- //FIXME
return NULL;
}
ArrayElement* elements= &This->inputs;
Table* table = ((FunctionTable*) (This->function))->table;
uint size = getSizeVectorTableEntry(&table->entries);
+ Constraint* constraints[size]; //FIXME: should add a space for the case that didn't match any entries
for(uint i=0; i<size; i++){
TableEntry* entry = getVectorTableEntry(&table->entries, i);
uint inputNum =getSizeArrayElement(elements);
}
Constraint* row= allocConstraint(IMPLIES, allocArrayConstraint(AND, inputNum, carray),
getElementValueConstraint((Element*)This, entry->output));
- pushVectorConstraint( getSATEncoderAllConstraints(encoder), row);
+ constraints[i]=row;
}
- //FIXME
- return NULL;
+ Constraint* result = allocArrayConstraint(OR, size, constraints);
+ pushVectorConstraint( getSATEncoderAllConstraints(encoder), result);
+ return result;
}
\ No newline at end of file
#include "boolean.h"
#include "table.h"
#include "tableentry.h"
+#include "order.h"
#include <strings.h>
size = getSizeVectorBoolean(csolver->allBooleans);
for(uint i=0; i<size; i++){
- Boolean* predicate = getVectorBoolean(csolver->allBooleans, i);
- switch(GETBOOLEANTYPE(predicate)){
+ Boolean* boolean = getVectorBoolean(csolver->allBooleans, i);
+ switch(GETBOOLEANTYPE(boolean)){
case PREDICATEOP:
- setFunctionEncodingType(getPredicateFunctionEncoding((BooleanPredicate*)predicate),
+ setFunctionEncodingType(getPredicateFunctionEncoding((BooleanPredicate*)boolean),
ENUMERATEIMPLICATIONS);
break;
+ case ORDERCONST:
+ setOrderEncodingType( ((BooleanOrder*)boolean)->order, PAIRWISE );
+ break;
default:
continue;
}