1 #ifndef ELEMENTENCODING_H
2 #define ELEMENTENCODING_H
4 #include "naiveencoder.h"
5 #include "constraint.h"
7 enum ElementEncodingType {
8 ELEM_UNASSIGNED, ONEHOT, UNARY, BINARYINDEX, ONEHOTBINARY, BINARYVAL
11 typedef enum ElementEncodingType ElementEncodingType;
13 struct ElementEncoding {
14 ElementEncodingType type;
16 Edge * variables;/* List Variables Used To Encode Element */
17 uint64_t * encodingArray; /* List the Variables in the appropriate order */
18 uint64_t * inUseArray;/* Bitmap to track variables in use */
20 uint numVars; /* Number of variables */
23 void initElementEncoding(ElementEncoding *This, Element *element);
24 static inline ElementEncodingType getElementEncodingType(ElementEncoding * This) {return This->type;}
25 void setElementEncodingType(ElementEncoding* This, ElementEncodingType type);
26 void deleteElementEncoding(ElementEncoding *This);
27 void allocEncodingArrayElement(ElementEncoding *This, uint size);
28 void allocInUseArrayElement(ElementEncoding *This, uint size);
29 void generateBinaryIndexEncodingVars(SATEncoder* encode, ElementEncoding* This);
30 void generateElementEncodingVariables(SATEncoder* encoder, ElementEncoding* This);
32 static inline bool isinUseElement(ElementEncoding *This, uint offset) {
33 return (This->inUseArray[(offset>>6)] >> (offset & 63)) &0x1;
36 static inline void setInUseElement(ElementEncoding *This, uint offset) {
37 This->inUseArray[(offset>>6)] |= 1 << (offset & 63);