Dear Andrew, Nicolas, Florent, others,
On 08/18/2010 12:36 PM, Nicolas M. Thiery wrote:
> Jason started working on this ticket. Jason: could you state the
> current status?
The current status is that basically nothing of value has been done
other than thinking a bit about design. Help is very much welcome! Let
me try to expand on some of the issues and strategies below. Nicolas
and Florent, please comment!
I think a good prototype is the file sage.combinat.binary_trees.py in
the combinat queue. The basic setup is that there are three kinds of
classes: element classes, factory classes and parent classes. The
framework requires using the metaclass framework that Nicolas and
Florent have set up, but I think this might not be so difficult.
I've sketched out a very rough outline of how these classes should be
defined below. I'm not sure how well they will work. First we have the
element classes. I think there should be three:
StandardTableau < SemistandardTableau < Tableau
where '<' means 'is a subclass of'. I think 'Tableau' in sage means any
filling of the boxes of a partition diagram with sage objects.
Semistandard means a filling with positive integers which is strictly
increasing in columns and weakly increasing in rows and Standard means
the Semistandard with evaluation {1, .., n} where n is the number of
boxes. (I have not considered SkewTableaux here, and that is maybe an
issue. I think it they can probably be done separately later, but I
haven't thought very hard about it.)
An element can be created directly with
sage: t = SemistandardTableau([[1,2,3],[2,3]])
or by first creating a parent
sage: ST5 = SemistandardTableaux(5)
sage: t = ST5([[1,2,3],[2,3]])
The 'metaclass' trick is so that both of these will work, and the
parents will be set appropriately. Anyway, here is what I roughly think
the element classes should look.
**** The element classes ****
class Tableau(SageObject):
__metaclass__ = ClasscallMetaclass
@staticmethod
def __classcall_private__(cls, *args, **kwargs):
return Tableaux_all().element_class(Tableaux_all(), *args, **kwargs)
def check(self):
# consists of an 'assert' statement verifying that self is a
# valid tableau. In particular, this should be done here and
# not in __init__.
def __init__(self, t):
self._list = t
# maybe nothing else is necessary here
# define all methods applicable to any tableau (regardless of what it
# is filled with) here.
class SemistandardTableau(Tableau):
# __metaclass__, __classcall_private__, check, init as above
# define all methods specific to semistandard tableaux here.
class StandardTableau(SemistandardTableau):
# as above
**********************************************************
Next up, we have the factory classes. We need to have lots of specific
parent classes to handle all the possible iterators. These will be
named things like: Tableaux_all, SemistandardTableaux_size_weight,
StandardTableaux_shape, etc. These are intended for internal library
use only. The user should be able to create a class simply by
specifying the constraints they care about as arguments to the
appropriate factory class. The factory class will dispatch things
appropriately. Note: I'm not at all sure that the inheritance as I've
defined it below will work. Comments welcome!
**** The factory classes ****
class Tableaux(UniqueRepresentation, Parent):
@staticmethod
def __classcall_private__(cls, *args, **kwargs):
# Process the args to determine the appropriate parent class of
# the form Tableaux_constraints. Raise an assertion error if
# the given args don't make sense. Otherwise, we have a bunch
# of:
if (constraints_specify_ABC):
return Tableaux_ABC(*possibly sanitized arguments*)
# No __init__ method is necessary
class SemistandardTableaux(UR, Parent, Tableaux): # similar
class StandardTableaux(UR, Parent, SemistandardTableaux): # similar
************************************************************
Finally we have the specific parent classes. I think they should look
roughly as follows.
**** The parent classes ****
class Tableaux_all(Tableaux):
def __init__(self):
super(Tableaux_all, self).__init__()
# I don't know a good category, since general tableaux (which
# allow, for example, real-number entries) are not enumerable.
def __contains__(self, t):
return isinstance(t, self.element_class)
def _element_constructor(self, *args, **kwargs):
return self.element_class(self, *args, **kwargs)
Element = Tableau
class SemistandardTableaux_all(DisjointUnionEnumeratedSets,
SemistandardTableaux):
def __init__(self):
DisjointUnionEnumeratedSets.__init__(
self, Family(NonNegativeIntegers(),
SemistandardTableaux_size),
facade=True, keepkey = False)
# Note that I'm not clear on what facade and keepkey do.
# They may not be necessary or advisable.
# _contains_, _element_constructor_, Element similar to above
class SemistandardTableaux_size(SemistandardTableaux):
def __init__(self, size):
super(SemistandardTableaux_size, self).__init__(
category = InfiniteFiniteEnumeratedSets())
self._size = size
def __iter__(self):
# Should be implemented, if possible.
class SemistandardTableaux_size_weight(SemistandardTableaux):
# similar
********************************************
Sorry for the really long post about this. I've been thinking about
this design a little bit, but I this is the first I've written anything
down. Again, I'm not at all sure that I properly understand everything,
but I hope this is useful!
Cheers,
Jason
--
You received this message because you are subscribed to the Google Groups
"sage-combinat-devel" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-combinat-devel?hl=en.