Skip to content

Commit e69ec1e

Browse files
authored
Merge pull request #41 from com-github-javabdd/40-rethink-the-cache-ratio-option
#40 Redesign the operator cache ratio.
2 parents 36f36ce + e150f67 commit e69ec1e

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/main/java/com/github/javabdd/BDDFactory.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,8 @@ public void reset() {
417417

418418
/**
419419
* Sets the cache ratio for the operator caches. When the node table grows, operator caches will also grow to
420-
* maintain the ratio.
420+
* maintain the ratio. A ratio of {@code 0.5} leads to caches that are half the node table size, while a ratio
421+
* of {@code 2.0} leads to caches that are twice the node table size.
421422
*
422423
* <p>
423424
* Compare to bdd_setcacheratio.

src/main/java/com/github/javabdd/JFactory.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ public void printStat() {
434434

435435
@Override
436436
public double setCacheRatio(double x) {
437-
return bdd_setcacheratio((int)x);
437+
return bdd_setcacheratio(x);
438438
}
439439

440440
@Override
@@ -4726,7 +4726,7 @@ void bdd_init(int initnodesize, int cs) {
47264726

47274727
BddCache countcache; /* Cache for count results */
47284728

4729-
int cacheratio;
4729+
double cacheratio;
47304730

47314731
boolean satPolarity;
47324732

@@ -4817,7 +4817,7 @@ int bdd_setcachesize(int newcachesize) {
48174817

48184818
void bdd_operator_noderesize() {
48194819
if (cacheratio > 0) {
4820-
int newcachesize = bddnodesize / cacheratio;
4820+
int newcachesize = (int)(bddnodesize * cacheratio);
48214821

48224822
BddCache_resize(applycache, newcachesize);
48234823
BddCache_resize(itecache, newcachesize);
@@ -6088,8 +6088,8 @@ int bdd_setmaxincrease(int size) {
60886088
return old;
60896089
}
60906090

6091-
int bdd_setcacheratio(int r) {
6092-
int old = cacheratio;
6091+
double bdd_setcacheratio(double r) {
6092+
double old = cacheratio;
60936093

60946094
if (r <= 0) {
60956095
return bdd_error(BDD_RANGE);

0 commit comments

Comments
 (0)