void EncodingGraph::encode() {
- if (solver->getTuner()->getTunable(ENCODINGGRAPHOPT, &offon) == 0)
+ if (solver->getTuner()->getTunable(ENCODINGGRAPHOPT, &onoff) == 0)
return;
buildGraph();
SetIteratorEncodingSubGraph *itesg = subgraphs.iterator();
newSize = (leftSize > newSize) ? leftSize : newSize;
newSize = (rightSize > newSize) ? rightSize : newSize;
min = rightSize > leftSize ? leftSize : rightSize;
-// model_print("Merge=%s\tsimilarity=%f\n", max==newSize?"TRUE":"FALSE", left->measureSimilarity(right));
merge = leftGraph->measureSimilarity(right) > 1.5 || min == newSize;
+// model_print("Merge=%s\tsimilarity=%f\n", merge?"TRUE":"FALSE", leftGraph->measureSimilarity(right));
} else {
//Neither are null
leftSize = convertSize(leftGraph->numValues());
newSize = (leftSize > newSize) ? leftSize : newSize;
newSize = (rightSize > newSize) ? rightSize : newSize;
min = rightSize > leftSize ? leftSize : rightSize;
-// model_print("Merge=%s\tsimilarity=%f\n", max==newSize?"TRUE":"FALSE", leftGraph->measureSimilarity(right));
merge = leftGraph->measureSimilarity(rightGraph) > 1.5 || min == newSize;
+// model_print("Merge=%s\tsimilarity=%f\n", merge?"TRUE":"FALSE", leftGraph->measureSimilarity(rightGraph));
}
if (merge) {
//add the edge
if (encoding->element->anyValue) {
uint setSize = encoding->element->getRange()->getSize();
int maxIndex = getMaximumUsedIndex(encoding);
-// model_print("maxIndex=%d\tsetSize=%u\tmetric=%f\n", maxIndex, setSize, (maxIndex - setSize) == 0? -1.0 : (setSize*1.0/(maxIndex-setSize)) );
- if (maxIndex != -1 && (maxIndex - setSize) != 0 && (setSize * 1.0 / (maxIndex - setSize)) < pow(1.9, (uint)solver->getTuner()->getTunable(MUSTVALUE, &mustValueBinaryIndex) - 4)) {
+ maxIndex = maxIndex == -1? (int)encoding->encArraySize : maxIndex;
+ if(setSize == encoding->encArraySize && maxIndex == (int)setSize){
+ return;
+ }
+ double ratio = (setSize*(1+2*encoding->numVars))/ (encoding->numVars*(encoding->numVars + maxIndex*1.0 - setSize));
+// model_print("encArraySize=%u\tmaxIndex=%d\tsetSize=%u\tmetric=%f\tnumBits=%u\n", encoding->encArraySize, maxIndex, setSize, ratio, encoding->numVars);
+ if ( ratio < pow(2, (uint)solver->getTuner()->getTunable(MUSTVALUE, &mustValueBinaryIndex) - 3)) {
generateAnyValueBinaryIndexEncodingPositive(encoding);
} else {
generateAnyValueBinaryIndexEncoding(encoding);