passagemath-polyhedra 10.6.31rc3__cp314-cp314-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of passagemath-polyhedra might be problematic. Click here for more details.

Files changed (206) hide show
  1. passagemath_polyhedra-10.6.31rc3.dist-info/METADATA +367 -0
  2. passagemath_polyhedra-10.6.31rc3.dist-info/METADATA.bak +369 -0
  3. passagemath_polyhedra-10.6.31rc3.dist-info/RECORD +206 -0
  4. passagemath_polyhedra-10.6.31rc3.dist-info/WHEEL +6 -0
  5. passagemath_polyhedra-10.6.31rc3.dist-info/top_level.txt +2 -0
  6. passagemath_polyhedra.libs/libgmp-6e109695.so.10.5.0 +0 -0
  7. passagemath_polyhedra.libs/libgomp-e985bcbb.so.1.0.0 +0 -0
  8. sage/all__sagemath_polyhedra.py +50 -0
  9. sage/game_theory/all.py +8 -0
  10. sage/game_theory/catalog.py +6 -0
  11. sage/game_theory/catalog_normal_form_games.py +923 -0
  12. sage/game_theory/cooperative_game.py +844 -0
  13. sage/game_theory/matching_game.py +1181 -0
  14. sage/game_theory/normal_form_game.py +2697 -0
  15. sage/game_theory/parser.py +275 -0
  16. sage/geometry/all__sagemath_polyhedra.py +22 -0
  17. sage/geometry/cone.py +6940 -0
  18. sage/geometry/cone_catalog.py +847 -0
  19. sage/geometry/cone_critical_angles.py +1027 -0
  20. sage/geometry/convex_set.py +1119 -0
  21. sage/geometry/fan.py +3743 -0
  22. sage/geometry/fan_isomorphism.py +389 -0
  23. sage/geometry/fan_morphism.py +1884 -0
  24. sage/geometry/hasse_diagram.py +202 -0
  25. sage/geometry/hyperplane_arrangement/affine_subspace.py +390 -0
  26. sage/geometry/hyperplane_arrangement/all.py +1 -0
  27. sage/geometry/hyperplane_arrangement/arrangement.py +3895 -0
  28. sage/geometry/hyperplane_arrangement/check_freeness.py +145 -0
  29. sage/geometry/hyperplane_arrangement/hyperplane.py +773 -0
  30. sage/geometry/hyperplane_arrangement/library.py +825 -0
  31. sage/geometry/hyperplane_arrangement/ordered_arrangement.py +642 -0
  32. sage/geometry/hyperplane_arrangement/plot.py +520 -0
  33. sage/geometry/integral_points.py +35 -0
  34. sage/geometry/integral_points_generic_dense.cpython-314-x86_64-linux-gnu.so +0 -0
  35. sage/geometry/integral_points_generic_dense.pyx +7 -0
  36. sage/geometry/lattice_polytope.py +5894 -0
  37. sage/geometry/linear_expression.py +773 -0
  38. sage/geometry/newton_polygon.py +767 -0
  39. sage/geometry/point_collection.cpython-314-x86_64-linux-gnu.so +0 -0
  40. sage/geometry/point_collection.pyx +1008 -0
  41. sage/geometry/polyhedral_complex.py +2616 -0
  42. sage/geometry/polyhedron/all.py +8 -0
  43. sage/geometry/polyhedron/backend_cdd.py +460 -0
  44. sage/geometry/polyhedron/backend_cdd_rdf.py +231 -0
  45. sage/geometry/polyhedron/backend_field.py +347 -0
  46. sage/geometry/polyhedron/backend_normaliz.py +2503 -0
  47. sage/geometry/polyhedron/backend_number_field.py +168 -0
  48. sage/geometry/polyhedron/backend_polymake.py +765 -0
  49. sage/geometry/polyhedron/backend_ppl.py +582 -0
  50. sage/geometry/polyhedron/base.py +1206 -0
  51. sage/geometry/polyhedron/base0.py +1444 -0
  52. sage/geometry/polyhedron/base1.py +886 -0
  53. sage/geometry/polyhedron/base2.py +812 -0
  54. sage/geometry/polyhedron/base3.py +1845 -0
  55. sage/geometry/polyhedron/base4.py +1262 -0
  56. sage/geometry/polyhedron/base5.py +2700 -0
  57. sage/geometry/polyhedron/base6.py +1741 -0
  58. sage/geometry/polyhedron/base7.py +997 -0
  59. sage/geometry/polyhedron/base_QQ.py +1258 -0
  60. sage/geometry/polyhedron/base_RDF.py +98 -0
  61. sage/geometry/polyhedron/base_ZZ.py +934 -0
  62. sage/geometry/polyhedron/base_mutable.py +215 -0
  63. sage/geometry/polyhedron/base_number_field.py +122 -0
  64. sage/geometry/polyhedron/cdd_file_format.py +155 -0
  65. sage/geometry/polyhedron/combinatorial_polyhedron/all.py +1 -0
  66. sage/geometry/polyhedron/combinatorial_polyhedron/base.cpython-314-x86_64-linux-gnu.so +0 -0
  67. sage/geometry/polyhedron/combinatorial_polyhedron/base.pxd +76 -0
  68. sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx +3859 -0
  69. sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.cpython-314-x86_64-linux-gnu.so +0 -0
  70. sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pxd +39 -0
  71. sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pyx +1038 -0
  72. sage/geometry/polyhedron/combinatorial_polyhedron/conversions.cpython-314-x86_64-linux-gnu.so +0 -0
  73. sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pxd +9 -0
  74. sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pyx +501 -0
  75. sage/geometry/polyhedron/combinatorial_polyhedron/face_data_structure.pxd +207 -0
  76. sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.cpython-314-x86_64-linux-gnu.so +0 -0
  77. sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pxd +102 -0
  78. sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx +2274 -0
  79. sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.cpython-314-x86_64-linux-gnu.so +0 -0
  80. sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pxd +370 -0
  81. sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pyx +84 -0
  82. sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.cpython-314-x86_64-linux-gnu.so +0 -0
  83. sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pxd +31 -0
  84. sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pyx +587 -0
  85. sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.cpython-314-x86_64-linux-gnu.so +0 -0
  86. sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pxd +52 -0
  87. sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pyx +560 -0
  88. sage/geometry/polyhedron/constructor.py +773 -0
  89. sage/geometry/polyhedron/double_description.py +753 -0
  90. sage/geometry/polyhedron/double_description_inhomogeneous.py +564 -0
  91. sage/geometry/polyhedron/face.py +1060 -0
  92. sage/geometry/polyhedron/generating_function.py +1810 -0
  93. sage/geometry/polyhedron/lattice_euclidean_group_element.py +178 -0
  94. sage/geometry/polyhedron/library.py +3502 -0
  95. sage/geometry/polyhedron/misc.py +121 -0
  96. sage/geometry/polyhedron/modules/all.py +1 -0
  97. sage/geometry/polyhedron/modules/formal_polyhedra_module.py +155 -0
  98. sage/geometry/polyhedron/palp_database.py +447 -0
  99. sage/geometry/polyhedron/parent.py +1279 -0
  100. sage/geometry/polyhedron/plot.py +1986 -0
  101. sage/geometry/polyhedron/ppl_lattice_polygon.py +556 -0
  102. sage/geometry/polyhedron/ppl_lattice_polytope.py +1257 -0
  103. sage/geometry/polyhedron/representation.py +1723 -0
  104. sage/geometry/pseudolines.py +515 -0
  105. sage/geometry/relative_interior.py +445 -0
  106. sage/geometry/toric_plotter.py +1103 -0
  107. sage/geometry/triangulation/all.py +2 -0
  108. sage/geometry/triangulation/base.cpython-314-x86_64-linux-gnu.so +0 -0
  109. sage/geometry/triangulation/base.pyx +963 -0
  110. sage/geometry/triangulation/data.h +147 -0
  111. sage/geometry/triangulation/data.pxd +4 -0
  112. sage/geometry/triangulation/element.py +914 -0
  113. sage/geometry/triangulation/functions.h +10 -0
  114. sage/geometry/triangulation/functions.pxd +4 -0
  115. sage/geometry/triangulation/point_configuration.py +2256 -0
  116. sage/geometry/triangulation/triangulations.h +49 -0
  117. sage/geometry/triangulation/triangulations.pxd +7 -0
  118. sage/geometry/voronoi_diagram.py +319 -0
  119. sage/interfaces/all__sagemath_polyhedra.py +1 -0
  120. sage/interfaces/polymake.py +2028 -0
  121. sage/numerical/all.py +13 -0
  122. sage/numerical/all__sagemath_polyhedra.py +11 -0
  123. sage/numerical/backends/all.py +1 -0
  124. sage/numerical/backends/all__sagemath_polyhedra.py +1 -0
  125. sage/numerical/backends/cvxopt_backend.cpython-314-x86_64-linux-gnu.so +0 -0
  126. sage/numerical/backends/cvxopt_backend.pyx +1006 -0
  127. sage/numerical/backends/cvxopt_backend_test.py +19 -0
  128. sage/numerical/backends/cvxopt_sdp_backend.cpython-314-x86_64-linux-gnu.so +0 -0
  129. sage/numerical/backends/cvxopt_sdp_backend.pyx +382 -0
  130. sage/numerical/backends/cvxpy_backend.cpython-314-x86_64-linux-gnu.so +0 -0
  131. sage/numerical/backends/cvxpy_backend.pxd +41 -0
  132. sage/numerical/backends/cvxpy_backend.pyx +934 -0
  133. sage/numerical/backends/cvxpy_backend_test.py +13 -0
  134. sage/numerical/backends/generic_backend_test.py +24 -0
  135. sage/numerical/backends/interactivelp_backend.cpython-314-x86_64-linux-gnu.so +0 -0
  136. sage/numerical/backends/interactivelp_backend.pxd +36 -0
  137. sage/numerical/backends/interactivelp_backend.pyx +1231 -0
  138. sage/numerical/backends/interactivelp_backend_test.py +12 -0
  139. sage/numerical/backends/logging_backend.py +391 -0
  140. sage/numerical/backends/matrix_sdp_backend.cpython-314-x86_64-linux-gnu.so +0 -0
  141. sage/numerical/backends/matrix_sdp_backend.pxd +15 -0
  142. sage/numerical/backends/matrix_sdp_backend.pyx +478 -0
  143. sage/numerical/backends/ppl_backend.cpython-314-x86_64-linux-gnu.so +0 -0
  144. sage/numerical/backends/ppl_backend.pyx +1126 -0
  145. sage/numerical/backends/ppl_backend_test.py +13 -0
  146. sage/numerical/backends/scip_backend.cpython-314-x86_64-linux-gnu.so +0 -0
  147. sage/numerical/backends/scip_backend.pxd +22 -0
  148. sage/numerical/backends/scip_backend.pyx +1289 -0
  149. sage/numerical/backends/scip_backend_test.py +13 -0
  150. sage/numerical/interactive_simplex_method.py +5338 -0
  151. sage/numerical/knapsack.py +665 -0
  152. sage/numerical/linear_functions.cpython-314-x86_64-linux-gnu.so +0 -0
  153. sage/numerical/linear_functions.pxd +31 -0
  154. sage/numerical/linear_functions.pyx +1648 -0
  155. sage/numerical/linear_tensor.py +470 -0
  156. sage/numerical/linear_tensor_constraints.py +448 -0
  157. sage/numerical/linear_tensor_element.cpython-314-x86_64-linux-gnu.so +0 -0
  158. sage/numerical/linear_tensor_element.pxd +6 -0
  159. sage/numerical/linear_tensor_element.pyx +459 -0
  160. sage/numerical/mip.cpython-314-x86_64-linux-gnu.so +0 -0
  161. sage/numerical/mip.pxd +40 -0
  162. sage/numerical/mip.pyx +3667 -0
  163. sage/numerical/sdp.cpython-314-x86_64-linux-gnu.so +0 -0
  164. sage/numerical/sdp.pxd +39 -0
  165. sage/numerical/sdp.pyx +1433 -0
  166. sage/rings/all__sagemath_polyhedra.py +3 -0
  167. sage/rings/polynomial/all__sagemath_polyhedra.py +10 -0
  168. sage/rings/polynomial/omega.py +982 -0
  169. sage/schemes/all__sagemath_polyhedra.py +2 -0
  170. sage/schemes/toric/all.py +10 -0
  171. sage/schemes/toric/chow_group.py +1248 -0
  172. sage/schemes/toric/divisor.py +2082 -0
  173. sage/schemes/toric/divisor_class.cpython-314-x86_64-linux-gnu.so +0 -0
  174. sage/schemes/toric/divisor_class.pyx +322 -0
  175. sage/schemes/toric/fano_variety.py +1606 -0
  176. sage/schemes/toric/homset.py +650 -0
  177. sage/schemes/toric/ideal.py +451 -0
  178. sage/schemes/toric/library.py +1322 -0
  179. sage/schemes/toric/morphism.py +1958 -0
  180. sage/schemes/toric/points.py +1032 -0
  181. sage/schemes/toric/sheaf/all.py +1 -0
  182. sage/schemes/toric/sheaf/constructor.py +302 -0
  183. sage/schemes/toric/sheaf/klyachko.py +921 -0
  184. sage/schemes/toric/toric_subscheme.py +905 -0
  185. sage/schemes/toric/variety.py +3460 -0
  186. sage/schemes/toric/weierstrass.py +1078 -0
  187. sage/schemes/toric/weierstrass_covering.py +457 -0
  188. sage/schemes/toric/weierstrass_higher.py +288 -0
  189. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.info +10 -0
  190. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v03 +0 -0
  191. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v04 +0 -0
  192. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v05 +1 -0
  193. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v06 +1 -0
  194. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.info +22 -0
  195. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v04 +0 -0
  196. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v05 +0 -0
  197. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v06 +0 -0
  198. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v07 +0 -0
  199. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v08 +0 -0
  200. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v09 +0 -0
  201. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v10 +0 -0
  202. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v11 +1 -0
  203. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v12 +1 -0
  204. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v13 +1 -0
  205. sage_wheels/share/reflexive_polytopes/reflexive_polytopes_2d +80 -0
  206. sage_wheels/share/reflexive_polytopes/reflexive_polytopes_3d +37977 -0
