Solving QP problem using Gurobi in Matlab wrong optimization results
I'm trying to solve a QP problem using Gurobi in Matlab. For a sparse and dense formulation it works fine, but for the sparse condensed formulation, I get wrong results. Furthermore, I get different results without model.ub and model.lb, which should not be the case, because the bound constraints are also determined in the inequality constraint. Does anyone have a clue what I am doing wrong? If you think you need more information, please let me know!
I use the following code for the sparse condensed formulation:
model.A = sparse(Aineq_SparseCondensed); % Aineq*x ≤ bineq
model.sense = repmat('<',size(Aineq_SparseCondensed,1),1); % Defines that it is an inequality constraint
model.rhs = full(bineq_SparseCondensed(:));
model.Q = G; % G is the Hessian
model.obj = F; % F is the lineair term
model.lb = zeros(N*n_u,1); % lower bound of decision variables
model.ub = 10*ones(N*n_u,1); % upper bound of decision variables
params.outputflag = 0;
tic;
X = gurobi(model,params);
toc
Example of a good result (from dense formulation using Gurobi)
Wrong results of the sparse condensed formulation (for different horizons (see Model Predictive Control) different results are obtained, which is also wrong). The information between brackets is not really important to fix the problem:
Kind regards,
-
This is the output file, where it is stated that is a suboptimal solution. Does anyone know what is wrong?
Gurobi Optimizer version 9.0.0 build v9.0.0rc2 (win64)
Optimize a model with 1200 rows, 600 columns and 123120 nonzeros
Model fingerprint: 0xe662f7d9
Model has 180208 quadratic objective terms
Coefficient statistics:
Matrix range [2e-09, 6e+01]
Objective range [2e+00, 3e+03]
QObjective range [9e-06, 1e+05]
Bounds range [0e+00, 0e+00]
RHS range [1e+01, 1e+01]
Warning: Model contains large quadratic objective coefficient range
Consider reformulating model or setting NumericFocus parameter
to avoid numerical issues.
Presolve removed 984 rows and 0 columns
Presolve time: 0.07s
Presolved: 216 rows, 816 columns, 61392 nonzeros
Presolved model has 180208 quadratic objective terms
Ordering time: 0.00sBarrier statistics:
Free vars : 599
AA' NZ : 3.310e+05
Factor NZ : 3.325e+05 (roughly 4 MBytes of memory)
Factor Ops : 1.808e+08 (less than 1 second per iteration)
Threads : 4Objective Residual
Iter Primal Dual Primal Dual Compl Time
0 -4.17510601e+08 -1.63056159e+06 8.29e+04 4.40e+02 1.00e+06 0s
1 -2.82756548e+07 -2.55465846e+06 5.78e+03 6.87e+01 7.47e+04 0s
2 -3.57724334e+06 -2.07988024e+06 7.34e+02 8.72e+00 1.20e+04 0s
3 -7.39341661e+05 -1.20087103e+06 1.50e+02 1.62e+00 3.11e+03 0s
4 -1.75885703e+05 -7.33675200e+05 3.50e+01 4.06e-01 1.16e+03 0s
5 -3.64750286e+04 -3.16463485e+05 7.45e+00 7.91e-02 3.66e+02 0s
6 -1.36910620e+04 -1.19999492e+05 1.40e+00 1.09e-02 1.04e+02 0s
7 -1.61380338e+04 -3.45478087e+04 1.49e-02 7.91e-05 1.32e+01 1s
8 -2.02387236e+04 -3.04987488e+04 1.58e-06 7.77e-11 7.25e+00 1s
9 -2.23393760e+04 -2.41207684e+04 1.44e-07 1.75e-11 1.26e+00 1s
10 -2.28586854e+04 -2.32352618e+04 1.53e-10 1.11e-11 2.66e-01 1s
11 -2.29762400e+04 -2.30156695e+04 1.47e-09 6.67e-12 2.78e-02 1s
12 -2.29900894e+04 -2.29923534e+04 9.20e-11 8.06e-12 1.60e-03 1s
13 -2.29909847e+04 -2.29909879e+04 1.66e-09 8.91e-12 2.26e-06 1s
14 -2.29909847e+04 -2.29909879e+04 1.51e-07 1.01e-11 2.23e-06 1s
15 -2.29909848e+04 -2.29909879e+04 1.73e-07 7.75e-12 2.22e-06 1s
16 -2.29909851e+04 -2.29909879e+04 3.37e-07 8.53e-12 2.21e-06 1s
17 -2.29909856e+04 -2.29909878e+04 5.15e-07 1.36e-11 2.05e-06 1s
18 -2.29909858e+04 -2.29909876e+04 6.11e-07 1.10e-11 1.86e-06 1s
19 -2.29909861e+04 -2.29909876e+04 6.91e-07 7.31e-12 1.86e-06 1s
20 -2.29909845e+04 -2.29909877e+04 1.02e-06 7.55e-12 1.77e-06 1s
21 -2.29909834e+04 -2.29909872e+04 1.67e-06 1.03e-11 1.21e-06 1s
22 -2.29909837e+04 -2.29909872e+04 3.32e-06 8.77e-12 1.18e-06 1s
23 -2.29909841e+04 -2.29909872e+04 4.22e-06 7.25e-12 1.13e-06 1s
24 -2.29909882e+04 -2.29909868e+04 6.78e-06 1.14e-11 7.41e-07 1s
25 -2.29909835e+04 -2.29909867e+04 7.27e-06 7.24e-12 5.63e-07 1s
26 -2.29909877e+04 -2.29909867e+04 1.48e-05 6.81e-12 5.05e-07 1s
27 -2.29909997e+04 -2.29909866e+04 1.61e-05 9.28e-12 4.08e-07 1s
28 -2.29909904e+04 -2.29909865e+04 1.60e-05 8.22e-12 3.43e-07 1s
29 -2.29909456e+04 -2.29909865e+04 2.42e-05 4.90e-12 2.77e-07 1s
30 -2.29909989e+04 -2.29909864e+04 4.94e-05 5.75e-12 2.40e-07 1s
31 -2.29909556e+04 -2.29909864e+04 5.13e-05 7.83e-12 1.45e-07 1s
32 -2.29910192e+04 -2.29909864e+04 1.52e-04 6.57e-12 1.42e-07 1s
33 -2.29909610e+04 -2.29909863e+04 1.26e-04 6.88e-12 1.01e-07 1s
34 -2.29909403e+04 -2.29909864e+04 1.27e-04 7.17e-12 9.92e-08 1s
35 -2.29910019e+04 -2.29909863e+04 2.22e-04 5.94e-12 6.37e-08 1s
36 -2.29910984e+04 -2.29909864e+04 3.28e-04 6.34e-12 6.00e-08 1s
37 -2.29919336e+04 -2.29909864e+04 5.51e-04 5.59e-12 5.94e-08 2s
38 -2.29913987e+04 -2.29909865e+04 5.78e-04 4.87e-12 4.40e-08 2s
39 -2.29900550e+04 -2.29909869e+04 5.90e-04 8.16e-12 3.28e-08 2s
40 -2.29862010e+04 -2.29909875e+04 9.50e-04 7.44e-12 2.65e-08 2s
41 -2.29855414e+04 -2.29909888e+04 1.81e-03 1.10e-11 2.65e-08 2s
42 -2.29873605e+04 -2.29909889e+04 2.82e-03 9.59e-12 2.65e-08 2s
43 -2.29928240e+04 -2.29909890e+04 7.60e-03 6.50e-12 2.65e-08 2s
44 -2.30004372e+04 -2.29909892e+04 1.38e-02 1.02e-11 2.65e-08 2s
45 -2.29745207e+04 -2.29911125e+04 1.44e-02 1.23e-11 2.46e-08 2s
46 -2.29867578e+04 -2.29912354e+04 3.79e-02 8.26e-12 2.21e-08 2s
47 -2.29637766e+04 -2.29913974e+04 1.99e-02 9.45e-12 2.15e-08 2s
48 -2.30107063e+04 -2.29920147e+04 3.06e-02 9.20e-12 2.10e-08 2s
49 -2.30354049e+04 -2.29921821e+04 9.36e-02 7.27e-12 1.58e-08 2s
50 -2.28805300e+04 -2.29927785e+04 1.24e-01 7.84e-12 1.70e-08 2s
51 -2.29373508e+04 -2.29982794e+04 1.51e-01 1.44e-11 1.31e-08 2s
52 -2.29296386e+04 -2.29982466e+04 1.76e-01 1.09e-11 1.36e-08 2s
53 -2.28385527e+04 -2.29987450e+04 1.55e-01 1.36e-11 1.51e-08 2s
54 -2.30951167e+04 -2.29992792e+04 3.92e-01 1.32e-11 1.51e-08 2s
55 -2.28863943e+04 -2.30160183e+04 3.49e-01 2.03e-11 1.06e-07 2sBarrier performed 55 iterations in 2.03 seconds
Sub-optimal termination - objective -2.29909847e+040
Please sign in to leave a comment.
Comments
1 comment