当前位置:网站首页>[MPC] ② quadprog solves positive definite, semi positive definite and negative definite quadratic programming
[MPC] ② quadprog solves positive definite, semi positive definite and negative definite quadratic programming
2022-07-01 10:21:00 【Houchang Village Road caixukun】
List of articles

One 、 summary
The first issue of the article has already introduced , Quadratic programming problem and matlab Of quadprog How to use the function , Details visible :quadprog Function details . In the quadratic programming problem , According to the positive definiteness of Hessian matrix , Quadratic programming problems can be divided into strictly convex 、 Convex 、 Nonconvex quadratic problem . In order to verify ,matlab Of quadprog Function's ability to solve three quadratic problems , In this paper, various types of Hessian matrices are generated , And try quadprog To solve the .
Two 、Matlab verification
( One ) Hessen positive definite 、 Semi positive definite 、 Negative definite matrix generation
Hessian matrix first needs to satisfy matrix symmetry , At the same time, the positive definiteness of the matrix is determined according to the eigenvalue . therefore , For simplicity, the diagonal matrix is generated directly for verification .
H_posi=diag([1,2,3]);
H_semi=diag([0,2,3]);
H_nega=diag([-1,-2,-3]);
( Two ) Matrix positive definiteness verification
Matrix positive definiteness judgment : Mainly to make use of eig Function to solve the eigenvalue of a matrix , And judge the positive and negative of single eigenvalue .
% Judgment matrix m It's positive definite 、 Semi positive definite or negative definite
% Matrix input required m
% for example :m = [2 -1; -1 2];
if issymmetric(m) % Check whether the matrix is symmetrical
% disp(' Matrix symmetry ');
d = eig(m); % Calculate the eigenvalue of the matrix
if all(d > 0)
disp(' The matrix is positive definite ');
elseif all(d >= 0)
disp(' Matrix positive semidefinite ');
else
disp(' Matrix negative definite ');
end
else
disp(' Matrix asymmetry ');
end
( 3、 ... and ) Various types of quadratic solver
clear;clc;
H_posi=diag([1,2,3]);
H_semi=diag([0,2,3]);
H_nega=diag([-1,-2,-3]);
A = [1 1 1; -1 2 1; 2 1 1];
b = [2; 2; 3];
f = [2;-3;1];
lb = zeros(3,1);
ub = ones(size(lb));
Aeq = ones(1,3);
beq = 1/2;
x_posi = quadprog(H_posi,f,A,b,Aeq,beq,lb,ub)
x_semi = quadprog(H_semi,f,A,b,Aeq,beq,lb,ub)
x_nega = quadprog(H_nega,f,A,b,Aeq,beq,lb,ub)
3、 ... and 、 Solution result
Three types of quadratic programming problems ,quadprog Functions can be solved . But the nonconvex case , There will be non convex function prompt .
Find the minimum value that meets the constraint .
Optimization completed , Because the objective function does not decrease in the feasible direction . Do not reduce in the feasible direction , Within the optimality tolerance .
And the constraint conditions are satisfied within the allowable value of the constraint conditions . < Stop standard details >
Four 、quadprog Algorithm to choose
quadprog The solver contains three quadratic programming algorithms , have access to optimoptions To configure Algorithm Options .
- ‘interior-point-convex’( The default value is )
- ‘trust-region-reflective’
- 'active-set
Algorithm selection principle :
- If you encounter a convex problem , Or don't know if your problem is convex , Please use ‘interior-point-convex’.
- If your nonconvex problem has only boundaries or only linear equality constraints , Please use ‘trust-region-reflective’.
- If you have a positive semidefinite problem with a large number of linear constraints without a large number of variables , Please try ‘active-set’.
边栏推荐
- 客户端如何请求数据库?
- 项目必用的全局异常处理器,你学会了吗
- Change password of MySQL version 5.7 and 8.0
- Po mode deep encapsulation
- Does anyone know the logic of limit statement execution in Clickhouse? In the picture, the SQL above can be executed successfully
- 零基础入门测试该学什么?最全整理,照着学就对了
- The programmer was beaten.
- [fxcg] large scale job hopping may be one of the driving forces behind the soaring inflation in the United States
- 在通达信上买基金安全吗?
- MySQL常用命令
猜你喜欢

机器学习之线性回归详解

CRC 校驗

Wireshark TS | 快速重传和乱序之混淆

How to solve the problem of SQL?

《百年巨匠》数字藏品中奖名单公布

If you meet a female driver and drive didi as an amateur, you can earn 500 a day!

Japanese professor sues Intel FPGA and SOC products for infringing a design patent

Finally, someone made it clear what DRAM and NAND flash are

Continue to advance, and softcom power steadily promotes cloud intelligence strategy

Win11账号被锁定无法登录怎么办?Win11账号被锁定无法登录
随机推荐
STM32逆变器电源设计方案,基于STM32F103控制器[通俗易懂]
Introduction of uniapp wechat applet components on demand
《天天数学》连载55:二月二十四日
Venv: directory structure of venv
Kotlin 协程调度切换线程是时候解开真相了
缺少比较器,运放来救场!(运放当做比较器电路记录)
What legal risks and qualifications should be paid attention to when building a digital collection platform?
Ssh server rejects password, try again; Permitrootlogin yes invalid problem
.NET 5.0+ 无需依赖第三方 原生实现定时任务
About widthstep of images in opencv
How to solve the problem of SQL?
SSH服务器拒绝密码,再试一次;PermitRootLogin yes无效问题
SQLAchemy 常用操作
IDEA运行报错Command line is too long. Shorten command line for...
The "China Mobile Chain" state secret engine was officially launched on BSN
sql语句修改字段类型「建议收藏」
CRC verification
C [byte array] and [hexadecimal string] mutual conversion - codeplus series
Programmers want to go to state-owned enterprises? The technology is backward and the salary is low. I can't find a job after lying flat for several years
线程基础知识