Now the Tuner decides about creating proxy variables
[satune.git] / src / Encoders / elementencoding.cc
index da6efd19154b0f1f3075114151e426923bc46fe9..6cb399346a9a14765ba7e318811c722dbedecf0d 100644 (file)
@@ -8,12 +8,16 @@
 const char *elemEncTypeNames[] = {"UNASSIGNED", "ONEHOT", "UNARY", "BINARYINDEX", "BINARYVAL"};
 
 ElementEncoding::ElementEncoding(Element *_element) :
+       anyValue(false),
        type(ELEM_UNASSIGNED),
        element(_element),
        variables(NULL),
        encodingArray(NULL),
        inUseArray(NULL),
+       edgeArray(NULL),
+       polarityArray(NULL),
        encArraySize(0),
+       encoding(EENC_UNKNOWN),
        numVars(0) {
 }
 
@@ -24,6 +28,10 @@ ElementEncoding::~ElementEncoding() {
                ourfree(encodingArray);
        if (inUseArray != NULL)
                ourfree(inUseArray);
+       if (edgeArray != NULL)
+               ourfree(edgeArray);
+       if (polarityArray != NULL)
+               ourfree(polarityArray);
 }
 
 void ElementEncoding::allocEncodingArrayElement(uint size) {
@@ -32,7 +40,7 @@ void ElementEncoding::allocEncodingArrayElement(uint size) {
 }
 
 void ElementEncoding::allocInUseArrayElement(uint size) {
-       uint bytes = ((size + ((1 << 9) - 1)) >> 6) & ~7;//Depends on size of inUseArray
+       uint bytes = ((size + 63) >> 3) & ~7;   //Depends on size of inUseArray
        inUseArray = (uint64_t *) ourcalloc(1, bytes);
 }
 
@@ -47,7 +55,7 @@ void ElementEncoding::encodingArrayInitialization() {
        allocEncodingArrayElement(encSize);
        allocInUseArrayElement(encSize);
        for (uint i = 0; i < size; i++) {
-               encodingArray[i] = set->getMemberAt(i);
+               encodingArray[i] = set->getElement(i);
                setInUseElement(i);
        }
 }
@@ -57,7 +65,7 @@ void ElementEncoding::print() {
        if (type == BINARYINDEX) {
                for (uint i = 0; i < encArraySize; i++) {
                        if (i != 0)
-                               model_print(" ,");
+                               model_print("");
                        if (isinUseElement(i))
                                model_print("%" PRIu64 "", encodingArray[i]);
                        else