package lp-glpk

  1. Overview
  2. Docs

Source file g.ml

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
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
module CI = Cstubs_internals

external lp_glpk_stub_1_glp_term_out : int -> unit
  = "lp_glpk_stub_1_glp_term_out" 

external lp_glpk_stub_2_glp_create_prob : unit -> CI.voidp
  = "lp_glpk_stub_2_glp_create_prob" 

external lp_glpk_stub_3_glp_delete_prob : _ CI.fatptr -> unit
  = "lp_glpk_stub_3_glp_delete_prob" 

external lp_glpk_stub_4_glp_set_prob_name
  : _ CI.fatptr -> _ CI.fatptr -> unit = "lp_glpk_stub_4_glp_set_prob_name" 

external lp_glpk_stub_5_glp_get_prob_name : _ CI.fatptr -> CI.voidp
  = "lp_glpk_stub_5_glp_get_prob_name" 

external lp_glpk_stub_6_glp_set_obj_dir : _ CI.fatptr -> int -> unit
  = "lp_glpk_stub_6_glp_set_obj_dir" 

external lp_glpk_stub_7_glp_get_obj_dir : _ CI.fatptr -> int
  = "lp_glpk_stub_7_glp_get_obj_dir" 

external lp_glpk_stub_8_glp_add_rows : _ CI.fatptr -> int -> int
  = "lp_glpk_stub_8_glp_add_rows" 

external lp_glpk_stub_9_glp_add_cols : _ CI.fatptr -> int -> int
  = "lp_glpk_stub_9_glp_add_cols" 

external lp_glpk_stub_10_glp_set_row_name
  : _ CI.fatptr -> int -> _ CI.fatptr -> unit
  = "lp_glpk_stub_10_glp_set_row_name" 

external lp_glpk_stub_11_glp_get_row_name : _ CI.fatptr -> int -> CI.voidp
  = "lp_glpk_stub_11_glp_get_row_name" 

external lp_glpk_stub_12_glp_set_col_name
  : _ CI.fatptr -> int -> _ CI.fatptr -> unit
  = "lp_glpk_stub_12_glp_set_col_name" 

external lp_glpk_stub_13_glp_get_col_name : _ CI.fatptr -> int -> CI.voidp
  = "lp_glpk_stub_13_glp_get_col_name" 

external lp_glpk_stub_14_glp_set_row_bnds
  : _ CI.fatptr -> int -> int -> float -> float -> unit
  = "lp_glpk_stub_14_glp_set_row_bnds" 

external lp_glpk_stub_15_glp_set_col_bnds
  : _ CI.fatptr -> int -> int -> float -> float -> unit
  = "lp_glpk_stub_15_glp_set_col_bnds" 

external lp_glpk_stub_16_glp_set_obj_coef
  : _ CI.fatptr -> int -> float -> unit = "lp_glpk_stub_16_glp_set_obj_coef" 

external lp_glpk_stub_17_glp_set_mat_row
  : _ CI.fatptr -> int -> int -> _ CI.fatptr -> _ CI.fatptr -> unit
  = "lp_glpk_stub_17_glp_set_mat_row" 

external lp_glpk_stub_18_glp_set_mat_col
  : _ CI.fatptr -> int -> int -> _ CI.fatptr -> _ CI.fatptr -> unit
  = "lp_glpk_stub_18_glp_set_mat_col" 

external lp_glpk_stub_19_glp_load_matrix
  : _ CI.fatptr -> int -> _ CI.fatptr -> _ CI.fatptr -> _ CI.fatptr -> unit
  = "lp_glpk_stub_19_glp_load_matrix" 

external lp_glpk_stub_20_glp_set_col_kind : _ CI.fatptr -> int -> int -> unit
  = "lp_glpk_stub_20_glp_set_col_kind" 

external lp_glpk_stub_21_glp_get_col_kind : _ CI.fatptr -> int -> int
  = "lp_glpk_stub_21_glp_get_col_kind" 

external lp_glpk_stub_22_glp_get_num_rows : _ CI.fatptr -> int
  = "lp_glpk_stub_22_glp_get_num_rows" 

external lp_glpk_stub_23_glp_get_num_cols : _ CI.fatptr -> int
  = "lp_glpk_stub_23_glp_get_num_cols" 

external lp_glpk_stub_24_glp_get_num_nz : _ CI.fatptr -> int
  = "lp_glpk_stub_24_glp_get_num_nz" 

