当前位置:网站首页>[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’.
边栏推荐
- PHP string to binary conversion
- 线程基础知识
- Who's still buying three squirrels
- Hardware midrange project
- Fried money, lost 10million.
- C# [字节数组]与[16进制字符串]互相转换 - CodePlus系列
- Design and practice of new generation cloud native database
- 12. Gateway new generation gateway
- Ssh server rejects password, try again; Permitrootlogin yes invalid problem
- CRC verification
猜你喜欢

leetcode:111. Minimum depth of binary tree

渗透常用工具-Goby

Sleeping second brother...

SQL server2014 failed to delete the database, with an error offset of 0x0000

uniapp微信小程序组件按需引入

新品大揭秘!雅迪冠能 3 多元产品矩阵,满足全球用户出行需求

Floyd repeat

Venv: directory structure of venv

CRC check

The stock position building rate of global funds and asset management reached a new low in 15 years
随机推荐
【邂逅Django】——(二)数据库配置
Is it safe to buy funds on the access letter?
树莓派4B系统搭建(超详细版)
有大佬知道这是为啥吗?表结构都是刚直接复制的源表 mysql-cdc
C# 一行代码计算文件的MD5值 - CodePlus系列
Who's still buying three squirrels
C one line code calculates the MD5 value of the file - codeplus series
程序员都想去国企?技术落后薪资低,躺平几年出来都找不到工作...
数字藏品新一轮热度开启
TC8:UDP_ USER_ INTERFACE_ 01-08
【MPC】①二次规划问题MATLAB求解器quadprog
Graduation summary of actual combat camp
The programmer was beaten.
CodeBlocks 左侧项目栏消失,workspace 自动保存项目,Default workspace,打开上次的workspace,工作区(图文教程,已解决)
Introduction of uniapp wechat applet components on demand
《天天数学》连载55:二月二十四日
Ubuntu system installation and MySQL configuration
.NET 5.0+ 无需依赖第三方 原生实现定时任务
The "China Mobile Chain" state secret engine was officially launched on BSN
I like two men...