Commit 8009990d authored by Manuel Mohr's avatar Manuel Mohr
Browse files

lpp: Add Gurobi support for improving an initial solution.

parent 6effa6d0
......@@ -80,6 +80,9 @@ static void free_gurobi(gurobi_t *grb)
static void gurobi_construct(gurobi_t *grb)
{
int i, o;
int sv_cnt;
int *indices;
double *startv;
int numcols, numrows, numentries;
int objsen, *matbeg, *matcnt, *matind;
double *obj, *rhs, *matval, *lb;
......@@ -100,6 +103,8 @@ static void gurobi_construct(gurobi_t *grb)
colname = obstack_alloc(&obst, numcols * sizeof(*colname));
rowname = obstack_alloc(&obst, numrows * sizeof(*rowname));
vartype = obstack_alloc(&obst, numcols * sizeof(*vartype));
indices = obstack_alloc(&obst, numcols * sizeof(*indices));
startv = obstack_alloc(&obst, numcols * sizeof(*startv));
matbeg = obstack_alloc(&obst, numcols * sizeof(*matbeg));
matcnt = obstack_alloc(&obst, numcols * sizeof(*matcnt));
matind = obstack_alloc(&obst, numentries * sizeof(*matind));
......@@ -108,6 +113,7 @@ static void gurobi_construct(gurobi_t *grb)
sense = obstack_alloc(&obst, numrows * sizeof(*sense));
o = 0;
sv_cnt = 0;
/* fill the Gurobi matrix*/
for (i = 0; i < numcols; ++i) {
lpp_name_t *curr_var = lpp->vars[1+i];
......@@ -118,6 +124,11 @@ static void gurobi_construct(gurobi_t *grb)
colname[i] = (char*) curr_var->name;
vartype[i] = gurobi_var_encoding[curr_var->type.var_type];
if (curr_var->value_kind == lpp_value_start) {
indices[sv_cnt] = i;
startv[sv_cnt++] = curr_var->value;
}
matbeg[i] = o;
matcnt[i] = 0;
matrix_foreach_in_col(lpp->m, 1 + i, elem) {
......@@ -145,6 +156,12 @@ static void gurobi_construct(gurobi_t *grb)
check_gurobi_error(grb, error);
grb->modelenv = GRBgetenv(grb->model);
/* set start values */
for (i = 0; i < sv_cnt; ++i) {
error = GRBsetdblattrelement(grb->model, GRB_DBL_ATTR_START, indices[i], startv[i]);
check_gurobi_error(grb, error);
}
obstack_free(&obst, NULL);
lpp_free_matrix(lpp);
}
......
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