sdpa-python 0.2.2__cp313-cp313-win_amd64.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.
- sdpa_python-0.2.2.dist-info/LICENSE +339 -0
- sdpa_python-0.2.2.dist-info/METADATA +69 -0
- sdpa_python-0.2.2.dist-info/RECORD +24 -0
- sdpa_python-0.2.2.dist-info/WHEEL +5 -0
- sdpa_python-0.2.2.dist-info/top_level.txt +1 -0
- sdpap/__init__.py +28 -0
- sdpap/convert.py +348 -0
- sdpap/fileio.py +836 -0
- sdpap/fvelim/__init__.py +24 -0
- sdpap/fvelim/fvelim.py +256 -0
- sdpap/fvelim/fvelimext.cp313-win_amd64.pyd +0 -0
- sdpap/matdata.py +80 -0
- sdpap/param.py +366 -0
- sdpap/sdpacall/__init__.py +24 -0
- sdpap/sdpacall/sdpa.cp313-win_amd64.pyd +0 -0
- sdpap/sdpacall/sdpacall.py +71 -0
- sdpap/sdpap.py +450 -0
- sdpap/sdpaputils.py +140 -0
- sdpap/spcolo/__init__.py +26 -0
- sdpap/spcolo/asputils.py +182 -0
- sdpap/spcolo/clique.py +68 -0
- sdpap/spcolo/spcolo.py +356 -0
- sdpap/spcolo/spcoloext.cp313-win_amd64.pyd +0 -0
- sdpap/symcone.py +157 -0
sdpap/param.py
ADDED
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
"""
|
|
3
|
+
SDPA solver parameters
|
|
4
|
+
This file is a component of SDPAP
|
|
5
|
+
Copyright (C) 2010-2022 SDPA Project
|
|
6
|
+
|
|
7
|
+
This program is free software; you can redistribute it and/or modify
|
|
8
|
+
it under the terms of the GNU General Public License as published by
|
|
9
|
+
the Free Software Foundation; either version 2 of the License, or
|
|
10
|
+
(at your option) any later version.
|
|
11
|
+
|
|
12
|
+
This program is distributed in the hope that it will be useful,
|
|
13
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
GNU General Public License for more details.
|
|
16
|
+
|
|
17
|
+
You should have received a copy of the GNU General Public License along
|
|
18
|
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
19
|
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20
|
+
|
|
21
|
+
December 2010: Originally written by Kenta Kato
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
__all__ = ['param']
|
|
25
|
+
|
|
26
|
+
import multiprocessing # for cpu count
|
|
27
|
+
|
|
28
|
+
def param(option=None, gmp_backend=False):
|
|
29
|
+
"""Create SDPAP parameters
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
option: A dictionary for parameters.
|
|
33
|
+
example:
|
|
34
|
+
{'epsilonStar':1.0e-7, 'epsilonDash':1.0e-5}
|
|
35
|
+
|
|
36
|
+
Returns:
|
|
37
|
+
option: A dictionary of parameters. Each field is as follows:
|
|
38
|
+
* maxIteration: The maximum number of iterations.
|
|
39
|
+
* epsilonStar: The accuracy of an approximate optimal solution
|
|
40
|
+
for primal and dual SDP.
|
|
41
|
+
* lambdaStar: An initial point.
|
|
42
|
+
* omegaStar: The search region for an optimal solution.
|
|
43
|
+
* lowerBound: Lower bound of the minimum objective value of
|
|
44
|
+
the primal SDP.
|
|
45
|
+
* upperBound: Upper bound of the maximum objective value of
|
|
46
|
+
the dual SDP
|
|
47
|
+
* betaStar: The parameter for controlling the search direction
|
|
48
|
+
if the current point is feasible.
|
|
49
|
+
* betaBar: The parameter for controlling the search direction
|
|
50
|
+
if the current point is infeasible.
|
|
51
|
+
* gammaStar: A reduction factor for the primal and dual step lengths.
|
|
52
|
+
* epsilonDash: The relative accuracy of an approximate optimal
|
|
53
|
+
solution between primal and dual SDP.
|
|
54
|
+
* isSymmetric: The flag for the checking the symmetricity of input
|
|
55
|
+
matrices. (False => no check, True => check)
|
|
56
|
+
* isDimacs: The flag to compute DIMACS ERROR
|
|
57
|
+
(False => no computation, True => computation)
|
|
58
|
+
* xPrint: default %+8.3e, NOPRINT skips printout
|
|
59
|
+
* yPrint: default %+8.3e, NOPRINT skips printout
|
|
60
|
+
* sPrint: default %+8.3e, NOPRINT skips printout
|
|
61
|
+
* infPrint: default %+10.16e, NOPRINT skips printout
|
|
62
|
+
* print: Destination of file output.
|
|
63
|
+
the default setting is stdout by 'display'.
|
|
64
|
+
If print is set 'no' or empty, no message is print out
|
|
65
|
+
* resultFile: Destination of detail file output
|
|
66
|
+
* sdpaResult: Destination of file output for SDPA result
|
|
67
|
+
* numThreads: Number of Threads for internal computation
|
|
68
|
+
* convMethod: Conversion method from CLP to LMI or EQ standard form
|
|
69
|
+
|
|
70
|
+
The following parameters are for Exploiting sparsity algorithm.
|
|
71
|
+
* domainMethod: Algorithm option for domain space. Parameter is:
|
|
72
|
+
'none': Exploiting no sparsity in the domain space
|
|
73
|
+
'clique': Applying dconv_cliquetree
|
|
74
|
+
'basis': Applying dconv_basisrep
|
|
75
|
+
* rangeMethod: Algorithm option for range space. Parameter is:
|
|
76
|
+
'none': Exploiting no sparsity in the range space
|
|
77
|
+
'clique': Applying rconv_cliquetree
|
|
78
|
+
'decomp': Applying rconv_matdecomp
|
|
79
|
+
|
|
80
|
+
The following parameters are for Free variables elimination.
|
|
81
|
+
* frvMethod: The method to eliminate free variables
|
|
82
|
+
('split' or 'elimination')
|
|
83
|
+
* rho: The parameter of range in split method or
|
|
84
|
+
pivoting in elimination method
|
|
85
|
+
* zeroPoint: The zero point of matrix operation,
|
|
86
|
+
determine unboundness, or LU decomposition
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
One recommended choice of Exploiting sparsity parameters:
|
|
90
|
+
domain = 'clique'
|
|
91
|
+
range = 'decomp'
|
|
92
|
+
convMethod = 'EQ'
|
|
93
|
+
The other recommended choice of parameters:
|
|
94
|
+
domain = 'basis'
|
|
95
|
+
range = 'clique'
|
|
96
|
+
convMethod = 'LMI'
|
|
97
|
+
"""
|
|
98
|
+
|
|
99
|
+
# Default parameter
|
|
100
|
+
option0 = {
|
|
101
|
+
'maxIteration': 100,
|
|
102
|
+
'epsilonStar': 1.0E-7,
|
|
103
|
+
'lambdaStar': 1.0E2,
|
|
104
|
+
'omegaStar': 2.0,
|
|
105
|
+
'lowerBound': -1.0E5,
|
|
106
|
+
'upperBound': 1.0E5,
|
|
107
|
+
'betaStar': 0.1,
|
|
108
|
+
'betaBar': 0.2,
|
|
109
|
+
'gammaStar': 0.9,
|
|
110
|
+
'epsilonDash': 1.0E-7,
|
|
111
|
+
'mpfPrecision': 200,
|
|
112
|
+
'isSymmetric': False,
|
|
113
|
+
'isDimacs': False,
|
|
114
|
+
'xPrint': '%+18.12Fe' if gmp_backend else '%+8.3e',
|
|
115
|
+
'yPrint': '%+18.12Fe' if gmp_backend else '%+8.3e',
|
|
116
|
+
'sPrint': '%+18.12Fe' if gmp_backend else '%+8.3e',
|
|
117
|
+
'infPrint': '%+10.16e',
|
|
118
|
+
'print': 'display',
|
|
119
|
+
'resultFile': '',
|
|
120
|
+
'sdpaResult': '',
|
|
121
|
+
'numThreads': multiprocessing.cpu_count(), # Max Avialable Number
|
|
122
|
+
'frvMethod': 'split', # 'split' or 'elimination'
|
|
123
|
+
'convMethod': 'LMI', # 'LMI' or 'EQ'
|
|
124
|
+
'domainMethod': 'none', # 'none' or 'clique' or 'basis'
|
|
125
|
+
'rangeMethod': 'none', # 'none' or 'clique' or 'decomp'
|
|
126
|
+
'rho': 0.0,
|
|
127
|
+
'zeroPoint': 1.0E-12
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if option == None:
|
|
131
|
+
return option0
|
|
132
|
+
if not isinstance(option, dict):
|
|
133
|
+
print("Input parameter is not dictionary.\n"
|
|
134
|
+
"Default parameter is set.")
|
|
135
|
+
return option0
|
|
136
|
+
|
|
137
|
+
if 'maxIteration' not in option:
|
|
138
|
+
option['maxIteration'] = option0['maxIteration']
|
|
139
|
+
elif not isinstance(option['maxIteration'], int):
|
|
140
|
+
print("option.maxIteration must be integer.\n"
|
|
141
|
+
"Default value is set.")
|
|
142
|
+
option['maxIteration'] = option0['maxIteration']
|
|
143
|
+
|
|
144
|
+
if 'epsilonStar' not in option:
|
|
145
|
+
option['epsilonStar'] = option0['epsilonStar']
|
|
146
|
+
elif not isinstance(option['epsilonStar'], float):
|
|
147
|
+
print("option.epsilonStar must be float.\n"
|
|
148
|
+
"Default value is set.")
|
|
149
|
+
option['epsilonStar'] = option0['epsilonStar']
|
|
150
|
+
|
|
151
|
+
if 'lambdaStar' not in option:
|
|
152
|
+
option['lambdaStar'] = option0['lambdaStar'];
|
|
153
|
+
elif not isinstance(option['lambdaStar'], float):
|
|
154
|
+
print("option.lambdaStar must be float.\n"
|
|
155
|
+
"Default value is set.")
|
|
156
|
+
option['lambdaStar'] = option0['lambdaStar']
|
|
157
|
+
|
|
158
|
+
if 'omegaStar' not in option:
|
|
159
|
+
option['omegaStar'] = option0['omegaStar']
|
|
160
|
+
elif not isinstance(option['omegaStar'], float):
|
|
161
|
+
print("option.omegaStar must be float.\n"
|
|
162
|
+
"Default value is set.")
|
|
163
|
+
option['omegaStar'] = option0['omegaStar']
|
|
164
|
+
|
|
165
|
+
if 'lowerBound' not in option:
|
|
166
|
+
option['lowerBound'] = option0['lowerBound']
|
|
167
|
+
elif not isinstance(option['lowerBound'], float):
|
|
168
|
+
print("option.lowerBound must be float.\n"
|
|
169
|
+
"Default value is set.")
|
|
170
|
+
option['lowerBound'] = option0['lowerBound']
|
|
171
|
+
|
|
172
|
+
if 'upperBound' not in option:
|
|
173
|
+
option['upperBound'] = option0['upperBound']
|
|
174
|
+
elif not isinstance(option['upperBound'], float):
|
|
175
|
+
print("option. must be float.\n"
|
|
176
|
+
"Default value is set.")
|
|
177
|
+
option['upperBound'] = option0['upperBound']
|
|
178
|
+
|
|
179
|
+
if 'betaStar' not in option:
|
|
180
|
+
option['betaStar'] = option0['betaStar']
|
|
181
|
+
elif not isinstance(option['betaStar'], float):
|
|
182
|
+
print("option. must be float.\n"
|
|
183
|
+
"Default value is set.")
|
|
184
|
+
option['betaStar'] = option0['betaStar']
|
|
185
|
+
|
|
186
|
+
if 'betaBar' not in option:
|
|
187
|
+
option['betaBar'] = option0['betaBar']
|
|
188
|
+
elif not isinstance(option['betaBar'], float):
|
|
189
|
+
print("option.betaBar must be float.\n"
|
|
190
|
+
"Default value is set.")
|
|
191
|
+
option['betaBar'] = option0['betaBar']
|
|
192
|
+
|
|
193
|
+
if 'gammaStar' not in option:
|
|
194
|
+
option['gammaStar'] = option0['gammaStar']
|
|
195
|
+
elif not isinstance(option['gammaStar'], float):
|
|
196
|
+
print("option.gammaStar must be float.\n"
|
|
197
|
+
"Default value is set.")
|
|
198
|
+
option['gammaStar'] = option0['gammaStar']
|
|
199
|
+
|
|
200
|
+
if 'epsilonDash' not in option:
|
|
201
|
+
option['epsilonDash'] = option0['epsilonDash']
|
|
202
|
+
elif not isinstance(option['epsilonDash'], float):
|
|
203
|
+
print("option.epsilonDash must be float.\n"
|
|
204
|
+
"Default value is set.")
|
|
205
|
+
option['epsilonDash'] = option0['epsilonDash']
|
|
206
|
+
|
|
207
|
+
if 'mpfPrecision' not in option:
|
|
208
|
+
option['mpfPrecision'] = option0['mpfPrecision']
|
|
209
|
+
elif not isinstance(option['mpfPrecision'], int):
|
|
210
|
+
print("option.mpfPrecision must be integer.\n"
|
|
211
|
+
"Default value is set.")
|
|
212
|
+
option['mpfPrecision'] = option0['mpfPrecision']
|
|
213
|
+
|
|
214
|
+
if 'searchDir' in option:
|
|
215
|
+
print("Parameter *searchDir* is no longer supported.\n"
|
|
216
|
+
"HRVW/KSH/M is automatically used.")
|
|
217
|
+
|
|
218
|
+
if 'isSymmetric' not in option:
|
|
219
|
+
option['isSymmetric'] = option0['isSymmetric']
|
|
220
|
+
elif not isinstance(option['isSymmetric'], bool):
|
|
221
|
+
print("option.isSymmetric must be bool.\n"
|
|
222
|
+
"Default value is set.")
|
|
223
|
+
option['isSymmetric'] = option0['isSymmetric']
|
|
224
|
+
|
|
225
|
+
if 'isDimacs' not in option:
|
|
226
|
+
option['isDimacs'] = option0['isDimacs']
|
|
227
|
+
elif not isinstance(option['isDimacs'], bool):
|
|
228
|
+
print("option.isDimacs must be bool.\n"
|
|
229
|
+
"Default value is set.")
|
|
230
|
+
option['isDimacs'] = option0['isDimacs']
|
|
231
|
+
|
|
232
|
+
if 'xPrint' not in option:
|
|
233
|
+
option['xPrint'] = option0['xPrint']
|
|
234
|
+
elif not isinstance(option['xPrint'], str):
|
|
235
|
+
print("option.xPrint must be string.\n"
|
|
236
|
+
"Default value is set.")
|
|
237
|
+
option['xPrint'] = option0['xPrint']
|
|
238
|
+
|
|
239
|
+
if 'yPrint' not in option:
|
|
240
|
+
option['yPrint'] = option0['yPrint']
|
|
241
|
+
elif not isinstance(option['yPrint'], str):
|
|
242
|
+
print("option.YPrint must be string.\n"
|
|
243
|
+
"Default value is set.")
|
|
244
|
+
option['yPrint'] = option0['yPrint']
|
|
245
|
+
|
|
246
|
+
if 'sPrint' not in option:
|
|
247
|
+
option['sPrint'] = option0['sPrint']
|
|
248
|
+
elif not isinstance(option['sPrint'], str):
|
|
249
|
+
print("option.sPrint must be string.\n"
|
|
250
|
+
"Default value is set.")
|
|
251
|
+
option['sPrint'] = option0['sPrint']
|
|
252
|
+
|
|
253
|
+
if 'infPrint' not in option:
|
|
254
|
+
option['infPrint'] = option0['infPrint']
|
|
255
|
+
elif not isinstance(option['infPrint'], str):
|
|
256
|
+
print("option.infPrint must be string.\n"
|
|
257
|
+
"Default value is set.")
|
|
258
|
+
option['infPrint'] = option0['infPrint']
|
|
259
|
+
|
|
260
|
+
if 'print' not in option:
|
|
261
|
+
option['print']=option0['print']
|
|
262
|
+
elif len(option['print']) == 0:
|
|
263
|
+
option['print'] = 'no'
|
|
264
|
+
elif not isinstance(option['print'], str):
|
|
265
|
+
print("option.print must be string.\n"
|
|
266
|
+
"Default value is set.\n"
|
|
267
|
+
"*** option.print must be string for FILE. ***\n"
|
|
268
|
+
" \"display\" is for stdout.\n"
|
|
269
|
+
" \"no\" or empty is for skip message.\n"
|
|
270
|
+
" filename is filename in which message will be written.\n"
|
|
271
|
+
"*** option.print must be string for FILE. ***")
|
|
272
|
+
option['print'] = option0['print']
|
|
273
|
+
|
|
274
|
+
if 'resultFile' not in option or len(option['resultFile']) == 0:
|
|
275
|
+
option['resultFile'] = option0['resultFile']
|
|
276
|
+
elif not isinstance(option['resultFile'], str):
|
|
277
|
+
print("option.resultFile must be string.\n"
|
|
278
|
+
"Default value is set.")
|
|
279
|
+
option['resultFile'] = option0['resultFile']
|
|
280
|
+
|
|
281
|
+
if 'sdpaResult' not in option or len(option['sdpaResult']) == 0:
|
|
282
|
+
option['sdpaResult'] = option0['sdpaResult']
|
|
283
|
+
elif not isinstance(option['sdpaResult'], str):
|
|
284
|
+
print("option.sdpaResult must be string.\n"
|
|
285
|
+
"Default value is set.")
|
|
286
|
+
option['sdpaResult'] = option0['sdpaResult']
|
|
287
|
+
|
|
288
|
+
if 'numThreads' not in option:
|
|
289
|
+
option['numThreads'] = option0['numThreads']
|
|
290
|
+
elif not isinstance(option['numThreads'], int):
|
|
291
|
+
print("option.numThreads must be integer.\n"
|
|
292
|
+
"Default value is set.")
|
|
293
|
+
option['numThreads'] = option0['numThreads']
|
|
294
|
+
|
|
295
|
+
if 'frvMethod' not in option:
|
|
296
|
+
option['frvMethod'] = option0['frvMethod']
|
|
297
|
+
elif len(option['frvMethod']) == 0:
|
|
298
|
+
option['frvMethod'] = option0['frvMethod']
|
|
299
|
+
elif not isinstance(option['frvMethod'], str):
|
|
300
|
+
print("option.frvMethod must be 'split' or 'elimination'.\n"
|
|
301
|
+
"Default value is set.")
|
|
302
|
+
option['frvMethod'] = option0['frvMethod']
|
|
303
|
+
elif (option['frvMethod'] != 'split' and
|
|
304
|
+
option['frvMethod'] != 'elimination'):
|
|
305
|
+
print("option.frvMethod must be \"split\" or \"elimination\".\n"
|
|
306
|
+
"Default value is set.")
|
|
307
|
+
option['frvMethod'] = option0['frvMethod']
|
|
308
|
+
|
|
309
|
+
if 'convMethod' not in option:
|
|
310
|
+
option['convMethod'] = option0['convMethod']
|
|
311
|
+
elif len(option['convMethod']) == 0:
|
|
312
|
+
option['convMethod'] = option0['convMethod']
|
|
313
|
+
elif not isinstance(option['convMethod'], str):
|
|
314
|
+
print("option.convMethod must be 'LMI' or 'EQ'.\n"
|
|
315
|
+
"Default value is set.")
|
|
316
|
+
option['convMethod'] = option0['convMethod']
|
|
317
|
+
elif option['convMethod'] != 'LMI' and option['convMethod'] != 'EQ':
|
|
318
|
+
print("option.toSedumi must be 'LMI' or 'EQ'.\n"
|
|
319
|
+
"Default value is set.")
|
|
320
|
+
option['convMethod'] = option0['convMethod']
|
|
321
|
+
|
|
322
|
+
if 'domainMethod' not in option:
|
|
323
|
+
option['domainMethod'] = option0['domainMethod']
|
|
324
|
+
elif len(option['domainMethod']) == 0:
|
|
325
|
+
option['domainMethod'] = option0['domainMethod']
|
|
326
|
+
elif isinstance(option['domainMethod'], str) == False:
|
|
327
|
+
print("option.domainMethod must be 'none' or 'clique' or 'basis'.\n"
|
|
328
|
+
"Default parameter is set.")
|
|
329
|
+
option['domainMethod'] = option0['domainMethod']
|
|
330
|
+
elif option['domainMethod'] != 'none' and \
|
|
331
|
+
option['domainMethod'] != 'clique' and \
|
|
332
|
+
option['domainMethod'] != 'basis':
|
|
333
|
+
print("option.domainMethod must be 'none' or 'clique' or 'basis'.\n"
|
|
334
|
+
"Default parameter is set.")
|
|
335
|
+
option['domainMethod'] = option0['domainMethod']
|
|
336
|
+
|
|
337
|
+
if 'rangeMethod' not in option:
|
|
338
|
+
option['rangeMethod'] = option0['rangeMethod']
|
|
339
|
+
elif len(option['rangeMethod']) == 0:
|
|
340
|
+
option['rangeMethod'] = option0['rangeMethod']
|
|
341
|
+
elif isinstance(option['rangeMethod'], str) == False:
|
|
342
|
+
print("option.rangeMethod must be 'none' or 'clique' or 'decomp'.\n"
|
|
343
|
+
"Default parameter is set.")
|
|
344
|
+
option['rangeMethod'] = option0['rangeMethod']
|
|
345
|
+
elif option['rangeMethod'] != 'none' and \
|
|
346
|
+
option['rangeMethod'] != 'clique' and \
|
|
347
|
+
option['rangeMethod'] != 'decomp':
|
|
348
|
+
print("option.rangeMethod must be 'none' or 'clique' or 'decomp'.\n"
|
|
349
|
+
"Default parameter is set.")
|
|
350
|
+
option['rangeMethod'] = option0['rangeMethod']
|
|
351
|
+
|
|
352
|
+
if 'rho' not in option:
|
|
353
|
+
option['rho'] = option0['rho']
|
|
354
|
+
elif not isinstance(option['rho'], float):
|
|
355
|
+
print("option.rho must be float.\n"
|
|
356
|
+
"Default value is set.")
|
|
357
|
+
option['rho'] = option0['rho']
|
|
358
|
+
|
|
359
|
+
if 'zeroPoint' not in option:
|
|
360
|
+
option['zeroPoint'] = option0['zeroPoint']
|
|
361
|
+
elif not isinstance(option['zeroPoint'], float):
|
|
362
|
+
print("option.zeroPoint must be float.\n"
|
|
363
|
+
"Default value is set.")
|
|
364
|
+
option['zeroPoint'] = option0['zeroPoint']
|
|
365
|
+
|
|
366
|
+
return option
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This file is a component of SDPAP
|
|
3
|
+
Copyright (C) 2010-2022 SDPA Project
|
|
4
|
+
|
|
5
|
+
This program is free software; you can redistribute it and/or modify
|
|
6
|
+
it under the terms of the GNU General Public License as published by
|
|
7
|
+
the Free Software Foundation; either version 2 of the License, or
|
|
8
|
+
(at your option) any later version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful,
|
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License along
|
|
16
|
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
17
|
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18
|
+
|
|
19
|
+
December 2010: Originally written by Kenta Kato
|
|
20
|
+
"""
|
|
21
|
+
|
|
22
|
+
from .sdpacall import *
|
|
23
|
+
|
|
24
|
+
__all__ = filter(lambda s:not s.startswith('_'),dir())
|
|
Binary file
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
"""
|
|
3
|
+
Routines to convert to MatData and call SDPA (C API)
|
|
4
|
+
This file is a component of SDPAP
|
|
5
|
+
Copyright (C) 2010-2022 SDPA Project
|
|
6
|
+
|
|
7
|
+
This program is free software; you can redistribute it and/or modify
|
|
8
|
+
it under the terms of the GNU General Public License as published by
|
|
9
|
+
the Free Software Foundation; either version 2 of the License, or
|
|
10
|
+
(at your option) any later version.
|
|
11
|
+
|
|
12
|
+
This program is distributed in the hope that it will be useful,
|
|
13
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15
|
+
GNU General Public License for more details.
|
|
16
|
+
|
|
17
|
+
You should have received a copy of the GNU General Public License along
|
|
18
|
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
19
|
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
20
|
+
|
|
21
|
+
December 2010: Originally written by Kenta Kato
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
__all__ = ['solve_sdpa']
|
|
25
|
+
|
|
26
|
+
from . import sdpa
|
|
27
|
+
from sdpap.matdata import MatData
|
|
28
|
+
from sdpap.symcone import SymCone
|
|
29
|
+
from scipy.sparse import csr_matrix
|
|
30
|
+
from scipy import sparse
|
|
31
|
+
from numpy import array
|
|
32
|
+
|
|
33
|
+
def get_backend_info():
|
|
34
|
+
return sdpa.get_backend_info()
|
|
35
|
+
|
|
36
|
+
def solve_sdpa(A, b, c, K, option):
|
|
37
|
+
"""Solve SDP with sdpa
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
A, b, c: Sparse matrix which denotes SDP problem
|
|
41
|
+
K: SymCone
|
|
42
|
+
option: Dictionary of option parameters
|
|
43
|
+
|
|
44
|
+
Returns:
|
|
45
|
+
A tuple (x, y, info). Each members are:
|
|
46
|
+
x: Primal result
|
|
47
|
+
y: Dual result
|
|
48
|
+
info: Result SDPA information
|
|
49
|
+
"""
|
|
50
|
+
At = (A.T).tocsc()
|
|
51
|
+
At.sort_indices()
|
|
52
|
+
if not sparse.isspmatrix_csc(b):
|
|
53
|
+
b = b.tocsc()
|
|
54
|
+
if not sparse.isspmatrix_csc(c):
|
|
55
|
+
c = c.tocsc()
|
|
56
|
+
b.sort_indices()
|
|
57
|
+
c.sort_indices()
|
|
58
|
+
data_At = MatData(At)
|
|
59
|
+
data_b = MatData(b)
|
|
60
|
+
data_c = MatData(c)
|
|
61
|
+
dict_K = K.todict()
|
|
62
|
+
|
|
63
|
+
data_x, data_y, data_s, info = sdpa.sedumiwrap(data_At, data_b, data_c,
|
|
64
|
+
dict_K, option)
|
|
65
|
+
|
|
66
|
+
x = csr_matrix(array(data_x)).T
|
|
67
|
+
y = csr_matrix(array(data_y)).T
|
|
68
|
+
s = csr_matrix(array(data_s)).T
|
|
69
|
+
|
|
70
|
+
return x, y, s, info
|
|
71
|
+
|