Getting hierarchies of partitions (correction & continue)
- To: mathgroup at smc.vnet.net
- Subject: [mg36511] Getting hierarchies of partitions (correction & continue)
- From: Emilio Martin-Serrano <EMartinSerrano at houston.sns.slb.com>
- Date: Tue, 10 Sep 2002 06:24:41 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Group,
Sorry for the previous posting. The following solves (to some extent my
problem)
<<DiscreteMath`Combinatorica`
fLPartition[ksN_,r_]:=With[{ks=KSubsets[Range[r],ksN],ks1=Partition[Range[r],1]},MapThread[Complement[Append[#1,#2],(Sequence@@{#}&/@Partition[#2,1])]&,{Array[ks1&,Length[ks]],ks}]]
fHierarchy[r_]:=Module[{ksN=2},While
[ksN<(r+1),s=fLPartition[ksN,r];ksN=ksN+1;Print[s]]]
fHierarchy[10], gives the structure for 10 elements, and so on.
However, I do not like this solution since to my taste is to complex and
rather inelegant. Nest or Fold would do better. Any Idea?
Just an additional remark.
Besides, I do not need the whole taxonomy, but a subset satisfying a
minimizing condition on connectivity implied by some relationships among
the elements. This condition is satisfied by one and only one element, or
class of equivalence in each level of the hierarchy. So it is that very
class which matter and consequently the procedure should give control on
each class as the total structure is being generated. Once it is known which
class satisfies the condition it is possible to avoid generating the whole
structure and the subsequent combinatorial explosion. With just
fHierarchy[100] a Dell Latitude, 1 GH, 256 MB RAM runs out of memory.
This an addition to the previous posting
In fact, the thing is even worst. These are the CPU times for the
following computations
times1=First[Timing[fLPartition[3,10];]]/. Second->1
0.02
times2=First[Timing[fLPartition[3,20];]]/. Second->1
0.18
times3=First[Timing[fLPartition[3,30];]]/. Second->1
0.701
times4=First[Timing[fLPartition[3,40];]]/. Second->1
1.913
times5=First[Timing[fLPartition[3,50];]]/. Second->1
4.236
times6=First[Timing[fLPartition[3,60];]]/. Second->1
8.222
times7=First[Timing[fLPartition[3,70];]]/. Second->1
14.39
times8=First[Timing[fLPartition[3,80];]]/. Second->1
23.563
So far so good. But for
times9=First[Timing[fLPartition[3,90];]]/. Second->1
The computation does not always end. Some times it ends some times it does
not (I aborted the process four times after 1 hour of computing and
running out of, 2Gbites of, virtual memory)
Emilio Martin-Serrano
___________________________________
Emilio Martin-Serrano
Schlumberger
Oil & Gas Business Consulting Principal
1325 South Dairy Ashford Road
Houston, TX 77077
Tel. +1 (281) 285 1223
Fax +1 (281) 285 1626