matlab遗传算法学习和全局化算法_第1页
matlab遗传算法学习和全局化算法_第2页
matlab遗传算法学习和全局化算法_第3页
matlab遗传算法学习和全局化算法_第4页
matlab遗传算法学习和全局化算法_第5页
已阅读5页,还剩26页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、1 遗传算法步骤1 根据具体问题选择编码方式,随机产生初始种群,个体数目一定,每个个体表现为染色体的基因编码2 选择合适的适应度函数,计算并评价群体中各个体的适应。3 选择(selection)。根据各个个体的适应度,按照一定的规则或方法,从当前群体中选择出一些优良的个体遗传到下一代群体4 交叉(crossover)。将选择过后的群体内的各个个体随机搭配成对,对每一对个体,以一定概率(交叉概率)交换它们中的部分基因。5 变异(mutation)。对交叉过后的群体中的每一个个体,以某个概率(称为变异概率)改n 变某一个或某一些基因位上的基因值为其他的等位基因6 终止条件判断。若满足终止条件,则以

2、进化过程中得到的具有最大适应度的个体作为最优解输出,终止运算。否则,迭代执行Step2 至Step5。适应度是评价群体中染色体个体好坏的标准,是算法进化的驱动力,是自然选择的唯一依据,改变种群结构的操作皆通过适应度函数来控制。在遗传算法中,以个体适应度的大小来确定该个体被遗传到下一代群体中的概率。个体的适应度越大,被遗传到下一代的概率就越大,相反,被遗传到下一代的概率就越小。1 a,b,c=gaopt(bound,fun)其中,bound=xm,xM为求解区间上届和下届构成的矩阵。Fun为用户编写的函数。a为搜索的结果向量,由搜索的出的最优x向量与目标函数构成,b为最终搜索种群,c为中间搜索过

3、程变参数,其第一列为代数,后边列分别为该代最好的的个体与目标函数的值,可以认为寻优的中间结果。2 ga函数。X,F, FLAG,OUTPUT = GA(fun, n,opts).n为自变量个数,opts为遗传算法控制选项,用gaoptimset()函数设置各种选项,InitialPopulation可以设置初始种群,用PopulationSize可以设置种群规模,SelectionFcn可以定义选择函数,3 gatool 函数用于打开,GATOOL is now included in OPTIMTOOL。2.2 通过GUI 使用遗传算法在Matlab 工作窗口键入下列命令gatool, 或通

