passagemath-polyhedra 10.6.31rc3__cp314-cp314-musllinux_1_2_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 (208) 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 +208 -0
  4. passagemath_polyhedra-10.6.31rc3.dist-info/WHEEL +5 -0
  5. passagemath_polyhedra-10.6.31rc3.dist-info/top_level.txt +2 -0
  6. passagemath_polyhedra.libs/libgcc_s-0cd532bd.so.1 +0 -0
  7. passagemath_polyhedra.libs/libgmp-0e7fc84e.so.10.5.0 +0 -0
  8. passagemath_polyhedra.libs/libgomp-8949ffbe.so.1.0.0 +0 -0
  9. passagemath_polyhedra.libs/libstdc++-5d72f927.so.6.0.33 +0 -0
  10. sage/all__sagemath_polyhedra.py +50 -0
  11. sage/game_theory/all.py +8 -0
  12. sage/game_theory/catalog.py +6 -0
  13. sage/game_theory/catalog_normal_form_games.py +923 -0
  14. sage/game_theory/cooperative_game.py +844 -0
  15. sage/game_theory/matching_game.py +1181 -0
  16. sage/game_theory/normal_form_game.py +2697 -0
  17. sage/game_theory/parser.py +275 -0
  18. sage/geometry/all__sagemath_polyhedra.py +22 -0
  19. sage/geometry/cone.py +6940 -0
  20. sage/geometry/cone_catalog.py +847 -0
  21. sage/geometry/cone_critical_angles.py +1027 -0
  22. sage/geometry/convex_set.py +1119 -0
  23. sage/geometry/fan.py +3743 -0
  24. sage/geometry/fan_isomorphism.py +389 -0
  25. sage/geometry/fan_morphism.py +1884 -0
  26. sage/geometry/hasse_diagram.py +202 -0
  27. sage/geometry/hyperplane_arrangement/affine_subspace.py +390 -0
  28. sage/geometry/hyperplane_arrangement/all.py +1 -0
  29. sage/geometry/hyperplane_arrangement/arrangement.py +3895 -0
  30. sage/geometry/hyperplane_arrangement/check_freeness.py +145 -0
  31. sage/geometry/hyperplane_arrangement/hyperplane.py +773 -0
  32. sage/geometry/hyperplane_arrangement/library.py +825 -0
  33. sage/geometry/hyperplane_arrangement/ordered_arrangement.py +642 -0
  34. sage/geometry/hyperplane_arrangement/plot.py +520 -0
  35. sage/geometry/integral_points.py +35 -0
  36. sage/geometry/integral_points_generic_dense.cpython-314-x86_64-linux-musl.so +0 -0
  37. sage/geometry/integral_points_generic_dense.pyx +7 -0
  38. sage/geometry/lattice_polytope.py +5894 -0
  39. sage/geometry/linear_expression.py +773 -0
  40. sage/geometry/newton_polygon.py +767 -0
  41. sage/geometry/point_collection.cpython-314-x86_64-linux-musl.so +0 -0
  42. sage/geometry/point_collection.pyx +1008 -0
  43. sage/geometry/polyhedral_complex.py +2616 -0
  44. sage/geometry/polyhedron/all.py +8 -0
  45. sage/geometry/polyhedron/backend_cdd.py +460 -0
  46. sage/geometry/polyhedron/backend_cdd_rdf.py +231 -0
  47. sage/geometry/polyhedron/backend_field.py +347 -0
  48. sage/geometry/polyhedron/backend_normaliz.py +2503 -0
  49. sage/geometry/polyhedron/backend_number_field.py +168 -0
  50. sage/geometry/polyhedron/backend_polymake.py +765 -0
  51. sage/geometry/polyhedron/backend_ppl.py +582 -0
  52. sage/geometry/polyhedron/base.py +1206 -0
  53. sage/geometry/polyhedron/base0.py +1444 -0
  54. sage/geometry/polyhedron/base1.py +886 -0
  55. sage/geometry/polyhedron/base2.py +812 -0
  56. sage/geometry/polyhedron/base3.py +1845 -0
  57. sage/geometry/polyhedron/base4.py +1262 -0
  58. sage/geometry/polyhedron/base5.py +2700 -0
  59. sage/geometry/polyhedron/base6.py +1741 -0
  60. sage/geometry/polyhedron/base7.py +997 -0
  61. sage/geometry/polyhedron/base_QQ.py +1258 -0
  62. sage/geometry/polyhedron/base_RDF.py +98 -0
  63. sage/geometry/polyhedron/base_ZZ.py +934 -0
  64. sage/geometry/polyhedron/base_mutable.py +215 -0
  65. sage/geometry/polyhedron/base_number_field.py +122 -0
  66. sage/geometry/polyhedron/cdd_file_format.py +155 -0
  67. sage/geometry/polyhedron/combinatorial_polyhedron/all.py +1 -0
  68. sage/geometry/polyhedron/combinatorial_polyhedron/base.cpython-314-x86_64-linux-musl.so +0 -0
  69. sage/geometry/polyhedron/combinatorial_polyhedron/base.pxd +76 -0
  70. sage/geometry/polyhedron/combinatorial_polyhedron/base.pyx +3859 -0
  71. sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.cpython-314-x86_64-linux-musl.so +0 -0
  72. sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pxd +39 -0
  73. sage/geometry/polyhedron/combinatorial_polyhedron/combinatorial_face.pyx +1038 -0
  74. sage/geometry/polyhedron/combinatorial_polyhedron/conversions.cpython-314-x86_64-linux-musl.so +0 -0
  75. sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pxd +9 -0
  76. sage/geometry/polyhedron/combinatorial_polyhedron/conversions.pyx +501 -0
  77. sage/geometry/polyhedron/combinatorial_polyhedron/face_data_structure.pxd +207 -0
  78. sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.cpython-314-x86_64-linux-musl.so +0 -0
  79. sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pxd +102 -0
  80. sage/geometry/polyhedron/combinatorial_polyhedron/face_iterator.pyx +2274 -0
  81. sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.cpython-314-x86_64-linux-musl.so +0 -0
  82. sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pxd +370 -0
  83. sage/geometry/polyhedron/combinatorial_polyhedron/face_list_data_structure.pyx +84 -0
  84. sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.cpython-314-x86_64-linux-musl.so +0 -0
  85. sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pxd +31 -0
  86. sage/geometry/polyhedron/combinatorial_polyhedron/list_of_faces.pyx +587 -0
  87. sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.cpython-314-x86_64-linux-musl.so +0 -0
  88. sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pxd +52 -0
  89. sage/geometry/polyhedron/combinatorial_polyhedron/polyhedron_face_lattice.pyx +560 -0
  90. sage/geometry/polyhedron/constructor.py +773 -0
  91. sage/geometry/polyhedron/double_description.py +753 -0
  92. sage/geometry/polyhedron/double_description_inhomogeneous.py +564 -0
  93. sage/geometry/polyhedron/face.py +1060 -0
  94. sage/geometry/polyhedron/generating_function.py +1810 -0
  95. sage/geometry/polyhedron/lattice_euclidean_group_element.py +178 -0
  96. sage/geometry/polyhedron/library.py +3502 -0
  97. sage/geometry/polyhedron/misc.py +121 -0
  98. sage/geometry/polyhedron/modules/all.py +1 -0
  99. sage/geometry/polyhedron/modules/formal_polyhedra_module.py +155 -0
  100. sage/geometry/polyhedron/palp_database.py +447 -0
  101. sage/geometry/polyhedron/parent.py +1279 -0
  102. sage/geometry/polyhedron/plot.py +1986 -0
  103. sage/geometry/polyhedron/ppl_lattice_polygon.py +556 -0
  104. sage/geometry/polyhedron/ppl_lattice_polytope.py +1257 -0
  105. sage/geometry/polyhedron/representation.py +1723 -0
  106. sage/geometry/pseudolines.py +515 -0
  107. sage/geometry/relative_interior.py +445 -0
  108. sage/geometry/toric_plotter.py +1103 -0
  109. sage/geometry/triangulation/all.py +2 -0
  110. sage/geometry/triangulation/base.cpython-314-x86_64-linux-musl.so +0 -0
  111. sage/geometry/triangulation/base.pyx +963 -0
  112. sage/geometry/triangulation/data.h +147 -0
  113. sage/geometry/triangulation/data.pxd +4 -0
  114. sage/geometry/triangulation/element.py +914 -0
  115. sage/geometry/triangulation/functions.h +10 -0
  116. sage/geometry/triangulation/functions.pxd +4 -0
  117. sage/geometry/triangulation/point_configuration.py +2256 -0
  118. sage/geometry/triangulation/triangulations.h +49 -0
  119. sage/geometry/triangulation/triangulations.pxd +7 -0
  120. sage/geometry/voronoi_diagram.py +319 -0
  121. sage/interfaces/all__sagemath_polyhedra.py +1 -0
  122. sage/interfaces/polymake.py +2028 -0
  123. sage/numerical/all.py +13 -0
  124. sage/numerical/all__sagemath_polyhedra.py +11 -0
  125. sage/numerical/backends/all.py +1 -0
  126. sage/numerical/backends/all__sagemath_polyhedra.py +1 -0
  127. sage/numerical/backends/cvxopt_backend.cpython-314-x86_64-linux-musl.so +0 -0
  128. sage/numerical/backends/cvxopt_backend.pyx +1006 -0
  129. sage/numerical/backends/cvxopt_backend_test.py +19 -0
  130. sage/numerical/backends/cvxopt_sdp_backend.cpython-314-x86_64-linux-musl.so +0 -0
  131. sage/numerical/backends/cvxopt_sdp_backend.pyx +382 -0
  132. sage/numerical/backends/cvxpy_backend.cpython-314-x86_64-linux-musl.so +0 -0
  133. sage/numerical/backends/cvxpy_backend.pxd +41 -0
  134. sage/numerical/backends/cvxpy_backend.pyx +934 -0
  135. sage/numerical/backends/cvxpy_backend_test.py +13 -0
  136. sage/numerical/backends/generic_backend_test.py +24 -0
  137. sage/numerical/backends/interactivelp_backend.cpython-314-x86_64-linux-musl.so +0 -0
  138. sage/numerical/backends/interactivelp_backend.pxd +36 -0
  139. sage/numerical/backends/interactivelp_backend.pyx +1231 -0
  140. sage/numerical/backends/interactivelp_backend_test.py +12 -0
  141. sage/numerical/backends/logging_backend.py +391 -0
  142. sage/numerical/backends/matrix_sdp_backend.cpython-314-x86_64-linux-musl.so +0 -0
  143. sage/numerical/backends/matrix_sdp_backend.pxd +15 -0
  144. sage/numerical/backends/matrix_sdp_backend.pyx +478 -0
  145. sage/numerical/backends/ppl_backend.cpython-314-x86_64-linux-musl.so +0 -0
  146. sage/numerical/backends/ppl_backend.pyx +1126 -0
  147. sage/numerical/backends/ppl_backend_test.py +13 -0
  148. sage/numerical/backends/scip_backend.cpython-314-x86_64-linux-musl.so +0 -0
  149. sage/numerical/backends/scip_backend.pxd +22 -0
  150. sage/numerical/backends/scip_backend.pyx +1289 -0
  151. sage/numerical/backends/scip_backend_test.py +13 -0
  152. sage/numerical/interactive_simplex_method.py +5338 -0
  153. sage/numerical/knapsack.py +665 -0
  154. sage/numerical/linear_functions.cpython-314-x86_64-linux-musl.so +0 -0
  155. sage/numerical/linear_functions.pxd +31 -0
  156. sage/numerical/linear_functions.pyx +1648 -0
  157. sage/numerical/linear_tensor.py +470 -0
  158. sage/numerical/linear_tensor_constraints.py +448 -0
  159. sage/numerical/linear_tensor_element.cpython-314-x86_64-linux-musl.so +0 -0
  160. sage/numerical/linear_tensor_element.pxd +6 -0
  161. sage/numerical/linear_tensor_element.pyx +459 -0
  162. sage/numerical/mip.cpython-314-x86_64-linux-musl.so +0 -0
  163. sage/numerical/mip.pxd +40 -0
  164. sage/numerical/mip.pyx +3667 -0
  165. sage/numerical/sdp.cpython-314-x86_64-linux-musl.so +0 -0
  166. sage/numerical/sdp.pxd +39 -0
  167. sage/numerical/sdp.pyx +1433 -0
  168. sage/rings/all__sagemath_polyhedra.py +3 -0
  169. sage/rings/polynomial/all__sagemath_polyhedra.py +10 -0
  170. sage/rings/polynomial/omega.py +982 -0
  171. sage/schemes/all__sagemath_polyhedra.py +2 -0
  172. sage/schemes/toric/all.py +10 -0
  173. sage/schemes/toric/chow_group.py +1248 -0
  174. sage/schemes/toric/divisor.py +2082 -0
  175. sage/schemes/toric/divisor_class.cpython-314-x86_64-linux-musl.so +0 -0
  176. sage/schemes/toric/divisor_class.pyx +322 -0
  177. sage/schemes/toric/fano_variety.py +1606 -0
  178. sage/schemes/toric/homset.py +650 -0
  179. sage/schemes/toric/ideal.py +451 -0
  180. sage/schemes/toric/library.py +1322 -0
  181. sage/schemes/toric/morphism.py +1958 -0
  182. sage/schemes/toric/points.py +1032 -0
  183. sage/schemes/toric/sheaf/all.py +1 -0
  184. sage/schemes/toric/sheaf/constructor.py +302 -0
  185. sage/schemes/toric/sheaf/klyachko.py +921 -0
  186. sage/schemes/toric/toric_subscheme.py +905 -0
  187. sage/schemes/toric/variety.py +3460 -0
  188. sage/schemes/toric/weierstrass.py +1078 -0
  189. sage/schemes/toric/weierstrass_covering.py +457 -0
  190. sage/schemes/toric/weierstrass_higher.py +288 -0
  191. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.info +10 -0
  192. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v03 +0 -0
  193. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v04 +0 -0
  194. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v05 +1 -0
  195. sage_wheels/share/reflexive_polytopes/Full2d/zzdb.v06 +1 -0
  196. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.info +22 -0
  197. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v04 +0 -0
  198. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v05 +0 -0
  199. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v06 +0 -0
  200. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v07 +0 -0
  201. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v08 +0 -0
  202. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v09 +0 -0
  203. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v10 +0 -0
  204. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v11 +1 -0
  205. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v12 +1 -0
  206. sage_wheels/share/reflexive_polytopes/Full3d/zzdb.v13 +1 -0
  207. sage_wheels/share/reflexive_polytopes/reflexive_polytopes_2d +80 -0
  208. sage_wheels/share/reflexive_polytopes/reflexive_polytopes_3d +37977 -0
