*/
#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'};
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;
}
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);
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));
cpx_solve(cpx);
free_cpx(cpx);
}
+
#else
+
void lpp_solve_local(lpp_t *lpp) {
fprintf(stderr, "CPLEX not available!\n");
}