Re: [Javabdd-devel] Retrieving a set from a BDD
Brought to you by:
joewhaley
|
From: John W. <joe...@gm...> - 2007-11-30 04:11:03
|
The BDD "compression" happens within the BDD library. You can have
1000 copies of the same BDD set and it takes the same amount of space
as one copy.
-John
On Nov 29, 2007 12:29 AM, Wassim Masri <wm...@au...> wrote:
> Hi John,
>
> (Thank you for the quick response)
>
> If I keep "itemsSet1" and "itemsSet2" around, would I be achieving any
> compression?
>
> It seems to me that set1 and set2 will stored in 2 different places
> now, since I would have:
>
> 1) set1 and set2 represented by the BDDs referenced by "itemsSet1" and
> "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
> cannot be consumed, i.e., I must pass their clone when adding them to
> "poolOfSets":
> ...
> poolOfSets.andWith(itemsSet1.id());
> poolOfSets.andWith(itemsSet2.id());
> ...
>
>
> Finally, in order to verify my understanding above, I freed
> "poolOfSets" then tried to retrieve set1 and set2 using "itemsSet1"
> and "itemsSet2", the test was successful (please see last 3 statements):
>
> BDDFactory B;
> B = BDDFactory.init(1000, 1000);
> B.setVarNum(500);
>
> // pool of items
> BDD [] items = new BDD[100];
> for (int i = 0; i < 100; i++)
> {
> items[i] = B.ithVar(i);
> }
>
> // set 1
> BDD itemsSet1 = 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 = 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 = 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
> set1 and set2 in "poolOfSets"
>
> 2) Retrieve set1 and set2 from "poolOfSets", which maintain them in
> compressed form.
>
> Thank you for your help
> Wes Masri
>
>
> ----------------------------------------------------------------
>
>
|