external lp_glpk_stub_25_glp_get_num_int : _ CI.fatptr -> int
  = "lp_glpk_stub_25_glp_get_num_int" 

external lp_glpk_stub_26_glp_get_num_bin : _ CI.fatptr -> int
  = "lp_glpk_stub_26_glp_get_num_bin" 

external lp_glpk_stub_27_glp_init_smcp : _ CI.fatptr -> unit
  = "lp_glpk_stub_27_glp_init_smcp" 

external lp_glpk_stub_28_glp_init_iocp : _ CI.fatptr -> unit
  = "lp_glpk_stub_28_glp_init_iocp" 

external lp_glpk_stub_29_glp_simplex : _ CI.fatptr -> _ CI.fatptr -> int
  = "lp_glpk_stub_29_glp_simplex" 

external lp_glpk_stub_30_glp_intopt : _ CI.fatptr -> _ CI.fatptr -> int
  = "lp_glpk_stub_30_glp_intopt" 

external lp_glpk_stub_31_glp_get_status : _ CI.fatptr -> int
  = "lp_glpk_stub_31_glp_get_status" 

external lp_glpk_stub_32_glp_mip_status : _ CI.fatptr -> int
  = "lp_glpk_stub_32_glp_mip_status" 

external lp_glpk_stub_33_glp_get_obj_val : _ CI.fatptr -> float
  = "lp_glpk_stub_33_glp_get_obj_val" 

external lp_glpk_stub_34_glp_mip_obj_val : _ CI.fatptr -> float
  = "lp_glpk_stub_34_glp_mip_obj_val" 

external lp_glpk_stub_35_glp_get_row_prim : _ CI.fatptr -> int -> float
  = "lp_glpk_stub_35_glp_get_row_prim" 

external lp_glpk_stub_36_glp_get_row_dual : _ CI.fatptr -> int -> float
  = "lp_glpk_stub_36_glp_get_row_dual" 

external lp_glpk_stub_37_glp_mip_row_val : _ CI.fatptr -> int -> float
  = "lp_glpk_stub_37_glp_mip_row_val" 

external lp_glpk_stub_38_glp_get_col_prim : _ CI.fatptr -> int -> float
  = "lp_glpk_stub_38_glp_get_col_prim" 

external lp_glpk_stub_39_glp_get_col_dual : _ CI.fatptr -> int -> float
  = "lp_glpk_stub_39_glp_get_col_dual" 

external lp_glpk_stub_40_glp_mip_col_val : _ CI.fatptr -> int -> float
  = "lp_glpk_stub_40_glp_mip_col_val" 

type 'a result = 'a
type 'a return = 'a
type 'a fn =
 | Returns  : 'a CI.typ   -> 'a return fn
 | Function : 'a CI.typ * 'b fn  -> ('a -> 'b) fn
let map_result f x = f x
let returning t = Returns t
let (@->) f p = Function (f, p)
let foreign : type a b. string -> (a -> b) fn -> (a -> b) =
  fun name t -> match t, name with
| Function
    (CI.Pointer _,
     Function (CI.Primitive CI.Int, Returns (CI.Primitive CI.Double))),
  "glp_mip_col_val" ->
  (fun x1 x3 ->
    let CI.CPointer x2 = x1 in lp_glpk_stub_40_glp_mip_col_val x2 x3)
| Function
    (CI.Pointer _,
     Function (CI.Primitive CI.Int, Returns (CI.Primitive CI.Double))),
  "glp_get_col_dual" ->
  (fun x4 x6 ->
    let CI.CPointer x5 = x4 in lp_glpk_stub_39_glp_get_col_dual x5 x6)
| Function
    (CI.Pointer _,
     Function (CI.Primitive CI.Int, Returns (CI.Primitive CI.Double))),
  "glp_get_col_prim" ->
  (fun x7 x9 ->
    let CI.CPointer x8 = x7 in lp_glpk_stub_38_glp_get_col_prim x8 x9)
| Function
    (CI.Pointer _,
     Function (CI.Primitive CI.Int, Returns (CI.Primitive CI.Double))),
  "glp_mip_row_val" ->
  (fun x10 x12 ->
    let CI.CPointer x11 = x10 in lp_glpk_stub_37_glp_mip_row_val x11 x12)
