Skip to content

Instantly share code, notes, and snippets.

@yogabonito
Created September 10, 2017 21:32
Show Gist options
  • Save yogabonito/10a49bd0b3bceb0e698e2ca7bbf5633f to your computer and use it in GitHub Desktop.
Save yogabonito/10a49bd0b3bceb0e698e2ca7bbf5633f to your computer and use it in GitHub Desktop.
Speed comparison between `region` and `clusterpy`
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Speed comparison: AZP in `region` and `clusterpy`"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In this notebook we will compare the running times of the AZP implementations in `region` and in `clusterpy` based on a dataset which is also used in the problems 4, 5, and 6 in [Duque et al. (2011)](https://www.google.at/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&uact=8&ved=0ahUKEwiK2efWuprWAhVFvBQKHRouACIQFgg9MAE&url=http%3A%2F%2Fonlinelibrary.wiley.com%2Fdoi%2F10.1111%2Fj.1538-4632.2010.00810.x%2Fabstract&usg=AFQjCNF--NAHN98PKuR-gVNQPTk34XDdnA) (see table 4 and figure 5 on page 119). In these three problems, the dataset is clustered into 3, 4, and 6 clusters respectively. Juan Carlos Duque, one of the authors of the mentioned paper, provided me with the .shp- and .dbf-files used in the paper."
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ClusterPy: Library of spatially constrained clustering algorithms\n",
"Some functions are not available, reason: No module named 'Polygon'\n",
"Some functions are not available, reason: No module named 'Polygon'\n"
]
}
],
"source": [
"%matplotlib inline\n",
"import time\n",
"\n",
"import clusterpy as cp\n",
"import geopandas as gpd\n",
"import numpy as np\n",
"import networkx as nx\n",
"import pandas as pd\n",
"import matplotlib.pyplot as plt\n",
"import libpysal.api as ps_api\n",
"\n",
"from region.p_regions.azp import AZP"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"def convert_from_geodataframe(gdf):\n",
" w = ps_api.Rook.from_dataframe(gdf)\n",
" graph = w.to_networkx()\n",
" adj = nx.to_scipy_sparse_matrix(graph)\n",
" neighbor_dict = w.neighbors\n",
" return adj, graph, neighbor_dict, w"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"method = \"azp\" # used for clusterpy"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 5x5 dataset from [Duque et al. (2011)](https://www.google.at/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&uact=8&ved=0ahUKEwiK2efWuprWAhVFvBQKHRouACIQFgg9MAE&url=http%3A%2F%2Fonlinelibrary.wiley.com%2Fdoi%2F10.1111%2Fj.1538-4632.2010.00810.x%2Fabstract&usg=AFQjCNF--NAHN98PKuR-gVNQPTk34XDdnA)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"shp5_wo_ext = \"EX5\"\n",
"shp5 = shp5_wo_ext + \".shp\""
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"df5 = gpd.read_file(shp5)\n",
"attr5 = np.array(df5.VARIABLE0)\n",
"adj5 = convert_from_geodataframe(df5)[0] # use sparse matrix in region instead of GeoDataFrame\n",
"layer5 = cp.importArcData(shp5_wo_ext)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7f68be090ba8>"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAP4AAAD8CAYAAABXXhlaAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAC/lJREFUeJzt3X+snQV5wPHvYy8GiwNrSohruavJCAsh89fJUm8jM7Zb\nUFzrHJmY4DqnqRCHhZkYWLKQ/TX/MAhxrnhTmSwQdCndWplzYNHh6Gh2W8iEVgPBFVqLxTSzRP9g\nzGd/3MNyubnXe3Le99zzluf7Sd7cc07f+54nvf3e9z3nvvdtZCaSannNuAeQtPwMXyrI8KWCDF8q\nyPClggxfKsjwpYIMXyrI8KWCJpbzyVavXp3r1q1bzqeUSjl48OBPMvP8pdZb1vDXrVvHzMzMcj6l\nVEpEHB1kPQ/1pYIMXyrI8KWCDF8qyPClgpYMPyLuiIiTEfH4nMfeGBEPRMST/Y+rRjumpDYNssf/\nCnD5vMduBPZl5kXAvv59SWeIJcPPzIeAU/Me3gLc2b99J/CBlueSNELDnsBzQWae6N9+DrhgsRUj\nYhuwDWBycnKgjZ9z3rn8/PQLQ44mvfqsWrWKU6fm73+H1/jMvczMiFj0ip2ZOQ1MA/R6vYGu7Pnz\n0y/w+UcebjraSNywfgN33PXdcY+xqD+5+l383V/tGfcYC/qjm7awY+/+cY+xqGs3T7Hza938d/fx\nD21odXvDvqv/44h4E0D/48n2RpI0asOGvxfY2r+9FejmLkbSggb5cd49wL8DF0fEsYj4GPBZ4Hci\n4klgU/++pDPEkq/xM/PDi/zRxpZnkbRMPHNPKsjwpYIMXyrI8KWCDF8qyPClggxfKsjwpYIMXyrI\n8KWCDF8qyPClggxfKsjwpYIMXyrI8KWCDF8qyPClggxfKsjwpYIMXyrI8KWCDF8qyPClggxfKsjw\npYIMXyrI8KWCDF8qyPClghqFHxE3RMQTEfF4RNwTEWe3NZik0Rk6/IhYA3wK6GXmpcAK4Kq2BpM0\nOk0P9SeA10XEBLAS+FHzkSSN2tDhZ+Zx4HPAM8AJ4KeZeX9bg0kaocwcagFWAQ8C5wNnAf8IXL3A\netuAGWBmcnIyBwG4uLjMWwZsZ2aQficY3ibgh5n5PEBE7AamgLvmrpSZ08A0QK/Xy0E3fvue/Q1G\nG51rtkyx4+vdnA3g2t+b4s6bvzbuMRa09S8/xJd2PzzuMRb1iQ9u4Ev/0M35PvH7G1rdXpPX+M8A\n6yNiZUQEsBE40s5YkkapyWv8A8Au4BDwvf62pluaS9IINTnUJzNvBm5uaRZJy8Qz96SCDF8qyPCl\nggxfKsjwpYIMXyrI8KWCDF8qyPClggxfKsjwpYIMXyrI8KWCDF8qyPClggxfKsjwpYIMXyrI8KWC\nDF8qyPClggxfKsjwpYIMXyrI8KWCDF8qyPClggxfKsjwpYIMXyrI8KWCGoUfEW+IiF0R8f2IOBIR\n72xrMEmjM9Hw828DvpmZV0bEa4GVLcwkacSGDj8izgMuA/4YIDNfBF5sZyxJoxSZOdwnRrwVmAYO\nA28BDgLbM/Nn89bbBmwDmJycfMfRo0cH2fZQM0mvZoO0GhEHM7O35HoNwu8BjwAbMvNARNwGnM7M\nv1jsc3q9Xs7MzAyybW7fs3+ouUbtmi1T7NjbzdkArt08xRf/uZvzffK9U9z63W7OBnD9u6b439O3\njXuMBa04d3ur4Td5c+8YcCwzD/Tv7wLe3mB7kpbJ0OFn5nPAsxFxcf+hjcwe9kvquKbv6l8H3N1/\nR/9p4KPNR5I0ao3Cz8zHgCVfT0jqFs/ckwoyfKkgw5cKMnypIMOXCjJ8qSDDlwoyfKkgw5cKMnyp\nIMOXCjJ8qSDDlwoyfKkgw5cKMnypIMOXCjJ8qSDDlwoyfKkgw5cKMnypIMOXCjJ8qSDDlwoyfKkg\nw5cKMnypIMOXCjJ8qaDG4UfEioh4NCLua2MgSaPXxh5/O3Ckhe1IWiaNwo+ItcAVwM52xpG0HJru\n8W8FPgP8ooVZJC2XzBxqAd4P/E3/9ruB+xZZbxswA8xMTk7mIAAXF5d5y4DtzAzS7wTD2wBsjoj3\nAWcD50bEXZl59dyVMnMamAbo9Xo56MZv/c9/bTDa6Fz/m7/NF/btH/cYi7pu4xS3PPbQuMdY0J+9\n9TI+/8jD4x5jUTes38AXvtXNr+11m6Za3d7Qh/qZeVNmrs3MdcBVwIPzo5fUTf4cXyqoyaH+/8vM\n7wDfaWNbkkbPPb5UkOFLBRm+VJDhSwUZvlSQ4UsFGb5UkOFLBRm+VJDhSwUZvlSQ4UsFGb5UkOFL\nBRm+VJDhSwUZvlSQ4UsFGb5UkOFLBRm+VJDhSwUZvlSQ4UsFGb5UkOFLBRm+VJDhSwUZvlSQ4UsF\nGb5U0NDhR8SFEfHtiDgcEU9ExPY2B5M0OhMNPvcl4NOZeSgifgU4GBEPZObhlmaTNCJD7/Ez80Rm\nHurffgE4AqxpazBJoxOZ2XwjEeuAh4BLM/P0vD/bBmwDmJycfMfRo0eX3t5rApqPJb2qDNJqRBzM\nzN5S6zU51H/5iV4P3AtcPz96gMycBqYBer3eYDkn7D1+b9PRRmLzmj/gn47vGvcYi7pizZXsfOr+\ncY+xoI//+u9y+5794x5jUddsmWLHD7417jEWdO3Fm1rdXqN39SPiLGajvzszd7czkqRRa/KufgBf\nBo5k5i3tjSRp1Jrs8TcAHwHeExGP9Zf3tTSXpBEa+jV+Zv4bEC3OImmZeOaeVJDhSwUZvlSQ4UsF\nGb5UkOFLBRm+VJDhSwUZvlSQ4UsFGb5UkOFLBRm+VJDhSwUZvlSQ4UsFGb5UkOFLBRm+VJDhSwUZ\nvlSQ4UsFGb5UkOFLBRm+VJDhSwUZvlSQ4UsFGb5UkOFLBTUKPyIuj4gfRMRTEXFjW0NJGq2hw4+I\nFcAXgfcClwAfjohL2hpM0ug02eP/FvBUZj6dmS8CXwW2tDOWpFFqEv4a4Nk594/1H5PUdZk51AJc\nCeycc/8jwF8vsN42YAaYmZyczEGsWrUqARcXlznLIICZQfqdYHjHgQvn3F/bf+wVMnMamAbo9Xo5\nyIZPnTrVYCxJS2lyqP8fwEUR8eaIeC1wFbC3nbEkjdLQe/zMfCki/hT4F2AFcEdmPtHaZJJGpsmh\nPpn5DeAbLc0iaZl45p5UkOFLBRm+VJDhSwUZvlRQ9M+uW54ni3geODrAqquBn4x4nGF1eTbo9nxd\nng26Pd+gs/1aZp6/1ErLGv6gImImM3vjnmMhXZ4Nuj1fl2eDbs/X9mwe6ksFGb5UUFfDnx73AL9E\nl2eDbs/X5dmg2/O1OlsnX+NLGq2u7vEljVCnwu/yxTsj4sKI+HZEHI6IJyJi+7hnmi8iVkTEoxFx\n37hnmS8i3hARuyLi+xFxJCLeOe6ZXhYRN/S/po9HxD0RcfaY57kjIk5GxONzHntjRDwQEU/2P65q\n8hydCf8MuHjnS8CnM/MSYD3wyY7NB7AdODLuIRZxG/DNzPwN4C10ZM6IWAN8Cuhl5qXM/or5VeOd\niq8Al8977EZgX2ZeBOzr3x9aZ8Kn4xfvzMwTmXmof/sFZv/hduYagxGxFrgC2DnuWeaLiPOAy4Av\nA2Tmi5n53+Od6hUmgNdFxASwEvjROIfJzIeA+Zeh2gLc2b99J/CBJs/RpfDPmIt3RsQ64G3AgfFO\n8gq3Ap8BfjHuQRbwZuB54G/7L0V2RsQ54x4KIDOPA58DngFOAD/NzPvHO9WCLsjME/3bzwEXNNlY\nl8I/I0TE64F7gesz8/S45wGIiPcDJzPz4LhnWcQE8HZgR2a+DfgZDQ9V29J/rbyF2W9OvwqcExFX\nj3eqX65/Uc1GP47rUvgDXbxznCLiLGajvzszd497njk2AJsj4r+YfYn0noi4a7wjvcIx4FhmvnyE\ntIvZbwRdsAn4YWY+n5n/A+wGpsY800J+HBFvAuh/PNlkY10Kv9MX74yIYPY16pHMvGXc88yVmTdl\n5trMXMfs39uDmdmZvVZmPgc8GxEX9x/aCBwe40hzPQOsj4iV/a/xRjryxuM8e4Gt/dtbgT1NNtbo\nmnttOgMu3rmB2f874HsR8Vj/sT/vX3dQS7sOuLv/Tf1p4KNjngeAzDwQEbuAQ8z+5OZRxnwGX0Tc\nA7wbWB0Rx4Cbgc8Cfx8RH2P2N1z/sNFzeOaeVE+XDvUlLRPDlwoyfKkgw5cKMnypIMOXCjJ8qSDD\nlwr6PzWe6wpOTHYYAAAAAElFTkSuQmCC\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x7f68be081a58>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"df5.plot(column=\"VARIABLE0\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## clustering into 3 regions (problem 4 in [Duque et al. (2011)](https://www.google.at/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&uact=8&ved=0ahUKEwiK2efWuprWAhVFvBQKHRouACIQFgg9MAE&url=http%3A%2F%2Fonlinelibrary.wiley.com%2Fdoi%2F10.1111%2Fj.1538-4632.2010.00810.x%2Fabstract&usg=AFQjCNF--NAHN98PKuR-gVNQPTk34XDdnA))"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"n_regions = 3"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### ... with `region`"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"n_regions_per_comp {0: 3}\n",
"comp_label 0\n",
"n_regions_in_comp 3\n",
"Regions in comp: {0, 1, 2}\n",
"comp_adj.shape: (25, 25)\n",
"initial_clustering [0 0 1 2 2 0 0 1 2 2 0 1 1 2 2 1 1 1 2 2 1 1 1 1 1]\n",
"data [[ 1.116]\n",
" [-0.024]\n",
" [-0.733]\n",
" [ 0.369]\n",
" [ 0.118]\n",
" [ 0.344]\n",
" [ 0.428]\n",
" [-0.915]\n",
" [ 0.267]\n",
" [ 0.29 ]\n",
" [ 0.364]\n",
" [ 0.38 ]\n",
" [ 0.548]\n",
" [ 0.926]\n",
" [ 3.037]\n",
" [ 1.433]\n",
" [ 0.743]\n",
" [ 1.363]\n",
" [ 1.106]\n",
" [ 0.721]\n",
" [ 2.126]\n",
" [ 2.156]\n",
" [ 1.758]\n",
" [ 0.339]\n",
" [ 1.669]]\n",
"start with obj. val.: [[ 110.781]]\n",
"RN {0: {2, 11, 15, 7}, 1: {1, 3, 6, 8, 10, 13, 18, 19}, 2: {2, 7, 12, 17, 23, 24}}\n",
"step 2\n",
"step 3\n",
" chosen region: 2\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 24 from 1 to 2\n",
" donor is losing {19} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 23 from 1 to 2\n",
" donor is losing {24} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 17 from 1 to 2\n",
" donor is losing {18} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 0\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 15 from 1 to 0\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 2 from 1 to 0\n",
" donor is losing {1, 3} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 3 from 2 to 0\n",
" donor is losing {2} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 4 from 2 to 0\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 8 from 2 to 0\n",
" donor is losing {3, 7} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 7 from 1 to 0\n",
" donor is losing {8, 2} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 9 from 2 to 0\n",
" donor is losing {4} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 1\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 15 from 0 to 1\n",
" donor is losing {16, 20} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 23 from 2 to 1\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"n_regions_per_comp {0: 3}\n",
"comp_label 0\n",
"n_regions_in_comp 3\n",
"Regions in comp: {0, 1, 2}\n",
"comp_adj.shape: (25, 25)\n",
"initial_clustering [0 0 1 1 1 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2]\n",
"data [[ 1.116]\n",
" [-0.024]\n",
" [-0.733]\n",
" [ 0.369]\n",
" [ 0.118]\n",
" [ 0.344]\n",
" [ 0.428]\n",
" [-0.915]\n",
" [ 0.267]\n",
" [ 0.29 ]\n",
" [ 0.364]\n",
" [ 0.38 ]\n",
" [ 0.548]\n",
" [ 0.926]\n",
" [ 3.037]\n",
" [ 1.433]\n",
" [ 0.743]\n",
" [ 1.363]\n",
" [ 1.106]\n",
" [ 0.721]\n",
" [ 2.126]\n",
" [ 2.156]\n",
" [ 1.758]\n",
" [ 0.339]\n",
" [ 1.669]]\n",
"start with obj. val.: [[ 174.689]]\n",
"RN {0: {11, 2, 10, 7}, 1: {1, 5, 6, 22, 23, 24}, 2: {17, 18, 19, 21}}\n",
"step 2\n",
"step 3\n",
" chosen region: 2\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 21 from 1 to 2\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 16 from 1 to 2\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 19 from 1 to 2\n",
" donor is losing {24} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 14 from 1 to 2\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 17 from 1 to 2\n",
" donor is losing {22} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 20 from 1 to 2\n",
" donor is losing {21} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 15 from 1 to 2\n",
" donor is losing {20} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 18 from 1 to 2\n",
" donor is losing {19, 23} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 0\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 10 from 1 to 0\n",
" donor is losing {5, 15} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 11 from 1 to 0\n",
" donor is losing {16, 10} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 2 from 1 to 0\n",
" donor is losing {1} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 3 from 1 to 0\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 16 from 2 to 0\n",
" donor is losing {11} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 1\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 3 from 0 to 1\n",
" donor is losing {8, 4} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 2 from 0 to 1\n",
" donor is losing {3} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"n_regions_per_comp {0: 3}\n",
"comp_label 0\n",
"n_regions_in_comp 3\n",
"Regions in comp: {0, 1, 2}\n",
"comp_adj.shape: (25, 25)\n",
"initial_clustering [0 0 1 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]\n",
"data [[ 1.116]\n",
" [-0.024]\n",
" [-0.733]\n",
" [ 0.369]\n",
" [ 0.118]\n",
" [ 0.344]\n",
" [ 0.428]\n",
" [-0.915]\n",
" [ 0.267]\n",
" [ 0.29 ]\n",
" [ 0.364]\n",
" [ 0.38 ]\n",
" [ 0.548]\n",
" [ 0.926]\n",
" [ 3.037]\n",
" [ 1.433]\n",
" [ 0.743]\n",
" [ 1.363]\n",
" [ 1.106]\n",
" [ 0.721]\n",
" [ 2.126]\n",
" [ 2.156]\n",
" [ 1.758]\n",
" [ 0.339]\n",
" [ 1.669]]\n",
"start with obj. val.: [[ 224.309]]\n",
"RN {0: {2, 5, 6}, 1: {0, 1, 3, 4}, 2: {8, 9, 2}}\n",
"step 2\n",
"step 3\n",
" chosen region: 2\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 2 from 1 to 2\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 7 from 1 to 2\n",
" donor is losing {2} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 6 from 1 to 2\n",
" donor is losing {1} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 5 from 1 to 2\n",
" donor is losing {0} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 10 from 1 to 2\n",
" donor is losing {5} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 8 from 1 to 2\n",
" donor is losing {3} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 13 from 1 to 2\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 9 from 1 to 2\n",
" donor is losing {8, 4} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 12 from 1 to 2\n",
" donor is losing {7} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 11 from 1 to 2\n",
" donor is losing {6} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 16 from 1 to 2\n",
" donor is losing {11} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 1\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 13 from 2 to 1\n",
" donor is losing {18} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 0\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 5 from 2 to 0\n",
" donor is losing {0} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 2 from 2 to 0\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 10 from 2 to 0\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 15 from 1 to 0\n",
" donor is losing {10} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 16 from 2 to 0\n",
" donor is losing {21, 15} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"n_regions_per_comp {0: 3}\n",
"comp_label 0\n",
"n_regions_in_comp 3\n",
"Regions in comp: {0, 1, 2}\n",
"comp_adj.shape: (25, 25)\n",
"initial_clustering [0 0 1 2 2 0 0 1 1 2 0 0 1 1 2 0 0 1 1 2 0 0 1 1 1]\n",
"data [[ 1.116]\n",
" [-0.024]\n",
" [-0.733]\n",
" [ 0.369]\n",
" [ 0.118]\n",
" [ 0.344]\n",
" [ 0.428]\n",
" [-0.915]\n",
" [ 0.267]\n",
" [ 0.29 ]\n",
" [ 0.364]\n",
" [ 0.38 ]\n",
" [ 0.548]\n",
" [ 0.926]\n",
" [ 3.037]\n",
" [ 1.433]\n",
" [ 0.743]\n",
" [ 1.363]\n",
" [ 1.106]\n",
" [ 0.721]\n",
" [ 2.126]\n",
" [ 2.156]\n",
" [ 1.758]\n",
" [ 0.339]\n",
" [ 1.669]]\n",
"start with obj. val.: [[ 101.53]]\n",
"RN {0: {17, 2, 12, 22, 7}, 1: {1, 3, 6, 9, 11, 14, 16, 19, 21}, 2: {8, 24, 2, 18, 13}}\n",
"step 2\n",
"step 3\n",
" chosen region: 2\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 13 from 1 to 2\n",
" donor is losing {14} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 2 from 1 to 2\n",
" donor is losing {1} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 1 from 0 to 2\n",
" donor is losing {2} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 8 from 1 to 2\n",
" donor is losing {9, 3} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 1\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 16 from 0 to 1\n",
" donor is losing {17} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 13 from 2 to 1\n",
" donor is losing {12} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 19 from 2 to 1\n",
" donor is losing {24, 18} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 0\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 22 from 1 to 0\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"n_regions_per_comp {0: 3}\n",
"comp_label 0\n",
"n_regions_in_comp 3\n",
"Regions in comp: {0, 1, 2}\n",
"comp_adj.shape: (25, 25)\n",
"initial_clustering [0 0 1 2 2 1 0 1 2 2 1 1 1 2 2 1 1 1 2 2 1 1 1 1 1]\n",
"data [[ 1.116]\n",
" [-0.024]\n",
" [-0.733]\n",
" [ 0.369]\n",
" [ 0.118]\n",
" [ 0.344]\n",
" [ 0.428]\n",
" [-0.915]\n",
" [ 0.267]\n",
" [ 0.29 ]\n",
" [ 0.364]\n",
" [ 0.38 ]\n",
" [ 0.548]\n",
" [ 0.926]\n",
" [ 3.037]\n",
" [ 1.433]\n",
" [ 0.743]\n",
" [ 1.363]\n",
" [ 1.106]\n",
" [ 0.721]\n",
" [ 2.126]\n",
" [ 2.156]\n",
" [ 1.758]\n",
" [ 0.339]\n",
" [ 1.669]]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"start with obj. val.: [[ 131.075]]\n",
"RN {0: {2, 11, 5, 7}, 1: {0, 1, 3, 6, 8, 13, 18, 19}, 2: {2, 7, 12, 17, 23, 24}}\n",
"step 2\n",
"step 3\n",
" chosen region: 1\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 0\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 5 from 1 to 0\n",
" donor is losing {0} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 11 from 1 to 0\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 16 from 1 to 0\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 2 from 1 to 0\n",
" donor is losing {1, 3} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 7 from 1 to 0\n",
" donor is losing {8, 2, 6} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 3 from 2 to 0\n",
" donor is losing {2} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 10 from 1 to 0\n",
" donor is losing {5} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 8 from 2 to 0\n",
" donor is losing {7} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 4 from 2 to 0\n",
" donor is losing {3} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 9 from 2 to 0\n",
" donor is losing {4} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 12 from 1 to 0\n",
" donor is losing {11, 13, 7} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 2\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 9 from 0 to 2\n",
" donor is losing {14} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 12 from 0 to 2\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 7 from 0 to 2\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"n_regions_per_comp {0: 3}\n",
"comp_label 0\n",
"n_regions_in_comp 3\n",
"Regions in comp: {0, 1, 2}\n",
"comp_adj.shape: (25, 25)\n",
"initial_clustering [0 0 0 1 1 0 0 0 2 1 0 0 0 2 1 0 0 0 2 1 0 0 0 0 0]\n",
"data [[ 1.116]\n",
" [-0.024]\n",
" [-0.733]\n",
" [ 0.369]\n",
" [ 0.118]\n",
" [ 0.344]\n",
" [ 0.428]\n",
" [-0.915]\n",
" [ 0.267]\n",
" [ 0.29 ]\n",
" [ 0.364]\n",
" [ 0.38 ]\n",
" [ 0.548]\n",
" [ 0.926]\n",
" [ 3.037]\n",
" [ 1.433]\n",
" [ 0.743]\n",
" [ 1.363]\n",
" [ 1.106]\n",
" [ 0.721]\n",
" [ 2.126]\n",
" [ 2.156]\n",
" [ 1.758]\n",
" [ 0.339]\n",
" [ 1.669]]\n",
"start with obj. val.: [[ 156.342]]\n",
"RN {0: {8, 19, 18, 3, 13}, 1: {8, 24, 2, 18, 13}, 2: {3, 7, 9, 12, 14, 17, 19, 23}}\n",
"step 2\n",
"step 3\n",
" chosen region: 0\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 1\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 24 from 0 to 1\n",
" donor is losing {19} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 2 from 0 to 1\n",
" donor is losing {3} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 1 from 0 to 1\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 7 from 0 to 1\n",
" donor is losing {8, 2} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 6 from 0 to 1\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 23 from 0 to 1\n",
" donor is losing {24} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 11 from 0 to 1\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 2\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 23 from 1 to 2\n",
" donor is losing {22} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 12 from 0 to 2\n",
" donor is losing {13, 7} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 7 from 1 to 2\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 11 from 1 to 2\n",
" donor is losing {16, 10, 12} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 24 from 1 to 2\n",
" donor is losing {23} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 19 from 1 to 2\n",
" donor is losing {24, 18} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 16 from 0 to 2\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"n_regions_per_comp {0: 3}\n",
"comp_label 0\n",
"n_regions_in_comp 3\n",
"Regions in comp: {0, 1, 2}\n",
"comp_adj.shape: (25, 25)\n",
"initial_clustering [0 0 1 1 1 0 0 1 1 1 0 2 1 1 1 0 2 1 1 1 0 2 1 1 1]\n",
"data [[ 1.116]\n",
" [-0.024]\n",
" [-0.733]\n",
" [ 0.369]\n",
" [ 0.118]\n",
" [ 0.344]\n",
" [ 0.428]\n",
" [-0.915]\n",
" [ 0.267]\n",
" [ 0.29 ]\n",
" [ 0.364]\n",
" [ 0.38 ]\n",
" [ 0.548]\n",
" [ 0.926]\n",
" [ 3.037]\n",
" [ 1.433]\n",
" [ 0.743]\n",
" [ 1.363]\n",
" [ 1.106]\n",
" [ 0.721]\n",
" [ 2.126]\n",
" [ 2.156]\n",
" [ 1.758]\n",
" [ 0.339]\n",
" [ 1.669]]\n",
"start with obj. val.: [[ 139.758]]\n",
"RN {0: {16, 2, 11, 21, 7}, 1: {16, 1, 11, 21, 6}, 2: {6, 10, 12, 15, 17, 20, 22}}\n",
"step 2\n",
"step 3\n",
" chosen region: 2\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 22 from 1 to 2\n",
" donor is losing {21} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 20 from 0 to 2\n",
" donor is losing {21} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 12 from 1 to 2\n",
" donor is losing {11} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 13 from 1 to 2\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 23 from 1 to 2\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 7 from 1 to 2\n",
" donor is losing {6} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 17 from 1 to 2\n",
" donor is losing {16, 12, 22} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 18 from 1 to 2\n",
" donor is losing {17} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 24 from 1 to 2\n",
" donor is losing {23} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 1\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 7 from 2 to 1\n",
" donor is losing {2} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 12 from 2 to 1\n",
" donor is losing {7} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 11 from 2 to 1\n",
" donor is losing {10, 6} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 0\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 11 from 1 to 0\n",
" donor is losing {16, 10} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 12 from 1 to 0\n",
" donor is losing {17, 11} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 16 from 2 to 0\n",
" donor is losing {11} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 13 from 2 to 0\n",
" donor is losing {8, 14} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 8 from 1 to 0\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"n_regions_per_comp {0: 3}\n",
"comp_label 0\n",
"n_regions_in_comp 3\n",
"Regions in comp: {0, 1, 2}\n",
"comp_adj.shape: (25, 25)\n",
"initial_clustering [0 0 0 1 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 2 2 2]\n",
"data [[ 1.116]\n",
" [-0.024]\n",
" [-0.733]\n",
" [ 0.369]\n",
" [ 0.118]\n",
" [ 0.344]\n",
" [ 0.428]\n",
" [-0.915]\n",
" [ 0.267]\n",
" [ 0.29 ]\n",
" [ 0.364]\n",
" [ 0.38 ]\n",
" [ 0.548]\n",
" [ 0.926]\n",
" [ 3.037]\n",
" [ 1.433]\n",
" [ 0.743]\n",
" [ 1.363]\n",
" [ 1.106]\n",
" [ 0.721]\n",
" [ 2.126]\n",
" [ 2.156]\n",
" [ 1.758]\n",
" [ 0.339]\n",
" [ 1.669]]\n",
"start with obj. val.: [[ 146.424]]\n",
"RN {0: {3, 9, 14, 19, 22, 23}, 1: {8, 24, 2, 18, 13}, 2: {17, 18, 19, 21}}\n",
"step 2\n",
"step 3\n",
" chosen region: 2\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 17 from 0 to 2\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 16 from 0 to 2\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 19 from 1 to 2\n",
" donor is losing {24, 18} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 21 from 0 to 2\n",
" donor is losing {22} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 11 from 0 to 2\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 20 from 0 to 2\n",
" donor is losing {21} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 18 from 0 to 2\n",
" donor is losing {19, 23} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 15 from 0 to 2\n",
" donor is losing {16, 20} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 13 from 0 to 2\n",
" donor is losing {18, 14} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 0\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 11 from 2 to 0\n",
" donor is losing {6} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 16 from 2 to 0\n",
" donor is losing {11} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 1\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 8 from 0 to 1\n",
" donor is losing {9} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 7 from 0 to 1\n",
" donor is losing {8} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 19 from 2 to 1\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 2 from 0 to 1\n",
" donor is losing {3} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"277 ms ± 62.3 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
]
}
],
"source": [
"%timeit AZP().fit_from_scipy_sparse_matrix(adj=adj5, n_regions=n_regions, data=attr5)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### ... with `clusterpy`"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0, 2, 2, 2, 0, 0]\n",
"initial O.F: 9.259791300000002\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0, 2, 2, 2, 0, 0]\n",
"FINAL O.F.: 9.119373231372547\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n",
"initial O.F: 13.092783818181818\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 2, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n",
"FINAL O.F.: 12.615489238095238\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2]\n",
"initial O.F: 13.275961090909092\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2]\n",
"FINAL O.F.: 9.670804457142856\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"initial O.F: 8.642999957142859\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"FINAL O.F.: 8.486904713286712\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0]\n",
"initial O.F: 9.259791300000002\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 2, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0]\n",
"FINAL O.F.: 9.119373231372549\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n",
"initial O.F: 13.166656608695652\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n",
"FINAL O.F.: 13.166656608695652\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 1, 2, 2, 0, 0, 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"initial O.F: 11.43110210526316\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 1, 1, 2, 2, 0, 0, 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"FINAL O.F.: 10.56964561111111\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 0, 2, 2, 2, 0, 0]\n",
"initial O.F: 13.343903300000001\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 2, 0, 0, 2, 2, 2, 0, 0]\n",
"FINAL O.F.: 13.343903300000001\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [2, 0, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"initial O.F: 8.685420666666667\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 0, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"FINAL O.F.: 8.685420666666667\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"initial O.F: 7.00070848888889\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"FINAL O.F.: 6.764515314285714\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [2, 2, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]\n",
"initial O.F: 13.092783818181818\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 0, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1]\n",
"FINAL O.F.: 12.615489238095238\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 1, 2, 1, 1, 2, 2, 2, 1, 1]\n",
"initial O.F: 6.9971348\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 1, 2, 1, 1, 2, 2, 2, 1, 1]\n",
"FINAL O.F.: 6.9971347999999995\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [2, 2, 0, 0, 0, 2, 2, 0, 0, 0, 2, 2, 2, 2, 2, 1, 2, 1, 2, 2, 1, 1, 1, 2, 2]\n",
"initial O.F: 9.802601633333333\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 2, 2]\n",
"FINAL O.F.: 8.907127880952382\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [2, 2, 0, 0, 0, 2, 2, 0, 0, 0, 2, 2, 2, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"initial O.F: 8.136516844696969\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 2, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"FINAL O.F.: 6.569520830769231\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 2, 2, 0, 0, 2, 2, 2, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"initial O.F: 8.136516844696969\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 2, 2, 2, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"FINAL O.F.: 7.373772000000001\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [2, 2, 1, 0, 0, 2, 2, 1, 0, 0, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"initial O.F: 11.593607803921568\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"FINAL O.F.: 6.569520830769232\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 0, 1, 1, 0, 0, 0, 1, 1]\n",
"initial O.F: 13.343903300000001\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 0, 1, 1, 0, 0, 0, 1, 1]\n",
"FINAL O.F.: 13.343903300000001\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0]\n",
"initial O.F: 13.092783818181818\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 1, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0]\n",
"FINAL O.F.: 12.615489238095238\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"initial O.F: 6.569520830769232\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"FINAL O.F.: 6.569520830769231\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"initial O.F: 6.569520830769232\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"FINAL O.F.: 6.569520830769232\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"initial O.F: 9.045742363636364\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 2, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"FINAL O.F.: 8.685420666666667\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"initial O.F: 7.00070848888889\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"FINAL O.F.: 6.764515314285715\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [2, 0, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"initial O.F: 8.685420666666667\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 0, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"FINAL O.F.: 8.685420666666667\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"initial O.F: 9.045742363636364\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"FINAL O.F.: 8.685420666666667\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 0, 2, 2, 0, 0, 0, 2, 2, 0, 0, 0, 2, 1, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"initial O.F: 10.209809257142858\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"FINAL O.F.: 6.764515314285715\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"initial O.F: 9.045742363636364\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 2, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"FINAL O.F.: 8.685420666666666\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n",
"initial O.F: 13.166656608695652\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n",
"FINAL O.F.: 13.166656608695652\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0]\n",
"initial O.F: 9.259791300000002\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 2, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0]\n",
"FINAL O.F.: 9.119373231372549\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 0, 2, 2, 0, 0, 0, 2, 2, 0, 0, 0, 2, 2, 1, 0, 2, 2, 2, 1, 1, 1, 2, 2]\n",
"initial O.F: 11.315637831818183\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 1, 0, 2, 2, 2, 1, 1, 1, 2, 2]\n",
"FINAL O.F.: 8.525161392857143\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"initial O.F: 6.569520830769232\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"FINAL O.F.: 6.569520830769232\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [1, 1, 0, 2, 2, 1, 1, 0, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"initial O.F: 11.43110210526316\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 0, 0, 2, 2, 1, 1, 0, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"FINAL O.F.: 10.569645611111111\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 2, 2, 0, 0]\n",
"initial O.F: 9.858085416666666\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0]\n",
"FINAL O.F.: 8.603368516666665\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"initial O.F: 6.569520830769232\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"FINAL O.F.: 6.569520830769232\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 0, 2, 2, 0, 0, 0, 2, 2, 0, 0, 0, 2, 1, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"initial O.F: 10.209809257142858\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"FINAL O.F.: 6.764515314285715\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"initial O.F: 9.045742363636364\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 2, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"FINAL O.F.: 8.685420666666667\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 2, 1, 0, 0, 0, 2, 2, 2, 0, 0]\n",
"initial O.F: 11.315637831818183\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 2, 1, 0, 0, 0, 2, 2, 2, 0, 0]\n",
"FINAL O.F.: 8.525161392857145\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"initial O.F: 9.045742363636366\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 2, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"FINAL O.F.: 8.685420666666667\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 1, 2, 2, 0, 0, 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"initial O.F: 11.43110210526316\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 1, 1, 2, 2, 0, 0, 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"FINAL O.F.: 10.569645611111111\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n",
"initial O.F: 13.166656608695652\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n",
"FINAL O.F.: 13.166656608695652\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"initial O.F: 6.569520830769232\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"FINAL O.F.: 6.569520830769232\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"initial O.F: 6.569520830769232\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"FINAL O.F.: 6.569520830769232\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"initial O.F: 9.045742363636364\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"FINAL O.F.: 8.685420666666666\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"initial O.F: 8.486904713286712\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"FINAL O.F.: 8.486904713286712\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 2]\n",
"initial O.F: 9.378596488888888\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 2, 1]\n",
"FINAL O.F.: 7.703387600000001\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"initial O.F: 7.00070848888889\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"FINAL O.F.: 6.764515314285715\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"initial O.F: 8.642999957142857\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"FINAL O.F.: 8.486904713286712\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0]\n",
"initial O.F: 13.166656608695652\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"FINAL O.F.: 13.166656608695655\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [2, 1, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 0, 2, 0, 2, 2, 0, 0, 0, 2, 2]\n",
"initial O.F: 9.119373231372549\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 1, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 0, 2, 0, 2, 2, 0, 0, 0, 2, 2]\n",
"FINAL O.F.: 9.119373231372549\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]\n",
"initial O.F: 13.999814869565219\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 1, 0, 0, 1, 1, 1, 1, 1]\n",
"FINAL O.F.: 7.077287915966387\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2]\n",
"initial O.F: 13.999814869565215\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 0, 2, 0, 2, 2, 0, 0, 0, 0, 0]\n",
"FINAL O.F.: 7.077287915966387\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [2, 0, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"initial O.F: 6.751285183333334\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 2, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"FINAL O.F.: 6.56952083076923\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"initial O.F: 9.045742363636364\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 2, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"FINAL O.F.: 8.685420666666667\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [2, 2, 1, 1, 1, 2, 2, 1, 1, 1, 2, 2, 2, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"initial O.F: 8.13651684469697\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 1, 1, 1, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"FINAL O.F.: 7.373772000000001\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [2, 2, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 2, 2, 1, 1, 1, 2, 2]\n",
"initial O.F: 9.2597913\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 0, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 2, 2, 1, 1, 1, 2, 2]\n",
"FINAL O.F.: 9.119373231372549\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [2, 2, 0, 0, 0, 2, 2, 0, 0, 0, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"initial O.F: 8.960943333333333\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"FINAL O.F.: 7.312367028571428\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 1, 0, 0, 1, 1, 1, 0, 0]\n",
"initial O.F: 13.343903300000001\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 1, 0, 0, 1, 1, 1, 0, 0]\n",
"FINAL O.F.: 13.343903300000001\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"initial O.F: 10.209809257142858\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"FINAL O.F.: 6.764515314285715\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"initial O.F: 9.045742363636364\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 2, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"FINAL O.F.: 8.685420666666667\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"initial O.F: 9.045742363636366\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 2, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"FINAL O.F.: 8.685420666666667\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"initial O.F: 7.00070848888889\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"FINAL O.F.: 6.764515314285714\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [2, 0, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 2, 2, 1, 1, 1, 2, 2]\n",
"initial O.F: 9.119373231372549\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 0, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 1, 2, 1, 2, 2, 1, 1, 1, 2, 2]\n",
"FINAL O.F.: 9.119373231372549\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 1, 2, 2, 0, 0, 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"initial O.F: 11.43110210526316\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 1, 1, 2, 2, 0, 0, 1, 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"FINAL O.F.: 10.569645611111111\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [1, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"initial O.F: 13.618158954545457\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"FINAL O.F.: 6.569520830769231\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"initial O.F: 9.045742363636364\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 2, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"FINAL O.F.: 8.685420666666667\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"initial O.F: 7.00070848888889\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"FINAL O.F.: 6.764515314285715\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 1]\n",
"initial O.F: 9.378596488888888\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 2, 0, 2, 2, 1, 2, 2, 2, 2, 1]\n",
"FINAL O.F.: 8.958676089285715\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"initial O.F: 7.00070848888889\n",
"Performing local search\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"FINAL SOLUTION: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"FINAL O.F.: 6.764515314285715\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [2, 2, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"initial O.F: 6.569520830769232\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 2, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"FINAL O.F.: 6.569520830769232\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"initial O.F: 7.00070848888889\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"FINAL O.F.: 6.764515314285715\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n",
"initial O.F: 13.092783818181818\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 2, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n",
"FINAL O.F.: 12.615489238095236\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"initial O.F: 7.00070848888889\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"FINAL O.F.: 6.764515314285715\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"initial O.F: 6.569520830769232\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"FINAL O.F.: 6.569520830769231\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"initial O.F: 6.569520830769232\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"FINAL O.F.: 6.569520830769232\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 0, 2, 2, 0, 0, 0, 2, 2, 0, 0, 0, 2, 1, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"initial O.F: 10.209809257142858\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"FINAL O.F.: 6.764515314285715\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 2, 2, 0, 0, 2, 2, 2, 0, 0, 0, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"initial O.F: 8.13651684469697\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 2, 2, 2, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"FINAL O.F.: 7.373772000000001\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"initial O.F: 8.960943333333333\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"FINAL O.F.: 7.312367028571428\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 2, 2, 2, 1, 1]\n",
"initial O.F: 9.802601633333335\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, 2, 2, 2, 1, 1]\n",
"FINAL O.F.: 9.003593716666668\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [0, 2, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n",
"initial O.F: 12.615489238095236\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 2, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n",
"FINAL O.F.: 12.615489238095238\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [2, 1, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 0, 2, 0, 2, 2, 0, 0, 0, 2, 2]\n",
"initial O.F: 9.119373231372549\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 1, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 0, 2, 0, 2, 2, 0, 0, 0, 2, 2]\n",
"FINAL O.F.: 9.119373231372549\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [2, 2, 1, 1, 1, 2, 2, 1, 1, 1, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"initial O.F: 8.960943333333333\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"FINAL O.F.: 7.312367028571428\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 3\n",
"Constructing regions\n",
"initial Solution: [1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]\n",
"initial O.F: 12.635391333333335\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1, 1, 0, 1, 1, 2, 1, 1, 1, 2, 2]\n",
"FINAL O.F.: 10.080993757575758\n",
"Done\n",
"Adding variables\n",
"Done\n",
"27.5 ms ± 1.7 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n"
]
}
],
"source": [
"%timeit layer5.cluster(method, ['VARIABLE0'], n_regions)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## clustering into 4 regions (problem 5 in [Duque et al. (2011)](https://www.google.at/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&uact=8&ved=0ahUKEwiK2efWuprWAhVFvBQKHRouACIQFgg9MAE&url=http%3A%2F%2Fonlinelibrary.wiley.com%2Fdoi%2F10.1111%2Fj.1538-4632.2010.00810.x%2Fabstract&usg=AFQjCNF--NAHN98PKuR-gVNQPTk34XDdnA))"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"n_regions = 4"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### ... with `region`"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"n_regions_per_comp {0: 4}\n",
"comp_label 0\n",
"n_regions_in_comp 4\n",
"Regions in comp: {0, 1, 2, 3}\n",
"comp_adj.shape: (25, 25)\n",
"initial_clustering [0 0 1 2 2 0 0 3 2 2 0 0 3 2 2 0 0 3 3 2 0 0 3 3 3]\n",
"data [[ 1.116]\n",
" [-0.024]\n",
" [-0.733]\n",
" [ 0.369]\n",
" [ 0.118]\n",
" [ 0.344]\n",
" [ 0.428]\n",
" [-0.915]\n",
" [ 0.267]\n",
" [ 0.29 ]\n",
" [ 0.364]\n",
" [ 0.38 ]\n",
" [ 0.548]\n",
" [ 0.926]\n",
" [ 3.037]\n",
" [ 1.433]\n",
" [ 0.743]\n",
" [ 1.363]\n",
" [ 1.106]\n",
" [ 0.721]\n",
" [ 2.126]\n",
" [ 2.156]\n",
" [ 1.758]\n",
" [ 0.339]\n",
" [ 1.669]]\n",
"start with obj. val.: [[ 83.962]]\n",
"RN {0: {17, 2, 12, 22, 7}, 1: {1, 3, 7}, 2: {24, 2, 18, 12, 7}, 3: {2, 6, 8, 11, 13, 16, 19, 21}}\n",
"step 2\n",
"step 3\n",
" chosen region: 3\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 6 from 0 to 3\n",
" donor is losing {7} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 11 from 0 to 3\n",
" donor is losing {12} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 0\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 22 from 3 to 0\n",
" donor is losing {21} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 1\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 3 from 2 to 1\n",
" donor is losing {2} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 8 from 2 to 1\n",
" donor is losing {7} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 7 from 3 to 1\n",
" donor is losing {8, 2} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 1 from 0 to 1\n",
" donor is losing {2} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 4 from 2 to 1\n",
" donor is losing {3} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 9 from 2 to 1\n",
" donor is losing {4} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 2\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 24 from 3 to 2\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"n_regions_per_comp {0: 4}\n",
"comp_label 0\n",
"n_regions_in_comp 4\n",
"Regions in comp: {0, 1, 2, 3}\n",
"comp_adj.shape: (25, 25)\n",
"initial_clustering [0 0 1 2 2 0 0 1 1 2 0 3 1 1 1 0 1 1 1 1 0 1 1 1 1]\n",
"data [[ 1.116]\n",
" [-0.024]\n",
" [-0.733]\n",
" [ 0.369]\n",
" [ 0.118]\n",
" [ 0.344]\n",
" [ 0.428]\n",
" [-0.915]\n",
" [ 0.267]\n",
" [ 0.29 ]\n",
" [ 0.364]\n",
" [ 0.38 ]\n",
" [ 0.548]\n",
" [ 0.926]\n",
" [ 3.037]\n",
" [ 1.433]\n",
" [ 0.743]\n",
" [ 1.363]\n",
" [ 1.106]\n",
" [ 0.721]\n",
" [ 2.126]\n",
" [ 2.156]\n",
" [ 1.758]\n",
" [ 0.339]\n",
" [ 1.669]]\n",
"start with obj. val.: [[ 130.559]]\n",
"RN {0: {16, 2, 11, 21, 7}, 1: {1, 3, 6, 9, 11, 15, 20}, 2: {8, 2, 14}, 3: {16, 10, 12, 6}}\n",
"step 2\n",
"step 3\n",
" chosen region: 2\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 14 from 1 to 2\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 2 from 1 to 2\n",
" donor is losing {1} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 19 from 1 to 2\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 1 from 0 to 2\n",
" donor is losing {2} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 7 from 1 to 2\n",
" donor is losing {2, 6} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 8 from 1 to 2\n",
" donor is losing {9, 3} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 3\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 12 from 1 to 3\n",
" donor is losing {7} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 16 from 1 to 3\n",
" donor is losing {11, 15} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 17 from 1 to 3\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 7 from 2 to 3\n",
" donor is losing {12} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 13 from 1 to 3\n",
" donor is losing {8, 12, 14} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 6 from 0 to 3\n",
" donor is losing {7} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 1 from 2 to 3\n",
" donor is losing {0, 6} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 8 from 2 to 3\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 0\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 16 from 3 to 0\n",
" donor is losing {21, 15} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 17 from 3 to 0\n",
" donor is losing {22} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 1\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 20 from 0 to 1\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 13 from 3 to 1\n",
" donor is losing {18, 14} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"n_regions_per_comp {0: 4}\n",
"comp_label 0\n",
"n_regions_in_comp 4\n",
"Regions in comp: {0, 1, 2, 3}\n",
"comp_adj.shape: (25, 25)\n",
"initial_clustering [0 0 1 2 2 0 0 1 3 2 0 3 3 3 3 3 3 3 3 3 3 3 3 3 3]\n",
"data [[ 1.116]\n",
" [-0.024]\n",
" [-0.733]\n",
" [ 0.369]\n",
" [ 0.118]\n",
" [ 0.344]\n",
" [ 0.428]\n",
" [-0.915]\n",
" [ 0.267]\n",
" [ 0.29 ]\n",
" [ 0.364]\n",
" [ 0.38 ]\n",
" [ 0.548]\n",
" [ 0.926]\n",
" [ 3.037]\n",
" [ 1.433]\n",
" [ 0.743]\n",
" [ 1.363]\n",
" [ 1.106]\n",
" [ 0.721]\n",
" [ 2.126]\n",
" [ 2.156]\n",
" [ 1.758]\n",
" [ 0.339]\n",
" [ 1.669]]\n",
"start with obj. val.: [[ 102.458]]\n",
"RN {0: {2, 11, 15, 7}, 1: {8, 1, 3, 12, 6}, 2: {8, 2, 14}, 3: {9, 10, 3, 6, 7}}\n",
"step 2\n",
"step 3\n",
" chosen region: 3\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 0\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 15 from 3 to 0\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 11 from 3 to 0\n",
" donor is losing {10, 6} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 20 from 3 to 0\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 16 from 3 to 0\n",
" donor is losing {15} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 17 from 3 to 0\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 18 from 3 to 0\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 12 from 3 to 0\n",
" donor is losing {11} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 2\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 8 from 3 to 2\n",
" donor is losing {3, 7} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 13 from 3 to 2\n",
" donor is losing {8, 12} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 18 from 0 to 2\n",
" donor is losing {19, 23} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 12 from 0 to 2\n",
" donor is losing {13} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 11 from 0 to 2\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 6 from 0 to 2\n",
" donor is losing {7} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 1 from 0 to 2\n",
" donor is losing {2} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 1\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 1 from 2 to 1\n",
" donor is losing {0} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"n_regions_per_comp {0: 4}\n",
"comp_label 0\n",
"n_regions_in_comp 4\n",
"Regions in comp: {0, 1, 2, 3}\n",
"comp_adj.shape: (25, 25)\n",
"initial_clustering [0 0 1 2 2 0 0 1 3 2 3 3 1 3 2 3 3 3 3 2 3 3 3 3 3]\n",
"data [[ 1.116]\n",
" [-0.024]\n",
" [-0.733]\n",
" [ 0.369]\n",
" [ 0.118]\n",
" [ 0.344]\n",
" [ 0.428]\n",
" [-0.915]\n",
" [ 0.267]\n",
" [ 0.29 ]\n",
" [ 0.364]\n",
" [ 0.38 ]\n",
" [ 0.548]\n",
" [ 0.926]\n",
" [ 3.037]\n",
" [ 1.433]\n",
" [ 0.743]\n",
" [ 1.363]\n",
" [ 1.106]\n",
" [ 0.721]\n",
" [ 2.126]\n",
" [ 2.156]\n",
" [ 1.758]\n",
" [ 0.339]\n",
" [ 1.669]]\n",
"start with obj. val.: [[ 82.026]]\n",
"RN {0: {11, 2, 10, 7}, 1: {1, 3, 6, 8, 11, 13, 17}, 2: {8, 24, 2, 18, 13}, 3: {3, 5, 6, 7, 9, 12, 14, 19}}\n",
"step 2\n",
"step 3\n",
" chosen region: 3\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 2\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 8 from 3 to 2\n",
" donor is losing {9, 3, 7} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 13 from 3 to 2\n",
" donor is losing {8, 14} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 18 from 3 to 2\n",
" donor is losing {13} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 0\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 10 from 3 to 0\n",
" donor is losing {5} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 11 from 3 to 0\n",
" donor is losing {6} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 16 from 3 to 0\n",
" donor is losing {11} as neighbors\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 12 from 1 to 0\n",
" donor is losing {17, 11, 13} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 13 from 2 to 0\n",
" donor is losing {12} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 18 from 2 to 0\n",
" donor is losing {17, 23} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 19 from 2 to 0\n",
" donor is losing {24, 18} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 1\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 1 from 0 to 1\n",
" donor is losing {2} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 8 from 2 to 1\n",
" donor is losing {7} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 3 from 2 to 1\n",
" donor is losing {2} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 4 from 2 to 1\n",
" donor is losing {3} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"n_regions_per_comp {0: 4}\n",
"comp_label 0\n",
"n_regions_in_comp 4\n",
"Regions in comp: {0, 1, 2, 3}\n",
"comp_adj.shape: (25, 25)\n",
"initial_clustering [0 0 1 2 2 0 0 1 2 2 0 1 1 2 2 3 1 1 1 2 3 1 1 1 1]\n",
"data [[ 1.116]\n",
" [-0.024]\n",
" [-0.733]\n",
" [ 0.369]\n",
" [ 0.118]\n",
" [ 0.344]\n",
" [ 0.428]\n",
" [-0.915]\n",
" [ 0.267]\n",
" [ 0.29 ]\n",
" [ 0.364]\n",
" [ 0.38 ]\n",
" [ 0.548]\n",
" [ 0.926]\n",
" [ 3.037]\n",
" [ 1.433]\n",
" [ 0.743]\n",
" [ 1.363]\n",
" [ 1.106]\n",
" [ 0.721]\n",
" [ 2.126]\n",
" [ 2.156]\n",
" [ 1.758]\n",
" [ 0.339]\n",
" [ 1.669]]\n",
"start with obj. val.: [[ 90.099]]\n",
"RN {0: {2, 11, 15, 7}, 1: {1, 3, 6, 8, 10, 13, 15, 19, 20}, 2: {24, 2, 18, 12, 7}, 3: {16, 10, 21}}\n",
"step 2\n",
"step 3\n",
" chosen region: 1\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 0\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 2 from 1 to 0\n",
" donor is losing {1, 3} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 7 from 1 to 0\n",
" donor is losing {8, 2} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 11 from 1 to 0\n",
" donor is losing {10, 6} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 12 from 1 to 0\n",
" donor is losing {7} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 3 from 2 to 0\n",
" donor is losing {2} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 3\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 21 from 1 to 3\n",
" donor is losing {20} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 22 from 1 to 3\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 2\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 12 from 0 to 2\n",
" donor is losing {17, 13} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"n_regions_per_comp {0: 4}\n",
"comp_label 0\n",
"n_regions_in_comp 4\n",
"Regions in comp: {0, 1, 2, 3}\n",
"comp_adj.shape: (25, 25)\n",
"initial_clustering [0 0 1 2 2 0 0 1 2 2 0 1 1 2 2 0 1 1 2 2 0 1 3 3 3]\n",
"data [[ 1.116]\n",
" [-0.024]\n",
" [-0.733]\n",
" [ 0.369]\n",
" [ 0.118]\n",
" [ 0.344]\n",
" [ 0.428]\n",
" [-0.915]\n",
" [ 0.267]\n",
" [ 0.29 ]\n",
" [ 0.364]\n",
" [ 0.38 ]\n",
" [ 0.548]\n",
" [ 0.926]\n",
" [ 3.037]\n",
" [ 1.433]\n",
" [ 0.743]\n",
" [ 1.363]\n",
" [ 1.106]\n",
" [ 0.721]\n",
" [ 2.126]\n",
" [ 2.156]\n",
" [ 1.758]\n",
" [ 0.339]\n",
" [ 1.669]]\n",
"start with obj. val.: [[ 76.022]]\n",
"RN {0: {16, 2, 11, 21, 7}, 1: {1, 3, 6, 8, 10, 13, 15, 18, 20, 22}, 2: {2, 7, 12, 17, 23, 24}, 3: {17, 18, 19, 21}}\n",
"step 2\n",
"step 3\n",
" chosen region: 1\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 3\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 17 from 1 to 3\n",
" donor is losing {18} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 21 from 1 to 3\n",
" donor is losing {20, 22} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 19 from 2 to 3\n",
" donor is losing {24} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 14 from 2 to 3\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 20 from 0 to 3\n",
" donor is losing {21} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 0\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 16 from 1 to 0\n",
" donor is losing {21, 15} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 17 from 3 to 0\n",
" donor is losing {12} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 2\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 17 from 0 to 2\n",
" donor is losing {18, 12, 22} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"n_regions_per_comp {0: 4}\n",
"comp_label 0\n",
"n_regions_in_comp 4\n",
"Regions in comp: {0, 1, 2, 3}\n",
"comp_adj.shape: (25, 25)\n",
"initial_clustering [0 0 1 2 2 0 0 1 2 2 0 0 1 2 2 0 0 2 2 2 0 0 2 3 3]\n",
"data [[ 1.116]\n",
" [-0.024]\n",
" [-0.733]\n",
" [ 0.369]\n",
" [ 0.118]\n",
" [ 0.344]\n",
" [ 0.428]\n",
" [-0.915]\n",
" [ 0.267]\n",
" [ 0.29 ]\n",
" [ 0.364]\n",
" [ 0.38 ]\n",
" [ 0.548]\n",
" [ 0.926]\n",
" [ 3.037]\n",
" [ 1.433]\n",
" [ 0.743]\n",
" [ 1.363]\n",
" [ 1.106]\n",
" [ 0.721]\n",
" [ 2.126]\n",
" [ 2.156]\n",
" [ 1.758]\n",
" [ 0.339]\n",
" [ 1.669]]\n",
"start with obj. val.: [[ 88.707]]\n",
"RN {0: {17, 2, 12, 22, 7}, 1: {1, 3, 6, 8, 11, 13, 17}, 2: {2, 7, 12, 16, 21, 23, 24}, 3: {18, 19, 22}}\n",
"step 2\n",
"step 3\n",
" chosen region: 3\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 22 from 2 to 3\n",
" donor is losing {21} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 19 from 2 to 3\n",
" donor is losing {24} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 17 from 2 to 3\n",
" donor is losing {16, 22} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 16 from 0 to 3\n",
" donor is losing {17} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 21 from 0 to 3\n",
" donor is losing {22} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 18 from 2 to 3\n",
" donor is losing {17, 23} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 13 from 2 to 3\n",
" donor is losing {18, 12} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 20 from 0 to 3\n",
" donor is losing {21} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 15 from 0 to 3\n",
" donor is losing {20} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 2\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 13 from 3 to 2\n",
" donor is losing {8} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 19 from 3 to 2\n",
" donor is losing {14} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 0\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 16 from 3 to 0\n",
" donor is losing {11} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 12 from 1 to 0\n",
" donor is losing {17, 11, 13} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 13 from 2 to 0\n",
" donor is losing {12} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 8 from 2 to 0\n",
" donor is losing {7} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 3 from 2 to 0\n",
" donor is losing {2} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 1\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 3 from 0 to 1\n",
" donor is losing {4} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 8 from 0 to 1\n",
" donor is losing {9, 3} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 1 from 0 to 1\n",
" donor is losing {2} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 4 from 2 to 1\n",
" donor is losing {3} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 9 from 2 to 1\n",
" donor is losing {8, 4} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"n_regions_per_comp {0: 4}\n",
"comp_label 0\n",
"n_regions_in_comp 4\n",
"Regions in comp: {0, 1, 2, 3}\n",
"comp_adj.shape: (25, 25)\n",
"initial_clustering [0 0 1 2 2 0 0 1 2 2 0 1 1 2 2 1 1 1 2 2 1 1 3 3 3]\n",
"data [[ 1.116]\n",
" [-0.024]\n",
" [-0.733]\n",
" [ 0.369]\n",
" [ 0.118]\n",
" [ 0.344]\n",
" [ 0.428]\n",
" [-0.915]\n",
" [ 0.267]\n",
" [ 0.29 ]\n",
" [ 0.364]\n",
" [ 0.38 ]\n",
" [ 0.548]\n",
" [ 0.926]\n",
" [ 3.037]\n",
" [ 1.433]\n",
" [ 0.743]\n",
" [ 1.363]\n",
" [ 1.106]\n",
" [ 0.721]\n",
" [ 2.126]\n",
" [ 2.156]\n",
" [ 1.758]\n",
" [ 0.339]\n",
" [ 1.669]]\n",
"start with obj. val.: [[ 82.018]]\n",
"RN {0: {2, 11, 15, 7}, 1: {1, 3, 6, 8, 10, 13, 18, 22}, 2: {2, 7, 12, 17, 23, 24}, 3: {17, 18, 19, 21}}\n",
"step 2\n",
"step 3\n",
" chosen region: 2\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 17 from 1 to 2\n",
" donor is losing {18} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 1\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 3\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 19 from 2 to 3\n",
" donor is losing {24} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 14 from 2 to 3\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 21 from 1 to 3\n",
" donor is losing {22} as neighbors\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 20 from 1 to 3\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 15 from 1 to 3\n",
" donor is losing {20} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 0\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 15 from 3 to 0\n",
" donor is losing {10} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 16 from 1 to 0\n",
" donor is losing {21, 15} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"275 ms ± 58.8 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
]
}
],
"source": [
"%timeit AZP().fit_from_scipy_sparse_matrix(adj=adj5, n_regions=n_regions, data=attr5)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### ... with `clusterpy`"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 3]\n",
"initial O.F: 6.924007100000001\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 2, 3, 3, 3, 3, 3, 0, 0, 0, 3, 3]\n",
"FINAL O.F.: 4.7550974358974365\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n",
"initial O.F: 8.330504952380952\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 2, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0]\n",
"FINAL O.F.: 8.038384416666666\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [1, 1, 2, 3, 3, 1, 1, 2, 3, 3, 1, 1, 1, 3, 3, 0, 1, 3, 3, 3, 0, 0, 0, 3, 3]\n",
"initial O.F: 8.564110806818181\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 1, 2, 3, 3, 1, 1, 2, 3, 3, 1, 1, 1, 3, 3, 0, 1, 0, 3, 3, 0, 0, 0, 3, 3]\n",
"FINAL O.F.: 8.559924275\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [2, 3, 3, 0, 0, 3, 3, 3, 0, 0, 3, 3, 0, 0, 0, 1, 3, 1, 0, 0, 1, 1, 1, 0, 0]\n",
"initial O.F: 10.332075220454545\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0]\n",
"FINAL O.F.: 7.392555333333332\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [1, 1, 3, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"initial O.F: 4.180918119658121\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 1, 3, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"FINAL O.F.: 4.18091811965812\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [3, 3, 2, 1, 1, 3, 3, 2, 1, 1, 3, 3, 3, 1, 1, 0, 3, 1, 1, 1, 0, 0, 1, 1, 1]\n",
"initial O.F: 9.179810791666668\n",
"Performing local search\n",
"FINAL SOLUTION: [3, 3, 2, 1, 1, 3, 3, 2, 1, 1, 3, 3, 3, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1]\n",
"FINAL O.F.: 8.518362600732603\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [3, 3, 2, 0, 0, 3, 3, 2, 0, 0, 3, 3, 3, 3, 3, 1, 3, 1, 3, 3, 1, 1, 1, 3, 3]\n",
"initial O.F: 8.2329683\n",
"Performing local search\n",
"FINAL SOLUTION: [3, 2, 2, 0, 0, 3, 3, 2, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 3, 3]\n",
"FINAL O.F.: 7.836795733333334\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 0, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 2, 3, 0, 0, 0, 0, 3, 3, 3, 0, 0]\n",
"initial O.F: 4.829871011904762\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 2, 3, 0, 3, 0, 0, 3, 3, 3, 0, 0]\n",
"FINAL O.F.: 4.072216895238095\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [2, 0, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"initial O.F: 6.091108516666668\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 0, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"FINAL O.F.: 6.091108516666668\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [2, 2, 3, 0, 0, 2, 2, 3, 0, 0, 2, 2, 2, 0, 0, 1, 2, 0, 0, 0, 1, 1, 1, 0, 0]\n",
"initial O.F: 8.564110806818183\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 2, 3, 0, 0, 2, 2, 3, 0, 0, 2, 2, 2, 0, 0, 1, 2, 1, 0, 0, 1, 1, 1, 0, 0]\n",
"FINAL O.F.: 8.559924275000002\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [3, 3, 1, 0, 0, 3, 3, 1, 0, 0, 3, 3, 3, 0, 0, 2, 3, 0, 0, 0, 2, 2, 2, 0, 0]\n",
"initial O.F: 8.564110806818183\n",
"Performing local search\n",
"FINAL SOLUTION: [3, 3, 1, 0, 0, 3, 3, 1, 0, 0, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, 0]\n",
"FINAL O.F.: 8.518362600732603\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 0, 3, 2, 2, 0, 0, 3, 2, 2, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"initial O.F: 6.35992848888889\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 3, 2, 2, 0, 0, 3, 2, 2, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"FINAL O.F.: 6.359928488888889\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 3, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"initial O.F: 4.180918119658121\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 3, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"FINAL O.F.: 4.18091811965812\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 1, 3, 1, 3, 3, 1, 1, 1, 0, 2]\n",
"initial O.F: 12.150364411111113\n",
"Performing local search\n",
"FINAL SOLUTION: [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0, 0, 1, 0, 0, 0, 0, 1, 1, 1, 0, 2]\n",
"FINAL O.F.: 8.315367233516485\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 2, 2, 0, 0, 2, 2, 2, 0, 0, 0, 1, 3, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"initial O.F: 5.578939308333333\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 2, 2, 2, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 3, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"FINAL O.F.: 4.985169288888889\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1]\n",
"initial O.F: 13.835618772727273\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0]\n",
"FINAL O.F.: 6.463207857142859\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [1, 1, 2, 3, 3, 1, 1, 2, 3, 3, 1, 1, 1, 3, 3, 0, 1, 3, 3, 3, 0, 0, 0, 3, 3]\n",
"initial O.F: 8.564110806818181\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 1, 2, 3, 3, 1, 1, 2, 3, 3, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 0, 0, 0, 3, 3]\n",
"FINAL O.F.: 8.518362600732603\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [3, 3, 0, 0, 0, 3, 3, 0, 0, 0, 3, 3, 3, 3, 1, 2, 3, 2, 3, 3, 2, 2, 2, 3, 3]\n",
"initial O.F: 4.583183825641026\n",
"Performing local search\n",
"FINAL SOLUTION: [3, 0, 0, 0, 0, 3, 3, 0, 0, 0, 3, 3, 3, 3, 1, 2, 3, 2, 3, 3, 2, 2, 2, 3, 3]\n",
"FINAL O.F.: 4.072216895238096\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 0, 1, 2, 2, 0, 0, 1, 2, 2, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"initial O.F: 7.391310000000001\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 1, 1, 2, 2, 0, 0, 1, 2, 2, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"FINAL O.F.: 6.767606784313725\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [2, 2, 3, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2]\n",
"initial O.F: 8.779918285714286\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 3, 3, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2]\n",
"FINAL O.F.: 8.373544416666668\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [2, 0, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 3, 2, 3, 2, 2, 3, 3, 3, 2, 1]\n",
"initial O.F: 8.223749466666664\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 0, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 3, 2, 3, 2, 2, 3, 3, 3, 2, 1]\n",
"FINAL O.F.: 8.223749466666664\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 3, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"initial O.F: 4.180918119658121\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 3, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"FINAL O.F.: 4.18091811965812\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [2, 2, 0, 0, 0, 2, 2, 0, 0, 0, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 3, 3]\n",
"initial O.F: 7.770957833333333\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 0, 0, 0, 0, 2, 2, 0, 0, 0, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 1, 1, 1, 3, 3]\n",
"FINAL O.F.: 7.068112095238096\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n",
"initial O.F: 8.330504952380952\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 2, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n",
"FINAL O.F.: 8.038384416666666\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 0, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 1, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"initial O.F: 4.180918119658121\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 1, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"FINAL O.F.: 4.18091811965812\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [1, 1, 2, 2, 2, 1, 1, 2, 2, 2, 1, 1, 1, 0, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"initial O.F: 5.578939308333333\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 2, 2, 2, 2, 1, 1, 2, 2, 2, 1, 1, 1, 1, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"FINAL O.F.: 5.1930571924603175\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 2, 3, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1]\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"initial O.F: 6.091108516666668\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 2, 3, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"FINAL O.F.: 6.091108516666668\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 3]\n",
"initial O.F: 6.55880611965812\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 3, 1]\n",
"FINAL O.F.: 4.883597230769231\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [3, 3, 2, 1, 1, 3, 3, 2, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0]\n",
"initial O.F: 11.065758000000002\n",
"Performing local search\n",
"FINAL SOLUTION: [3, 2, 2, 1, 1, 3, 3, 2, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 0]\n",
"FINAL O.F.: 10.275641607843138\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 0, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n",
"initial O.F: 8.330504952380952\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 3, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n",
"FINAL O.F.: 8.038384416666666\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 3, 2, 0, 1, 1, 1, 2, 2, 2, 1, 1]\n",
"initial O.F: 6.421703250000001\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 2, 1, 1, 1, 1, 2, 2, 2, 1, 1]\n",
"FINAL O.F.: 4.82892151923077\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 3, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"initial O.F: 8.258754000000001\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 3, 2, 0, 0, 0, 3, 2, 0, 0, 0, 3, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"FINAL O.F.: 7.775502000000001\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 3, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"initial O.F: 4.180918119658121\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 3, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"FINAL O.F.: 4.18091811965812\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 3, 1, 3, 3, 3, 3, 1, 3, 3, 3, 3, 3, 3, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"initial O.F: 6.091108516666668\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 3, 1, 3, 3, 3, 3, 1, 3, 3, 3, 3, 3, 3, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"FINAL O.F.: 6.091108516666668\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 2, 1, 1, 1, 1, 2]\n",
"initial O.F: 8.772730999999999\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]\n",
"FINAL O.F.: 8.038384416666666\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [2, 1, 1, 3, 3, 2, 2, 1, 3, 3, 2, 2, 2, 3, 3, 0, 2, 3, 3, 3, 0, 0, 0, 3, 3]\n",
"initial O.F: 8.691915312770563\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 2, 1, 3, 3, 2, 2, 1, 3, 3, 2, 2, 2, 3, 3, 0, 2, 0, 3, 3, 0, 0, 0, 3, 3]\n",
"FINAL O.F.: 8.559924275\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [2, 0, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"initial O.F: 6.091108516666668\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 0, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"FINAL O.F.: 6.091108516666668\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 1, 1, 0, 0, 2, 1, 1, 0, 0, 1, 1, 1, 3, 0, 3, 1, 1, 3, 3, 3, 1, 1]\n",
"initial O.F: 8.658478774025976\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 2, 1, 1, 0, 0, 2, 1, 1, 0, 0, 0, 1, 1, 3, 0, 3, 1, 1, 3, 3, 3, 1, 1]\n",
"FINAL O.F.: 8.559924275000002\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 0, 3, 2, 2, 0, 0, 3, 2, 2, 0, 0, 0, 2, 2, 1, 0, 2, 2, 2, 1, 1, 1, 2, 2]\n",
"initial O.F: 8.564110806818181\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 3, 2, 2, 0, 0, 3, 2, 2, 0, 0, 0, 2, 2, 1, 0, 1, 2, 2, 1, 1, 1, 2, 2]\n",
"FINAL O.F.: 8.559924275000002\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 3, 1, 3, 3, 3, 3, 1, 3, 3, 3, 3, 3, 3, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"initial O.F: 6.091108516666668\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 3, 1, 3, 3, 3, 3, 1, 3, 3, 3, 3, 3, 3, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"FINAL O.F.: 6.091108516666668\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0]\n",
"initial O.F: 8.330504952380952\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 1, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0]\n",
"FINAL O.F.: 8.038384416666666\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [2, 0, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 3, 1, 2, 1, 2, 2, 1, 1, 1, 2, 2]\n",
"initial O.F: 3.5663934666666677\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 2, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 3, 1, 2, 1, 2, 2, 1, 1, 1, 2, 2]\n",
"FINAL O.F.: 3.515655270588235\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 2, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 3, 0, 3, 0, 0, 3, 3, 3, 0, 0]\n",
"initial O.F: 8.692706564705883\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 2, 1, 0, 0, 0, 2, 1, 0, 0, 0, 0, 0, 0, 0, 3, 0, 3, 0, 0, 3, 3, 3, 0, 0]\n",
"FINAL O.F.: 8.6840897375\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 2, 3, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"initial O.F: 8.967508285714288\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 3, 2, 2, 0, 0, 3, 2, 2, 0, 0, 0, 2, 1, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"FINAL O.F.: 7.458282232142858\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [2, 2, 3, 1, 1, 2, 2, 3, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0]\n",
"initial O.F: 11.065758\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 3, 3, 1, 1, 2, 2, 3, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0]\n",
"FINAL O.F.: 10.275641607843136\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 3, 1, 3, 3, 3, 3, 1, 3, 3, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]\n",
"initial O.F: 8.967508285714286\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 1, 3, 3, 0, 0, 1, 3, 3, 0, 0, 0, 3, 2, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3]\n",
"FINAL O.F.: 7.458282232142858\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3]\n",
"initial O.F: 4.18091811965812\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3]\n",
"FINAL O.F.: 4.18091811965812\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [1, 0, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"initial O.F: 8.967508285714288\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 1, 3, 0, 0, 1, 1, 3, 0, 0, 1, 1, 1, 0, 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"FINAL O.F.: 7.458282232142858\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3]\n",
"initial O.F: 6.55880611965812\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 3, 0]\n",
"FINAL O.F.: 4.883597230769231\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 3, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1]\n",
"initial O.F: 3.5156552705882347\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 3, 0, 1, 0, 1, 1, 0, 0, 0, 1, 1]\n",
"FINAL O.F.: 3.5156552705882356\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 3]\n",
"initial O.F: 6.55880611965812\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 3, 1]\n",
"FINAL O.F.: 4.883597230769231\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 1, 1, 2, 2, 0, 0, 1, 2, 2, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"initial O.F: 6.767606784313725\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 1, 1, 2, 2, 0, 0, 1, 2, 2, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"FINAL O.F.: 6.767606784313726\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 3, 2, 3, 1, 3, 3, 3, 3, 3, 3, 3, 3]\n",
"initial O.F: 5.578939308333333\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 2, 3, 1, 3, 3, 3, 3, 3, 3, 3, 3]\n",
"FINAL O.F.: 4.985169288888889\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [3, 3, 0, 0, 0, 3, 3, 0, 0, 0, 3, 3, 3, 2, 1, 2, 3, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"initial O.F: 5.578939308333333\n",
"Performing local search\n",
"FINAL SOLUTION: [3, 0, 0, 0, 0, 3, 3, 0, 3, 3, 3, 3, 3, 3, 1, 2, 3, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"FINAL O.F.: 4.985169288888889\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 0, 1, 2, 2, 0, 0, 1, 2, 2, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"initial O.F: 7.391310000000001\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 1, 1, 2, 2, 0, 0, 1, 2, 2, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"FINAL O.F.: 6.767606784313724\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [2, 0, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 3, 1, 2, 1, 2, 2, 1, 1, 1, 2, 2]\n",
"initial O.F: 3.5663934666666677\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 2, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 3, 1, 2, 1, 2, 2, 1, 1, 1, 2, 2]\n",
"FINAL O.F.: 3.515655270588236\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 3, 3, 0, 0, 2, 3, 3, 0, 0, 0, 3, 3, 1, 0, 3, 3, 3, 1, 1, 1, 3, 3]\n",
"initial O.F: 8.564110806818181\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 2, 3, 3, 0, 0, 2, 3, 3, 0, 0, 0, 3, 3, 1, 0, 1, 3, 3, 1, 1, 1, 3, 3]\n",
"FINAL O.F.: 8.559924275\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [3, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1]\n",
"initial O.F: 13.046102571428573\n",
"Performing local search\n",
"FINAL SOLUTION: [3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 2, 0, 0, 1, 0, 0, 0, 1, 1]\n",
"FINAL O.F.: 6.989428618589742\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [2, 0, 3, 1, 1, 2, 2, 3, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"initial O.F: 10.142978944444444\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 0, 3, 1, 1, 2, 0, 3, 1, 1, 2, 0, 0, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"FINAL O.F.: 8.42411142857143\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 0, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2]\n",
"initial O.F: 8.330504952380952\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 3, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2]\n",
"FINAL O.F.: 8.038384416666666\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [3, 3, 2, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 1, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"initial O.F: 4.18091811965812\n",
"Performing local search\n",
"FINAL SOLUTION: [3, 3, 2, 3, 3, 3, 3, 2, 3, 3, 3, 3, 3, 3, 1, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"FINAL O.F.: 4.18091811965812\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [1, 1, 2, 0, 0, 1, 1, 2, 0, 0, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"initial O.F: 7.391310000000001\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 2, 2, 0, 0, 1, 1, 2, 0, 0, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"FINAL O.F.: 6.767606784313724\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 2, 3, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"initial O.F: 8.967508285714286\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 3, 2, 2, 0, 0, 3, 2, 2, 0, 0, 0, 2, 1, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"FINAL O.F.: 7.458282232142858\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 3, 2, 3, 2, 2, 3, 3, 3, 0, 2]\n",
"initial O.F: 6.989508411111111\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 1, 0, 0, 0, 0, 0, 3, 3, 3, 0, 0]\n",
"FINAL O.F.: 4.755097435897436\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 3, 0, 0, 3, 3, 3, 1, 0]\n",
"initial O.F: 9.11575103529412\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 2, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 3, 0, 1, 1, 0, 3, 3, 3, 1, 1]\n",
"FINAL O.F.: 8.694065380952381\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 0, 0, 2, 2, 0, 0, 0, 2, 2, 0, 0, 0, 2, 1, 3, 0, 3, 2, 2, 3, 3, 3, 2, 2]\n",
"initial O.F: 6.161953700000001\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 3, 2, 2, 2, 2, 3, 3, 3, 2, 2]\n",
"FINAL O.F.: 4.82892151923077\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [3, 3, 0, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 1, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3]\n",
"initial O.F: 8.779918285714286\n",
"Performing local search\n",
"FINAL SOLUTION: [3, 0, 0, 3, 3, 3, 3, 0, 3, 3, 3, 3, 3, 3, 1, 3, 3, 3, 3, 3, 3, 3, 3, 2, 3]\n",
"FINAL O.F.: 8.373544416666668\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 2, 3, 1, 3, 3, 3, 3, 3, 3, 3, 3]\n",
"initial O.F: 4.18091811965812\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 2, 3, 1, 3, 3, 3, 3, 3, 3, 3, 3]\n",
"FINAL O.F.: 4.18091811965812\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [1, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 3, 1, 2, 1, 1, 2, 2, 2, 1, 1]\n",
"initial O.F: 9.120179250000001\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 3, 1, 2, 1, 1, 2, 2, 2, 1, 1]\n",
"FINAL O.F.: 8.979761181372549\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3]\n",
"initial O.F: 4.18091811965812\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3]\n",
"FINAL O.F.: 4.180918119658119\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"initial O.F: 6.254397246031746\n",
"Performing local search\n",
"FINAL SOLUTION: [3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"FINAL O.F.: 5.916415212121213\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [2, 2, 3, 0, 0, 2, 2, 3, 0, 0, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"initial O.F: 7.391310000000001\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 3, 3, 0, 0, 2, 2, 3, 0, 0, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"FINAL O.F.: 6.767606784313724\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 2, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3]\n",
"initial O.F: 4.18091811965812\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 2, 3, 0, 3, 3, 3, 3, 3, 3, 3, 3]\n",
"FINAL O.F.: 4.18091811965812\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"initial O.F: 4.180918119658121\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 3, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"FINAL O.F.: 4.18091811965812\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 1, 3, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"initial O.F: 8.967508285714286\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 3, 1, 1, 0, 0, 3, 1, 1, 0, 0, 0, 1, 2, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1]\n",
"FINAL O.F.: 7.458282232142858\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [2, 2, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 3, 2, 1, 2, 2, 1, 1, 1, 2, 2]\n",
"initial O.F: 9.120179250000001\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 0, 0, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 3, 2, 1, 2, 2, 1, 1, 1, 2, 2]\n",
"FINAL O.F.: 8.97976118137255\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 2, 2, 0, 0, 2, 2, 2, 0, 0, 0, 3, 3, 1, 0, 3, 3, 3, 1, 1, 3, 3, 3]\n",
"initial O.F: 7.500004083333334\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 2, 2, 2, 2, 0, 0, 2, 0, 0, 0, 0, 0, 0, 3, 1, 0, 3, 3, 3, 1, 1, 1, 3, 3]\n",
"FINAL O.F.: 6.783928649999999\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 3, 2]\n",
"initial O.F: 6.622525708333333\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 0, 0, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2, 2, 2, 2, 2, 2, 3, 2]\n",
"FINAL O.F.: 5.6878484\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [3, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0]\n",
"initial O.F: 13.252189238095237\n",
"Performing local search\n",
"FINAL SOLUTION: [3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 2, 0]\n",
"FINAL O.F.: 6.972913576923076\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]\n",
"initial O.F: 8.779918285714286\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 2, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0]\n",
"FINAL O.F.: 8.373544416666668\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 4\n",
"Constructing regions\n",
"initial Solution: [0, 0, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 1, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"initial O.F: 4.180918119658121\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 1, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2]\n",
"FINAL O.F.: 4.18091811965812\n",
"Done\n",
"Adding variables\n",
"Done\n",
"31.2 ms ± 5.6 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n"
]
}
],
"source": [
"%timeit layer5.cluster(method, ['VARIABLE0'], n_regions)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## clustering into 6 regions (problem 5 in [Duque et al. (2011)](https://www.google.at/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&cad=rja&uact=8&ved=0ahUKEwiK2efWuprWAhVFvBQKHRouACIQFgg9MAE&url=http%3A%2F%2Fonlinelibrary.wiley.com%2Fdoi%2F10.1111%2Fj.1538-4632.2010.00810.x%2Fabstract&usg=AFQjCNF--NAHN98PKuR-gVNQPTk34XDdnA))"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"n_regions = 6"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### ... with `region`"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"n_regions_per_comp {0: 6}\n",
"comp_label 0\n",
"n_regions_in_comp 6\n",
"Regions in comp: {0, 1, 2, 3, 4, 5}\n",
"comp_adj.shape: (25, 25)\n",
"initial_clustering [0 0 1 2 2 3 3 1 4 4 3 3 1 4 4 3 3 1 4 4 3 3 5 5 5]\n",
"data [[ 1.116]\n",
" [-0.024]\n",
" [-0.733]\n",
" [ 0.369]\n",
" [ 0.118]\n",
" [ 0.344]\n",
" [ 0.428]\n",
" [-0.915]\n",
" [ 0.267]\n",
" [ 0.29 ]\n",
" [ 0.364]\n",
" [ 0.38 ]\n",
" [ 0.548]\n",
" [ 0.926]\n",
" [ 3.037]\n",
" [ 1.433]\n",
" [ 0.743]\n",
" [ 1.363]\n",
" [ 1.106]\n",
" [ 0.721]\n",
" [ 2.126]\n",
" [ 2.156]\n",
" [ 1.758]\n",
" [ 0.339]\n",
" [ 1.669]]\n",
"start with obj. val.: [[ 53.815]]\n",
"RN {0: {2, 5, 6}, 1: {1, 3, 6, 8, 11, 13, 16, 18, 22}, 2: {8, 9, 2}, 3: {0, 1, 7, 12, 17, 22}, 4: {3, 4, 7, 12, 17, 23, 24}, 5: {17, 18, 19, 21}}\n",
"step 2\n",
"step 3\n",
" chosen region: 5\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 19 from 4 to 5\n",
" donor is losing {24} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 14 from 4 to 5\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 17 from 1 to 5\n",
" donor is losing {16, 18, 22} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 21 from 3 to 5\n",
" donor is losing {22} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 20 from 3 to 5\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 1\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 17 from 5 to 1\n",
" donor is losing {12} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 0\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 6 from 3 to 0\n",
" donor is losing {1, 7} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 11 from 3 to 0\n",
" donor is losing {12} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 5 from 3 to 0\n",
" donor is losing {0, 6} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 10 from 3 to 0\n",
" donor is losing {5} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 4\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 17 from 1 to 4\n",
" donor is losing {16, 18, 22} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 12 from 1 to 4\n",
" donor is losing {17, 11, 13} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 2\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 9 from 4 to 2\n",
" donor is losing {4} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 8 from 4 to 2\n",
" donor is losing {9, 3} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 3\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 20 from 5 to 3\n",
" donor is losing {15} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 21 from 5 to 3\n",
" donor is losing {16, 20} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 22 from 5 to 3\n",
" donor is losing {17, 21} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"n_regions_per_comp {0: 6}\n",
"comp_label 0\n",
"n_regions_in_comp 6\n",
"Regions in comp: {0, 1, 2, 3, 4, 5}\n",
"comp_adj.shape: (25, 25)\n",
"initial_clustering [0 0 1 2 2 3 4 1 5 2 3 3 1 5 2 3 3 1 5 2 3 3 1 1 1]\n",
"data [[ 1.116]\n",
" [-0.024]\n",
" [-0.733]\n",
" [ 0.369]\n",
" [ 0.118]\n",
" [ 0.344]\n",
" [ 0.428]\n",
" [-0.915]\n",
" [ 0.267]\n",
" [ 0.29 ]\n",
" [ 0.364]\n",
" [ 0.38 ]\n",
" [ 0.548]\n",
" [ 0.926]\n",
" [ 3.037]\n",
" [ 1.433]\n",
" [ 0.743]\n",
" [ 1.363]\n",
" [ 1.106]\n",
" [ 0.721]\n",
" [ 2.126]\n",
" [ 2.156]\n",
" [ 1.758]\n",
" [ 0.339]\n",
" [ 1.669]]\n",
"start with obj. val.: [[ 63.076]]\n",
"RN {0: {2, 5, 6}, 1: {1, 3, 6, 8, 11, 13, 16, 18, 19, 21}, 2: {8, 24, 2, 18, 13}, 3: {0, 17, 12, 6, 22}, 4: {1, 11, 5, 7}, 5: {3, 7, 9, 12, 14, 17, 19, 23}}\n",
"step 2\n",
"step 3\n",
" chosen region: 3\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 2\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 2 from 1 to 2\n",
" donor is losing {1, 3} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 7 from 1 to 2\n",
" donor is losing {8, 2, 6} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 1\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 11 from 3 to 1\n",
" donor is losing {12} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 16 from 3 to 1\n",
" donor is losing {17} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 19 from 2 to 1\n",
" donor is losing {24, 18} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 0\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 5 from 3 to 0\n",
" donor is losing {0, 6} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 10 from 3 to 0\n",
" donor is losing {11, 5} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 11 from 1 to 0\n",
" donor is losing {10, 6} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 16 from 1 to 0\n",
" donor is losing {15} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 12 from 1 to 0\n",
" donor is losing {11, 13, 7} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 4\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 1 from 0 to 4\n",
" donor is losing {2} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 0 from 0 to 4\n",
" donor is losing {1} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 7 from 2 to 4\n",
" donor is losing {12, 6} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 2 from 2 to 4\n",
" donor is losing {1, 7} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 5\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 19 from 1 to 5\n",
" donor is losing {14} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 3 from 2 to 5\n",
" donor is losing {2} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 4 from 2 to 5\n",
" donor is losing {3} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 9 from 2 to 5\n",
" donor is losing {8, 4, 14} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"n_regions_per_comp {0: 6}\n",
"comp_label 0\n",
"n_regions_in_comp 6\n",
"Regions in comp: {0, 1, 2, 3, 4, 5}\n",
"comp_adj.shape: (25, 25)\n",
"initial_clustering [0 0 1 2 2 0 0 1 3 3 0 4 5 3 3 4 4 5 3 3 4 4 5 5 5]\n",
"data [[ 1.116]\n",
" [-0.024]\n",
" [-0.733]\n",
" [ 0.369]\n",
" [ 0.118]\n",
" [ 0.344]\n",
" [ 0.428]\n",
" [-0.915]\n",
" [ 0.267]\n",
" [ 0.29 ]\n",
" [ 0.364]\n",
" [ 0.38 ]\n",
" [ 0.548]\n",
" [ 0.926]\n",
" [ 3.037]\n",
" [ 1.433]\n",
" [ 0.743]\n",
" [ 1.363]\n",
" [ 1.106]\n",
" [ 0.721]\n",
" [ 2.126]\n",
" [ 2.156]\n",
" [ 1.758]\n",
" [ 0.339]\n",
" [ 1.669]]\n",
"start with obj. val.: [[ 39.452]]\n",
"RN {0: {2, 11, 15, 7}, 1: {8, 1, 3, 12, 6}, 2: {8, 9, 2}, 3: {3, 4, 7, 12, 17, 23, 24}, 4: {17, 10, 12, 6, 22}, 5: {7, 11, 13, 16, 18, 19, 21}}\n",
"step 2\n",
"step 3\n",
" chosen region: 3\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 5\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 13 from 3 to 5\n",
" donor is losing {12} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 11 from 4 to 5\n",
" donor is losing {12, 6} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 18 from 3 to 5\n",
" donor is losing {17, 23} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 2\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 8 from 3 to 2\n",
" donor is losing {3, 7} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 13 from 5 to 2\n",
" donor is losing {8, 14} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 9 from 3 to 2\n",
" donor is losing {8, 4} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 4\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 22 from 5 to 4\n",
" donor is losing {21} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 0\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 11 from 5 to 0\n",
" donor is losing {10, 6} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 16 from 4 to 0\n",
" donor is losing {11} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 12 from 5 to 0\n",
" donor is losing {11, 7} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 1\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 1 from 0 to 1\n",
" donor is losing {2} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"n_regions_per_comp {0: 6}\n",
"comp_label 0\n",
"n_regions_in_comp 6\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Regions in comp: {0, 1, 2, 3, 4, 5}\n",
"comp_adj.shape: (25, 25)\n",
"initial_clustering [0 0 1 2 2 3 0 1 2 2 3 3 1 2 2 3 3 3 3 2 4 3 5 5 5]\n",
"data [[ 1.116]\n",
" [-0.024]\n",
" [-0.733]\n",
" [ 0.369]\n",
" [ 0.118]\n",
" [ 0.344]\n",
" [ 0.428]\n",
" [-0.915]\n",
" [ 0.267]\n",
" [ 0.29 ]\n",
" [ 0.364]\n",
" [ 0.38 ]\n",
" [ 0.548]\n",
" [ 0.926]\n",
" [ 3.037]\n",
" [ 1.433]\n",
" [ 0.743]\n",
" [ 1.363]\n",
" [ 1.106]\n",
" [ 0.721]\n",
" [ 2.126]\n",
" [ 2.156]\n",
" [ 1.758]\n",
" [ 0.339]\n",
" [ 1.669]]\n",
"start with obj. val.: [[ 50.397]]\n",
"RN {0: {2, 11, 5, 7}, 1: {1, 3, 6, 8, 11, 13, 17}, 2: {24, 2, 18, 12, 7}, 3: {0, 6, 12, 13, 19, 20, 22, 23}, 4: {21, 15}, 5: {17, 18, 19, 21}}\n",
"step 2\n",
"step 3\n",
" chosen region: 5\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 21 from 3 to 5\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 18 from 3 to 5\n",
" donor is losing {19, 13, 23} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 17 from 3 to 5\n",
" donor is losing {18, 22} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 13 from 2 to 5\n",
" donor is losing {12} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 4\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 15 from 3 to 4\n",
" donor is losing {20} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 21 from 5 to 4\n",
" donor is losing {20} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 22 from 5 to 4\n",
" donor is losing {21} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 17 from 5 to 4\n",
" donor is losing {16} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 3\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 6 from 0 to 3\n",
" donor is losing {11, 7} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 12 from 1 to 3\n",
" donor is losing {17, 11, 13} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 2\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 0\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 1\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 3 from 2 to 1\n",
" donor is losing {2} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 4 from 2 to 1\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 8 from 2 to 1\n",
" donor is losing {3, 7} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 9 from 2 to 1\n",
" donor is losing {8, 4} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"n_regions_per_comp {0: 6}\n",
"comp_label 0\n",
"n_regions_in_comp 6\n",
"Regions in comp: {0, 1, 2, 3, 4, 5}\n",
"comp_adj.shape: (25, 25)\n",
"initial_clustering [0 1 2 3 3 1 1 2 4 3 1 1 2 3 3 1 1 3 3 3 1 1 3 5 5]\n",
"data [[ 1.116]\n",
" [-0.024]\n",
" [-0.733]\n",
" [ 0.369]\n",
" [ 0.118]\n",
" [ 0.344]\n",
" [ 0.428]\n",
" [-0.915]\n",
" [ 0.267]\n",
" [ 0.29 ]\n",
" [ 0.364]\n",
" [ 0.38 ]\n",
" [ 0.548]\n",
" [ 0.926]\n",
" [ 3.037]\n",
" [ 1.433]\n",
" [ 0.743]\n",
" [ 1.363]\n",
" [ 1.106]\n",
" [ 0.721]\n",
" [ 2.126]\n",
" [ 2.156]\n",
" [ 1.758]\n",
" [ 0.339]\n",
" [ 1.669]]\n",
"start with obj. val.: [[ 74.296]]\n",
"RN {0: {1, 5}, 1: {0, 2, 7, 12, 17, 22}, 2: {1, 3, 6, 8, 11, 13, 17}, 3: {2, 8, 12, 16, 21, 23, 24}, 4: {9, 3, 13, 7}, 5: {18, 19, 22}}\n",
"step 2\n",
"step 3\n",
" chosen region: 3\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 2\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 11 from 1 to 2\n",
" donor is losing {12} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 16 from 1 to 2\n",
" donor is losing {17} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 3 from 3 to 2\n",
" donor is losing {2} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 4 from 3 to 2\n",
" donor is losing {3} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 9 from 3 to 2\n",
" donor is losing {4} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 1 from 1 to 2\n",
" donor is losing {2} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 6 from 1 to 2\n",
" donor is losing {1, 7} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 5 from 1 to 2\n",
" donor is losing {0, 6} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 10 from 1 to 2\n",
" donor is losing {11, 5} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 5\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 19 from 3 to 5\n",
" donor is losing {24} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 22 from 3 to 5\n",
" donor is losing {21} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 17 from 3 to 5\n",
" donor is losing {16, 22} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 16 from 2 to 5\n",
" donor is losing {21} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 12 from 2 to 5\n",
" donor is losing {17, 13} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 4\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 9 from 2 to 4\n",
" donor is losing {14} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 7 from 2 to 4\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 4 from 2 to 4\n",
" donor is losing {9} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 12 from 5 to 4\n",
" donor is losing {13, 7} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 0\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 5 from 2 to 0\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 10 from 2 to 0\n",
" donor is losing {15} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 11 from 2 to 0\n",
" donor is losing {16, 10, 12} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 12 from 4 to 0\n",
" donor is losing {17, 11} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 16 from 5 to 0\n",
" donor is losing {11, 15} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 6 from 2 to 0\n",
" donor is losing {11, 5} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 1\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"n_regions_per_comp {0: 6}\n",
"comp_label 0\n",
"n_regions_in_comp 6\n",
"Regions in comp: {0, 1, 2, 3, 4, 5}\n",
"comp_adj.shape: (25, 25)\n",
"initial_clustering [0 0 1 2 2 3 3 1 4 4 3 3 1 4 4 3 3 1 4 5 3 3 1 1 1]\n",
"data [[ 1.116]\n",
" [-0.024]\n",
" [-0.733]\n",
" [ 0.369]\n",
" [ 0.118]\n",
" [ 0.344]\n",
" [ 0.428]\n",
" [-0.915]\n",
" [ 0.267]\n",
" [ 0.29 ]\n",
" [ 0.364]\n",
" [ 0.38 ]\n",
" [ 0.548]\n",
" [ 0.926]\n",
" [ 3.037]\n",
" [ 1.433]\n",
" [ 0.743]\n",
" [ 1.363]\n",
" [ 1.106]\n",
" [ 0.721]\n",
" [ 2.126]\n",
" [ 2.156]\n",
" [ 1.758]\n",
" [ 0.339]\n",
" [ 1.669]]\n",
"start with obj. val.: [[ 66.765]]\n",
"RN {0: {2, 5, 6}, 1: {1, 3, 6, 8, 11, 13, 16, 18, 19, 21}, 2: {8, 9, 2}, 3: {0, 1, 7, 12, 17, 22}, 4: {3, 4, 7, 12, 17, 19, 23}, 5: {24, 18, 14}}\n",
"step 2\n",
"step 3\n",
" chosen region: 0\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 2 from 1 to 0\n",
" donor is losing {1, 3} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 7 from 1 to 0\n",
" donor is losing {8, 2, 6} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 8 from 4 to 0\n",
" donor is losing {3, 7} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 5 from 3 to 0\n",
" donor is losing {0} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 9 from 4 to 0\n",
" donor is losing {4} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 10 from 3 to 0\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 6 from 3 to 0\n",
" donor is losing {1, 5, 7} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 11 from 3 to 0\n",
" donor is losing {12, 6} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 3\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 5\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 14 from 4 to 5\n",
" donor is losing {9} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 24 from 1 to 5\n",
" donor is losing {19} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 1\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 16 from 3 to 1\n",
" donor is losing {17, 11} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 11 from 0 to 1\n",
" donor is losing {16} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 10 from 0 to 1\n",
" donor is losing {15} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 5 from 0 to 1\n",
" donor is losing {10} as neighbors\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 6 from 0 to 1\n",
" donor is losing {11} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 0 from 0 to 1\n",
" donor is losing {5} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 2\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 9 from 0 to 2\n",
" donor is losing {4, 14} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 8 from 0 to 2\n",
" donor is losing {9, 13} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 4\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 23 from 1 to 4\n",
" donor is losing {24} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 12 from 1 to 4\n",
" donor is losing {13} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 22 from 1 to 4\n",
" donor is losing {23} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 17 from 1 to 4\n",
" donor is losing {18, 22} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"n_regions_per_comp {0: 6}\n",
"comp_label 0\n",
"n_regions_in_comp 6\n",
"Regions in comp: {0, 1, 2, 3, 4, 5}\n",
"comp_adj.shape: (25, 25)\n",
"initial_clustering [0 0 1 2 2 0 0 3 2 2 0 4 3 2 2 5 5 5 2 2 5 5 5 5 5]\n",
"data [[ 1.116]\n",
" [-0.024]\n",
" [-0.733]\n",
" [ 0.369]\n",
" [ 0.118]\n",
" [ 0.344]\n",
" [ 0.428]\n",
" [-0.915]\n",
" [ 0.267]\n",
" [ 0.29 ]\n",
" [ 0.364]\n",
" [ 0.38 ]\n",
" [ 0.548]\n",
" [ 0.926]\n",
" [ 3.037]\n",
" [ 1.433]\n",
" [ 0.743]\n",
" [ 1.363]\n",
" [ 1.106]\n",
" [ 0.721]\n",
" [ 2.126]\n",
" [ 2.156]\n",
" [ 1.758]\n",
" [ 0.339]\n",
" [ 1.669]]\n",
"start with obj. val.: [[ 54.134]]\n",
"RN {0: {2, 11, 15, 7}, 1: {1, 3, 7}, 2: {2, 7, 12, 17, 23, 24}, 3: {2, 6, 8, 11, 13, 17}, 4: {16, 10, 12, 6}, 5: {18, 19, 10, 11, 12}}\n",
"step 2\n",
"step 3\n",
" chosen region: 2\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 5\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 18 from 2 to 5\n",
" donor is losing {17, 23} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 4\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 10 from 0 to 4\n",
" donor is losing {15} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 15 from 5 to 4\n",
" donor is losing {10} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 12 from 3 to 4\n",
" donor is losing {17, 11, 13, 7} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 16 from 5 to 4\n",
" donor is losing {11} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 13 from 2 to 4\n",
" donor is losing {12} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 8 from 2 to 4\n",
" donor is losing {7} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 18 from 5 to 4\n",
" donor is losing {13} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 19 from 2 to 4\n",
" donor is losing {24, 18} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 3\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 8 from 4 to 3\n",
" donor is losing {9, 3} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 3 from 2 to 3\n",
" donor is losing {2} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 4 from 2 to 3\n",
" donor is losing {3} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 9 from 2 to 3\n",
" donor is losing {8, 4, 14} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 1\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 1 from 0 to 1\n",
" donor is losing {2} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 3 from 3 to 1\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 7 from 3 to 1\n",
" donor is losing {2, 12, 6} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 0\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 10 from 4 to 0\n",
" donor is losing {5} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 15 from 4 to 0\n",
" donor is losing {20} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"n_regions_per_comp {0: 6}\n",
"comp_label 0\n",
"n_regions_in_comp 6\n",
"Regions in comp: {0, 1, 2, 3, 4, 5}\n",
"comp_adj.shape: (25, 25)\n",
"initial_clustering [0 0 1 2 2 0 0 1 2 2 3 3 3 2 2 3 3 3 2 2 4 3 3 5 5]\n",
"data [[ 1.116]\n",
" [-0.024]\n",
" [-0.733]\n",
" [ 0.369]\n",
" [ 0.118]\n",
" [ 0.344]\n",
" [ 0.428]\n",
" [-0.915]\n",
" [ 0.267]\n",
" [ 0.29 ]\n",
" [ 0.364]\n",
" [ 0.38 ]\n",
" [ 0.548]\n",
" [ 0.926]\n",
" [ 3.037]\n",
" [ 1.433]\n",
" [ 0.743]\n",
" [ 1.363]\n",
" [ 1.106]\n",
" [ 0.721]\n",
" [ 2.126]\n",
" [ 2.156]\n",
" [ 1.758]\n",
" [ 0.339]\n",
" [ 1.669]]\n",
"start with obj. val.: [[ 54.613]]\n",
"RN {0: {11, 2, 10, 7}, 1: {8, 1, 3, 12, 6}, 2: {2, 7, 12, 17, 23, 24}, 3: {5, 6, 7, 13, 18, 20, 23}, 4: {21, 15}, 5: {18, 19, 22}}\n",
"step 2\n",
"step 3\n",
" chosen region: 4\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 15 from 3 to 4\n",
" donor is losing set() as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 10 from 3 to 4\n",
" donor is losing {5} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 21 from 3 to 4\n",
" donor is losing {20} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 22 from 3 to 4\n",
" donor is losing {23} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 3\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 13 from 2 to 3\n",
" donor is losing {12} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 18 from 2 to 3\n",
" donor is losing {17, 23} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 8 from 2 to 3\n",
" donor is losing {7} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 19 from 2 to 3\n",
" donor is losing {24, 18} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 10 from 4 to 3\n",
" donor is losing {11, 5} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 1\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 1 from 0 to 1\n",
" donor is losing {2} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 3 from 2 to 1\n",
" donor is losing {2} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 8 from 3 to 1\n",
" donor is losing {9, 3} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 4 from 2 to 1\n",
" donor is losing {3} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 5\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 19 from 3 to 5\n",
" donor is losing {24} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
" MOVING 18 from 3 to 5\n",
" donor is losing {19, 23} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 17 from 3 to 5\n",
" donor is losing {22} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 2\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"step 3\n",
" chosen region: 0\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
" MOVING 1 from 1 to 0\n",
" donor is losing {0} as neighbors\n",
"step 4\n",
"step 5\n",
"step 5 loop\n",
"step 5 loop\n",
"step 5 loop\n",
"297 ms ± 56.6 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
]
}
],
"source": [
"%timeit AZP().fit_from_scipy_sparse_matrix(adj=adj5, n_regions=n_regions, data=attr5)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### ... with `clusterpy`"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 5, 5, 0, 0, 2, 5, 5, 0, 0, 0, 5, 4, 1, 0, 1, 5, 5, 1, 1, 1, 5, 3]\n",
"initial O.F: 2.2307786750000003\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 2, 5, 5, 0, 0, 2, 5, 5, 0, 0, 5, 5, 4, 1, 0, 1, 5, 5, 1, 1, 1, 5, 3]\n",
"FINAL O.F.: 2.2274324507936507\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [0, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 5, 3, 4, 3, 3, 3, 3, 3, 3, 3, 3]\n",
"initial O.F: 3.5712136161616166\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 5, 3, 4, 3, 3, 3, 3, 3, 3, 3, 3]\n",
"FINAL O.F.: 3.571213616161616\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [0, 0, 3, 5, 5, 0, 0, 3, 5, 5, 0, 0, 0, 5, 1, 4, 0, 2, 5, 5, 4, 4, 4, 5, 5]\n",
"initial O.F: 3.2062046250000003\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 3, 5, 5, 0, 0, 3, 5, 5, 0, 0, 0, 5, 1, 4, 0, 2, 5, 5, 4, 4, 4, 5, 5]\n",
"FINAL O.F.: 3.2062046250000003\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [4, 0, 0, 2, 2, 4, 4, 0, 2, 2, 4, 4, 4, 2, 1, 3, 4, 2, 2, 2, 3, 3, 5, 2, 2]\n",
"initial O.F: 3.781773980952381\n",
"Performing local search\n",
"FINAL SOLUTION: [4, 4, 0, 2, 2, 4, 4, 0, 2, 2, 4, 4, 4, 2, 1, 3, 4, 5, 2, 2, 5, 5, 5, 2, 2]\n",
"FINAL O.F.: 3.2708146250000003\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [2, 5, 0, 0, 0, 5, 5, 0, 0, 0, 5, 5, 5, 5, 1, 3, 5, 3, 5, 5, 3, 3, 3, 4, 5]\n",
"initial O.F: 4.272424133333334\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 5, 0, 5, 5, 5, 5, 0, 5, 5, 5, 5, 5, 5, 1, 3, 5, 4, 4, 4, 3, 3, 3, 4, 4]\n",
"FINAL O.F.: 2.1765928666666667\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [5, 4, 2, 0, 0, 4, 4, 2, 0, 0, 4, 4, 4, 4, 1, 3, 4, 3, 4, 4, 3, 3, 3, 4, 4]\n",
"initial O.F: 2.794325466666667\n",
"Performing local search\n",
"FINAL SOLUTION: [5, 2, 2, 0, 0, 4, 4, 2, 0, 0, 4, 4, 4, 4, 1, 3, 4, 3, 4, 4, 3, 3, 3, 4, 4]\n",
"FINAL O.F.: 2.756293466666667\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [4, 4, 0, 2, 2, 4, 4, 0, 2, 2, 4, 4, 4, 4, 5, 3, 4, 1, 1, 1, 3, 3, 1, 1, 1]\n",
"initial O.F: 2.8592882222222227\n",
"Performing local search\n",
"FINAL SOLUTION: [4, 4, 0, 2, 2, 4, 4, 0, 2, 2, 4, 4, 4, 1, 5, 3, 4, 1, 1, 1, 3, 3, 3, 1, 1]\n",
"FINAL O.F.: 2.2851519583333335\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [5, 3, 1, 4, 4, 5, 3, 1, 4, 4, 5, 5, 5, 0, 0, 2, 5, 0, 0, 0, 2, 2, 2, 0, 0]\n",
"initial O.F: 5.55278167857143\n",
"Performing local search\n",
"FINAL SOLUTION: [5, 3, 1, 4, 4, 5, 5, 1, 4, 4, 5, 5, 5, 5, 0, 2, 5, 0, 0, 0, 2, 2, 2, 0, 0]\n",
"FINAL O.F.: 5.417145125\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [0, 5, 1, 3, 3, 0, 0, 1, 3, 3, 0, 0, 0, 0, 2, 4, 0, 4, 0, 0, 4, 4, 4, 0, 0]\n",
"initial O.F: 2.4975454666666668\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 5, 1, 3, 3, 0, 0, 1, 3, 3, 0, 0, 0, 0, 2, 4, 0, 4, 0, 0, 4, 4, 4, 0, 0]\n",
"FINAL O.F.: 2.497545466666667\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [2, 2, 3, 1, 1, 2, 2, 3, 1, 1, 2, 2, 2, 2, 4, 5, 2, 2, 2, 2, 5, 5, 0, 2, 2]\n",
"initial O.F: 3.244030928571429\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 3, 3, 1, 1, 2, 2, 3, 1, 1, 2, 2, 2, 2, 4, 5, 2, 0, 2, 2, 5, 5, 5, 2, 2]\n",
"FINAL O.F.: 2.7199900833333333\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [5, 5, 3, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 2, 5, 5, 5, 5, 0, 1, 1, 1, 5, 0]\n",
"initial O.F: 3.624284196078432\n",
"Performing local search\n",
"FINAL SOLUTION: [5, 3, 4, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 2, 1, 5, 1, 5, 5, 1, 1, 1, 5, 0]\n",
"FINAL O.F.: 1.9389577333333334\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [1, 1, 4, 0, 0, 1, 1, 4, 0, 0, 1, 1, 1, 3, 5, 2, 1, 3, 3, 3, 2, 2, 2, 3, 3]\n",
"initial O.F: 2.2851519583333335\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 1, 4, 0, 0, 1, 1, 4, 0, 0, 1, 1, 1, 3, 5, 3, 3, 3, 3, 3, 2, 2, 2, 3, 3]\n",
"FINAL O.F.: 2.2027335238095245\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [2, 5, 3, 1, 1, 5, 5, 3, 1, 1, 5, 5, 1, 1, 4, 0, 5, 0, 1, 1, 0, 0, 0, 1, 1]\n",
"initial O.F: 2.9408724\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 5, 3, 1, 1, 5, 5, 3, 1, 1, 5, 5, 1, 1, 4, 0, 5, 0, 1, 1, 0, 0, 0, 1, 1]\n",
"FINAL O.F.: 2.940872400000001\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [0, 0, 3, 2, 2, 0, 0, 3, 2, 2, 0, 0, 0, 2, 1, 4, 0, 2, 2, 2, 4, 4, 4, 2, 5]\n",
"initial O.F: 2.662748625\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 3, 2, 2, 0, 0, 3, 2, 2, 0, 0, 2, 2, 1, 4, 2, 2, 2, 2, 4, 4, 4, 2, 5]\n",
"FINAL O.F.: 2.5980202651515154\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [5, 5, 0, 3, 3, 5, 5, 0, 3, 3, 5, 5, 5, 5, 1, 4, 5, 4, 5, 5, 4, 4, 4, 5, 2]\n",
"initial O.F: 1.924041716666667\n",
"Performing local search\n",
"FINAL SOLUTION: [5, 5, 0, 3, 3, 5, 5, 0, 3, 3, 5, 5, 5, 5, 1, 4, 5, 4, 5, 5, 4, 4, 4, 5, 2]\n",
"FINAL O.F.: 1.924041716666667\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [0, 0, 1, 4, 4, 0, 0, 1, 4, 4, 0, 0, 0, 4, 5, 2, 0, 4, 4, 4, 2, 2, 2, 3, 4]\n",
"initial O.F: 3.511584180555556\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 1, 4, 4, 0, 0, 1, 4, 4, 0, 0, 4, 4, 5, 2, 0, 2, 4, 4, 2, 2, 2, 3, 3]\n",
"FINAL O.F.: 3.074845103571429\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [3, 5, 1, 0, 0, 5, 5, 1, 0, 0, 5, 5, 5, 5, 2, 4, 5, 5, 5, 5, 4, 4, 4, 5, 5]\n",
"initial O.F: 3.0878684423076925\n",
"Performing local search\n",
"FINAL SOLUTION: [3, 1, 1, 0, 0, 5, 5, 1, 0, 0, 5, 5, 5, 5, 2, 4, 5, 4, 5, 5, 4, 4, 4, 5, 5]\n",
"FINAL O.F.: 2.756293466666667\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [3, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 5, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"initial O.F: 3.5712136161616166\n",
"Performing local search\n",
"FINAL SOLUTION: [3, 1, 2, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 5, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0]\n",
"FINAL O.F.: 3.571213616161616\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [3, 3, 0, 0, 5, 3, 3, 0, 0, 0, 3, 3, 3, 3, 1, 4, 3, 2, 3, 3, 2, 2, 2, 3, 3]\n",
"initial O.F: 4.386193642307693\n",
"Performing local search\n",
"FINAL SOLUTION: [3, 0, 0, 5, 5, 3, 3, 0, 5, 5, 3, 3, 3, 3, 1, 4, 3, 2, 3, 3, 2, 2, 2, 3, 3]\n",
"FINAL O.F.: 2.7846000833333333\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [0, 0, 1, 5, 5, 0, 0, 1, 5, 5, 0, 0, 0, 0, 4, 2, 0, 3, 0, 0, 3, 3, 3, 0, 0]\n",
"initial O.F: 2.8739384423076926\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 1, 1, 5, 5, 0, 0, 1, 5, 5, 0, 0, 0, 0, 4, 2, 0, 3, 0, 0, 3, 3, 3, 0, 0]\n",
"FINAL O.F.: 2.7846000833333333\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [4, 4, 2, 4, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 3, 1, 4, 4, 4, 5, 1, 1, 1, 0, 5]\n",
"initial O.F: 3.102686483333334\n",
"Performing local search\n",
"FINAL SOLUTION: [4, 4, 2, 4, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 3, 1, 4, 1, 4, 4, 1, 1, 1, 0, 5]\n",
"FINAL O.F.: 2.2058837333333337\n",
"Done\n",
"Adding variables\n",
"Done\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [4, 4, 2, 4, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 3, 4, 4, 4, 4, 0, 1, 1, 1, 4, 5]\n",
"initial O.F: 3.1914941960784318\n",
"Performing local search\n",
"FINAL SOLUTION: [4, 4, 2, 4, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 3, 1, 4, 1, 4, 0, 1, 1, 1, 4, 5]\n",
"FINAL O.F.: 2.1832184000000003\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [0, 0, 3, 5, 5, 0, 0, 3, 5, 5, 0, 0, 0, 5, 5, 4, 4, 5, 5, 5, 2, 2, 1, 5, 5]\n",
"initial O.F: 8.377099038961038\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 3, 5, 5, 0, 0, 3, 5, 5, 0, 0, 0, 5, 5, 4, 0, 1, 5, 5, 2, 2, 1, 5, 5]\n",
"FINAL O.F.: 8.083331975000002\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [2, 4, 3, 0, 0, 2, 2, 3, 0, 0, 2, 2, 2, 2, 2, 5, 2, 1, 2, 2, 1, 1, 1, 2, 2]\n",
"initial O.F: 7.297789826923077\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 4, 3, 0, 0, 2, 4, 3, 0, 0, 2, 2, 2, 2, 2, 5, 2, 2, 2, 2, 1, 1, 1, 2, 2]\n",
"FINAL O.F.: 7.004057897435899\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [4, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 3, 0, 2, 5, 2, 2, 5, 5, 5, 2, 2]\n",
"initial O.F: 3.0602497500000005\n",
"Performing local search\n",
"FINAL SOLUTION: [4, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 3, 0, 2, 5, 2, 2, 5, 5, 5, 2, 2]\n",
"FINAL O.F.: 3.0602497500000005\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 4, 5, 0, 1, 0, 0, 1, 1, 1, 3, 0]\n",
"initial O.F: 3.3189421875000003\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 4, 5, 0, 1, 0, 0, 1, 1, 1, 0, 3]\n",
"FINAL O.F.: 2.0946771875000003\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [2, 2, 1, 4, 4, 2, 2, 1, 4, 4, 2, 2, 2, 4, 3, 0, 2, 5, 4, 4, 0, 0, 0, 4, 4]\n",
"initial O.F: 3.2062046250000003\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 2, 1, 4, 4, 2, 2, 1, 4, 4, 2, 2, 2, 4, 3, 0, 2, 5, 4, 4, 0, 0, 0, 4, 4]\n",
"FINAL O.F.: 3.2062046250000003\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [1, 1, 5, 0, 0, 1, 1, 5, 0, 0, 1, 1, 1, 1, 3, 2, 1, 4, 1, 1, 4, 4, 4, 1, 1]\n",
"initial O.F: 2.8739384423076926\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 5, 5, 0, 0, 1, 1, 5, 0, 0, 1, 1, 1, 1, 3, 2, 1, 4, 1, 1, 4, 4, 4, 1, 1]\n",
"FINAL O.F.: 2.784600083333334\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [2, 2, 1, 4, 4, 2, 2, 1, 4, 4, 2, 2, 2, 4, 0, 3, 2, 5, 5, 5, 3, 3, 5, 5, 5]\n",
"initial O.F: 3.0420532083333334\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 2, 1, 4, 4, 2, 2, 1, 4, 4, 2, 2, 2, 5, 0, 3, 2, 5, 5, 5, 3, 3, 3, 5, 5]\n",
"FINAL O.F.: 2.2851519583333335\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [4, 4, 0, 2, 2, 4, 4, 0, 2, 2, 4, 4, 4, 4, 3, 1, 4, 1, 4, 4, 1, 1, 1, 4, 5]\n",
"initial O.F: 1.9240417166666668\n",
"Performing local search\n",
"FINAL SOLUTION: [4, 4, 0, 2, 2, 4, 4, 0, 2, 2, 4, 4, 4, 4, 3, 1, 4, 1, 4, 4, 1, 1, 1, 4, 5]\n",
"FINAL O.F.: 1.9240417166666668\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [2, 2, 1, 3, 3, 2, 2, 1, 3, 3, 2, 2, 2, 3, 5, 0, 2, 3, 3, 3, 0, 0, 0, 3, 4]\n",
"initial O.F: 2.6627486250000003\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 2, 1, 3, 3, 2, 2, 1, 3, 3, 2, 2, 3, 3, 5, 0, 3, 3, 3, 3, 0, 0, 0, 3, 4]\n",
"FINAL O.F.: 2.598020265151516\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 1, 1, 0, 0, 2, 1, 1, 0, 0, 0, 0, 4, 5, 0, 3, 0, 0, 5, 5, 5, 0, 0]\n",
"initial O.F: 2.8093284423076925\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 2, 2, 1, 1, 0, 0, 2, 1, 1, 0, 0, 0, 0, 4, 5, 0, 3, 0, 0, 5, 5, 5, 0, 0]\n",
"FINAL O.F.: 2.7199900833333337\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [1, 1, 4, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1, 1, 3, 2, 1, 1, 1, 1, 5, 5, 1, 0, 1]\n",
"initial O.F: 4.672612000000001\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 1, 4, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1, 1, 3, 2, 1, 0, 1, 1, 5, 5, 0, 0, 0]\n",
"FINAL O.F.: 2.923433683333333\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [2, 2, 3, 1, 1, 2, 2, 3, 1, 1, 2, 2, 2, 2, 4, 2, 2, 2, 2, 5, 2, 2, 2, 2, 0]\n",
"initial O.F: 6.83006775\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 3, 3, 1, 1, 2, 2, 3, 1, 1, 2, 2, 2, 2, 4, 2, 2, 2, 2, 5, 2, 2, 2, 2, 0]\n",
"FINAL O.F.: 6.256984000000001\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 3, 2, 4, 2, 2, 2, 2, 2, 2, 2, 5]\n",
"initial O.F: 4.012139166666667\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 3, 4, 4, 4, 4, 5, 2, 2, 2, 5, 5]\n",
"FINAL O.F.: 2.4432297500000004\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [2, 4, 4, 0, 0, 3, 3, 4, 0, 0, 3, 3, 3, 3, 5, 3, 3, 3, 3, 3, 1, 1, 3, 3, 3]\n",
"initial O.F: 3.914374380952382\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 4, 4, 0, 0, 3, 3, 4, 0, 0, 3, 3, 3, 3, 5, 1, 3, 1, 3, 3, 1, 1, 1, 3, 3]\n",
"FINAL O.F.: 2.756293466666667\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [5, 5, 2, 1, 1, 5, 5, 2, 1, 1, 5, 5, 5, 5, 3, 4, 5, 0, 5, 5, 4, 4, 0, 5, 5]\n",
"initial O.F: 2.871134192307693\n",
"Performing local search\n",
"FINAL SOLUTION: [5, 2, 2, 1, 1, 5, 5, 2, 1, 1, 5, 5, 5, 5, 3, 4, 5, 0, 5, 5, 4, 4, 4, 5, 5]\n",
"FINAL O.F.: 2.719990083333334\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 5, 5, 0, 0, 2, 5, 5, 0, 0, 0, 5, 3, 4, 0, 1, 5, 5, 4, 4, 4, 5, 5]\n",
"initial O.F: 3.2062046250000003\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 2, 5, 5, 0, 0, 2, 5, 5, 0, 0, 0, 5, 3, 4, 0, 1, 5, 5, 4, 4, 4, 5, 5]\n",
"FINAL O.F.: 3.2062046250000003\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [0, 5, 2, 1, 1, 0, 0, 2, 1, 1, 0, 0, 0, 1, 3, 4, 0, 1, 1, 1, 4, 4, 4, 1, 1]\n",
"initial O.F: 3.371314064285714\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 5, 2, 1, 1, 0, 0, 2, 1, 1, 0, 0, 0, 1, 3, 4, 0, 4, 1, 1, 4, 4, 4, 1, 1]\n",
"FINAL O.F.: 3.111564514285715\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [1, 1, 4, 5, 5, 1, 1, 4, 5, 5, 1, 1, 1, 5, 3, 0, 1, 5, 5, 5, 2, 2, 2, 5, 5]\n",
"initial O.F: 3.417586141666667\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 1, 4, 5, 5, 1, 1, 4, 5, 5, 1, 1, 1, 5, 3, 0, 1, 2, 5, 5, 2, 2, 2, 5, 5]\n",
"FINAL O.F.: 3.2708146250000008\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [1, 1, 5, 2, 2, 1, 1, 5, 2, 2, 1, 1, 1, 0, 4, 3, 1, 0, 0, 0, 3, 3, 3, 0, 0]\n",
"initial O.F: 2.2851519583333335\n",
"Performing local search\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"FINAL SOLUTION: [1, 1, 5, 2, 2, 1, 1, 5, 2, 2, 1, 1, 1, 0, 4, 3, 0, 0, 0, 0, 3, 3, 3, 0, 0]\n",
"FINAL O.F.: 2.2765576071428577\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [5, 0, 4, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3]\n",
"initial O.F: 8.21132575\n",
"Performing local search\n",
"FINAL SOLUTION: [5, 4, 4, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3]\n",
"FINAL O.F.: 7.7690472368421055\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [0, 0, 3, 1, 1, 0, 0, 3, 1, 1, 0, 0, 0, 1, 5, 1, 1, 1, 1, 2, 1, 1, 1, 1, 4]\n",
"initial O.F: 6.953596087912089\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 3, 1, 1, 0, 0, 3, 1, 1, 0, 0, 0, 1, 5, 1, 1, 1, 1, 2, 1, 1, 1, 1, 4]\n",
"FINAL O.F.: 6.953596087912089\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [0, 2, 2, 1, 1, 5, 5, 2, 1, 1, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3, 3, 5, 4, 5]\n",
"initial O.F: 7.830714095238095\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 2, 2, 1, 1, 0, 0, 2, 1, 1, 0, 0, 0, 0, 5, 5, 5, 5, 5, 5, 3, 3, 3, 4, 5]\n",
"FINAL O.F.: 4.870795904761905\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [2, 2, 3, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 4, 5, 2, 5, 2, 2, 5, 5, 5, 1, 0]\n",
"initial O.F: 2.2058837333333337\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 2, 3, 2, 2, 2, 2, 3, 2, 2, 2, 2, 2, 2, 4, 5, 2, 5, 2, 2, 5, 5, 5, 1, 0]\n",
"FINAL O.F.: 2.2058837333333337\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [3, 3, 1, 5, 5, 3, 3, 1, 5, 5, 3, 3, 3, 5, 0, 2, 3, 5, 5, 5, 4, 4, 4, 5, 5]\n",
"initial O.F: 3.417586141666667\n",
"Performing local search\n",
"FINAL SOLUTION: [3, 3, 1, 5, 5, 3, 3, 1, 5, 5, 3, 3, 3, 5, 0, 2, 5, 5, 5, 5, 4, 4, 4, 5, 5]\n",
"FINAL O.F.: 3.34353116017316\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [4, 2, 1, 5, 5, 2, 2, 1, 5, 5, 2, 2, 2, 5, 3, 0, 2, 5, 5, 5, 0, 0, 0, 5, 5]\n",
"initial O.F: 3.2185540642857142\n",
"Performing local search\n",
"FINAL SOLUTION: [4, 2, 1, 5, 5, 2, 2, 1, 5, 5, 2, 2, 5, 5, 3, 0, 5, 5, 5, 5, 0, 0, 0, 5, 5]\n",
"FINAL O.F.: 3.054914866666667\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [4, 5, 2, 1, 1, 4, 4, 2, 1, 1, 4, 4, 4, 4, 4, 0, 3, 0, 4, 4, 0, 0, 0, 4, 4]\n",
"initial O.F: 7.410146466666668\n",
"Performing local search\n",
"FINAL SOLUTION: [4, 5, 2, 1, 1, 4, 5, 2, 1, 1, 4, 4, 4, 4, 4, 3, 3, 3, 4, 4, 0, 0, 0, 4, 4]\n",
"FINAL O.F.: 7.085400242424243\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [1, 1, 2, 1, 4, 1, 1, 2, 1, 1, 1, 1, 1, 1, 3, 0, 1, 5, 1, 1, 5, 5, 5, 1, 1]\n",
"initial O.F: 3.158178500000001\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 2, 2, 4, 4, 1, 1, 2, 4, 4, 1, 1, 1, 1, 3, 0, 1, 5, 1, 1, 5, 5, 5, 1, 1]\n",
"FINAL O.F.: 2.7846000833333338\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [2, 2, 5, 1, 1, 2, 2, 5, 1, 1, 2, 2, 2, 1, 4, 0, 2, 3, 1, 1, 0, 0, 3, 1, 1]\n",
"initial O.F: 3.268010375\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 2, 5, 1, 1, 2, 2, 5, 1, 1, 2, 2, 2, 1, 4, 0, 2, 3, 1, 1, 0, 0, 0, 1, 1]\n",
"FINAL O.F.: 3.2062046250000003\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [2, 2, 4, 5, 0, 2, 2, 4, 5, 5, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3]\n",
"initial O.F: 6.849658666666668\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 4, 4, 5, 0, 2, 2, 4, 5, 5, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3]\n",
"FINAL O.F.: 6.307298770833333\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [5, 5, 2, 3, 3, 5, 5, 2, 3, 3, 5, 5, 0, 3, 1, 4, 5, 3, 3, 3, 4, 4, 4, 3, 3]\n",
"initial O.F: 3.665975778571428\n",
"Performing local search\n",
"FINAL SOLUTION: [5, 5, 2, 3, 3, 5, 5, 2, 3, 3, 5, 5, 0, 3, 1, 4, 3, 3, 3, 3, 4, 4, 4, 3, 3]\n",
"FINAL O.F.: 3.5851117196969695\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [1, 1, 5, 3, 3, 1, 1, 5, 3, 3, 1, 1, 1, 3, 4, 2, 1, 3, 3, 3, 2, 2, 2, 3, 0]\n",
"initial O.F: 2.6627486250000003\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 1, 5, 3, 3, 1, 1, 5, 3, 3, 1, 1, 3, 3, 4, 2, 1, 2, 3, 3, 2, 2, 2, 3, 0]\n",
"FINAL O.F.: 2.227432450793651\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [2, 2, 3, 0, 0, 2, 2, 3, 0, 0, 2, 2, 2, 5, 5, 1, 2, 5, 5, 5, 1, 1, 1, 5, 4]\n",
"initial O.F: 5.6185119583333325\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 2, 3, 0, 0, 2, 2, 3, 0, 0, 2, 2, 2, 5, 5, 1, 2, 5, 5, 4, 1, 1, 1, 4, 4]\n",
"FINAL O.F.: 4.933947291666667\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [0, 0, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 2, 4, 0, 5, 5, 5, 1, 1, 5, 5, 5]\n",
"initial O.F: 2.7347045641025645\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 3, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 2, 4, 5, 5, 5, 5, 1, 1, 1, 5, 5]\n",
"FINAL O.F.: 2.383647166666667\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [0, 2, 2, 5, 5, 5, 5, 2, 5, 5, 5, 5, 5, 5, 3, 4, 5, 4, 4, 4, 4, 4, 4, 4, 1]\n",
"initial O.F: 3.8599583484848488\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 5, 2, 5, 5, 5, 5, 2, 5, 5, 5, 5, 5, 5, 3, 4, 1, 1, 1, 1, 4, 4, 4, 1, 1]\n",
"FINAL O.F.: 2.1186103106060608\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [5, 5, 3, 0, 0, 5, 5, 3, 0, 0, 5, 5, 5, 5, 4, 2, 5, 1, 1, 1, 2, 2, 1, 1, 1]\n",
"initial O.F: 2.8592882222222227\n",
"Performing local search\n",
"FINAL SOLUTION: [5, 5, 3, 0, 0, 5, 5, 3, 0, 0, 5, 5, 5, 1, 4, 2, 5, 1, 1, 1, 2, 2, 2, 1, 1]\n",
"FINAL O.F.: 2.285151958333334\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [4, 0, 3, 2, 2, 4, 4, 3, 2, 2, 4, 4, 4, 2, 5, 1, 4, 2, 2, 2, 1, 1, 1, 2, 2]\n",
"initial O.F: 3.371314064285714\n",
"Performing local search\n",
"FINAL SOLUTION: [4, 0, 3, 2, 2, 4, 4, 3, 2, 2, 4, 4, 4, 2, 5, 1, 2, 2, 2, 2, 1, 1, 1, 2, 2]\n",
"FINAL O.F.: 3.3330503863636363\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [2, 5, 4, 1, 1, 5, 5, 4, 1, 1, 5, 5, 5, 1, 3, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1]\n",
"initial O.F: 6.853611214285715\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 5, 4, 1, 1, 5, 5, 4, 1, 1, 5, 5, 5, 1, 3, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1]\n",
"FINAL O.F.: 6.853611214285714\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [0, 0, 5, 3, 3, 0, 0, 5, 3, 3, 0, 0, 0, 3, 1, 2, 0, 2, 3, 3, 2, 2, 2, 3, 4]\n",
"initial O.F: 2.2307786750000003\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 5, 3, 3, 0, 0, 5, 3, 3, 0, 0, 3, 3, 1, 2, 0, 2, 3, 3, 2, 2, 2, 3, 4]\n",
"FINAL O.F.: 2.227432450793651\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [2, 2, 4, 2, 2, 2, 2, 5, 2, 2, 2, 2, 2, 2, 3, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0]\n",
"initial O.F: 2.8790172307692306\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 2, 4, 2, 2, 2, 2, 5, 2, 2, 2, 2, 2, 2, 3, 0, 2, 0, 0, 0, 0, 0, 0, 1, 0]\n",
"FINAL O.F.: 2.8790172307692306\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [2, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 3, 5, 0, 5, 5, 5, 5, 5, 5, 4, 5]\n",
"initial O.F: 2.4171669166666665\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 3, 5, 0, 5, 5, 5, 5, 5, 5, 4, 5]\n",
"FINAL O.F.: 2.4171669166666665\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [2, 3, 1, 5, 5, 3, 3, 1, 5, 5, 3, 3, 3, 3, 4, 0, 3, 4, 4, 4, 0, 0, 4, 4, 4]\n",
"initial O.F: 5.502953589285714\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 3, 1, 5, 5, 3, 3, 1, 5, 5, 3, 3, 3, 4, 4, 0, 3, 4, 4, 4, 0, 0, 0, 4, 4]\n",
"FINAL O.F.: 5.318329892857143\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [4, 5, 2, 1, 1, 5, 5, 2, 1, 1, 5, 5, 5, 5, 0, 5, 5, 5, 5, 5, 5, 5, 5, 5, 3]\n",
"initial O.F: 6.8405599375\n",
"Performing local search\n",
"FINAL SOLUTION: [4, 4, 2, 1, 1, 4, 4, 2, 1, 1, 4, 4, 4, 3, 0, 5, 4, 3, 3, 3, 5, 5, 5, 3, 3]\n",
"FINAL O.F.: 2.2851519583333335\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [0, 0, 2, 4, 4, 0, 0, 2, 4, 4, 0, 0, 0, 4, 1, 3, 0, 4, 4, 4, 3, 3, 3, 4, 5]\n",
"initial O.F: 2.6627486250000003\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 2, 4, 4, 0, 0, 2, 4, 4, 0, 0, 4, 4, 1, 3, 0, 3, 4, 4, 3, 3, 3, 4, 5]\n",
"FINAL O.F.: 2.2274324507936507\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [1, 1, 3, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 0, 4, 5, 4, 4, 4, 4, 4, 4, 4, 2]\n",
"initial O.F: 4.012139166666667\n",
"Performing local search\n",
"FINAL SOLUTION: [1, 1, 3, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1, 0, 5, 2, 2, 2, 2, 4, 4, 4, 2, 2]\n",
"FINAL O.F.: 2.383647166666667\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [3, 3, 4, 1, 1, 3, 3, 4, 1, 1, 3, 3, 3, 3, 0, 5, 3, 2, 3, 3, 5, 5, 2, 3, 3]\n",
"initial O.F: 2.871134192307693\n",
"Performing local search\n",
"FINAL SOLUTION: [3, 4, 4, 1, 1, 3, 3, 4, 1, 1, 3, 3, 3, 3, 0, 5, 3, 2, 3, 3, 5, 5, 5, 3, 3]\n",
"FINAL O.F.: 2.7199900833333333\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [4, 4, 2, 1, 1, 4, 4, 2, 1, 1, 4, 4, 4, 5, 3, 0, 4, 0, 5, 5, 0, 0, 0, 5, 5]\n",
"initial O.F: 2.348743475\n",
"Performing local search\n",
"FINAL SOLUTION: [4, 4, 2, 1, 1, 4, 4, 2, 1, 1, 4, 4, 4, 5, 3, 5, 5, 5, 5, 5, 0, 0, 0, 5, 5]\n",
"FINAL O.F.: 2.202733523809524\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [2, 2, 1, 0, 0, 2, 2, 1, 0, 0, 2, 2, 4, 0, 5, 3, 2, 3, 0, 0, 3, 3, 3, 0, 0]\n",
"initial O.F: 3.406226228571429\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 2, 1, 0, 0, 2, 2, 1, 0, 0, 2, 2, 4, 0, 5, 3, 2, 3, 0, 0, 3, 3, 3, 0, 0]\n",
"FINAL O.F.: 3.4062262285714286\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [4, 4, 1, 0, 0, 4, 4, 1, 0, 0, 4, 4, 4, 4, 2, 5, 4, 3, 3, 3, 5, 5, 3, 3, 3]\n",
"initial O.F: 2.8592882222222227\n",
"Performing local search\n",
"FINAL SOLUTION: [4, 4, 1, 0, 0, 4, 4, 1, 0, 0, 4, 4, 4, 3, 2, 3, 3, 3, 3, 3, 5, 5, 5, 3, 3]\n",
"FINAL O.F.: 2.2027335238095245\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [4, 4, 1, 0, 0, 4, 4, 1, 0, 0, 4, 4, 4, 5, 5, 3, 4, 5, 5, 5, 2, 2, 2, 5, 5]\n",
"initial O.F: 5.517361970238095\n",
"Performing local search\n",
"FINAL SOLUTION: [4, 4, 1, 0, 0, 4, 4, 1, 0, 0, 4, 4, 4, 5, 5, 3, 4, 5, 5, 5, 2, 2, 2, 5, 5]\n",
"FINAL O.F.: 5.5173619702380945\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [5, 5, 1, 3, 3, 5, 5, 1, 3, 3, 5, 5, 3, 3, 2, 4, 5, 0, 3, 3, 4, 4, 0, 3, 3]\n",
"initial O.F: 3.272278028571429\n",
"Performing local search\n",
"FINAL SOLUTION: [5, 5, 1, 3, 3, 5, 5, 1, 3, 3, 5, 5, 5, 3, 2, 4, 5, 0, 3, 3, 4, 4, 4, 3, 3]\n",
"FINAL O.F.: 3.2062046250000007\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [0, 0, 3, 4, 4, 0, 0, 3, 4, 4, 0, 0, 0, 4, 5, 1, 0, 4, 4, 2, 1, 1, 1, 4, 2]\n",
"initial O.F: 3.0984881250000003\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 0, 3, 4, 4, 0, 0, 3, 4, 4, 0, 0, 4, 4, 5, 1, 4, 4, 4, 4, 1, 1, 1, 4, 2]\n",
"FINAL O.F.: 2.5980202651515154\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [3, 3, 2, 1, 1, 3, 3, 2, 1, 1, 3, 3, 3, 1, 4, 0, 3, 5, 1, 1, 5, 5, 5, 1, 1]\n",
"initial O.F: 3.2708146250000003\n",
"Performing local search\n",
"FINAL SOLUTION: [3, 3, 2, 1, 1, 3, 3, 2, 1, 1, 3, 3, 3, 1, 4, 0, 3, 5, 1, 1, 5, 5, 5, 1, 1]\n",
"FINAL O.F.: 3.2708146250000003\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [5, 5, 2, 0, 0, 5, 5, 2, 0, 0, 5, 5, 5, 5, 4, 1, 5, 3, 5, 5, 3, 3, 3, 5, 5]\n",
"initial O.F: 2.8739384423076926\n",
"Performing local search\n",
"FINAL SOLUTION: [5, 2, 2, 0, 0, 5, 5, 2, 0, 0, 5, 5, 5, 5, 4, 1, 5, 3, 5, 5, 3, 3, 3, 5, 5]\n",
"FINAL O.F.: 2.784600083333334\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [4, 0, 0, 3, 3, 4, 4, 0, 3, 3, 4, 4, 4, 1, 2, 5, 4, 1, 1, 1, 5, 5, 5, 1, 1]\n",
"initial O.F: 2.4129564642857146\n",
"Performing local search\n",
"FINAL SOLUTION: [4, 4, 0, 3, 3, 4, 4, 0, 3, 3, 4, 4, 4, 1, 2, 1, 1, 1, 1, 1, 5, 5, 5, 1, 1]\n",
"FINAL O.F.: 2.2027335238095245\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [3, 5, 1, 5, 5, 5, 5, 1, 5, 5, 5, 5, 5, 5, 4, 0, 5, 0, 0, 0, 0, 0, 0, 2, 0]\n",
"initial O.F: 2.417166916666667\n",
"Performing local search\n",
"FINAL SOLUTION: [3, 5, 1, 5, 5, 5, 5, 1, 5, 5, 5, 5, 5, 5, 4, 0, 5, 0, 0, 0, 0, 0, 0, 2, 0]\n",
"FINAL O.F.: 2.4171669166666665\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 4, 5, 2, 0, 2, 2, 0, 0, 0, 2, 3]\n",
"initial O.F: 2.0946771875000003\n",
"Performing local search\n",
"FINAL SOLUTION: [2, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 2, 2, 2, 4, 5, 2, 0, 2, 2, 0, 0, 0, 2, 3]\n",
"FINAL O.F.: 2.0946771875000003\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [3, 1, 5, 0, 0, 3, 1, 5, 0, 0, 3, 3, 3, 0, 2, 4, 3, 4, 0, 0, 4, 4, 4, 0, 0]\n",
"initial O.F: 3.1932563\n",
"Performing local search\n",
"FINAL SOLUTION: [3, 1, 5, 0, 0, 3, 3, 5, 0, 0, 3, 3, 3, 0, 2, 4, 3, 4, 0, 0, 4, 4, 4, 0, 0]\n",
"FINAL O.F.: 3.1115645142857145\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [0, 0, 1, 5, 5, 0, 0, 1, 5, 5, 0, 0, 0, 0, 4, 3, 0, 2, 0, 0, 2, 2, 2, 0, 0]\n",
"initial O.F: 2.8739384423076926\n",
"Performing local search\n",
"FINAL SOLUTION: [0, 1, 1, 5, 5, 0, 0, 1, 5, 5, 0, 0, 0, 0, 4, 3, 0, 2, 0, 0, 2, 2, 2, 0, 0]\n",
"FINAL O.F.: 2.7846000833333338\n",
"Done\n",
"Adding variables\n",
"Done\n",
"Getting variables\n",
"Variables successfully extracted\n",
"Running original AZP algorithm (Openshaw and Rao, 1995)\n",
"Number of areas: 25\n",
"Number of regions: 6\n",
"Constructing regions\n",
"initial Solution: [4, 4, 1, 3, 3, 4, 4, 1, 3, 3, 4, 4, 4, 0, 2, 4, 4, 0, 0, 0, 0, 0, 0, 0, 5]\n",
"initial O.F: 4.684819097222222\n",
"Performing local search\n",
"FINAL SOLUTION: [4, 4, 1, 3, 3, 4, 4, 1, 3, 3, 4, 4, 4, 4, 2, 0, 4, 5, 5, 5, 0, 0, 0, 5, 5]\n",
"FINAL O.F.: 2.4454128388888896\n",
"Done\n",
"Adding variables\n",
"Done\n",
"26.9 ms ± 2.27 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n"
]
}
],
"source": [
"%timeit layer5.cluster(method, ['VARIABLE0'], n_regions)"
]
}
],
"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.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment