Re: [Javabdd-devel] Retrieving a set from a BDD
Brought to you by:
joewhaley
|
From: Wassim M. <wm...@au...> - 2007-11-29 08:31:03
|
Hi John,
(Thank you for the quick response)
If I keep "itemsSet1" and "itemsSet2" around, would I be achieving any =20
compression?
It seems to me that set1 and set2 will stored in 2 different places =20
now, since I would have:
1) set1 and set2 represented by the BDDs referenced by "itemsSet1" and =20
"itemsSet2" (no compression is achieved here).
AND
2) set1 and set2 stored (potentially compressed) in poolOfSets.
Note that in order to keep "itemsSet1" and "itemsSet2" around, they =20
cannot be consumed, i.e., I must pass their clone when adding them to =20
"poolOfSets":
...
poolOfSets.andWith(itemsSet1.id());
poolOfSets.andWith(itemsSet2.id());
...
Finally, in order to verify my understanding above, I freed =20
"poolOfSets" then tried to retrieve set1 and set2 using "itemsSet1" =20
and "itemsSet2", the test was successful (please see last 3 statements):
BDDFactory B;
B =3D BDDFactory.init(1000, 1000);
B.setVarNum(500);
// pool of items
BDD [] items =3D new BDD[100];
for (int i =3D 0; i < 100; i++)
{
=09items[i] =3D B.ithVar(i);
}
// set 1
BDD itemsSet1 =3D B.zero();
itemsSet1.orWith(items[0].id());
itemsSet1.orWith(items[1].id());
itemsSet1.orWith(items[2].id());
itemsSet1.orWith(items[3].id());
System.out.println("itemsSet1 " + itemsSet1);
System.out.println("count " + itemsSet1.nodeCount());
// set 2
BDD itemsSet2 =3D B.zero();
itemsSet2.orWith(items[10].id());
itemsSet2.orWith(items[11].id());
itemsSet2.orWith(items[2].id());
itemsSet2.orWith(items[3].id());
System.out.println("itemsSet2 " + itemsSet2);
System.out.println("count " + itemsSet2.nodeCount());
// pool of sets
BDD poolOfSets;
poolOfSets =3D B.one();
poolOfSets.andWith(itemsSet1.id());
poolOfSets.andWith(itemsSet2.id());
System.out.println("poolOfSets " + poolOfSets);
System.out.println("count " + poolOfSets.nodeCount());
// retrieve set1 and set2
System.out.println("itemsSet1 " + itemsSet1); // got set1 successfully
System.out.println("itemsSet1 " + itemsSet2); // got set2 successfully
// retrieve set1 and set2 after freeing poolOfSets
poolOfSets.free(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
System.out.println("itemsSet1 " + itemsSet1); // got set1 successfully
System.out.println("itemsSet1 " + itemsSet2); // got set2 successfully
To recap, my goal is:
1) To be able to free "itemsSet1" and "itemsSet2" right after I store =20
set1 and set2 in "poolOfSets"
2) Retrieve set1 and set2 from "poolOfSets", which maintain them in =20
compressed form.
Thank you for your help
Wes Masri
----------------------------------------------------------------
|