2 Optimization Problems

  • 回顾1
    • Randomised Algorithms
    • Evolutionary Algorithms
  • 2
    • Optimisation
    • Randomised Algorithms
    • Local Search
    • Stochastic Local Search Algorithms (Simulated Annealing)
    • TSP
  • 补充:各algorithm层级关系
    • EAs
    • randomised algorithms (特别是Stochastic Local Search algorithm)
    • Heuristic algorithms
    • search and enumeration algorithms

1 Traveling Salesman Problem (TSP)相关

1.1 什么是TSP

  • Given (1)城市列表 (2)各城市之间的距离
  • Sought 从选定城市出发,经过所有城市一次后,返回原出发城市的最短路径
  • 举个例子:如下图,假设“A为出发城市”,最短路径及长度是?
    在这里插入图片描述

1.2 Solving TSP

两个问题

  • 问题一:什么样的问题是TSP?

  • 问题二:用什么算法解决TSP?

如何选择合适的算法?
by对比complexity

  • Brute force algorithms: O(n!), the factorial of the number of cities
  • Improved brute force algorithms (比如branch and cut algorithms): O(1.999^n)

➡️ linear programming problem 是一个NP-hard problem. LP 不能解决large instances的NP-complete problems in polynomial time

  • randomized search algorithms: 不能解决TSP问题,为什么?
  • Heuristic algorithms

1.3 同类问题扩展

2 Optimisation

2.1 什么是Optimisation

  • Optimization - to find the best and optimal solution to a problem
  • for example
    • Traveling salesman problem
    • Portfolio optimisation: balance between potential return and finical risk
    • Engineering optimisation: design a product that need to maximise and minimise something
  • Definition
    • given a function f(x), map a set A to real numbers
    • sought: an element x* in A so that f(x*) is the maximum or minimum

2.2 optimisation相关常用语

  • f(x)
    • minimisation - objective function, cost function
    • maximization - fitness function
  • A: feasible set
  • the domain A of f(x): search space
  • x belong to A: candidate solutions, or feasible solutions
    在这里插入图片描述

2.3 Optimisation问题分类

  • 从objective function出发
    • linear
      • additivity - 俩加一起
      • homogeneity - 乘上一个系数
    • non-linear
      • convex
      • non-convex
    • multi-objectuve vs single objective
    • constrained vs non-constrained
  • 从solutions出发
    • continuous
    • discrete

3 常见的optimisation algorithms

  • Mathematical programming algorithms
    • linear programming
  • Search and enumeration algorithms
    • Brute force algorithms - 列出所有可能的解法,挑一个最好的
    • Improved brute force algorithms - 比如branch and bound algorithms
    • Heuristic algorithms
      • Randomized algorithms
      • Local search, Stochastic local search - 比如greedy search

3.1 Randomized algorithms

  • 两分类use random numbers to
    • to find a solution to a problem
    • to improve a solution to a problem
  • 针对分类一,两个代表的算法
    • Las Vegas algorithm - 找到最优为止
    • Monte Carlo algorithm - 存在终止flag,在范围内寻找最优
  • 为什么randomised algotirhms不适合解决TSP?

3.2 Local search algorithms

  • Local search是什么?a heuristic algorithm for solving hard optimization problems
  • 描述一下Local search。给一个initial guess,然后incrementally improve it until it obtain an optimal one. (iteratively moves to a neighbour solution)
  • 什么是Incremental improvement?就是从initial solution or current solution,去到一个neighbor solution
  • 什么是neighbor solution?取决于search space里边的neighborhood relation,大概从similarity measure (distance measure)去判断

一般local search algorithms的伪代码
1)初始化x0,设定结束标识terminationflag为false
2)while true 循环,判断条件是terminationflag
a. 判断f(v)<f(x),决定是否用neighbour solution v去更新current solution x
b. 判断termination criterion是否符合,决定是否修改terminationflag
3)输出x
在这里插入图片描述

【Note】termination criterion如何判断?(1)到达最大迭代次数(2)在有限迭代次数后,没有明显提升效果

hill climbing algorithm
最简单的local search algorithm,是迭代寻找immediate neighbour solutions的算法。

  • 分类一:simple hill climbing,只要better就更新
  • 分类二:steepest ascent/descent hill climbing,对比所有neighbor solutions然后选the best
    在这里插入图片描述

对于TSP问题,要怎么找到immediate neighbour solutions?

3.3 Stochastic Local Search Algorithms

3.3.1 2-Opt Algorithm

问题举例1
四城市的TSP问题,三种解法,区别是两条边的不同。由此引出一个问题,如何确定改变哪两条边?there we have 2-Opt algorithm。
解决:(1)remove两条边,得到两个部分。(2)reconnect两个部分,得到一个可行的新的解法(中间可能需要做reverse)。

问题举例2
六个城市的TSP问题。
解决:(1)去掉两条边,得到两个独立的部分。(2)连接两个部分,做reverse,得到a new solution

伪代码
初始化TSP solution
(1)选定需要交换的两个城市i和j(我们得到独立两部分)
(2)三步走:从出发城市开始到城市i,这部分的路径是route[1]到route[i-1],把它加入new route;从城市i到城市j,这部分的路径是route[I]到route[j],把它加入new route;从route[j+1]到最后到出发城市,把这部分的路径加入new route。
(3)输出new route
在这里插入图片描述

  • Trade off between explotation and exploration

3.3.2 Stochastic Local Search with random start

  • motivation
  • exploration and exploitation
  • pros and cons of randomised search & local search
    • randomized search is good at exploration, but not good at exploitation. and it’s bad for problems where good solutions are just a small portion of all possible solutions.
    • local search on the other hand, is good at exploitation, but bad at exploration.
  • 最好的办法就是两者结合!没错!又是结合!

问题:怎样找到这个balance?

  • 方法一:escape local optimum
    [random restart] restart local search,然后重新初始化一个solution,再去做local search。注意,该办法只适用于 local optimum的数量很少,且重新开始local search的代价是比较小的情况。
    [Perform random non-improving step] Simulated Annealing. 随机移动到一个less fit neighbor.

  • 方法二:avoid local optimum

    • Tabu search【扩展了一个paper】

3.3.3 Simulated Annealing

  • 起源:Kirkpatrick 在1983提出的一个解决optimisation problem的generic heuristic algorithm
  • 本质是一个stochastic local search
  • 伪代码
    • 初始化
      • k
      • randomly generate一个初始的solution x_0
      • 计算object function value f(x_0)
      • 模拟一个“温度参数”t_0
    • while循环 k<k_max
      • 计算温度temperature(t_0)
      • pick一个intermidiate neighbour solution x_new,用(比如)2-OPT
      • 计算新solution的objective function value f(x_new)
      • 计算一个概率P( f(x), f(x_new), T),对比这个概率和随机(0,1)的值,并决定是否更新solution x以及e = f(x)
      • 对比e_best跟e_new,如果x_new算出来的值更小,就更新
      • k++
    • 输出x_best
  • 注意
    • 概率函数P - 跟e_best对比,两种计算方式
    • temperature() - 一个decrease函数
  • Main Idea
    • 接受P = 1的better solution
    • 接受e<e_best的worse solution

3.5 用不同algorithm解决TSP

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值