-
Notifications
You must be signed in to change notification settings - Fork 17
/
types.jl
317 lines (282 loc) · 6.79 KB
/
types.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
#############################################################################
# ECOS.jl
# Wrapper around the ECOS solver https://github.com/ifa-ethz/ecos
# See http://github.com/JuliaOpt/ECOS.jl
#############################################################################
# types.jl
# Julia implementations of the types defined in ecos.h
# Types are mapped as follows
# pfloat -> Cdouble
# idxint -> SuiteSparse_long -> Clong
#############################################################################
# Solve status flags
# From: https://github.com/ifa-ethz/ecos/blob/master/include/ecos.h
const ECOS_OPTIMAL = 0 # Problem solved to optimality
const ECOS_PINF = 1 # Found certificate of primal infeasibility
const ECOS_DINF = 2 # Found certificate of dual infeasibility
const ECOS_INACC_OFFSET = 10 # Offset exitflag at inaccurate results
const ECOS_MAXIT = -1 # Maximum number of iterations reached
const ECOS_NUMERICS = -2 # Search direction unreliable
const ECOS_OUTCONE = -3 # s or z got outside the cone, numerics?
const ECOS_SIGINT = -4 # solver interrupted by a signal/ctrl-c
const ECOS_FATAL = -7 # Unknown problem in solver
struct Clpcone
p::Clong
w::Ptr{Cdouble}
v::Ptr{Cdouble}
kkt_idx::Ptr{Clong}
end
struct Csocone
p::Clong
skbar::Ptr{Cdouble}
zkbar::Ptr{Cdouble}
a::Clong
d1::Clong
w::Cdouble
eta::Cdouble
eta_square::Cdouble
q::Ptr{Cdouble}
Didx::Ptr{Clong}
u0::Cdouble
u1::Cdouble
v1::Cdouble
end
struct Ccone
lpcone::Ptr{Clpcone}
socone::Ptr{Csocone}
nsoc::Clong
end
struct Cspmat
jc::Ptr{Clong}
ir::Ptr{Clong}
pr::Ptr{Cdouble}
n::Clong
m::Clong
nnz::Clong
end
struct Ckkt
PKPt::Ptr{Cspmat}
L::Ptr{Cspmat}
D::Ptr{Cdouble}
work1::Ptr{Cdouble}
work2::Ptr{Cdouble}
work3::Ptr{Cdouble}
work4::Ptr{Cdouble}
work5::Ptr{Cdouble}
work6::Ptr{Cdouble}
RHS1::Ptr{Cdouble}
RHS2::Ptr{Cdouble}
dx1::Ptr{Cdouble}
dx2::Ptr{Cdouble}
dy1::Ptr{Cdouble}
dy2::Ptr{Cdouble}
dz1::Ptr{Cdouble}
dz2::Ptr{Cdouble}
P::Ptr{Clong}
Pinv::Ptr{Clong}
PK::Ptr{Clong}
Parent::Ptr{Clong}
Sign::Ptr{Clong}
Pattern::Ptr{Clong}
Flag::Ptr{Clong}
Lnz::Ptr{Clong}
delta::Cdouble
end
struct Cstats
pcost::Cdouble
dcost::Cdouble
pres::Cdouble
dres::Cdouble
pinf::Cdouble
dinf::Cdouble
pinfres::Cdouble
dinfres::Cdouble
gap::Cdouble
relgap::Cdouble
sigma::Cdouble
mu::Cdouble
step::Cdouble
step_aff::Cdouble
kapovert::Cdouble
iter::Clong
nitref1::Clong
nitref2::Clong
nitref3::Clong
tsetup::Cdouble
tsolve::Cdouble
tfactor::Cdouble
tkktsolve::Cdouble
torder::Cdouble
tkktcreate::Cdouble
ttranspose::Cdouble
tperm::Cdouble
tfactor_t1::Cdouble
tfactor_t2::Cdouble
end
struct Csettings
gamma::Cdouble
delta::Cdouble
eps::Cdouble
feastol::Cdouble
abstol::Cdouble
reltol::Cdouble
feastol_inacc::Cdouble
abstol_inacc::Cdouble
reltol_inacc::Cdouble
nitref::Clong
maxit::Clong
verbose::Clong
max_bk_iter::Clong
bk_scale::Cdouble
centrality::Cdouble
end
if VersionNumber(ver()) >= v"2.0.5"
@eval struct Cpwork
# Dimensions
n::Clong
m::Clong
p::Clong
D::Clong
# Variables
x::Ptr{Cdouble}
y::Ptr{Cdouble}
z::Ptr{Cdouble}
s::Ptr{Cdouble}
lambda::Ptr{Cdouble}
kap::Cdouble
tau::Cdouble
# Best iterates seen so far
best_x::Ptr{Cdouble}
best_y::Ptr{Cdouble}
best_z::Ptr{Cdouble}
best_s::Ptr{Cdouble}
best_kap::Cdouble
best_tau::Cdouble
best_cx::Cdouble
best_by::Cdouble
best_hz::Cdouble
best_info::Ptr{Cstats}
# Temporary variables
dsaff::Ptr{Cdouble}
dzaff::Ptr{Cdouble}
W_times_dzaff::Ptr{Cdouble}
dsaff_by_W::Ptr{Cdouble}
saff::Ptr{Cdouble}
zaff::Ptr{Cdouble}
# Cone
C::Ptr{Ccone}
A::Ptr{Cspmat}
G::Ptr{Cspmat}
c::Ptr{Cdouble}
b::Ptr{Cdouble}
h::Ptr{Cdouble}
# indices that map entries of A and G to the KKT matrix
AtoK::Ptr{Clong}
GtoK::Ptr{Clong}
# equilibration vector
xequil::Ptr{Cdouble}
Aequil::Ptr{Cdouble}
Gequil::Ptr{Cdouble}
# scalings of problem data
resx0::Cdouble
resy0::Cdouble
resz0::Cdouble
# residuals
rx::Ptr{Cdouble}
ry::Ptr{Cdouble}
rz::Ptr{Cdouble}
rt::Cdouble
hresx::Cdouble
hresy::Cdouble
hresz::Cdouble
# norm iterates
nx::Cdouble
ny::Cdouble
nz::Cdouble
ns::Cdouble
# temporary storage
cx::Cdouble
by::Cdouble
hz::Cdouble
sz::Cdouble
# KKT System
KKT::Ptr{Ckkt}
# info struct
info::Ptr{Cstats}
# settings struct
stgs::Ptr{Csettings}
end
else
@eval struct Cpwork
# Dimensions
n::Clong
m::Clong
p::Clong
D::Clong
# Variables
x::Ptr{Cdouble}
y::Ptr{Cdouble}
z::Ptr{Cdouble}
s::Ptr{Cdouble}
lambda::Ptr{Cdouble}
kap::Cdouble
tau::Cdouble
# Best iterates seen so far
best_x::Ptr{Cdouble}
best_y::Ptr{Cdouble}
best_z::Ptr{Cdouble}
best_s::Ptr{Cdouble}
best_kap::Cdouble
best_tau::Cdouble
best_cx::Cdouble
best_by::Cdouble
best_hz::Cdouble
best_info::Ptr{Cstats}
# Temporary variables
dsaff::Ptr{Cdouble}
dzaff::Ptr{Cdouble}
W_times_dzaff::Ptr{Cdouble}
dsaff_by_W::Ptr{Cdouble}
saff::Ptr{Cdouble}
zaff::Ptr{Cdouble}
# Cone
C::Ptr{Ccone}
A::Ptr{Cspmat}
G::Ptr{Cspmat}
c::Ptr{Cdouble}
b::Ptr{Cdouble}
h::Ptr{Cdouble}
# equilibration vector
xequil::Ptr{Cdouble}
Aequil::Ptr{Cdouble}
Gequil::Ptr{Cdouble}
# scalings of problem data
resx0::Cdouble
resy0::Cdouble
resz0::Cdouble
# residuals
rx::Ptr{Cdouble}
ry::Ptr{Cdouble}
rz::Ptr{Cdouble}
rt::Cdouble
hresx::Cdouble
hresy::Cdouble
hresz::Cdouble
# norm iterates
nx::Cdouble
ny::Cdouble
nz::Cdouble
ns::Cdouble
# temporary storage
cx::Cdouble
by::Cdouble
hz::Cdouble
sz::Cdouble
# KKT System
KKT::Ptr{Ckkt}
# info struct
info::Ptr{Cstats}
# settings struct
stgs::Ptr{Csettings}
end
end