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
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.Primitive CI.Int))),
  "glp_intopt" ->
  (fun x29 x31 ->
    let CI.CPointer x32 = x31 in
    let CI.CPointer x30 = x29 in lp_glpk_stub_30_glp_intopt x30 x32)
| Function
    (CI.Pointer _, Function (CI.Pointer _, Returns (CI.Primitive CI.Int))),
  "glp_simplex" ->
  (fun x33 x35 ->
    let CI.CPointer x36 = x35 in
    let CI.CPointer x34 = x33 in lp_glpk_stub_29_glp_simplex x34 x36)
| Function (CI.Pointer _, Returns CI.Void), "glp_init_iocp" ->
  (fun x37 -> let CI.CPointer x38 = x37 in lp_glpk_stub_28_glp_init_iocp x38)
| Function (CI.Pointer _, Returns CI.Void), "glp_init_smcp" ->
  (fun x39 -> let CI.CPointer x40 = x39 in lp_glpk_stub_27_glp_init_smcp x40)
| Function (CI.Pointer _, Returns (CI.Primitive CI.Int)), "glp_get_num_bin" ->
  (fun x41 ->
    let CI.CPointer x42 = x41 in lp_glpk_stub_26_glp_get_num_bin x42)
| Function (CI.Pointer _, Returns (CI.Primitive CI.Int)), "glp_get_num_int" ->
  (fun x43 ->
    let CI.CPointer x44 = x43 in lp_glpk_stub_25_glp_get_num_int x44)
| Function (CI.Pointer _, Returns (CI.Primitive CI.Int)), "glp_get_num_nz" ->
  (fun x45 ->
    let CI.CPointer x46 = x45 in lp_glpk_stub_24_glp_get_num_nz x46)
| Function (CI.Pointer _, Returns (CI.Primitive CI.Int)), "glp_get_num_cols" ->
  (fun x47 ->
    let CI.CPointer x48 = x47 in lp_glpk_stub_23_glp_get_num_cols x48)
| Function (CI.Pointer _, Returns (CI.Primitive CI.Int)), "glp_get_num_rows" ->
  (fun x49 ->
    let CI.CPointer x50 = x49 in lp_glpk_stub_22_glp_get_num_rows x50)
| Function
    (CI.Pointer _,
     Function
       (CI.Primitive CI.Int,
        Returns (CI.View {CI.ty = CI.Primitive CI.Int; read = x54; _}))),
  "glp_get_col_kind" ->
  (fun x51 x53 ->
    let CI.CPointer x52 = x51 in
    x54 (lp_glpk_stub_21_glp_get_col_kind x52 x53))
| Function
    (CI.Pointer _,
     Function
       (CI.Primitive CI.Int,
        Function
          (CI.View {CI.ty = CI.Primitive CI.Int; write = x59; _},
           Returns CI.Void))),
  "glp_set_col_kind" ->
  (fun x55 x57 x58 ->
    let CI.CPointer x56 = x55 in
    let x60 = x59 x58 in lp_glpk_stub_20_glp_set_col_kind x56 x57 x60)
| Function
    (CI.Pointer _,
     Function
       (CI.Primitive CI.Int,
        Function
          (CI.Pointer _,
           Function (CI.Pointer _, Function (CI.Pointer _, Returns CI.Void))))),
  "glp_load_matrix" ->
  (fun x61 x63 x64 x66 x68 ->
    let CI.CPointer x69 = x68 in
    let CI.CPointer x67 = x66 in
    let CI.CPointer x65 = x64 in
    let CI.CPointer x62 = x61 in
    lp_glpk_stub_19_glp_load_matrix x62 x63 x65 x67 x69)
| 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 x70 x72 x73 x74 x76 ->
    let CI.CPointer x77 = x76 in
    let CI.CPointer x75 = x74 in
    let CI.CPointer x71 = x70 in
    lp_glpk_stub_18_glp_set_mat_col x71 x72 x73 x75 x77)
| 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 x78 x80 x81 x82 x84 ->
    let CI.CPointer x85 = x84 in
    let CI.CPointer x83 = x82 in
    let CI.CPointer x79 = x78 in
    lp_glpk_stub_17_glp_set_mat_row x79 x80 x81 x83 x85)
| Function
    (CI.Pointer _,
     Function
       (CI.Primitive CI.Int,
        Function (CI.Primitive CI.Double, Returns CI.Void))),
  "glp_set_obj_coef" ->
  (fun x86 x88 x89 ->
    let CI.CPointer x87 = x86 in lp_glpk_stub_16_glp_set_obj_coef x87 x88 x89)
| Function
    (CI.Pointer _,
     Function
       (CI.Primitive CI.Int,
        Function
          (CI.View {CI.ty = CI.Primitive CI.Int; write = x94; _},
           Function
             (CI.Primitive CI.Double,
              Function (CI.Primitive CI.Double, Returns CI.Void))))),
  "glp_set_col_bnds" ->
  (fun x90 x92 x93 x96 x97 ->
    let CI.CPointer x91 = x90 in
    let x95 = x94 x93 in lp_glpk_stub_15_glp_set_col_bnds x91 x92 x95 x96 x97)
