]>
gitweb.michael.orlitzky.com - sage.d.git/blob - mjo/cone/faces.py
9c6cfd4f2fc2a75d3c36ac3bc2b1a78b98938f7e
3 def face_generated_by(K
,S
):
5 Return the intersection of all faces of ``K`` that contain ``S``.
9 .. [Tam] Bit-Shun Tam. On the duality operator of a convex cone. Linear
10 Algebra and its Applications, 64:33-56, 1985, doi:10.1016/0024-3795(85)
15 sage: from mjo.cone.faces import face_generated_by
19 The face generated by a standard basis vector in the nonnegative
20 orthant should be the cone consisting of all nonnegative multiples
21 of that standard basis vector::
23 sage: K = Cone([(1,0,0),(0,1,0),(0,0,1)])
24 sage: F = Cone([(1,0,0)])
25 sage: face_generated_by(K,F) == F
28 If we take a nontrivial combination of standard basis vectors in the
29 nonnegative orthant, then the face that the combination generates
30 should be the cone generated by those two basis vectors::
32 sage: e1 = vector(QQ, [1,0,0])
33 sage: e2 = vector(QQ, [0,1,0])
34 sage: e3 = vector(QQ, [0,0,1])
35 sage: K = Cone([e1,e2,e2])
36 sage: F = [e1/2 + e2/2]
37 sage: face_generated_by(K,F).is_equivalent(Cone([e1,e2]))
40 An error is raised if ``S`` is not contained in ``K``::
42 sage: K = Cone([(1,0),(0,1)])
43 sage: S = [(1,1), (-1,3)]
44 sage: face_generated_by(K,S)
45 Traceback (most recent call last):
47 ValueError: S is not a subset of the cone
51 The face generated by <whatever> should be a face::
53 sage: set_random_seed()
54 sage: K = random_cone(max_ambient_dim=8, max_rays=10)
55 sage: S = [K.random_element() for idx in range(0,5)]
56 sage: F = face_generated_by(K, S)
60 The face generated by a set should always contain that set::
62 sage: set_random_seed()
63 sage: K = random_cone(max_ambient_dim=8, max_rays=10)
64 sage: S = [K.random_element() for idx in range(0,5)]
65 sage: F = face_generated_by(K, S)
66 sage: all([F.contains(x) for x in S])
69 The generators of a proper cone are all extreme vectors of the cone,
70 and therefore generate their own faces::
72 sage: set_random_seed()
73 sage: K = random_cone(max_ambient_dim=8,
75 ....: strictly_convex=True,
77 sage: all([face_generated_by(K, [r]) == Cone([r]) for r in K])
81 face_lattice
= K
.face_lattice()
82 candidates
= [F
for F
in face_lattice
if all([F
.contains(x
) for x
in S
])]
84 # K itself is a face of K, so unless we were given a set S that
85 # isn't a subset of K, the candidates list will be nonempty.
86 if len(candidates
) == 0:
87 raise ValueError('S is not a subset of the cone')
89 return face_lattice
.sorted(candidates
)[0]