lpp: only read solution in gurobi solver if one was found
[libfirm] / ir / lpp / lpp_solvers.c
index 1cfc52a..104b8f2 100644 (file)
@@ -1,67 +1,49 @@
-/**
- * @file   lpp_solvers.c
- * @date   16.06.2011
- * @author Sebastian Hack
+/*
+ * Copyright (C) 2005-2011 University of Karlsruhe.  All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
  *
- * Copyright (C) 2011 Saarland University
- * Released under the LGPL
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
  */
 
-#include <unistd.h>
+/**
+ * @file
+ * @author  Sebastian Hack
+ */
+#include "config.h"
 
-#include "lpp_cplex.h"
 #include "lpp_solvers.h"
-
-static void dummy_solver(lpp_t *lpp)
-{
-  int i;
-
-  for(i = 0; i < lpp->var_next; ++i) {
-    lpp->vars[i]->value = i;
-    lpp->vars[i]->value_kind = lpp_value_solution;
-  }
-
-  if(lpp->log)
-         fprintf(lpp->log, "dummy solver exiting now.\n");
-
-  sleep(1);
-  lpp->sol_time = 0.0;
-  lpp->iterations = 0;
-  lpp->sol_state = lpp_optimal;
-}
-
-static void segv_solver(lpp_t *lpp)
-{
-  int i;
-
-  for(i = 0; i < lpp->var_next; ++i) {
-    lpp->vars[i]->value = i;
-    lpp->vars[i]->value_kind = lpp_value_solution;
-  }
-
-  if(lpp->log)
-         fprintf(lpp->log, "segv dummy solver exiting now.\n");
-
-  sleep(1);
-  *((int *) 0) = 1;
-}
+#include "lpp_cplex.h"
+#include "lpp_gurobi.h"
 
 lpp_solver_t lpp_solvers[] = {
-  { lpp_solve_cplex,   "cplex",   1 },
-  { dummy_solver,      "dummy",   2 },
-  { segv_solver,       "segv",    2 },
-  { NULL,              NULL,      0 }
+#ifdef WITH_CPLEX
+       { lpp_solve_cplex,   "cplex",   1 },
+#endif
+#ifdef WITH_GUROBI
+       { lpp_solve_gurobi,  "gurobi",  1 },
+#endif
+       { NULL,              NULL,      0 }
 };
 
 lpp_solver_func_t *lpp_find_solver(const char *name)
 {
-  int i;
+       int i;
 
-  for(i = 0; lpp_solvers[i].solver != NULL; i++)
-    if(strcmp(lpp_solvers[i].name, name) == 0)
-      return lpp_solvers[i].solver;
+       for(i = 0; lpp_solvers[i].solver != NULL; i++)
+               if(strcmp(lpp_solvers[i].name, name) == 0)
+                       return lpp_solvers[i].solver;
 
-  return NULL;
+       return NULL;
 }
-
-