| Function
    (CI.Pointer _,
     Function
       (CI.Primitive CI.Int,
        Function
          (CI.View {CI.ty = CI.Primitive CI.Int; write = x102; _},
           Function
             (CI.Primitive CI.Double,
              Function (CI.Primitive CI.Double, Returns CI.Void))))),
  "glp_set_row_bnds" ->
  (fun x98 x100 x101 x104 x105 ->
    let CI.CPointer x99 = x98 in
    let x103 = x102 x101 in
    lp_glpk_stub_14_glp_set_row_bnds x99 x100 x103 x104 x105)
| Function
    (CI.Pointer _,
     Function
       (CI.Primitive CI.Int,
        Returns (CI.View {CI.ty = CI.Pointer x109; read = x110; _}))),
  "glp_get_col_name" ->
  (fun x106 x108 ->
    let CI.CPointer x107 = x106 in
    x110 (CI.make_ptr x109 (lp_glpk_stub_13_glp_get_col_name x107 x108)))
| Function
    (CI.Pointer _,
     Function
       (CI.Primitive CI.Int,
        Function
          (CI.View {CI.ty = CI.Pointer _; write = x115; _}, Returns CI.Void))),
  "glp_set_col_name" ->
  (fun x111 x113 x114 ->
    let CI.CPointer x117 = x115 x114 in
    let CI.CPointer x112 = x111 in
    let x116 = x117 in lp_glpk_stub_12_glp_set_col_name x112 x113 x116)
| Function
    (CI.Pointer _,
     Function
       (CI.Primitive CI.Int,
        Returns (CI.View {CI.ty = CI.Pointer x121; read = x122; _}))),
  "glp_get_row_name" ->
  (fun x118 x120 ->
    let CI.CPointer x119 = x118 in
    x122 (CI.make_ptr x121 (lp_glpk_stub_11_glp_get_row_name x119 x120)))
| Function
    (CI.Pointer _,
     Function
       (CI.Primitive CI.Int,
        Function
          (CI.View {CI.ty = CI.Pointer _; write = x127; _}, Returns CI.Void))),
  "glp_set_row_name" ->
  (fun x123 x125 x126 ->
    let CI.CPointer x129 = x127 x126 in
    let CI.CPointer x124 = x123 in
    let x128 = x129 in lp_glpk_stub_10_glp_set_row_name x124 x125 x128)
| Function
    (CI.Pointer _,
     Function (CI.Primitive CI.Int, Returns (CI.Primitive CI.Int))),
  "glp_add_cols" ->
  (fun x130 x132 ->
    let CI.CPointer x131 = x130 in lp_glpk_stub_9_glp_add_cols x131 x132)
| Function
    (CI.Pointer _,
     Function (CI.Primitive CI.Int, Returns (CI.Primitive CI.Int))),
  "glp_add_rows" ->
  (fun x133 x135 ->
    let CI.CPointer x134 = x133 in lp_glpk_stub_8_glp_add_rows x134 x135)
| Function
    (CI.Pointer _,
     Returns (CI.View {CI.ty = CI.Primitive CI.Int; read = x138; _})),
  "glp_get_obj_dir" ->
  (fun x136 ->
    let CI.CPointer x137 = x136 in x138 (lp_glpk_stub_7_glp_get_obj_dir x137))
| Function
    (CI.Pointer _,
     Function
       (CI.View {CI.ty = CI.Primitive CI.Int; write = x142; _},
        Returns CI.Void)),
  "glp_set_obj_dir" ->
  (fun x139 x141 ->
    let CI.CPointer x140 = x139 in
    let x143 = x142 x141 in lp_glpk_stub_6_glp_set_obj_dir x140 x143)
| Function
    (CI.Pointer _,
     Returns (CI.View {CI.ty = CI.Pointer x146; read = x147; _})),
  "glp_get_prob_name" ->
  (fun x144 ->
    let CI.CPointer x145 = x144 in
    x147 (CI.make_ptr x146 (lp_glpk_stub_5_glp_get_prob_name x145)))
| Function
    (CI.Pointer _,
     Function
       (CI.View {CI.ty = CI.Pointer _; write = x151; _}, Returns CI.Void)),
  "glp_set_prob_name" ->
  (fun x148 x150 ->
    let CI.CPointer x153 = x151 x150 in
    let CI.CPointer x149 = x148 in
    let x152 = x153 in lp_glpk_stub_4_glp_set_prob_name x149 x152)
| Function (CI.Pointer _, Returns CI.Void), "glp_delete_prob" ->
  (fun x154 ->
    let CI.CPointer x155 = x154 in lp_glpk_stub_3_glp_delete_prob x155)
| Function (CI.Void, Returns (CI.Pointer x157)), "glp_create_prob" ->
  (fun x156 -> CI.make_ptr x157 (lp_glpk_stub_2_glp_create_prob x156))
| Function
    (CI.View {CI.ty = CI.Primitive CI.Int; write = x159; _}, Returns CI.Void),
  "glp_term_out" ->
  (fun x158 -> let x160 = x159 x158 in lp_glpk_stub_1_glp_term_out x160)
| _, 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.