quadprog different output for R2020a and R2017a

8 ビュー (過去 30 日間)
Kyril Kaufmann
Kyril Kaufmann 2020 年 5 月 4 日
コメント済み: Kyril Kaufmann 2020 年 5 月 6 日
Hello,
If I run quadprog minimization function I get completely different results on R2020a and R2017a. It seems that the output on the lattest release is wrong. Did something changed? Is it a bug you are aware of?
Kind regards
  5 件のコメント
Jason Nicholson
Jason Nicholson 2020 年 5 月 5 日
Okay. I will take a look. My hunch is your H has a high condition number. I'll explain more if that is the issue.
Kyril Kaufmann
Kyril Kaufmann 2020 年 5 月 5 日
That's really nice of you.
For the moment I run the code with the 2017 release and it gives me nice results so it's not urgent. Thanks so much

サインインしてコメントする。

採用された回答

Jason Nicholson
Jason Nicholson 2020 年 5 月 6 日
There is an option called 'LinearSolver'. It can be dense or sparse. I set it to sparse and it converged quickly.
This problem is solvable but be careful with the condition number of the H matrix. i.e. cond(H). The higher the condition number, the more ill-conditioned the problem. ill-condition problems are harder to solve. With the generic cost: J = 1/2*x'*H*x+f'*x. Small pertubations to f will cause large changes to the solution, x.
% Load files
structure = load('quadprog_input.mat');
H = structure.quadprog_input.H; % 404x404 matrix
f = structure.quadprog_input.f; % 1x404 vector
Aineq = structure.quadprog_input.Aineq; % 808x404 matrix
bineq = structure.quadprog_input.bineq; % 808x1 vector
% opt = structure.quadprog_input.opt;
% with opt.TolCon = 100*eps, opt.TollFun = 100*eps, opt.Display = 'none',
% opt.Algorithm = 'interior-point-convex
Aeq = [];
beq = [];
f = f'; % f should be 404x1
% Objective is 1/2*dp'*2*H*dp+f'*dp
%
% dp' is 1x404
% dp is 404x1
% 2*H is 404x404
% f is 404x1
% f' is 1x404
%
% 1/2*dp' * 2*H *dp + f' *dp
% 1x404 404x404 404x1 1x404 404x1
% 1x1 + 1x1
% 1x1
% Thus, f should be 404x1
%
opt = optimoptions('quadprog', 'TolCon', 100*eps, 'TolFun', 100*eps, ...
'Display', 'iter-detailed', 'Algorithm', 'interior-point-convex', ...
'MaxIter', 1500,'LinearSolver','sparse');
% Best case cost ignoring constraints
[~,fval,~] = quadprog(2*H,f,[], [], [], [],[],[],[],opt)
% solve quadprog problem. Note this doesn't converge
[dp,fval,~] = quadprog(2*H,f,Aineq, bineq, Aeq, beq,[],[],[],opt); fval
  2 件のコメント
Jason Nicholson
Jason Nicholson 2020 年 5 月 6 日
FYI, if this is a linear fitting problem that you have converted to quadratic program. I have another option for you. However, I will need your C matrix in H=C'*C.
Kyril Kaufmann
Kyril Kaufmann 2020 年 5 月 6 日
Hello, thanks for your support. No it's not a linear fitting.
With your set of options it works! At least my power imput (dp) is within meaningfull physical range. I'm not sure though what happend here...

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeQuadratic Programming and Cone Programming についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by