If the objective value that Gurobi returns is not what you expected, the first step is to identify the type of wrong result.
The most common reasons for this are:
- Termination criteria
- Incorrect objective sense
- If using an MPS file, check that the objective sense is set correctly. By default, Gurobi assumes a problem is of minimization.
- Numerical issues and/or wrong variable values in the optimal solution
Comparing the returned solution with a known solution
If you have a known solution, you can test if this solution is feasible for your model. Create a fixed model by fixing the variables to the values in the known solution. To do this, set each variable's lower and upper bound to its value in the solution.
Is the fixed model feasible?
- What is the IIS for the fixed model? To compute the Irreducible Infeasible Subsystem (IIS) for the model, follow the instructions in the article How do I use 'compute IIS' to find a subset of constraints that are causing model infeasibility?
- Is the objective value of the fixed model different from your expectation, and/or is it different to the objective value of the original model? Check your model for modeling errors leading to the incorrect computation of the objective function.
- Do you see warnings in the fixed model log indicating variables or constraints violate feasibility tolerances? This typically indicates numerical issues in the model. Check if your model has numerical issues. Setting the NumericFocus parameter to a higher value, the Aggregate parameter to zero, or disabling Presolve may alleviate the numerical issues. However, the best way forward will be to reformulate/rescale your model to address the numerical issues. Please take a look at our guidelines for numerical issues.
Note: If you are using an older version of Gurobi, please update to the latest Gurobi release. In every release, numerous improvements are made, including bug fixes from previous versions.