summaryrefslogtreecommitdiffstats
path: root/external
diff options
context:
space:
mode:
Diffstat (limited to 'external')
-rw-r--r--external/glpk/dune17
-rw-r--r--external/glpk/function_description.ml37
-rw-r--r--external/glpk/type_description.ml24
3 files changed, 78 insertions, 0 deletions
diff --git a/external/glpk/dune b/external/glpk/dune
new file mode 100644
index 0000000..5d75615
--- /dev/null
+++ b/external/glpk/dune
@@ -0,0 +1,17 @@
+; SPDX-FileCopyrightText: Copyright 2025 Alexandre Jesus <https://adbjesus.com>
+;
+; SPDX-License-Identifier: CC0-1.0
+
+(library
+ (name glpk)
+ (ctypes
+ (external_library_name glpk)
+ (headers (include "glpk.h"))
+ (type_description
+ (instance Types)
+ (functor Type_description))
+ (function_description
+ (instance Functions)
+ (functor Function_description))
+ (generated_types Types_generated)
+ (generated_entry_point C))) \ No newline at end of file
diff --git a/external/glpk/function_description.ml b/external/glpk/function_description.ml
new file mode 100644
index 0000000..3dd469a
--- /dev/null
+++ b/external/glpk/function_description.ml
@@ -0,0 +1,37 @@
+open Ctypes
+
+module Types = Types_generated
+
+module Functions (F : Ctypes.FOREIGN) = struct
+ open F
+
+ let glp_create_prob = foreign "glp_create_prob" (void @-> returning Types.glp_prob)
+
+ let glp_delete_prob = foreign "glp_delete_prob" (Types.glp_prob @-> returning void)
+
+ let glp_add_rows = foreign "glp_add_rows" (Types.glp_prob @-> int @-> returning void)
+
+ let glp_add_cols = foreign "glp_add_cols" (Types.glp_prob @-> int @-> returning void)
+
+ let glp_set_row_bnds = foreign "glp_set_row_bnds" (Types.glp_prob @-> int @-> int @-> double @-> double @-> returning void)
+
+ let glp_set_col_bnds = foreign "glp_set_col_bnds" (Types.glp_prob @-> int @-> int @-> double @-> double @-> returning void)
+
+ let glp_set_col_kind = foreign "glp_set_col_kind" (Types.glp_prob @-> int @-> int @-> returning void)
+
+ let glp_set_obj_coef = foreign "glp_set_obj_coef" (Types.glp_prob @-> int @-> double @-> returning void)
+
+ let glp_set_obj_dir = foreign "glp_set_obj_dir" (Types.glp_prob @-> int @-> returning void)
+
+ let glp_set_mat_col = foreign "glp_set_mat_col" (Types.glp_prob @-> int @-> int @-> ptr int @-> ptr double @-> returning void)
+
+ let glp_simplex = foreign "glp_simplex" (Types.glp_prob @-> Types.glp_smcp_ptr @-> returning void)
+
+ let glp_intopt = foreign "glp_intopt" (Types.glp_prob @-> Types.glp_iocp_ptr @-> returning void)
+
+ let glp_mip_status = foreign "glp_mip_status" (Types.glp_prob @-> returning int)
+
+ let glp_mip_obj_val = foreign "glp_mip_obj_val" (Types.glp_prob @-> returning double)
+
+ let glp_term_out = foreign "glp_term_out" (int @-> returning int)
+end
diff --git a/external/glpk/type_description.ml b/external/glpk/type_description.ml
new file mode 100644
index 0000000..620b82b
--- /dev/null
+++ b/external/glpk/type_description.ml
@@ -0,0 +1,24 @@
+open Ctypes
+
+module Types (F: Ctypes.TYPE) = struct
+ open F
+
+ type glp_prob = unit ptr
+ let glp_prob : glp_prob typ = ptr void
+
+ type glp_iocp_ptr = unit ptr
+ let glp_iocp_ptr : glp_iocp_ptr typ = ptr void
+
+ type glp_smcp
+ let glp_smcp : glp_smcp structure typ = structure "glp_smcp"
+
+ type glp_smcp_ptr = unit ptr
+ let glp_smcp_ptr : glp_smcp_ptr typ = ptr void
+
+ let glp_min = constant "GLP_MIN" int
+ let glp_fx = constant "GLP_FX" int
+ let glp_lo = constant "GLP_LO" int
+ let glp_opt = constant "GLP_OPT" int
+ let glp_iv = constant "GLP_IV" int
+ let glp_off = constant "GLP_OFF" int
+end