From 514f5b7abd94760f871998f8dc333879ce33924a Mon Sep 17 00:00:00 2001 From: bdemsky Date: Mon, 17 Jul 2017 11:59:24 -0700 Subject: [PATCH] Handle sets of 1 --- src/Backend/satelemencoder.c | 4 ++-- src/common.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Backend/satelemencoder.c b/src/Backend/satelemencoder.c index 4f22ba0..5a47435 100644 --- a/src/Backend/satelemencoder.c +++ b/src/Backend/satelemencoder.c @@ -31,10 +31,10 @@ Edge getElementValueBinaryIndexConstraint(SATEncoder * This, Element* elem, uint ElementEncoding* elemEnc = getElementEncoding(elem); for(uint i=0; iencArraySize; i++){ if(isinUseElement(elemEnc, i) && elemEnc->encodingArray[i]==value) { - return generateBinaryConstraint(This->cnf, elemEnc->numVars, elemEnc->variables, i); + return (elemEnc->numVars == 0) ? E_True: generateBinaryConstraint(This->cnf, elemEnc->numVars, elemEnc->variables, i); } } - return E_BOGUS; + return E_False; } Edge getElementValueOneHotConstraint(SATEncoder * This, Element* elem, uint64_t value) { diff --git a/src/common.h b/src/common.h index 5d8c389..a06dab2 100644 --- a/src/common.h +++ b/src/common.h @@ -32,7 +32,7 @@ extern int switch_alloc; #define model_print printf -#define NEXTPOW2(x) (1<<(sizeof(uint)*8-__builtin_clz(x-1))) +#define NEXTPOW2(x) ((x==1) ? 1 : (1<<(sizeof(uint)*8-__builtin_clz(x-1)))) #define NUMBITS(x) ((x==0) ? 0 : 8*sizeof(x)-__builtin_clz(x)) #ifdef CONFIG_DEBUG -- 2.34.1