| Function
    (CI.Pointer _,
     Function (CI.Primitive CI.Int, Returns (CI.Primitive CI.Double))),
  "glp_get_row_dual" ->
  (fun x13 x15 ->
    let CI.CPointer x14 = x13 in lp_glpk_stub_36_glp_get_row_dual x14 x15)
| Function
    (CI.Pointer _,
     Function (CI.Primitive CI.Int, Returns (CI.Primitive CI.Double))),
  "glp_get_row_prim" ->
  (fun x16 x18 ->
    let CI.CPointer x17 = x16 in lp_glpk_stub_35_glp_get_row_prim x17 x18)
| Function (CI.Pointer _, Returns (CI.Primitive CI.Double)),
  "glp_mip_obj_val" ->
  (fun x19 ->
    let CI.CPointer x20 = x19 in lp_glpk_stub_34_glp_mip_obj_val x20)
| Function (CI.Pointer _, Returns (CI.Primitive CI.Double)),
  "glp_get_obj_val" ->
  (fun x21 ->
    let CI.CPointer x22 = x21 in lp_glpk_stub_33_glp_get_obj_val x22)
| Function
    (CI.Pointer _,
     Returns (CI.View {CI.ty = CI.Primitive CI.Int; read = x25; _})),
  "glp_mip_status" ->
  (fun x23 ->
    let CI.CPointer x24 = x23 in x25 (lp_glpk_stub_32_glp_mip_status x24))
| Function
    (CI.Pointer _,
     Returns (CI.View {CI.ty = CI.Primitive CI.Int; read = x28; _})),
  "glp_get_status" ->
  (fun x26 ->
    let CI.CPointer x27 = x26 in x28 (lp_glpk_stub_31_glp_get_status x27))
| Function
    (CI.Pointer _,
     Function
       (CI.Pointer _,
        Returns (CI.View {CI.ty = CI.Primitive CI.Int; read = x33; _}))),
  "glp_intopt" ->
  (fun x29 x31 ->
    let CI.CPointer x32 = x31 in
    let CI.CPointer x30 = x29 in x33 (lp_glpk_stub_30_glp_intopt x30 x32))
| Function
    (CI.Pointer _,
     Function
       (CI.Pointer _,
        Returns (CI.View {CI.ty = CI.Primitive CI.Int; read = x38; _}))),
  "glp_simplex" ->
  (fun x34 x36 ->
    let CI.CPointer x37 = x36 in
    let CI.CPointer x35 = x34 in x38 (lp_glpk_stub_29_glp_simplex x35 x37))
| Function (CI.Pointer _, Returns CI.Void), "glp_init_iocp" ->
  (fun x39 -> let CI.CPointer x40 = x39 in lp_glpk_stub_28_glp_init_iocp x40)
| Function (CI.Pointer _, Returns CI.Void), "glp_init_smcp" ->
  (fun x41 -> let CI.CPointer x42 = x41 in lp_glpk_stub_27_glp_init_smcp x42)
| Function (CI.Pointer _, Returns (CI.Primitive CI.Int)), "glp_get_num_bin" ->
  (fun x43 ->
    let CI.CPointer x44 = x43 in lp_glpk_stub_26_glp_get_num_bin x44)
| Function (CI.Pointer _, Returns (CI.Primitive CI.Int)), "glp_get_num_int" ->
  (fun x45 ->
    let CI.CPointer x46 = x45 in lp_glpk_stub_25_glp_get_num_int x46)
| Function (CI.Pointer _, Returns (CI.Primitive CI.Int)), "glp_get_num_nz" ->
  (fun x47 ->
    let CI.CPointer x48 = x47 in lp_glpk_stub_24_glp_get_num_nz x48)
| Function (CI.Pointer _, Returns (CI.Primitive CI.Int)), "glp_get_num_cols" ->
  (fun x49 ->
    let CI.CPointer x50 = x49 in lp_glpk_stub_23_glp_get_num_cols x50)
| Function (CI.Pointer _, Returns (CI.Primitive CI.Int)), "glp_get_num_rows" ->
  (fun x51 ->
    let CI.CPointer x52 = x51 in lp_glpk_stub_22_glp_get_num_rows x52)
| Function
    (CI.Pointer _,
     Function
       (CI.Primitive CI.Int,
        Returns (CI.View {CI.ty = CI.Primitive CI.Int; read = x56; _}))),
  "glp_get_col_kind" ->
  (fun x53 x55 ->
    let CI.CPointer x54 = x53 in
    x56 (lp_glpk_stub_21_glp_get_col_kind x54 x55))
