From: Matthias Braun Date: Thu, 1 Dec 2011 17:00:54 +0000 (+0100) Subject: lpp_gurobi: fix timelimit, do not abort on missing ObjBound X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=e665f86c4e76a5414e6555c8c98da324cc5335e3;p=libfirm lpp_gurobi: fix timelimit, do not abort on missing ObjBound --- diff --git a/ir/lpp/lpp_gurobi.c b/ir/lpp/lpp_gurobi.c index b3dca0fb7..fe0cb3af6 100644 --- a/ir/lpp/lpp_gurobi.c +++ b/ir/lpp/lpp_gurobi.c @@ -28,6 +28,7 @@ #include #include +#include #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 */