Beispiel #1
0
    def __init__(self, shape, pi=None):
        """
        EXAMPLES::

            sage: from sage.combinat.sf.ns_macdonald import NonattackingBacktracker
            sage: n = NonattackingBacktracker(LatticeDiagram([0,1,2]))
            sage: n._ending_position
            (3, 2)
            sage: n._initial_state
            (2, 1)
        """
        self._shape = shape
        self._n = sum(shape)
        self._initial_data = [ [None]*s for s in shape ]
        if pi is None:
            pi=Permutation([1]).to_permutation_group_element()
        self.pi=pi

        #The ending position will be at the highest box
        #which is farthest right
        ending_row = max(shape)
        ending_col = len(shape) - list(reversed(list(shape))).index(ending_row)
        self._ending_position = (ending_col, ending_row)

        #Get the lowest box that is farthest left
        starting_row = 1
        nonzero = [i for i in shape if i != 0]
        starting_col = list(shape).index(nonzero[0]) + 1

        GenericBacktracker.__init__(self, self._initial_data, (starting_col, starting_row))
    def __init__(self, shape, pi=None):
        """
        EXAMPLES::

            sage: from sage.combinat.sf.ns_macdonald import NonattackingBacktracker
            sage: n = NonattackingBacktracker(LatticeDiagram([0,1,2]))
            sage: n._ending_position
            (3, 2)
            sage: n._initial_state
            (2, 1)
        """
        self._shape = shape
        self._n = sum(shape)
        self._initial_data = [[None] * s for s in shape]
        if pi == None:
            pi = Permutation([1]).to_permutation_group_element()
        self.pi = pi

        #The ending position will be at the highest box
        #which is farthest right
        ending_row = max(shape)
        ending_col = len(shape) - list(reversed(list(shape))).index(ending_row)
        self._ending_position = (ending_col, ending_row)

        #Get the lowest box that is farthest left
        starting_row = 1
        nonzero = [i for i in shape if i != 0]
        starting_col = list(shape).index(nonzero[0]) + 1

        GenericBacktracker.__init__(self, self._initial_data,
                                    (starting_col, starting_row))
    def __init__(self, shape, max_entry=None):
        """
        EXAMPLES::

            sage: from sage.combinat.composition_tableau import CompositionTableauxBacktracker
            sage: n = CompositionTableauxBacktracker([1,3,2])
            sage: n._ending_position
            (2, 1)
            sage: n._initial_state
            (0, 0)
        """
        self._shape = shape
        self._n = sum(shape)
        self._initial_data = [[None] * s for s in shape]
        if max_entry is None:
            max_entry = sum(shape)
        self.max_entry = max_entry

        # The ending position will be at the lowest box which is farthest right
        ending_row = len(shape) - 1
        ending_col = shape[-1] - 1
        self._ending_position = (ending_row, ending_col)

        # Get the highest box that is farthest left
        starting_row = 0
        starting_col = 0

        GenericBacktracker.__init__(self, self._initial_data,
                                    (starting_row, starting_col))
Beispiel #4
0
    def __init__(self, shape, max_entry=None):
        """
        EXAMPLES::

            sage: from sage.combinat.composition_tableau import CompositionTableauxBacktracker
            sage: n = CompositionTableauxBacktracker([1,3,2])
            sage: n._ending_position
            (2, 1)
            sage: n._initial_state
            (0, 0)
        """
        self._shape = shape
        self._n = sum(shape)
        self._initial_data = [ [None]*s for s in shape ]
        if max_entry is None:
            max_entry=sum(shape)
        self.max_entry=max_entry

        # The ending position will be at the lowest box which is farthest right
        ending_row = len(shape)-1
        ending_col = shape[-1]-1
        self._ending_position = (ending_row, ending_col)

        # Get the highest box that is farthest left
        starting_row = 0
        starting_col = 0

        GenericBacktracker.__init__(self, self._initial_data, (starting_row, starting_col))
