summaryrefslogtreecommitdiffhomepage
path: root/ir/lpp
diff options
context:
space:
mode:
authorManuel Mohr <manuel.mohr@kit.edu>2013-02-01 10:16:53 +0100
committerManuel Mohr <manuel.mohr@kit.edu>2013-02-01 10:25:55 +0100
commit8009990dbeeca664c7d7a7e570e80d857c87c955 (patch)
treeef763233053b4b67beedc2621c7085d65d52e36c /ir/lpp
parent6effa6d0fb14c2458c19916c3a0d7a14b81f4b4a (diff)
lpp: Add Gurobi support for improving an initial solution.
Diffstat (limited to 'ir/lpp')
-rw-r--r--ir/lpp/lpp_gurobi.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/ir/lpp/lpp_gurobi.c b/ir/lpp/lpp_gurobi.c
index 610badf..359abb4 100644
--- a/ir/lpp/lpp_gurobi.c
+++ b/ir/lpp/lpp_gurobi.c
@@ -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);
}