Added call to eliminate_phi_interferences. Enabled phi-destruction.
[libfirm] / ir / be / lpp_local.c
index ebf45a8..362be3e 100644 (file)
@@ -6,21 +6,23 @@
  */
 #undef HAVE_CPLEX
 
-#ifdef HAVE_CPLEX
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
+#include "lpp_local.h"
+#include <stdio.h>
+
+#ifdef HAVE_CPLEX
 #include <alloca.h>
 #include <sys/time.h>
 
-#include "lpp_local.h"
 #include "xmalloc.h"
 #include "assert.h"
 #include "sp_matrix.h"
 #include "ilcplex/cplex.h"
 
-#define LOGFILE stdout
-
+#undef LOGFILE //stdout
+#define TIME_LIMIT 5*60 /* in sec. 0 for none */
 
 static char cpx_cst_encoding[4] = {'?', 'E', 'L', 'G'};
 static char cpx_var_encoding[4] = {'?', '?', 'C', 'B'};
@@ -52,8 +54,10 @@ static cpx_t *new_cpx(lpp_t *lpp) {
        chk_cpx_err(cpx);
        CPXchgobjsen(cpx->env, cpx->prob, (lpp->opt_type == minimize)?1:-1);
        chk_cpx_err(cpx);
+#ifdef LOGFILE
        if (CPXsetlogfile(cpx->env, LOGFILE))
                assert(0 && "Could not set logfile");
+#endif
        return cpx;
 }
 
@@ -145,6 +149,8 @@ static void cpx_solve(cpx_t *cpx) {
        CPXsetintparam(cpx->env, CPX_PARAM_MIPSTART, CPX_ON);
        CPXsetintparam(cpx->env, CPX_PARAM_MIPEMPHASIS, CPX_MIPEMPHASIS_BESTBOUND);
        CPXsetintparam(cpx->env, CPX_PARAM_VARSEL, CPX_VARSEL_STRONG);
+       if (TIME_LIMIT)
+               CPXsetdblparam(cpx->env, CPX_PARAM_TILIM, TIME_LIMIT);
 
        /* solve */
        gettimeofday(&tvb, NULL);
@@ -170,7 +176,7 @@ static void cpx_solve(cpx_t *cpx) {
                case CPX_STAT_OPTIMAL:          lpp->sol_state = optimal; break;
                default:                                        lpp->sol_state = unknown;
        }
-       assert(lpp->sol_state == optimal);
+       assert(lpp->sol_state == optimal || lpp->sol_state == feasible);
 
        /* get variable solution values */
        values = alloca(numcols * sizeof(*values));
@@ -192,7 +198,9 @@ void lpp_solve_local(lpp_t *lpp) {
        cpx_solve(cpx);
        free_cpx(cpx);
 }
+
 #else
+
 void lpp_solve_local(lpp_t *lpp) {
        fprintf(stderr, "CPLEX not available!\n");
 }