forked from mcmtroffaes/pycddlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcddlib.pxi.in
379 lines (339 loc) · 14.3 KB
/
cddlib.pxi.in
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
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
# this is an include file for both cdd.h and cdd_f.h
# pycddlib is a Python wrapper for Komei Fukuda's cddlib
# Copyright (c) 2008, Matthias Troffaes
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
cdef extern from "@cddhdr@" nogil:
# set operations and enums are already imported from _common.pxd
# typedefs
###########
ctypedef int @dd@_boolean
ctypedef long @dd@_rowrange
ctypedef long @dd@_colrange
ctypedef long @dd@_bigrange
ctypedef set_type @dd@_rowset
ctypedef set_type @dd@_colset
ctypedef long *@dd@_rowindex
ctypedef int *@dd@_rowflag
ctypedef long *@dd@_colindex
ctypedef @mytype@ **@dd@_Amatrix
ctypedef @mytype@ *@dd@_Arow
ctypedef set_type *@dd@_SetVector
ctypedef @mytype@ **@dd@_Bmatrix
ctypedef set_type *@dd@_Aincidence
# enums
########
ctypedef enum @dd@_AdjacencyTestType:
@dd@_Combinatorial
@dd@_Algebraic
ctypedef enum @dd@_NumberType:
@dd@_Unknown
@dd@_Real
@dd@_Rational
@dd@_Integer
ctypedef enum @dd@_RepresentationType:
@dd@_Unspecified
@dd@_Inequality
@dd@_Generator
ctypedef enum @dd@_RowOrderType:
@dd@_MaxIndex
@dd@_MinIndex
@dd@_MinCutoff
@dd@_MaxCutoff
@dd@_MixCutoff
@dd@_LexMin
@dd@_LexMax
@dd@_RandomRow
# not translated: @dd@_ConversionType, @dd@_IncidenceOutputType, @dd@_AdjacencyOutputType, @dd@_FileInputModeType
ctypedef enum @dd@_ErrorType:
@dd@_DimensionTooLarge
@dd@_ImproperInputFormat
@dd@_NegativeMatrixSize
@dd@_EmptyVrepresentation
@dd@_EmptyHrepresentation
@dd@_EmptyRepresentation
@dd@_IFileNotFound
@dd@_OFileNotOpen
@dd@_NoLPObjective
@dd@_NoRealNumberSupport
@dd@_NotAvailForH
@dd@_NotAvailForV
@dd@_CannotHandleLinearity
@dd@_RowIndexOutOfRange
@dd@_ColIndexOutOfRange
@dd@_LPCycling
@dd@_NumericallyInconsistent
@dd@_NoError
ctypedef enum @dd@_CompStatusType:
@dd@_InProgress
@dd@_AllFound
@dd@_RegionEmpty
ctypedef enum @dd@_LPObjectiveType:
@dd@_LPnone
@dd@_LPmax
@dd@_LPmin
ctypedef enum @dd@_LPSolverType:
@dd@_CrissCross
@dd@_DualSimplex
ctypedef enum @dd@_LPStatusType:
@dd@_LPSundecided
@dd@_Optimal
@dd@_Inconsistent
@dd@_DualInconsistent
@dd@_StrucInconsistent
@dd@_StrucDualInconsistent
@dd@_Unbounded
@dd@_DualUnbounded
# structures
#############
# forward, pointer, and alias declarations
ctypedef struct @dd@_raydata
ctypedef @dd@_raydata *@dd@_RayPtr
ctypedef struct @dd@_adjacencydata
ctypedef @dd@_adjacencydata *@dd@_AdjacencyPtr
ctypedef @dd@_adjacencydata @dd@_AdjacencyType
ctypedef struct @dd@_lpsolution
ctypedef @dd@_lpsolution *@dd@_LPSolutionPtr
ctypedef struct @dd@_lpdata
ctypedef @dd@_lpdata *@dd@_LPPtr
ctypedef struct @dd@_matrixdata
ctypedef @dd@_matrixdata *@dd@_MatrixPtr
ctypedef struct @dd@_setfamily
ctypedef @dd@_setfamily *@dd@_SetFamilyPtr
ctypedef struct @dd@_nodedata
ctypedef @dd@_nodedata *@dd@_NodePtr
ctypedef struct @dd@_graphdata
ctypedef @dd@_graphdata *@dd@_GraphPtr
ctypedef struct @dd@_polyhedradata
ctypedef @dd@_polyhedradata *@dd@_PolyhedraPtr
ctypedef struct @dd@_conedata
ctypedef @dd@_conedata *@dd@_ConePtr
ctypedef struct @dd@_raydata:
@mytype@ *Ray
@dd@_rowset ZeroSet
@dd@_rowrange FirstInfeasIndex
@dd@_boolean feasible
@mytype@ ARay
@dd@_RayPtr Next
ctypedef struct @dd@_adjacencydata:
@dd@_RayPtr Ray1, Ray2
@dd@_AdjacencyPtr Next
ctypedef struct @dd@_lpsolution:
#@dd@_DataFileType filename
@dd@_LPObjectiveType objective
@dd@_LPSolverType solver
@dd@_rowrange m
@dd@_colrange d
@dd@_NumberType numbtype
@dd@_LPStatusType LPS
@mytype@ optvalue
@dd@_Arow sol
@dd@_Arow dsol
@dd@_colindex nbindex
@dd@_rowrange re
@dd@_colrange se
long pivots[5]
long total_pivots
ctypedef struct @dd@_lpdata:
@dd@_LPObjectiveType objective
@dd@_LPSolverType solver
@dd@_boolean Homogeneous
@dd@_rowrange m
@dd@_colrange d
@dd@_Amatrix A
@dd@_Bmatrix B
@dd@_rowrange objrow
@dd@_colrange rhscol
@dd@_NumberType numbtype
@dd@_rowrange eqnumber # number of equalities
@dd@_rowset equalityset
@dd@_boolean redcheck_extensive
@dd@_rowrange ired
@dd@_rowset redset_extra
@dd@_rowset redset_accum
@dd@_rowset posset_extra
@dd@_boolean lexicopivot
@dd@_LPStatusType LPS
@dd@_rowrange m_alloc
@dd@_colrange d_alloc
@mytype@ optvalue
@dd@_Arow sol
@dd@_Arow dsol
@dd@_colindex nbindex
@dd@_rowrange re
@dd@_colrange se
long pivots[5]
long total_pivots
int use_given_basis
@dd@_colindex given_nbindex
time_t starttime
time_t endtime
ctypedef struct @dd@_matrixdata:
@dd@_rowrange rowsize
@dd@_rowset linset
@dd@_colrange colsize
@dd@_RepresentationType representation
@dd@_NumberType numbtype
@dd@_Amatrix matrix
@dd@_LPObjectiveType objective
@dd@_Arow rowvec
ctypedef struct @dd@_setfamily:
@dd@_bigrange famsize
@dd@_bigrange setsize
@dd@_SetVector set
ctypedef struct @dd@_nodedata:
@dd@_bigrange key
@dd@_NodePtr next
ctypedef struct @dd@_graphdata:
@dd@_bigrange vsize
@dd@_NodePtr *adjlist
ctypedef struct @dd@_polyhedradata:
@dd@_RepresentationType representation
@dd@_boolean homogeneous
@dd@_colrange d
@dd@_rowrange m
@dd@_Amatrix A
@dd@_NumberType numbtype
@dd@_ConePtr child
@dd@_rowrange m_alloc
@dd@_colrange d_alloc
@dd@_Arow c
@dd@_rowflag EqualityIndex
@dd@_boolean IsEmpty
@dd@_boolean NondegAssumed
@dd@_boolean InitBasisAtBottom
@dd@_boolean RestrictedEnumeration
@dd@_boolean RelaxedEnumeration
@dd@_rowrange m1
@dd@_boolean AincGenerated
@dd@_colrange ldim
@dd@_bigrange n
@dd@_Aincidence Ainc
@dd@_rowset Ared
@dd@_rowset Adom
ctypedef struct @dd@_conedata:
@dd@_RepresentationType representation
@dd@_rowrange m
@dd@_colrange d
@dd@_Amatrix A
@dd@_NumberType numbtype
@dd@_PolyhedraPtr parent
@dd@_rowrange m_alloc
@dd@_colrange d_alloc
@dd@_rowrange Iteration
@dd@_RowOrderType HalfspaceOrder
@dd@_RayPtr FirstRay, LastRay, ArtificialRay
@dd@_RayPtr PosHead, ZeroHead, NegHead, PosLast, ZeroLast, NegLast
@dd@_AdjacencyType **Edges
unsigned int rseed
@dd@_boolean ColReduced
@dd@_bigrange LinearityDim
@dd@_colrange d_orig
@dd@_colindex newcol
@dd@_colindex InitialRayIndex
@dd@_rowindex OrderVector
@dd@_boolean RecomputeRowOrder
@dd@_boolean PreOrderedRun
@dd@_rowset GroundSet, EqualitySet, NonequalitySet, AddedHalfspaces, WeaklyAddedHalfspaces, InitialHalfspaces
long RayCount, FeasibleRayCount, WeaklyFeasibleRayCount, TotalRayCount, ZeroRayCount
long EdgeCount, TotalEdgeCount
long count_int, count_int_good, count_int_bad
@dd@_Bmatrix B
@dd@_Bmatrix Bsave
@dd@_ErrorType Error
@dd@_CompStatusType CompStatus
time_t starttime, endtime
# functions
############
# not everything is defined here, just most common operations
# add more as needed...
cdef void @dd@_set_d(@mytype@, double)
cdef void @dd@_set_si(@mytype@, signed long int)
cdef void @dd@_set_si2(@mytype@, signed long int, unsigned long int)
cdef double @dd@_get_d(@mytype@)
cdef void @dd@_set_global_constants()
cdef void @dd@_free_global_constants()
cdef void @dd@_WriteErrorMessages(libc.stdio.FILE *, @dd@_ErrorType)
cdef void @dd@_InitializeArow(@dd@_colrange,@dd@_Arow *)
cdef void @dd@_InitializeAmatrix(@dd@_rowrange,@dd@_colrange,@dd@_Amatrix *)
cdef void @dd@_InitializeBmatrix(@dd@_colrange, @dd@_Bmatrix *)
cdef @dd@_SetFamilyPtr @dd@_CreateSetFamily(@dd@_bigrange,@dd@_bigrange)
cdef void @dd@_FreeSetFamily(@dd@_SetFamilyPtr)
cdef @dd@_MatrixPtr @dd@_CreateMatrix(@dd@_rowrange,@dd@_colrange)
cdef void @dd@_FreeAmatrix(@dd@_rowrange,@dd@_colrange,@dd@_Amatrix)
cdef void @dd@_FreeArow(@dd@_colrange, @dd@_Arow)
cdef void @dd@_FreeBmatrix(@dd@_colrange,@dd@_Bmatrix)
cdef void @dd@_FreeDDMemory(@dd@_PolyhedraPtr)
cdef void @dd@_FreePolyhedra(@dd@_PolyhedraPtr)
cdef void @dd@_FreeMatrix(@dd@_MatrixPtr)
cdef void @dd@_SetToIdentity(@dd@_colrange, @dd@_Bmatrix)
cdef @dd@_MatrixPtr @dd@_CopyInput(@dd@_PolyhedraPtr)
cdef @dd@_MatrixPtr @dd@_CopyOutput(@dd@_PolyhedraPtr)
cdef @dd@_MatrixPtr @dd@_CopyInequalities(@dd@_PolyhedraPtr)
cdef @dd@_MatrixPtr @dd@_CopyGenerators(@dd@_PolyhedraPtr)
cdef @dd@_SetFamilyPtr @dd@_CopyIncidence(@dd@_PolyhedraPtr)
cdef @dd@_SetFamilyPtr @dd@_CopyAdjacency(@dd@_PolyhedraPtr)
cdef @dd@_SetFamilyPtr @dd@_CopyInputIncidence(@dd@_PolyhedraPtr)
cdef @dd@_SetFamilyPtr @dd@_CopyInputAdjacency(@dd@_PolyhedraPtr)
cdef @dd@_boolean @dd@_DDFile2File(char *ifile, char *ofile, @dd@_ErrorType *err)
cdef @dd@_boolean @dd@_DDInputAppend(@dd@_PolyhedraPtr*, @dd@_MatrixPtr, @dd@_ErrorType*)
cdef @dd@_MatrixPtr @dd@_PolyFile2Matrix(libc.stdio.FILE *f, @dd@_ErrorType *)
cdef @dd@_PolyhedraPtr @dd@_DDMatrix2Poly(@dd@_MatrixPtr, @dd@_ErrorType *)
cdef @dd@_PolyhedraPtr @dd@_DDMatrix2Poly2(@dd@_MatrixPtr, @dd@_RowOrderType, @dd@_ErrorType *)
cdef @dd@_boolean @dd@_Redundant(@dd@_MatrixPtr, @dd@_rowrange, @dd@_Arow, @dd@_ErrorType *)
cdef @dd@_rowset @dd@_RedundantRows(@dd@_MatrixPtr, @dd@_ErrorType *)
cdef @dd@_boolean @dd@_SRedundant(@dd@_MatrixPtr, @dd@_rowrange, @dd@_Arow, @dd@_ErrorType *)
cdef @dd@_rowset @dd@_SRedundantRows(@dd@_MatrixPtr, @dd@_ErrorType *)
cdef @dd@_rowset @dd@_RedundantRowsViaShooting(@dd@_MatrixPtr, @dd@_ErrorType *)
cdef @dd@_rowrange @dd@_RayShooting(@dd@_MatrixPtr, @dd@_Arow intpt, @dd@_Arow direction)
cdef @dd@_boolean @dd@_ImplicitLinearity(@dd@_MatrixPtr, @dd@_rowrange, @dd@_Arow, @dd@_ErrorType *)
cdef @dd@_rowset @dd@_ImplicitLinearityRows(@dd@_MatrixPtr, @dd@_ErrorType *)
cdef int @dd@_FreeOfImplicitLinearity(@dd@_MatrixPtr, @dd@_Arow, @dd@_rowset *, @dd@_ErrorType *)
cdef @dd@_boolean @dd@_MatrixCanonicalizeLinearity(@dd@_MatrixPtr *, @dd@_rowset *,@dd@_rowindex *, @dd@_ErrorType *)
cdef @dd@_boolean @dd@_MatrixCanonicalize(@dd@_MatrixPtr *, @dd@_rowset *, @dd@_rowset *, @dd@_rowindex *, @dd@_ErrorType *)
cdef @dd@_boolean @dd@_MatrixRedundancyRemove(@dd@_MatrixPtr *M, @dd@_rowset *redset,@dd@_rowindex *newpos, @dd@_ErrorType *)
cdef @dd@_boolean @dd@_FindRelativeInterior(@dd@_MatrixPtr, @dd@_rowset *, @dd@_rowset *, @dd@_LPSolutionPtr *, @dd@_ErrorType *)
cdef @dd@_boolean @dd@_ExistsRestrictedFace(@dd@_MatrixPtr, @dd@_rowset, @dd@_rowset, @dd@_ErrorType *)
cdef @dd@_boolean @dd@_ExistsRestrictedFace2(@dd@_MatrixPtr, @dd@_rowset, @dd@_rowset, @dd@_LPSolutionPtr *, @dd@_ErrorType *)
cdef @dd@_SetFamilyPtr @dd@_Matrix2Adjacency(@dd@_MatrixPtr, @dd@_ErrorType *)
cdef @dd@_SetFamilyPtr @dd@_Matrix2WeakAdjacency(@dd@_MatrixPtr, @dd@_ErrorType *)
cdef long @dd@_MatrixRank(@dd@_MatrixPtr, @dd@_rowset, @dd@_colset, @dd@_rowset *, @dd@_colset *)
cdef @dd@_MatrixPtr @dd@_CopyMatrix(@dd@_MatrixPtr)
cdef int @dd@_MatrixAppendTo(@dd@_MatrixPtr*, @dd@_MatrixPtr)
cdef int @dd@_MatrixRowRemove(@dd@_MatrixPtr *M, @dd@_rowrange r)
cdef void @dd@_WriteAmatrix(libc.stdio.FILE *, @dd@_Amatrix, @dd@_rowrange, @dd@_colrange)
cdef void @dd@_WriteArow(libc.stdio.FILE *f, @dd@_Arow a, @dd@_colrange)
cdef void @dd@_WriteBmatrix(libc.stdio.FILE *, @dd@_colrange, @dd@_Bmatrix T)
cdef void @dd@_WriteMatrix(libc.stdio.FILE *, @dd@_MatrixPtr)
cdef void @dd@_MatrixIntegerFilter(@dd@_MatrixPtr)
cdef void @dd@_WriteReal(libc.stdio.FILE *, @mytype@)
cdef void @dd@_WriteNumber(libc.stdio.FILE *f, @mytype@ x)
cdef void @dd@_WritePolyFile(libc.stdio.FILE *, @dd@_PolyhedraPtr)
cdef void @dd@_WriteRunningMode(libc.stdio.FILE *, @dd@_PolyhedraPtr)
cdef void @dd@_WriteErrorMessages(libc.stdio.FILE *, @dd@_ErrorType)
cdef void @dd@_WriteSetFamily(libc.stdio.FILE *, @dd@_SetFamilyPtr)
cdef void @dd@_WriteSetFamilyCompressed(libc.stdio.FILE *, @dd@_SetFamilyPtr)
cdef void @dd@_WriteProgramDescription(libc.stdio.FILE *)
cdef void @dd@_WriteDDTimes(libc.stdio.FILE *, @dd@_PolyhedraPtr)
cdef void @dd@_WriteTimes(libc.stdio.FILE *, time_t, time_t)
cdef void @dd@_WriteIncidence(libc.stdio.FILE *, @dd@_PolyhedraPtr)
cdef void @dd@_WriteAdjacency(libc.stdio.FILE *, @dd@_PolyhedraPtr)
cdef void @dd@_WriteInputAdjacency(libc.stdio.FILE *, @dd@_PolyhedraPtr)
cdef void @dd@_WriteInputIncidence(libc.stdio.FILE *, @dd@_PolyhedraPtr)
cdef @dd@_LPPtr @dd@_Matrix2LP(@dd@_MatrixPtr, @dd@_ErrorType *)
cdef @dd@_boolean @dd@_LPSolve(@dd@_LPPtr, @dd@_LPSolverType, @dd@_ErrorType *)
cdef void @dd@_FreeLPData(@dd@_LPPtr)
cdef void @dd@_WriteLP(libc.stdio.FILE *f, @dd@_LPPtr lp)
cdef void @dd@_WriteLPResult(libc.stdio.FILE *f, @dd@_LPPtr lp, @dd@_ErrorType err)