Beispiel #5
0
    def __init__(self, crystal, index_set=None):
        r"""
        Time complexity: `O(nF)` amortized for each produced
        element, where `n` is the size of the index set, and `F` is
        the cost of computing `e` and `f` operators.

        Memory complexity: `O(D)` where `D` is the depth of the crystal.

        Principle of the algorithm:

        Let `C` be a classical crystal. It's an acyclic graph where each
        connected component has a unique element without predecessors (the
        highest weight element for this component). Let's assume for
        simplicity that `C` is irreducible (i.e. connected) with highest
        weight element `u`.

        One can define a natural spanning tree of `C` by taking
        `u` as the root of the tree, and for any other element
        `y` taking as ancestor the element `x` such that
        there is an `i`-arrow from `x` to `y` with
        `i` minimal. Then, a path from `u` to `y`
        describes the lexicographically smallest sequence
        `i_1,\dots,i_k` such that
        `(f_{i_k} \circ f_{i_1})(u)=y`.

        Morally, the iterator implemented below just does a depth first
        search walk through this spanning tree. In practice, this can be
        achieved recursively as follows: take an element `x`, and
        consider in turn each successor `y = f_i(x)`, ignoring
        those such that `y = f_j(x^{\prime})` for some `x^{\prime}` and
        `j<i` (this can be tested by computing `e_j(y)`
        for `j<i`).

        EXAMPLES::

            sage: from sage.combinat.crystals.crystals import CrystalBacktracker
            sage: C = crystals.Tableaux(['B',3],shape=[3,2,1])
            sage: CB = CrystalBacktracker(C)
            sage: len(list(CB))
            1617
            sage: CB = CrystalBacktracker(C, [1,2])
            sage: len(list(CB))
            8
        """
        GenericBacktracker.__init__(self, None, None)
        self._crystal = crystal
        if index_set is None:
            self._index_set = crystal.index_set()
        else:
            self._index_set = index_set
Beispiel #6
0
    def __init__(self, crystal, index_set=None):
        r"""
        Time complexity: `O(nF)` amortized for each produced
        element, where `n` is the size of the index set, and `F` is
        the cost of computing `e` and `f` operators.

        Memory complexity: `O(D)` where `D` is the depth of the crystal.

        Principle of the algorithm:

        Let `C` be a classical crystal. It's an acyclic graph where all
        connected component has a unique element without predecessors (the
        highest weight element for this component). Let's assume for
        simplicity that `C` is irreducible (i.e. connected) with highest
        weight element `u`.

        One can define a natural spanning tree of `C` by taking
        `u` as the root of the tree, and for any other element
        `y` taking as ancestor the element `x` such that
        there is an `i`-arrow from `x` to `y` with
        `i` minimal. Then, a path from `u` to `y`
        describes the lexicographically smallest sequence
        `i_1,\dots,i_k` such that
        `(f_{i_k} \circ f_{i_1})(u)=y`.

        Morally, the iterator implemented below just does a depth first
        search walk through this spanning tree. In practice, this can be
        achieved recursively as follow: take an element `x`, and
        consider in turn each successor `y = f_i(x)`, ignoring
        those such that `y = f_j(x^{\prime})` for some `x^{\prime}` and
        `j<i` (this can be tested by computing `e_j(y)`
        for `j<i`).

        EXAMPLES::

            sage: from sage.combinat.crystals.crystals import CrystalBacktracker
            sage: C = crystals.Tableaux(['B',3],shape=[3,2,1])
            sage: CB = CrystalBacktracker(C)
            sage: len(list(CB))
            1617
            sage: CB = CrystalBacktracker(C, [1,2])
            sage: len(list(CB))
            8
        """
        GenericBacktracker.__init__(self, None, None)
        self._crystal = crystal
        if index_set is None:
            self._index_set = crystal.index_set()
        else:
            self._index_set = index_set