1 #include "elementencoding.h"
3 #include "naiveencoder.h"
5 #include "satencoder.h"
7 void initElementEncoding(ElementEncoding * This, Element *element) {
9 This->type=ELEM_UNASSIGNED;
11 This->encodingArray=NULL;
12 This->inUseArray=NULL;
17 void deleteElementEncoding(ElementEncoding *This) {
18 if (This->variables!=NULL)
19 ourfree(This->variables);
20 if (This->encodingArray!=NULL)
21 ourfree(This->encodingArray);
22 if (This->inUseArray!=NULL)
23 ourfree(This->inUseArray);
26 void allocEncodingArrayElement(ElementEncoding *This, uint size) {
27 This->encodingArray=ourcalloc(1, sizeof(uint64_t)*size);
28 This->encArraySize=size;
31 void allocInUseArrayElement(ElementEncoding *This, uint size) {
32 uint bytes = ((size + ((1 << 9)-1)) >> 6)&~7;//Depends on size of inUseArray
33 This->inUseArray=ourcalloc(1, bytes);
36 void allocElementConstraintVariables(ElementEncoding* This, uint numVars){
37 This->numVars = numVars;
38 This->variables = ourmalloc(sizeof(Constraint*) * numVars);
41 void setElementEncodingType(ElementEncoding* This, ElementEncodingType type){
45 void generateBinaryIndexEncodingVars(SATEncoder* encoder, ElementEncoding* This){
46 ASSERT(This->type==BINARYINDEX);
47 allocElementConstraintVariables(This, NUMBITS(This->encArraySize-1));
48 getArrayNewVarsSATEncoder(encoder, This->numVars, This->variables);
51 void generateElementEncodingVariables(SATEncoder* encoder, ElementEncoding* This){
52 ASSERT(This->type!=ELEM_UNASSIGNED);
53 if(This->variables!=NULL)
57 generateBinaryIndexEncodingVars(encoder, This);