CustomStartPointSet
自定义起点
说明
CustomStartPointSet 是一个矩阵的对象包装器,其行代表 MultiStart 的起点。
创建对象
描述
输入参量
起点,指定为矩阵。ptmatrix 的每一行代表一个起点。
示例: randn(40,3) 创建了 3 维的 40 个起点。
数据类型: double
属性
对象函数
list | 列出起点 |
示例
创建一个具有 64 个三维点的 CustomStartPointSet 对象。
[x,y,z] = meshgrid(1:4); ptmatrix = [x(:),y(:),z(:)] + [10,20,30]; tpoints = CustomStartPointSet(ptmatrix);
tpoints 是 ptmatrix 对象中包含的 CustomStartPointSet 矩阵。
使用 tpoints 从 list 对象中提取原始矩阵。
tpts = list(tpoints);
检查 tpts 输出是否与 ptmatrix 相同。
isequal(ptmatrix,tpts)
ans = logical
1
若要生成一组与问题边界范围不同的伪随机起始点,请显式地创建这些点。例如,考虑以下涉及二维点的问题:
sixmin = @(x)(4*x(1)^2 - 2.1*x(1)^4 + x(1)^6/3 ... + x(1)*x(2) - 4*x(2)^2 + 4*x(2)^4); lb = [-6,-12]; ub = [20,40]; x0 = [1,2]; problem = createOptimProblem("fmincon",... x0=x0,lb=lb,ub=ub,objective=sixmin);
假设您希望起始点位于区间
这比问题的边界要小得多。在此范围内生成 20 个点:
rng default % For reproducibility N = 20; % Number of points lbcustom = [-5,-4]; ubcustom = [5,4]; ptmatrix = lbcustom + rand(N,2).*repmat((ubcustom - lbcustom),N,1);
查看伪随机点的取值范围:
[minpt,maxpt] = bounds(ptmatrix)
minpt = 1×2
-4.0246 -3.7453
maxpt = 1×2
4.7059 3.6018
这些点几乎覆盖了整个范围。
将这些点放入一个 CustomStartPointSet 对象中。
tpoints = CustomStartPointSet(ptmatrix);
使用自定义起始点来解决该问题。
ms = MultiStart; [x,fval, exitflag,output] = run(ms,problem,tpoints)
MultiStart completed the runs from all start points. All 20 local solver runs converged with a positive local solver exitflag.
x = 1×2
-0.0898 0.7127
fval = -1.0316
exitflag = 1
output = struct with fields:
funcCount: 952
localSolverTotal: 20
localSolverSuccess: 20
localSolverIncomplete: 0
localSolverNoSolution: 0
message: 'MultiStart completed the runs from all start points. ↵↵All 20 local solver runs converged with a positive local solver exitflag.'
相比之下,如果使用来自边界范围内的 20 个伪随机点来求解该问题。
[x2,fval2,exitflag2,output2] = run(ms,problem,20)
MultiStart completed the runs from all start points. All 20 local solver runs converged with a positive local solver exitflag.
x2 = 1×2
0.0898 -0.7127
fval2 = -1.0316
exitflag2 = 1
output2 = struct with fields:
funcCount: 1558
localSolverTotal: 20
localSolverSuccess: 20
localSolverIncomplete: 0
localSolverNoSolution: 0
message: 'MultiStart completed the runs from all start points. ↵↵All 20 local solver runs converged with a positive local solver exitflag.'
在此示例中,虽然两个解的目标函数值相同(以体现精度),但使用自定义起始点集的解所进行的函数计算次数要少得多。
版本历史记录
在 R2010a 中推出
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)