设置 MultiStart 的起点
设置起点的四种方法
有四种方法可以告诉 MultiStart
局部求解器使用哪个起点:
传递一个正整数
k
。MultiStart
生成k - 1
个起点,就像使用RandomStartPointSet
对象和problem
结构体一样。MultiStart
还使用x0
结构体中的problem
个起点,总共k
个起点。传递一个
RandomStartPointSet
对象。传递一个
CustomStartPointSet
对象。传递
RandomStartPointSet
和CustomStartPointSet
对象的元胞数组。如果您有一些想要运行的特定点,但还希望MultiStart
使用其他随机起点,请传递一个元胞数组。
注意
您可以控制 MultiStart
是否使用所有起点,或者仅使用满足边界或其他不等式约束的点。有关详细信息,请参阅过滤起点(可选)。
正整数作为起点
运行 MultiStart
作为 k
起点的语法是
[xmin,fmin,flag,outpt,allmins] = run(ms,problem,k);
正整数 k
指定 MultiStart
使用的起点数量。MultiStart
使用问题的维度和来自 problem
结构体的边界生成随机起点。MultiStart
生成 k - 1
随机起点,并使用来自 x0
结构体的 problem
起点。
起点的 RandomStartPointSet 对象
创建一个 RandomStartPointSet
对象如下:
stpoints = RandomStartPointSet;
从 RandomStartPointSet
开始运行 MultiStart
,如下所示:
[xmin,fmin,flag,outpt,allmins] = run(ms,problem,stpoints);
默认情况下,RandomStartPointSet
对象会生成 10 个起点。使用 NumStartPoints
属性控制起点的数量。例如,要生成 40 个起点:
stpoints = RandomStartPointSet('NumStartPoints',40);
您可以将 ArtificialBound
设置为 RandomStartPointSet
。这个 ArtificialBound
与问题结构体的边界一起工作:
如果分量没有边界,则
RandomStartPointSet
使用-ArtificialBound
的下界和ArtificialBound
的上界。如果某个分量有下界
lb
但没有上界,则RandomStartPointSet
使用上界lb + 2*ArtificialBound
。类似地,如果一个分量有上界
ub
但没有下界,则RandomStartPointSet
使用下界ub - 2*ArtificialBound
。
例如,要生成 100
起点和 ArtificialBound
的 50
:
stpoints = RandomStartPointSet('NumStartPoints',100, ... 'ArtificialBound',50);
RandomStartPointSet
对象生成与问题结构体中的 x0
点具有相同维度的起点;请参阅 list
。
起点的 CustomStartPointSet 对象
要使用一组特定的起点,请将这些点放入 CustomStartPointSet
中,如下所示:
将起点放在矩阵中。矩阵的每一行代表一个起点。
MultiStart
运行矩阵的所有行,并根据StartPointsToRun
属性进行过滤。有关详细信息,请参阅MultiStart 算法。从矩阵创建一个
CustomStartPointSet
对象:tpoints = CustomStartPointSet(ptmatrix);
例如,创建一组 40 个五维点,每个点的分量等于 10 加上平均值为 25 的指数分布变量:
pts = -25*log(rand(40,5)) + 10; tpoints = CustomStartPointSet(pts);
从 CustomStartPointSet
开始运行 MultiStart
,如下所示:
[xmin,fmin,flag,outpt,allmins] = run(ms,problem,tpoints);
要从 CustomStartPointSet
对象获取原始点矩阵,请使用 list
:
pts = list(tpoints); % Assumes tpoints is a CustomStartPointSet
CustomStartPointSet
有两个属性:StartPointsDimension
和 NumStartPoints
。您可以使用这些属性来查询 CustomStartPointSet
对象。例如示例中的 tpoints
对象具有以下属性:
tpoints.StartPointsDimension
ans = 5
tpoints.NumStartPoints
ans = 40
起点对象的单元格数组
要使用一组特定的起点以及一些随机生成的点,请传递 RandomStartPointSet
或 CustomStartPointSet
对象的元胞数组。
例如,要使用 起点的 CustomStartPointSet 对象 的 40 个特定五维点和 RandomStartPointSet
的 40 个额外五维点:
pts = -25*log(rand(40,5)) + 10;
tpoints = CustomStartPointSet(pts);
rpts = RandomStartPointSet('NumStartPoints',40);
allpts = {tpoints,rpts};
从 allpts
元胞数组开始运行 MultiStart
:
% Assume ms and problem exist
[xmin,fmin,flag,outpt,allmins] = run(ms,problem,allpts);