summaryrefslogtreecommitdiffhomepage
path: root/ir/lpp
diff options
context:
space:
mode:
authorMatthias Braun <matze@braunis.de>2011-07-15 14:10:05 +0200
committerMatthias Braun <matze@braunis.de>2011-08-12 19:49:54 +0200
commitc40cddcb2ab00386525581d30eb51759eeb985af (patch)
tree1f6626193cdeaff3ba27179bc3cc68fbea439aa1 /ir/lpp
parent321855ff2c234518e0ac8d794903eb78d23fc1fa (diff)
lpp: only read solution in gurobi solver if one was found
Diffstat (limited to 'ir/lpp')
-rw-r--r--ir/lpp/lpp_gurobi.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/ir/lpp/lpp_gurobi.c b/ir/lpp/lpp_gurobi.c
index 6c215db..c329e7c 100644
--- a/ir/lpp/lpp_gurobi.c
+++ b/ir/lpp/lpp_gurobi.c
@@ -223,20 +223,24 @@ static void gurobi_solve(gurobi_t *grb)
default: lpp->sol_state = lpp_feasible; break;
}
- /* get variable solution values */
- values = alloca(numcols * sizeof(*values));
- error = GRBgetdblattrarray(grb->model, GRB_DBL_ATTR_X, 0, numcols, values);
- check_gurobi_error(grb, error);
- for(i=0; i<numcols; ++i) {
- lpp->vars[1+i]->value = values[i];
- lpp->vars[1+i]->value_kind = lpp_value_solution;
- }
+ if (lpp->sol_state >= lpp_feasible) {
+ /* get variable solution values */
+ values = alloca(numcols * sizeof(*values));
+ error = GRBgetdblattrarray(grb->model, GRB_DBL_ATTR_X, 0, numcols,
+ values);
+ check_gurobi_error(grb, error);
+ for(i=0; i<numcols; ++i) {
+ lpp->vars[1+i]->value = values[i];
+ lpp->vars[1+i]->value_kind = lpp_value_solution;
+ }
- /* Get the value of the objective function. */
- error = GRBgetdblattr(grb->model, GRB_DBL_ATTR_OBJVAL, &lpp->objval);
- check_gurobi_error(grb, error);
- error = GRBgetdblattr(grb->model , GRB_DBL_ATTR_OBJBOUND, &lpp->best_bound);
- check_gurobi_error(grb, error);
+ /* Get the value of the objective function. */
+ error = GRBgetdblattr(grb->model, GRB_DBL_ATTR_OBJVAL, &lpp->objval);
+ check_gurobi_error(grb, error);
+ error = GRBgetdblattr(grb->model , GRB_DBL_ATTR_OBJBOUND,
+ &lpp->best_bound);
+ check_gurobi_error(grb, error);
+ }
/* get some statistics */
error = GRBgetdblattr(grb->model, GRB_DBL_ATTR_ITERCOUNT, &iterations);