# HG changeset patch # User jwe # Date 1172005511 0 # Node ID 4e81fe3bceff887fa4d07477a54058de14c60aa3 # Parent debb662eab079788d8eebcc750006d4db1ec7861 [project @ 2007-02-20 21:05:10 by jwe] diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2007-02-20 Rafael Laboissiere + + * 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 * mkoctfile.in: Use OCTAVE_PREFIX, not OCTAVE_CONF_PREFIX, in sed diff --git a/configure.in b/configure.in --- a/configure.in +++ b/configure.in @@ -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, [ diff --git a/scripts/ChangeLog b/scripts/ChangeLog --- a/scripts/ChangeLog +++ b/scripts/ChangeLog @@ -1,3 +1,8 @@ +2007-02-20 Rafael Laboissiere + + * 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 * plot/__uiobject_alloc__.in: If next available element in diff --git a/scripts/optimization/glpk.m b/scripts/optimization/glpk.m --- a/scripts/optimization/glpk.m +++ b/scripts/optimization/glpk.m @@ -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 ## diff --git a/src/ChangeLog b/src/ChangeLog --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2007-02-20 Rafael Laboissiere + + * DLD-FUNCTIONS/__glpk__.cc: Adapt code for changes in the GLPK + API for version 4.15 or later. + 2007-02-20 John W. Eaton * mxarray.h (mxArray::get_scalar): New function. diff --git a/src/DLD-FUNCTIONS/__glpk__.cc b/src/DLD-FUNCTIONS/__glpk__.cc --- a/src/DLD-FUNCTIONS/__glpk__.cc +++ b/src/DLD-FUNCTIONS/__glpk__.cc @@ -38,8 +38,12 @@ #if defined (HAVE_GLPK) -extern "C" { +extern "C" +{ #include + +#ifdef GLPK_PRE_4_15 + #ifndef _GLPLIB_H #include #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;