@@ -0,0 +1,1006 @@
1
+ # sage_setup: distribution = sagemath-polyhedra
2
+ # sage.doctest: needs cvxopt
3
+ r"""
4
+ CVXOPT Backend
5
+
6
+
7
+ AUTHORS:
8
+
9
+ - Ingolfur Edvardsson (2014-05): initial implementation
10
+ """
11
+ #*****************************************************************************
12
+ # Copyright (C) 2014 Ingolfur Edvardsson <ingolfured@gmail.com>
13
+ #
14
+ # This program is free software: you can redistribute it and/or modify
15
+ # it under the terms of the GNU General Public License as published by
16
+ # the Free Software Foundation, either version 2 of the License, or
17
+ # (at your option) any later version.
18
+ # http://www.gnu.org/licenses/
19
+ #*****************************************************************************
20
+
21
+ from sage.numerical.mip import MIPSolverException
22
+ from sage.numerical.backends.generic_backend cimport GenericBackend
23
+ from copy import copy
24
+
25
+
26
+ cdef class CVXOPTBackend(GenericBackend):
27
+ """
28
+ MIP Backend that uses the CVXOPT solver.
29
+
30
+ There is no support for integer variables.
31
+
32
+ EXAMPLES::
33
+
34
+ sage: p = MixedIntegerLinearProgram(solver='CVXOPT')
35
+
36
+ TESTS:
37
+
38
+ :issue:`20332`::
39
+
40
+ sage: p
41
+ Mixed Integer Program (no objective, 0 variables, 0 constraints)
42
+ """
43
+
44
+ cdef list objective_function # c_matrix
45
+ cdef list G_matrix
46
+ cdef str prob_name
47
+ cdef bint is_maximize
48
+
49
+ cdef list row_lower_bound
50
+ cdef list row_upper_bound
51
+ cdef list col_lower_bound
52
+ cdef list col_upper_bound
53
+
54
+ cdef list row_name_var
55
+ cdef list col_name_var
56
+ cdef dict answer
57
+ cdef dict param
58
+
59
+ def __cinit__(self, maximization=True):
60
+ """
61
+ Cython constructor.
62
+
63
+ EXAMPLES::
64
+
65
+ sage: from sage.numerical.backends.generic_backend import get_solver
66
+ sage: p = get_solver(solver='CVXOPT')
67
+ """
68
+
69
+ self.objective_function = [] # c_matrix in the example for cvxopt
70
+ self.G_matrix = []
71
+ self.prob_name = ''
72
+ self.obj_constant_term = 0
73
+ self.is_maximize = 1
74
+
75
+ self.row_lower_bound = []
76
+ self.row_upper_bound = []
77
+ self.col_lower_bound = []
78
+ self.col_upper_bound = []
79
+
80
+ self.row_name_var = []
81
+ self.col_name_var = []
82
+
83
+ self.param = {"show_progress": False,
84
+ "maxiters": 100,
85
+ "abstol": 1e-7,
86
+ "reltol": 1e-6,
87
+ "feastol": 1e-7,
88
+ "refinement": 0}
89
+ self.answer = {}
90
+ if maximization:
91
+ self.set_sense(+1)
92
+ else:
93
+ self.set_sense(-1)
94
+
95
+ cpdef __copy__(self):
96
+ # Added a second inequality to this doctest,
97
+ # because otherwise CVXOPT complains: ValueError: Rank(A) < p or Rank([G; A]) < n
98
+ """
99
+ Return a copy of ``self``.
100
+
101
+ EXAMPLES::
102
+
103
+ sage: from sage.numerical.backends.generic_backend import get_solver
104
+ sage: p = MixedIntegerLinearProgram(solver='CVXOPT')
105
+ sage: b = p.new_variable()
106
+ sage: p.add_constraint(b[1] + b[2] <= 6)
107
+ sage: p.add_constraint(b[2] <= 5)
108
+ sage: p.set_objective(b[1] + b[2])
109
+ sage: cp = copy(p.get_backend())
110
+ sage: cp.solve()
111
+ 0
112
+ sage: cp.get_objective_value()
113
+ 6.0
114
+ """
115
+ cdef CVXOPTBackend cp = type(self)()
116
+ cp.objective_function = self.objective_function[:]
117
+ cp.G_matrix = [row[:] for row in self.G_matrix]
118
+ cp.prob_name = self.prob_name
119
+ cp.obj_constant_term = self.obj_constant_term
120
+ cp.is_maximize = self.is_maximize
121
+
122
+ cp.row_lower_bound = self.row_lower_bound[:]
123
+ cp.row_upper_bound = self.row_upper_bound[:]
124
+ cp.col_lower_bound = self.col_lower_bound[:]
125
+ cp.col_upper_bound = self.col_upper_bound[:]
126
+
127
+ cp.row_name_var = self.row_name_var[:]
128
+ cp.col_name_var = self.col_name_var[:]
129
+
130
+ cp.param = copy(self.param)
131
+ return cp
132
+
133
+ cpdef int add_variable(self, lower_bound=0.0, upper_bound=None, binary=False, continuous=True, integer=False, obj=None, name=None) except -1:
134
+ """
135
+ Add a variable.
136
+
137
+ This amounts to adding a new column to the matrix. By default,
138
+ the variable is both positive and real.
139
+ Variable types are always continuous, and thus the parameters
140
+ ``binary``, ``integer``, and ``continuous`` have no effect.
141
+
142
+ INPUT:
143
+
144
+ - ``lower_bound`` -- the lower bound of the variable (default: 0)
145
+
146
+ - ``upper_bound`` -- the upper bound of the variable (default: ``None``)
147
+
148
+ - ``binary`` -- ``True`` if the variable is binary (default: ``False``)
149
+
150
+ - ``continuous`` -- ``True`` if the variable is continuous (default: ``True``)
151
+
152
+ - ``integer`` -- ``True`` if the variable is integer (default: ``False``)
153
+
154
+ - ``obj`` -- (optional) coefficient of this variable in the objective function (default: 0.0)
155
+
156
+ - ``name`` -- an optional name for the newly added variable (default: ``None``)
157
+
158
+ OUTPUT: the index of the newly created variable
159
+
160
+ EXAMPLES::
161
+
162
+ sage: from sage.numerical.backends.generic_backend import get_solver
163
+ sage: p = get_solver(solver='CVXOPT')
164
+ sage: p.ncols()
165
+ 0
166
+ sage: p.add_variable()
167
+ 0
168
+ sage: p.ncols()
169
+ 1
170
+ sage: p.add_variable()
171
+ 1
172
+ sage: p.add_variable(lower_bound=-2.0)
173
+ 2
174
+ sage: p.add_variable(continuous=True)
175
+ 3
176
+ sage: p.add_variable(name='x',obj=1.0)
177
+ 4
178
+ sage: p.col_name(3)
179
+ 'x_3'
180
+ sage: p.col_name(4)
181
+ 'x'
182
+ sage: p.objective_coefficient(4)
183
+ 1.00000000000000
184
+
185
+ TESTS::
186
+
187
+ sage: p.add_variable(integer=True)
188
+ Traceback (most recent call last):
189
+ ...
190
+ RuntimeError: CVXOPT only supports continuous variables
191
+ sage: p.add_variable(binary=True)
192
+ Traceback (most recent call last):
193
+ ...
194
+ RuntimeError: CVXOPT only supports continuous variables
195
+ """
196
+ if obj is None:
197
+ obj = 0.0
198
+ if binary or integer:
199
+ raise RuntimeError("CVXOPT only supports continuous variables")
200
+ self.G_matrix.append([0 for i in range(self.nrows())])
201
+ self.col_lower_bound.append(lower_bound)
202
+ self.col_upper_bound.append(upper_bound)
203
+ self.objective_function.append(obj)
204
+ self.col_name_var.append(name)
205
+ return len(self.objective_function) - 1
206
+
207
+ cpdef set_variable_type(self, int variable, int vtype):
208
+ """
209
+ Set the type of a variable.
210
+
211
+ EXAMPLES::
212
+
213
+ sage: from sage.numerical.backends.generic_backend import get_solver
214
+ sage: p = get_solver(solver='cvxopt')
215
+ sage: p.add_variables(5)
216
+ 4
217
+ sage: p.set_variable_type(3, -1)
218
+ sage: p.set_variable_type(3, -2)
219
+ Traceback (most recent call last):
220
+ ...
221
+ ValueError: ...
222
+ """
223
+ if vtype != -1:
224
+ raise ValueError('This backend does not handle integer variables ! Read the doc !')
225
+
226
+ cpdef set_sense(self, int sense):
227
+ """
228
+ Set the direction (maximization/minimization).
229
+
230
+ INPUT:
231
+
232
+ - ``sense`` -- integer:
233
+
234
+ * `+1` => Maximization
235
+ * `-1` => Minimization
236
+
237
+ EXAMPLES::
238
+
239
+ sage: from sage.numerical.backends.generic_backend import get_solver
240
+ sage: p = get_solver(solver='CVXOPT')
241
+ sage: p.is_maximization()
242
+ True
243
+ sage: p.set_sense(-1)
244
+ sage: p.is_maximization()
245
+ False
246
+ """
247
+ if sense == 1:
248
+ self.is_maximize = 1
249
+ else:
250
+ self.is_maximize = 0
251
+
252
+ cpdef objective_coefficient(self, int variable, coeff=None):
253
+ """
254
+ Set or get the coefficient of a variable in the objective
255
+ function
256
+
257
+ INPUT:
258
+
259
+ - ``variable`` -- integer; the variable's id
260
+
261
+ - ``coeff`` -- double; its coefficient
262
+
263
+ EXAMPLES::
264
+
265
+ sage: from sage.numerical.backends.generic_backend import get_solver
266
+ sage: p = get_solver(solver='CVXOPT')
267
+ sage: p.add_variable()
268
+ 0
269
+ sage: p.objective_coefficient(0)
270
+ 0.0
271
+ sage: p.objective_coefficient(0,2)
272
+ sage: p.objective_coefficient(0)
273
+ 2.0
274
+ """
275
+ if coeff is not None:
276
+ self.objective_function[variable] = float(coeff)
277
+ else:
278
+ return self.objective_function[variable]
279
+
280
+ cpdef set_objective(self, list coeff, d=0.0):
281
+ """
282
+ Set the objective function.
283
+
284
+ INPUT:
285
+
286
+ - ``coeff`` -- list of real values, whose i-th element is the
287
+ coefficient of the i-th variable in the objective function
288
+
289
+ - ``d`` -- double; the constant term in the linear function (set to `0`
290
+ by default)
291
+
292
+ EXAMPLES::
293
+
294
+ sage: from sage.numerical.backends.generic_backend import get_solver
295
+ sage: p = get_solver(solver='CVXOPT')
296
+ sage: p.add_variables(5)
297
+ 4
298
+ sage: p.set_objective([1, 1, 2, 1, 3])
299
+ sage: [p.objective_coefficient(x) for x in range(5)]
300
+ [1, 1, 2, 1, 3]
301
+ """
302
+ for i in range(len(coeff)):
303
+ self.objective_function[i] = coeff[i]
304
+ self.obj_constant_term = d
305
+
306
+ cpdef set_verbosity(self, int level):
307
+ """
308
+ Do not apply for the cvxopt solver.
309
+ """
310
+ pass
311
+
312
+ cpdef add_col(self, indices, coeffs):
313
+ """
314
+ Add a column.
315
+
316
+ INPUT:
317
+
318
+ - ``indices`` -- list of integers; this list contains the
319
+ indices of the constraints in which the variable's
320
+ coefficient is nonzero
321
+
322
+ - ``coeffs`` -- list of real values; associates a coefficient
323
+ to the variable in each of the constraints in which it
324
+ appears. Namely, the i-th entry of ``coeffs`` corresponds to
325
+ the coefficient of the variable in the constraint
326
+ represented by the i-th entry in ``indices``.
327
+
328
+ .. NOTE::
329
+
330
+ ``indices`` and ``coeffs`` are expected to be of the same
331
+ length.
332
+
333
+ EXAMPLES::
334
+
335
+ sage: from sage.numerical.backends.generic_backend import get_solver
336
+ sage: p = get_solver(solver='CVXOPT')
337
+ sage: p.ncols()
338
+ 0
339
+ sage: p.nrows()
340
+ 0
341
+ sage: p.add_linear_constraints(5, 0, None)
342
+ sage: p.add_col(range(5), range(5))
343
+ sage: p.nrows()
344
+ 5
345
+ """
346
+ column = []
347
+ for _ in indices:
348
+ column.append(0.0)
349
+
350
+ for idx, ind in enumerate(indices):
351
+ column[ind] = coeffs[idx]
352
+
353
+ self.G_matrix.append(column)
354
+
355
+ self.col_lower_bound.append(None)
356
+ self.col_upper_bound.append(None)
357
+ self.objective_function.append(0)
358
+ self.col_name_var.append(None)
359
+
360
+ cpdef add_linear_constraint(self, coefficients, lower_bound, upper_bound, name=None):
361
+ """
362
+ Add a linear constraint.
363
+
364
+ INPUT:
365
+
366
+ - ``coefficients`` an iterable with ``(c,v)`` pairs where ``c``
367
+ is a variable index (integer) and ``v`` is a value (real
368
+ value).
369
+
370
+ - ``lower_bound`` -- a lower bound, either a real value or ``None``
371
+
372
+ - ``upper_bound`` -- an upper bound, either a real value or ``None``
373
+
374
+ - ``name`` -- an optional name for this row (default: ``None``)
375
+
376
+ EXAMPLES::
377
+
378
+ sage: from sage.numerical.backends.generic_backend import get_solver
379
+ sage: p = get_solver(solver='CVXOPT')
380
+ sage: p.add_variables(5)
381
+ 4
382
+ sage: p.add_linear_constraint(zip(range(5), range(5)), 2.0, 2.0)
383
+ sage: p.row(0)
384
+ ([1, 2, 3, 4], [1, 2, 3, 4])
385
+ sage: p.row_bounds(0)
386
+ (2.00000000000000, 2.00000000000000)
387
+ sage: p.add_linear_constraint(zip(range(5), range(5)), 1.0, 1.0, name='foo')
388
+ sage: p.row_name(-1)
389
+ 'foo'
390
+ """
391
+ coefficients = list(coefficients)
392
+ for c in coefficients:
393
+ while c[0] > len(self.G_matrix) - 1:
394
+ self.add_variable()
395
+ for i in range(len(self.G_matrix)):
396
+ self.G_matrix[i].append(0.0)
397
+ for c in coefficients:
398
+ self.G_matrix[c[0]][-1] = c[1]
399
+
400
+ self.row_lower_bound.append(lower_bound)
401
+ self.row_upper_bound.append(upper_bound)
402
+ self.row_name_var.append(name)
403
+
404
+ cpdef int solve(self) except -1:
405
+ """
406
+ Solve the problem.
407
+
408
+ .. NOTE::
409
+
410
+ This method raises ``MIPSolverException`` exceptions when
411
+ the solution cannot be computed for any reason (none
412
+ exists, or the LP solver was not able to find it, etc...)
413
+
414
+ EXAMPLES::
415
+
416
+ sage: p = MixedIntegerLinearProgram(solver='cvxopt', maximization=False)
417
+ sage: x = p.new_variable(nonnegative=True)
418
+ sage: p.set_objective(-4*x[0] - 5*x[1])
419
+ sage: p.add_constraint(2*x[0] + x[1] <= 3)
420
+ sage: p.add_constraint(2*x[1] + x[0] <= 3)
421
+ sage: N(p.solve(), digits=2)
422
+ -9.0
423
+
424
+ sage: p = MixedIntegerLinearProgram(solver='cvxopt', maximization=False)
425
+ sage: x = p.new_variable(nonnegative=True)
426
+ sage: p.set_objective(x[0] + 2*x[1])
427
+ sage: p.add_constraint(-5*x[0] + x[1] <= 7)
428
+ sage: p.add_constraint(-5*x[0] + x[1] >= 7)
429
+ sage: p.add_constraint(x[0] + x[1] >= 26)
430
+ sage: p.add_constraint(x[0] >= 3)
431
+ sage: p.add_constraint(x[1] >= 4)
432
+ sage: N(p.solve(), digits=4)
433
+ 48.83
434
+
435
+ sage: p = MixedIntegerLinearProgram(solver='cvxopt')
436
+ sage: x = p.new_variable(nonnegative=True)
437
+ sage: p.set_objective(x[0] + x[1] + 3*x[2])
438
+ sage: p.solver_parameter("show_progress",True)
439
+ sage: p.add_constraint(x[0] + 2*x[1] <= 4)
440
+ sage: p.add_constraint(5*x[2] - x[1] <= 8)
441
+ sage: N(p.solve(), digits=2)
442
+ pcost dcost gap pres dres k/t
443
+ ...
444
+ 8.8
445
+
446
+ When the optimal solution is not unique, CVXOPT as an interior point solver
447
+ gives a different type of solution compared to the solvers that use the
448
+ simplex method.
449
+
450
+ In the following example, the top face of the cube is optimal, and CVXOPT
451
+ gives the center point of the top face, whereas the other tested solvers
452
+ return a vertex::
453
+
454
+ sage: c = MixedIntegerLinearProgram(solver='cvxopt')
455
+ sage: p = MixedIntegerLinearProgram(solver='ppl')
456
+ sage: g = MixedIntegerLinearProgram()
457
+ sage: xc = c.new_variable(nonnegative=True)
458
+ sage: xp = p.new_variable(nonnegative=True)
459
+ sage: xg = g.new_variable(nonnegative=True)
460
+ sage: c.set_objective(xc[2])
461
+ sage: p.set_objective(xp[2])
462
+ sage: g.set_objective(xg[2])
463
+ sage: c.add_constraint(xc[0] <= 100)
464
+ sage: c.add_constraint(xc[1] <= 100)
465
+ sage: c.add_constraint(xc[2] <= 100)
466
+ sage: p.add_constraint(xp[0] <= 100)
467
+ sage: p.add_constraint(xp[1] <= 100)
468
+ sage: p.add_constraint(xp[2] <= 100)
469
+ sage: g.add_constraint(xg[0] <= 100)
470
+ sage: g.add_constraint(xg[1] <= 100)
471
+ sage: g.add_constraint(xg[2] <= 100)
472
+ sage: N(c.solve(), digits=4)
473
+ 100.0
474
+ sage: N(c.get_values(xc[0]), digits=3)
475
+ 50.0
476
+ sage: N(c.get_values(xc[1]), digits=3)
477
+ 50.0
478
+ sage: N(c.get_values(xc[2]), digits=4)
479
+ 100.0
480
+ sage: N(p.solve(), digits=4)
481
+ 100.0
482
+ sage: N(p.get_values(xp[0]), 2)
483
+ 0.00
484
+ sage: N(p.get_values(xp[1]), 2)
485
+ 0.00
486
+ sage: N(p.get_values(xp[2]), digits=4)
487
+ 100.0
488
+ sage: N(g.solve(), digits=4)
489
+ 100.0
490
+ sage: N(g.get_values(xg[0]), 2) # abstol 1e-15
491
+ 0.00
492
+ sage: N(g.get_values(xg[1]), 2) # abstol 1e-15
493
+ 0.00
494
+ sage: N(g.get_values(xg[2]), digits=4)
495
+ 100.0
496
+ """
497
+ from cvxopt import matrix, solvers
498
+ h = []
499
+
500
+ # for the equation bounds
501
+ for eq_index in range(self.nrows()):
502
+ h.append(self.row_upper_bound[eq_index])
503
+ # upper bound is already in G
504
+ if self.row_lower_bound[eq_index] is not None:
505
+ h.append(-1 * self.row_lower_bound[eq_index])
506
+ for cindex in range(len(self.G_matrix)):
507
+ if cindex == eq_index:
508
+ self.G_matrix[cindex].append(-1) # after multiplying the eq by -1
509
+ else:
510
+ self.G_matrix[cindex].append(0)
511
+
512
+ # for the upper bounds (if there are any)
513
+ for i in range(len(self.col_upper_bound)):
514
+ if self.col_upper_bound[i] is not None:
515
+ h.append(self.col_upper_bound[i])
516
+ for cindex in range(len(self.G_matrix)):
517
+ if cindex == i:
518
+ self.G_matrix[cindex].append(1)
519
+ else:
520
+ self.G_matrix[cindex].append(0)
521
+ if self.col_lower_bound[i] is not None:
522
+ h.append(self.col_lower_bound[i])
523
+ for cindex in range(len(self.G_matrix)):
524
+ if cindex == i:
525
+ self.G_matrix[cindex].append(-1) # after multiplying the eq by -1
526
+ else:
527
+ self.G_matrix[cindex].append(0)
528
+
529
+ G = []
530
+ for col in self.G_matrix:
531
+ tempcol = []
532
+ for i in range(len(col)):
533
+ tempcol.append( float(col[i]) )
534
+ G.append(tempcol)
535
+
536
+ G = matrix(G)
537
+
538
+ #cvxopt minimizes on default
539
+ if self.is_maximize:
540
+ c = [-1 * float(e) for e in self.objective_function]
541
+ else:
542
+ c = [float(e) for e in self.objective_function]
543
+ c = matrix(c)
544
+
545
+ h = [float(e) for e in h]
546
+ h = matrix(h)
547
+
548
+ #solvers comes from the cvxopt library
549
+ for k,v in self.param.iteritems():
550
+ solvers.options[k] = v
551
+ self.answer = solvers.lp(c,G,h)
552
+
553
+ #possible outcomes
554
+ if self.answer['status'] == 'optimized':
555
+ pass
556
+ elif self.answer['status'] == 'primal infeasible':
557
+ raise MIPSolverException("CVXOPT: primal infeasible")
558
+ elif self.answer['status'] == 'dual infeasible':
559
+ raise MIPSolverException("CVXOPT: dual infeasible")
560
+ elif self.answer['status'] == 'unknown':
561
+ raise MIPSolverException("CVXOPT: Terminated early due to numerical difficulties or because the maximum number of iterations was reached.")
562
+ return 0
563
+
564
+ cpdef get_objective_value(self):
565
+ """
566
+ Return the value of the objective function.
567
+
568
+ .. NOTE::
569
+
570
+ Behaviour is undefined unless ``solve`` has been called before.
571
+
572
+ EXAMPLES::
573
+
574
+ sage: from sage.numerical.backends.generic_backend import get_solver
575
+ sage: p = get_solver(solver='cvxopt')
576
+ sage: p.add_variables(2)
577
+ 1
578
+ sage: p.add_linear_constraint([(0,1), (1,2)], None, 3)
579
+ sage: p.set_objective([2, 5])
580
+ sage: p.solve()
581
+ 0
582
+ sage: N(p.get_objective_value(),4)
583
+ 7.5
584
+ sage: N(p.get_variable_value(0),4)
585
+ 3.6e-7
586
+ sage: N(p.get_variable_value(1),4)
587
+ 1.5
588
+ """
589
+ sum = self.obj_constant_term
590
+ i = 0
591
+ for v in self.objective_function:
592
+ sum += v * float(self.answer['x'][i])
593
+ i+=1
594
+ return sum
595
+
596
+ cpdef get_variable_value(self, int variable):
597
+ """
598
+ Return the value of a variable given by the solver.
599
+
600
+ .. NOTE::
601
+
602
+ Behaviour is undefined unless ``solve`` has been called before.
603
+
604
+ EXAMPLES::
605
+
606
+ sage: from sage.numerical.backends.generic_backend import get_solver
607
+ sage: p = get_solver(solver='CVXOPT')
608
+ sage: p.add_variables(2)
609
+ 1
610
+ sage: p.add_linear_constraint([(0,1), (1, 2)], None, 3)
611
+ sage: p.set_objective([2, 5])
612
+ sage: p.solve()
613
+ 0
614
+ sage: N(p.get_objective_value(),4)
615
+ 7.5
616
+ sage: N(p.get_variable_value(0),4)
617
+ 3.6e-7
618
+ sage: N(p.get_variable_value(1),4)
619
+ 1.5
620
+ """
621
+ return self.answer['x'][variable]
622
+
623
+ cpdef int ncols(self) noexcept:
624
+ """
625
+ Return the number of columns/variables.
626
+
627
+ EXAMPLES::
628
+
629
+ sage: from sage.numerical.backends.generic_backend import get_solver
630
+ sage: p = get_solver(solver='CVXOPT')
631
+ sage: p.ncols()
632
+ 0
633
+ sage: p.add_variables(2)
634
+ 1
635
+ sage: p.ncols()
636
+ 2
637
+ """
638
+
639
+ return len(self.objective_function)
640
+
641
+ cpdef int nrows(self) noexcept:
642
+ """
643
+ Return the number of rows/constraints.
644
+
645
+ EXAMPLES::
646
+
647
+ sage: from sage.numerical.backends.generic_backend import get_solver
648
+ sage: p = get_solver(solver='CVXOPT')
649
+ sage: p.nrows()
650
+ 0
651
+ sage: p.add_variables(5)
652
+ 4
653
+ sage: p.add_linear_constraints(2, 2.0, None)
654
+ sage: p.nrows()
655
+ 2
656
+ """
657
+ return len(self.row_upper_bound)
658
+
659
+ cpdef bint is_maximization(self) noexcept:
660
+ """
661
+ Test whether the problem is a maximization
662
+
663
+ EXAMPLES::
664
+
665
+ sage: from sage.numerical.backends.generic_backend import get_solver
666
+ sage: p = get_solver(solver='CVXOPT')
667
+ sage: p.is_maximization()
668
+ True
669
+ sage: p.set_sense(-1)
670
+ sage: p.is_maximization()
671
+ False
672
+ """
673
+ if self.is_maximize == 1:
674
+ return 1
675
+ else:
676
+ return 0
677
+
678
+ cpdef problem_name(self, name=None):
679
+ """
680
+ Return or define the problem's name.
681
+
682
+ INPUT:
683
+
684
+ - ``name`` -- string; the problem's name. When set to
685
+ ``None`` (default), the method returns the problem's name.
686
+
687
+ EXAMPLES::
688
+
689
+ sage: from sage.numerical.backends.generic_backend import get_solver
690
+ sage: p = get_solver(solver='CVXOPT')
691
+ sage: p.problem_name()
692
+ ''
693
+ sage: p.problem_name("There once was a french fry")
694
+ sage: print(p.problem_name())
695
+ There once was a french fry
696
+ """
697
+ if name is None:
698
+ return self.prob_name
699
+ self.prob_name = name
700
+
701
+ cpdef row(self, int i):
702
+ """
703
+ Return a row.
704
+
705
+ INPUT:
706
+
707
+ - ``index`` -- integer; the constraint's id
708
+
709
+ OUTPUT:
710
+
711
+ A pair ``(indices, coeffs)`` where ``indices`` lists the
712
+ entries whose coefficient is nonzero, and to which ``coeffs``
713
+ associates their coefficient on the model of the
714
+ ``add_linear_constraint`` method.
715
+
716
+ EXAMPLES::
717
+
718
+ sage: from sage.numerical.backends.generic_backend import get_solver
719
+ sage: p = get_solver(solver='CVXOPT')
720
+ sage: p.add_variables(5)
721
+ 4
722
+ sage: p.add_linear_constraint(list(zip(range(5), range(5))), 2, 2)
723
+ sage: p.row(0)
724
+ ([1, 2, 3, 4], [1, 2, 3, 4])
725
+ sage: p.row_bounds(0)
726
+ (2, 2)
727
+ """
728
+ coeff = []
729
+ idx = []
730
+ index = 0
731
+ for col in self.G_matrix:
732
+ if col[i] != 0:
733
+ idx.append(index)
734
+ coeff.append(col[i])
735
+ index += 1
736
+ return (idx, coeff)
737
+
738
+ cpdef row_bounds(self, int index):
739
+ """
740
+ Return the bounds of a specific constraint.
741
+
742
+ INPUT:
743
+
744
+ - ``index`` -- integer; the constraint's id
745
+
746
+ OUTPUT:
747
+
748
+ A pair ``(lower_bound, upper_bound)``. Each of them can be set
749
+ to ``None`` if the constraint is not bounded in the
750
+ corresponding direction, and is a real value otherwise.
751
+
752
+ EXAMPLES::
753
+
754
+ sage: from sage.numerical.backends.generic_backend import get_solver
755
+ sage: p = get_solver(solver='CVXOPT')
756
+ sage: p.add_variables(5)
757
+ 4
758
+ sage: p.add_linear_constraint(list(zip(range(5), range(5))), 2, 2)
759
+ sage: p.row(0)
760
+ ([1, 2, 3, 4], [1, 2, 3, 4])
761
+ sage: p.row_bounds(0)
762
+ (2, 2)
763
+ """
764
+ return (self.row_lower_bound[index], self.row_upper_bound[index])
765
+
766
+ cpdef col_bounds(self, int index):
767
+ """
768
+ Return the bounds of a specific variable.
769
+
770
+ INPUT:
771
+
772
+ - ``index`` -- integer; the variable's id
773
+
774
+ OUTPUT:
775
+
776
+ A pair ``(lower_bound, upper_bound)``. Each of them can be set
777
+ to ``None`` if the variable is not bounded in the
778
+ corresponding direction, and is a real value otherwise.
779
+
780
+ EXAMPLES::
781
+
782
+ sage: from sage.numerical.backends.generic_backend import get_solver
783
+ sage: p = get_solver(solver='CVXOPT')
784
+ sage: p.add_variable()
785
+ 0
786
+ sage: p.col_bounds(0)
787
+ (0.0, None)
788
+ sage: p.variable_upper_bound(0, 5)
789
+ sage: p.col_bounds(0)
790
+ (0.0, 5)
791
+ """
792
+ return (self.col_lower_bound[index], self.col_upper_bound[index])
793
+
794
+ cpdef bint is_variable_binary(self, int index) noexcept:
795
+ """
796
+ Test whether the given variable is of binary type.
797
+ CVXOPT does not allow integer variables, so this is a bit moot.
798
+
799
+ INPUT:
800
+
801
+ - ``index`` -- integer; the variable's id
802
+
803
+ EXAMPLES::
804
+
805
+ sage: from sage.numerical.backends.generic_backend import get_solver
806
+ sage: p = get_solver(solver='CVXOPT')
807
+ sage: p.ncols()
808
+ 0
809
+ sage: p.add_variable()
810
+ 0
811
+ sage: p.set_variable_type(0,0)
812
+ Traceback (most recent call last):
813
+ ...
814
+ ValueError: ...
815
+ sage: p.is_variable_binary(0)
816
+ False
817
+ """
818
+ return False
819
+
820
+ cpdef bint is_variable_integer(self, int index) noexcept:
821
+ """
822
+ Test whether the given variable is of integer type.
823
+ CVXOPT does not allow integer variables, so this is a bit moot.
824
+
825
+ INPUT:
826
+
827
+ - ``index`` -- integer; the variable's id
828
+
829
+ EXAMPLES::
830
+
831
+ sage: from sage.numerical.backends.generic_backend import get_solver
832
+ sage: p = get_solver(solver='CVXOPT')
833
+ sage: p.ncols()
834
+ 0
835
+ sage: p.add_variable()
836
+ 0
837
+ sage: p.set_variable_type(0,-1)
838
+ sage: p.set_variable_type(0,1)
839
+ Traceback (most recent call last):
840
+ ...
841
+ ValueError: ...
842
+ sage: p.is_variable_integer(0)
843
+ False
844
+ """
845
+ return False
846
+
847
+ cpdef bint is_variable_continuous(self, int index) noexcept:
848
+ """
849
+ Test whether the given variable is of continuous/real type.
850
+ CVXOPT does not allow integer variables, so this is a bit moot.
851
+
852
+ INPUT:
853
+
854
+ - ``index`` -- integer; the variable's id
855
+
856
+ EXAMPLES::
857
+
858
+ sage: from sage.numerical.backends.generic_backend import get_solver
859
+ sage: p = get_solver(solver='CVXOPT')
860
+ sage: p.ncols()
861
+ 0
862
+ sage: p.add_variable()
863
+ 0
864
+ sage: p.is_variable_continuous(0)
865
+ True
866
+ sage: p.set_variable_type(0,1)
867
+ Traceback (most recent call last):
868
+ ...
869
+ ValueError: ...
870
+ sage: p.is_variable_continuous(0)
871
+ True
872
+ """
873
+ return True
874
+
875
+ cpdef row_name(self, int index):
876
+ """
877
+ Return the ``index``-th row name.
878
+
879
+ INPUT:
880
+
881
+ - ``index`` -- integer; the row's id
882
+
883
+ EXAMPLES::
884
+
885
+ sage: from sage.numerical.backends.generic_backend import get_solver
886
+ sage: p = get_solver(solver='CVXOPT')
887
+ sage: p.add_linear_constraints(1, 2, None, names=["Empty constraint 1"])
888
+ sage: p.row_name(0)
889
+ 'Empty constraint 1'
890
+ """
891
+ if self.row_name_var[index] is not None:
892
+ return self.row_name_var[index]
893
+ return "constraint_" + repr(index)
894
+
895
+ cpdef col_name(self, int index):
896
+ """
897
+ Return the ``index``-th col name.
898
+
899
+ INPUT:
900
+
901
+ - ``index`` -- integer; the col's id
902
+
903
+ - ``name`` -- (``char *``) its name; when set to ``NULL``
904
+ (default), the method returns the current name
905
+
906
+ EXAMPLES::
907
+
908
+ sage: from sage.numerical.backends.generic_backend import get_solver
909
+ sage: p = get_solver(solver='CVXOPT')
910
+ sage: p.add_variable(name="I am a variable")
911
+ 0
912
+ sage: p.col_name(0)
913
+ 'I am a variable'
914
+ """
915
+ if self.col_name_var[index] is not None:
916
+ return self.col_name_var[index]
917
+ return "x_" + repr(index)
918
+
919
+ cpdef variable_upper_bound(self, int index, value=False):
920
+ """
921
+ Return or define the upper bound on a variable.
922
+
923
+ INPUT:
924
+
925
+ - ``index`` -- integer; the variable's id
926
+
927
+ - ``value`` -- real value, or ``None`` to mean that the
928
+ variable has not upper bound. When set to ``False``
929
+ (default), the method returns the current value.
930
+
931
+ EXAMPLES::
932
+
933
+ sage: from sage.numerical.backends.generic_backend import get_solver
934
+ sage: p = get_solver(solver='CVXOPT')
935
+ sage: p.add_variable()
936
+ 0
937
+ sage: p.col_bounds(0)
938
+ (0.0, None)
939
+ sage: p.variable_upper_bound(0, 5)
940
+ sage: p.col_bounds(0)
941
+ (0.0, 5)
942
+ """
943
+ if value is not False:
944
+ self.col_upper_bound[index] = value
945
+ else:
946
+ return self.col_upper_bound[index]
947
+
948
+ cpdef variable_lower_bound(self, int index, value=False):
949
+ """
950
+ Return or define the lower bound on a variable.
951
+
952
+ INPUT:
953
+
954
+ - ``index`` -- integer; the variable's id
955
+
956
+ - ``value`` -- real value, or ``None`` to mean that the
957
+ variable has not lower bound. When set to ``False``
958
+ (default), the method returns the current value.
959
+
960
+ EXAMPLES::
961
+
962
+ sage: from sage.numerical.backends.generic_backend import get_solver
963
+ sage: p = get_solver(solver='CVXOPT')
964
+ sage: p.add_variable()
965
+ 0
966
+ sage: p.col_bounds(0)
967
+ (0.0, None)
968
+ sage: p.variable_lower_bound(0, 5)
969
+ sage: p.col_bounds(0)
970
+ (5, None)
971
+ """
972
+ if value is not False:
973
+ self.col_lower_bound[index] = value
974
+ else:
975
+ return self.col_lower_bound[index]
976
+
977
+ cpdef solver_parameter(self, name, value=None):
978
+ """
979
+ Return or define a solver parameter.
980
+
981
+ INPUT:
982
+
983
+ - ``name`` -- string; the parameter
984
+
985
+ - ``value`` -- the parameter's value if it is to be defined,
986
+ or ``None`` (default) to obtain its current value
987
+
988
+ .. NOTE::
989
+
990
+ The list of available parameters is available at
991
+ :meth:`~sage.numerical.mip.MixedIntegerLinearProgram.solver_parameter`.
992
+
993
+ EXAMPLES::
994
+
995
+ sage: from sage.numerical.backends.generic_backend import get_solver
996
+ sage: p = get_solver(solver='CVXOPT')
997
+ sage: p.solver_parameter("show_progress")
998
+ False
999
+ sage: p.solver_parameter("show_progress", True)
1000
+ sage: p.solver_parameter("show_progress")
1001
+ True
1002
+ """
1003
+ if value is None:
1004
+ return self.param[name]
1005
+ else:
1006
+ self.param[name] = value