@@ -0,0 +1,448 @@
1
+ # sage_setup: distribution = sagemath-polyhedra
2
+ """
3
+ Constraints on Linear Functions Tensored with a Free Module
4
+
5
+ Here is an example of a vector-valued linear function::
6
+
7
+ sage: mip.<x> = MixedIntegerLinearProgram('ppl') # base ring is QQ
8
+ sage: x[0] * vector([3,4]) + 1 # vector linear function
9
+ (1, 1) + (3, 4)*x_0
10
+
11
+ Just like :mod:`~sage.numerical.linear_functions`, (in)equalities
12
+ become symbolic inequalities::
13
+
14
+ sage: 3 + x[0] + 2*x[1] <= 10
15
+ 3 + x_0 + 2*x_1 <= 10
16
+ sage: x[0] * vector([3,4]) + 1 <= 10
17
+ (1, 1) + (3, 4)*x_0 <= (10, 10)
18
+ sage: x[0] * matrix([[0,0,1],[0,1,0],[1,0,0]]) + x[1] * identity_matrix(3) >= 0
19
+ [0 0 0] [x_1 0 x_0]
20
+ [0 0 0] <= [0 x_0 + x_1 0 ]
21
+ [0 0 0] [x_0 0 x_1]
22
+ """
23
+ # ****************************************************************************
24
+ # Copyright (C) 2014 Volker Braun <vbraun.name@gmail.com>
25
+ #
26
+ # Distributed under the terms of the GNU General Public License (GPL)
27
+ # as published by the Free Software Foundation; either version 2 of
28
+ # the License, or (at your option) any later version.
29
+ # https://www.gnu.org/licenses/
30
+ # ****************************************************************************
31
+
32
+ from sage.structure.parent import Parent
33
+ from sage.structure.element import Element
34
+ from sage.misc.cachefunc import cached_function
35
+
36
+
37
+ #*****************************************************************************
38
+ #
39
+ # Utility functions to test that something is a linear function / constraint
40
+ #
41
+ #*****************************************************************************
42
+
43
+ def is_LinearTensorConstraint(x):
44
+ """
45
+ Test whether ``x`` is a constraint on module-valued linear functions.
46
+
47
+ INPUT:
48
+
49
+ - ``x`` -- anything
50
+
51
+ OUTPUT: boolean
52
+
53
+ EXAMPLES::
54
+
55
+ sage: mip.<x> = MixedIntegerLinearProgram()
56
+ sage: vector_ieq = (x[0] * vector([1,2]) <= x[1] * vector([2,3]))
57
+ sage: from sage.numerical.linear_tensor_constraints import is_LinearTensorConstraint
58
+ sage: is_LinearTensorConstraint(vector_ieq)
59
+ doctest:warning...
60
+ DeprecationWarning: The function is_LinearTensorConstraint is deprecated;
61
+ use 'isinstance(..., LinearTensorConstraint)' instead.
62
+ See https://github.com/sagemath/sage/issues/38184 for details.
63
+ True
64
+ sage: is_LinearTensorConstraint('a string')
65
+ False
66
+ """
67
+ from sage.misc.superseded import deprecation
68
+ deprecation(38184,
69
+ "The function is_LinearTensorConstraint is deprecated; "
70
+ "use 'isinstance(..., LinearTensorConstraint)' instead.")
71
+ return isinstance(x, LinearTensorConstraint)
72
+
73
+
74
+ #*****************************************************************************
75
+ #
76
+ # Factory functions for the parents to ensure uniqueness
77
+ #
78
+ #*****************************************************************************
79
+
80
+ @cached_function
81
+ def LinearTensorConstraintsParent(linear_functions_parent):
82
+ """
83
+ Return the parent for linear functions over ``base_ring``.
84
+
85
+ The output is cached, so only a single parent is ever constructed
86
+ for a given base ring.
87
+
88
+ INPUT:
89
+
90
+ - ``linear_functions_parent`` -- a
91
+ :class:`~sage.numerical.linear_functions.LinearFunctionsParent_class`. The
92
+ type of linear functions that the constraints are made out of.
93
+
94
+ OUTPUT: the parent of the linear constraints with the given linear functions
95
+
96
+ EXAMPLES::
97
+
98
+ sage: from sage.numerical.linear_functions import LinearFunctionsParent
99
+ sage: from sage.numerical.linear_tensor import LinearTensorParent
100
+ sage: from sage.numerical.linear_tensor_constraints import \
101
+ ....: LinearTensorConstraintsParent, LinearTensorConstraintsParent
102
+ sage: LF = LinearFunctionsParent(QQ)
103
+ sage: LT = LinearTensorParent(QQ^2, LF)
104
+ sage: LinearTensorConstraintsParent(LT)
105
+ Linear constraints in the tensor product of Vector space of dimension 2
106
+ over Rational Field and Linear functions over Rational Field
107
+ """
108
+ return LinearTensorConstraintsParent_class(linear_functions_parent)
109
+
110
+
111
+ # ****************************************************************************
112
+ #
113
+ # Elements of linear tensor constraints
114
+ #
115
+ # ****************************************************************************
116
+
117
+ class LinearTensorConstraint(Element):
118
+ """
119
+ Formal constraint involving two module-valued linear functions.
120
+
121
+ .. NOTE::
122
+
123
+ In the code, we use "linear tensor" as abbreviation for the
124
+ tensor product (over the common base ring) of a :mod:`linear
125
+ function <sage.numerical.linear_functions>` and a free module
126
+ like a vector/matrix space.
127
+
128
+ .. warning::
129
+
130
+ This class has no reason to be instantiated by the user, and
131
+ is meant to be used by instances of
132
+ :class:`MixedIntegerLinearProgram`.
133
+
134
+ INPUT:
135
+
136
+ - ``parent`` -- the parent, a
137
+ :class:`LinearTensorConstraintsParent_class`
138
+
139
+ - ``lhs``, ``rhs`` -- two
140
+ :class:`sage.numerical.linear_tensor_element.LinearTensor`. The
141
+ left and right hand side of the constraint (in)equality.
142
+
143
+ - ``equality`` -- boolean (default: ``False``); whether the
144
+ constraint is an equality. If ``False``, it is a ``<=``
145
+ inequality.
146
+
147
+ EXAMPLES::
148
+
149
+ sage: mip.<b> = MixedIntegerLinearProgram()
150
+ sage: (b[2]+2*b[3]) * vector([1,2]) <= b[8] * vector([2,3]) - 5
151
+ (1.0, 2.0)*x_0 + (2.0, 4.0)*x_1 <= (-5.0, -5.0) + (2.0, 3.0)*x_2
152
+ """
153
+
154
+ def __init__(self, parent, lhs, rhs, equality):
155
+ r"""
156
+ Constructor for ``LinearTensorConstraint``.
157
+
158
+ INPUT:
159
+
160
+ See :class:`LinearTensorConstraint`.
161
+
162
+ EXAMPLES::
163
+
164
+ sage: mip.<b> = MixedIntegerLinearProgram()
165
+ sage: b[2] * vector([1,2]) + 2*b[3] <= 0
166
+ (1.0, 2.0)*x_0 + (2.0, 2.0)*x_1 <= (0.0, 0.0)
167
+ """
168
+ super().__init__(parent)
169
+ self._lhs = lhs
170
+ self._rhs = rhs
171
+ self._equality = equality
172
+
173
+ def is_equation(self):
174
+ """
175
+ Whether the constraint is a chained equation.
176
+
177
+ OUTPUT: boolean
178
+
179
+ EXAMPLES::
180
+
181
+ sage: mip.<b> = MixedIntegerLinearProgram()
182
+ sage: (b[0] * vector([1,2]) == 0).is_equation()
183
+ True
184
+ sage: (b[0] * vector([1,2]) >= 0).is_equation()
185
+ False
186
+ """
187
+ return self._equality
188
+
189
+ def is_less_or_equal(self):
190
+ """
191
+ Whether the constraint is a chained less-or_equal inequality.
192
+
193
+ OUTPUT: boolean
194
+
195
+ EXAMPLES::
196
+
197
+ sage: mip.<b> = MixedIntegerLinearProgram()
198
+ sage: (b[0] * vector([1,2]) == 0).is_less_or_equal()
199
+ False
200
+ sage: (b[0] * vector([1,2]) >= 0).is_less_or_equal()
201
+ True
202
+ """
203
+ return not self._equality
204
+
205
+ def lhs(self):
206
+ """
207
+ Return the left side of the (in)equality.
208
+
209
+ OUTPUT:
210
+
211
+ Instance of
212
+ :class:`sage.numerical.linear_tensor_element.LinearTensor`. A
213
+ linear function valued in a free module.
214
+
215
+ EXAMPLES::
216
+
217
+ sage: mip.<x> = MixedIntegerLinearProgram()
218
+ sage: (x[0] * vector([1,2]) == 0).lhs()
219
+ (1.0, 2.0)*x_0
220
+ """
221
+ return self._lhs
222
+
223
+ def rhs(self):
224
+ """
225
+ Return the right side of the (in)equality.
226
+
227
+ OUTPUT:
228
+
229
+ Instance of
230
+ :class:`sage.numerical.linear_tensor_element.LinearTensor`. A
231
+ linear function valued in a free module.
232
+
233
+ EXAMPLES::
234
+
235
+ sage: mip.<x> = MixedIntegerLinearProgram()
236
+ sage: (x[0] * vector([1,2]) == 0).rhs()
237
+ (0.0, 0.0)
238
+ """
239
+ return self._rhs
240
+
241
+ def _ascii_art_(self):
242
+ """
243
+ Return Ascii Art.
244
+
245
+ OUTPUT:
246
+
247
+ Ascii art of the constraint (in)equality.
248
+
249
+ EXAMPLES::
250
+
251
+ sage: mip.<x> = MixedIntegerLinearProgram()
252
+ sage: ascii_art(x[0] * vector([1,2]) >= 0)
253
+ (0.0, 0.0) <= (1.0, 2.0)*x_0
254
+ sage: ascii_art(x[0] * matrix([[1,2],[3,4]]) >= 0)
255
+ [0 0] <= [x_0 2*x_0]
256
+ [0 0] [3*x_0 4*x_0]
257
+ """
258
+ from sage.typeset.ascii_art import AsciiArt
259
+
260
+ def matrix_art(m):
261
+ lines = str(m).splitlines()
262
+ return AsciiArt(lines, baseline=len(lines) // 2)
263
+ comparator = AsciiArt([' == ' if self.is_equation() else ' <= '])
264
+ return matrix_art(self.lhs()) + comparator + matrix_art(self.rhs())
265
+
266
+ def _repr_(self):
267
+ r"""
268
+ Return a string representation of the constraint.
269
+
270
+ OUTPUT: string
271
+
272
+ EXAMPLES::
273
+
274
+ sage: mip.<b> = MixedIntegerLinearProgram()
275
+ sage: b[3] * vector([1,2]) <= (b[8] + 9) * vector([2,3])
276
+ (1.0, 2.0)*x_0 <= (18.0, 27.0) + (2.0, 3.0)*x_1
277
+ sage: b[3] * vector([1,2]) == (b[8] + 9) * vector([2,3])
278
+ (1.0, 2.0)*x_0 == (18.0, 27.0) + (2.0, 3.0)*x_1
279
+ sage: b[0] * identity_matrix(3) == 0
280
+ [x_2 0 0 ] [0 0 0]
281
+ [0 x_2 0 ] == [0 0 0]
282
+ [0 0 x_2] [0 0 0]
283
+ """
284
+ if self.parent().linear_tensors().is_matrix_space():
285
+ return str(self._ascii_art_())
286
+ comparator = (' == ' if self.is_equation() else ' <= ')
287
+ return str(self.lhs()) + comparator + str(self.rhs())
288
+
289
+
290
+ #*****************************************************************************
291
+ #
292
+ # Parent of linear constraints
293
+ #
294
+ #*****************************************************************************
295
+
296
+ class LinearTensorConstraintsParent_class(Parent):
297
+ """
298
+ Parent for :class:`LinearTensorConstraint`.
299
+
300
+ .. warning::
301
+
302
+ This class has no reason to be instantiated by the user, and
303
+ is meant to be used by instances of
304
+ :class:`MixedIntegerLinearProgram`. Also, use the
305
+ :func:`LinearTensorConstraintsParent` factory function.
306
+
307
+ INPUT/OUTPUT: see :func:`LinearTensorConstraintsParent`
308
+
309
+ EXAMPLES::
310
+
311
+ sage: p = MixedIntegerLinearProgram()
312
+ sage: LT = p.linear_functions_parent().tensor(RDF^2); LT
313
+ Tensor product of Vector space of dimension 2 over Real Double
314
+ Field and Linear functions over Real Double Field
315
+ sage: from sage.numerical.linear_tensor_constraints import LinearTensorConstraintsParent
316
+ sage: LTC = LinearTensorConstraintsParent(LT); LTC
317
+ Linear constraints in the tensor product of Vector space of
318
+ dimension 2 over Real Double Field and Linear functions over
319
+ Real Double Field
320
+ sage: type(LTC)
321
+ <class 'sage.numerical.linear_tensor_constraints.LinearTensorConstraintsParent_class'>
322
+ """
323
+ Element = LinearTensorConstraint
324
+
325
+ def __init__(self, linear_tensor_parent):
326
+ """
327
+ The Python constructor.
328
+
329
+ INPUT:
330
+
331
+ - ``linear_tensor_parent`` -- instance of
332
+ :class:`LinearTensorParent_class`
333
+
334
+ TESTS::
335
+
336
+ sage: from sage.numerical.linear_functions import LinearFunctionsParent
337
+ sage: LF = LinearFunctionsParent(RDF)
338
+ sage: from sage.numerical.linear_tensor import LinearTensorParent
339
+ sage: LT = LinearTensorParent(RDF^2, LF)
340
+ sage: from sage.numerical.linear_tensor_constraints import LinearTensorConstraintsParent
341
+ sage: LinearTensorConstraintsParent(LT)
342
+ Linear constraints in the tensor product of Vector space of
343
+ dimension 2 over Real Double Field and Linear functions over
344
+ Real Double Field
345
+ """
346
+ Parent.__init__(self)
347
+ self._LT = linear_tensor_parent
348
+ self._LF = linear_tensor_parent.linear_functions()
349
+
350
+ def linear_tensors(self):
351
+ """
352
+ Return the parent for the linear functions.
353
+
354
+ OUTPUT: instance of :class:`sage.numerical.linear_tensor.LinearTensorParent_class`
355
+
356
+ EXAMPLES::
357
+
358
+ sage: mip.<x> = MixedIntegerLinearProgram()
359
+ sage: ieq = (x[0] * vector([1,2]) >= 0)
360
+ sage: ieq.parent().linear_tensors()
361
+ Tensor product of Vector space of dimension 2 over Real Double
362
+ Field and Linear functions over Real Double Field
363
+ """
364
+ return self._LT
365
+
366
+ def linear_functions(self):
367
+ """
368
+ Return the parent for the linear functions.
369
+
370
+ OUTPUT: instance of :class:`sage.numerical.linear_functions.LinearFunctionsParent_class`
371
+
372
+ EXAMPLES::
373
+
374
+ sage: mip.<x> = MixedIntegerLinearProgram()
375
+ sage: ieq = (x[0] * vector([1,2]) >= 0)
376
+ sage: ieq.parent().linear_functions()
377
+ Linear functions over Real Double Field
378
+ """
379
+ return self._LF
380
+
381
+ def _repr_(self):
382
+ """
383
+ Return a string representation.
384
+
385
+ OUTPUT: string
386
+
387
+ EXAMPLES::
388
+
389
+ sage: mip.<x> = MixedIntegerLinearProgram()
390
+ sage: ieq = (x[0] * vector([1,2]) >= 0)
391
+ sage: ieq.parent() # indirect doctests
392
+ Linear constraints in the tensor product of Vector space of
393
+ dimension 2 over Real Double Field and Linear functions over
394
+ Real Double Field
395
+ """
396
+ return 'Linear constraints in the tensor product of {0} and {1}'.format(
397
+ self.linear_tensors().free_module(), self.linear_functions())
398
+
399
+ def _element_constructor_(self, left, right, equality):
400
+ """
401
+ Construct a :class:`LinearConstraint`.
402
+
403
+ INPUT:
404
+
405
+ - ``left`` -- a :class:`LinearTensor`, or something that can
406
+ be converted into one, a list/tuple of
407
+ :class:`LinearTensor`, or an existing
408
+ :class:`LinearTensorConstraint`.
409
+
410
+ - ``right`` -- a :class:`LinearTensor` or ``None``
411
+ (default)
412
+
413
+ - ``equality`` -- boolean; whether to
414
+ construct an equation or a less-or-equal inequality
415
+
416
+ OUTPUT: the :class:`LinearTensorConstraint` constructed from the input data
417
+
418
+ EXAMPLES::
419
+
420
+ sage: mip.<x> = MixedIntegerLinearProgram()
421
+ sage: ieq = (x[0] * vector([1,2]) >= 0)
422
+ sage: LTC = ieq.parent()
423
+ sage: LTC._element_constructor_(1, 2, True)
424
+ (1.0, 1.0) == (2.0, 2.0)
425
+ sage: LTC(x[0], x[1], False)
426
+ (1.0, 1.0)*x_0 <= (1.0, 1.0)*x_1
427
+ sage: type(_)
428
+ <class 'sage.numerical.linear_tensor_constraints.LinearTensorConstraintsParent_class.element_class'>
429
+ """
430
+ LT = self.linear_tensors()
431
+ left = LT(left)
432
+ right = LT(right)
433
+ equality = bool(equality)
434
+ return self.element_class(self, left, right, equality)
435
+
436
+ def _an_element_(self):
437
+ """
438
+ Return an element.
439
+
440
+ EXAMPLES::
441
+
442
+ sage: mip.<x> = MixedIntegerLinearProgram()
443
+ sage: ieq = (x[0] * vector([1,2]) >= 0)
444
+ sage: ieq.parent().an_element() # indirect doctest
445
+ (0.0, 0.0) <= (1.0, 0.0) + (5.0, 0.0)*x_2 + (7.0, 0.0)*x_5
446
+ """
447
+ LT = self.linear_tensors()
448
+ return LT.an_element() >= 0
@@ -0,0 +1,6 @@
1
+ # sage_setup: distribution = sagemath-polyhedra
2
+ from sage.structure.element cimport Element, ModuleElement
3
+
4
+ cdef class LinearTensor(ModuleElement):
5
+ cdef dict _f
6
+ cpdef _add_(self, other)