Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
@ab3735
Latest commit 3d862b6 Feb 21, 2020 History
1 contributor

Users who have contributed to this file

{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"<h1><center>Guide Notebook for the 380CT Assignment on TSP</center></h1>"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"_Kamal Bentahar_\n",
"\n",
"[https://github.coventry.ac.uk/380CT-1920JANMAY/TSP-Guidance](https://github.coventry.ac.uk/380CT-1920JANMAY/TSP-Guidance)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Notation and definitions"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let $G$ be a complete weighted graph with $n$ vertices...\n",
"\n",
"- **Complete**: the graph is undirected, has no self-loops, and each node is connected to all the other vertices.\n",
"- **Weighted**: the edges have a weight (a positive integer).\n",
"- **Cycle**: a path that visits every vertex once, and goes back to the start point.\n",
"- **Total cost of the cycle**: sum of the edge weights of the cycle."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Definition of the problem"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Given $G$ as above, the versions of the TSP are defined as follows:\n",
"\n",
"* **Decisional TSP (D-TSP)**:\n",
"> Given a total cost $k$, decide if $G$ is has a cycle of length $\\leq k$.\n",
"\n",
" **NP-complete**, because D-TSP $\\in$ NP and D-TSP $\\leq_p$ HAMCYCLE.\n",
" \n",
" * D-TSP $\\in$ NP: once a cycle is given (a certificate) we can quickly evaluate the its cost in $O(n)$ time to verify it is equal to $k$.\n",
" * D-TSP $\\leq_p$ HAMCYCLE: Reduction from HAMCYCLE (Hoos and Stutzler, p.25).\n",
"\n",
"* **Search TSP**:\n",
"> Given a total cost $k$, search for a cycle of length $\\leq k$ in $G$.\n",
"> (If found then return it, otherwise say that there is no such cycle.)\n",
" \n",
"* **Optimization TSP**:\n",
"> Given $G$, find a cycle of minimal total cost.\n",
"\n",
" **NP-Hard**, because the optimization version of (decision) NP-complete problems are automatically NP-Hard. (using the same method sketched above for **Search TSP**)\n",
"\n",
"The facts about the complexity classes memberships can also be found in (Garey and Johnson, 1979) and (Hoos and Stutzler, 2005)."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Testing methodology"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* **Exact methods**:\n",
" Average time for instances with increasing $n$.\n",
"\n",
"* **Greedy and meta-heuristics**:\n",
" Average \"quality\" as $n$ increases.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Random instances sampling strategy"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"General TSP instances will be generated by creating symmetric adjacency matrices uniformly at random."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Code"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"First start by importing relevant libraries."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"from random import randint, choice\n",
"from pprint import pprint\n",
"from itertools import permutations\n",
"from math import inf as oo # Infinity (∞) is larger than any number\n",
"from math import sqrt\n",
"from time import time\n",
"import matplotlib.pyplot as plt\n",
"import copy"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Basics"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let the set of vertices be $\\{0, 1, 2,\\ldots, n-1\\}$.\n",
"\n",
"Without loss of generality, we can consider $0$ to be the start and end point of cycles."
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [],
"source": [
"MAX_DISTANCE = 100\n",
"\n",
"def random_symmetric_graph(n):\n",
" ''' Symmetric adjacency matrix of size nxn '''\n",
" dist_matrix = [[oo for _ in range(n)] for _ in range(n)]\n",
" for i in range(n):\n",
" for j in range(i+1,n):\n",
" v = randint(1,MAX_DISTANCE)\n",
" dist_matrix[i][j] = v\n",
" dist_matrix[j][i] = v\n",
" return dist_matrix\n",
"\n",
"def random_euclidean_graph(n):\n",
" ''' Symmetric adjacency matrix of a Euclidean graph of size nxn '''\n",
" dist_matrix = [[oo for _ in range(n)] for _ in range(n)]\n",
" points = []\n",
" for p in range(n):\n",
" x,y = randint(0,MAX_DISTANCE), randint(0,MAX_DISTANCE)\n",
" points.append((x,y))\n",
" for i in range(n):\n",
" p1 = points[i]\n",
" for j in range(i+1,n):\n",
" p2 = points[j]\n",
" distance = sqrt((p1[0]-p2[0])**2+(p1[1]-p2[1])**2)\n",
" dist_matrix[i][j] = distance\n",
" dist_matrix[j][i] = distance\n",
" return dist_matrix\n",
"\n",
"def show(G):\n",
" ''' Show adjacency matrix. Useful for debugging. '''\n",
" n = len(G)\n",
" r = \" \"\n",
" for i in range(n):\n",
" r += f'{i:4}'\n",
" r += '\\n -'+'-'*(4*n)+'\\n'\n",
" for i in range(n):\n",
" r += f'{i:2} | '\n",
" for j in range(n):\n",
" r += f'{G[i][j]:4}'\n",
" r += '\\n'\n",
" r = r.replace('inf', ' ∞')\n",
" print(r)\n",
"\n",
"def cost(G, cycle):\n",
" ''' Calculate the cost of the given cycle '''\n",
" c = 0\n",
" n = len(G)\n",
" for i in range(n):\n",
" a = cycle[i]\n",
" b = cycle[(i+1)%n]\n",
" c += G[a][b]\n",
" return c"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" 0 1 2 3 4\n",
" ---------------------\n",
" 0 | ∞63.19810123729984524.04163056034261545.011109739707630.0\n",
" 1 | 63.198101237299845 ∞50.9901951359278518.97366596101027653.53503525729669\n",
" 2 | 24.04163056034261550.99019513592785 ∞32.24903099319427.0710678118654755\n",
" 3 | 45.011109739707618.97366596101027632.2490309931942 ∞35.4682957019364\n",
" 4 | 30.053.535035257296697.071067811865475535.4682957019364 ∞\n",
"\n"
]
}
],
"source": [
"G=random_euclidean_graph(5)\n",
"show(G)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Example"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" 0 1 2 3 4\n",
" ---------------------\n",
" 0 | ∞ 12 19 68 74\n",
" 1 | 12 ∞ 91 29 6\n",
" 2 | 19 91 ∞ 50 55\n",
" 3 | 68 29 50 ∞ 88\n",
" 4 | 74 6 55 88 ∞\n",
"\n"
]
}
],
"source": [
"G=random_symmetric_graph(5)\n",
"show(G)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Solution methods"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Exact methods - Exhaustive search"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The idea is to:\n",
"- Consider vertex $0$ as the start and end point.\n",
"- Iterate over all permutations of the vertices $\\{1,2,\\ldots, n-1\\}$.\n",
" - Calculate cost of each permutation and keep track of minimum cost permutation.\n",
"- Return the cycle with minimum cost.\n",
"\n",
"More formally, the pseudo-code is as follows:\n",
"\n",
"**Input**: $G$.\n",
"\n",
"**Output**: a cycle in $G$ of shortest cost."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"1. $bestcycle\\gets \\emptyset$\n",
"2. $bestcost\\gets \\infty$\n",
"3. **for all** possible cycles $p$ in $G$ (starting and ending at $0$) **do**\n",
"4. $\\quad$ $c\\gets$ cost of $p$\n",
"2. $\\quad$ **if** $c<bestcost$ **then**\n",
"3. $\\qquad$ $bestcycle\\gets p$\n",
"3. $\\qquad$ $bestcost\\gets c$\n",
"4. $\\quad$ **end if**\n",
"5. **end for**\n",
"6. **return** $bestcycle, bestcost$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"There are $(n-1)!$ possible cycles, and each computation of a cycle's cost costs $O(n)$. So this algorithm costs $$O((n-1)!\\cdot n)=O(n!).$$"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def exhaustive_search(G):\n",
" n = len(G) \n",
" best_cost = oo # infinity\n",
" best_cycle = []\n",
" for cycle in permutations(range(1,n)): # permutations of [1,2,...,n-1]\n",
" cycle=[0]+list(cycle) # add the starting city: 0\n",
" c = cost(G, cycle)\n",
" if c < best_cost:\n",
" best_cost = c\n",
" best_cycle = cycle\n",
" return (best_cycle, best_cost)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Testing exhaustive search time cost"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Test completely random graphs:"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"8\t0.02001166343688965\n",
"9\t0.12252664566040039\n",
"10\t1.4062316417694092\n"
]
}
],
"source": [
"pnts_n = []\n",
"pnts_t = []\n",
"\n",
"n = 8\n",
"t0 = t1 = 0\n",
"\n",
"while t1-t0<1: # in seconds; if it takes too long then stop testing\n",
" G = random_symmetric_graph(n)\n",
" t0 = time()\n",
" exhaustive_search(G)\n",
" t1 = time()\n",
" # record time\n",
" print( f\"{n}\\t{t1-t0}\" )\n",
" pnts_n.append( n )\n",
" pnts_t.append( t1-t0 )\n",
" n += 1"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let us plot this data to see it visually."
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD4CAYAAAD8Zh1EAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAgAElEQVR4nO3deZhU1bnv8e8rigJxQGgCARk0mIgeErU1GqNiNBG9CmpMZDIOaD9yHSIOR45cPQaDE07XiNEOGsV0xAFjMEEEEcNVj0MbDyJyiX1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"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"plt.plot(pnts_n, pnts_t, 'ro-')\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Let us see if the emperical times match the theoretical $O(n!)$ expectation.\n",
"\n",
"`pnts_t[i]` contains the time for `pnts_n[i]`, so we expect $\\text{pnts_t[i]} \\approx \\text{pnts_n[i]}!$.\n",
"Hence, we must have\n",
"\n",
"$$\n",
"\\frac{\\text{pnts_t[i]}}{\\text{pnts_t[i-1]}} \\approx \\frac{i!}{(i-1)!} = i.\n",
"$$"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD4CAYAAAD1jb0+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4xLjAsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+17YcXAAAgAElEQVR4nO3dd5hV1bnH8e9CkaY0QYpIEZSoKG1ERUS8JFeN144FUexYiIk1osQoUYI1MbEkYgMNYgFNjMaCBB0UAQeC0iwUKUoZQEA6M7PuH+8+OWeGGZiZU/Ypv8/zzDMze5/Dedlz+LFm7Xev7bz3iIhI5qkRdgEiIlI9CnARkQylABcRyVAKcBGRDKUAFxHJUHun8sWaNGni27Ztm8qXFBHJeDNmzFjjvW9adntKA7xt27YUFBSk8iVFRDKec25Jeds1hSIikqEU4CIiGUoBLiKSoRTgIiIZSgEuIpKhFOCS28aMgbZtoUYN+zxmTNgViVRaStsIRdLKmDEwaBBs2WLfL1li3wMMGBBeXSKVpBG45K6hQ6PhHbFli20XyQAKcMldS5dWbbtImlGAS+5q3bpq20XSjAJcctfpp++6rW5dGD489bWIVIMCXHLTl1/CqFFwyCE24nYO2rSBkSN1AlMyhrpQJPds2gTnngt16sCkSXDggWFXJFItCnDJLd7DNdfYCPz99xX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Bh+jkwCfhJzHOvCI7jAuDyVNYVPOYe4P4yz0v28ZqM3S3qc6BvsO1a4Nrgawc8EbyPZgN5KTpee6rrGeCHmPdXQbD94OA5nwc/56EprusXMe+vqcT8B4PNTX8dHMuU1hV8fxnW2BD7vIQeL2x0vwLYiY2er8TOyU3EBh8TiQZzHvDMnt5PwePmBMftcWIGOLv70KX0IiIZKh3mwEVEpBoU4CIiGUoBLiKSoRTgIiIZSgEuIpKhFOAiIhlKAS4ikqH+H5gA5XzV+nnhAAAAAElFTkSuQmCC\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"pnts_ratios = [pnts_t[i]/pnts_t[i-1] for i in range(1,len(pnts_n))]\n",
"plt.plot(pnts_n[:-1], pnts_ratios, 'ro-')\n",
"plt.plot(pnts_n,pnts_n,'b-') # theoretical ratios\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"8\t0.011517763137817383\n",
"9\t0.08803129196166992\n",
"10\t0.8997573852539062\n",
"11\t9.502121210098267\n"
]
}
],
"source": [
"pnts_n = []\n",
"pnts_t = []\n",
"\n",
"n = 8\n",
"t0 = t1 = 0\n",
"\n",
"while t1-t0<1: # in seconds; if it takes too long then stop testing\n",
" G = random_euclidean_graph(n)\n",
" t0 = time()\n",
" exhaustive_search(G)\n",
" t1 = time()\n",
" # record time\n",
" print( f\"{n}\\t{t1-t0}\" )\n",
" pnts_n.append( n )\n",
" pnts_t.append( t1-t0 )\n",
" n += 1"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD9CAYAAACsq4z3AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAF/5JREFUeJzt3XuYVXW9x/H3lwGVi6EkKkgDqaW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kNLGvI/CwEPmdmHzWzboRu/GMttqmIfUJ+\nY4H075Pm9nD3N3LPVwF7tLJNpeyffMYC4MAfzGxBbs3iSlSSfZKqgp47ZjYM+DjQF+huZifHTVWY\nPMfyDFDr7gcD1wC/Lm/K9rn7EmAq8CDwAPAcsClqqALlOZbU75O2ePi3fCZOW2tnLP/l7ocAQ4Ef\nmdng8iVLt1QVdOAo4O/u3ujuG4FfAZ9tsU1ei1OnQLtjcff33X1N7vn9QBcz2638UbfP3W9y98Pc\nfTDwD+BvLTaplH3S7lgqZZ808+aWw1u5x7da2aZS9k8+Y9nyr1/c/S3gHsLhi0pTkn2StoK+HBhk\nZt3MzIAhhPVKm5sPnJo7s2IQ4VDGGy1/UQq0OxYz2zP3PczsM4T98U7Zk7bDzHbPPdYSjjnPbbFJ\npeyTdsdSKfukmfnAabnnpwG/aWWb0i/onox2x2Jm3c1s5y3PgaMJh9IqTWn2SexZ4lZmfycALxJ2\n0u3AjsD3ge/nvm/AdYQZ4hdoYxY5DV95jOVsYBFhhvvPwGdjZ25jHI8Di3M5h+Teq9R90t5YUrtP\ngDsJ8zEbCcdczwQ+CvwReIlw1k6v3LZ9gfub/ewxhH+NvAKMq9SxEM4K+Wvua1HssbQxjuNyz9cD\nbwK/L9c+0ZWiIiIZkbZDLiIiUiAVdBGRjFBBFxHJCBV0EZGMUEEXEckIFXQRkYxQQRcRyQgVdBGR\njPh/hmzs8qbbb5gAAAAASUVORK5CYII=\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x24f86844d68>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.plot(pnts_n, pnts_t, 'ro-')\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Discussion"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* Exhaustive search exhibits combinatorial running time $O(n!)$:\n",
"* So it is only useful/possible when $n$ is small, up to about 13 on the current machine if it needs to finish within an hour."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Approximation"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Greedy search"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"##### Nearest neigbours"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def greedy_nearest_neighbours(G):\n",
" H = copy.deepcopy(G) # We need the original G. We work on/modify H\n",
" n = len(H)\n",
" cities = list(range(n))\n",
" cycle = [] # solution to be built\n",
" city = 0 # Start city\n",
" while len(cities)>0:\n",
" # Find nearest neighbour\n",
" city_neighbours = H[city]\n",
" smallest_distance = min(city_neighbours)\n",
" nearest_city = city_neighbours.index(smallest_distance)\n",
" # Update 'cycle' and 'cities' and H then 'city'\n",
" cycle.append(city)\n",
" cities.remove(city)\n",
" for i in range(n): # 'city' is not to be used again!\n",
" H[city][i] = oo\n",
" H[i][city] = oo\n",
" city = nearest_city\n",
" return (cycle, cost(G, cycle))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The while-loop costs $O(n)$, and the nested for-loop within it also costs $O(n)$, while the rest can be assumed to cost $O(1)$.\n",
"So the total cost of this greedy approach is $O(n)\\times O(n) = O(n^2)$."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Example"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" 0 1 2 3\n",
" -----------------\n",
" 0 | ∞ 44 50 62\n",
" 1 | 44 ∞ 70 51\n",
" 2 | 50 70 ∞ 13\n",
" 3 | 62 51 13 ∞\n",
"\n"
]
},
{
"data": {
"text/plain": [
"([0, 1, 3, 2], 158)"
]
},
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"G=random_symmetric_graph(4)\n",
"show(G)\n",
"greedy_nearest_neighbours(G)"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" 0 1 2 3\n",
" -----------------\n",
" 0 | ∞114.3372205364464877.0778826901725482.38931969618392\n",
" 1 | 114.33722053644648 ∞38.0788655293195496.42095207992918\n",
" 2 | 77.0778826901725438.07886552931954 ∞68.94200461257273\n",
" 3 | 82.3893196961839296.4209520799291868.94200461257273 ∞\n",
"\n"
]
},
{
"data": {
"text/plain": [
"([0, 2, 1, 3], 293.9670199956052)"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"G=random_euclidean_graph(4)\n",
"show(G)\n",
"greedy_nearest_neighbours(G)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Test time and quality cost"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We will initially estimate the \"quality\" simply by comparing the length of the cycle found by the greed approach to the \"average length of a random cycle\".\n",
"\n",
"The average length of a random cycle is estimated to be the average length of a graph edge multiplied by the number of edges, i.e.\n",
"\n",
"$$\\frac{\\text{MAX_DISTANCE}}{2} \\times n.$$"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"10\t0.0496525764465332\t0.5082679999999999\n",
"20\t0.1907353401184082\t0.319404\n",
"30\t0.3874533176422119\t0.24130666666666664\n",
"40\t0.7231287956237793\t0.19880899999999999\n",
"50\t1.103902816772461\t0.1685712\n",
"60\t1.5338325500488281\t0.14980266666666667\n",
"70\t1.8535380363464355\t0.13568571428571427\n",
"80\t2.7287096977233887\t0.123572\n",
"90\t3.5187318325042725\t0.11156755555555554\n",
"100\t4.073294162750244\t0.10502280000000001\n",
"110\t4.978093862533569\t0.09801854545454546\n",
"120\t6.004432439804077\t0.092656\n",
"130\t7.973381757736206\t0.087268\n",
"140\t8.291640758514404\t0.08288485714285714\n",
"150\t8.916183471679688\t0.0789024\n",
"160\t10.312152862548828\t0.07590525\n"
]
}
],
"source": [
"MAX_REPETITIONS = 500\n",
"\n",
"pnts_n = []\n",
"pnts_t = []\n",
"pnts_q = []\n",
"\n",
"n = 10\n",
"t = 0\n",
"\n",
"while t<10: # in seconds; if it takes too long then stop testing\n",
" t = 0\n",
" expected_cycle_length = (MAX_DISTANCE/2)*n # TODO: Better estimate?\n",
" sum_of_distances = 0\n",
" for repetitions in range(MAX_REPETITIONS):\n",
" G = random_symmetric_graph(n)\n",
" t0 = time()\n",
" cycle, length = greedy_nearest_neighbours(G)\n",
" t1 = time()\n",
" sum_of_distances += length\n",
" t += t1-t0\n",
" # record time and quality\n",
" q = (sum_of_distances/MAX_REPETITIONS)/expected_cycle_length\n",
" pnts_n.append( n )\n",
" pnts_t.append( t )\n",
" pnts_q.append( q )\n",
" print( f\"{n}\\t{t}\\t{q}\" )\n",
" n += 10"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAD8CAYAAABn919SAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHEBJREFUeJzt3XmUVOWZx/HvI4ZdBQQR2RrEZYyjYlqjSJwIogYIRs8Y\nNUA0iRITl7iHxShoGExiGI1RIiLKkRYluBF3RXAPpHEgsqioyKIYGogiO4Rn/niL2PRCL7XcW7d+\nn3P6VNWtS9+HpvvH2+99F3N3REQk/+0VdQEiIpIZCnQRkYRQoIuIJIQCXUQkIRToIiIJoUAXEUkI\nBbqISEIo0EVEEkKBLiKSEHvn8mKtW7f2oqKiXF5SRCTvzZ07d427t6npvJwGelFREaWlpbm8pIhI\n3jOzZbU5T10uIiIJoUAXEUkIBbqISEIo0EVEEkKBLiKSEAp0EZFsKimBoiLYa6/wWFKStUvldNii\niEhBKSmBIUNg06bwetmy8Bpg4MCMX04tdBGRbBkx4qsw32XTpnA8CxToIiLZsnx53Y6nSYEuIpIt\nrVpVfbxTp6xcToEuIpINixfD+vXhZmh5TZvC6NFZuWSNgW5mE81stZktKHeslZm9aGZLUo8ts1Kd\niEg+2rgRzjkHWrS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EjiT8B/PQUAzMxtU/pwYfA0riWNN5ZnZCGAH\nUBJ1LeWZWVNgOHBj1LXswd6E3xhPAK4DpprVZVf7uiuYQDezrxHCvMTdH0sd/oeZtUu93w5YHVF5\nJwEDzOxj4GGgl5lNjlF9EFoRK919dur1NELAx6XGU4Gl7l7m7tuBx4AeMaqvvOpqqtU+vbliZhcC\n/YGBqf94ID41Hkz4z3t+6uemA/C2mR1IfGpcCTzmwRzCb9+ts1lfQQR66n/F+4DF7j623FvTgQtS\nzy8g9K3nnLsPc/cO7l5E2Jv1ZXcfFJf6ANz9M2CFmR2WOtQbWER8alwOnGBmTVP/3r2BxTGqr7zq\napoOnGdmjcysC3AIMCeC+jCzMwhdgAPcfVO5t2JRo7u/4+4HuHtR6udmJWHgw2dxqRF4gnBjFDM7\nlDCQYE1W68vFzYyoP4CehF9r/w7MS330BfYn3IhcQrgb3SoGtX6br26Kxqo+4BigNPV1fAJoGaca\ngVHAu8AC4EHCKIJI6wOmEPr0txNC5yd7qgkYQRj18B7wnQhr/IDQz7vr5+VPcauxwvsfk7opGkWN\n1XwNGwKTU9+PbwO9sl2fZoqKiCREQXS5iIgUAgW6iEhCKNBFRBJCgS4ikhAKdBGRhFCgi4gkhAJd\nRCQhFOgiIgnx/xmt4HL/3qYvAAAAAElFTkSuQmCC\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x24f870a6940>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.plot(pnts_n, pnts_t, 'ro-')\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8CAYAAACMwORRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAG8dJREFUeJzt3XmUlNWZx/HvQ7eIqEGERmXrxrgQl0hIi0uauC9Rz7iM\nZ0ZtnHEmkRCPMa4jisctITOo0ThGJYzRMbHV8WggTMSg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hcXFyhvO6rb7EdcukM7Mq4BvAa8A+7r4mdWgtsE9EZQH8HPgnYHvavmKq\nbxjQADyS6jp6yMx2p4hqdPfVwF3ACmANsNHdn6eIakyTraamN6gmq1L7ovSPwHOp50VTn5mdDax2\n97daHSqWGg8CRpvZa2b2spkdmdrfbfUlNtzNbA/gGeBKd/80/ZiHt9BIhhGZ2VnAenefl+2cKOtL\nKSd87HzQ3b8BfE7oTtgh6hpT/dZnE96IBgK7m9mY9HOirjGTYqypiZlNALYBdVHXks7MegM3AjdH\nXUsbygmfIo8GrgOeMjPrzhdMZLib2S6EYK9z99+mdq8zs/1Sx/cD1kdU3reAvzKzZcCTwIlm9lgR\n1QehdbHK3V9LbT9NCPtiqvFk4EN3b3D3rcBvgWOLrMYm2WpaTehHbjI4ta/gzOwS4CygNvUGBMVT\n31cJb+Jvpf7fDAZeN7N9KZ4aVwG/9WAO4VN5/+6sL3Hhnnq3/BWw2N3vTjs0Hfj71PO/J/TFF5y7\n3+Dug929CrgA+G93H1Ms9QG4+1pgpZkdnNp1ErCIIqqR0B1ztJn1Tv2dnwQsprhqbJKtpunABWa2\nq5kNAw4E5hS6ODM7ndBN+Ffu3ph2qCjqc/f57j7A3atS/29WEQZNrC2WGoFphIuqmNlBhEEIH3Vr\nfYW4+FFMD6CG8LH3beDN1OMMoB/hIuZ7hKvaexdBrcfTfEG1qOoDRgD1qd/jNKBvEdZ4G/AOsAD4\nDWFEQqQ1Ak8QrgFsJYTQd9uqCZhAGEGxBPhORPUtJfQLN/1/mRxVfdlqbHV8GakLqkX0O+wJPJb6\nt/g6cGJ316c7VEVEYihx3TIiIkmgcBcRiSGFu4hIDCncRURiSOEuIhJDCncRkRhSuIuIxJDCXUQk\nhv4fQW0BVLWREV4AAAAASUVORK5CYII=\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x24f8710d6a0>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.plot(pnts_n, pnts_q, 'ro-')\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"10\t0.06430292129516602\t143.42119902704604\n",
"20\t0.17042922973632812\t142.83896438342083\n",
"30\t0.48963046073913574\t142.04123881625168\n",
"40\t0.776923418045044\t141.14993333691754\n",
"50\t1.0704421997070312\t140.34975785979168\n",
"60\t1.514561414718628\t140.55813580788916\n",
"70\t2.0883636474609375\t138.78251853848585\n",
"80\t2.5483763217926025\t138.66092482047029\n",
"90\t3.320828914642334\t137.51922662536322\n",
"100\t4.0691139698028564\t138.2574686102402\n",
"110\t4.8069376945495605\t137.42881961473122\n",
"120\t5.977138519287109\t137.11342466295704\n"
]
}
],
"source": [
"MAX_REPETITIONS = 500\n",
"\n",
"pnts_n = []\n",
"pnts_t = []\n",
"pnts_q = []\n",
"\n",
"n = 10\n",
"t = 0\n",
"\n",
"while t<5: # in seconds; if it takes too long then stop testing\n",
" t = 0\n",
" expected_cycle_length = 0.71*sqrt(n) # TODO: Better estimate?\n",
" sum_of_distances = 0\n",
" for repetitions in range(MAX_REPETITIONS):\n",
" G = random_euclidean_graph(n)\n",
" t0 = time()\n",
" cycle, length = greedy_nearest_neighbours(G)\n",
" t1 = time()\n",
" sum_of_distances += length\n",
" t += t1-t0\n",
" # record time and quality\n",
" q = (sum_of_distances/MAX_REPETITIONS)/expected_cycle_length\n",
" pnts_n.append( n )\n",
" pnts_t.append( t )\n",
" pnts_q.append( q )\n",
" print( f\"{n}\\t{t}\\t{q}\" )\n",
" n += 10"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAW4AAAD8CAYAAABXe05zAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAG1tJREFUeJzt3XmYVNWd//H3FwQUEdGABERokmDAEAXTgyhJgLgTlIlb\nVDSiGJwZf9GfcQYXzGhUVNRoGNe0NK6tj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A\nclLPZOpcT3z72HrC1N6ETd+mAkcluW1ACfBWQ79PqYC7rM59zwGHxl1/Y9tX772fARVRt6+Yetz/\nx8xKgP7AXKCzu3+UeutjoHNMZTXV74GxwJY61wqlbT2BauDe1FDQJDPbnQJon7uvBG4GqoCPgDXu\n/jwF0LY6MrUl+mMRc+8c4M+pryNrX9EFt5m1A54A/r+7r637nod/FhM3zcbMhgOr3H1+pnuS2raU\nXYCDgbvcvT/wBfWGDpLavtR47wjCP05dgd3N7Iy69yS1bekUUlvqM7NxhCHZiqh/VlEFt5m1IoR2\nhbtPSV3+xMy6pN7vAqyKq74mGAQcb2bvAY8CPzGzhyiMtkHoqXzg7nNTrx8nBHkhtO8IYLm7V7v7\nRmAKcBiF0bZamdqS1bGISWBmo4DhwMjUP04QYfuKJrjNzIByYLG731LnrWeAs1Jfn0UY+04Ud7/M\n3bu5ewnhYchMdz+DAmgbgLt/DKwws++mLh0OvE1htK8KGGhmbVN/Rg8nPHgthLbVytSWZ4BTzaxN\n6mjEXsC8GOprEjM7hjBMeby719R5K7r2xT3Qn8MHCj8k/BftTWBh6mMY8A3CQ72/A38B9o671ia2\ncwhbH04WTNuAfkBl6vfvKWCvQmkf8FtgCfAW8CDQJqltAx4hjNVvJPxPafSO2gKMA5YSHmAeG3f9\nO9m+dwlj2bW5cnfU7dPKSRGRhCmaoRIRkUKh4BYRSRgFt4hIwii4RUQSRsEtIpIwCm4RkYRRcIuI\nJIyCW0QkYf4X3GmNLIbrjy8AAAAASUVORK5CYII=\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x24f8382db38>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.plot(pnts_n, pnts_t, 'ro-')\n",
"plt.show()"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD8CAYAAAB5Pm/hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxI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6fuPu85OMvCWGx\nG2Eht4eSpz0EnBhNhQ1jZp2A44EHUg7nfdvMbCfCmkuTAdz9G3f/nBi0Lak50MrMmgOFwMfkcduq\n2tyI9O0ZBkx39w3u/hHwAdCrUQqthzQbNz3n7huTT/8JdEo+zlrbFPS1lFyT/yDgNaCDu3+SfGkV\n0CGishrqduAKwuJ0FeLQtm5AOfBgcljqATNrTQza5u4rgVuAZcAnwH/c/Tli0LZK0rVnN2B5ynkr\nksfy1TnAn5OPs9Y2BX0tmNkOwO+Bn1baRhEP05bybuqSmQ0BVrv73HTn5GvbCD3ensA97n4QsJZK\nQxn52raH6DxOAAABjUlEQVTkWPUwwi+zXYHWZjYy9Zx8bVs6cWtPBTMbRxgeTmT7sxT0NTCzFoSQ\nT7j7H5KH/2VmuyRf3wVYHVV9DXAYMNTMlhL2DjjazB4lHm1bAaxw99eSz2cQgj8ObTsG+Mjdy939\nW+APwKHEo22p0rVnJdA55bxOyWN5xcx+BAwBSnzLHPestU1BXw0zM8I479vufmvKS08DZyUfnwU8\n1di1NZS7j3X3Tu5eRLgANNvdRxKPtq0Clif3TADoD7xFDNpGGLLpY2aFyX+f/QnXjuLQtlTp2vM0\ncIaZbWdm3YA9gdcjqK/ezGwQYch0qLuvS3kpe21zd32l+QL6Ev5kfBOYn/waDOxMmAnwPvBX4L+i\nrrWB7exH2BOYuLQNOBAoTf63exJoE6O2/Zywq9si4BFgu3xuG2Hb0U+Abwl/jY2qrj3AOGAJ8C5w\nXNT116NtHxDG4isy5d5st013xoqIxJyGbkREYk5BLyIScwp6EZGYU9CLiMScgl5EJOYU9CIiMaeg\nFxGJOQW9iEjM/X/K1H+jH/37WQAAAABJRU5ErkJggg==\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x24f870031d0>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plt.plot(pnts_n, pnts_q, 'ro-')\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Metaheuristics"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"............................................................\n",
"\n",
"............................................................\n",
"\n",
"............................................................\n",
"\n",
"............................................................\n",
"\n",
"............................................................\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# References"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"* Garey, S. and Johnson, D. (1979)\n",
"**Computers and Intractability: A Guide to the Theory of NP-Completeness.**\n",
"Freeman.\n",
"\n",
"* Hoos, H. and Stutzler, T. (2005)\n",
"**Stochastic Local Search: Foundations and Applications.**\n",
"Morgan Kaufmann.\n",
"\n",
"* Sipser, M. (2013).\n",
"**Introduction to the theory of computation**\n",
"(3rd international ed.). Cengage Learning."
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.1"
}
},
"nbformat": 4,
"nbformat_minor": 1
}