Browse Source

Fixes to handling of constants in CUDD - factor out pre-hash truncation in to a separate function and make sure truncation is also carrued oit when *re*hashing the table. [from Joachim Klein]

git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@10872 bbc10eb1-c90d-0410-af57-cb519fbb1720
master
Dave Parker 10 years ago
parent
commit
325d8c5cd2
  1. 35
      cudd/cudd/cuddTable.c

35
cudd/cudd/cuddTable.c

@ -1463,6 +1463,28 @@ cuddUniqueInterZdd(
} /* end of cuddUniqueInterZdd */ } /* end of cuddUniqueInterZdd */
/**
* Truncate a double value to 10^-10 precision.
*/
static double truncateDoubleConstant(double value)
{
double trunc, m, n;
// (round off before doing hash function to ensure
// close valued constants are in the same table)
if (finite(value)) {
trunc = 10000000000.0; // 10^10
m = value * trunc;
n = floor(m);
if (m-n >= 0.5)
n = n + 1;
n = n / trunc;
return n;
} else {
return value;
}
}
/**Function******************************************************************** /**Function********************************************************************
Synopsis [Checks the unique table for the existence of a constant node.] Synopsis [Checks the unique table for the existence of a constant node.]
@ -1511,17 +1533,7 @@ cuddUniqueConst(
// this is the new version... // this is the new version...
// (round off before doing hash function to ensure // (round off before doing hash function to ensure
// close valued constants are in the same table) // close valued constants are in the same table)
if (finite(value)) {
trunc = 10000000000.0; // 10^10
m = value * trunc;
n = floor(m);
if (m-n >= 0.5)
n = n + 1;
n = n / trunc;
split.value = n;
} else {
split.value = value;
}
split.value = truncateDoubleConstant(value);
pos = ddHash(split.bits[0], split.bits[1], unique->constants.shift); pos = ddHash(split.bits[0], split.bits[1], unique->constants.shift);
nodelist = unique->constants.nodelist; nodelist = unique->constants.nodelist;
@ -1710,6 +1722,7 @@ cuddRehash(
while (node != NULL) { while (node != NULL) {
next = node->next; next = node->next;
split.value = cuddV(node); split.value = cuddV(node);
split.value = truncateDoubleConstant(split.value);
pos = ddHash(split.bits[0], split.bits[1], shift); pos = ddHash(split.bits[0], split.bits[1], shift);
node->next = nodelist[pos]; node->next = nodelist[pos];
nodelist[pos] = node; nodelist[pos] = node;

Loading…
Cancel
Save