fgoalattain
求解涉及多目标的目标达到问题
语法
说明
fgoalattain 求解目标达到问题,这是多目标优化问题最小化的一种表示。
fgoalattain 求以下问题的最小值:
weight、goal、b 和 beq 是向量,A 和 Aeq 是矩阵,F(x)、c(x) 和 ceq(x) 是返回向量的函数。F(x)、c(x) 和 ceq(x) 可以是非线性函数。
x、lb 和 ub 可以作为向量或矩阵传递;请参阅矩阵参量。
[ 还返回在解 x,fval,attainfactor,exitflag,output] = fgoalattain(___)x 处的达到因子、描述 fgoalattain 退出条件的值 exitflag,以及包含优化过程信息的结构体 output。
示例
假设有以下双目标函数
显然,在此函数中,当 时, 最小,达到 2;当 时, 最小,达到 5。
设置目标 [3,6] 和权重 [1,1],并从 x0 = 1 开始求解目标达到问题。
fun = @(x)[2+(x-3)^2;5+x^2/4]; goal = [3,6]; weight = [1,1]; x0 = 1; x = fgoalattain(fun,x0,goal,weight)
Local minimum possible. Constraints satisfied. fgoalattain stopped because the size of the current search direction is less than twice the value of the step size tolerance and constraints are satisfied to within the value of the constraint tolerance. <stopping criteria details>
x = 2.0000
计算 在解处的值。
fun(x)
ans = 2×1
3.0000
6.0000
fgoalattain 完全达到了目标。
目标函数是
此处,p_1 = [2,3] 且 p_2 = [4,1]。目标是 [3,6],权重是 [1,1],线性约束是 。
创建目标函数、目标和权重。
p_1 = [2,3]; p_2 = [4,1]; fun = @(x)[2 + norm(x-p_1)^2;5 + norm(x-p_2)^2/4]; goal = [3,6]; weight = [1,1];
创建表示 A*x <= b 的线性约束矩阵 A 和 b。
A = [1,1]; b = 4;
设置初始点 [1,1] 并求解目标达到问题。
x0 = [1,1]; x = fgoalattain(fun,x0,goal,weight,A,b)
Local minimum possible. Constraints satisfied. fgoalattain stopped because the size of the current search direction is less than twice the value of the step size tolerance and constraints are satisfied to within the value of the constraint tolerance. <stopping criteria details>
x = 1×2
2.0694 1.9306
计算 在解处的值。
fun(x)
ans = 2×1
3.1484
6.1484
fgoalattain 没有满足目标。由于权重相等,求解器溢出每个目标的量是相同的。
目标函数是
此处,p_1 = [2,3] 且 p_2 = [4,1]。目标是 [3,6],权重是 [1,1],边界是 、。
创建目标函数、目标和权重。
p_1 = [2,3]; p_2 = [4,1]; fun = @(x)[2 + norm(x-p_1)^2;5 + norm(x-p_2)^2/4]; goal = [3,6]; weight = [1,1];
创建边界。
lb = [0,2]; ub = [3,5];
将初始点设置为 [1,4],并求解目标达到问题。
x0 = [1,4];
A = []; % no linear constraints
b = [];
Aeq = [];
beq = [];
x = fgoalattain(fun,x0,goal,weight,A,b,Aeq,beq,lb,ub)Local minimum possible. Constraints satisfied. fgoalattain stopped because the size of the current search direction is less than twice the value of the step size tolerance and constraints are satisfied to within the value of the constraint tolerance. <stopping criteria details>
x = 1×2
2.6667 2.3333
计算 在解处的值。
fun(x)
ans = 2×1
2.8889
5.8889
fgoalattain 超出满足目标。由于权重相等,求解器结果溢出每个目标的量是相同的。
目标函数是
此处,p_1 = [2,3] 且 p_2 = [4,1]。目标是 [3,6],权重是 [1,1],非线性约束是 。
创建目标函数、目标和权重。
p_1 = [2,3]; p_2 = [4,1]; fun = @(x)[2 + norm(x-p_1)^2;5 + norm(x-p_2)^2/4]; goal = [3,6]; weight = [1,1];
非线性约束函数在 norm4.m 文件中。
type norm4function [c,ceq] = norm4(x) ceq = []; c = norm(x)^2 - 4;
为线性约束和边界创建空输入参量。
A = []; Aeq = []; b = []; beq = []; lb = []; ub = [];
将初始点设置为 [1,1],并求解目标达到问题。
x0 = [1,1]; x = fgoalattain(fun,x0,goal,weight,A,b,Aeq,beq,lb,ub,@norm4)
Local minimum possible. Constraints satisfied. fgoalattain stopped because the size of the current search direction is less than twice the value of the step size tolerance and constraints are satisfied to within the value of the constraint tolerance. <stopping criteria details>
x = 1×2
1.1094 1.6641
计算 在解处的值。
fun(x)
ans = 2×1
4.5778
7.1991
fgoalattain 没有满足目标。尽管权重相等,但 与其目标 3 相差约 1.58, 与其目标 6 相差约 1.2。非线性约束会防止解 x 同等地达到各目标。
通过将选项设置为返回迭代输出来监控目标达到求解过程。
options = optimoptions('fgoalattain','Display','iter');
目标函数是
此处,p_1 = [2,3] 且 p_2 = [4,1]。目标是 [3,6],权重是 [1,1],线性约束是 。
创建目标函数、目标和权重。
p_1 = [2,3]; p_2 = [4,1]; fun = @(x)[2 + norm(x-p_1)^2;5 + norm(x-p_2)^2/4]; goal = [3,6]; weight = [1,1];
创建表示 A*x <= b 的线性约束矩阵 A 和 b。
A = [1,1]; b = 4;
为线性等式约束、边界和非线性约束创建空输入参量。
Aeq = []; beq = []; lb = []; ub = []; nonlcon = [];
设置初始点 [1,1] 并求解目标达到问题。
x0 = [1,1]; x = fgoalattain(fun,x0,goal,weight,A,b,Aeq,beq,lb,ub,nonlcon,options)
Attainment Max Line search Directional
Iter F-count factor constraint steplength derivative Procedure
0 4 0 4
1 9 -1 2.5 1 -0.535
2 14 -1.235e-08 0.2813 1 0.883
3 19 0.1452 0.005926 1 0.883
4 24 0.1484 2.868e-06 1 0.883
5 29 0.1484 6.757e-13 1 0.883 Hessian modified
Local minimum possible. Constraints satisfied.
fgoalattain stopped because the size of the current search direction is less than
twice the value of the step size tolerance and constraints are
satisfied to within the value of the constraint tolerance.
<stopping criteria details>
x = 1×2
2.0694 1.9306
报告的达到因子为正值表示 fgoalattain 找不到满足目标的解。
目标函数是
此处,p_1 = [2,3] 且 p_2 = [4,1]。目标是 [3,6],权重是 [1,1],线性约束是 。
创建目标函数、目标和权重。
p_1 = [2,3]; p_2 = [4,1]; fun = @(x)[2 + norm(x-p_1)^2;5 + norm(x-p_2)^2/4]; goal = [3,6]; weight = [1,1];
创建表示 A*x <= b 的线性约束矩阵 A 和 b。
A = [1,1]; b = 4;
设置初始点 [1,1] 并求解目标达到问题。请求返回目标函数的值。
x0 = [1,1]; [x,fval] = fgoalattain(fun,x0,goal,weight,A,b)
Local minimum possible. Constraints satisfied. fgoalattain stopped because the size of the current search direction is less than twice the value of the step size tolerance and constraints are satisfied to within the value of the constraint tolerance. <stopping criteria details>
x = 1×2
2.0694 1.9306
fval = 2×1
3.1484
6.1484
目标函数值高于目标,这意味着 fgoalattain 不满足目标。
目标函数是
此处,p_1 = [2,3] 且 p_2 = [4,1]。目标是 [3,6],权重是 [1,1],线性约束是 。
创建目标函数、目标和权重。
p_1 = [2,3]; p_2 = [4,1]; fun = @(x)[2 + norm(x-p_1)^2;5 + norm(x-p_2)^2/4]; goal = [3,6]; weight = [1,1];
创建表示 A*x <= b 的线性约束矩阵 A 和 b。
A = [1,1]; b = 4;
设置初始点 [1,1] 并求解目标达到问题。请求返回目标函数的值、实现因子、退出标志、输出结构体和拉格朗日乘数。
x0 = [1,1]; [x,fval,attainfactor,exitflag,output,lambda] = fgoalattain(fun,x0,goal,weight,A,b)
Local minimum possible. Constraints satisfied. fgoalattain stopped because the size of the current search direction is less than twice the value of the step size tolerance and constraints are satisfied to within the value of the constraint tolerance. <stopping criteria details>
x = 1×2
2.0694 1.9306
fval = 2×1
3.1484
6.1484
attainfactor = 0.1484
exitflag = 4
output = struct with fields:
iterations: 6
funcCount: 29
lssteplength: 1
stepsize: 4.1890e-13
algorithm: 'active-set'
firstorderopt: []
constrviolation: 6.8343e-13
message: 'Local minimum possible. Constraints satisfied.↵↵fgoalattain stopped because the size of the current search direction is less than↵twice the value of the step size tolerance and constraints are ↵satisfied to within the value of the constraint tolerance.↵↵<stopping criteria details>↵↵Optimization stopped because the norm of the current search direction, 3.713953e-13,↵is less than 2*options.StepTolerance = 1.000000e-06, and the maximum constraint ↵violation, 6.834255e-13, is less than options.ConstraintTolerance = 1.000000e-06.'
lambda = struct with fields:
lower: [2×1 double]
upper: [2×1 double]
eqlin: [0×1 double]
eqnonlin: [0×1 double]
ineqlin: 0.5394
ineqnonlin: [0×1 double]
attainfactor 为正值表明目标没有达到;您也可以通过比较 fval 和 goal 来确定这一点。
lambda.ineqlin 值非零,表明线性不等式对解进行了约束。
目标函数是
此处,p_1 = [2,3] 且 p_2 = [4,1]。目标是 [3,6],初始权重是 [1,1]。
创建目标函数、目标和初始权重。
p_1 = [2,3]; p_2 = [4,1]; fun = @(x)[2 + norm(x-p_1)^2;5 + norm(x-p_2)^2/4]; goal = [3,6]; weight = [1,1];
设置线性约束 。
A = [1 1]; b = 4;
从点 x0 = [1 1] 开始求解目标达到问题。
x0 = [1 1]; [x,fval] = fgoalattain(fun,x0,goal,weight,A,b)
Local minimum possible. Constraints satisfied. fgoalattain stopped because the size of the current search direction is less than twice the value of the step size tolerance and constraints are satisfied to within the value of the constraint tolerance. <stopping criteria details>
x = 1×2
2.0694 1.9306
fval = 2×1
3.1484
6.1484
fval 的每个分量都高于 goal 的对应分量,表明目标未达到。
通过将 weight(1) 设置为较小的值,提高满足第一个目标的重要性。
weight(1) = 1/10; [x,fval] = fgoalattain(fun,x0,goal,weight,A,b)
Local minimum possible. Constraints satisfied. fgoalattain stopped because the size of the current search direction is less than twice the value of the step size tolerance and constraints are satisfied to within the value of the constraint tolerance. <stopping criteria details>
x = 1×2
2.0115 1.9885
fval = 2×1
3.0233
6.2328
现在,fval(1) 的值更接近 goal(1),而 fval(2) 更远离 goal(2)。
将 goal(2) 更改为 7,该值高于当前解。解发生变化。
goal(2) = 7; [x,fval] = fgoalattain(fun,x0,goal,weight,A,b)
Local minimum possible. Constraints satisfied. fgoalattain stopped because the size of the current search direction is less than twice the value of the step size tolerance and constraints are satisfied to within the value of the constraint tolerance. <stopping criteria details>
x = 1×2
1.9639 2.0361
fval = 2×1
2.9305
6.3047
fval 的两个分量都小于 goal 的对应分量。但是,与 fval(2) 和 goal(2) 的接近程度相比,fval(1) 更接近 goal(1)。在目标无法达到时,权重越小,会使对应分量更可能接近达到,但在目标能够达到时,则会使溢出目标的量更小。
将权重更改为相等。各个 fval 结果与其对应目标的距离相等。
weight(2) = 1/10; [x,fval] = fgoalattain(fun,x0,goal,weight,A,b)
Local minimum possible. Constraints satisfied. fgoalattain stopped because the size of the current search direction is less than twice the value of the step size tolerance and constraints are satisfied to within the value of the constraint tolerance. <stopping criteria details>
x = 1×2
1.7613 2.2387
fval = 2×1
2.6365
6.6365
约束可防止各个 fval 结果与对应目标等距。例如,对 x(2) 设置上界 2。
ub = [Inf,2]; lb = []; Aeq = []; beq = []; [x,fval] = fgoalattain(fun,x0,goal,weight,A,b,Aeq,beq,lb,ub)
Local minimum possible. Constraints satisfied. fgoalattain stopped because the size of the current search direction is less than twice the value of the step size tolerance and constraints are satisfied to within the value of the constraint tolerance. <stopping criteria details>
x = 1×2
2.0000 2.0000
fval = 2×1
3.0000
6.2500
在这种情况下,fval(1) 正好达到其目标,但 fval(2) 低于其目标。
输入参数
目标函数,指定为函数句柄或函数名称。fun 函数接受向量 x,并返回向量 F,即在 x 处计算的目标函数值。对于函数文件,您可以将函数 fun 指定为函数句柄:
x = fgoalattain(@myfun,x0,goal,weight)
其中 myfun 是一个 MATLAB® 函数,例如
function F = myfun(x) F = ... % Compute function values at x.
fun 也可以是匿名函数的函数句柄:
x = fgoalattain(@(x)sin(x.*x),x0,goal,weight);
fgoalattain 以 x0 参量的形状将 x 传递给目标函数和任何非线性约束函数。例如,如果 x0 是 5×3 数组,则 fgoalattain 将 x 以 5×3 数组的形式传递给 fun。但是,在将 x 转换为列向量 x(:) 后,fgoalattain 会将线性约束矩阵 A 或 Aeq 乘以 x。
要使目标函数尽可能接近目标值(即不大于也不小于),请使用 optimoptions 将 EqualityGoalCount 选项设置为值应处在目标值邻域中的目标的数目。这些目标必须划分为 fun 返回的向量 F 的前几个元素。
假设目标函数的梯度也可以计算并且 SpecifyObjectiveGradient 选项是 true,设置如下:
options = optimoptions('fgoalattain','SpecifyObjectiveGradient',true)
在这种情况下,函数 fun 必须在第二个输出参量中返回在 x 处的梯度值 G(矩阵)。梯度由每个 F 在 x 点处的偏导数 dF/dx 组成。如果 F 是长度为 m 的向量,且 x 的长度为 n,其中 n 是 x0 的长度,则 F(x) 的梯度 G 是 n×m 矩阵,其中 G(i,j) 是 F(j) 关于 x(i) 的偏导数(即,G 的第 j 列是第 j 个目标函数 F(j) 的梯度)。
注意
仅当问题没有非线性约束,或问题有非线性约束且 SpecifyConstraintGradient 设置为 true 时,将 SpecifyObjectiveGradient 设置为 true 才会高效。在算法内部,目标被折叠到约束中,因此要为求解器提供两种梯度(目标和约束),以避免估计梯度。
数据类型: char | string | function_handle
初始点,指定为实数向量或实数数组。求解器使用 x0 中的元素数量和 x0 的大小来确定 fun 接受的变量数量和大小。
示例: x0 = [1,2,3,4]
数据类型: double
要达到的目标,指定为实数向量。fgoalattain 尝试找到最小乘数 γ,使以下不等式对于解 x 处的所有 i 值都成立:
假设 weight 是正向量:
如果求解器找到同时达到所有目标的点
x,则达到因子 γ 为负,目标过达到。如果求解器找不到同时达到所有目标的点
x,则达到因子 γ 为正,目标欠达到。
示例: [1 3 6]
数据类型: double
相对达到因子,指定为实数向量。fgoalattain 尝试找到最小乘数 γ,使以下不等式对于解 x 处的所有 i 值都成立:
当 goal 的值全部非零时,为确保溢出或低于活动目标的百分比相同,请将 weight 设置为 abs(goal)。(活动目标是一组目标,它们阻碍解处的目标进一步改进。)
注意
将 weight 向量的某一分量设置为零会导致对应的目标约束被视为硬约束,而不是目标约束。设置硬约束的另一种方法是使用输入参量 nonlcon。
当 weight 为正时,fgoalattain 尝试使目标函数小于目标值。要使目标函数大于目标值,请将 weight 设置为负值而不是正值。要了解权重对解的一部分影响,请参阅权重、目标和约束对目标达到的影响。
要使目标函数尽可能接近目标值,请使用 EqualityGoalCount 选项,并将目标指定为 fun 返回的向量的第一个元素(请参阅 fun 和 options)。有关示例,请参阅多目标达成优化。
示例: abs(goal)
数据类型: double
线性不等式约束,指定为实矩阵。A 是 M×N 矩阵,其中 M 是不等式的数目,而 N 是变量的数目(x0 中的元素数)。对于大型问题,如果使用支持稀疏数据的算法,则可将 A 作为稀疏矩阵传递。请参阅稀疏性在优化算法中的应用。
A 以如下形式编写 M 个线性不等式
A*x <= b,
其中,x 是由 N 个变量组成的列向量 x(:),b 是具有 M 个元素的列向量。
例如,假设有以下不等式:
x1 +2x2 ≤10
3x1 +4x2 ≤20
5x1 +6x2 ≤30,
通过输入以下约束来指定不等式。
A = [1,2;3,4;5,6]; b = [10;20;30];
示例: 要指定 x 分量总和等于或小于 1,请使用 A = ones(1,N) 和 b = 1。
数据类型: single | double
线性不等式约束,指定为实数向量。b 是与 A 矩阵相关的包含 M 个元素的向量。如果将 b 作为行向量传递,求解器会在内部将 b 转换为列向量 b(:)。
b 以如下形式编写 M 个线性不等式
A*x <= b,
其中,x 是由 N 个变量组成的列向量 x(:),A 是大小为 M×N 的矩阵。
例如,假设有以下不等式:
x1 + 2x2 ≤ 10
3x1 + 4x2 ≤ 20
5x1 + 6x2 ≤ 30。
通过输入以下约束来指定不等式。
A = [1,2;3,4;5,6]; b = [10;20;30];
示例: 要指定 x 分量总和等于或小于 1,请使用 A = ones(1,N) 和 b = 1。
数据类型: single | double
线性等式约束,指定为实矩阵。Aeq 是 Me×N 矩阵,其中 Me 是等式的数目,而 N 是变量的数目(x0 中的元素数)。对于大型问题,如果使用支持稀疏数据的算法,则可将 A 作为稀疏矩阵传递。请参阅稀疏性在优化算法中的应用。
Aeq 以如下形式编写 Me 个线性等式
Aeq*x = beq,
其中,x 是由 N 个变量组成的列向量 x(:),beq 是具有 Me 个元素的列向量。
例如,假设有以下不等式:
x1 +2x2 +3x3 =10
2x1 +4x2 + x3 =20,
通过输入以下约束来指定不等式。
Aeq = [1,2,3;2,4,1]; beq = [10;20];
示例: 要指定 x 分量总和为 1,请使用 Aeq = ones(1,N) 和 beq = 1。
数据类型: single | double
线性等式约束,指定为实数向量。beq 是与 Aeq 矩阵相关的包含 Me 个元素的向量。如果将 beq 作为行向量传递,求解器会在内部将 beq 转换为列向量 beq(:)。
beq 以如下形式编写 Me 个线性等式
Aeq*x = beq,
其中,x 是由 N 个变量组成的列向量 x(:),Aeq 是大小为 Me×N 的矩阵。
例如,请参考以下等式:
x1 + 2x2 + 3x3 = 10
2x1 + 4x2 + x3 = 20。
通过输入以下约束来指定等式。
Aeq = [1,2,3;2,4,1]; beq = [10;20];
示例: 要指定 x 分量总和为 1,请使用 Aeq = ones(1,N) 和 beq = 1。
数据类型: single | double
下界,指定为实数向量或实数数组。如果 x0 中的元素数等于 lb 中的元素数,则 lb 指定
x(i) >= lb(i)(对于全部 i)。
如果 numel(lb) < numel(x0),则 lb 指定
x(i) >= lb(i) (1 <= i <= numel(lb))。
如果 lb 的元素数少于 x0,求解器将发出警告。
示例: 要指定所有 x 分量为正,请使用 lb = zeros(size(x0))。
数据类型: single | double
上界,指定为实数向量或实数数组。如果 x0 中的元素数等于 ub 中的元素数,则 ub 指定
x(i) <= ub(i)(对于全部 i)。
如果 numel(ub) < numel(x0),则 ub 指定
x(i) <= ub(i) (1 <= i <= numel(ub))。
如果 ub 的元素数少于 x0,求解器将发出警告。
示例: 要指定 x 的所有分量小于 1,请使用 ub = ones(size(x0))。
数据类型: single | double
非线性约束,指定为函数句柄或函数名称。nonlcon 函数接受向量或数组 x,并返回两个数组 c(x) 和 ceq(x)。
c(x)是由x处的非线性不等式约束组成的数组。fgoalattain尝试满足c(x) <= 0for all entries ofc.ceq(x)是由x处的非线性等式约束组成的数组。fgoalattain尝试满足ceq(x) = 0for all entries ofceq.
例如,
x = fgoalattain(@myfun,x0,...,@mycon)
其中 mycon 是一个 MATLAB 函数,例如:
function [c,ceq] = mycon(x) c = ... % Compute nonlinear inequalities at x. ceq = ... % Compute nonlinear equalities at x.
假设约束的梯度也可以计算且 SpecifyConstraintGradient 选项是 true,设置如下:
options = optimoptions('fgoalattain',SpecifyConstraintGradient=true)
在本例中,函数 nonlcon 还必须在第三个输出参量 GC 中返回 c(x) 的梯度,在第四个输出参量 GCeq 中返回 ceq(x) 的梯度。请参阅非线性约束,了解如何“条件化”处理梯度,以将其用于不接受原始梯度的求解器。
如果 nonlcon 返回由 m 个分量组成的向量 c,x 的长度为 n,其中 n 是 x0 的长度,则 c(x) 的梯度 GC 是 n×m 矩阵,其中 GC(i,j) 是 c(j) 关于 x(i) 的偏导数(即,GC 的第 j 列是第 j 个不等式约束 c(j) 的梯度)。同样,如果 ceq 有 p 个分量,ceq(x) 的梯度 GCeq 是 n×p 矩阵,其中 GCeq(i,j) 是 ceq(j) 关于 x(i) 的偏导数(即,GCeq 的第 j 列是第 j 个等式约束 ceq(j) 的梯度)。
注意
仅当 SpecifyObjectiveGradient 设置为 true 时,将 SpecifyConstraintGradient 设置为 true 才有效。在内部,目标折叠到约束中,因此求解器需要按顺序提供的两个梯度(目标和约束)以避免估计梯度。
注意
由于 Optimization Toolbox™ 函数只接受 double 类型的输入,用户提供的目标和非线性约束函数必须返回 double 类型的输出。
如有必要,请参阅传递额外参数以了解如何参数化非线性约束函数 nonlcon。
数据类型: char | function_handle | string
优化选项,指定为 optimoptions 的输出或 optimset 等返回的结构体。
optimoptions 显示中缺少某些选项。这些选项在下表中以斜体显示。有关详细信息,请参阅查看优化选项。
有关在 optimset 中具有不同名称的选项的详细信息,请参阅当前选项名称和旧选项名称。
| 选项 | 描述 |
|---|---|
ConstraintTolerance | 约束违反值的终止容差,非负标量。默认值为 对于 |
| Diagnostics | 显示关于要最小化或求解的函数的诊断信息。选项是 |
| DiffMaxChange | 有限差分梯度变量的最大变化(正标量)。默认值为 |
| DiffMinChange | 有限差分梯度变量的最小变化(正标量)。默认值为 |
| 显示级别(请参阅迭代输出):
|
EqualityGoalCount | 使目标函数 对于 |
FiniteDifferenceStepSize | 有限差分的标量或向量步长因子。当您将
sign′(x) = sign(x)(例外是 sign′(0) = 1)。中心有限差分是
FiniteDifferenceStepSize 扩展为向量。对于正向有限差分,默认值为 sqrt(eps);对于中心有限差分,默认值为 eps^(1/3)。 对于 |
FiniteDifferenceType | 用于估计梯度的有限差分的类型, 当同时估计这两种类型的有限差分时,该算法小心地遵守边界。例如,为了避免在边界之外的某个点进行计算,算法可能采取一个后向步而不是前向步。 对于 |
FunctionTolerance | 函数值的终止容差(非负标量)。默认值为 对于 |
| FunValCheck | 该检查表示目标函数和约束值是否有效。如果为 |
MaxFunctionEvaluations | 允许的最大函数计算次数(非负整数)。默认值为 对于 |
MaxIterations | 允许的最大迭代次数(非负整数)。默认值为 对于 |
| MaxSQPIter | 允许的 SQP 迭代最大次数(正整数)。默认值为 |
| MeritFunction | 如果此选项设置为 |
OptimalityTolerance | 一阶最优性的终止容差(非负标量)。默认值为 对于 |
OutputFcn | 优化函数在每次迭代中调用的一个或多个用户定义的函数。传递函数句柄或函数句柄的元胞数组。默认值是“无”( |
PlotFcn | 在算法执行过程中显示各种进度测量值的绘图。从预定义绘图中选择,或者自行编写。传递名称、函数句柄或由名称或函数句柄组成的元胞数组。对于自定义绘图函数,传递函数句柄。默认值是“无”(
自定义绘图函数使用与输出函数相同的语法。请参阅Optimization Toolbox 的输出函数和输出函数和绘图函数语法。 对于 |
| RelLineSrchBnd | 线搜索步长的相对边界(非负实数标量值),使得 |
| RelLineSrchBndDuration |
|
SpecifyConstraintGradient | 用户定义的非线性约束函数梯度。当此选项设置为 对于 |
SpecifyObjectiveGradient | 用户定义的目标函数梯度。请参考 对于 |
StepTolerance |
对于 |
| TolConSQP | 内部迭代 SQP 约束违反值的终止容差(正标量)。默认值为 |
TypicalX | 典型的 |
UseParallel | 并行计算的指示。此选项为 |
示例: optimoptions('fgoalattain','PlotFcn','optimplotfval')
问题结构体,指定为具有下表中字段的结构体。
| 字段名称 | 条目 |
|---|---|
| 目标函数 fun |
| x 的初始点 |
| 要达到的目标 |
| 目标的相对重要性因子 |
| 线性不等式约束的矩阵 |
| 线性不等式约束的向量 |
| 线性等式约束的矩阵 |
| 线性等式约束的向量 |
lb | 由下界组成的向量 |
ub | 由上界组成的向量 |
| 非线性约束函数 |
| 'fgoalattain' |
| 用 optimoptions 创建的选项 |
您必须在 problem 结构体中至少提供 objective、x0、goal、weight、solver 和 options 字段。
数据类型: struct
输出参量
解处的目标函数值,以实数数组形式返回。通常,fval = fun(x)。
达到因子,以实数形式返回。attainfactor 包含解处的 γ 值。如果 attainfactor 为负,则目标过达到;如果 attainfactor 为正,则目标欠达到。请参阅 goal。
fgoalattain 停止的原因,以整数形式返回。
| 函数收敛于解 |
| 搜索方向的模小于指定的容差,约束违反值小于 |
| 方向导数的模小于指定容差,约束违反值小于 |
| 迭代次数超过 |
| 由输出函数或绘图函数停止 |
| 找不到可行点。 |
有关优化过程的信息,以包含下表中字段的结构体形式返回。
iterations | 执行的迭代次数 |
funcCount | 函数计算次数 |
lssteplength | 搜索方向上线搜索步的大小 |
constrviolation | 约束函数的最大值 |
stepsize |
|
algorithm | 使用的优化算法 |
firstorderopt | 一阶最优性的测度 |
message | 退出消息 |
算法
有关 fgoalattain 算法的说明和目标达到概念的讨论,请参阅算法。
替代功能
App
优化实时编辑器任务为 fgoalattain 提供了一个可视化界面。
扩展功能
要并行运行,请将 'UseParallel' 选项设置为 true。
options = optimoptions('solvername','UseParallel',true)
有关详细信息,请参阅在 Optimization Toolbox 中使用并行计算。
版本历史记录
在 R2006a 之前推出
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)