coneprog
二级锥编程求解器
句法
Description
这coneprog
Function is a second-order cone programming solver that finds the minimum of a problem specified by
受约束的约束
F,,,,X,,,,b,,,,beq,,,,lb,,,,和UB是向量,一个和AEQare matrices. For each一世, 矩阵一个sc((一世),向量dsc((一世)和bsc((一世)和标量γ((一世)are in a second-order cone constraint that you create usingsecondordercone
。
有关锥体约束的更多详细信息,请参阅Second-Order Cone Constraint。
Examples
单锥约束
to set up a problem with a second-order cone constraint, create a second-order cone constraint object.
a = diag([1,1/2,0]);b =零(3,1);d = [0; 0; 1];伽马= 0;socConstraints = secondorderCone(a,b,d,伽马);
创建目标函数向量。
f = [-1,-2,0];
这problem has no linear constraints. Create empty matrices for these constraints.
aineq = [];bineq = [];aeq = [];beq = [];
将上限和下限设置为X((3)
。
lb = [-inf,-inf,0];ub = [inf,inf,2];
通过使用coneprog
功能。
[[X,,,,Fval] = coneprog(f,socConstraints,Aineq,bineq,Aeq,beq,lb,ub)
找到最佳解决方案。
x =3×10。4851 3.8806 2.0000
FVAL = -8.2462
这solution componentX((3)
处于上限。圆锥约束在解决方案上处于活动状态:
norm(A*x-b) - d'*x当约束处于活动状态时,%接近0
ANS = -2.5677E -08
几个圆锥约束
要设置有几个二阶锥体约束的问题,请创建一个约束对象。为了节省时间和内存,请先创建最高的索引约束。
a = diag([1,2,0]);b =零(3,1);d = [0; 0; 1];伽马= -1;socconstraints(3)= secondorderCone(a,b,d,伽马);a = diag([3,0,1]);d = [0; 1; 0];socconstraints(2)= secondordercone(a,b,d,伽马);a = diag([0; 1/2; 1/2]);d = [1; 0; 0]; socConstraints(1) = secondordercone(A,b,d,gamma);
Create the linear objective function vector.
f = [-1; -2; -4];
通过使用coneprog
功能。
[x,fval] = coneprog(f,socconstraints)
找到最佳解决方案。
x =3×10。4238 1.6477 2.3225
FVAL = -13.0089
Cone Programming with Linear Constraints
Specify an objective function vector and a single second-order cone constraint.
f = [-4; -9; -2];asc = diag([1,4,0]);b = [0; 0; 0];d = [0; 0; 1];伽马= 0;socConstraints = secondorderCone(ASC,B,D,Gamma);
指定线性不等式约束。
a = [1/4,1/9,1];b = 5;
Solve the problem.
[x,fval] = coneprog(f,socconstraints,a,b)
找到最佳解决方案。
x =3×13.2304 0.6398 4.1213
FVAL=-26.9225
带有非默认选项的锥编程
to observe the iterations of theconeprog
求解器,设置展示
option to'iTer'
。
options = optimoptions('coneprog',,,,'Display',,,,'iTer');
创建二阶锥体编程问题,并使用options
。
ASC = diag([1,1/2,0]);b =零(3,1);d = [0; 0; 1];伽马= 0;socConstraints = secondorderCone(ASC,B,D,Gamma);f = [-1,-2,0];aineq = [];bineq = [];aeq = [];beq = []; lb = [-Inf,-Inf,0]; ub = [Inf,Inf,2]; [x,fval] = coneprog(f,socConstraints,Aineq,bineq,Aeq,beq,lb,ub,options)
Iter Fval Primal Infeas Dual Infeas Duality Gap Time 1 0.000000e+00 0.000000e+00 5.714286e-01 1.250000e-01 0.03 2 -7.558066e+00 0.000000e+00 7.151114e-02 1.564306e-02 0.04 3 -7.366973e+00 0.000000e+00 1.075440e-02 2.352525e-03 0.05 4 -8.243432e+00 0.000000e+00 5.191882e-05 1.135724e-05 0.05 5 -8.246067e+00 1.387779e-17 2.430813e-06 5.317403e-07 0.05 6 -8.246211e+00 0.000000e+00 6.154504e-09 1.346298e-09 0.05 Optimal solution found.
x =3×10。4851 3.8806 2.0000
FVAL = -8.2462
Cone Programming with Problem Structure
创建二阶锥体编程问题的元素。为了节省时间和内存,请先创建最高的索引约束。
a = diag([1,2,0]);b =零(3,1);d = [0; 0; 1];伽马= -1;socconstraints(3)= secondorderCone(a,b,d,伽马);a = diag([3,0,1]);d = [0; 1; 0];socconstraints(2)= secondordercone(a,b,d,伽马);a = diag([0; 1/2; 1/2]);d = [1; 0; 0]; socConstraints(1) = secondordercone(A,b,d,gamma); f = [-1;-2;-4]; options = optimoptions('coneprog',,,,'Display',,,,'iTer');
Create a problem structure with the required fields, as described inproblem。
问题= struct('F',,,,F,,,,...'socConstraints',,,,社会,,,,...'aineq',,,,[[],'bineq',,,,[[],...'Aeq',,,,[[],'beq',,,,[[],...'lb',,,,[[],'ub',,,,[[],...“求解器”,,,,'coneprog',,,,...'options',,,,options);
通过打电话解决问题coneprog
。
[[X,,,,Fval] = coneprog(problem)
Iter Fval Primal Infeas Dual Infeas Duality Gap Time 1 0.000000e+00 0.000000e+00 5.333333e-01 5.555556e-02 0.18 2 -9.696012e+00 1.850372e-17 7.631901e-02 7.949897e-03 0.20 3 -1.178942e+01 9.251859e-18 1.261803e-02 1.314378e-03 0.20 4 -1.294426e+01 1.850372e-17 1.683078e-03 1.753206e-04 0.20 5 -1.295217e+01 1.850372e-17 8.994595e-04 9.369370e-05 0.21 6 -1.295331e+01 1.850372e-17 4.748841e-04 4.946709e-05 0.21 7 -1.300753e+01 9.251859e-18 2.799942e-05 2.916606e-06 0.21 8 -1.300671e+01 9.251859e-18 2.366136e-05 2.464725e-06 0.21 9 -1.300850e+01 1.850372e-17 8.187205e-06 8.528338e-07 0.21 10 -1.300843e+01 4.625929e-18 7.326330e-06 7.631594e-07 0.21 11 -1.300862e+01 9.251859e-18 2.707005e-06 2.819797e-07 0.21 12 -1.300892e+01 0.000000e+00 9.204457e-08 9.587976e-09 0.22 Optimal solution found.
x =3×10。4238 1.6477 2.3225
FVAL = -13.0089
Examineconeprog
解决方案过程
创建二阶锥体编程问题。为了节省时间和内存,请先创建最高的索引约束。
a = diag([1,2,0]);b =零(3,1);d = [0; 0; 1];伽马= -1;socconstraints(3)= secondorderCone(a,b,d,伽马);a = diag([3,0,1]);d = [0; 1; 0];socconstraints(2)= secondordercone(a,b,d,伽马);a = diag([0; 1/2; 1/2]);d = [1; 0; 0]; socConstraints(1) = secondordercone(A,b,d,gamma); f = [-1;-2;-4]; options = optimoptions('coneprog',,,,'Display',,,,'iTer'); A = []; b = []; Aeq = []; beq = []; lb = []; ub = [];
解决问题,请求有关解决方案过程的信息。
[[X,,,,Fval,exitflag,output] = coneprog(f,socConstraints,A,b,Aeq,beq,lb,ub,options)
Iter Fval Primal Infeas Dual Infeas Duality Gap Time 1 0.000000e+00 0.000000e+00 5.333333e-01 5.555556e-02 0.03 2 -9.696012e+00 5.551115e-17 7.631901e-02 7.949897e-03 0.03 3 -1.178942e+01 3.700743e-17 1.261803e-02 1.314378e-03 0.03 4 -1.294426e+01 1.850372e-17 1.683078e-03 1.753206e-04 0.03 5 -1.295217e+01 9.251859e-18 8.994595e-04 9.369370e-05 0.03 6 -1.295331e+01 9.251859e-18 4.748841e-04 4.946709e-05 0.03 7 -1.300753e+01 9.251859e-18 2.799942e-05 2.916606e-06 0.03 8 -1.300671e+01 9.251859e-18 2.366136e-05 2.464725e-06 0.04 9 -1.300850e+01 9.251859e-18 8.222244e-06 8.564838e-07 0.04 10 -1.300843e+01 1.850372e-17 7.318333e-06 7.623264e-07 0.04 11 -1.300865e+01 9.251859e-18 2.636568e-06 2.746425e-07 0.04 12 -1.300892e+01 1.850372e-17 3.407939e-08 3.549936e-09 0.04 Optimal solution found.
x =3×10。4238 1.6477 2.3225
FVAL = -13.0089
出口=1
output =struct with fields:迭代:12原始性:1。8504e-17 dualfeasibility: 3.4079e-08 dualitygap: 3.5499e-09 algorithm: 'interior-point' linearsolver: 'augmented' message: 'Optimal solution found.'
迭代显示和输出结构都显示
coneprog
使用12个迭代来达到解决方案。这exit flag value
1
和output.message
value'Optimal solution found.'
表示解决方案是可靠的。这
output
结构表明,二元性差距也是通过溶液过程降低的。You can reproduce the
FVAL
output by multiplyingf'*x
。
f'*x
ANS = -13.0089
获得coneprog
Dual Variables
创建二阶锥体编程问题。为了节省时间和内存,请先创建最高的索引约束。
a = diag([1,2,0]);b =零(3,1);d = [0; 0; 1];伽马= -1;socconstraints(3)= secondorderCone(a,b,d,伽马);a = diag([3,0,1]);d = [0; 1; 0];socconstraints(2)= secondordercone(a,b,d,伽马);a = diag([0; 1/2; 1/2]);d = [1; 0; 0]; socConstraints(1) = secondordercone(A,b,d,gamma); f = [-1;-2;-4];
Solve the problem, requesting dual variables at the solution along with all otherconeprog
输出..
[X,FVAL,EXITFLAG,输出,lambda] = coneprog(F,,,,社会);
找到最佳解决方案。
Examine the returned兰姆达
结构体。Because the only problem constraints are cone constraints, examine only thesoc
字段兰姆达
结构体。
d一世sp(lambda.soc)
1。0e-05 * 0.0879 0.3002 0.0589
这些约束具有非零的二元值,表明在解决方案上的约束处于活动状态。
Input Arguments
F
-Coefficient vector
real vector|真正的数组
Coefficient vector, specified as a real vector or real array. The coefficient vector represents the objective functionf'*x
。符号假设F
是列向量,但是您可以使用行矢量或数组。在内部coneprog
convertsF
to the column vectorF((:)
。
Example:F=[[1,,,,3,,,,5,,,,-6]
数据类型:double
社会
-Second-order cone constraints
vector ofsecondorderconectraint
对象
二阶锥体约束,指定为secondorderconectraint
对象。使用secondordercone
功能。
社会
encodes the constraints
阵列和方程之间的映射如下:
一个sc((一世)=
社会。一个((一世)
bsc((一世)=
socconstraints.b(i)
dsc((一世)=
socconstraints.d(i)
γ((一世)=
社会。伽玛((一世)
Example:一个sc=d一世ag([1 1/2 0]); bsc = zeros(3,1); dsc = [0;0;1]; gamma = -1; socConstraints = secondordercone(Asc,bsc,dsc,gamma);
数据类型:struct
一个
-Linear inequality constraints
真正的矩阵
Linear inequality constraints, specified as a real matrix.一个
一世s anm
-by-n
matrix, wherem
一世s the number of inequalities, andn
一世s the number of variables (length ofF
)。对于大问题,通过一个
作为稀疏矩阵。
一个
encodes them
线性不平等
一个*x <= b
,,,,
在哪里X
是专栏向量n
变量X(:)
,,,,和b
是一个与m
元素。
例如,考虑以下不平等:
X1+2X2≤10
3X1+4X2≤20
5X1+6X2≤30。
Specify the inequalities by entering the following constraints.
a = [1,2; 3,4; 5,6];b = [10; 20; 30];
Example:要指定X组件总计高达1或更少,请服用a =一个(1,n)
和b=1
。
数据类型:double
b
-Linear inequality constraints
real vector
线性不等式约束,指定为真实向量。b
一世s anm
- 元素向量与一个
矩阵。如果您通过b
作为行矢量,求解器内部转换b
to the column vectorb((:)
。对于大问题,通过b
as a sparse vector.
b
encodes them
线性不平等
一个*x <= b
,,,,
在哪里X
是专栏向量n
变量X(:)
,,,,和一个
是大小的矩阵m
-by-n
。
例如,考虑以下不平等:
X1+2X2≤10
3X1+4X2≤20
5X1+6X2≤30。
Specify the inequalities by entering the following constraints.
a = [1,2; 3,4; 5,6];b = [10; 20; 30];
Example:to specify that the x components sum to 1 or less, usea =一个(1,n)
和b=1
。
数据类型:double
AEQ
-线性平等约束
真正的矩阵
线性平等约束,,,,specified as a real matrix.AEQ
一世s anme
-by-n
matrix, whereme
一世s the number of equalities, andn
一世s the number of variables (length ofF
)。对于大问题,通过AEQ
作为稀疏矩阵。
AEQ
encodes theme
linear equalities
aeq*x = beq
,,,,
在哪里X
是专栏向量n
变量X(:)
,,,,和beq
是一个与me
元素。
例如,考虑这些平等:
X1+2X2+3X3=10
2X1+4X2+X3= 20。
Specify the equalities by entering the following constraints.
AEQ = [1,2,3; 2,4,1];beq = [10; 20];
Example:要指定X组件总和为1AEQ=ones(1,N)
和BEQ = 1
。
数据类型:double
beq
-线性平等约束
real vector
线性平等约束,指定为真实向量。beq
一世s anme
- 元素向量与AEQ
矩阵。如果您通过beq
作为行矢量,求解器内部转换beq
to the column vectorbeq(:)
。对于大问题,通过beq
as a sparse vector.
beq
encodes theme
linear equalities
aeq*x = beq
,,,,
在哪里X
是专栏向量n
变量X(:)
,,,,和AEQ
是大小的矩阵me
-by-n
。
例如,考虑这些平等:
X1+2X2+3X3=10
2X1+4X2+X3= 20。
Specify the equalities by entering the following constraints.
AEQ = [1,2,3; 2,4,1];beq = [10; 20];
Example:要指定X组件总和为1,请使用AEQ=ones(1,N)
和BEQ = 1
。
数据类型:double
lb
-Lower bounds
real vector|真正的数组
下限,指定为真实向量或实际数组。如果长度F
一世s equal to the length oflb
, 然后lb
指定
X((一世)>= lb(i)
对所有人一世
。
Ifnumel(lb)
lb
指定
X((一世)>= lb(i)
为了1<= i <= numel(lb)
。
在这种情况下,求解器发出警告。
Example:要指定所有X组件都是正面的,请使用lb =零(size(f))
。
数据类型:double
UB
-上限
real vector|真正的数组
上限,指定为真实向量或真实数组。如果长度F
一世s equal to the length ofUB
, 然后UB
指定
x(i)<= ub(i)
对所有人一世
。
Ifnumel(ub)
UB
指定
x(i)<= ub(i)
为了1<= i <= numel(ub)
。
在这种情况下,求解器发出警告。
Example:to specify that all x-components are less than1
, 利用ub =一个(size(f))
。
数据类型:double
options
-优化选项
output of最佳选择
优化选项,,,,specified as the output of最佳选择
。
选项 | Description |
---|---|
约束 |
约束的可行性公差,标量 |
|
Level of display (seeIterative Display):
|
线性色素 |
用于解决迭代一步的算法: If
For a sparse example, see比较Coneprog算法的速度。 |
|
允许的最大迭代次数,一个正整数。默认值为 看tolerances and Stopping Criteria和Iterations and Function Counts。 |
maxTime |
算法运行的秒内最大时间,正数或 |
|
双重可行性的终止耐受性,一个正标量。默认值为 |
Example:Optimoptions('Coneprog',“ Display”,“ Iter”,“ Maxiterations”,100)
problem
-Problem structure
结构体
问题结构,指定为具有以下字段的结构。
场地name | 入口 |
---|---|
|
Linear objective function vectorF |
|
二阶锥体约束的结构阵列 |
|
线性不等式约束的矩阵 |
|
Vector of linear inequality constraints |
|
线性平等约束的矩阵 |
|
Vector of linear equality constraints |
lb |
较低的向量 |
UB |
上限向量 |
|
'coneprog' |
|
选项s created with最佳选择 |
数据类型:struct
输出参数
FVAL
-Objective function value at the solution
实数
解决方案的目标函数值,返回为实数。一般来说,FVAL
=f'*x
。这FVAL
output is empty when the出口
value is –2
,,,,–3
, 或者–10
。
出口
- 原因coneprog
停了下来
一世nteger
Reasonconeprog
停了下来,,,,returned as an integer.
Value | Description |
---|---|
|
函数收敛到解决方案 |
|
这number of iterations exceeded |
|
no feasible point was found. |
|
这problem is unbounded. |
|
搜索方向变得太小了。没有进一步的进展。 |
|
这个问题在数值上是不稳定的。 |
小费
如果您得到出口标志0
,,,,-7
, 或者-10
,尝试使用不同的值线性色素
option.
output
- 有关优化过程的信息
结构体
Information about the optimization process, returned as a structure with these fields.
场地 | Description |
---|---|
algorithm |
使用的优化算法 |
双重可行性 |
双重约束的最大违规行为 |
DualityGap |
双重性差距 |
迭代 |
迭代次数 |
信息 |
Exit message |
原始性 |
最大约束违规行为 |
linearsolver |
内部步骤求解器算法使用 |
这output
字段双重可行性
,,,,DualityGap
,,,,和原始性
当出口
value is –2, –3, or –10.
兰姆达
- 解决方案的双变量
结构体
更多关于
Second-Order Cone Constraint
为什么约束
called a second-order cone constraint? Consider a cone in 3-D space with elliptical cross-sections in theX-y平面,直径与zcoordinate. Theycoordinate has scale ½, and theXcoordinate has scale 1. The inequality defining the inside of this cone with its point at [0,0,0] is
In theconeprog
语法,该锥有以下论点。
a = diag([1 1/2 0]);b = [0; 0; 0];d = [0; 0; 1];伽马= 0;
Plot the boundary of the cone.
[x,y] = meshgrid(-2:0.1:2);z = sqrt(x.^2 + y.^2/4);冲浪(X,Y,Z)视图(8,2)Xlabel'x'ylabel'y'zlabel'z'
这b
和伽玛
争论移动锥。这一个
和d
争论旋转锥体并改变其形状。
一个lgorithms
该算法使用内点方法。有关详细信息,请参阅Second-Order Cone Programming Algorithm。
一个lternative Functionality
应用程序
这优化Live Editor task provides a visual interface forconeprog
。
版本历史记录
Introduced in R2020bR2021A:两个coneprog
兰姆达
Structures Renamed
Behavior changed in R2021a
这coneprog
兰姆达
输出参数字段lambda.eq
和兰姆达。一世neq
已重命名为lambda.eqlin
和兰姆达。一世neqlin
,,,,respectively. This change causes theconeprog
兰姆达
结构体字段to have the same names as the corresponding fields in other solvers.
MATLABCommand
您单击了与此MATLAB命令相对应的链接:
通过在MATLAB命令窗口中输入该命令。Web浏览器不支持MATLAB命令。万博1manbetx
You can also select a web site from the following list:
如何获得最佳网站性能
选择中国网站(中文或英语)以获得最佳场地性能。其他Mathworks乡村网站未针对您所在的访问进行优化。
一个mericas
- 一个mérica Latina(Español)
- Canada((英语)
- United States((英语)