Helloooooooo everybody !

I have a funny problem that I wasn't able to solve elegantly so far. There
are several mathematical objects (combinatorial designs, but it doesn't
matter) that I am implementing in Sage these days, each with several
parameters, and a theorem saying that the following are equivalent :

- There exists a TD(k,n)
- There exists a OA(k,n,2)
- There exists a MOLS(n, k-2)

(You don't need to understand what these objects are. Just know that they
are pretty things.)

The problem is that being all equivalent, here is how I would like to
implement them

def TD(k,n)
   1) does there exist a OA(k,n,2) ? If so, return it
   2) does there exist a MOLS(n, k-2) ? If so, return it
   3) Otherwise, try to see if some TD-specific construction is available
for this set of parameters.

def OA(k,n):
   1) does there exist a TD(k,n) ? If so, return it
   2) does there exist a MOLS(k,n-2) ? If so, return it
   3) Otherwise, try to see if some OA-specific construction is available
for this set of parameters.

def MOLS(k,n):
   1) does there exist a TD(k,n+2) ? If so, return it
   2) does there exist a OA(k,n+2) ? If so, return it
   3) Otherwise, try to see if some MOLS-specific construction is available
for this set of parameters.

The problem is obvious. TD calls OA which call TD which call OA which calls
TD, which calls ...
And you can have longer cycles. And you actually have more than 3
equivalent objects.

The question is : how is it possible to break those cycles elegantly ? The
only theoretically correct answer I have so far is to add a "parameter
already_tried=[...]" containing the list of constructors that have been
called already (*). So that you don't ask them back. Which means that there
would be ugly "if OA not in already_tried: call OA" everywhere. Rather ugly.

Note that there is no specific need for speed in there. Building the object
itself is quite long in some cases, and finding the function that contains
the right implementation is rather negligible.

Thaaaaaaaaaaanks for your ideas :-P

Nathann

(*) I also had an prettier one based on modifying the cached_function
mechanism, but it can fail when exceptions are thrown :-P

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to sage-devel@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to