Skip to main content

Large matrix coefficients and large RHS warning



1 comment

  • Maliheh Aramon
    Gurobi Staff Gurobi Staff

    Hi Emma, 

    Yes, the numerics are not looking good. Apart from the large matrix coefficient range and large RHS values, the objective coefficient range is very small [2e-13, 2e-6]. 

    1. What is the smallest meaningful number in your model? I would suggest first getting rid of all small coefficient values that do not have any meaning. For example, what a value as small as 1e-13 really means in your model? Can you replace all of these small values with zero? The smallest coefficient value in the model should be ideally one order of magnitude larger than the default Gurobi feasibility/optimality tolerances.
    2. You can consider scaling the model variables and constraints to get more reasonable coefficients. Maybe you can change your variable units or scale constraints to get their coefficients closer to 1
    3. Use the parameter setting ScaleFlag=2 and NumericFocus=1|2 
    • Gurobi has three different heuristic algorithms to find scaling factors. Higher values for the ScaleFlag uses more aggressive heuristics to improve the constraint matrix numerics for the scaled model.
    • It is true that higher values for NumericFocus increases the runtime, but you can start from NumericFocus=1
  • Sometimes setting Aggregate=0 can improve the model numerics. You might want to check out our documentation in Guidelines for Numerical Issues/Solver parameters to manage/Presolve to learn more about situations where it makes sense to set this parameter to 0.
  • Best regards,




Please sign in to leave a comment.