scs 3.2.8__cp314-cp314t-macosx_10_13_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.
- scs/__init__.py +197 -0
- scs/_scs_direct.cpython-314t-darwin.so +0 -0
- scs/_scs_indirect.cpython-314t-darwin.so +0 -0
- scs-3.2.8.dist-info/LICENSE +21 -0
- scs-3.2.8.dist-info/METADATA +54 -0
- scs-3.2.8.dist-info/RECORD +7 -0
- scs-3.2.8.dist-info/WHEEL +6 -0
scs/__init__.py
ADDED
@@ -0,0 +1,197 @@
|
|
1
|
+
#!/usr/bin/env python
|
2
|
+
from warnings import warn
|
3
|
+
from scipy import sparse
|
4
|
+
from scs import _scs_direct
|
5
|
+
|
6
|
+
__version__ = _scs_direct.version()
|
7
|
+
__sizeof_int__ = _scs_direct.sizeof_int()
|
8
|
+
__sizeof_float__ = _scs_direct.sizeof_float()
|
9
|
+
|
10
|
+
_USE_INDIRECT_DEFAULT = False
|
11
|
+
|
12
|
+
|
13
|
+
# SCS return integers correspond to one of these flags:
|
14
|
+
# (copied from scs/include/glbopts.h)
|
15
|
+
INFEASIBLE_INACCURATE = -7 # SCS best guess infeasible
|
16
|
+
UNBOUNDED_INACCURATE = -6 # SCS best guess unbounded
|
17
|
+
SIGINT = -5 # interrupted by sig int
|
18
|
+
FAILED = -4 # SCS failed
|
19
|
+
INDETERMINATE = -3 # indeterminate (norm too small)
|
20
|
+
INFEASIBLE = -2 # primal infeasible, dual unbounded
|
21
|
+
UNBOUNDED = -1 # primal unbounded, dual infeasible
|
22
|
+
UNFINISHED = 0 # never returned, used as placeholder
|
23
|
+
SOLVED = 1 # problem solved to desired accuracy
|
24
|
+
SOLVED_INACCURATE = 2 # SCS best guess solved
|
25
|
+
|
26
|
+
|
27
|
+
# Choose which SCS to import based on settings.
|
28
|
+
def _select_scs_module(stgs):
|
29
|
+
|
30
|
+
if stgs.pop("gpu", False): # False by default
|
31
|
+
if not stgs.pop("use_indirect", _USE_INDIRECT_DEFAULT):
|
32
|
+
raise NotImplementedError(
|
33
|
+
"For the GPU direct solver, pass `use_indirect=False cudss=True`.")
|
34
|
+
from scs import _scs_gpu
|
35
|
+
|
36
|
+
return _scs_gpu
|
37
|
+
|
38
|
+
if stgs.pop("mkl", False): # False by default
|
39
|
+
if stgs.pop("use_indirect", False):
|
40
|
+
raise NotImplementedError(
|
41
|
+
"MKL indirect solver not yet available, pass `use_indirect=False`."
|
42
|
+
)
|
43
|
+
from scs import _scs_mkl
|
44
|
+
|
45
|
+
return _scs_mkl
|
46
|
+
|
47
|
+
if stgs.pop("cudss", False): # False by default
|
48
|
+
if stgs.pop("use_indirect", False):
|
49
|
+
raise NotImplementedError(
|
50
|
+
"cuDSS is a direct solver, pass `use_indirect=False`."
|
51
|
+
)
|
52
|
+
from scs import _scs_cudss
|
53
|
+
|
54
|
+
return _scs_cudss
|
55
|
+
|
56
|
+
if stgs.pop("use_indirect", _USE_INDIRECT_DEFAULT):
|
57
|
+
from scs import _scs_indirect
|
58
|
+
|
59
|
+
return _scs_indirect
|
60
|
+
|
61
|
+
return _scs_direct
|
62
|
+
|
63
|
+
|
64
|
+
class SCS(object):
|
65
|
+
def __init__(self, data, cone, **settings):
|
66
|
+
"""Initialize the SCS solver.
|
67
|
+
|
68
|
+
@param data Dictionary containing keys `P`, `A`, `b`, `c`.
|
69
|
+
@param cone Dictionary containing cone information.
|
70
|
+
@param settings Settings as kwargs, see docs.
|
71
|
+
|
72
|
+
"""
|
73
|
+
self._settings = settings
|
74
|
+
if not data or not cone:
|
75
|
+
raise ValueError("Missing data or cone information")
|
76
|
+
|
77
|
+
if "b" not in data or "c" not in data:
|
78
|
+
raise ValueError("Missing one of b, c from data dictionary")
|
79
|
+
if "A" not in data:
|
80
|
+
raise ValueError("Missing A from data dictionary")
|
81
|
+
|
82
|
+
A = data["A"]
|
83
|
+
b = data["b"]
|
84
|
+
c = data["c"]
|
85
|
+
|
86
|
+
if A is None or b is None or c is None:
|
87
|
+
raise ValueError("Incomplete data specification")
|
88
|
+
|
89
|
+
if not sparse.issparse(A):
|
90
|
+
raise TypeError("A is required to be a sparse matrix")
|
91
|
+
if not A.format == "csc":
|
92
|
+
warn(
|
93
|
+
"Converting A to a CSC (compressed sparse column) matrix;"
|
94
|
+
" may take a while."
|
95
|
+
)
|
96
|
+
A = A.tocsc()
|
97
|
+
|
98
|
+
if sparse.issparse(b):
|
99
|
+
b = b.todense()
|
100
|
+
|
101
|
+
if sparse.issparse(c):
|
102
|
+
c = c.todense()
|
103
|
+
|
104
|
+
m = len(b)
|
105
|
+
n = len(c)
|
106
|
+
|
107
|
+
if not A.has_sorted_indices:
|
108
|
+
A.sort_indices()
|
109
|
+
Adata, Aindices, Acolptr = A.data, A.indices, A.indptr
|
110
|
+
if A.shape != (m, n):
|
111
|
+
raise ValueError("A shape not compatible with b,c")
|
112
|
+
|
113
|
+
Pdata, Pindices, Pcolptr = None, None, None
|
114
|
+
if "P" in data:
|
115
|
+
P = data["P"]
|
116
|
+
if P is not None:
|
117
|
+
if not sparse.issparse(P):
|
118
|
+
raise TypeError("P is required to be a sparse matrix")
|
119
|
+
if P.shape != (n, n):
|
120
|
+
raise ValueError("P shape not compatible with A,b,c")
|
121
|
+
if not P.format == "csc":
|
122
|
+
warn(
|
123
|
+
"Converting P to a CSC (compressed sparse column) "
|
124
|
+
"matrix; may take a while."
|
125
|
+
)
|
126
|
+
P = P.tocsc()
|
127
|
+
# extract upper triangular component only
|
128
|
+
if sparse.tril(P, -1).data.size > 0:
|
129
|
+
P = sparse.triu(P, format="csc")
|
130
|
+
if not P.has_sorted_indices:
|
131
|
+
P.sort_indices()
|
132
|
+
Pdata, Pindices, Pcolptr = P.data, P.indices, P.indptr
|
133
|
+
|
134
|
+
# Which scs are we using (scs_direct, scs_indirect, ...)
|
135
|
+
_scs = _select_scs_module(self._settings)
|
136
|
+
|
137
|
+
# Initialize solver
|
138
|
+
self._solver = _scs.SCS(
|
139
|
+
(m, n),
|
140
|
+
Adata,
|
141
|
+
Aindices,
|
142
|
+
Acolptr,
|
143
|
+
Pdata,
|
144
|
+
Pindices,
|
145
|
+
Pcolptr,
|
146
|
+
b,
|
147
|
+
c,
|
148
|
+
cone,
|
149
|
+
**self._settings
|
150
|
+
)
|
151
|
+
|
152
|
+
def solve(self, warm_start=True, x=None, y=None, s=None):
|
153
|
+
"""Solve the optimization problem.
|
154
|
+
|
155
|
+
@param warm_start Whether to warm-start. By default the solution of
|
156
|
+
the previous problem is used as the warm-start. The
|
157
|
+
warm-start can be overriden to another value by
|
158
|
+
passing `x`, `y`, `s` args.
|
159
|
+
@param x Primal warm-start override.
|
160
|
+
@param y Dual warm-start override.
|
161
|
+
@param s Slack warm-start override.
|
162
|
+
|
163
|
+
@return dictionary with solution with keys:
|
164
|
+
'x' - primal solution
|
165
|
+
's' - primal slack solution
|
166
|
+
'y' - dual solution
|
167
|
+
'info' - information dictionary (see docs)
|
168
|
+
"""
|
169
|
+
return self._solver.solve(warm_start, x, y, s)
|
170
|
+
|
171
|
+
def update(self, b=None, c=None):
|
172
|
+
"""Update the `b` vector, `c` vector, or both, before another solve.
|
173
|
+
|
174
|
+
After a solve we can reuse the SCS workspace in another solve if the
|
175
|
+
only problem data that has changed are the `b` and `c` vectors.
|
176
|
+
|
177
|
+
@param b New `b` vector.
|
178
|
+
@param c New `c` vector.
|
179
|
+
|
180
|
+
"""
|
181
|
+
self._solver.update(b, c)
|
182
|
+
|
183
|
+
|
184
|
+
# Backwards compatible helper function that simply calls the main API.
|
185
|
+
def solve(data, cone, **settings):
|
186
|
+
solver = SCS(data, cone, **settings)
|
187
|
+
|
188
|
+
# Hack out the warm start data from old API
|
189
|
+
x = y = s = None
|
190
|
+
if "x" in data:
|
191
|
+
x = data["x"]
|
192
|
+
if "y" in data:
|
193
|
+
y = data["y"]
|
194
|
+
if "s" in data:
|
195
|
+
s = data["s"]
|
196
|
+
|
197
|
+
return solver.solve(warm_start=True, x=x, y=y, s=s)
|
Binary file
|
Binary file
|
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 Brendan O'Donoghue
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -0,0 +1,54 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: scs
|
3
|
+
Version: 3.2.8
|
4
|
+
Summary: Splitting conic solver
|
5
|
+
Author-Email: Brendan O'Donoghue <bodonoghue85@gmail.com>
|
6
|
+
License: MIT License
|
7
|
+
|
8
|
+
Copyright (c) 2017 Brendan O'Donoghue
|
9
|
+
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
12
|
+
in the Software without restriction, including without limitation the rights
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
15
|
+
furnished to do so, subject to the following conditions:
|
16
|
+
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
18
|
+
copies or substantial portions of the Software.
|
19
|
+
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
26
|
+
SOFTWARE.
|
27
|
+
|
28
|
+
Classifier: License :: OSI Approved :: MIT License
|
29
|
+
Classifier: Programming Language :: C
|
30
|
+
Classifier: Programming Language :: Python
|
31
|
+
Classifier: Programming Language :: Python :: 3
|
32
|
+
Classifier: Programming Language :: Python :: 3.11
|
33
|
+
Classifier: Programming Language :: Python :: 3.12
|
34
|
+
Classifier: Programming Language :: Python :: 3.13
|
35
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
36
|
+
Classifier: Programming Language :: Python :: Implementation :: CPython
|
37
|
+
Classifier: Operating System :: Microsoft :: Windows
|
38
|
+
Classifier: Operating System :: POSIX
|
39
|
+
Classifier: Operating System :: Unix
|
40
|
+
Classifier: Operating System :: MacOS
|
41
|
+
Requires-Python: >=3.9
|
42
|
+
Requires-Dist: numpy
|
43
|
+
Requires-Dist: scipy
|
44
|
+
Description-Content-Type: text/markdown
|
45
|
+
|
46
|
+
scs-python
|
47
|
+
===
|
48
|
+
|
49
|
+
[](https://github.com/bodono/scs-python/actions/workflows/build.yml)
|
50
|
+
[](https://www.cvxgrp.org/scs/)
|
51
|
+
[](https://pepy.tech/project/scs)
|
52
|
+
|
53
|
+
Python interface for [SCS](https://github.com/cvxgrp/scs) 3.0.0 and higher.
|
54
|
+
The full documentation is available [here](https://www.cvxgrp.org/scs/).
|
@@ -0,0 +1,7 @@
|
|
1
|
+
scs/_scs_indirect.cpython-314t-darwin.so,sha256=4XQENbiI3odF8ZVBbLHYDzoFnfr4pJek6RiY8iNiDqg,123432
|
2
|
+
scs/_scs_direct.cpython-314t-darwin.so,sha256=qKinC0w0RfMyPSdi6PsgSRA-8ZjJN_6hRkzuvwrLeWo,141008
|
3
|
+
scs/__init__.py,sha256=96fIOXkd0xJ5mU4-ild1Km5__fJb1n41NxvRRQdBBpE,6440
|
4
|
+
scs-3.2.8.dist-info/RECORD,,
|
5
|
+
scs-3.2.8.dist-info/LICENSE,sha256=lxIl5g3kUJCLfZjb72Z7K6XviabPAckIClya6BP-0Bg,1075
|
6
|
+
scs-3.2.8.dist-info/WHEEL,sha256=RlC2yqNddCeqlxEUoxUHmvBwVbaXPQ3TgcUqGMBCeFE,125
|
7
|
+
scs-3.2.8.dist-info/METADATA,sha256=NXOnuqeyO5Kl7oCCTUjivQngCggQqXZN25VJyCSVxGU,2806
|