1 #include "naiveencoder.h"
2 #include "elementencoding.h"
4 #include "functionencoding.h"
12 #include "tableentry.h"
17 void naiveEncodingDecision(CSolver* csolver){
18 uint size = getSizeVectorElement(csolver->allElements);
19 for(uint i=0; i<size; i++){
20 Element* element = getVectorElement(csolver->allElements, i);
21 //Whether it's a ElementFunction or ElementSet we should do the followings:
22 setElementEncodingType(getElementEncoding(element), BINARYINDEX);
23 baseBinaryIndexElementAssign(getElementEncoding(element));
24 if(GETELEMENTTYPE(element) == ELEMFUNCRETURN){
25 setFunctionEncodingType(getElementFunctionEncoding((ElementFunction*)element),
26 ENUMERATEIMPLICATIONS);
30 size = getSizeVectorBoolean(csolver->allBooleans);
31 for(uint i=0; i<size; i++){
32 Boolean* boolean = getVectorBoolean(csolver->allBooleans, i);
33 switch(GETBOOLEANTYPE(boolean)){
35 setFunctionEncodingType(getPredicateFunctionEncoding((BooleanPredicate*)boolean),
36 ENUMERATEIMPLICATIONS);
39 setOrderEncodingType( ((BooleanOrder*)boolean)->order, PAIRWISE );
47 void baseBinaryIndexElementAssign(ElementEncoding *This) {
48 Element * element=This->element;
49 Set * set= getElementSet(element);
50 ASSERT(set->isRange==false);
51 uint size=getSizeVectorInt(set->members);
52 uint encSize=NEXTPOW2(size);
53 allocEncodingArrayElement(This, encSize);
54 allocInUseArrayElement(This, encSize);
55 for(uint i=0;i<size;i++) {
56 This->encodingArray[i]=getVectorInt(set->members, i);
57 setInUseElement(This, i);