Numeric stability with SOC
AnsweredHello,
I'm solving a linear problem with a single second-order cone constraint and have issues with numerical stability. The single SOC includes many variables and is used to limit the Euclidean distance between the new and a pre-existing solution.
Sometimes Gurobi reports numerical troubles or an infeasible model, although computing the IIS shows that the model is feasible and just re-trying to solve it will eventually succeed. Setting a higher numeric focus decreases the probability of this happening but does not fully resolve the issue. Higher numeric focus also generally decreases the solve time, which was very surprising to me.
I’ve added a log where Gurobi wrongly reports an infeasible model below. So far, the SOC is scaled the same way all other equations are scaled to be within the recommended range, and I’ve wondered, if you can recommend any ranges for SOCs specifically to resolve my issue.
Thanks and regards,
Leonard
Gurobi Optimizer version 9.0.0 build v9.0.0rc2 (win64)
Optimize a model with 107398 rows, 91565 columns and 335512 nonzeros
Model has 1 quadratic constraint
Coefficient statistics:
Matrix range [1e-03, 1e+05]
QMatrix range [2e-01, 2e-01]
QLMatrix range [1e-03, 2e+00]
Objective range [1e+00, 1e+00]
Bounds range [0e+00, 0e+00]
RHS range [1e-02, 1e+02]
QRHS range [1e+02, 1e+02]
Presolve removed 89883 rows and 65609 columns
Presolve time: 0.10s
Presolved: 33449 rows, 25958 columns, 118701 nonzeros
Presolved model has 1 second-order cone constraint
Ordering time: 0.01s
Barrier statistics:
Dense cols : 1
AA' NZ : 2.117e+05
Factor NZ : 6.712e+05 (roughly 30 MBytes of memory)
Factor Ops : 1.819e+07 (less than 1 second per iteration)
Threads : 4
Objective Residual
Iter Primal Dual Primal Dual Compl Time
0 2.11204503e+11 -4.45640267e+09 5.70e+03 2.21e+06 6.74e+07 0s
1 1.96083498e+11 -4.40904042e+09 5.15e+03 1.97e+06 6.09e+07 0s
2 1.36127990e+11 -4.48882239e+09 3.07e+03 1.48e+06 3.73e+07 0s
3 6.73418397e+10 -4.60336577e+09 1.11e+03 3.87e+05 1.33e+07 1s
4 2.39745001e+10 -4.02500967e+09 3.16e+02 3.24e+04 3.84e+06 1s
5 8.25452236e+09 -2.91430577e+09 1.00e+02 3.07e+03 1.24e+06 1s
6 2.54330090e+09 -2.01865927e+09 2.90e+01 7.51e+02 3.76e+05 1s
7 5.49097992e+08 -1.11414736e+09 5.43e+00 4.27e+01 8.15e+04 1s
8 2.29986393e+08 -5.41086619e+08 2.11e+00 7.81e+00 3.13e+04 1s
9 7.82794703e+07 -2.28634770e+08 6.46e-01 2.20e+00 9.88e+03 1s
10 3.47485069e+07 -9.85049565e+07 2.57e-01 7.37e-01 3.74e+03 1s
11 1.25047889e+07 -3.51267830e+07 7.59e-02 1.86e-01 1.15e+03 1s
12 9.19002901e+06 -1.42087487e+07 5.12e-02 6.73e-02 5.67e+02 1s
13 7.98593990e+06 -9.24386777e+06 3.83e-02 4.33e-02 4.06e+02 1s
14 6.51588807e+06 -2.28061971e+06 2.78e-02 1.36e-02 2.08e+02 2s
15 4.38956391e+06 5.19445578e+05 1.09e-02 4.77e-03 8.39e+01 2s
16 3.98739523e+06 9.66795275e+05 8.10e-03 3.72e-03 6.39e+01 2s
17 3.93165029e+06 1.21906050e+06 7.66e-03 3.18e-03 5.73e+01 2s
18 3.74507672e+06 1.69430163e+06 6.27e-03 2.18e-03 4.28e+01 2s
19 3.49519819e+06 1.92265529e+06 4.36e-03 1.74e-03 3.20e+01 2s
20 3.46359622e+06 2.01290933e+06 4.11e-03 1.57e-03 2.94e+01 2s
21 3.29371164e+06 2.28050784e+06 2.81e-03 1.06e-03 2.01e+01 2s
22 3.18352969e+06 2.39808287e+06 1.99e-03 8.43e-04 1.53e+01 2s
23 3.13416763e+06 2.49411061e+06 1.63e-03 6.65e-04 1.24e+01 2s
24 3.08433761e+06 2.61762648e+06 1.26e-03 4.56e-04 8.97e+00 2s
25 3.04253986e+06 2.67954289e+06 9.66e-04 3.48e-04 6.92e+00 3s
26 3.02698043e+06 2.70917597e+06 8.57e-04 3.06e-04 6.04e+00 3s
27 3.01043929e+06 2.75241964e+06 7.31e-04 2.46e-04 4.89e+00 3s
28 2.99236780e+06 2.79867613e+06 5.94e-04 1.72e-04 3.66e+00 3s
29 2.97827097e+06 2.80997676e+06 4.98e-04 1.52e-04 3.17e+00 3s
30 2.97094191e+06 2.82340476e+06 4.50e-04 1.27e-04 2.77e+00 3s
31 2.96354512e+06 2.83833351e+06 3.93e-04 1.09e-04 2.35e+00 3s
32 2.94903016e+06 2.86159834e+06 2.94e-04 7.34e-05 1.63e+00 3s
33 2.93691030e+06 2.88015426e+06 2.21e-04 5.79e-05 1.06e+00 3s
34 2.93094428e+06 2.88377227e+06 1.85e-04 5.41e-05 8.81e-01 3s
35 2.92632681e+06 2.88685226e+06 1.57e-04 6.16e-05 7.37e-01 3s
36 2.92288390e+06 2.89136800e+06 1.36e-04 7.74e-05 5.89e-01 3s
37 2.91715363e+06 2.89273187e+06 1.03e-04 7.56e-05 4.56e-01 4s
38 2.91610673e+06 2.89427116e+06 9.63e-05 7.65e-05 4.08e-01 4s
39 2.91419434e+06 2.89549512e+06 8.61e-05 4.55e-05 3.49e-01 4s
40 2.90993640e+06 2.89697628e+06 6.19e-05 1.56e-05 2.42e-01 4s
41 2.90885303e+06 2.89803626e+06 5.61e-05 7.95e-06 2.02e-01 4s
42 2.90580884e+06 2.89880641e+06 3.76e-05 3.59e-06 1.31e-01 4s
43 2.90343801e+06 2.89899695e+06 2.34e-05 2.67e-06 8.27e-02 4s
44 2.90197705e+06 2.89910645e+06 1.40e-05 2.19e-06 5.33e-02 4s
45 2.90118114e+06 2.89934169e+06 9.29e-06 1.00e-06 3.42e-02 5s
46 2.90103024e+06 2.89950274e+06 8.39e-06 3.29e-07 2.85e-02 5s
47 2.90092999e+06 2.89954459e+06 7.81e-06 2.12e-07 2.58e-02 5s
48 2.90028452e+06 2.89956396e+06 3.83e-06 1.35e-07 1.34e-02 5s
49 2.90007153e+06 2.89961162e+06 2.56e-06 9.02e-09 8.56e-03 5s
50 2.90002119e+06 2.89962702e+06 2.26e-06 4.00e-08 7.32e-03 5s
51 2.89993729e+06 2.89963145e+06 1.76e-06 3.68e-08 5.68e-03 5s
52 2.89990522e+06 2.89962945e+06 1.57e-06 9.20e-08 5.12e-03 5s
53 2.89977906e+06 2.89963129e+06 8.11e-07 1.89e-08 2.74e-03 6s
54 2.89969299e+06 2.89963388e+06 3.00e-07 1.48e-07 1.09e-03 6s
55 2.89968665e+06 2.89963677e+06 2.64e-07 3.24e-07 9.32e-04 6s
56 2.89968526e+06 2.90001233e+06 2.56e-07 1.92e-05 9.05e-04 6s
57 2.89967114e+06 2.90008553e+06 8.31e-07 7.66e-02 6.16e-04 6s
58 2.89966596e+06 2.90015644e+06 5.53e-06 3.52e-02 1.33e-03 6s
59 2.89965168e+06 2.90007850e+06 1.39e-05 3.94e-01 5.93e-04 6s
60 2.89965082e+06 2.90006819e+06 1.39e-05 4.46e-01 5.30e-04 6s
61 2.89964814e+06 2.90013424e+06 4.22e-05 9.24e-01 5.32e-04 7s
62 2.89964352e+06 2.90019310e+06 7.51e-06 5.98e-01 1.69e-04 7s
63 2.89964192e+06 2.90019522e+06 1.59e-05 1.03e+00 8.85e-05 7s
64 2.89964158e+06 2.89997749e+06 1.74e-05 1.37e+00 1.16e-04 7s
65 2.89964158e+06 7.34128606e+06 1.74e-05 4.74e+01 1.88e+00 7s
66 5.33803671e+12 -4.45657206e+09 1.44e+05 2.21e+06 1.70e+09 7s
67 4.50762430e+12 -4.37229183e+09 1.22e+05 1.81e+06 1.38e+09 8s
68 2.44714353e+12 -3.98769235e+09 6.59e+04 1.04e+06 6.51e+08 8s
69 6.14555617e+11 -3.24092412e+09 1.66e+04 1.31e+05 1.20e+08 8s
70 1.02974882e+11 -2.73687834e+09 2.83e+03 1.49e+04 1.72e+07 8s
71 7.30099447e+09 -2.04282508e+09 2.51e+02 4.31e+02 1.35e+06 8s
72 7.31611449e+08 -1.11121792e+09 4.00e+01 9.60e+01 1.97e+05 8s
73 2.77152841e+08 -4.66313724e+08 1.68e+01 3.37e+01 6.21e+04 8s
74 8.34192841e+07 -2.72895917e+08 5.69e+00 1.83e+01 1.96e+04 8s
75 4.42905946e+07 -1.72157622e+08 3.26e+00 1.10e+01 1.02e+04 8s
76 2.14090426e+07 -8.71708499e+07 1.51e+00 5.47e+00 4.13e+03 8s
77 1.18639960e+07 -4.88495467e+07 7.56e-01 3.06e+00 1.95e+03 8s
78 7.25032752e+06 -2.16517901e+07 3.77e-01 1.42e+00 8.36e+02 9s
79 4.93091330e+06 -7.55422160e+06 1.81e-01 5.91e-01 3.32e+02 9s
80 3.87552009e+06 -2.41620697e+06 9.06e-02 2.95e-01 1.55e+02 9s
81 3.39796417e+06 2.23025361e+05 4.55e-02 1.48e-01 7.26e+01 9s
82 3.15740734e+06 1.10594980e+06 2.15e-02 9.98e-02 4.30e+01 9s
83 3.11554612e+06 1.86516196e+06 1.75e-02 5.75e-02 2.64e+01 9s
84 3.06956946e+06 2.11760261e+06 1.31e-02 4.24e-02 1.96e+01 9s
85 3.01769361e+06 2.31162260e+06 8.35e-03 3.12e-02 1.41e+01 9s
86 2.99467341e+06 2.55317950e+06 6.32e-03 1.77e-02 8.78e+00 9s
87 2.96292248e+06 2.63906238e+06 3.64e-03 1.32e-02 6.25e+00 9s
88 2.95811596e+06 2.71426665e+06 3.24e-03 9.47e-03 4.71e+00 10s
89 2.94371904e+06 2.77609518e+06 2.32e-03 6.42e-03 3.22e+00 10s
90 2.93492258e+06 2.84531185e+06 1.82e-03 2.64e-03 1.74e+00 10s
91 2.92290397e+06 2.87116644e+06 1.13e-03 1.37e-03 1.00e+00 10s
92 2.91506118e+06 2.88006443e+06 7.13e-04 9.43e-04 6.71e-01 10s
93 2.91247251e+06 2.88487800e+06 5.91e-04 7.35e-04 5.30e-01 10s
94 2.90941734e+06 2.89364499e+06 4.54e-04 2.91e-04 3.07e-01 10s
95 2.90583017e+06 2.89598345e+06 2.84e-04 2.39e-04 1.91e-01 10s
96 2.90302316e+06 2.89715327e+06 1.53e-04 1.45e-04 1.13e-01 10s
97 2.90197628e+06 2.89743711e+06 1.08e-04 1.29e-04 8.66e-02 11s
98 2.90171800e+06 2.89863508e+06 9.57e-05 4.74e-05 5.97e-02 11s
99 2.90101903e+06 2.89888514e+06 6.32e-05 3.62e-05 4.11e-02 11s
100 2.90013951e+06 2.89923041e+06 2.33e-05 2.54e-05 1.73e-02 11s
101 2.89985780e+06 2.89950770e+06 1.02e-05 1.06e-05 6.71e-03 11s
102 2.89980507e+06 2.89955719e+06 7.72e-06 9.13e-06 4.77e-03 11s
103 2.89972891e+06 2.89960988e+06 4.19e-06 1.74e-05 2.31e-03 11s
104 2.89967439e+06 2.89962690e+06 1.65e-06 9.47e-07 9.21e-04 12s
105 2.89965103e+06 2.89963571e+06 5.36e-07 3.24e-06 2.97e-04 12s
106 2.89964596e+06 2.89963955e+06 2.85e-07 5.25e-05 1.27e-04 12s
107 2.89964546e+06 2.89964053e+06 2.59e-07 2.13e-04 1.12e-04 12s
108 2.89964946e+06 2.89964768e+06 2.96e-07 2.10e-01 2.26e-04 12s
109 2.89967537e+06 2.89967671e+06 2.91e-05 1.39e+00 8.89e-04 12s
110 2.89985198e+06 2.90004412e+06 9.52e-03 5.47e+00 3.04e-03 13s
111 2.89994740e+06 2.90019002e+06 1.14e-02 2.82e+00 6.04e-03 13s
112 2.89979377e+06 2.89978961e+06 5.65e-03 2.18e+00 2.30e-03 13s
113 2.89999348e+06 2.90043002e+06 9.99e-03 2.99e+01 1.12e-02 13s
114 2.90031814e+06 2.90076581e+06 1.23e-02 4.82e+01 2.72e-02 13s
115 2.90054127e+06 2.90091988e+06 1.24e-02 6.28e+01 3.54e-02 13s
116 2.90110784e+06 2.90153283e+06 1.23e-02 6.95e+01 6.04e-02 13s
117 2.90194402e+06 2.90207875e+06 1.43e-02 1.37e-01 1.08e-01 13s
118 2.90325881e+06 2.90415817e+06 1.38e-02 7.61e+01 2.05e-01 13s
119 2.90737198e+06 2.90701657e+06 1.27e-02 1.73e+02 3.97e-01 13s
120 2.91096506e+06 2.91345920e+06 1.25e-02 3.14e+02 6.94e-01 14s
121 2.91460198e+06 2.92008664e+06 1.25e-02 5.92e+02 1.09e+00 14s
122 2.91849063e+06 2.92658756e+06 1.26e-02 1.11e+03 1.55e+00 14s
123 2.93064173e+06 2.93803799e+06 1.35e-02 1.25e+03 2.73e+00 14s
124 2.94447967e+06 2.95051829e+06 1.35e-02 1.55e+03 4.42e+00 14s
125 2.95627273e+06 2.97211629e+06 1.34e-02 3.83e+00 7.44e+00 14s
126 2.96461541e+06 2.98612748e+06 1.35e-02 5.19e+00 1.01e+01 14s
127 2.98209031e+06 2.99192865e+06 1.34e-02 3.24e+02 1.17e+01 14s
128 2.99123401e+06 3.01930853e+06 1.34e-02 5.80e+01 1.71e+01 14s
129 3.02711216e+06 3.03740507e+06 1.36e-02 4.43e+01 2.15e+01 15s
130 3.08941449e+06 3.07580236e+06 1.36e-02 3.13e+01 3.11e+01 15s
131 3.11540255e+06 3.12117632e+06 1.35e-02 7.41e+03 4.03e+01 15s
132 3.16062676e+06 3.18903229e+06 1.35e-02 1.63e+03 5.60e+01 15s
133 3.22338918e+06 3.28755893e+06 1.32e-02 3.24e+04 8.16e+01 15s
134 3.32560727e+06 3.44114069e+06 1.30e-02 3.50e+04 1.27e+02 15s
135 3.66654757e+06 3.60488081e+06 1.32e-02 6.02e+04 1.82e+02 15s
136 3.86093118e+06 4.10494932e+06 1.32e-02 1.47e+05 2.93e+02 15s
137 4.72519788e+06 5.10866339e+06 1.29e-02 1.01e+03 5.88e+02 15s
138 6.22361508e+06 5.92098111e+06 1.27e-02 2.34e+05 8.53e+02 15s
139* 9.39171016e+06 7.75676600e+06 2.10e-07 2.84e+00 1.66e-07 16s
140* 1.92256197e+07 2.08441357e+07 7.60e-08 2.67e+00 7.34e-08 16s
141* 5.73911795e+07 3.01685592e+07 2.01e-08 1.74e+00 1.06e-08 16s
142* 1.12858218e+08 1.79420427e+08 8.19e-09 3.40e+00 7.50e-09 16s
Barrier performed 142 iterations in 15.89 seconds
Infeasible model
-
Official comment
This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?. -
Hi Leonard,
When solving quadratic problem, numerics are often key to a successful solution process.
In your case, having a very dense SOC constraint makes the problem even more prone to numerical trouble.
The coefficient range of your linear matrix is
Matrix range [1e-03, 1e+05]
It is recommended to keep this range below 6 orders of magnitude if possible, 4 is the actual way to go.
It is possible that your problem is on the edge of infeasibility, meaning that it is feasible but only within tolerances. This would explain the IIS behavior. You could test the following to try to improve the behavior:
- Update to the latest version 9.1.2
- Have a look at our Guidelines for Numerical Issues and try to rescale your model
- Experiment with the NumericFocus parameter. You stated that you already did with success. This makes sense as the parameter forces Gurobi to focus more on numerical stability.
- Check whether you have almost parallel constraints as these may cause serious trouble in the solution process
- Check whether your model has stable behavior without the SOC constraint, i.e., remove the SOC constraint and tighten the FeasibilityTol parameter.
If none of the above works, you might consider sharing your model with the community as described in Posting to the Community Forum.
Best regards,
Jaromił0 -
Ok. Thanks.
0
Post is closed for comments.
Comments
3 comments