17
17
import java .io .BufferedWriter ;
18
18
import java .io .IOException ;
19
19
import java .io .PrintStream ;
20
+ import java .math .BigInteger ;
20
21
import java .util .Arrays ;
21
22
import java .util .Collection ;
22
23
import java .util .Collections ;
@@ -297,12 +298,12 @@ protected int nodeCount_impl(int v) {
297
298
}
298
299
299
300
@ Override
300
- protected double pathCount_impl (int v ) {
301
+ protected BigInteger pathCount_impl (int v ) {
301
302
return bdd_pathcount (v );
302
303
}
303
304
304
305
@ Override
305
- protected double satCount_impl (int v ) {
306
+ protected BigInteger satCount_impl (int v ) {
306
307
return bdd_satcount (v );
307
308
}
308
309
@@ -1062,16 +1063,16 @@ BddCacheData copy() {
1062
1063
}
1063
1064
}
1064
1065
1065
- private static class BddCacheDataD extends BddCacheData {
1066
- double dres ;
1066
+ private static class BddCacheDataBI extends BddCacheData {
1067
+ BigInteger bires ;
1067
1068
1068
1069
@ Override
1069
1070
BddCacheData copy () {
1070
- BddCacheDataD that = new BddCacheDataD ();
1071
+ BddCacheDataBI that = new BddCacheDataBI ();
1071
1072
that .a = this .a ;
1072
1073
that .b = this .b ;
1073
1074
that .c = this .c ;
1074
- that .dres = this .dres ;
1075
+ that .bires = this .bires ;
1075
1076
return that ;
1076
1077
}
1077
1078
}
@@ -1083,9 +1084,9 @@ private static class BddCache {
1083
1084
1084
1085
BddCache copy () {
1085
1086
BddCache that = new BddCache ();
1086
- boolean is_d = this .table instanceof BddCacheDataD [];
1087
- if (is_d ) {
1088
- that .table = new BddCacheDataD [this .table .length ];
1087
+ boolean is_bi = this .table instanceof BddCacheDataBI [];
1088
+ if (is_bi ) {
1089
+ that .table = new BddCacheDataBI [this .table .length ];
1089
1090
} else {
1090
1091
that .table = new BddCacheDataI [this .table .length ];
1091
1092
}
@@ -6277,110 +6278,92 @@ void varprofile_rec(int r, int[] varprofile) {
6277
6278
varprofile_rec (HIGH (r ), varprofile );
6278
6279
}
6279
6280
6280
- double bdd_pathcount (int r ) {
6281
+ BigInteger bdd_pathcount (int r ) {
6281
6282
CHECK (r );
6282
6283
6283
6284
miscid = CACHEID_PATHCOU ;
6284
6285
6285
6286
if (countcache == null ) {
6286
- countcache = BddCacheD_init (cachesize );
6287
+ countcache = BddCacheBI_init (cachesize );
6287
6288
}
6288
6289
6289
6290
return bdd_pathcount_rec (r );
6290
6291
}
6291
6292
6292
- double bdd_pathcount_rec (int r ) {
6293
- BddCacheDataD entry ;
6294
- double size ;
6293
+ BigInteger bdd_pathcount_rec (int r ) {
6294
+ BddCacheDataBI entry ;
6295
6295
6296
6296
if (ISZERO (r )) {
6297
- return 0.0 ;
6297
+ return BigInteger . ZERO ;
6298
6298
}
6299
6299
if (ISONE (r )) {
6300
- return 1.0 ;
6300
+ return BigInteger . ONE ;
6301
6301
}
6302
6302
6303
- entry = BddCache_lookupD (countcache , PATHCOUHASH (r ));
6303
+ entry = BddCache_lookupBI (countcache , PATHCOUHASH (r ));
6304
6304
if (entry .a == r && entry .c == miscid ) {
6305
- return entry .dres ;
6305
+ return entry .bires ;
6306
6306
}
6307
6307
6308
- size = bdd_pathcount_rec (LOW (r )) + bdd_pathcount_rec (HIGH (r ));
6308
+ BigInteger size = bdd_pathcount_rec (LOW (r )). add ( bdd_pathcount_rec (HIGH (r ) ));
6309
6309
6310
6310
entry .a = r ;
6311
6311
entry .c = miscid ;
6312
- entry .dres = size ;
6312
+ entry .bires = size ;
6313
6313
6314
6314
return size ;
6315
6315
}
6316
6316
6317
- double bdd_satcount (int r ) {
6317
+ BigInteger bdd_satcount (int r ) {
6318
6318
if (ZDD ) {
6319
6319
return bdd_pathcount (r );
6320
6320
}
6321
6321
6322
- double size = 1 ;
6323
-
6324
6322
CHECK (r );
6325
6323
6326
6324
if (countcache == null ) {
6327
- countcache = BddCacheD_init (cachesize );
6325
+ countcache = BddCacheBI_init (cachesize );
6328
6326
}
6329
6327
6330
6328
miscid = CACHEID_SATCOU ;
6331
- if (!ZDD ) {
6332
- size = Math .pow (2.0 , LEVEL (r ));
6333
- }
6334
-
6335
- return size * satcount_rec (r );
6336
- }
6337
-
6338
- double bdd_satcountset (int r , int varset ) {
6339
- double unused = bddvarnum ;
6340
- int n ;
6341
-
6342
- if (ISCONST (varset ) || ISZERO (r )) { /* empty set */
6343
- return 0.0 ;
6344
- }
6345
-
6346
- for (n = varset ; !ISCONST (n ); n = HIGH (n )) {
6347
- unused --;
6329
+ BigInteger size ;
6330
+ if (ZDD ) {
6331
+ size = BigInteger .ONE ;
6332
+ } else {
6333
+ size = BigInteger .TWO .pow (LEVEL (r ));
6348
6334
}
6349
6335
6350
- unused = bdd_satcount (r ) / Math .pow (2.0 , unused );
6351
-
6352
- return unused >= 1.0 ? unused : 1.0 ;
6336
+ return size .multiply (satcount_rec (r ));
6353
6337
}
6354
6338
6355
- double satcount_rec (int root ) {
6356
- BddCacheDataD entry ;
6357
- double size , s ;
6339
+ BigInteger satcount_rec (int root ) {
6340
+ BddCacheDataBI entry ;
6358
6341
6359
6342
if (root < 2 ) {
6360
- return root ;
6343
+ return BigInteger . valueOf ( root ) ;
6361
6344
}
6362
6345
6363
- entry = BddCache_lookupD (countcache , SATCOUHASH (root ));
6346
+ entry = BddCache_lookupBI (countcache , SATCOUHASH (root ));
6364
6347
if (entry .a == root && entry .c == miscid ) {
6365
- return entry .dres ;
6348
+ return entry .bires ;
6366
6349
}
6367
6350
6368
- size = 0 ;
6369
- s = 1 ;
6351
+ BigInteger size = BigInteger . ZERO ;
6352
+ BigInteger s = BigInteger . ONE ;
6370
6353
if (!ZDD ) {
6371
- s *= Math . pow ( 2.0 , LEVEL (LOW (root )) - LEVEL (root ) - 1 );
6354
+ s = s . multiply ( BigInteger . TWO . pow ( LEVEL (LOW (root )) - LEVEL (root ) - 1 ) );
6372
6355
}
6373
- size += s * satcount_rec (LOW (root ));
6356
+ size = size . add ( s . multiply ( satcount_rec (LOW (root )) ));
6374
6357
6375
- s = 1 ;
6358
+ s = BigInteger . ONE ;
6376
6359
if (!ZDD ) {
6377
- s *= Math . pow ( 2.0 , LEVEL (HIGH (root )) - LEVEL (root ) - 1 );
6360
+ s = s . multiply ( BigInteger . TWO . pow ( LEVEL (HIGH (root )) - LEVEL (root ) - 1 ) );
6378
6361
}
6379
- size += s * satcount_rec (HIGH (root ));
6362
+ size = size . add ( s . multiply ( satcount_rec (HIGH (root )) ));
6380
6363
6381
6364
entry .a = root ;
6382
6365
entry .c = miscid ;
6383
- entry .dres = size ;
6366
+ entry .bires = size ;
6384
6367
6385
6368
return size ;
6386
6369
}
@@ -6942,7 +6925,7 @@ void bdd_operator_init(int cachesize) {
6942
6925
appexcache = BddCacheI_init (cachesize );
6943
6926
replacecache = BddCacheI_init (cachesize );
6944
6927
misccache = BddCacheI_init (cachesize );
6945
- countcache = BddCacheD_init (cachesize );
6928
+ countcache = BddCacheBI_init (cachesize );
6946
6929
}
6947
6930
6948
6931
quantvarsetID = 0 ;
@@ -7050,16 +7033,16 @@ BddCache BddCacheI_init(int size) {
7050
7033
return cache ;
7051
7034
}
7052
7035
7053
- BddCache BddCacheD_init (int size ) {
7036
+ BddCache BddCacheBI_init (int size ) {
7054
7037
int n ;
7055
7038
7056
7039
size = bdd_prime_gte (size );
7057
7040
7058
7041
BddCache cache = new BddCache ();
7059
- cache .table = new BddCacheDataD [size ];
7042
+ cache .table = new BddCacheDataBI [size ];
7060
7043
7061
7044
for (n = 0 ; n < size ; n ++) {
7062
- cache .table [n ] = new BddCacheDataD ();
7045
+ cache .table [n ] = new BddCacheDataBI ();
7063
7046
cache .table [n ].a = -1 ;
7064
7047
}
7065
7048
cache .tablesize = size ;
@@ -7082,21 +7065,21 @@ int BddCache_resize(BddCache cache, int newsize) {
7082
7065
}
7083
7066
int n ;
7084
7067
7085
- boolean is_d = cache .table instanceof BddCacheDataD [];
7068
+ boolean is_bi = cache .table instanceof BddCacheDataBI [];
7086
7069
7087
7070
cache .table = null ;
7088
7071
7089
7072
newsize = bdd_prime_gte (newsize );
7090
7073
7091
- if (is_d ) {
7092
- cache .table = new BddCacheDataD [newsize ];
7074
+ if (is_bi ) {
7075
+ cache .table = new BddCacheDataBI [newsize ];
7093
7076
} else {
7094
7077
cache .table = new BddCacheDataI [newsize ];
7095
7078
}
7096
7079
7097
7080
for (n = 0 ; n < newsize ; n ++) {
7098
- if (is_d ) {
7099
- cache .table [n ] = new BddCacheDataD ();
7081
+ if (is_bi ) {
7082
+ cache .table [n ] = new BddCacheDataBI ();
7100
7083
} else {
7101
7084
cache .table [n ] = new BddCacheDataI ();
7102
7085
}
@@ -7111,8 +7094,8 @@ BddCacheDataI BddCache_lookupI(BddCache cache, int hash) {
7111
7094
return (BddCacheDataI )cache .table [Math .abs (hash % cache .tablesize )];
7112
7095
}
7113
7096
7114
- BddCacheDataD BddCache_lookupD (BddCache cache , int hash ) {
7115
- return (BddCacheDataD )cache .table [Math .abs (hash % cache .tablesize )];
7097
+ BddCacheDataBI BddCache_lookupBI (BddCache cache , int hash ) {
7098
+ return (BddCacheDataBI )cache .table [Math .abs (hash % cache .tablesize )];
7116
7099
}
7117
7100
7118
7101
void BddCache_reset (BddCache cache ) {
0 commit comments