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 class ElementEncoding {
15 ElementEncoding(Element *element);
16 ElementEncodingType getElementEncodingType() {return type;}
18 void setElementEncodingType(ElementEncodingType type);
19 void deleteElementEncoding();
20 void allocEncodingArrayElement(uint size);
21 void allocInUseArrayElement(uint size);
22 uint numEncodingVars() {return numVars;}
23 bool isinUseElement(uint offset) { return (inUseArray[(offset >> 6)] >> (offset & 63)) & 0x1;}
24 void setInUseElement(uint offset) {inUseArray[(offset >> 6)] |= 1 << (offset & 63);}
25 void encodingArrayInitialization();
26 uint getSizeEncodingArray(uint setSize) {
29 return NEXTPOW2(setSize);
40 ElementEncodingType type;
42 Edge *variables;/* List Variables Used To Encode Element */
45 uint64_t *encodingArray; /* List the Variables in the appropriate order */
46 uint64_t *inUseArray; /* Bitmap to track variables in use */
50 uint64_t offset;/* Value = offset + encoded number (interpretted according to isBinaryValSigned) */
51 uint64_t low;/* Lowest value to encode */
52 uint64_t high;/* High value to encode. If low > high, we assume wrap around to include 0. */
54 bool isBinaryValSigned;
57 uint numVars; /* Number of variables */