Hi Mayron,
The runtime of an optimization problem depends on a multitude of different options. From afar (and sometimes also from nearby), it is impossible to quantify the specific reasons.
* You can, for example, try to export your model as MPS file and run the Gurobi Tuner:
* It might be worthwile to review your model formulation, and try to improve some formulations
** E.g., computing tighter "Big M" values, if you use any in your constraints
** Disaggregate sums, whereever possible
*** e.g. instead of using a constraint with 4 binaries "3 * x <= a + b + c" convert it to 3 constraints:
*** x <= a
*** x <= b
*** x <= c
*** This will improve the quality of the LP relaxation during the solving process and thus might reduce the overall runtime.
You can get some intermediate information regarding Gurobi's internal status by using the "GurobiSolver.Status" callback.
For example, this callback method will compute + print the MIP Gap whenever Gurobi invokes the appropriate callback type:
using (var solver = new GurobiSolver(grbConfig))
{
solver.Status += statusInfo =>
{
if (statusInfo.LowerBound.HasValue && statusInfo.Incumbent.HasValue)
{
double gap;
if (statusInfo.LowerBound.Value.IsAlmost(statusInfo.Incumbent.Value))
{
gap = 0d;
}
else if (statusInfo.LowerBound.Value.IsAlmost(0))
{
gap = double.PositiveInfinity;
}
else
{
gap = Math.Abs(statusInfo.LowerBound.Value - statusInfo.Incumbent.Value) / Math.Abs(statusInfo.LowerBound.Value);
}
Console.Write($"Current gap: {gap * 100:0.####}%");
Console.WriteLine(statusInfo.SolverTime.HasValue ? $" - Runtime: {statusInfo.SolverTime.Value:0.##} seconds" : "");
}
};
// ...
}
Please let us know, if you have any further questions.
Best Regards
Jannick