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/symcone.py
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
"""
|
|
3
|
+
Class definition of SymCone
|
|
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
|
+
September 2010: Originally written by Kenta Kato
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
__all__ = ['SymCone']
|
|
25
|
+
|
|
26
|
+
class SymCone(object):
|
|
27
|
+
"""Description of a Cartesian product of symmetric cones.
|
|
28
|
+
|
|
29
|
+
Attributes:
|
|
30
|
+
f: A column vector space to denote free variables or equality constraints
|
|
31
|
+
l: An LP cone
|
|
32
|
+
q: An SOCP cone or a product of SOCP cones
|
|
33
|
+
s: A column vector space corresponding to
|
|
34
|
+
an SDP cone or a product of SDP cones
|
|
35
|
+
"""
|
|
36
|
+
def __init__(self, f=0, l=0, q=(), s=()):
|
|
37
|
+
"""Constructor
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
f: Size of free variables or equality constraints
|
|
41
|
+
l: Size LP cone
|
|
42
|
+
q: A tuple of size of SOCP cone
|
|
43
|
+
s: A tuple of size of SDP cone
|
|
44
|
+
"""
|
|
45
|
+
if isinstance(f, int):
|
|
46
|
+
self.f = f
|
|
47
|
+
else:
|
|
48
|
+
print("SymCone(): SymCone.f must be integer.\n"
|
|
49
|
+
"SymCone.f = 0 is set.")
|
|
50
|
+
self.f = 0
|
|
51
|
+
|
|
52
|
+
if isinstance(l, int):
|
|
53
|
+
self.l = l
|
|
54
|
+
else:
|
|
55
|
+
print("SymCone(): SymCone.l must be integer.\n"
|
|
56
|
+
"SymCone.l = 0 is set.")
|
|
57
|
+
self.l = 0
|
|
58
|
+
|
|
59
|
+
if isinstance(q, tuple):
|
|
60
|
+
self.q = q
|
|
61
|
+
else:
|
|
62
|
+
print("SymCone(): SymCone.q must be tuple of integers.\n"
|
|
63
|
+
"SymCone.q = () is set.")
|
|
64
|
+
self.q = ()
|
|
65
|
+
|
|
66
|
+
if isinstance(s, tuple):
|
|
67
|
+
self.s = s
|
|
68
|
+
else:
|
|
69
|
+
print("SymCone(): SymCone.s must be tuple of integers\n"
|
|
70
|
+
"SymCone.s = () is set.")
|
|
71
|
+
self.s = ()
|
|
72
|
+
|
|
73
|
+
def __str__(self):
|
|
74
|
+
"""Convert into strings for print()."""
|
|
75
|
+
retStr = ""
|
|
76
|
+
retStr += " f: " + str(self.f) + "\n"
|
|
77
|
+
retStr += " l: " + str(self.l) + "\n"
|
|
78
|
+
retStr += " len(q): " + str(len(self.q)) + "\n"
|
|
79
|
+
retStr += " size(q): " + str(sum(self.q)) + "\n"
|
|
80
|
+
if len(self.q) > 0:
|
|
81
|
+
retStr += "range(q): " + \
|
|
82
|
+
str(min(self.q)) + "-" + str(max(self.q)) + "\n"
|
|
83
|
+
else:
|
|
84
|
+
retStr += "range(q): 0\n"
|
|
85
|
+
|
|
86
|
+
retStr += " len(s): " + str(len(self.s)) + "\n"
|
|
87
|
+
retStr += " size(s): " + str(sum(k ** 2 for k in self.s)) + "\n"
|
|
88
|
+
if len(self.s) > 0:
|
|
89
|
+
retStr += "range(s): " + \
|
|
90
|
+
str(min(self.s)) + "-" + str(max(self.s)) + "\n"
|
|
91
|
+
else:
|
|
92
|
+
retStr += "range(s): 0\n"
|
|
93
|
+
return retStr
|
|
94
|
+
|
|
95
|
+
def debugprint(self):
|
|
96
|
+
"""Print SymCone for debug"""
|
|
97
|
+
retStr = str(self)
|
|
98
|
+
retStr += " q: " + str(self.q) + "\n"
|
|
99
|
+
retStr += " s: " + str(self.s) + "\n"
|
|
100
|
+
print(retStr)
|
|
101
|
+
|
|
102
|
+
def check_validity(self):
|
|
103
|
+
"""Check validity for SDPA input
|
|
104
|
+
|
|
105
|
+
Returns:
|
|
106
|
+
True: Valid
|
|
107
|
+
False: Invalid
|
|
108
|
+
"""
|
|
109
|
+
if not isinstance(self.f, int):
|
|
110
|
+
print("SymCone.check_validity(): SymCone.f must be integer.")
|
|
111
|
+
return False
|
|
112
|
+
if not isinstance(self.l, int):
|
|
113
|
+
print("SymCone.check_validity(): SymCone.l must be integer.")
|
|
114
|
+
return False
|
|
115
|
+
if not isinstance(self.q, tuple):
|
|
116
|
+
print("SymCone.check_validity(): "
|
|
117
|
+
"SymCone.q must be tuple of integers.")
|
|
118
|
+
return False
|
|
119
|
+
if not isinstance(self.s, tuple):
|
|
120
|
+
print("SymCone.check_validity(): "
|
|
121
|
+
"SymCone.s must be tuple of integers")
|
|
122
|
+
return False
|
|
123
|
+
|
|
124
|
+
return True
|
|
125
|
+
|
|
126
|
+
def fromdict(self, otherDict):
|
|
127
|
+
"""Convert from canonical dictionary
|
|
128
|
+
See also todict().
|
|
129
|
+
|
|
130
|
+
Args:
|
|
131
|
+
otherDict: A dictionary which keys are ('f', 'l', 'q', 's')
|
|
132
|
+
"""
|
|
133
|
+
self.f = int(otherDict["f"])
|
|
134
|
+
self.l = int(otherDict["l"])
|
|
135
|
+
self.q = tuple(otherDict["q"])
|
|
136
|
+
self.s = tuple(otherDict["s"])
|
|
137
|
+
return
|
|
138
|
+
|
|
139
|
+
def todict(self):
|
|
140
|
+
"""Convert to canonical dictionary
|
|
141
|
+
See also fromdict().
|
|
142
|
+
|
|
143
|
+
Returns:
|
|
144
|
+
otherDict: A dictionary which keys are ('f', 'l', 'q', 's')
|
|
145
|
+
"""
|
|
146
|
+
otherDict = {}
|
|
147
|
+
otherDict["f"] = int(self.f)
|
|
148
|
+
otherDict["l"] = int(self.l)
|
|
149
|
+
otherDict["q"] = tuple(self.q)
|
|
150
|
+
otherDict["s"] = tuple(self.s)
|
|
151
|
+
return otherDict
|
|
152
|
+
|
|
153
|
+
def copy(self):
|
|
154
|
+
"""Deepcopy of SymCone for SymCone()."""
|
|
155
|
+
import copy
|
|
156
|
+
return copy.deepcopy(self)
|
|
157
|
+
|