4、过Start 打开其下子菜单Genetic Algorithm Tool,如图1。只要在相应的窗格选择相应的选项便可进行遗传算法的计算。其中fitnessfun 窗格为适应度函数, 填写形式为fitnessfun,Number of variable 窗格为变量个数。其它窗格参数根据情况填入。填好各窗格内容,单击Start 按钮,便可运行遗传算法例子1 应用实例已知某一生物的总量y(单位:万个)与时间t(月)之间的关系为y=k0(1-exp(-k1*t),统计十个月得到数据见表1,试求关系式中的k0,k1。先编写目标函数,并以文件名myfung.m 存盘。function y=myfung(x

5、)TOT=2.0567 3.6904 4.9881 6.0189 6.8371 7.4881 8.0047 8.4151 8.7411 9.0000;t=1:10;r,s=size(TOT);y=0;for i=1:sy=y+(TOT(i)-x(:,1)*(1-exp(-x(:,2)*t(i)2 %最小估计原则end打开遗传算法的GUI,在Fitness function 窗格中输入myfung,在Number of variables 窗格中输入数字2,在Stopping criteria 选项中设置generations 为300,fitness limit 为0.001,stall ge

6、nerations 为100,其它参数为缺省值,然后单击Start 运行遗传算法得到k0=9.99559,k1=0.23018,即例子2 2 matlab 7 GA工具箱_木子一车(转载)例子1求的最大值;也就是求负函数的最小值最大值为-38.8503,在点 xmin=11.6255 5.7250;clearf=(x1,x2)(-(21.5+x1.*sin(4*pi*x1)+x2.*sin(20*pi*x2)t1=-3:0.1:12.1; t2=4:1.8/(length(t1)-1):5.8;x,y=meshgrid(t1,t2);mesh(x,y,f(x,y)方法1 遗传算法f=(x)-(

7、21.5+x(1)*sin(4*pi*x(1)+x(2)*sin(20*pi*x(2);opt1 = gaoptimset;opt1.PopInitRange = -3.0 4.1;12.1 5.8;opt1.PopulationSize = 1000;opt1.MutationFcn=mutationuniform;x, fval = ga(f,2,opt1)x,fval = ga(f,2, -3.0;4.1,12.1;5.8);方法2 gatool 的用法在matlab7命令行输入 gatool,见附图。在 PopulationSize=10000; 请注意Mutation函数的选择。f(

8、x1*,x2*)=-my_func1(x1*,x2*)=38.84741978236206,where x1*=11.62378; x2*=5.72501方法3 全局优化算法gs = GlobalSearch(Display,iter);f=(x)-(21.5+x(1)*sin(4*pi*x(1)+x(2)*sin(20*pi*x(2);opts = optimset(Algorithm,interior-point);problem = createOptimProblem(fmincon,objective,f,x0,1/2 1/3,lb,-3 4.1,ub,12.1 5.8,option

9、s,opts);xming,fming,flagg,outptg,manyminsg = run(gs,problem)方法4 multistart 方法ms =MultiStart(TolFun,1e-10,TolX,1e-10);opts=optimset(Algorithm, interior-point);f=(x)-(21.5+x(1)*sin(4*pi*x(1)+x(2)*sin(20*pi*x(2);problem=createOptimProblem(fmincon,x0,0,0,objective,f,lb,-3,4.1,ub,12.1,5.8,options,opts);x

10、minm,fminm,flagm,outptm,someminsm=run(ms,problem,300);%stpoints=RandomStartPointSet;%默认产生10个起始点此方法得不到最优解;查看局部解的分布范围 enter hist(someminsm.Fval).方法4.1 对上个方法的改进;首先根据上个方法搜索的最佳点,取现在的方法的搜索范围为上个最优解的周围区域,缩小搜索范围clearms=MultiStart;opts=optimset(Algorithm,interior-point);f=(x)(-(21.5+x(1).*sin(4*pi*x(1)+x(2).*

11、sin(20*pi*x(2);problem=createOptimProblem(fmincon,x0,12,5,objective,f,lb,10,4,ub,12.1,5.8,options,opts);xminm,fminm,flagm,outptm,manyminsm=run(ms,problem,200)xminm = 11.6255 5.7250fminm = -38.8503flagm = 1outptm = funcCount: 8660 localSolverTotal: 200 localSolverSuccess: 200 localSolverIncomplete: 0

12、 localSolverNoSolution: 0 message: 1x129 charmanyminsm = 1x78 GlobalOptimSolution Properties: X Fval Exitflag OutputX0方法4.2 pts = -4*rand(200,2) + 13*rand(200,2);tpoints = CustomStartPointSet(pts);rpts = RandomStartPointSet(NumStartPoints,200);allpts = tpoints,rpts;ms=MultiStart;opts=optimset(Algori

13、thm, interior-point,LargeScale,off);f=(x)(-(21.5+x(1).*sin(4*pi*x(1)+x(2).*sin(20*pi*x(2);problem=createOptimProblem(fmincon,x0,12.1,5.6,objective,f,lb,9,4,ub,12.1,5.8,options,opts);xmin,fmin,flag,outpt,allmins = run(ms,problem,allpts)3 【问题】求f(x)=x+10*sin(5x)+7*cos(4x)的最大值,其中0=x Export to Workspace

14、and select Export problem and options to a MATLAB structure named例子5 多起始点优化(MultiStart Global Optimization)gs = GlobalSearch;ms = MultiStart;xstart = randn(3,1);options = optimset(Algorithm,interior-point);假设你想解决一个问题并假设局部解相邻0.01之内,并且函数值在函数精度之内;求解时间少于2000s;gs = GlobalSearch(TolX,0.01,MaxTime,2000);gs

15、 = GlobalSearch;ms = MultiStart; xmin,fmin,flag,outpt,allmins = run(ms,problem,k);%k为要使用的起点数目,k可以由RandomStartPointSet函数产生;5.1 RandomStartPointSet Object for Start Pointsstpoints = RandomStartPointSet;%默认产生10个起始点,如果想产生stpoints = RandomStartPointSet(NumStartPoints,40);Running a solver is nearly identi

16、cal for GlobalSearch and MultiStart. The only difference in syntax is MultiStart takes an additional input describing the start points.startpts = RandomStartPointSet(ArtificialBound,100,NumStartPoints,50);x fval eflag output manymins = run(ms,problem,startpts)5.2 CustomStartPointSet Object for Start

17、 PointsTo use a specific set of starting points, package them in a HYPERLINK jar:file:/D:/Program%20Files/MATLAB/R2010a/help/toolbox/gads/help.jar%21/customstartpointsetclass.html CustomStartPointSet as follows:Place the starting points in a matrix. Each row of the matrix represents one starting poi

18、nt. MultiStart runs all the rows of the matrix, subject to filtering with the StartPointsToRun property. For more information, see HYPERLINK jar:file:/D:/Program%20Files/MATLAB/R2010a/help/toolbox/gads/help.jar%21/bsc59ag-2.html l bsc9eez MultiStart Algorithm.Create a CustomStartPointSet object from

19、 the matrix:tpoints = CustomStartPointSet(ptmatrix);For example, create a set of 40 five-dimensional points, with each component of a point equal to 10 plus an exponentially distributed variable with mean 25:pts = -25*log(rand(40,5) + 10;tpoints = CustomStartPointSet(pts);To get the original matrix

20、of points from a CustomStartPointSet object, use the HYPERLINK jar:file:/D:/Program%20Files/MATLAB/R2010a/help/toolbox/gads/help.jar%21/customstartpointset.list.html list method:pts = list(tpoints); % Assumes tpoints is a CustomStartPointSetA CustomStartPointSet has two properties: DimStartPoints an

21、d NumStartPoints. You can use these properties to query a CustomStartPointSet object. For example, the tpoints object in the example has the following properties:tpoints.DimStartPointsans =5tpoints.NumStartPointsans =405.3 Cell Array of Objects for Start PointsTo use a specific set of starting point

22、s along with some randomly generated points, pass a cell array of RandomStartPointSet or CustomStartPointSet objects.For example, to use both the 40 specific five-dimensional points of HYPERLINK jar:file:/D:/Program%20Files/MATLAB/R2010a/help/toolbox/gads/help.jar%21/bsc595w.html l bsc881a-3 CustomS

23、tartPointSet Object for Start Points and 40 additional five-dimensional points from RandomStartPointSet:pts = -25*log(rand(40,5) + 10;tpoints = CustomStartPointSet(pts);rpts = RandomStartPointSet(NumStartPoints,40);allpts = tpoints,rpts;Run MultiStart with the allpts cell array:% Assume ms and probl

24、em existxmin,fmin,flag,outpt,allmins = run(ms,problem,allpts);例子6 小值优化(基于全局算法和多起点算法的比较)sixmin = 4x2 2.1x4 + x6/3 + xy 4y2 + 4y4.X Y = meshgrid(-2:.1:2,-1:.05:1);Z = 4*X.2 - 2.1*X.4 + X.6./3 + X.*Y - 4*Y.2 + 4*Y.4;surf(X,Y,Z);view(-44,14)xlabel(x);ylabel(y)title(sixmin(x,y) X Y = meshgrid(-2:.1:2,-1:

25、.05:1);Z = 4*X.2 - 2.1*X.4 + X.6./3 + X.*Y - 4*Y.2 + 4*Y.4;surf(X,Y,Z);view(-44,14)xlabel(x);ylabel(y)title(sixmin(x,y)This function is also called the six-hump camel back function HYPERLINK jar:file:/D:/Program%20Files/MATLAB/R2010a/help/toolbox/gads/help.jar%21/bsc59ag-2.html l bsgwdzo 3. All the

26、local minima lie in the region 3x,y3.6.1 gobalSearchgs = GlobalSearch(Display,iter);opts = optimset(Algorithm,interior-point);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);problem=createOptimProblem(fmincon,x0,-1,2,objective,sixmin,lb,-3,-3,ub,3,3,options,opts);xming,

27、fming,flagg,outptg,manyminsg = run(gs,problem);xming,fming,flagg,outptg,manyminsgxming = -0.0898 0.7127fming =-1.0316flagg = 1outptg = funcCount: 2245 localSolverTotal: 8 localSolverSuccess: 8 localSolverIncomplete: 0 localSolverNoSolution: 0 message: 1x137 charmanyminsg = 1x4 GlobalOptimSolution Pr

28、operties: X Fval Exitflag Output X06.2 Run with MultiStartTo find several local minima of the problem described in HYPERLINK jar:file:/D:/Program%20Files/MATLAB/R2010a/help/toolbox/gads/help.jar%21/bsc595w.html l bsc599n Run the Solver using 50 runs of fmincon with MultiStart, enter:ms=MultiStart;op

29、ts=optimset(Algorithm,interior-point);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);problem=createOptimProblem(fmincon,x0,-1,2,objective,sixmin,lb,-3,-3,ub,3,3,options,opts);xminm,fminm,flagm,outptm,manyminsm=run(ms,problem,50);The output of the run (which varies based on the rando

30、m seed):xminm,fminm,flagm,outptm,manyminsmxminm =-0.0898 0.7127fminm = -1.0316flagm = 1outptm = funcCount: 2035 localSolverTotal: 50 localSolverSuccess: 50 localSolverIncomplete: 0 localSolverNoSolution: 0 message: 1x128 charmanyminsm = 1x6 GlobalOptimSolution Properties: X Fval Exitflag Output X0在这

31、个例子中multistart方法找个6个局部最优解,而globalsearch方法找到4个 HYPERLINK jar:file:/D:/Program%20Files/MATLAB/R2010a/help/toolbox/gads/help.jar%21/bsc59_4.html l bsc89tq Example: Visualizing the Basins of Attraction.ms = MultiStart(TolFun,0.01,TolX,0.01);opts = optimset(Algorithm,active-set);sixmin = (x)(4*x(1)2 - 2.

32、1*x(1)4 + x(1)6/3 . + x(1)*x(2) - 4*x(2)2 + 4*x(2)4);problem = createOptimProblem(fmincon,x0,-1,2,. objective,sixmin,lb,-3,-3,ub,3,3,. options,opts);xminm,fminm,flagm,outptm,someminsm = run(ms,problem,50);7 优化结果的改进7.1 要判断一个解是否为全局解,首先确定是否为局部解,使用pattern search函数x = patternsearch(fun,x0,A,b,Aeq,beq,LB,

33、UB,nonlcon,options)x = patternsearch(problem)%求函数的最小值;problem.solver = patternsearch;其次把刚才求得的解设置为初始点problem.x0 = x;例子1 ffun = (x)(x(1)-(x(1)-x(2)2)options = optimset(Algorithm,active-set);% active-set,trust-region-reflective, interior-point,levenberg-marquardt, trust-region-dogleg,lm-line-search, or

34、 sqp.ffun = (x)(x(1)-(x(1)-x(2)2);problem = createOptimProblem(fmincon,objective,ffun,x0,1/2 1/3,lb,0 -1,ub,1 1,options,options);x fval exitflag = fmincon(problem)x = 0;1.6143e-008fval =-2.6059e-016exitflag = 1% 把求解值设为pattersearch起始值搜索到一个更小的值-3problem.x0 = x;problem.solver = patternsearch;xp fvalp e

35、xitflagp = patternsearch(problem)xp =1.0000 -1.0000fvalp =-3.0000exitflagp =17.2 对于用globalsearch方法到multistart方法的一些改变 1 Change the solver field to fminunc: problem.solver = fminunc; To avoid a warning if your objective function does not compute a gradient, change the local options structure to have L

36、argeScale set to off: problem.options.LargeScale = off; 2 Add an artificial constraint, retaining fmincon as the local solver: problem.lb = -Inf;7.3 如果你能确定最优值的取值范围的情况下,缩小搜索范围f=(x,y)x6+y6+sin(x+y)*(x2+y2)-cos(x2/(1+y2)*(2+x4+x2y2+y4);10 x,y10, 因为106 远大于104,所以如果把搜索范围改在最佳值所在的范围-2,2将会取得较好的结果f=(x)x(1)6+x

37、(2)6+sin(x(1)+x(2)*(x(1)2+x(2)2)-cos(x(1)2/(1+x(2)2)*(2+x(1)4+x(1)2x(2)2+x(2)4);startpts = RandomStartPointSet(ArtificialBound,100,NumStartPoints,50);x fval eflag output manymins = run(ms,problem,startpts)7.4 改进搜索起始值(使得起始值更散开一些);或者增加起始点数目(multistart)Uniform Grid. To generate a uniform grid of start

38、points:1 Generate multidimensional arrays with ndgrid. Give the lower bound, spacing, and upper bound for each component. For example, to generate a set of three-dimensional arrays with1 First component from 2 through 0, spacing 0.52 Second component from 0 through 2, spacing 0.253 Third component f

39、rom 10 through 5, spacing 1X,Y,Z = ndgrid(-2:.5:0,0:.25:2,-10:5); 2 Place the arrays into a single matrix, with each row representing one start point. For example: W = X(:),Y(:),Z(:); In this example, W is a 720-by-3 matrix.3. Put the matrix into a CustomStartPointSet object. For example: custpts =

40、CustomStartPointSet(W);8 GlobalSearch and MultiStart Examplesf(r,t) = g(r)h(t),g(r)=(sin(r)-sin(2*r)/2+sin(3*r)/3-sin(4*r)/4+4)*r2/(r+1);h(t)=2+cos(t)+cos(2*t-1)/2;f=(r,t)(sin(r)-sin(2*r)/2+sin(3*r)/3-sin(4*r)/4+4)*r2/(r+1)*(2+cos(t)+cos(2*t-1)/2)全局最优解在r=0;函数g近似和r成直线振荡关系,函数h有两个局部解,其中一个为全局最佳解;functio

41、nf=sawtoothxy(x,y)t r=cart2pol(x,y); % change to polar coordinatesh =cos(2*t-1/2)/2+cos(t)+2;g=(sin(r)-sin(2*r)/2+sin(3*r)/3-sin(4*r)/4+4).*r.2./(r+1);f=g.*h;endsubplot(1,2,1);ezplot(r)(sin(r) - sin(2*r)/2 + sin(3*r)/3 - sin(4*r)/4 + 4) .* r.2./(r+1),0,20)title(); ylabel(g)subplot(1,2,2);ezplot(t)2

42、+ cos(t) + cos(2*t-1/2)/2,0,2*pi)title(); ylabel(h)figureezsurf(x,y)sawtoothxy(x,y),-20,20)% sawtoothxy is defined in the first step belowview(-18,52)1 使用globalsearch方法problem=createOptimProblem(fmincon,objective,(x)sawtoothxy(x(1),x(2),x0,100,-50,options,optimset(Algorithm,sqp);problem.lb = -Inf;x

43、fval = fmincon(problem)gs = GlobalSearch(Display,iter);x fval = run(gs,problem)2 使用multistart方法problem=createOptimProblem(fminunc,objective,(x)sawtoothxy(x(1),x(2)x0,100,-50,options,optimset(LargeScale,off);x fval = fminunc(problem);ms = MultiStart;x fval eflag output manymins = run(ms,problem,50);%

44、求解器没有找到全局解,找到16个局部解。hist(manymins.Fval);bestf = manymins.Fval;% Plot the function values at the three best pointshist(bestf(1:3)9 Example: Isolated Global MinimumThe function sech(x) is nearly 0 for all |x|5, and sech(0)=1. The example is a two-dimensional version of the sech function, with one mini

45、mum at 1,1, the other at 1e5,-1e5:f(x,y) = 10sech(|x (1,1)|) 20sech(.0003(|x (1e5,1e5)|) 1.f has a global minimum of 21 at (1e5,1e5), and a local minimum of 11 at (1,1).% f is a vectorized version of the objective function% Each row of an input matrix x is one point to evaluatef = (x)-10*sech(sqrt(x

46、(:,1)-x1(1).2+(x(:,2)-x1(2).2) . -20*sech(3e-4*sqrt(x(:,1)-x2(1).2+(x(:,2)-x2(2).2)-1;hndl = ezsurf(x,y)f(x,y),-1e6 1e6,1000);set(hndl,LineStyle,none)view(-45,10)hold onannotation(textarrow,. 0.71 0.56,0.48 0.21,TextEdgeColor,none,. String,Global Minimum);hold off9.1 Default Settings Cannot Find the

47、 Global Minimum Add BoundsGlobalSearch and MultiStart cannot find the global minimum using default global options, since the default start point components are in the range (9999,10001) for GlobalSearch and (1000,1000) for MultiStart.With additional bounds of 1e6 and 1e6 in problem, GlobalSearch usu

48、ally does not find the global minimum:x1 = 1;1;x2 = 1e5;-1e5;f = (x)-10*sech(norm(x(:)-x1) -20*sech(norm(x(:)-x2)*3e-4) -1;problem = createOptimProblem(fmincon,x0,0,0,objective,f,. lb,-1e6;-1e6,ub,1e6;1e6);gs = GlobalSearch;xfinal fval = run(gs,problem)GlobalSearch stopped because it analyzed all th

49、e trial points.All 57 local solver runs converged with a positive local solver exit flag.xfinal = 1.0000 1.0000fval = -11.00009.2 GlobalSearch with Bounds and More Start PointsTo find the global minimum, you can search more points. This example uses 1e5 start points, and a MaxTime of 300 s:gs.NumTri

50、alPoints = 1e5;gs.MaxTime = 300;xg fvalg = run(gs,problem)MultiStart Without Bounds, Widely Dispersed Start PointsYou can also use MultiStart to search an unbounded region to find the global minimum. Again, you need many start points to have a good chance of finding the global minimum.The first five

51、 lines of code generate 10,000 widely dispersed random start points using the method described in HYPERLINK jar:file:/D:/Program%20Files/MATLAB/R2010a/help/toolbox/gads/help.jar%21/bsc5_cj.html l bsfjxwr Widely Dispersed Points for Unconstrained Components. newprob is a problem structure using the f

52、minunc local solver and no bounds:u = rand(1e4,1);u = 1./u;u = exp(u) - exp(1);s = rand(1e4,1)*2*pi;stpts = u.*cos(s),u.*sin(s);startpts = CustomStartPointSet(stpts);newprob = createOptimProblem(fminunc,x0,0;0,objective,f);xcust fcust = run(ms,newprob,startpts)MultiStart with a Regular Grid of Start

53、 PointsYou can also use a grid of start points instead of random start points. To learn how to construct a regular grid for more dimensions, or one that has small perturbations, see HYPERLINK jar:file:/D:/Program%20Files/MATLAB/R2010a/help/toolbox/gads/help.jar%21/bsc5_cj.html l bsfjxvg Uniform Grid

54、 or HYPERLINK jar:file:/D:/Program%20Files/MATLAB/R2010a/help/toolbox/gads/help.jar%21/bsc5_cj.html l bsfjxv3 Perturbed Grid.xx = -1e6:1e4:1e6;xxx yyy = meshgrid(xx,xx);z = xxx(:),yyy(:);bigstart = CustomStartPointSet(z);xgrid fgrid = run(ms,newprob,bigstart)MultiStart completed the runs from all st

55、art points.All 10000 local solver runs converged with a positive local solver exit flag.xcust = 1.0e+004 * 10.0000 -10.0000fcust = -21.0000In this case, MultiStart found the global minimum.MultiStart with Regular Grid and Promising Start PointsMaking a regular grid of start points, especially in hig

56、h dimensions, can use an inordinate amount of memory or time. You can filter the start points to run only those with small objective function value.To perform this filtering most efficiently, write your objective function in a vectorized fashion. For information, see HYPERLINK jar:file:/D:/Program%2

57、0Files/MATLAB/R2010a/help/toolbox/gads/help.jar%21/brdvu8r.html l bsab0cb Example: Writing a Vectorized Function or HYPERLINK jar:file:/D:/Program%20Files/MATLAB/R2010a/help/toolbox/gads/help.jar%21/f8355.html l brkj8lv-1 Vectorizing the Objective and Constraint Functions. The following function han

58、dle computes a vector of objectives based on an input matrix whose rows represent start points:x1 = 1;1;x2 = 1e5;-1e5;g = (x) -10*sech(sqrt(x(:,1)-x1(1).2 + (x(:,2)-x1(2).2) . -20*sech(sqrt(x(:,1)-x2(1).2 + (x(:,2)-x2(2).2)-1;Suppose you want to run the local solver only for points where the value i

59、s less than 2. Start with a denser grid than in HYPERLINK jar:file:/D:/Program%20Files/MATLAB/R2010a/help/toolbox/gads/help.jar%21/bsc9noc.html l bseyhh5 MultiStart with a Regular Grid of Start Points, then filter out all the points with high function value:xx = -1e6:1e3:1e6;xxx yyy = meshgrid(xx,xx

60、);z = xxx(:),yyy(:);idx = g(z) Approximated derivatives Evaluate in parallel.matlabpool closeGlobalSearchGlobalSearch does not distribute a problem and start points to multiple processes or processors. However, when GlobalSearch runs the fmincon local solver, fmincon can estimate gradients by parall

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论