main Content

coneprog

二级锥编程求解器

Description

coneprogFunction is a second-order cone programming solver that finds the minimum of a problem specified by

最小 X F t X

受约束的约束

一个 sc (( 一世 Å X - b sc (( 一世 d sc t (( 一世 Å X - γ (( 一世 一个 Å X b AEQ Å X = beq lb X UB

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

例子

X= coneprog(F,,,,社会solves the second-order cone programming problem with the constraints in社会编码为

  • 一个sc((一世)=社会((一世)。一个

  • bsc((一世)=社会((一世)。b

  • dsc((一世)=社会((一世)。d

  • γ((一世)=socconstraints(i).gamma

例子

X= coneprog(F,,,,社会,,,,一个,,,,b,,,,AEQ,,,,beq解决问题,受到不平等约束一个*xb和平等约束aeq*x = beq。Seta = []b = []如果不存在不平等。

例子

X= coneprog(F,,,,社会,,,,一个,,,,b,,,,AEQ,,,,beq,,,,lb,,,,UB在设计变量上定义了一组下限和上限,Xso that the solution is always in the rangelb ≤ x ≤ ub。SetAEQ = []beq=[[]如果不存在平等。

例子

X= coneprog(F,,,,社会,,,,一个,,,,b,,,,AEQ,,,,beq,,,,lb,,,,UB,,,,options最小化使用由优化选项指定的options。利用最佳选择to set these options.

例子

X= coneprog(problem找到最小problem,,,,a structure described inproblem

例子

[[X,,,,FVAL] = coneprog(___also returns the objective function value at the solutionFVAL=f'*x,,,,using any of the input argument combinations in previous syntaxes.

例子

[[X,,,,FVAL,,,,出口,,,,output] = coneprog(___additionally returns a value出口描述出口条件和结构outputthat contains information about the optimization process.

例子

[[X,,,,FVAL,,,,出口,,,,output,,,,兰姆达] = coneprog(___另外返回结构兰姆达其字段包含解决方案的双变量X

Examples

collapse all

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

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

创建二阶锥体编程问题的元素。为了节省时间和内存,请先创建最高的索引约束。

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

创建二阶锥体编程问题。为了节省时间和内存,请先创建最高的索引约束。

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 value1output.messagevalue'Optimal solution found.'表示解决方案是可靠的。

  • output结构表明,二元性差距也是通过溶液过程降低的。

  • You can reproduce theFVALoutput by multiplyingf'*x

f'*x
ANS = -13.0089

创建二阶锥体编程问题。为了节省时间和内存,请先创建最高的索引约束。

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

collapse all

Coefficient vector, specified as a real vector or real array. The coefficient vector represents the objective functionf'*x。符号假设F是列向量,但是您可以使用行矢量或数组。在内部coneprogconvertsFto the column vectorF((:)

Example:F=[[1,,,,3,,,,5,,,,-6]

数据类型:double

二阶锥体约束,指定为secondorderconectraint对象。使用secondordercone功能。

社会encodes the constraints

一个 sc (( 一世 Å X - b sc (( 一世 d sc t (( 一世 Å X - γ (( 一世

阵列和方程之间的映射如下:

  • 一个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, specified as a real matrix.一个一世s anm-by-nmatrix, 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一世s anm- 元素向量与一个矩阵。如果您通过b作为行矢量,求解器内部转换bto the column vectorb((:)。对于大问题,通过bas a sparse vector.

bencodes 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

线性平等约束,,,,specified as a real matrix.AEQ一世s anme-by-nmatrix, whereme一世s the number of equalities, andn一世s the number of variables (length ofF)。对于大问题,通过AEQ作为稀疏矩阵。

AEQencodes themelinear 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一世s anme- 元素向量与AEQ矩阵。如果您通过beq作为行矢量,求解器内部转换beqto the column vectorbeq(:)。对于大问题,通过beqas a sparse vector.

beqencodes themelinear 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

下限,指定为真实向量或实际数组。如果长度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

上限,指定为真实向量或真实数组。如果长度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

优化选项,,,,specified as the output of最佳选择

选项 Description
约束

约束的可行性公差,标量0通过1约束measures primal feasibility tolerance. The default is1E-6

展示

Level of display (seeIterative Display):

  • 'final'((default) displays only the final output.

  • 'iTer'在每次迭代处显示输出。

  • 'off'或者'没有任何'd一世splays no output.

线性色素

用于解决迭代一步的算法:

  • '汽车'(默认) -coneprog选择步进求解器。

    • 如果问题很少,则步进求解器是'prodchol'

    • 否则,步进求解器是“增强”

  • “增强”- 增强形式的步进求解器。看[[1]

  • '普通的'-n或者mal form step solver. See[[1]

  • 'prodchol'- 产品形式Cholesky Step求解器。看[4][5]

  • 'schur'- Schur补体方法步进求解器。看[2]

If'汽车'does not perform well, try these suggestions for线性色素

  • 如果问题很少,请尝试'普通的'

  • 如果问题稀疏,一些密集的柱或大锥,请尝试'prodchol'或者'schur'

  • If the problem is dense, use“增强”

For a sparse example, see比较Coneprog算法的速度

最大值

允许的最大迭代次数,一个正整数。默认值为200

tolerances and Stopping CriteriaIterations and Function Counts

maxTime

算法运行的秒内最大时间,正数或Inf。默认值为Inf,禁用此停止标准。

OptimalityTolerance

双重可行性的终止耐受性,一个正标量。默认值为1E-6

Example:Optimoptions('Coneprog',“ Display”,“ Iter”,“ Maxiterations”,100)

问题结构,指定为具有以下字段的结构。

场地name 入口

F

Linear objective function vectorF

社会

二阶锥体约束的结构阵列

一个一世neq

线性不等式约束的矩阵

Bineq

Vector of linear inequality constraints

AEQ

线性平等约束的矩阵

beq

Vector of linear equality constraints
lb 较低的向量
UB 上限向量

求解器

'coneprog'

options

选项s created with最佳选择

数据类型:struct

输出参数

collapse all

解决方案,作为真实向量或真实数组返回。的大小X与大小相同F。这Xoutput is empty when the出口value is –2,,,,–3, 或者–10

解决方案的目标函数值,返回为实数。一般来说,FVAL=f'*x。这FVALoutput is empty when the出口value is –2,,,,–3, 或者–10

Reasonconeprog停了下来,,,,returned as an integer.

Value Description

1

函数收敛到解决方案X

0

这number of iterations exceededoptions.maxiterations时间在se,或解决方案conds exceededoptions.MaxTime

-2

no feasible point was found.

-3

这problem is unbounded.

-7

搜索方向变得太小了。没有进一步的进展。

-10

这个问题在数值上是不稳定的。

小费

如果您得到出口标志0,,,,-7, 或者-10,尝试使用不同的值线性色素option.

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.

解决方案的双变量,作为这些字段的结构返回。

场地 Description
lower

Lower bounds corresponding tolb

上限对应于UB

一世neqlin

线性不等式对应于一个b

eqlin

Linear equalities corresponding toAEQbeq

soc Second-order cone constraints corresponding to社会

兰姆达一世s empty ([[])when the出口value is –2,,,,–3, 或者–10

Lagrange乘数(双变量)是以下拉格朗日的一部分,该拉格朗日在解决方案上是固定的(零梯度):

F t X + 一世 λ soc (( 一世 (( d soc t (( 一世 X - 伽玛 (( 一世 - 一个 soc (( 一世 X - b soc (( 一世 + λ 一世neqlin t (( b - 一个 X + λ eqlin t (( AEQ X - beq + λ t (( UB - X + λ lower t (( X - lb

不平等术语乘以兰姆达字段are nonnegative.

更多关于

collapse all

Second-Order Cone Constraint

为什么约束

一个 Å X - b d t Å X - γ

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

X 2 + y 2 4 z

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 R2020b

expand all

Behavior changed in R2021a