| Function
    (CI.Pointer _,
     Function
       (CI.Primitive CI.Int,
        Function
          (CI.View {CI.ty = CI.Primitive CI.Int; write = x61; _},
           Returns CI.Void))),
  "glp_set_col_kind" ->
  (fun x57 x59 x60 ->
    let CI.CPointer x58 = x57 in
    let x62 = x61 x60 in lp_glpk_stub_20_glp_set_col_kind x58 x59 x62)
| Function
    (CI.Pointer _,
     Function
       (CI.Primitive CI.Int,
        Function
          (CI.Pointer _,
           Function (CI.Pointer _, Function (CI.Pointer _, Returns CI.Void))))),
  "glp_load_matrix" ->
  (fun x63 x65 x66 x68 x70 ->
    let CI.CPointer x71 = x70 in
    let CI.CPointer x69 = x68 in
    let CI.CPointer x67 = x66 in
    let CI.CPointer x64 = x63 in
    lp_glpk_stub_19_glp_load_matrix x64 x65 x67 x69 x71)
| Function
    (CI.Pointer _,
     Function
       (CI.Primitive CI.Int,
        Function
          (CI.Primitive CI.Int,
           Function (CI.Pointer _, Function (CI.Pointer _, Returns CI.Void))))),
  "glp_set_mat_col" ->
  (fun x72 x74 x75 x76 x78 ->
    let CI.CPointer x79 = x78 in
    let CI.CPointer x77 = x76 in
    let CI.CPointer x73 = x72 in
    lp_glpk_stub_18_glp_set_mat_col x73 x74 x75 x77 x79)
| Function
    (CI.Pointer _,
     Function
       (CI.Primitive CI.Int,
        Function
          (CI.Primitive CI.Int,
           Function (CI.Pointer _, Function (CI.Pointer _, Returns CI.Void))))),
  "glp_set_mat_row" ->
  (fun x80 x82 x83 x84 x86 ->
    let CI.CPointer x87 = x86 in
    let CI.CPointer x85 = x84 in
    let CI.CPointer x81 = x80 in
    lp_glpk_stub_17_glp_set_mat_row x81 x82 x83 x85 x87)
| Function
    (CI.Pointer _,
     Function
       (CI.Primitive CI.Int,
        Function (CI.Primitive CI.Double, Returns CI.Void))),
  "glp_set_obj_coef" ->
  (fun x88 x90 x91 ->
    let CI.CPointer x89 = x88 in lp_glpk_stub_16_glp_set_obj_coef x89 x90 x91)
| Function
    (CI.Pointer _,
     Function
       (CI.Primitive CI.Int,
        Function
          (CI.View {CI.ty = CI.Primitive CI.Int; write = x96; _},
           Function
             (CI.Primitive CI.Double,
              Function (CI.Primitive CI.Double, Returns CI.Void))))),
  "glp_set_col_bnds" ->
  (fun x92 x94 x95 x98 x99 ->
    let CI.CPointer x93 = x92 in
    let x97 = x96 x95 in lp_glpk_stub_15_glp_set_col_bnds x93 x94 x97 x98 x99)
| Function
    (CI.Pointer _,
     Function
       (CI.Primitive CI.Int,
        Function
          (CI.View {CI.ty = CI.Primitive CI.Int; write = x104; _},
           Function
             (CI.Primitive CI.Double,
              Function (CI.Primitive CI.Double, Returns CI.Void))))),
  "glp_set_row_bnds" ->
  (fun x100 x102 x103 x106 x107 ->
    let CI.CPointer x101 = x100 in
    let x105 = x104 x103 in
    lp_glpk_stub_14_glp_set_row_bnds x101 x102 x105 x106 x107)
| Function
    (CI.Pointer _,
     Function
       (CI.Primitive CI.Int,
        Returns (CI.View {CI.ty = CI.Pointer x111; read = x112; _}))),
  "glp_get_col_name" ->
  (fun x108 x110 ->
    let CI.CPointer x109 = x108 in
    x112 (CI.make_ptr x111 (lp_glpk_stub_13_glp_get_col_name x109 x110)))
