- sage: L3infty = Cone([(0,1,1), (1,0,1), (0,-1,1), (-1,0,1)])
- sage: LL(L3infty)
- [
- [1 0 0]
- [0 1 0]
- [0 0 1]
- ]
-
- If our cone is the entire space, then every transformation on it is
- Lyapunov-like::
-
- sage: K = Cone([(1,0), (-1,0), (0,1), (0,-1)])
- sage: M = MatrixSpace(QQ,2)
- sage: M.basis() == LL(K)
- True
-
- TESTS:
-
- The inner product `\left< L\left(x\right), s \right>` is zero for
- every pair `\left( x,s \right)` in the discrete complementarity set
- of the cone::
-
- sage: set_random_seed()
- sage: K = random_cone(max_dim=8)
- sage: C_of_K = discrete_complementarity_set(K)
- sage: l = [ (L*x).inner_product(s) for (x,s) in C_of_K for L in LL(K) ]
- sage: sum(map(abs, l))
- 0
-
- The Lyapunov-like transformations on a cone and its dual are related
- by transposition, but we're not guaranteed to compute transposed
- elements of `LL\left( K \right)` as our basis for `LL\left( K^{*}
- \right)`
-
- sage: set_random_seed()
- sage: K = random_cone(max_dim=8)
- sage: LL2 = [ L.transpose() for L in LL(K.dual()) ]
- sage: V = VectorSpace( K.lattice().base_field(), K.lattice_dim()^2)
- sage: LL1_vecs = [ V(m.list()) for m in LL(K) ]
- sage: LL2_vecs = [ V(m.list()) for m in LL2 ]
- sage: V.span(LL1_vecs) == V.span(LL2_vecs)
- True
-
- """
- V = K.lattice().vector_space()
-
- C_of_K = discrete_complementarity_set(K)
-
- tensor_products = [ s.tensor_product(x) for (x,s) in C_of_K ]
-
- # Sage doesn't think matrices are vectors, so we have to convert
- # our matrices to vectors explicitly before we can figure out how
- # many are linearly-indepenedent.
- #
- # The space W has the same base ring as V, but dimension
- # dim(V)^2. So it has the same dimension as the space of linear
- # transformations on V. In other words, it's just the right size
- # to create an isomorphism between it and our matrices.
- W = VectorSpace(V.base_ring(), V.dimension()**2)
-
- # Turn our matrices into long vectors...
- vectors = [ W(m.list()) for m in tensor_products ]
-
- # Vector space representation of Lyapunov-like matrices
- # (i.e. vec(L) where L is Luapunov-like).
- LL_vector = W.span(vectors).complement()
-
- # Now construct an ambient MatrixSpace in which to stick our
- # transformations.
- M = MatrixSpace(V.base_ring(), V.dimension())
-
- matrix_basis = [ M(v.list()) for v in LL_vector.basis() ]
-
- return matrix_basis
-
-
-
-def lyapunov_rank(K):
- r"""
- Compute the Lyapunov (or bilinearity) rank of this cone.
-
- The Lyapunov rank of a cone can be thought of in (mainly) two ways:
-
- 1. The dimension of the Lie algebra of the automorphism group of the
- cone.
-
- 2. The dimension of the linear space of all Lyapunov-like
- transformations on the cone.
-
- INPUT:
-
- A closed, convex polyhedral cone.
-
- OUTPUT:
-
- An integer representing the Lyapunov rank of the cone. If the
- dimension of the ambient vector space is `n`, then the Lyapunov rank
- will be between `1` and `n` inclusive; however a rank of `n-1` is
- not possible (see the first reference).
-
- .. note::
-
- In the references, the cones are always assumed to be proper. We
- do not impose this restriction.
-
- .. seealso::
-
- :meth:`is_proper`
-
- ALGORITHM:
-
- The codimension formula from the second reference is used. We find
- all pairs `(x,s)` in the complementarity set of `K` such that `x`
- and `s` are rays of our cone. It is known that these vectors are
- sufficient to apply the codimension formula. Once we have all such
- pairs, we "brute force" the codimension formula by finding all
- linearly-independent `xs^{T}`.
-
- REFERENCES:
-
- .. [Gowda/Tao] M.S. Gowda and J. Tao. On the bilinearity rank of a proper
- cone and Lyapunov-like transformations, Mathematical Programming, 147
- (2014) 155-170.
-
- .. [Orlitzky/Gowda] M. Orlitzky and M. S. Gowda. The Lyapunov Rank of an
- Improper Cone. Work in-progress.
-
- .. [Rudolf et al.] G. Rudolf, N. Noyan, D. Papp, and F. Alizadeh, Bilinear
- optimality constraints for the cone of positive polynomials,
- Mathematical Programming, Series B, 129 (2011) 5-31.
-
- EXAMPLES:
-
- The nonnegative orthant in `\mathbb{R}^{n}` always has rank `n`
- [Rudolf et al.]_::
-
- sage: positives = Cone([(1,)])
- sage: lyapunov_rank(positives)
- 1
- sage: quadrant = Cone([(1,0), (0,1)])
- sage: lyapunov_rank(quadrant)
- 2
- sage: octant = Cone([(1,0,0), (0,1,0), (0,0,1)])
- sage: lyapunov_rank(octant)
- 3
-
- The full space `\mathbb{R}^{n}` has Lyapunov rank `n^{2}`
- [Orlitzky/Gowda]_::
-
- sage: R5 = VectorSpace(QQ, 5)
- sage: gs = R5.basis() + [ -r for r in R5.basis() ]
- sage: K = Cone(gs)
- sage: lyapunov_rank(K)
- 25
-
- The `L^{3}_{1}` cone is known to have a Lyapunov rank of one
- [Rudolf et al.]_::
-
- sage: L31 = Cone([(1,0,1), (0,-1,1), (-1,0,1), (0,1,1)])
- sage: lyapunov_rank(L31)
- 1
-
- Likewise for the `L^{3}_{\infty}` cone [Rudolf et al.]_::
-
- sage: L3infty = Cone([(0,1,1), (1,0,1), (0,-1,1), (-1,0,1)])
- sage: lyapunov_rank(L3infty)
- 1
-
- A single ray in `n` dimensions should have Lyapunov rank `n^{2} - n
- + 1` [Orlitzky/Gowda]_::
-
- sage: K = Cone([(1,0,0,0,0)])
- sage: lyapunov_rank(K)
- 21
- sage: K.lattice_dim()**2 - K.lattice_dim() + 1
- 21
-
- A subspace (of dimension `m`) in `n` dimensions should have a
- Lyapunov rank of `n^{2} - m\left(n - m)` [Orlitzky/Gowda]_::
-
- sage: e1 = (1,0,0,0,0)
- sage: neg_e1 = (-1,0,0,0,0)
- sage: e2 = (0,1,0,0,0)
- sage: neg_e2 = (0,-1,0,0,0)
- sage: z = (0,0,0,0,0)
- sage: K = Cone([e1, neg_e1, e2, neg_e2, z, z, z])
- sage: lyapunov_rank(K)
- 19
- sage: K.lattice_dim()**2 - K.dim()*codim(K)
- 19
-
- The Lyapunov rank should be additive on a product of proper cones
- [Rudolf et al.]_::