> We have to replace infinity by RD_INF in combinat...
It's almost done... Almost because of the following bug:
>> min (1, RD_INF);
RD_INF
>> min (RD_INF, 1);
1
>> max (RD_INF, 1);
1
>> max (1, RD_INF);
RD_INF
Should I send this on bugs@... ?
I've written a workaround which passes all the tests. And profiling
gives:
combinat::compositions(10) takes now 620 ms instead of 3890 ms !!!
combinat::partitions::list(15) takes now 430 ms instead of 2080 ms !!!
combinat::partitions::list(20) takes now 1610 ms instead of 8390 ms !!!
It seems to be a good improvement !!!
In the first case combinat::compositions(10), a completly ad hoc
recursive list builder takes 40ms...
Another further improvement is to replace i->1, i->RD_INF in the
Inner and Outer options parsing by 1 and RD_INF.
The call 1(x) is faster than (i->1)(x), and according to
prog::profile(combinat::partitions::list(20))
nearly 13 % of the time is spent in inner and outer... Moreover it
seems that this 13 % does not include the calling time. True ???
Let me do some test (list is defined as in
integerListsLexBuilder.tst). let
partitions := 0, RD_INF, ()->0, ()->RD_INF, RD_NINF, 0:
partitions2 := 0, RD_INF, 0, RD_INF, RD_NINF, 0:
prog::profile(list(20,partitions)): Total time: 2000 ms
prog::profile(list(20,partitions2)): Total time: 1300 ms
or with the following scan procedure which do not build the list
scan := proc() local g;
begin
g := combinat::integerListsLexBuilder::generator(args());
while g() <> FAIL do end_while
end_proc
prog::profile(scan(30,partitions)): Total time: 20200 ms
prog::profile(scan(30,partitions2)): Total time: 13140 ms
Not so bad, together with the toList improvement, we will get decent
result compared with ad hoc functions...
I've not done this second improvement.
Any comments or further ideas ?
Florent
|