diff src/DLD-FUNCTIONS/__glpk__.cc @ 5235:5f0ad69b5c8c

[project @ 2005-03-22 19:48:16 by jwe]
author jwe
date Tue, 22 Mar 2005 19:48:46 +0000
parents a791b8b777e4
children 652e8aa49fa7
line wrap: on
line diff
--- a/src/DLD-FUNCTIONS/__glpk__.cc	Tue Mar 22 18:37:06 2005 +0000
+++ b/src/DLD-FUNCTIONS/__glpk__.cc	Tue Mar 22 19:48:46 2005 +0000
@@ -30,7 +30,12 @@
 
 #include "defun-dld.h"
 #include "error.h"
+#include "gripes.h"
+#include "oct-map.h"
 #include "oct-obj.h"
+#include "pager.h"
+
+#if defined (HAVE_GLPK)
 
 extern "C" {
 #include <glpk.h>
@@ -113,14 +118,14 @@
 
 
 int
-glpk_fault_hook (void *info, char *msg)
+glpk_fault_hook (void * /* info */, char *msg)
 {
   OCTERR << "*** SEVERE CRITICAL ERROR *** from GLPK !\n\n"<<msg<<" %s\n";
   longjmp (mark, -1);
 }
 
 int
-glpk_print_hook (void *info, char *msg)
+glpk_print_hook (void * /* info */, char *msg)
 {
   OCTERR << msg << "\n";
   return 1;
@@ -267,7 +272,7 @@
 	    error = lpx_integer (lp);
 	  }
 	else
-	  error=lpx_simplex(lp);
+	  error = lpx_simplex(lp);
       }
      break;
 
@@ -354,13 +359,17 @@
    return error;
 }
 
-DEFUN_DLD (__glpk__, args, nlhs,
+#endif
+
+DEFUN_DLD (__glpk__, args, ,
   "__glpk__: internal interface for the GLPK library.\n\
 You should be using using glpk instead")
 {
   // The list of values to return.  See the declaration in oct-obj.h
   octave_value_list retval;
 
+#if defined (HAVE_GLPK)
+
   int nrhs = args.length ();
 
   if (nrhs < 1)
@@ -370,9 +379,9 @@
     }
 
   //-- 1st Input. Sense of optimization.
-  int sense;
+  volatile int sense;
   double SENSE = args(0).scalar_value ();
-  if (SENSE> = 0)
+  if (SENSE >= 0)
     sense = 1;
   else
     sense = -1;
@@ -393,7 +402,7 @@
   Array<int> cn (mrowsA*mrowsc+1);
   ColumnVector a (mrowsA*mrowsc+1, 0.0);
 
-  int nz = 0;
+  volatile int nz = 0;
   for (int i = 0; i < mrowsA; i++)
     {
       for (int j = 0; j < mrowsc; j++)
@@ -490,7 +499,7 @@
   charMatrix VTYPE (args(7).char_matrix_value ());
 
   Array<int> vartype (mrowsc);
-  int isMIP;
+  volatile int isMIP = 0;
   for (int i = 0; i < mrowsc ; i++)
     {
       if (VTYPE(i,0) == 'I')
@@ -499,9 +508,7 @@
 	  vartype(i) = LPX_IV;
 	}
       else
-	{
-	  vartype(i) = LPX_CV;
-	}
+	vartype(i) = LPX_CV;
     }
 
   //-- 9th Input. A structure containing the control parameters.
@@ -729,17 +736,16 @@
   ColumnVector mem (1);
 
   int jmpret = setjmp (mark);
+
   if (jmpret == 0)
-    {
-      int error = glpk (sense, mrowsc, mrowsA, c, nz, rn.fortran_vec (),
-			cn.fortran_vec (), a.fortran_vec (), b, ctype,
-			freeLB.fortran_vec (), lb, freeUB.fortran_vec (),
-			ub, vartype.fortran_vec (), isMIP, lpsolver,
-			save_pb, xmin.fortran_vec (), fmin.fortran_vec (),
-			status.fortran_vec (), lambda.fortran_vec (),
-			redcosts.fortran_vec (), time.fortran_vec (),
-			mem.fortran_vec ());
-    }
+    glpk (sense, mrowsc, mrowsA, c, nz, rn.fortran_vec (),
+	  cn.fortran_vec (), a.fortran_vec (), b, ctype,
+	  freeLB.fortran_vec (), lb, freeUB.fortran_vec (),
+	  ub, vartype.fortran_vec (), isMIP, lpsolver,
+	  save_pb, xmin.fortran_vec (), fmin.fortran_vec (),
+	  status.fortran_vec (), lambda.fortran_vec (),
+	  redcosts.fortran_vec (), time.fortran_vec (),
+	  mem.fortran_vec ());
 
   Octave_map extra;
 
@@ -753,5 +759,11 @@
   retval(1) = octave_value(fmin);
   retval(0) = octave_value(xmin);
 
+#else
+
+  gripe_not_supported ("glpk");
+
+#endif
+
   return retval;
 }