summaryrefslogtreecommitdiffhomepage
path: root/ir/lpp
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2011-12-01 18:00:54 +0100
committerMatthias Braun <matze@braunis.de>2011-12-01 20:02:21 +0100
commite665f86c4e76a5414e6555c8c98da324cc5335e3 (patch)
tree47cfd723ec8531293f3c1a10453bd59bb765664c /ir/lpp
parent7820863c6a1b5ff75c7ff5647b567fc838792fe4 (diff)
lpp_gurobi: fix timelimit, do not abort on missing ObjBound
Diffstat (limited to 'ir/lpp')
-rw-r--r--ir/lpp/lpp_gurobi.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/ir/lpp/lpp_gurobi.c b/ir/lpp/lpp_gurobi.c
index b3dca0f..fe0cb3a 100644
--- a/ir/lpp/lpp_gurobi.c
+++ b/ir/lpp/lpp_gurobi.c
@@ -28,6 +28,7 @@
#include <stdio.h>
#include <stdlib.h>
+#include <math.h>
#include "obst.h"
@@ -42,6 +43,7 @@ static char gurobi_var_encoding[4] = { 0, 0, GRB_CONTINUOUS, GRB_BINARY };
typedef struct _gurobi_t {
lpp_t *lpp;
GRBenv *env;
+ GRBenv *modelenv;
GRBmodel *model;
} gurobi_t;
@@ -79,6 +81,7 @@ static gurobi_t *new_gurobi(lpp_t *lpp)
static void free_gurobi(gurobi_t *grb)
{
+ GRBfreemodel(grb->model);
GRBfreeenv(grb->env);
free(grb);
}
@@ -168,6 +171,7 @@ static void gurobi_construct(gurobi_t *grb)
objsen, 0, obj, sense, rhs, matbeg, matcnt, matind,
matval, lb, NULL, vartype, colname, rowname);
check_gurobi_error(grb, error);
+ grb->modelenv = GRBgetenv(grb->model);
obstack_free(&obst, NULL);
lpp_free_matrix(lpp);
@@ -183,20 +187,9 @@ static void gurobi_solve(gurobi_t *grb)
double *values;
double iterations;
- /* set performance parameters */
- // CPXsetintparam(grb->env, CPX_PARAM_MIPSTART, CPX_ON);
- //CPXsetintparam(grb->env, CPX_PARAM_MIPORDTYPE, CPX_MIPORDER_COST);
- /* output every search tree node */
- // CPXsetintparam(grb->env, CPX_PARAM_MIPINTERVAL, 1);
-
- /* experimental switches */
- // CPXsetintparam(grb->env, CPX_PARAM_VARSEL, CPX_VARSEL_STRONG);
- // CPXsetdblparam(grb->env, CPX_PARAM_BTTOL, 1.0);
- // CPXsetintparam(grb->env, CPX_PARAM_BRDIR, CPX_BRDIR_UP);
-
/* Set the time limit appropriately */
if(lpp->time_limit_secs > 0.0) {
- error = GRBsetdblparam(grb->env, GRB_DBL_PAR_TIMELIMIT, lpp->time_limit_secs);
+ error = GRBsetdblparam(grb->modelenv, GRB_DBL_PAR_TIMELIMIT, lpp->time_limit_secs);
check_gurobi_error(grb, error);
}
@@ -250,7 +243,9 @@ static void gurobi_solve(gurobi_t *grb)
check_gurobi_error(grb, error);
error = GRBgetdblattr(grb->model , GRB_DBL_ATTR_OBJBOUND,
&lpp->best_bound);
- check_gurobi_error(grb, error);
+ if (error != 0) {
+ lpp->best_bound = FP_NAN;
+ }
}
/* get some statistics */