Sunday, 18 August 2013

Gurobi taking a long time to build model for LP

Gurobi taking a long time to build model for LP

I have been solving some LPs with gurobi, and I noticed that for most of
the instances I am encountering, building the model is taking way longer
than actually solving it. Perhaps this is standard, but it seems bizarre
to me.
One particular instance took 1.75 seconds to solve, but the following
portion of the code for building the model took 13.6 seconds:
for (int i = 0; i < numSeq2; ++i) {
expr = new GRBLinExpr();
//expr.clear();
for (int j = 0; j < numSeq1; ++j)
expr.addTerm(-1 * A[j][i], x[j]);
for (int j = 0; j < numIS2; ++j)
expr.addTerm(-1 * F[j][i], q[j]);
duals[i] = model.addConstr(expr, GRB.LESS_EQUAL, 0, "");
}
}
In the example described above, numSeq1 = 7475, numSeq2 = 7495, numIS2 =
2517, and the final LP had 9992 rows and 9992 columns. I know this is
fairly large, but it seems strange that it takes almost 10x as much time
to build the model than to solve it.
I tried expr.clear() instead of creating a new GRBLinExpr for each
constraint (commented out) and it didn't help.
Is there any way to make gurobi build the model any faster? Would cplex be
better than gurobi in this regard if the bottleneck is building the model?
Thanks!

No comments:

Post a Comment