1 #include "elementencoding.h"
3 #include "naiveencoder.h"
5 #include "satencoder.h"
8 const char *elemEncTypeNames[] = {"UNASSIGNED", "ONEHOT", "UNARY", "BINARYINDEX", "BINARYVAL"};
10 ElementEncoding::ElementEncoding(Element *_element) :
11 type(ELEM_UNASSIGNED),
20 ElementEncoding::~ElementEncoding() {
21 if (variables != NULL)
23 if (encodingArray != NULL)
24 ourfree(encodingArray);
25 if (inUseArray != NULL)
29 void ElementEncoding::allocEncodingArrayElement(uint size) {
30 encodingArray = (uint64_t *) ourcalloc(1, sizeof(uint64_t) * size);
34 void ElementEncoding::allocInUseArrayElement(uint size) {
35 uint bytes = ((size + ((1 << 9) - 1)) >> 6) & ~7;//Depends on size of inUseArray
36 inUseArray = (uint64_t *) ourcalloc(1, bytes);
39 void ElementEncoding::setElementEncodingType(ElementEncodingType _type) {
43 void ElementEncoding::encodingArrayInitialization() {
44 Set *set = element->getRange();
45 uint size = set->getSize();
46 uint encSize = getSizeEncodingArray(size);
47 allocEncodingArrayElement(encSize);
48 allocInUseArrayElement(encSize);
49 for (uint i = 0; i < size; i++) {
50 encodingArray[i] = set->getMemberAt(i);
55 void ElementEncoding::print() {
56 model_print("%s ", elemEncTypeNames[type]);
57 if (type == BINARYINDEX) {
58 for (uint i = 0; i < encArraySize; i++) {
61 if (isinUseElement(i))
62 model_print("%" PRIu64 "", encodingArray[i]);