m4/lx_check_glpk.m4
author kpeter
Sun, 05 Oct 2008 13:36:43 +0000
changeset 2619 30fb4d68b0e8
parent 2012 224cd6aacfc1
permissions -rw-r--r--
Improve network simplex algorithm

- Remove "Limited Search" and "Combined" pivot rules.
- Add a new pivot rule "Altering Candidate List".
- Make the edge selection faster in every pivot rule.
- Set the default rule to "Block Search".
- Doc improvements.

The algorithm became about 15-35 percent faster on various input files.
"Block Search" pivot rule proved to be by far the fastest on all inputs.
ladanyi@1489
     1
AC_DEFUN([LX_CHECK_GLPK],
ladanyi@1489
     2
[
ladanyi@1489
     3
  AC_ARG_WITH([glpk],
ladanyi@1489
     4
AS_HELP_STRING([--with-glpk@<:@=PREFIX@:>@], [search for GLPK under PREFIX or under the default search paths if PREFIX is not given @<:@default@:>@])
ladanyi@1489
     5
AS_HELP_STRING([--without-glpk], [disable checking for GLPK]),
ladanyi@1489
     6
              [], [with_glpk=yes])
ladanyi@1489
     7
ladanyi@1489
     8
  AC_ARG_WITH([glpk-includedir],
ladanyi@1489
     9
AS_HELP_STRING([--with-glpk-includedir=DIR], [search for GLPK headers in DIR]),
ladanyi@1489
    10
              [], [with_glpk_includedir=no])
ladanyi@1489
    11
ladanyi@1489
    12
  AC_ARG_WITH([glpk-libdir],
ladanyi@1489
    13
AS_HELP_STRING([--with-glpk-libdir=DIR], [search for GLPK libraries in DIR]),
ladanyi@1489
    14
              [], [with_glpk_libdir=no])
ladanyi@1489
    15
ladanyi@1489
    16
  lx_glpk_found=no
ladanyi@1489
    17
  if test x"$with_glpk" != x"no"; then
ladanyi@1489
    18
    AC_MSG_CHECKING([for GLPK])
ladanyi@1489
    19
ladanyi@1489
    20
    if test x"$with_glpk_includedir" != x"no"; then
ladanyi@1489
    21
      GLPK_CFLAGS="-I$with_glpk_includedir"
ladanyi@1489
    22
    elif test x"$with_glpk" != x"yes"; then
ladanyi@1489
    23
      GLPK_CFLAGS="-I$with_glpk/include"
ladanyi@1489
    24
    fi
ladanyi@1489
    25
ladanyi@1489
    26
    if test x"$with_glpk_libdir" != x"no"; then
ladanyi@1489
    27
      GLPK_LDFLAGS="-L$with_glpk_libdir"
ladanyi@1489
    28
    elif test x"$with_glpk" != x"yes"; then
ladanyi@1489
    29
      GLPK_LDFLAGS="-L$with_glpk/lib"
ladanyi@1489
    30
    fi
ladanyi@1489
    31
    GLPK_LIBS="-lglpk"
ladanyi@1489
    32
ladanyi@1489
    33
    lx_save_cxxflags="$CXXFLAGS"
ladanyi@1489
    34
    lx_save_ldflags="$LDFLAGS"
ladanyi@1489
    35
    lx_save_libs="$LIBS"
ladanyi@1489
    36
    CXXFLAGS="$GLPK_CFLAGS"
ladanyi@1489
    37
    LDFLAGS="$GLPK_LDFLAGS"
ladanyi@1489
    38
    LIBS="$GLPK_LIBS"
ladanyi@1489
    39
ladanyi@1489
    40
    lx_glpk_test_prog='
ladanyi@1489
    41
      extern "C" {
ladanyi@1489
    42
      #include <glpk.h>
ladanyi@1489
    43
      }
ladanyi@1489
    44
ladanyi@2615
    45
      int main(int argc, char** argv)
ladanyi@1489
    46
      {
ladanyi@1489
    47
        LPX *lp;
ladanyi@1489
    48
        lp = lpx_create_prob();
ladanyi@1489
    49
        lpx_delete_prob(lp);
ladanyi@1489
    50
        return 0;
ladanyi@1489
    51
      }'
ladanyi@1489
    52
ladanyi@1489
    53
    AC_LANG_PUSH(C++)
ladanyi@1489
    54
    AC_LINK_IFELSE([$lx_glpk_test_prog], [lx_glpk_found=yes], [lx_glpk_found=no])
ladanyi@1489
    55
    AC_LANG_POP(C++)
ladanyi@1489
    56
ladanyi@1489
    57
    CXXFLAGS="$lx_save_cxxflags"
ladanyi@1489
    58
    LDFLAGS="$lx_save_ldflags"
ladanyi@1489
    59
    LIBS="$lx_save_libs"
ladanyi@1489
    60
ladanyi@1489
    61
    if test x"$lx_glpk_found" = x"yes"; then
ladanyi@1489
    62
      AC_DEFINE([HAVE_GLPK], [1], [Define to 1 if you have GLPK.])
ladanyi@1489
    63
      AC_MSG_RESULT([yes])
ladanyi@1489
    64
    else
ladanyi@1489
    65
      GLPK_CFLAGS=""
ladanyi@1489
    66
      GLPK_LDFLAGS=""
ladanyi@1489
    67
      GLPK_LIBS=""
ladanyi@1489
    68
      AC_MSG_RESULT([no])
ladanyi@1489
    69
    fi
ladanyi@1489
    70
  fi
ladanyi@1489
    71
  GLPK_LIBS="$GLPK_LDFLAGS $GLPK_LIBS"
ladanyi@1489
    72
  AC_SUBST(GLPK_CFLAGS)
ladanyi@1489
    73
  AC_SUBST(GLPK_LIBS)
ladanyi@1489
    74
  AM_CONDITIONAL([HAVE_GLPK], [test x"$lx_glpk_found" = x"yes"])
ladanyi@1489
    75
])