Smart Algorithms - Local Neighborhood Search Algorithms

Get into the habit of writing together! This is the 5th day of my participation in the "Nuggets Daily New Plan · April Update Challenge", click to view the details of the event .

1. Neighborhood Overview

In function optimization problems in distance space, the usual neighborhood definition is a sphere (neighbors) centered at a point.

2. Local neighborhood search

It can be generally understood as: the purpose is to find the optimal solution to a problem. First find a feasible solution in the solution ( the initial solution , which may not be the optimal solution), then explore around the initial solution to find the optimal solution in the neighborhood of the initial solution that is better than the initial solution (set as solution A ). Then explore the vicinity of solution A, and then find the optimal solution in the neighborhood of solution A that is better than solution A ( set as solution B ), and continue to explore in this way until the end condition of the loop is reached, and the final solution is output.

3. Example explanation

3.1 Problem description

The local search algorithm is used to solve the symmetric traveling salesman path problem of five cities, that is, starting from point A, passing through all nodes, and finally returning to point A, and finding the path with the shortest distance. Among them, A, B, C, D, and E represent five cities respectively, and node A is the starting city.

distance weight matrix D D looks like this:

image.png

Schematic diagram of five city node paths:

image.png

3.2 Solving process

3.2.1 Step 1: Generate initial solution

Here, a random method is used to generate the initial solution (other methods can also be used to generate the initial solution),

The initial solution is x b e s t = ( A B C D E ) xbest = (ABCDE) , the current optimal (short) path length f ( x b e s t ) = 45 f(xbest)=45

定义邻域映射为对换两个城市位置的2-opt(两元素优化),选定A城市为起点。

3.2.2 步骤二:第一次搜索

此处使用全邻域搜索,即将当前解的邻居都找出来去比较大小。 第一次搜索找到的邻域集为:

N ( x b e s t ) N(xbest) = {(ABCDE),(ACBDE),(ADCBE),(AECDB),(ABDCE),(ABEDC),(ABCED)}

这些邻域都是由初始解以及初始解 ( A B C D E ) (ABCDE) 两两城市依次调换得到的解

注:A城市没有被调换是因为A是固定起点,不能换顺序

对应目标函数为 f ( x ) f(x) ={45, 43, 45, 60, 60, 59, 44}

更新最优解: x b e s t = x n The w = ( A C B D E ) xbest=xnow=(ACBDE)

3.2.3 步骤三:第二次搜索

第二次搜索找到的邻域集为:

N ( x b e s t ) N(xbest) ={(ACBDE),(ABCDE),(ADBCE),(AEBDC),(ACDBE),(ACEDB),(ACBED)},

对应目标函数为 f ( x ) f(x) ={43, 45, 44, 59, 59, 58, 43}

更新最优解 x b e s t = x n The w = ( A C B D E ) xbest=xnow=(ACBDE)

接下来,继续重复上述方式搜索,直到满足结束条件。

我们可以发现最优解又变成上一步最优解了,这也是局部搜索的局限性之一。

4. 局部搜索特点

  • 简单易行,但无法保证全局最优性(找到的可能是局部最优解,此算法不能跳出局部最优);
  • 局部搜索主要依赖起点的选取邻域的结构(起点选在局部最优附近,迭代几次找到的是局部最优解)
  • To get a good solution, different neighborhood structures and different initial points can be compared;
  • If there are enough choices of initial points , the global optimal solution can always be calculated (try more)

Guess you like

Origin juejin.im/post/7086105169397547015