r"""
Compute the discrete complementarity set of this cone.
- The complementarity set of this cone is the set of all orthogonal
- pairs `(x,s)` such that `x` is in this cone, and `s` is in its
- dual. The discrete complementarity set restricts `x` and `s` to be
- generators of their respective cones.
+ The complementarity set of a cone is the set of all orthogonal pairs
+ `(x,s)` such that `x` is in the cone, and `s` is in its dual. The
+ discrete complementarity set is a subset of the complementarity set
+ where `x` and `s` are required to be generators of their respective
+ cones.
+
+ For polyhedral cones, the discrete complementarity set is always
+ finite.
OUTPUT:
A list of pairs `(x,s)` such that,
+ * Both `x` and `s` are vectors (not rays).
* `x` is a generator of this cone.
* `s` is a generator of this cone's dual.
* `x` and `s` are orthogonal.
+ REFERENCES:
+
+ .. [Orlitzky/Gowda] M. Orlitzky and M. S. Gowda. The Lyapunov Rank of an
+ Improper Cone. Work in-progress.
+
EXAMPLES:
The discrete complementarity set of the nonnegative orthant consists
sage: discrete_complementarity_set(K)
[]
+ Likewise when this cone is trivial (its dual is the entire space)::
+
+ sage: L = ToricLattice(0)
+ sage: K = Cone([], ToricLattice(0))
+ sage: discrete_complementarity_set(K)
+ []
+
TESTS:
The complementarity set of the dual can be obtained by switching the
sage: sorted(actual) == sorted(expected)
True
+ The pairs in the discrete complementarity set are in fact
+ complementary::
+
+ sage: set_random_seed()
+ sage: K = random_cone(max_dim=6)
+ sage: dcs = discrete_complementarity_set(K)
+ sage: sum([x.inner_product(s).abs() for (x,s) in dcs])
+ 0
+
"""
V = K.lattice().vector_space()
- # Convert the rays to vectors so that we can compute inner
- # products.
+ # Convert rays to vectors so that we can compute inner products.
xs = [V(x) for x in K.rays()]
+
+ # We also convert the generators of the dual cone so that we
+ # return pairs of vectors and not (vector, ray) pairs.
ss = [V(s) for s in K.dual().rays()]
return [(x,s) for x in xs for s in ss if x.inner_product(s) == 0]