Skip to main content

ecos/
lib.rs

1pub type pfloat = f64;
2pub type idxint = i64;
3
4#[repr(C)]
5#[derive(Debug, Copy, Clone)]
6pub struct spmat {
7    pub jc: *mut idxint,
8    pub ir: *mut idxint,
9    pub pr: *mut pfloat,
10    pub n: idxint,
11    pub m: idxint,
12    pub nnz: idxint,
13}
14
15#[repr(C)]
16#[derive(Debug, Copy, Clone)]
17pub struct expcone {
18    pub colstart: [idxint; 3usize],
19    pub v: [pfloat; 6usize],
20    pub g: [pfloat; 3usize],
21}
22
23#[repr(C)]
24#[derive(Debug, Copy, Clone)]
25pub struct lpcone {
26    pub p: idxint,
27    pub w: *mut pfloat,
28    pub v: *mut pfloat,
29    pub kkt_idx: *mut idxint,
30}
31#[repr(C)]
32#[derive(Debug, Copy, Clone)]
33pub struct socone {
34    pub p: idxint,
35    pub skbar: *mut pfloat,
36    pub zkbar: *mut pfloat,
37    pub a: pfloat,
38    pub d1: pfloat,
39    pub w: pfloat,
40    pub eta: pfloat,
41    pub eta_square: pfloat,
42    pub q: *mut pfloat,
43    pub Didx: *mut idxint,
44    pub u0: pfloat,
45    pub u1: pfloat,
46    pub v1: pfloat,
47}
48#[repr(C)]
49#[derive(Debug, Copy, Clone)]
50pub struct cone {
51    pub lpc: *mut lpcone,
52    pub soc: *mut socone,
53    pub nsoc: idxint,
54    pub expc: *mut expcone,
55    pub nexc: idxint,
56    pub fexv: idxint,
57}
58
59extern "C" {
60    pub fn getSOCDetails(
61        soc: *mut socone,
62        conesize: *mut idxint,
63        eta_square: *mut pfloat,
64        d1: *mut pfloat,
65        u0: *mut pfloat,
66        u1: *mut pfloat,
67        v1: *mut pfloat,
68        q: *mut *mut pfloat,
69    );
70
71    pub fn unstretch(
72        n: idxint,
73        p: idxint,
74        C: *mut cone,
75        Pinv: *mut idxint,
76        Px: *mut pfloat,
77        dx: *mut pfloat,
78        dy: *mut pfloat,
79        dz: *mut pfloat,
80    );
81}
82
83#[repr(C)]
84#[derive(Debug, Copy, Clone)]
85pub struct kkt {
86    pub PKPt: *mut spmat,
87    pub L: *mut spmat,
88    pub D: *mut pfloat,
89    pub work1: *mut pfloat,
90    pub work2: *mut pfloat,
91    pub work3: *mut pfloat,
92    pub work4: *mut pfloat,
93    pub work5: *mut pfloat,
94    pub work6: *mut pfloat,
95    pub RHS1: *mut pfloat,
96    pub RHS2: *mut pfloat,
97    pub dx1: *mut pfloat,
98    pub dx2: *mut pfloat,
99    pub dy1: *mut pfloat,
100    pub dy2: *mut pfloat,
101    pub dz1: *mut pfloat,
102    pub dz2: *mut pfloat,
103    pub P: *mut idxint,
104    pub Pinv: *mut idxint,
105    pub PK: *mut idxint,
106    pub Parent: *mut idxint,
107    pub Sign: *mut idxint,
108    pub Pattern: *mut idxint,
109    pub Flag: *mut idxint,
110    pub Lnz: *mut idxint,
111    pub delta: pfloat,
112}
113
114#[repr(C)]
115#[derive(Debug, Copy, Clone)]
116pub struct settings {
117    pub gamma: pfloat,
118    pub delta: pfloat,
119    pub eps: pfloat,
120    pub feastol: pfloat,
121    pub abstol: pfloat,
122    pub reltol: pfloat,
123    pub feastol_inacc: pfloat,
124    pub abstol_inacc: pfloat,
125    pub reltol_inacc: pfloat,
126    pub nitref: idxint,
127    pub maxit: idxint,
128    pub verbose: idxint,
129    pub max_bk_iter: idxint,
130    pub bk_scale: pfloat,
131    pub centrality: pfloat,
132}
133#[repr(C)]
134#[derive(Debug, Copy, Clone)]
135pub struct stats {
136    pub pcost: pfloat,
137    pub dcost: pfloat,
138    pub pres: pfloat,
139    pub dres: pfloat,
140    pub pinf: pfloat,
141    pub dinf: pfloat,
142    pub pinfres: pfloat,
143    pub dinfres: pfloat,
144    pub gap: pfloat,
145    pub relgap: pfloat,
146    pub sigma: pfloat,
147    pub mu: pfloat,
148    pub step: pfloat,
149    pub step_aff: pfloat,
150    pub kapovert: pfloat,
151    pub iter: idxint,
152    pub nitref1: idxint,
153    pub nitref2: idxint,
154    pub nitref3: idxint,
155    pub tsetup: pfloat,
156    pub tsolve: pfloat,
157    pub pob: idxint,
158    pub cb: idxint,
159    pub cob: idxint,
160    pub pb: idxint,
161    pub db: idxint,
162    pub affBack: idxint,
163    pub cmbBack: idxint,
164    pub centrality: pfloat,
165}
166#[repr(C)]
167#[derive(Debug, Copy, Clone)]
168pub struct pwork {
169    pub n: idxint,
170    pub m: idxint,
171    pub p: idxint,
172    pub D: idxint,
173    pub x: *mut pfloat,
174    pub y: *mut pfloat,
175    pub z: *mut pfloat,
176    pub s: *mut pfloat,
177    pub lambda: *mut pfloat,
178    pub kap: pfloat,
179    pub tau: pfloat,
180    pub best_x: *mut pfloat,
181    pub best_y: *mut pfloat,
182    pub best_z: *mut pfloat,
183    pub best_s: *mut pfloat,
184    pub best_kap: pfloat,
185    pub best_tau: pfloat,
186    pub best_cx: pfloat,
187    pub best_by: pfloat,
188    pub best_hz: pfloat,
189    pub best_info: *mut stats,
190    pub dsaff: *mut pfloat,
191    pub dzaff: *mut pfloat,
192    pub W_times_dzaff: *mut pfloat,
193    pub dsaff_by_W: *mut pfloat,
194    pub saff: *mut pfloat,
195    pub zaff: *mut pfloat,
196    pub C: *mut cone,
197    pub A: *mut spmat,
198    pub G: *mut spmat,
199    pub c: *mut pfloat,
200    pub b: *mut pfloat,
201    pub h: *mut pfloat,
202    pub AtoK: *mut idxint,
203    pub GtoK: *mut idxint,
204    pub xequil: *mut pfloat,
205    pub Aequil: *mut pfloat,
206    pub Gequil: *mut pfloat,
207    pub resx0: pfloat,
208    pub resy0: pfloat,
209    pub resz0: pfloat,
210    pub rx: *mut pfloat,
211    pub ry: *mut pfloat,
212    pub rz: *mut pfloat,
213    pub rt: pfloat,
214    pub hresx: pfloat,
215    pub hresy: pfloat,
216    pub hresz: pfloat,
217    pub nx: pfloat,
218    pub ny: pfloat,
219    pub nz: pfloat,
220    pub ns: pfloat,
221    pub cx: pfloat,
222    pub by: pfloat,
223    pub hz: pfloat,
224    pub sz: pfloat,
225    pub KKT: *mut kkt,
226    pub info: *mut stats,
227    pub stgs: *mut settings,
228}
229
230extern "C" {
231    pub fn ECOS_setup(
232        n: idxint,
233        m: idxint,
234        p: idxint,
235        l: idxint,
236        ncones: idxint,
237        q: *mut idxint,
238        nex: idxint,
239        Gpr: *mut pfloat,
240        Gjc: *mut idxint,
241        Gir: *mut idxint,
242        Apr: *mut pfloat,
243        Ajc: *mut idxint,
244        Air: *mut idxint,
245        c: *mut pfloat,
246        h: *mut pfloat,
247        b: *mut pfloat,
248    ) -> *mut pwork;
249
250    pub fn expConeLineSearch(w: *mut pwork, dtau: pfloat, dkappa: pfloat, affine: idxint)
251        -> pfloat;
252
253    pub fn ECOS_solve(w: *mut pwork) -> idxint;
254
255    #[doc = " Cleanup: free memory (not used for embedded solvers, only standalone)"]
256    #[doc = ""]
257    #[doc = " Use the second argument to give the number of variables to NOT free."]
258    #[doc = " This is useful if you want to use the result of the optimization without"]
259    #[doc = " copying over the arrays. One use case is the MEX interface, where we"]
260    #[doc = " do not want to free x,y,s,z (depending on the number of LHS)."]
261    pub fn ECOS_cleanup(w: *mut pwork, keepvars: idxint);
262
263    #[doc = " Version: returns the current version number"]
264    #[doc = " Use a character array of length 7 to obtain the version number"]
265    #[doc = " in the format"]
266    #[doc = "      x.y.zzz"]
267    #[doc = " where x is the major, y the minor and zzz the build number"]
268    pub fn ECOS_ver() -> *const ::std::os::raw::c_char;
269
270    pub fn ecos_updateDataEntry_h(w: *mut pwork, idx: idxint, value: pfloat);
271
272    pub fn ecos_updateDataEntry_c(w: *mut pwork, idx: idxint, value: pfloat);
273
274    pub fn ECOS_updateData(
275        w: *mut pwork,
276        Gpr: *mut pfloat,
277        Apr: *mut pfloat,
278        c: *mut pfloat,
279        h: *mut pfloat,
280        b: *mut pfloat,
281    );
282}