| Function
    (CI.Pointer _,
     Function
       (CI.Primitive CI.Int,
        Function
          (CI.View {CI.ty = CI.Pointer _; write = x117; _}, Returns CI.Void))),
  "glp_set_col_name" ->
  (fun x113 x115 x116 ->
    let CI.CPointer x119 = x117 x116 in
    let CI.CPointer x114 = x113 in
    let x118 = x119 in lp_glpk_stub_12_glp_set_col_name x114 x115 x118)
| Function
    (CI.Pointer _,
     Function
       (CI.Primitive CI.Int,
        Returns (CI.View {CI.ty = CI.Pointer x123; read = x124; _}))),
  "glp_get_row_name" ->
  (fun x120 x122 ->
    let CI.CPointer x121 = x120 in
    x124 (CI.make_ptr x123 (lp_glpk_stub_11_glp_get_row_name x121 x122)))
| Function
    (CI.Pointer _,
     Function
       (CI.Primitive CI.Int,
        Function
          (CI.View {CI.ty = CI.Pointer _; write = x129; _}, Returns CI.Void))),
  "glp_set_row_name" ->
  (fun x125 x127 x128 ->
    let CI.CPointer x131 = x129 x128 in
    let CI.CPointer x126 = x125 in
    let x130 = x131 in lp_glpk_stub_10_glp_set_row_name x126 x127 x130)
| Function
    (CI.Pointer _,
     Function (CI.Primitive CI.Int, Returns (CI.Primitive CI.Int))),
  "glp_add_cols" ->
  (fun x132 x134 ->
    let CI.CPointer x133 = x132 in lp_glpk_stub_9_glp_add_cols x133 x134)
| Function
    (CI.Pointer _,
     Function (CI.Primitive CI.Int, Returns (CI.Primitive CI.Int))),
  "glp_add_rows" ->
  (fun x135 x137 ->
    let CI.CPointer x136 = x135 in lp_glpk_stub_8_glp_add_rows x136 x137)
| Function
    (CI.Pointer _,
     Returns (CI.View {CI.ty = CI.Primitive CI.Int; read = x140; _})),
  "glp_get_obj_dir" ->
  (fun x138 ->
    let CI.CPointer x139 = x138 in x140 (lp_glpk_stub_7_glp_get_obj_dir x139))
| Function
    (CI.Pointer _,
     Function
       (CI.View {CI.ty = CI.Primitive CI.Int; write = x144; _},
        Returns CI.Void)),
  "glp_set_obj_dir" ->
  (fun x141 x143 ->
    let CI.CPointer x142 = x141 in
    let x145 = x144 x143 in lp_glpk_stub_6_glp_set_obj_dir x142 x145)
| Function
    (CI.Pointer _,
     Returns (CI.View {CI.ty = CI.Pointer x148; read = x149; _})),
  "glp_get_prob_name" ->
  (fun x146 ->
    let CI.CPointer x147 = x146 in
    x149 (CI.make_ptr x148 (lp_glpk_stub_5_glp_get_prob_name x147)))
| Function
    (CI.Pointer _,
     Function
       (CI.View {CI.ty = CI.Pointer _; write = x153; _}, Returns CI.Void)),
  "glp_set_prob_name" ->
  (fun x150 x152 ->
    let CI.CPointer x155 = x153 x152 in
    let CI.CPointer x151 = x150 in
    let x154 = x155 in lp_glpk_stub_4_glp_set_prob_name x151 x154)
| Function (CI.Pointer _, Returns CI.Void), "glp_delete_prob" ->
  (fun x156 ->
    let CI.CPointer x157 = x156 in lp_glpk_stub_3_glp_delete_prob x157)
| Function (CI.Void, Returns (CI.Pointer x159)), "glp_create_prob" ->
  (fun x158 -> CI.make_ptr x159 (lp_glpk_stub_2_glp_create_prob x158))
| Function
    (CI.View {CI.ty = CI.Primitive CI.Int; write = x161; _}, Returns CI.Void),
  "glp_term_out" ->
  (fun x160 -> let x162 = x161 x160 in lp_glpk_stub_1_glp_term_out x162)
| _, s ->  Printf.ksprintf failwith "No match for %s" s


let foreign_value : type a. string -> a Ctypes.typ -> a Ctypes.ptr =
  fun name t -> match t, name with
| _, s ->  Printf.ksprintf failwith "No match for %s" s

OCaml

Innovation. Community. Security.