From: Hamed Date: Wed, 12 Jul 2017 20:18:52 +0000 (-0700) Subject: Adding sat solution translator for binary value encoding X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=07e565ec8d703fd955dbebe767384ae2dbdfa504;p=satune.git Adding sat solution translator for binary value encoding --- diff --git a/src/Backend/sattranslator.c b/src/Backend/sattranslator.c index f118e5b..1569b82 100644 --- a/src/Backend/sattranslator.c +++ b/src/Backend/sattranslator.c @@ -14,6 +14,16 @@ uint64_t getElementValueBinaryIndexSATTranslator(CSolver* This, ElementEncoding* return elemEnc->encodingArray[index]; } +uint64_t getElementValueBinaryValueSATTranslator(CSolver* This, ElementEncoding* elemEnc){ + uint64_t value=0; + for(int i=elemEnc->numVars-1;i>=0;i--) { + value=value<<1; + if (This->satEncoder->cnf->solver->solution[ getEdgeVar( elemEnc->variables[i] ) ]) + value |= 1; + } + return value; +} + uint64_t getElementValueOneHotSATTranslator(CSolver* This, ElementEncoding* elemEnc){ uint index=0; for(int i=elemEnc->numVars-1;i>=0;i--) { diff --git a/src/Backend/sattranslator.h b/src/Backend/sattranslator.h index 64ad37d..52e40a7 100644 --- a/src/Backend/sattranslator.h +++ b/src/Backend/sattranslator.h @@ -11,6 +11,8 @@ #include "classlist.h" bool getBooleanVariableValueSATTranslator( CSolver* This , Boolean* boolean); +uint64_t getElementValueBinaryIndexSATTranslator(CSolver* This, ElementEncoding* elemEnc); +uint64_t getElementValueBinaryValueSATTranslator(CSolver* This, ElementEncoding* elemEnc); uint64_t getElementValueOneHotSATTranslator(CSolver* This, ElementEncoding* elemEnc); uint64_t getElementValueUnarySATTranslator(CSolver* This, ElementEncoding* elemEnc); uint64_t getElementValueSATTranslator(CSolver* This, Element* element);