Large matrix coefficients and large RHS warning
AnsweredHi, I'm running an optimization algorithm in Python using Gurobi with a pretty large dataset that should iterate for a long time. The imported csvs contain a lot of zeroes and a lot of large values. I'm receiving a warning after the presolve that the model contains large matrix coefficients and a large right hand side. What can I do to fix this? Can I simply scale down all nonzero values by some factor? I'm already concerned about the runtime so I'm not sure I want to change the NumericFocus parameter.
Gurobi Optimizer version 9.5.1 build v9.5.1rc2 (win64)
Thread count: 4 physical cores, 8 logical processors, using up to 8 threads
Optimize a model with 1116052 rows, 575004 columns and 1984260 nonzeros
Model fingerprint: 0x223d0add
Variable types: 355740 continuous, 219264 integer (1024 binary)
Coefficient statistics:
Matrix range [8e02, 2e+10]
Objective range [2e13, 2e06]
Bounds range [1e+00, 1e+00]
RHS range [1e01, 2e+10]
Warning: Model contains large matrix coefficients
Warning: Model contains large rhs
Consider reformulating model or setting NumericFocus parameter
to avoid numerical issues.
Found heuristic solution: objective 143424.26885
Presolve removed 1116022 rows and 574935 columns
Presolve time: 1.34s
Presolved: 30 rows, 69 columns, 120 nonzeros
Found heuristic solution: objective 135423.71070
Variable types: 57 continuous, 12 integer (0 binary)
Explored 0 nodes (0 simplex iterations) in 1.75 seconds (1.28 work units)
Thread count was 8 (of 8 available processors)
Solution count 2: 135424 143424
Optimal solution found (tolerance 1.00e04)
Best objective 1.354237107007e+05, best bound 1.354237107007e+05, gap 0.0000%
0

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 [2e13, 2e6].
 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 1e13 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.
 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
 Use the parameter setting ScaleFlag=2 and NumericFocus=12
 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,
Maliheh
0
Please sign in to leave a comment.
Comments
1 comment