1 #include "naiveencoder.h"
2 #include "elementencoding.h"
4 #include "functionencoding.h"
12 #include "tableentry.h"
16 void naiveEncodingDecision(CSolver *This) {
17 SetIteratorBooleanEdge *iterator = This->getConstraints();
18 while (iterator->hasNext()) {
19 BooleanEdge b = iterator->next();
20 naiveEncodingConstraint(b.getBoolean());
25 void naiveEncodingConstraint(Boolean *This) {
31 if(((BooleanOrder *) This)->order->encoding.type == ORDER_UNASSIGNED)
32 ((BooleanOrder *) This)->order->setOrderEncodingType(PAIRWISE);
36 naiveEncodingLogicOp((BooleanLogic *) This);
40 naiveEncodingPredicate((BooleanPredicate *) This);
48 void naiveEncodingLogicOp(BooleanLogic *This) {
49 for (uint i = 0; i < This->inputs.getSize(); i++) {
50 naiveEncodingConstraint(This->inputs.get(i).getBoolean());
54 void naiveEncodingPredicate(BooleanPredicate *This) {
55 FunctionEncoding *encoding = This->getFunctionEncoding();
56 if (encoding->getFunctionEncodingType() == FUNC_UNASSIGNED)
57 This->getFunctionEncoding()->setFunctionEncodingType(ENUMERATEIMPLICATIONS);
59 for (uint i = 0; i < This->inputs.getSize(); i++) {
60 Element *element = This->inputs.get(i);
61 naiveEncodingElement(element);
65 void naiveEncodingElement(Element *This) {
66 ElementEncoding *encoding = This->getElementEncoding();
67 if (encoding->getElementEncodingType() == ELEM_UNASSIGNED) {
68 encoding->setElementEncodingType(BINARYINDEX);
69 encoding->encodingArrayInitialization();
72 if (This->type == ELEMFUNCRETURN) {
73 ElementFunction *function = (ElementFunction *) This;
74 for (uint i = 0; i < function->inputs.getSize(); i++) {
75 Element *element = function->inputs.get(i);
76 naiveEncodingElement(element);
78 FunctionEncoding *encoding = function->getElementFunctionEncoding();
79 if (encoding->getFunctionEncodingType() == FUNC_UNASSIGNED)
80 function->getElementFunctionEncoding()->setFunctionEncodingType(ENUMERATEIMPLICATIONS);