Adding objective function makes the problem infeasible
AnsweredI'm using Gurobi with CVX in MATLAB. When I run my optimization problem with 0 objectives and just solve the constraints, it returns that it is feasible. But when I add in my objective function, I get the output that the problem is infeasible. I also don't understand why it says I have quadratic constraints even though all my model constraints are linear. How can I solve this to return a feasible optimal solution with an objective value?
Here's the output without the objective:
Calling Gurobi_2 9.12: 10972 variables, 8830 equality constraints
------------------------------------------------------------
Gurobi Optimizer, licensed to CVX for CVX
Academic license - for non-commercial use only - expires 2024-06-11
Warning for adding variables: zero or small (< 1e-13) coefficients, ignored
Gurobi Optimizer version 9.1.2 build v9.1.2rc0 (mac64)
Thread count: 10 physical cores, 10 logical processors, using up to 10 threads
Optimize a model with 8830 rows, 10972 columns and 30944 nonzeros
Model fingerprint: 0x27b93575
Coefficient statistics:
Matrix range [1e-10, 2e+02]
Objective range [0e+00, 0e+00]
Bounds range [0e+00, 0e+00]
RHS range [3e-18, 1e+00]
Concurrent LP optimizer: primal simplex, dual simplex, and barrier
Showing barrier log only...
Presolve removed 6797 rows and 9912 columns
Presolve time: 0.01s
Presolved: 2033 rows, 1060 columns, 12819 nonzeros
Ordering time: 0.00s
Barrier statistics:
AA' NZ : 3.554e+04
Factor NZ : 3.898e+04 (roughly 2 MBytes of memory)
Factor Ops : 8.879e+05 (less than 1 second per iteration)
Threads : 1
Objective Residual
Iter Primal Dual Primal Dual Compl Time
0 0.00000000e+00 -4.49060273e-01 4.49e-01 0.00e+00 1.01e-02 0s
1 0.00000000e+00 -4.13204718e-01 2.58e-02 1.39e-16 6.83e-04 0s
2 0.00000000e+00 -1.09229776e-01 1.01e-03 2.36e-16 4.98e-05 0s
3 0.00000000e+00 -2.34535408e-03 1.75e-05 2.22e-16 9.31e-07 0s
4 0.00000000e+00 -6.69687821e-05 5.95e-07 2.22e-16 2.64e-08 0s
5 0.00000000e+00 -2.62543225e-06 9.61e-09 9.71e-17 8.46e-10 0s
6 0.00000000e+00 -1.06843555e-06 3.28e-10 6.74e-17 3.09e-10 0s
7 0.00000000e+00 -3.72453444e-09 6.59e-14 6.86e-17 1.07e-12 0s
Barrier solved model in 7 iterations and 0.03 seconds
Optimal objective 0.00000000e+00
Crossover log...
1207 DPushes remaining with DInf 2.0896265e-04 0s
0 DPushes remaining with DInf 0.0000000e+00 0s
218 PPushes remaining with PInf 2.0276555e+02 0s
0 PPushes remaining with PInf 6.1955783e+01 0s
Push phase complete: Pinf 6.1955783e+01, Dinf 0.0000000e+00 0s
Iteration Objective Primal Inf. Dual Inf. Time
857 0.0000000e+00 6.195578e+01 0.000000e+00 0s
Solved with dual simplex
Solved in 1313 iterations and 0.09 seconds
Optimal objective 0.000000000e+00
User-callback calls 1733, time in user-callback 0.01 sec
------------------------------------------------------------
Status: Solved
Optimal value (cvx_optval): +0
Here's the output after I add the objective:
Calling Gurobi_2 9.12: 14532 variables, 10966 equality constraints
------------------------------------------------------------
Gurobi Optimizer, licensed to CVX for CVX
Academic license - for non-commercial use only - expires 2024-06-11
Warning for adding variables: zero or small (< 1e-13) coefficients, ignored
Gurobi Optimizer version 9.1.2 build v9.1.2rc0 (mac64)
Thread count: 10 physical cores, 10 logical processors, using up to 10 threads
Optimize a model with 10966 rows, 14532 columns and 34502 nonzeros
Model fingerprint: 0x461d8fa9
Model has 1424 quadratic constraints
Coefficient statistics:
Matrix range [1e-10, 2e+02]
QMatrix range [1e+00, 1e+00]
Objective range [5e-02, 2e+02]
Bounds range [0e+00, 0e+00]
RHS range [2e-16, 1e+00]
Presolve removed 8757 rows and 13081 columns
Presolve time: 0.01s
Presolved: 3186 rows, 1452 columns, 14134 nonzeros
Presolved model has 18 second-order cone constraints
Ordering time: 0.00s
Barrier statistics:
Dense cols : 2
AA' NZ : 5.735e+04
Factor NZ : 7.122e+04 (roughly 2 MBytes of memory)
Factor Ops : 1.852e+06 (less than 1 second per iteration)
Threads : 1
Objective Residual
Iter Primal Dual Primal Dual Compl Time
0 2.21287234e+05 -1.73440791e+02 4.78e+01 4.16e+01 8.97e+02 0s
1 3.82273035e+04 -3.14634047e+02 2.82e+00 4.57e-05 5.82e+01 0s
2 3.26685461e+02 -1.24579985e+02 1.57e-02 5.03e-11 3.70e-01 0s
3 9.76422795e+01 2.65467694e+01 2.34e-03 2.44e-12 5.46e-02 0s
4 6.92994600e+01 4.30891493e+01 6.51e-04 2.27e-12 1.49e-02 0s
5 5.97815740e+01 5.37016411e+01 1.03e-04 8.90e-12 2.59e-03 0s
6 5.86857828e+01 5.68264081e+01 4.88e-05 6.73e-11 9.39e-04 0s
7 5.82689768e+01 5.75733083e+01 2.77e-05 1.82e-10 4.26e-04 0s
8 5.81170881e+01 5.77826400e+01 1.82e-05 2.77e-10 2.71e-04 0s
9 5.80837755e+01 5.79028582e+01 1.58e-05 2.74e-10 2.28e-04 0s
10 5.80243008e+01 5.82428296e+01 1.28e-05 3.69e-10 1.72e-04 0s
11 5.80097494e+01 5.86951251e+01 1.20e-05 4.14e-10 1.56e-04 0s
12 5.80001833e+01 6.06212211e+01 1.15e-05 4.73e-10 1.49e-04 0s
13 5.79973689e+01 6.36329576e+01 1.14e-05 4.82e-10 1.47e-04 0s
14 5.79977310e+01 6.70052428e+01 1.13e-05 4.87e-10 1.43e-04 0s
15 5.80003575e+01 7.34829932e+01 1.13e-05 8.29e-10 1.54e-04 0s
16 5.80005566e+01 9.09825838e+01 1.12e-05 1.83e-09 1.55e-04 0s
17 5.80022950e+01 1.05096568e+02 1.12e-05 3.42e-09 1.65e-04 0s
18 5.80028496e+01 1.61313029e+02 1.12e-05 6.12e-09 1.88e-04 0s
19 5.80014017e+01 1.95225225e+02 1.12e-05 1.10e-08 2.63e-04 0s
20 5.79994581e+01 2.24864248e+02 1.11e-05 1.16e-08 2.87e-04 1s
21 5.79985434e+01 2.22766469e+02 1.10e-05 1.17e-08 3.48e-04 1s
22 5.79970030e+01 3.87008928e+02 1.08e-05 1.45e-08 4.72e-04 1s
23 5.79967358e+01 3.86701360e+02 1.08e-05 3.01e-08 4.70e-04 1s
24 5.79964534e+01 4.23705061e+02 1.08e-05 3.06e-08 4.85e-04 1s
25 5.79968623e+01 5.31689057e+02 1.08e-05 3.65e-08 5.71e-04 1s
26 5.79940398e+01 5.10457187e+02 2.05e-05 2.35e-08 5.78e-04 1s
27 5.79918347e+01 5.51399077e+02 2.28e-05 3.73e-08 5.94e-04 1s
28 5.79913779e+01 5.52979515e+02 2.24e-05 3.21e-08 5.94e-04 1s
29 5.79929819e+01 1.22270935e+03 2.24e-05 8.42e-08 7.57e-04 1s
30 5.79922631e+01 1.21908143e+03 2.22e-05 6.67e-08 7.57e-04 1s
31 5.79893108e+01 1.29102123e+03 2.40e-05 7.81e-08 7.83e-04 1s
32 5.79913256e+01 1.28975630e+03 2.54e-05 9.84e-08 7.78e-04 1s
33 5.79909296e+01 1.30200208e+03 2.52e-05 9.27e-08 7.79e-04 1s
34 5.79909421e+01 1.29274612e+03 2.50e-05 8.95e-08 7.84e-04 1s
35 5.79874095e+01 1.53783595e+03 3.14e-05 2.37e-07 1.02e-03 1s
36 5.79884058e+01 1.56245906e+03 1.96e-05 2.36e-07 2.89e-03 1s
37 5.79858881e+01 1.56901426e+03 2.25e-05 2.29e-07 5.45e-03 1s
38 5.79835100e+01 1.53329063e+03 2.41e-05 1.41e-07 5.21e-03 1s
39 5.79831365e+01 1.53779330e+03 2.40e-05 1.37e-07 5.19e-03 1s
40 5.79822585e+01 1.53421992e+03 2.36e-05 1.36e-07 5.17e-03 1s
41 5.79834577e+01 1.53727055e+03 2.36e-05 1.51e-07 5.17e-03 1s
42 5.79806004e+01 1.60983754e+03 6.21e-05 1.59e-07 4.90e-03 1s
43 5.79802948e+01 1.60977338e+03 6.21e-05 1.79e-07 4.93e-03 2s
44 5.79804130e+01 1.42426983e+03 5.59e-05 1.30e-07 4.54e-03 2s
45 5.79786565e+01 1.29533945e+03 5.88e-05 9.80e-08 4.30e-03 2s
46 5.79773755e+01 1.23998197e+03 5.86e-05 1.50e-07 4.09e-03 2s
47 5.79769454e+01 1.23800246e+03 5.83e-05 1.47e-07 4.14e-03 2s
48 5.79757628e+01 1.32016353e+03 5.96e-05 1.43e-07 4.18e-03 2s
49 5.79742249e+01 1.23803954e+03 5.86e-05 1.14e-07 4.01e-03 2s
50 5.79713543e+01 1.19958479e+03 4.93e-05 1.18e-07 3.96e-03 2s
51 5.79710969e+01 1.06478954e+03 5.87e-05 1.31e-07 3.71e-03 2s
52 5.79708131e+01 9.94896393e+02 5.76e-05 1.33e-07 3.51e-03 2s
53 5.79704435e+01 8.91724522e+02 5.64e-05 1.24e-07 3.16e-03 2s
54 5.79678826e+01 8.63302688e+02 5.70e-05 1.24e-07 3.07e-03 2s
55 5.79670777e+01 2.64516718e+03 5.66e-05 2.02e-07 5.61e-03 2s
56 5.79631267e+01 2.61139765e+03 5.54e-05 1.24e-07 5.51e-03 2s
57 5.79629969e+01 1.62964700e+04 5.53e-05 1.42e-06 2.44e-02 2s
58 9.25155313e+06 -4.23730918e+03 2.00e+03 1.00e+03 8.86e+05 2s
59 4.07016674e+06 -3.75859891e+03 6.95e+02 3.51e+02 1.94e+05 2s
60 3.44397954e+05 -4.46690613e+02 6.80e+01 3.45e-05 1.77e+03 2s
61 6.80380767e+03 -4.26354552e+02 1.41e+00 9.23e-08 3.65e+01 2s
62 2.31963100e+02 -9.79111835e+01 5.82e-02 2.61e-09 1.42e+00 2s
63 1.05697626e+02 1.58424077e+01 1.93e-02 3.98e-10 3.79e-01 2s
64 6.39485675e+01 2.55612562e+01 4.47e-03 2.53e-10 7.76e-02 2s
65 6.02250154e+01 4.51678016e+01 2.00e-03 9.61e-11 1.88e-02 2s
66 5.91749849e+01 5.16914605e+01 1.28e-03 4.20e-11 8.03e-03 2s
67 5.82368547e+01 5.56209974e+01 5.70e-04 4.85e-11 2.34e-03 2s
68 5.79588611e+01 5.67344579e+01 2.67e-04 3.07e-10 9.61e-04 2s
69 5.78551155e+01 5.74064317e+01 1.25e-04 1.07e-09 3.84e-04 2s
70 5.78345768e+01 5.75546339e+01 9.25e-05 1.17e-09 2.67e-04 2s
71 5.78324681e+01 5.76044015e+01 6.70e-05 1.26e-09 1.97e-04 2s
72 5.78311057e+01 5.77493486e+01 4.59e-05 2.55e-09 1.18e-04 2s
73 5.78389290e+01 5.78054092e+01 3.33e-05 3.68e-09 8.96e-05 2s
74 5.78479309e+01 5.78165762e+01 2.63e-05 9.80e-09 7.88e-05 2s
75 5.78648469e+01 5.78366143e+01 2.30e-05 2.16e-08 9.47e-05 2s
76 5.78791807e+01 5.78554627e+01 2.05e-05 2.40e-08 1.08e-04 2s
77 5.79430010e+01 5.79160011e+01 1.83e-05 3.15e-08 1.87e-04 2s
78 5.79640006e+01 5.79417160e+01 1.77e-05 3.11e-08 2.16e-04 2s
79 5.80533990e+01 5.82237373e+01 1.87e-05 3.92e-08 9.19e-04 2s
80 6.00077821e+01 5.89394628e+01 1.92e-05 4.91e-08 4.86e-03 2s
81 1.06865549e+02 1.20975872e+02 1.54e-05 2.72e-08 1.13e-01 2s
82 5.56932556e+03 2.17681270e+03 1.86e-05 1.54e-06 5.13e+00 2s
83 7.90503351e+03 7.51476461e+03 1.35e-05 8.78e-07 8.41e+00 2s
84 6.70770858e+04 8.02236324e+05 2.97e-05 1.39e-04 6.37e+02 2s
85 9.94898600e+04 9.99838298e+05 3.21e-05 1.73e-04 1.08e+03 2s
86* 1.28323993e+05 1.04788852e+06 1.93e-09 2.48e-09 2.89e-08 2s
87* 1.97093043e+05 1.25121430e+06 1.48e-09 2.87e-09 2.74e-08 2s
88* 1.98587820e+05 1.26015666e+06 1.48e-09 2.86e-09 2.76e-08 3s
89* 2.44535127e+05 1.50607487e+06 1.29e-09 4.16e-09 3.13e-08 3s
90* 1.67044332e+06 4.85293580e+06 3.43e-10 8.70e-09 1.69e-08 3s
91* 1.93330721e+06 5.20846368e+06 3.59e-10 9.79e-09 1.52e-08 3s
92* 2.36769546e+06 6.20421717e+06 4.08e-10 1.11e-08 1.50e-08 3s
93* 3.59500195e+06 1.03650815e+07 3.68e-10 1.73e-08 1.72e-08 3s
94* 4.97113012e+06 1.54146547e+07 4.15e-10 2.64e-08 2.08e-08 3s
95* 7.51390412e+06 1.98217080e+07 5.90e-10 3.10e-08 1.67e-08 3s
96* 3.03216311e+07 6.06858954e+07 1.18e-09 5.73e-08 6.26e-09 3s
97* 4.96756826e+07 8.74297555e+07 2.54e-09 6.13e-08 4.25e-09 3s
98* 7.93153333e+07 1.30860803e+08 7.63e-09 6.79e-08 3.02e-09 3s
Barrier performed 98 iterations in 2.67 seconds
Infeasible model
User-callback calls 351, time in user-callback 0.02 sec
------------------------------------------------------------
Status: Failed
Optimal value (cvx_optval): NaN
-
Official comment
This post is more than two 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 try Gurobot, our chatbot interface offering instant, expert-level support. -
Hi Vinnet,
This can be caused by a numerically unstable model. Given the coefficient statistic of your model
Matrix range [1e-10, 2e+02] QMatrix range [1e+00, 1e+00] Objective range [5e-02, 2e+02] Bounds range [0e+00, 0e+00] RHS range [2e-16, 1e+00]
it is very likely that your model can have numerical issues. Please have a look at our Guidelines for Numerical Issues and try to improve the coefficient statistics. There is also the Warning
Warning for adding variables: zero or small (< 1e-13) coefficients, ignored
which means that any coefficient with a value lower than \( 10^{-13}\) will be treated as \(0\). If any of this coefficient is significant for the feasibility of the model, then this is also a possible cause of trouble.
Moreover, you should upgrade to the latest version of Gurobi to profit from bug fixes and improved performance.
Best regards,
Jaromił0
Post is closed for comments.
Comments
2 comments