changeset 6333:4e81fe3bceff

[project @ 2007-02-20 21:05:10 by jwe]
author jwe
date Tue, 20 Feb 2007 21:05:11 +0000
parents debb662eab07
children 877b80a8dee7
files ChangeLog configure.in scripts/ChangeLog scripts/optimization/glpk.m src/ChangeLog src/DLD-FUNCTIONS/__glpk__.cc
diffstat 6 files changed, 55 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Feb 20 20:41:35 2007 +0000
+++ b/ChangeLog	Tue Feb 20 21:05:11 2007 +0000
@@ -1,3 +1,8 @@
+2007-02-20  Rafael Laboissiere  <rafael@debian.org>
+
+	* configure.in: Check for versions of GLPK prior to 4.15 and set
+	the GLPK_PRE_4_15 macro accordingly.
+
 2007-02-16  John W. Eaton  <jwe@octave.org>
 
 	* mkoctfile.in: Use OCTAVE_PREFIX, not OCTAVE_CONF_PREFIX, in sed
--- a/configure.in	Tue Feb 20 20:41:35 2007 +0000
+++ b/configure.in	Tue Feb 20 21:05:11 2007 +0000
@@ -29,7 +29,7 @@
 EXTERN_CXXFLAGS="$CXXFLAGS"
 
 AC_INIT
-AC_REVISION($Revision: 1.555 $)
+AC_REVISION($Revision: 1.556 $)
 AC_PREREQ(2.57)
 AC_CONFIG_SRCDIR([src/octave.cc])
 AC_CONFIG_HEADER(config.h)
@@ -590,7 +590,9 @@
 
 GLPK_LIBS=
 if test -n "$glpk_lib"; then
-  AC_CHECK_LIB($glpk_lib, glp_lpx_simplex, [GLPK_LIBS="-l$glpk_lib"], [
+  AC_CHECK_LIB($glpk_lib, glp_lpx_simplex, [
+    GLPK_LIBS="-l$glpk_lib"
+    AC_DEFINE(GLPK_PRE_4_15, 1, [Define if GLPK version is less than 4.15.])], [
     AC_CHECK_LIB($glpk_lib, _glp_lpx_simplex, [GLPK_LIBS="-l$glpk_lib"], [])])
   if test -n "$GLPK_LIBS"; then
     AC_CHECK_HEADERS(glpk.h, [
--- a/scripts/ChangeLog	Tue Feb 20 20:41:35 2007 +0000
+++ b/scripts/ChangeLog	Tue Feb 20 21:05:11 2007 +0000
@@ -1,3 +1,8 @@
+2007-02-20  Rafael Laboissiere  <rafael@debian.org>
+
+	* optimization/glpk.m: Document the fact that extra.mem does not work
+	for versions of GLPK 4.15 and later.
+
 2007-02-19  John W. Eaton  <jwe@octave.org>
 
 	* plot/__uiobject_alloc__.in: If next available element in
--- a/scripts/optimization/glpk.m	Tue Feb 20 20:41:35 2007 +0000
+++ b/scripts/optimization/glpk.m	Tue Feb 20 21:05:11 2007 +0000
@@ -361,7 +361,8 @@
 ## @item time
 ## Time (in seconds) used for solving LP/MIP problem.
 ## @item mem
-## Memory (in bytes) used for solving LP/MIP problem.
+## Memory (in bytes) used for solving LP/MIP problem (this is not 
+## available if the version of GLPK is 4.15 or later).
 ## @end table
 ## @end table
 ## 
--- a/src/ChangeLog	Tue Feb 20 20:41:35 2007 +0000
+++ b/src/ChangeLog	Tue Feb 20 21:05:11 2007 +0000
@@ -1,3 +1,8 @@
+2007-02-20  Rafael Laboissiere  <rafael@laboissiere.net>
+
+	* DLD-FUNCTIONS/__glpk__.cc: Adapt code for changes in the GLPK
+	API for version 4.15 or later.
+
 2007-02-20  John W. Eaton  <jwe@octave.org>
 
 	* mxarray.h (mxArray::get_scalar): New function.
--- a/src/DLD-FUNCTIONS/__glpk__.cc	Tue Feb 20 20:41:35 2007 +0000
+++ b/src/DLD-FUNCTIONS/__glpk__.cc	Tue Feb 20 21:05:11 2007 +0000
@@ -38,8 +38,12 @@
 
 #if defined (HAVE_GLPK)
 
-extern "C" {
+extern "C"
+{
 #include <glpk.h>
+
+#ifdef GLPK_PRE_4_15
+
 #ifndef _GLPLIB_H
 #include <glplib.h>
 #endif
@@ -51,6 +55,16 @@
 #endif
 }
 
+#else
+
+extern "C"
+{
+void _glp_lib_print_hook (int (*func)(void *info, char *buf), void *info);
+void _glp_lib_fault_hook (int (*func)(void *info, char *buf), void *info);
+}
+
+#endif
+
 #define NIntP 17
 #define NRealP 10
 
@@ -150,10 +164,18 @@
 
   clock_t t_start = clock();
 
-  lib_set_fault_hook (NULL, glpk_fault_hook);
+#ifdef GLPK_PRE_4_15
+  lib_set_fault_hook (0, glpk_fault_hook);
+#else
+  _glp_lib_fault_hook (glpk_fault_hook, 0);
+#endif
 
   if (lpxIntParam[0] > 1)
-    lib_set_print_hook (NULL, glpk_print_hook);
+#ifdef GLPK_PRE_4_15
+    lib_set_print_hook (0, glpk_print_hook);
+#else
+    _glp_lib_print_hook (glpk_print_hook, 0);
+#endif
 
   LPX *lp = lpx_create_prob ();
 
@@ -286,7 +308,11 @@
       break;
 
     default:
+#ifdef GLPK_PRE_4_15
       insist (method != method);
+#else
+      glpk_fault_hook (0, "method != method");
+#endif
     }
 
   /*  errnum assumes the following results:
@@ -351,7 +377,12 @@
 	}
 
       *time = (clock () - t_start) / CLOCKS_PER_SEC;
+
+#ifdef GLPK_PRE_4_15
       *mem = (lib_env_ptr () -> mem_tpeak);
+#else
+      *mem = 0;
+#endif
 
       lpx_delete_prob (lp);
       return 0;