Commit e665f86c authored by Matthias Braun's avatar Matthias Braun
Browse files

lpp_gurobi: fix timelimit, do not abort on missing ObjBound

parent 7820863c
......@@ -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 */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment