{ "cells": [ { "cell_type": "markdown", "id": "forbidden-beast", "metadata": {}, "source": [ "### An engineering problem from \"Engineering Optimization\" by Xin-She Yang" ] }, { "cell_type": "markdown", "id": "removed-toyota", "metadata": {}, "source": [ "Goal: Design an optimal spring (cheapest / least material needed) that does the job. Parameters we can change: $d$, the diameter of the coil; $L$, the length of the spring; $w$, the thickness of the wire." ] }, { "cell_type": "markdown", "id": "located-architecture", "metadata": {}, "source": [ "Task: Minimize $$(2+L)dw^2$$ subject to the constraints\n", "\\begin{align*}\n", "g_1(L,d,w) &= 1 - \\frac{d^3L}{7178w^4} \\leq 0\\\\[5pt]\n", "g_2(L,d,w) &= \\frac{4d^2 - wd}{12566dw^3 - w^4} + \\frac{1}{5108w^2} - 1 \\leq 0\\\\[5pt]\n", "g_3(L,d,w) &= 1 - \\frac{140.45w}{d^2L} \\leq 0\\\\[5pt]\n", "g_4(L,d,w) &= \\frac{w+d}{1.5} - 1 \\leq 0\n", "\\end{align*}\n", "with boundary conditions\n", "$$\n", "0.05 \\leq w \\leq 2.0\n", "\\qquad\\qquad\n", "0.25 \\leq d \\leq 1.3\n", "\\qquad\\qquad\n", "2.0 \\leq L \\leq 15.0\n", "$$" ] }, { "cell_type": "code", "execution_count": 64, "id": "removable-stanford", "metadata": {}, "outputs": [], "source": [ "import math\n", "import random" ] }, { "cell_type": "code", "execution_count": 65, "id": "graphic-connection", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "9.807272192879124" ] }, "execution_count": 65, "metadata": {}, "output_type": "execute_result" } ], "source": [ "def random_in_range(lower, upper):\n", " return random.random() * (upper - lower) + lower\n", "random_in_range(2, 15)" ] }, { "cell_type": "code", "execution_count": 66, "id": "regional-brother", "metadata": {}, "outputs": [], "source": [ "def g1(L,d,w):\n", " return 1 - d**3 * L / (7178 * w**4)\n", "\n", "def g2(L,d,w):\n", " return (4*d**2 - w*d)/(12566 * d * w**3 - w**4) + 1/(5108*w**2) - 1\n", "\n", "def g3(L,d,w):\n", " return 1 - 140.45 * w / (d**2*L)\n", "\n", "def g4(L,d,w):\n", " return (w+d)/1.5 - 1\n", "\n", "def satisfies_constraints(L,d,w):\n", " return g1(L,d,w) <= 0 and g2(L,d,w) <= 0 and g3(L,d,w) <= 0 and g4(L,d,w) <= 0" ] }, { "cell_type": "code", "execution_count": 67, "id": "impossible-height", "metadata": {}, "outputs": [], "source": [ "def score(L,d,w): # w-squared is \"w**2\" not \"w^2\"\n", " return (2+L)*d*w**2" ] }, { "cell_type": "code", "execution_count": 68, "id": "physical-photograph", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(14.985475559511695, 1.2953884226171417, 1.9955223584629296)" ] }, "execution_count": 68, "metadata": {}, "output_type": "execute_result" } ], "source": [ "def tweak(L,d,w):\n", " delta_w = 0.01\n", " delta_d = 0.01\n", " delta_L = 0.1\n", " \n", " new_w = w + random_in_range(-1, 1) * delta_w\n", " while new_w < 0.05 or new_w > 2:\n", " new_w = w + random_in_range(-1, 1) * delta_w\n", " \n", " new_d = d + random_in_range(-1, 1) * delta_d\n", " while new_d < 0.25 or new_d > 1.3:\n", " new_d = d + random_in_range(-1, 1) * delta_d\n", " \n", " new_L = L + random_in_range(-1, 1) * delta_L\n", " while new_L < 2 or new_L > 15:\n", " new_L = L + random_in_range(-1, 1) * delta_L\n", " \n", " return (new_L, new_d, new_w)\n", " \n", "tweak(15, 1.3, 2.0)" ] }, { "cell_type": "code", "execution_count": 69, "id": "american-sleep", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(14.670093262180803, 1.0832237814826102, 1.7099436217865769)\n" ] } ], "source": [ "def random_solution():\n", " return (\n", " random_in_range(2, 15),\n", " random_in_range(0.25, 1.3),\n", " random_in_range(0.05, 2),\n", " )\n", "print(random_solution())" ] }, { "cell_type": "code", "execution_count": 70, "id": "b1c47481", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "4" ] }, "execution_count": 70, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# what does the * do\n", "def test(num1, num2):\n", " return num1 + num2\n", "L = [1,3]\n", "test(*L)" ] }, { "cell_type": "code", "execution_count": null, "id": "4ad15d13", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 88, "id": "fb12fc01", "metadata": {}, "outputs": [], "source": [ "%matplotlib notebook\n", "\n", "from mpl_toolkits.mplot3d import Axes3D\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "from IPython.display import clear_output\n", "from math import sqrt, pi\n", "\n", "def show_spring(L,d,w):\n", " \n", " ax.lines.clear()\n", " \n", " N = L\n", "\n", " theta = np.linspace(0, N * 2 * np.pi, 1000)\n", " z = theta/2/np.pi\n", " x = d * np.sin(theta)\n", " y = d* np.cos(theta)\n", " line = ax.plot(x, y, z, color='b', label='parametric curve', lw=w*30) # the full spiral\n", "\n", " fig.canvas.draw()\n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": null, "id": "c1faf301", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 106, "id": "alien-queensland", "metadata": {}, "outputs": [], "source": [ "def hill_climbing():\n", " \n", " start = random_solution()\n", " while not satisfies_constraints(*start):\n", " start = random_solution()\n", " sol = start\n", " value = score(*sol)\n", "\n", " bad = 0\n", " while True:\n", " new_sol = tweak(*sol)\n", " while not satisfies_constraints(*new_sol):\n", " new_sol = tweak(*sol)\n", " new_value = score(*new_sol)\n", " if new_value < value:\n", " bad = 0\n", " sol = new_sol\n", " value = new_value\n", " show_spring(*sol)\n", " \n", " else:\n", " bad += 1\n", " if bad > 1000:\n", " print(value)\n", " return sol\n", " \n" ] }, { "cell_type": "code", "execution_count": 107, "id": "c52a309c", "metadata": {}, "outputs": [ { "data": { "application/javascript": [ "/* Put everything inside the global mpl namespace */\n", "/* global mpl */\n", "window.mpl = {};\n", "\n", "mpl.get_websocket_type = function () {\n", " if (typeof WebSocket !== 'undefined') {\n", " return WebSocket;\n", " } else if (typeof MozWebSocket !== 'undefined') {\n", " return MozWebSocket;\n", " } else {\n", " alert(\n", " 'Your browser does not have WebSocket support. ' +\n", " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", " 'Firefox 4 and 5 are also supported but you ' +\n", " 'have to enable WebSockets in about:config.'\n", " );\n", " }\n", "};\n", "\n", "mpl.figure = function (figure_id, websocket, ondownload, parent_element) {\n", " this.id = figure_id;\n", "\n", " this.ws = websocket;\n", "\n", " this.supports_binary = this.ws.binaryType !== undefined;\n", "\n", " if (!this.supports_binary) {\n", " var warnings = document.getElementById('mpl-warnings');\n", " if (warnings) {\n", " warnings.style.display = 'block';\n", " warnings.textContent =\n", " 'This browser does not support binary websocket messages. ' +\n", " 'Performance may be slow.';\n", " }\n", " }\n", "\n", " this.imageObj = new Image();\n", "\n", " this.context = undefined;\n", " this.message = undefined;\n", " this.canvas = undefined;\n", " this.rubberband_canvas = undefined;\n", " this.rubberband_context = undefined;\n", " this.format_dropdown = undefined;\n", "\n", " this.image_mode = 'full';\n", "\n", " this.root = document.createElement('div');\n", " this.root.setAttribute('style', 'display: inline-block');\n", " this._root_extra_style(this.root);\n", "\n", " parent_element.appendChild(this.root);\n", "\n", " this._init_header(this);\n", " this._init_canvas(this);\n", " this._init_toolbar(this);\n", "\n", " var fig = this;\n", "\n", " this.waiting = false;\n", "\n", " this.ws.onopen = function () {\n", " fig.send_message('supports_binary', { value: fig.supports_binary });\n", " fig.send_message('send_image_mode', {});\n", " if (fig.ratio !== 1) {\n", " fig.send_message('set_device_pixel_ratio', {\n", " device_pixel_ratio: fig.ratio,\n", " });\n", " }\n", " fig.send_message('refresh', {});\n", " };\n", "\n", " this.imageObj.onload = function () {\n", " if (fig.image_mode === 'full') {\n", " // Full images could contain transparency (where diff images\n", " // almost always do), so we need to clear the canvas so that\n", " // there is no ghosting.\n", " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", " }\n", " fig.context.drawImage(fig.imageObj, 0, 0);\n", " };\n", "\n", " this.imageObj.onunload = function () {\n", " fig.ws.close();\n", " };\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", "\n", " this.ondownload = ondownload;\n", "};\n", "\n", "mpl.figure.prototype._init_header = function () {\n", " var titlebar = document.createElement('div');\n", " titlebar.classList =\n", " 'ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix';\n", " var titletext = document.createElement('div');\n", " titletext.classList = 'ui-dialog-title';\n", " titletext.setAttribute(\n", " 'style',\n", " 'width: 100%; text-align: center; padding: 3px;'\n", " );\n", " titlebar.appendChild(titletext);\n", " this.root.appendChild(titlebar);\n", " this.header = titletext;\n", "};\n", "\n", "mpl.figure.prototype._canvas_extra_style = function (_canvas_div) {};\n", "\n", "mpl.figure.prototype._root_extra_style = function (_canvas_div) {};\n", "\n", "mpl.figure.prototype._init_canvas = function () {\n", " var fig = this;\n", "\n", " var canvas_div = (this.canvas_div = document.createElement('div'));\n", " canvas_div.setAttribute('tabindex', '0');\n", " canvas_div.setAttribute(\n", " 'style',\n", " 'border: 1px solid #ddd;' +\n", " 'box-sizing: content-box;' +\n", " 'clear: both;' +\n", " 'min-height: 1px;' +\n", " 'min-width: 1px;' +\n", " 'outline: 0;' +\n", " 'overflow: hidden;' +\n", " 'position: relative;' +\n", " 'resize: both;' +\n", " 'z-index: 2;'\n", " );\n", "\n", " function on_keyboard_event_closure(name) {\n", " return function (event) {\n", " return fig.key_event(event, name);\n", " };\n", " }\n", "\n", " canvas_div.addEventListener(\n", " 'keydown',\n", " on_keyboard_event_closure('key_press')\n", " );\n", " canvas_div.addEventListener(\n", " 'keyup',\n", " on_keyboard_event_closure('key_release')\n", " );\n", "\n", " this._canvas_extra_style(canvas_div);\n", " this.root.appendChild(canvas_div);\n", "\n", " var canvas = (this.canvas = document.createElement('canvas'));\n", " canvas.classList.add('mpl-canvas');\n", " canvas.setAttribute(\n", " 'style',\n", " 'box-sizing: content-box;' +\n", " 'pointer-events: none;' +\n", " 'position: relative;' +\n", " 'z-index: 0;'\n", " );\n", "\n", " this.context = canvas.getContext('2d');\n", "\n", " var backingStore =\n", " this.context.backingStorePixelRatio ||\n", " this.context.webkitBackingStorePixelRatio ||\n", " this.context.mozBackingStorePixelRatio ||\n", " this.context.msBackingStorePixelRatio ||\n", " this.context.oBackingStorePixelRatio ||\n", " this.context.backingStorePixelRatio ||\n", " 1;\n", "\n", " this.ratio = (window.devicePixelRatio || 1) / backingStore;\n", "\n", " var rubberband_canvas = (this.rubberband_canvas = document.createElement(\n", " 'canvas'\n", " ));\n", " rubberband_canvas.setAttribute(\n", " 'style',\n", " 'box-sizing: content-box;' +\n", " 'left: 0;' +\n", " 'pointer-events: none;' +\n", " 'position: absolute;' +\n", " 'top: 0;' +\n", " 'z-index: 1;'\n", " );\n", "\n", " // Apply a ponyfill if ResizeObserver is not implemented by browser.\n", " if (this.ResizeObserver === undefined) {\n", " if (window.ResizeObserver !== undefined) {\n", " this.ResizeObserver = window.ResizeObserver;\n", " } else {\n", " var obs = _JSXTOOLS_RESIZE_OBSERVER({});\n", " this.ResizeObserver = obs.ResizeObserver;\n", " }\n", " }\n", "\n", " this.resizeObserverInstance = new this.ResizeObserver(function (entries) {\n", " var nentries = entries.length;\n", " for (var i = 0; i < nentries; i++) {\n", " var entry = entries[i];\n", " var width, height;\n", " if (entry.contentBoxSize) {\n", " if (entry.contentBoxSize instanceof Array) {\n", " // Chrome 84 implements new version of spec.\n", " width = entry.contentBoxSize[0].inlineSize;\n", " height = entry.contentBoxSize[0].blockSize;\n", " } else {\n", " // Firefox implements old version of spec.\n", " width = entry.contentBoxSize.inlineSize;\n", " height = entry.contentBoxSize.blockSize;\n", " }\n", " } else {\n", " // Chrome <84 implements even older version of spec.\n", " width = entry.contentRect.width;\n", " height = entry.contentRect.height;\n", " }\n", "\n", " // Keep the size of the canvas and rubber band canvas in sync with\n", " // the canvas container.\n", " if (entry.devicePixelContentBoxSize) {\n", " // Chrome 84 implements new version of spec.\n", " canvas.setAttribute(\n", " 'width',\n", " entry.devicePixelContentBoxSize[0].inlineSize\n", " );\n", " canvas.setAttribute(\n", " 'height',\n", " entry.devicePixelContentBoxSize[0].blockSize\n", " );\n", " } else {\n", " canvas.setAttribute('width', width * fig.ratio);\n", " canvas.setAttribute('height', height * fig.ratio);\n", " }\n", " /* This rescales the canvas back to display pixels, so that it\n", " * appears correct on HiDPI screens. */\n", " canvas.style.width = width + 'px';\n", " canvas.style.height = height + 'px';\n", "\n", " rubberband_canvas.setAttribute('width', width);\n", " rubberband_canvas.setAttribute('height', height);\n", "\n", " // And update the size in Python. We ignore the initial 0/0 size\n", " // that occurs as the element is placed into the DOM, which should\n", " // otherwise not happen due to the minimum size styling.\n", " if (fig.ws.readyState == 1 && width != 0 && height != 0) {\n", " fig.request_resize(width, height);\n", " }\n", " }\n", " });\n", " this.resizeObserverInstance.observe(canvas_div);\n", "\n", " function on_mouse_event_closure(name) {\n", " /* User Agent sniffing is bad, but WebKit is busted:\n", " * https://bugs.webkit.org/show_bug.cgi?id=144526\n", " * https://bugs.webkit.org/show_bug.cgi?id=181818\n", " * The worst that happens here is that they get an extra browser\n", " * selection when dragging, if this check fails to catch them.\n", " */\n", " var UA = navigator.userAgent;\n", " var isWebKit = /AppleWebKit/.test(UA) && !/Chrome/.test(UA);\n", " if(isWebKit) {\n", " return function (event) {\n", " /* This prevents the web browser from automatically changing to\n", " * the text insertion cursor when the button is pressed. We\n", " * want to control all of the cursor setting manually through\n", " * the 'cursor' event from matplotlib */\n", " event.preventDefault()\n", " return fig.mouse_event(event, name);\n", " };\n", " } else {\n", " return function (event) {\n", " return fig.mouse_event(event, name);\n", " };\n", " }\n", " }\n", "\n", " canvas_div.addEventListener(\n", " 'mousedown',\n", " on_mouse_event_closure('button_press')\n", " );\n", " canvas_div.addEventListener(\n", " 'mouseup',\n", " on_mouse_event_closure('button_release')\n", " );\n", " canvas_div.addEventListener(\n", " 'dblclick',\n", " on_mouse_event_closure('dblclick')\n", " );\n", " // Throttle sequential mouse events to 1 every 20ms.\n", " canvas_div.addEventListener(\n", " 'mousemove',\n", " on_mouse_event_closure('motion_notify')\n", " );\n", "\n", " canvas_div.addEventListener(\n", " 'mouseenter',\n", " on_mouse_event_closure('figure_enter')\n", " );\n", " canvas_div.addEventListener(\n", " 'mouseleave',\n", " on_mouse_event_closure('figure_leave')\n", " );\n", "\n", " canvas_div.addEventListener('wheel', function (event) {\n", " if (event.deltaY < 0) {\n", " event.step = 1;\n", " } else {\n", " event.step = -1;\n", " }\n", " on_mouse_event_closure('scroll')(event);\n", " });\n", "\n", " canvas_div.appendChild(canvas);\n", " canvas_div.appendChild(rubberband_canvas);\n", "\n", " this.rubberband_context = rubberband_canvas.getContext('2d');\n", " this.rubberband_context.strokeStyle = '#000000';\n", "\n", " this._resize_canvas = function (width, height, forward) {\n", " if (forward) {\n", " canvas_div.style.width = width + 'px';\n", " canvas_div.style.height = height + 'px';\n", " }\n", " };\n", "\n", " // Disable right mouse context menu.\n", " canvas_div.addEventListener('contextmenu', function (_e) {\n", " event.preventDefault();\n", " return false;\n", " });\n", "\n", " function set_focus() {\n", " canvas.focus();\n", " canvas_div.focus();\n", " }\n", "\n", " window.setTimeout(set_focus, 100);\n", "};\n", "\n", "mpl.figure.prototype._init_toolbar = function () {\n", " var fig = this;\n", "\n", " var toolbar = document.createElement('div');\n", " toolbar.classList = 'mpl-toolbar';\n", " this.root.appendChild(toolbar);\n", "\n", " function on_click_closure(name) {\n", " return function (_event) {\n", " return fig.toolbar_button_onclick(name);\n", " };\n", " }\n", "\n", " function on_mouseover_closure(tooltip) {\n", " return function (event) {\n", " if (!event.currentTarget.disabled) {\n", " return fig.toolbar_button_onmouseover(tooltip);\n", " }\n", " };\n", " }\n", "\n", " fig.buttons = {};\n", " var buttonGroup = document.createElement('div');\n", " buttonGroup.classList = 'mpl-button-group';\n", " for (var toolbar_ind in mpl.toolbar_items) {\n", " var name = mpl.toolbar_items[toolbar_ind][0];\n", " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", " var image = mpl.toolbar_items[toolbar_ind][2];\n", " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", "\n", " if (!name) {\n", " /* Instead of a spacer, we start a new button group. */\n", " if (buttonGroup.hasChildNodes()) {\n", " toolbar.appendChild(buttonGroup);\n", " }\n", " buttonGroup = document.createElement('div');\n", " buttonGroup.classList = 'mpl-button-group';\n", " continue;\n", " }\n", "\n", " var button = (fig.buttons[name] = document.createElement('button'));\n", " button.classList = 'mpl-widget';\n", " button.setAttribute('role', 'button');\n", " button.setAttribute('aria-disabled', 'false');\n", " button.addEventListener('click', on_click_closure(method_name));\n", " button.addEventListener('mouseover', on_mouseover_closure(tooltip));\n", "\n", " var icon_img = document.createElement('img');\n", " icon_img.src = '_images/' + image + '.png';\n", " icon_img.srcset = '_images/' + image + '_large.png 2x';\n", " icon_img.alt = tooltip;\n", " button.appendChild(icon_img);\n", "\n", " buttonGroup.appendChild(button);\n", " }\n", "\n", " if (buttonGroup.hasChildNodes()) {\n", " toolbar.appendChild(buttonGroup);\n", " }\n", "\n", " var fmt_picker = document.createElement('select');\n", " fmt_picker.classList = 'mpl-widget';\n", " toolbar.appendChild(fmt_picker);\n", " this.format_dropdown = fmt_picker;\n", "\n", " for (var ind in mpl.extensions) {\n", " var fmt = mpl.extensions[ind];\n", " var option = document.createElement('option');\n", " option.selected = fmt === mpl.default_extension;\n", " option.innerHTML = fmt;\n", " fmt_picker.appendChild(option);\n", " }\n", "\n", " var status_bar = document.createElement('span');\n", " status_bar.classList = 'mpl-message';\n", " toolbar.appendChild(status_bar);\n", " this.message = status_bar;\n", "};\n", "\n", "mpl.figure.prototype.request_resize = function (x_pixels, y_pixels) {\n", " // Request matplotlib to resize the figure. Matplotlib will then trigger a resize in the client,\n", " // which will in turn request a refresh of the image.\n", " this.send_message('resize', { width: x_pixels, height: y_pixels });\n", "};\n", "\n", "mpl.figure.prototype.send_message = function (type, properties) {\n", " properties['type'] = type;\n", " properties['figure_id'] = this.id;\n", " this.ws.send(JSON.stringify(properties));\n", "};\n", "\n", "mpl.figure.prototype.send_draw_message = function () {\n", " if (!this.waiting) {\n", " this.waiting = true;\n", " this.ws.send(JSON.stringify({ type: 'draw', figure_id: this.id }));\n", " }\n", "};\n", "\n", "mpl.figure.prototype.handle_save = function (fig, _msg) {\n", " var format_dropdown = fig.format_dropdown;\n", " var format = format_dropdown.options[format_dropdown.selectedIndex].value;\n", " fig.ondownload(fig, format);\n", "};\n", "\n", "mpl.figure.prototype.handle_resize = function (fig, msg) {\n", " var size = msg['size'];\n", " if (size[0] !== fig.canvas.width || size[1] !== fig.canvas.height) {\n", " fig._resize_canvas(size[0], size[1], msg['forward']);\n", " fig.send_message('refresh', {});\n", " }\n", "};\n", "\n", "mpl.figure.prototype.handle_rubberband = function (fig, msg) {\n", " var x0 = msg['x0'] / fig.ratio;\n", " var y0 = (fig.canvas.height - msg['y0']) / fig.ratio;\n", " var x1 = msg['x1'] / fig.ratio;\n", " var y1 = (fig.canvas.height - msg['y1']) / fig.ratio;\n", " x0 = Math.floor(x0) + 0.5;\n", " y0 = Math.floor(y0) + 0.5;\n", " x1 = Math.floor(x1) + 0.5;\n", " y1 = Math.floor(y1) + 0.5;\n", " var min_x = Math.min(x0, x1);\n", " var min_y = Math.min(y0, y1);\n", " var width = Math.abs(x1 - x0);\n", " var height = Math.abs(y1 - y0);\n", "\n", " fig.rubberband_context.clearRect(\n", " 0,\n", " 0,\n", " fig.canvas.width / fig.ratio,\n", " fig.canvas.height / fig.ratio\n", " );\n", "\n", " fig.rubberband_context.strokeRect(min_x, min_y, width, height);\n", "};\n", "\n", "mpl.figure.prototype.handle_figure_label = function (fig, msg) {\n", " // Updates the figure title.\n", " fig.header.textContent = msg['label'];\n", "};\n", "\n", "mpl.figure.prototype.handle_cursor = function (fig, msg) {\n", " fig.canvas_div.style.cursor = msg['cursor'];\n", "};\n", "\n", "mpl.figure.prototype.handle_message = function (fig, msg) {\n", " fig.message.textContent = msg['message'];\n", "};\n", "\n", "mpl.figure.prototype.handle_draw = function (fig, _msg) {\n", " // Request the server to send over a new figure.\n", " fig.send_draw_message();\n", "};\n", "\n", "mpl.figure.prototype.handle_image_mode = function (fig, msg) {\n", " fig.image_mode = msg['mode'];\n", "};\n", "\n", "mpl.figure.prototype.handle_history_buttons = function (fig, msg) {\n", " for (var key in msg) {\n", " if (!(key in fig.buttons)) {\n", " continue;\n", " }\n", " fig.buttons[key].disabled = !msg[key];\n", " fig.buttons[key].setAttribute('aria-disabled', !msg[key]);\n", " }\n", "};\n", "\n", "mpl.figure.prototype.handle_navigate_mode = function (fig, msg) {\n", " if (msg['mode'] === 'PAN') {\n", " fig.buttons['Pan'].classList.add('active');\n", " fig.buttons['Zoom'].classList.remove('active');\n", " } else if (msg['mode'] === 'ZOOM') {\n", " fig.buttons['Pan'].classList.remove('active');\n", " fig.buttons['Zoom'].classList.add('active');\n", " } else {\n", " fig.buttons['Pan'].classList.remove('active');\n", " fig.buttons['Zoom'].classList.remove('active');\n", " }\n", "};\n", "\n", "mpl.figure.prototype.updated_canvas_event = function () {\n", " // Called whenever the canvas gets updated.\n", " this.send_message('ack', {});\n", "};\n", "\n", "// A function to construct a web socket function for onmessage handling.\n", "// Called in the figure constructor.\n", "mpl.figure.prototype._make_on_message_function = function (fig) {\n", " return function socket_on_message(evt) {\n", " if (evt.data instanceof Blob) {\n", " var img = evt.data;\n", " if (img.type !== 'image/png') {\n", " /* FIXME: We get \"Resource interpreted as Image but\n", " * transferred with MIME type text/plain:\" errors on\n", " * Chrome. But how to set the MIME type? It doesn't seem\n", " * to be part of the websocket stream */\n", " img.type = 'image/png';\n", " }\n", "\n", " /* Free the memory for the previous frames */\n", " if (fig.imageObj.src) {\n", " (window.URL || window.webkitURL).revokeObjectURL(\n", " fig.imageObj.src\n", " );\n", " }\n", "\n", " fig.imageObj.src = (window.URL || window.webkitURL).createObjectURL(\n", " img\n", " );\n", " fig.updated_canvas_event();\n", " fig.waiting = false;\n", " return;\n", " } else if (\n", " typeof evt.data === 'string' &&\n", " evt.data.slice(0, 21) === 'data:image/png;base64'\n", " ) {\n", " fig.imageObj.src = evt.data;\n", " fig.updated_canvas_event();\n", " fig.waiting = false;\n", " return;\n", " }\n", "\n", " var msg = JSON.parse(evt.data);\n", " var msg_type = msg['type'];\n", "\n", " // Call the \"handle_{type}\" callback, which takes\n", " // the figure and JSON message as its only arguments.\n", " try {\n", " var callback = fig['handle_' + msg_type];\n", " } catch (e) {\n", " console.log(\n", " \"No handler for the '\" + msg_type + \"' message type: \",\n", " msg\n", " );\n", " return;\n", " }\n", "\n", " if (callback) {\n", " try {\n", " // console.log(\"Handling '\" + msg_type + \"' message: \", msg);\n", " callback(fig, msg);\n", " } catch (e) {\n", " console.log(\n", " \"Exception inside the 'handler_\" + msg_type + \"' callback:\",\n", " e,\n", " e.stack,\n", " msg\n", " );\n", " }\n", " }\n", " };\n", "};\n", "\n", "\n", "/*\n", " * return a copy of an object with only non-object keys\n", " * we need this to avoid circular references\n", " * https://stackoverflow.com/a/24161582/3208463\n", " */\n", "function simpleKeys(original) {\n", " return Object.keys(original).reduce(function (obj, key) {\n", " if (typeof original[key] !== 'object') {\n", " obj[key] = original[key];\n", " }\n", " return obj;\n", " }, {});\n", "}\n", "\n", "mpl.figure.prototype.mouse_event = function (event, name) {\n", " if (name === 'button_press') {\n", " this.canvas.focus();\n", " this.canvas_div.focus();\n", " }\n", "\n", " // from https://stackoverflow.com/q/1114465\n", " var boundingRect = this.canvas.getBoundingClientRect();\n", " var x = (event.clientX - boundingRect.left) * this.ratio;\n", " var y = (event.clientY - boundingRect.top) * this.ratio;\n", "\n", " this.send_message(name, {\n", " x: x,\n", " y: y,\n", " button: event.button,\n", " step: event.step,\n", " guiEvent: simpleKeys(event),\n", " });\n", "\n", " return false;\n", "};\n", "\n", "mpl.figure.prototype._key_event_extra = function (_event, _name) {\n", " // Handle any extra behaviour associated with a key event\n", "};\n", "\n", "mpl.figure.prototype.key_event = function (event, name) {\n", " // Prevent repeat events\n", " if (name === 'key_press') {\n", " if (event.key === this._key) {\n", " return;\n", " } else {\n", " this._key = event.key;\n", " }\n", " }\n", " if (name === 'key_release') {\n", " this._key = null;\n", " }\n", "\n", " var value = '';\n", " if (event.ctrlKey && event.key !== 'Control') {\n", " value += 'ctrl+';\n", " }\n", " else if (event.altKey && event.key !== 'Alt') {\n", " value += 'alt+';\n", " }\n", " else if (event.shiftKey && event.key !== 'Shift') {\n", " value += 'shift+';\n", " }\n", "\n", " value += 'k' + event.key;\n", "\n", " this._key_event_extra(event, name);\n", "\n", " this.send_message(name, { key: value, guiEvent: simpleKeys(event) });\n", " return false;\n", "};\n", "\n", "mpl.figure.prototype.toolbar_button_onclick = function (name) {\n", " if (name === 'download') {\n", " this.handle_save(this, null);\n", " } else {\n", " this.send_message('toolbar_button', { name: name });\n", " }\n", "};\n", "\n", "mpl.figure.prototype.toolbar_button_onmouseover = function (tooltip) {\n", " this.message.textContent = tooltip;\n", "};\n", "\n", "///////////////// REMAINING CONTENT GENERATED BY embed_js.py /////////////////\n", "// prettier-ignore\n", "var _JSXTOOLS_RESIZE_OBSERVER=function(A){var t,i=new WeakMap,n=new WeakMap,a=new WeakMap,r=new WeakMap,o=new Set;function s(e){if(!(this instanceof s))throw new TypeError(\"Constructor requires 'new' operator\");i.set(this,e)}function h(){throw new TypeError(\"Function is not a constructor\")}function c(e,t,i,n){e=0 in arguments?Number(arguments[0]):0,t=1 in arguments?Number(arguments[1]):0,i=2 in arguments?Number(arguments[2]):0,n=3 in arguments?Number(arguments[3]):0,this.right=(this.x=this.left=e)+(this.width=i),this.bottom=(this.y=this.top=t)+(this.height=n),Object.freeze(this)}function d(){t=requestAnimationFrame(d);var s=new WeakMap,p=new Set;o.forEach((function(t){r.get(t).forEach((function(i){var r=t instanceof window.SVGElement,o=a.get(t),d=r?0:parseFloat(o.paddingTop),f=r?0:parseFloat(o.paddingRight),l=r?0:parseFloat(o.paddingBottom),u=r?0:parseFloat(o.paddingLeft),g=r?0:parseFloat(o.borderTopWidth),m=r?0:parseFloat(o.borderRightWidth),w=r?0:parseFloat(o.borderBottomWidth),b=u+f,F=d+l,v=(r?0:parseFloat(o.borderLeftWidth))+m,W=g+w,y=r?0:t.offsetHeight-W-t.clientHeight,E=r?0:t.offsetWidth-v-t.clientWidth,R=b+v,z=F+W,M=r?t.width:parseFloat(o.width)-R-E,O=r?t.height:parseFloat(o.height)-z-y;if(n.has(t)){var k=n.get(t);if(k[0]===M&&k[1]===O)return}n.set(t,[M,O]);var S=Object.create(h.prototype);S.target=t,S.contentRect=new c(u,d,M,O),s.has(i)||(s.set(i,[]),p.add(i)),s.get(i).push(S)}))})),p.forEach((function(e){i.get(e).call(e,s.get(e),e)}))}return s.prototype.observe=function(i){if(i instanceof window.Element){r.has(i)||(r.set(i,new Set),o.add(i),a.set(i,window.getComputedStyle(i)));var n=r.get(i);n.has(this)||n.add(this),cancelAnimationFrame(t),t=requestAnimationFrame(d)}},s.prototype.unobserve=function(i){if(i instanceof window.Element&&r.has(i)){var n=r.get(i);n.has(this)&&(n.delete(this),n.size||(r.delete(i),o.delete(i))),n.size||r.delete(i),o.size||cancelAnimationFrame(t)}},A.DOMRectReadOnly=c,A.ResizeObserver=s,A.ResizeObserverEntry=h,A}; // eslint-disable-line\n", "mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home\", \"home\"], [\"Back\", \"Back to previous view\", \"fa fa-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Left button pans, Right button zooms\\nx/y fixes axis, CTRL fixes aspect\", \"fa fa-arrows\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\\nx/y fixes axis\", \"fa fa-square-o\", \"zoom\"], [\"\", \"\", \"\", \"\"], [\"Download\", \"Download plot\", \"fa fa-floppy-o\", \"download\"]];\n", "\n", "mpl.extensions = [\"eps\", \"jpeg\", \"pgf\", \"pdf\", \"png\", \"ps\", \"raw\", \"svg\", \"tif\", \"webp\"];\n", "\n", "mpl.default_extension = \"png\";/* global mpl */\n", "\n", "var comm_websocket_adapter = function (comm) {\n", " // Create a \"websocket\"-like object which calls the given IPython comm\n", " // object with the appropriate methods. Currently this is a non binary\n", " // socket, so there is still some room for performance tuning.\n", " var ws = {};\n", "\n", " ws.binaryType = comm.kernel.ws.binaryType;\n", " ws.readyState = comm.kernel.ws.readyState;\n", " function updateReadyState(_event) {\n", " if (comm.kernel.ws) {\n", " ws.readyState = comm.kernel.ws.readyState;\n", " } else {\n", " ws.readyState = 3; // Closed state.\n", " }\n", " }\n", " comm.kernel.ws.addEventListener('open', updateReadyState);\n", " comm.kernel.ws.addEventListener('close', updateReadyState);\n", " comm.kernel.ws.addEventListener('error', updateReadyState);\n", "\n", " ws.close = function () {\n", " comm.close();\n", " };\n", " ws.send = function (m) {\n", " //console.log('sending', m);\n", " comm.send(m);\n", " };\n", " // Register the callback with on_msg.\n", " comm.on_msg(function (msg) {\n", " //console.log('receiving', msg['content']['data'], msg);\n", " var data = msg['content']['data'];\n", " if (data['blob'] !== undefined) {\n", " data = {\n", " data: new Blob(msg['buffers'], { type: data['blob'] }),\n", " };\n", " }\n", " // Pass the mpl event to the overridden (by mpl) onmessage function.\n", " ws.onmessage(data);\n", " });\n", " return ws;\n", "};\n", "\n", "mpl.mpl_figure_comm = function (comm, msg) {\n", " // This is the function which gets called when the mpl process\n", " // starts-up an IPython Comm through the \"matplotlib\" channel.\n", "\n", " var id = msg.content.data.id;\n", " // Get hold of the div created by the display call when the Comm\n", " // socket was opened in Python.\n", " var element = document.getElementById(id);\n", " var ws_proxy = comm_websocket_adapter(comm);\n", "\n", " function ondownload(figure, _format) {\n", " window.open(figure.canvas.toDataURL());\n", " }\n", "\n", " var fig = new mpl.figure(id, ws_proxy, ondownload, element);\n", "\n", " // Call onopen now - mpl needs it, as it is assuming we've passed it a real\n", " // web socket which is closed, not our websocket->open comm proxy.\n", " ws_proxy.onopen();\n", "\n", " fig.parent_element = element;\n", " fig.cell_info = mpl.find_output_cell(\"
\");\n", " if (!fig.cell_info) {\n", " console.error('Failed to find cell for figure', id, fig);\n", " return;\n", " }\n", " fig.cell_info[0].output_area.element.on(\n", " 'cleared',\n", " { fig: fig },\n", " fig._remove_fig_handler\n", " );\n", "};\n", "\n", "mpl.figure.prototype.handle_close = function (fig, msg) {\n", " var width = fig.canvas.width / fig.ratio;\n", " fig.cell_info[0].output_area.element.off(\n", " 'cleared',\n", " fig._remove_fig_handler\n", " );\n", " fig.resizeObserverInstance.unobserve(fig.canvas_div);\n", "\n", " // Update the output cell to use the data from the current canvas.\n", " fig.push_to_output();\n", " var dataURL = fig.canvas.toDataURL();\n", " // Re-enable the keyboard manager in IPython - without this line, in FF,\n", " // the notebook keyboard shortcuts fail.\n", " IPython.keyboard_manager.enable();\n", " fig.parent_element.innerHTML =\n", " '';\n", " fig.close_ws(fig, msg);\n", "};\n", "\n", "mpl.figure.prototype.close_ws = function (fig, msg) {\n", " fig.send_message('closing', msg);\n", " // fig.ws.close()\n", "};\n", "\n", "mpl.figure.prototype.push_to_output = function (_remove_interactive) {\n", " // Turn the data on the canvas into data in the output cell.\n", " var width = this.canvas.width / this.ratio;\n", " var dataURL = this.canvas.toDataURL();\n", " this.cell_info[1]['text/html'] =\n", " '';\n", "};\n", "\n", "mpl.figure.prototype.updated_canvas_event = function () {\n", " // Tell IPython that the notebook contents must change.\n", " IPython.notebook.set_dirty(true);\n", " this.send_message('ack', {});\n", " var fig = this;\n", " // Wait a second, then push the new image to the DOM so\n", " // that it is saved nicely (might be nice to debounce this).\n", " setTimeout(function () {\n", " fig.push_to_output();\n", " }, 1000);\n", "};\n", "\n", "mpl.figure.prototype._init_toolbar = function () {\n", " var fig = this;\n", "\n", " var toolbar = document.createElement('div');\n", " toolbar.classList = 'btn-toolbar';\n", " this.root.appendChild(toolbar);\n", "\n", " function on_click_closure(name) {\n", " return function (_event) {\n", " return fig.toolbar_button_onclick(name);\n", " };\n", " }\n", "\n", " function on_mouseover_closure(tooltip) {\n", " return function (event) {\n", " if (!event.currentTarget.disabled) {\n", " return fig.toolbar_button_onmouseover(tooltip);\n", " }\n", " };\n", " }\n", "\n", " fig.buttons = {};\n", " var buttonGroup = document.createElement('div');\n", " buttonGroup.classList = 'btn-group';\n", " var button;\n", " for (var toolbar_ind in mpl.toolbar_items) {\n", " var name = mpl.toolbar_items[toolbar_ind][0];\n", " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", " var image = mpl.toolbar_items[toolbar_ind][2];\n", " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", "\n", " if (!name) {\n", " /* Instead of a spacer, we start a new button group. */\n", " if (buttonGroup.hasChildNodes()) {\n", " toolbar.appendChild(buttonGroup);\n", " }\n", " buttonGroup = document.createElement('div');\n", " buttonGroup.classList = 'btn-group';\n", " continue;\n", " }\n", "\n", " button = fig.buttons[name] = document.createElement('button');\n", " button.classList = 'btn btn-default';\n", " button.href = '#';\n", " button.title = name;\n", " button.innerHTML = '';\n", " button.addEventListener('click', on_click_closure(method_name));\n", " button.addEventListener('mouseover', on_mouseover_closure(tooltip));\n", " buttonGroup.appendChild(button);\n", " }\n", "\n", " if (buttonGroup.hasChildNodes()) {\n", " toolbar.appendChild(buttonGroup);\n", " }\n", "\n", " // Add the status bar.\n", " var status_bar = document.createElement('span');\n", " status_bar.classList = 'mpl-message pull-right';\n", " toolbar.appendChild(status_bar);\n", " this.message = status_bar;\n", "\n", " // Add the close button to the window.\n", " var buttongrp = document.createElement('div');\n", " buttongrp.classList = 'btn-group inline pull-right';\n", " button = document.createElement('button');\n", " button.classList = 'btn btn-mini btn-primary';\n", " button.href = '#';\n", " button.title = 'Stop Interaction';\n", " button.innerHTML = '';\n", " button.addEventListener('click', function (_evt) {\n", " fig.handle_close(fig, {});\n", " });\n", " button.addEventListener(\n", " 'mouseover',\n", " on_mouseover_closure('Stop Interaction')\n", " );\n", " buttongrp.appendChild(button);\n", " var titlebar = this.root.querySelector('.ui-dialog-titlebar');\n", " titlebar.insertBefore(buttongrp, titlebar.firstChild);\n", "};\n", "\n", "mpl.figure.prototype._remove_fig_handler = function (event) {\n", " var fig = event.data.fig;\n", " if (event.target !== this) {\n", " // Ignore bubbled events from children.\n", " return;\n", " }\n", " fig.close_ws(fig, {});\n", "};\n", "\n", "mpl.figure.prototype._root_extra_style = function (el) {\n", " el.style.boxSizing = 'content-box'; // override notebook setting of border-box.\n", "};\n", "\n", "mpl.figure.prototype._canvas_extra_style = function (el) {\n", " // this is important to make the div 'focusable\n", " el.setAttribute('tabindex', 0);\n", " // reach out to IPython and tell the keyboard manager to turn it's self\n", " // off when our div gets focus\n", "\n", " // location in version 3\n", " if (IPython.notebook.keyboard_manager) {\n", " IPython.notebook.keyboard_manager.register_events(el);\n", " } else {\n", " // location in version 2\n", " IPython.keyboard_manager.register_events(el);\n", " }\n", "};\n", "\n", "mpl.figure.prototype._key_event_extra = function (event, _name) {\n", " // Check for shift+enter\n", " if (event.shiftKey && event.which === 13) {\n", " this.canvas_div.blur();\n", " // select the cell after this one\n", " var index = IPython.notebook.find_cell_index(this.cell_info[0]);\n", " IPython.notebook.select(index + 1);\n", " }\n", "};\n", "\n", "mpl.figure.prototype.handle_save = function (fig, _msg) {\n", " fig.ondownload(fig, null);\n", "};\n", "\n", "mpl.find_output_cell = function (html_output) {\n", " // Return the cell and output element which can be found *uniquely* in the notebook.\n", " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", " // IPython event is triggered only after the cells have been serialised, which for\n", " // our purposes (turning an active figure into a static one), is too late.\n", " var cells = IPython.notebook.get_cells();\n", " var ncells = cells.length;\n", " for (var i = 0; i < ncells; i++) {\n", " var cell = cells[i];\n", " if (cell.cell_type === 'code') {\n", " for (var j = 0; j < cell.output_area.outputs.length; j++) {\n", " var data = cell.output_area.outputs[j];\n", " if (data.data) {\n", " // IPython >= 3 moved mimebundle to data attribute of output\n", " data = data.data;\n", " }\n", " if (data['text/html'] === html_output) {\n", " return [cell, data, j];\n", " }\n", " }\n", " }\n", " }\n", "};\n", "\n", "// Register the function which deals with the matplotlib target/channel.\n", "// The kernel may be null if the page has been refreshed.\n", "if (IPython.notebook.kernel !== null) {\n", " IPython.notebook.kernel.comm_manager.register_target(\n", " 'matplotlib',\n", " mpl.mpl_figure_comm\n", " );\n", "}\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ "(0.0, 15.0)" ] }, "execution_count": 107, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fig = plt.figure()\n", "ax = fig.add_subplot(projection='3d')\n", "ax.set_xlim([-2,2])\n", "ax.set_ylim([-2,2])\n", "ax.set_zlim([0,15])" ] }, { "cell_type": "code", "execution_count": 108, "id": "weighted-veteran", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0.002826002117435616\n", "(2.0194986124346066, 0.2812040553381623, 0.050002245742574475)\n", "-0.0007988621780734562 -0.2375130005865349 -42.97689226250465 -0.7791957992795088\n", "0.002826002117435616\n" ] } ], "source": [ "sol = hill_climbing()\n", "#sol = [2.02310938, 0.25113418, 0.05218225]\n", "# L, d, w\n", "print(sol)\n", "print(g1(*sol), g2(*sol), g3(*sol), g4(*sol))\n", "print(score(*sol))" ] }, { "cell_type": "code", "execution_count": 109, "id": "biblical-kentucky", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.0027511436522230925" ] }, "execution_count": 109, "metadata": {}, "output_type": "execute_result" } ], "source": [ "old_sol = [2.02310938, 0.25113418, 0.05218225]\n", "score(*old_sol)" ] }, { "cell_type": "code", "execution_count": 110, "id": "wired-meeting", "metadata": {}, "outputs": [ { "data": { "application/javascript": [ "/* Put everything inside the global mpl namespace */\n", "/* global mpl */\n", "window.mpl = {};\n", "\n", "mpl.get_websocket_type = function () {\n", " if (typeof WebSocket !== 'undefined') {\n", " return WebSocket;\n", " } else if (typeof MozWebSocket !== 'undefined') {\n", " return MozWebSocket;\n", " } else {\n", " alert(\n", " 'Your browser does not have WebSocket support. ' +\n", " 'Please try Chrome, Safari or Firefox ≥ 6. ' +\n", " 'Firefox 4 and 5 are also supported but you ' +\n", " 'have to enable WebSockets in about:config.'\n", " );\n", " }\n", "};\n", "\n", "mpl.figure = function (figure_id, websocket, ondownload, parent_element) {\n", " this.id = figure_id;\n", "\n", " this.ws = websocket;\n", "\n", " this.supports_binary = this.ws.binaryType !== undefined;\n", "\n", " if (!this.supports_binary) {\n", " var warnings = document.getElementById('mpl-warnings');\n", " if (warnings) {\n", " warnings.style.display = 'block';\n", " warnings.textContent =\n", " 'This browser does not support binary websocket messages. ' +\n", " 'Performance may be slow.';\n", " }\n", " }\n", "\n", " this.imageObj = new Image();\n", "\n", " this.context = undefined;\n", " this.message = undefined;\n", " this.canvas = undefined;\n", " this.rubberband_canvas = undefined;\n", " this.rubberband_context = undefined;\n", " this.format_dropdown = undefined;\n", "\n", " this.image_mode = 'full';\n", "\n", " this.root = document.createElement('div');\n", " this.root.setAttribute('style', 'display: inline-block');\n", " this._root_extra_style(this.root);\n", "\n", " parent_element.appendChild(this.root);\n", "\n", " this._init_header(this);\n", " this._init_canvas(this);\n", " this._init_toolbar(this);\n", "\n", " var fig = this;\n", "\n", " this.waiting = false;\n", "\n", " this.ws.onopen = function () {\n", " fig.send_message('supports_binary', { value: fig.supports_binary });\n", " fig.send_message('send_image_mode', {});\n", " if (fig.ratio !== 1) {\n", " fig.send_message('set_device_pixel_ratio', {\n", " device_pixel_ratio: fig.ratio,\n", " });\n", " }\n", " fig.send_message('refresh', {});\n", " };\n", "\n", " this.imageObj.onload = function () {\n", " if (fig.image_mode === 'full') {\n", " // Full images could contain transparency (where diff images\n", " // almost always do), so we need to clear the canvas so that\n", " // there is no ghosting.\n", " fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n", " }\n", " fig.context.drawImage(fig.imageObj, 0, 0);\n", " };\n", "\n", " this.imageObj.onunload = function () {\n", " fig.ws.close();\n", " };\n", "\n", " this.ws.onmessage = this._make_on_message_function(this);\n", "\n", " this.ondownload = ondownload;\n", "};\n", "\n", "mpl.figure.prototype._init_header = function () {\n", " var titlebar = document.createElement('div');\n", " titlebar.classList =\n", " 'ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix';\n", " var titletext = document.createElement('div');\n", " titletext.classList = 'ui-dialog-title';\n", " titletext.setAttribute(\n", " 'style',\n", " 'width: 100%; text-align: center; padding: 3px;'\n", " );\n", " titlebar.appendChild(titletext);\n", " this.root.appendChild(titlebar);\n", " this.header = titletext;\n", "};\n", "\n", "mpl.figure.prototype._canvas_extra_style = function (_canvas_div) {};\n", "\n", "mpl.figure.prototype._root_extra_style = function (_canvas_div) {};\n", "\n", "mpl.figure.prototype._init_canvas = function () {\n", " var fig = this;\n", "\n", " var canvas_div = (this.canvas_div = document.createElement('div'));\n", " canvas_div.setAttribute('tabindex', '0');\n", " canvas_div.setAttribute(\n", " 'style',\n", " 'border: 1px solid #ddd;' +\n", " 'box-sizing: content-box;' +\n", " 'clear: both;' +\n", " 'min-height: 1px;' +\n", " 'min-width: 1px;' +\n", " 'outline: 0;' +\n", " 'overflow: hidden;' +\n", " 'position: relative;' +\n", " 'resize: both;' +\n", " 'z-index: 2;'\n", " );\n", "\n", " function on_keyboard_event_closure(name) {\n", " return function (event) {\n", " return fig.key_event(event, name);\n", " };\n", " }\n", "\n", " canvas_div.addEventListener(\n", " 'keydown',\n", " on_keyboard_event_closure('key_press')\n", " );\n", " canvas_div.addEventListener(\n", " 'keyup',\n", " on_keyboard_event_closure('key_release')\n", " );\n", "\n", " this._canvas_extra_style(canvas_div);\n", " this.root.appendChild(canvas_div);\n", "\n", " var canvas = (this.canvas = document.createElement('canvas'));\n", " canvas.classList.add('mpl-canvas');\n", " canvas.setAttribute(\n", " 'style',\n", " 'box-sizing: content-box;' +\n", " 'pointer-events: none;' +\n", " 'position: relative;' +\n", " 'z-index: 0;'\n", " );\n", "\n", " this.context = canvas.getContext('2d');\n", "\n", " var backingStore =\n", " this.context.backingStorePixelRatio ||\n", " this.context.webkitBackingStorePixelRatio ||\n", " this.context.mozBackingStorePixelRatio ||\n", " this.context.msBackingStorePixelRatio ||\n", " this.context.oBackingStorePixelRatio ||\n", " this.context.backingStorePixelRatio ||\n", " 1;\n", "\n", " this.ratio = (window.devicePixelRatio || 1) / backingStore;\n", "\n", " var rubberband_canvas = (this.rubberband_canvas = document.createElement(\n", " 'canvas'\n", " ));\n", " rubberband_canvas.setAttribute(\n", " 'style',\n", " 'box-sizing: content-box;' +\n", " 'left: 0;' +\n", " 'pointer-events: none;' +\n", " 'position: absolute;' +\n", " 'top: 0;' +\n", " 'z-index: 1;'\n", " );\n", "\n", " // Apply a ponyfill if ResizeObserver is not implemented by browser.\n", " if (this.ResizeObserver === undefined) {\n", " if (window.ResizeObserver !== undefined) {\n", " this.ResizeObserver = window.ResizeObserver;\n", " } else {\n", " var obs = _JSXTOOLS_RESIZE_OBSERVER({});\n", " this.ResizeObserver = obs.ResizeObserver;\n", " }\n", " }\n", "\n", " this.resizeObserverInstance = new this.ResizeObserver(function (entries) {\n", " var nentries = entries.length;\n", " for (var i = 0; i < nentries; i++) {\n", " var entry = entries[i];\n", " var width, height;\n", " if (entry.contentBoxSize) {\n", " if (entry.contentBoxSize instanceof Array) {\n", " // Chrome 84 implements new version of spec.\n", " width = entry.contentBoxSize[0].inlineSize;\n", " height = entry.contentBoxSize[0].blockSize;\n", " } else {\n", " // Firefox implements old version of spec.\n", " width = entry.contentBoxSize.inlineSize;\n", " height = entry.contentBoxSize.blockSize;\n", " }\n", " } else {\n", " // Chrome <84 implements even older version of spec.\n", " width = entry.contentRect.width;\n", " height = entry.contentRect.height;\n", " }\n", "\n", " // Keep the size of the canvas and rubber band canvas in sync with\n", " // the canvas container.\n", " if (entry.devicePixelContentBoxSize) {\n", " // Chrome 84 implements new version of spec.\n", " canvas.setAttribute(\n", " 'width',\n", " entry.devicePixelContentBoxSize[0].inlineSize\n", " );\n", " canvas.setAttribute(\n", " 'height',\n", " entry.devicePixelContentBoxSize[0].blockSize\n", " );\n", " } else {\n", " canvas.setAttribute('width', width * fig.ratio);\n", " canvas.setAttribute('height', height * fig.ratio);\n", " }\n", " /* This rescales the canvas back to display pixels, so that it\n", " * appears correct on HiDPI screens. */\n", " canvas.style.width = width + 'px';\n", " canvas.style.height = height + 'px';\n", "\n", " rubberband_canvas.setAttribute('width', width);\n", " rubberband_canvas.setAttribute('height', height);\n", "\n", " // And update the size in Python. We ignore the initial 0/0 size\n", " // that occurs as the element is placed into the DOM, which should\n", " // otherwise not happen due to the minimum size styling.\n", " if (fig.ws.readyState == 1 && width != 0 && height != 0) {\n", " fig.request_resize(width, height);\n", " }\n", " }\n", " });\n", " this.resizeObserverInstance.observe(canvas_div);\n", "\n", " function on_mouse_event_closure(name) {\n", " /* User Agent sniffing is bad, but WebKit is busted:\n", " * https://bugs.webkit.org/show_bug.cgi?id=144526\n", " * https://bugs.webkit.org/show_bug.cgi?id=181818\n", " * The worst that happens here is that they get an extra browser\n", " * selection when dragging, if this check fails to catch them.\n", " */\n", " var UA = navigator.userAgent;\n", " var isWebKit = /AppleWebKit/.test(UA) && !/Chrome/.test(UA);\n", " if(isWebKit) {\n", " return function (event) {\n", " /* This prevents the web browser from automatically changing to\n", " * the text insertion cursor when the button is pressed. We\n", " * want to control all of the cursor setting manually through\n", " * the 'cursor' event from matplotlib */\n", " event.preventDefault()\n", " return fig.mouse_event(event, name);\n", " };\n", " } else {\n", " return function (event) {\n", " return fig.mouse_event(event, name);\n", " };\n", " }\n", " }\n", "\n", " canvas_div.addEventListener(\n", " 'mousedown',\n", " on_mouse_event_closure('button_press')\n", " );\n", " canvas_div.addEventListener(\n", " 'mouseup',\n", " on_mouse_event_closure('button_release')\n", " );\n", " canvas_div.addEventListener(\n", " 'dblclick',\n", " on_mouse_event_closure('dblclick')\n", " );\n", " // Throttle sequential mouse events to 1 every 20ms.\n", " canvas_div.addEventListener(\n", " 'mousemove',\n", " on_mouse_event_closure('motion_notify')\n", " );\n", "\n", " canvas_div.addEventListener(\n", " 'mouseenter',\n", " on_mouse_event_closure('figure_enter')\n", " );\n", " canvas_div.addEventListener(\n", " 'mouseleave',\n", " on_mouse_event_closure('figure_leave')\n", " );\n", "\n", " canvas_div.addEventListener('wheel', function (event) {\n", " if (event.deltaY < 0) {\n", " event.step = 1;\n", " } else {\n", " event.step = -1;\n", " }\n", " on_mouse_event_closure('scroll')(event);\n", " });\n", "\n", " canvas_div.appendChild(canvas);\n", " canvas_div.appendChild(rubberband_canvas);\n", "\n", " this.rubberband_context = rubberband_canvas.getContext('2d');\n", " this.rubberband_context.strokeStyle = '#000000';\n", "\n", " this._resize_canvas = function (width, height, forward) {\n", " if (forward) {\n", " canvas_div.style.width = width + 'px';\n", " canvas_div.style.height = height + 'px';\n", " }\n", " };\n", "\n", " // Disable right mouse context menu.\n", " canvas_div.addEventListener('contextmenu', function (_e) {\n", " event.preventDefault();\n", " return false;\n", " });\n", "\n", " function set_focus() {\n", " canvas.focus();\n", " canvas_div.focus();\n", " }\n", "\n", " window.setTimeout(set_focus, 100);\n", "};\n", "\n", "mpl.figure.prototype._init_toolbar = function () {\n", " var fig = this;\n", "\n", " var toolbar = document.createElement('div');\n", " toolbar.classList = 'mpl-toolbar';\n", " this.root.appendChild(toolbar);\n", "\n", " function on_click_closure(name) {\n", " return function (_event) {\n", " return fig.toolbar_button_onclick(name);\n", " };\n", " }\n", "\n", " function on_mouseover_closure(tooltip) {\n", " return function (event) {\n", " if (!event.currentTarget.disabled) {\n", " return fig.toolbar_button_onmouseover(tooltip);\n", " }\n", " };\n", " }\n", "\n", " fig.buttons = {};\n", " var buttonGroup = document.createElement('div');\n", " buttonGroup.classList = 'mpl-button-group';\n", " for (var toolbar_ind in mpl.toolbar_items) {\n", " var name = mpl.toolbar_items[toolbar_ind][0];\n", " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", " var image = mpl.toolbar_items[toolbar_ind][2];\n", " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", "\n", " if (!name) {\n", " /* Instead of a spacer, we start a new button group. */\n", " if (buttonGroup.hasChildNodes()) {\n", " toolbar.appendChild(buttonGroup);\n", " }\n", " buttonGroup = document.createElement('div');\n", " buttonGroup.classList = 'mpl-button-group';\n", " continue;\n", " }\n", "\n", " var button = (fig.buttons[name] = document.createElement('button'));\n", " button.classList = 'mpl-widget';\n", " button.setAttribute('role', 'button');\n", " button.setAttribute('aria-disabled', 'false');\n", " button.addEventListener('click', on_click_closure(method_name));\n", " button.addEventListener('mouseover', on_mouseover_closure(tooltip));\n", "\n", " var icon_img = document.createElement('img');\n", " icon_img.src = '_images/' + image + '.png';\n", " icon_img.srcset = '_images/' + image + '_large.png 2x';\n", " icon_img.alt = tooltip;\n", " button.appendChild(icon_img);\n", "\n", " buttonGroup.appendChild(button);\n", " }\n", "\n", " if (buttonGroup.hasChildNodes()) {\n", " toolbar.appendChild(buttonGroup);\n", " }\n", "\n", " var fmt_picker = document.createElement('select');\n", " fmt_picker.classList = 'mpl-widget';\n", " toolbar.appendChild(fmt_picker);\n", " this.format_dropdown = fmt_picker;\n", "\n", " for (var ind in mpl.extensions) {\n", " var fmt = mpl.extensions[ind];\n", " var option = document.createElement('option');\n", " option.selected = fmt === mpl.default_extension;\n", " option.innerHTML = fmt;\n", " fmt_picker.appendChild(option);\n", " }\n", "\n", " var status_bar = document.createElement('span');\n", " status_bar.classList = 'mpl-message';\n", " toolbar.appendChild(status_bar);\n", " this.message = status_bar;\n", "};\n", "\n", "mpl.figure.prototype.request_resize = function (x_pixels, y_pixels) {\n", " // Request matplotlib to resize the figure. Matplotlib will then trigger a resize in the client,\n", " // which will in turn request a refresh of the image.\n", " this.send_message('resize', { width: x_pixels, height: y_pixels });\n", "};\n", "\n", "mpl.figure.prototype.send_message = function (type, properties) {\n", " properties['type'] = type;\n", " properties['figure_id'] = this.id;\n", " this.ws.send(JSON.stringify(properties));\n", "};\n", "\n", "mpl.figure.prototype.send_draw_message = function () {\n", " if (!this.waiting) {\n", " this.waiting = true;\n", " this.ws.send(JSON.stringify({ type: 'draw', figure_id: this.id }));\n", " }\n", "};\n", "\n", "mpl.figure.prototype.handle_save = function (fig, _msg) {\n", " var format_dropdown = fig.format_dropdown;\n", " var format = format_dropdown.options[format_dropdown.selectedIndex].value;\n", " fig.ondownload(fig, format);\n", "};\n", "\n", "mpl.figure.prototype.handle_resize = function (fig, msg) {\n", " var size = msg['size'];\n", " if (size[0] !== fig.canvas.width || size[1] !== fig.canvas.height) {\n", " fig._resize_canvas(size[0], size[1], msg['forward']);\n", " fig.send_message('refresh', {});\n", " }\n", "};\n", "\n", "mpl.figure.prototype.handle_rubberband = function (fig, msg) {\n", " var x0 = msg['x0'] / fig.ratio;\n", " var y0 = (fig.canvas.height - msg['y0']) / fig.ratio;\n", " var x1 = msg['x1'] / fig.ratio;\n", " var y1 = (fig.canvas.height - msg['y1']) / fig.ratio;\n", " x0 = Math.floor(x0) + 0.5;\n", " y0 = Math.floor(y0) + 0.5;\n", " x1 = Math.floor(x1) + 0.5;\n", " y1 = Math.floor(y1) + 0.5;\n", " var min_x = Math.min(x0, x1);\n", " var min_y = Math.min(y0, y1);\n", " var width = Math.abs(x1 - x0);\n", " var height = Math.abs(y1 - y0);\n", "\n", " fig.rubberband_context.clearRect(\n", " 0,\n", " 0,\n", " fig.canvas.width / fig.ratio,\n", " fig.canvas.height / fig.ratio\n", " );\n", "\n", " fig.rubberband_context.strokeRect(min_x, min_y, width, height);\n", "};\n", "\n", "mpl.figure.prototype.handle_figure_label = function (fig, msg) {\n", " // Updates the figure title.\n", " fig.header.textContent = msg['label'];\n", "};\n", "\n", "mpl.figure.prototype.handle_cursor = function (fig, msg) {\n", " fig.canvas_div.style.cursor = msg['cursor'];\n", "};\n", "\n", "mpl.figure.prototype.handle_message = function (fig, msg) {\n", " fig.message.textContent = msg['message'];\n", "};\n", "\n", "mpl.figure.prototype.handle_draw = function (fig, _msg) {\n", " // Request the server to send over a new figure.\n", " fig.send_draw_message();\n", "};\n", "\n", "mpl.figure.prototype.handle_image_mode = function (fig, msg) {\n", " fig.image_mode = msg['mode'];\n", "};\n", "\n", "mpl.figure.prototype.handle_history_buttons = function (fig, msg) {\n", " for (var key in msg) {\n", " if (!(key in fig.buttons)) {\n", " continue;\n", " }\n", " fig.buttons[key].disabled = !msg[key];\n", " fig.buttons[key].setAttribute('aria-disabled', !msg[key]);\n", " }\n", "};\n", "\n", "mpl.figure.prototype.handle_navigate_mode = function (fig, msg) {\n", " if (msg['mode'] === 'PAN') {\n", " fig.buttons['Pan'].classList.add('active');\n", " fig.buttons['Zoom'].classList.remove('active');\n", " } else if (msg['mode'] === 'ZOOM') {\n", " fig.buttons['Pan'].classList.remove('active');\n", " fig.buttons['Zoom'].classList.add('active');\n", " } else {\n", " fig.buttons['Pan'].classList.remove('active');\n", " fig.buttons['Zoom'].classList.remove('active');\n", " }\n", "};\n", "\n", "mpl.figure.prototype.updated_canvas_event = function () {\n", " // Called whenever the canvas gets updated.\n", " this.send_message('ack', {});\n", "};\n", "\n", "// A function to construct a web socket function for onmessage handling.\n", "// Called in the figure constructor.\n", "mpl.figure.prototype._make_on_message_function = function (fig) {\n", " return function socket_on_message(evt) {\n", " if (evt.data instanceof Blob) {\n", " var img = evt.data;\n", " if (img.type !== 'image/png') {\n", " /* FIXME: We get \"Resource interpreted as Image but\n", " * transferred with MIME type text/plain:\" errors on\n", " * Chrome. But how to set the MIME type? It doesn't seem\n", " * to be part of the websocket stream */\n", " img.type = 'image/png';\n", " }\n", "\n", " /* Free the memory for the previous frames */\n", " if (fig.imageObj.src) {\n", " (window.URL || window.webkitURL).revokeObjectURL(\n", " fig.imageObj.src\n", " );\n", " }\n", "\n", " fig.imageObj.src = (window.URL || window.webkitURL).createObjectURL(\n", " img\n", " );\n", " fig.updated_canvas_event();\n", " fig.waiting = false;\n", " return;\n", " } else if (\n", " typeof evt.data === 'string' &&\n", " evt.data.slice(0, 21) === 'data:image/png;base64'\n", " ) {\n", " fig.imageObj.src = evt.data;\n", " fig.updated_canvas_event();\n", " fig.waiting = false;\n", " return;\n", " }\n", "\n", " var msg = JSON.parse(evt.data);\n", " var msg_type = msg['type'];\n", "\n", " // Call the \"handle_{type}\" callback, which takes\n", " // the figure and JSON message as its only arguments.\n", " try {\n", " var callback = fig['handle_' + msg_type];\n", " } catch (e) {\n", " console.log(\n", " \"No handler for the '\" + msg_type + \"' message type: \",\n", " msg\n", " );\n", " return;\n", " }\n", "\n", " if (callback) {\n", " try {\n", " // console.log(\"Handling '\" + msg_type + \"' message: \", msg);\n", " callback(fig, msg);\n", " } catch (e) {\n", " console.log(\n", " \"Exception inside the 'handler_\" + msg_type + \"' callback:\",\n", " e,\n", " e.stack,\n", " msg\n", " );\n", " }\n", " }\n", " };\n", "};\n", "\n", "\n", "/*\n", " * return a copy of an object with only non-object keys\n", " * we need this to avoid circular references\n", " * https://stackoverflow.com/a/24161582/3208463\n", " */\n", "function simpleKeys(original) {\n", " return Object.keys(original).reduce(function (obj, key) {\n", " if (typeof original[key] !== 'object') {\n", " obj[key] = original[key];\n", " }\n", " return obj;\n", " }, {});\n", "}\n", "\n", "mpl.figure.prototype.mouse_event = function (event, name) {\n", " if (name === 'button_press') {\n", " this.canvas.focus();\n", " this.canvas_div.focus();\n", " }\n", "\n", " // from https://stackoverflow.com/q/1114465\n", " var boundingRect = this.canvas.getBoundingClientRect();\n", " var x = (event.clientX - boundingRect.left) * this.ratio;\n", " var y = (event.clientY - boundingRect.top) * this.ratio;\n", "\n", " this.send_message(name, {\n", " x: x,\n", " y: y,\n", " button: event.button,\n", " step: event.step,\n", " guiEvent: simpleKeys(event),\n", " });\n", "\n", " return false;\n", "};\n", "\n", "mpl.figure.prototype._key_event_extra = function (_event, _name) {\n", " // Handle any extra behaviour associated with a key event\n", "};\n", "\n", "mpl.figure.prototype.key_event = function (event, name) {\n", " // Prevent repeat events\n", " if (name === 'key_press') {\n", " if (event.key === this._key) {\n", " return;\n", " } else {\n", " this._key = event.key;\n", " }\n", " }\n", " if (name === 'key_release') {\n", " this._key = null;\n", " }\n", "\n", " var value = '';\n", " if (event.ctrlKey && event.key !== 'Control') {\n", " value += 'ctrl+';\n", " }\n", " else if (event.altKey && event.key !== 'Alt') {\n", " value += 'alt+';\n", " }\n", " else if (event.shiftKey && event.key !== 'Shift') {\n", " value += 'shift+';\n", " }\n", "\n", " value += 'k' + event.key;\n", "\n", " this._key_event_extra(event, name);\n", "\n", " this.send_message(name, { key: value, guiEvent: simpleKeys(event) });\n", " return false;\n", "};\n", "\n", "mpl.figure.prototype.toolbar_button_onclick = function (name) {\n", " if (name === 'download') {\n", " this.handle_save(this, null);\n", " } else {\n", " this.send_message('toolbar_button', { name: name });\n", " }\n", "};\n", "\n", "mpl.figure.prototype.toolbar_button_onmouseover = function (tooltip) {\n", " this.message.textContent = tooltip;\n", "};\n", "\n", "///////////////// REMAINING CONTENT GENERATED BY embed_js.py /////////////////\n", "// prettier-ignore\n", "var _JSXTOOLS_RESIZE_OBSERVER=function(A){var t,i=new WeakMap,n=new WeakMap,a=new WeakMap,r=new WeakMap,o=new Set;function s(e){if(!(this instanceof s))throw new TypeError(\"Constructor requires 'new' operator\");i.set(this,e)}function h(){throw new TypeError(\"Function is not a constructor\")}function c(e,t,i,n){e=0 in arguments?Number(arguments[0]):0,t=1 in arguments?Number(arguments[1]):0,i=2 in arguments?Number(arguments[2]):0,n=3 in arguments?Number(arguments[3]):0,this.right=(this.x=this.left=e)+(this.width=i),this.bottom=(this.y=this.top=t)+(this.height=n),Object.freeze(this)}function d(){t=requestAnimationFrame(d);var s=new WeakMap,p=new Set;o.forEach((function(t){r.get(t).forEach((function(i){var r=t instanceof window.SVGElement,o=a.get(t),d=r?0:parseFloat(o.paddingTop),f=r?0:parseFloat(o.paddingRight),l=r?0:parseFloat(o.paddingBottom),u=r?0:parseFloat(o.paddingLeft),g=r?0:parseFloat(o.borderTopWidth),m=r?0:parseFloat(o.borderRightWidth),w=r?0:parseFloat(o.borderBottomWidth),b=u+f,F=d+l,v=(r?0:parseFloat(o.borderLeftWidth))+m,W=g+w,y=r?0:t.offsetHeight-W-t.clientHeight,E=r?0:t.offsetWidth-v-t.clientWidth,R=b+v,z=F+W,M=r?t.width:parseFloat(o.width)-R-E,O=r?t.height:parseFloat(o.height)-z-y;if(n.has(t)){var k=n.get(t);if(k[0]===M&&k[1]===O)return}n.set(t,[M,O]);var S=Object.create(h.prototype);S.target=t,S.contentRect=new c(u,d,M,O),s.has(i)||(s.set(i,[]),p.add(i)),s.get(i).push(S)}))})),p.forEach((function(e){i.get(e).call(e,s.get(e),e)}))}return s.prototype.observe=function(i){if(i instanceof window.Element){r.has(i)||(r.set(i,new Set),o.add(i),a.set(i,window.getComputedStyle(i)));var n=r.get(i);n.has(this)||n.add(this),cancelAnimationFrame(t),t=requestAnimationFrame(d)}},s.prototype.unobserve=function(i){if(i instanceof window.Element&&r.has(i)){var n=r.get(i);n.has(this)&&(n.delete(this),n.size||(r.delete(i),o.delete(i))),n.size||r.delete(i),o.size||cancelAnimationFrame(t)}},A.DOMRectReadOnly=c,A.ResizeObserver=s,A.ResizeObserverEntry=h,A}; // eslint-disable-line\n", "mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home\", \"home\"], [\"Back\", \"Back to previous view\", \"fa fa-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Left button pans, Right button zooms\\nx/y fixes axis, CTRL fixes aspect\", \"fa fa-arrows\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\\nx/y fixes axis\", \"fa fa-square-o\", \"zoom\"], [\"\", \"\", \"\", \"\"], [\"Download\", \"Download plot\", \"fa fa-floppy-o\", \"download\"]];\n", "\n", "mpl.extensions = [\"eps\", \"jpeg\", \"pgf\", \"pdf\", \"png\", \"ps\", \"raw\", \"svg\", \"tif\", \"webp\"];\n", "\n", "mpl.default_extension = \"png\";/* global mpl */\n", "\n", "var comm_websocket_adapter = function (comm) {\n", " // Create a \"websocket\"-like object which calls the given IPython comm\n", " // object with the appropriate methods. Currently this is a non binary\n", " // socket, so there is still some room for performance tuning.\n", " var ws = {};\n", "\n", " ws.binaryType = comm.kernel.ws.binaryType;\n", " ws.readyState = comm.kernel.ws.readyState;\n", " function updateReadyState(_event) {\n", " if (comm.kernel.ws) {\n", " ws.readyState = comm.kernel.ws.readyState;\n", " } else {\n", " ws.readyState = 3; // Closed state.\n", " }\n", " }\n", " comm.kernel.ws.addEventListener('open', updateReadyState);\n", " comm.kernel.ws.addEventListener('close', updateReadyState);\n", " comm.kernel.ws.addEventListener('error', updateReadyState);\n", "\n", " ws.close = function () {\n", " comm.close();\n", " };\n", " ws.send = function (m) {\n", " //console.log('sending', m);\n", " comm.send(m);\n", " };\n", " // Register the callback with on_msg.\n", " comm.on_msg(function (msg) {\n", " //console.log('receiving', msg['content']['data'], msg);\n", " var data = msg['content']['data'];\n", " if (data['blob'] !== undefined) {\n", " data = {\n", " data: new Blob(msg['buffers'], { type: data['blob'] }),\n", " };\n", " }\n", " // Pass the mpl event to the overridden (by mpl) onmessage function.\n", " ws.onmessage(data);\n", " });\n", " return ws;\n", "};\n", "\n", "mpl.mpl_figure_comm = function (comm, msg) {\n", " // This is the function which gets called when the mpl process\n", " // starts-up an IPython Comm through the \"matplotlib\" channel.\n", "\n", " var id = msg.content.data.id;\n", " // Get hold of the div created by the display call when the Comm\n", " // socket was opened in Python.\n", " var element = document.getElementById(id);\n", " var ws_proxy = comm_websocket_adapter(comm);\n", "\n", " function ondownload(figure, _format) {\n", " window.open(figure.canvas.toDataURL());\n", " }\n", "\n", " var fig = new mpl.figure(id, ws_proxy, ondownload, element);\n", "\n", " // Call onopen now - mpl needs it, as it is assuming we've passed it a real\n", " // web socket which is closed, not our websocket->open comm proxy.\n", " ws_proxy.onopen();\n", "\n", " fig.parent_element = element;\n", " fig.cell_info = mpl.find_output_cell(\"
\");\n", " if (!fig.cell_info) {\n", " console.error('Failed to find cell for figure', id, fig);\n", " return;\n", " }\n", " fig.cell_info[0].output_area.element.on(\n", " 'cleared',\n", " { fig: fig },\n", " fig._remove_fig_handler\n", " );\n", "};\n", "\n", "mpl.figure.prototype.handle_close = function (fig, msg) {\n", " var width = fig.canvas.width / fig.ratio;\n", " fig.cell_info[0].output_area.element.off(\n", " 'cleared',\n", " fig._remove_fig_handler\n", " );\n", " fig.resizeObserverInstance.unobserve(fig.canvas_div);\n", "\n", " // Update the output cell to use the data from the current canvas.\n", " fig.push_to_output();\n", " var dataURL = fig.canvas.toDataURL();\n", " // Re-enable the keyboard manager in IPython - without this line, in FF,\n", " // the notebook keyboard shortcuts fail.\n", " IPython.keyboard_manager.enable();\n", " fig.parent_element.innerHTML =\n", " '';\n", " fig.close_ws(fig, msg);\n", "};\n", "\n", "mpl.figure.prototype.close_ws = function (fig, msg) {\n", " fig.send_message('closing', msg);\n", " // fig.ws.close()\n", "};\n", "\n", "mpl.figure.prototype.push_to_output = function (_remove_interactive) {\n", " // Turn the data on the canvas into data in the output cell.\n", " var width = this.canvas.width / this.ratio;\n", " var dataURL = this.canvas.toDataURL();\n", " this.cell_info[1]['text/html'] =\n", " '';\n", "};\n", "\n", "mpl.figure.prototype.updated_canvas_event = function () {\n", " // Tell IPython that the notebook contents must change.\n", " IPython.notebook.set_dirty(true);\n", " this.send_message('ack', {});\n", " var fig = this;\n", " // Wait a second, then push the new image to the DOM so\n", " // that it is saved nicely (might be nice to debounce this).\n", " setTimeout(function () {\n", " fig.push_to_output();\n", " }, 1000);\n", "};\n", "\n", "mpl.figure.prototype._init_toolbar = function () {\n", " var fig = this;\n", "\n", " var toolbar = document.createElement('div');\n", " toolbar.classList = 'btn-toolbar';\n", " this.root.appendChild(toolbar);\n", "\n", " function on_click_closure(name) {\n", " return function (_event) {\n", " return fig.toolbar_button_onclick(name);\n", " };\n", " }\n", "\n", " function on_mouseover_closure(tooltip) {\n", " return function (event) {\n", " if (!event.currentTarget.disabled) {\n", " return fig.toolbar_button_onmouseover(tooltip);\n", " }\n", " };\n", " }\n", "\n", " fig.buttons = {};\n", " var buttonGroup = document.createElement('div');\n", " buttonGroup.classList = 'btn-group';\n", " var button;\n", " for (var toolbar_ind in mpl.toolbar_items) {\n", " var name = mpl.toolbar_items[toolbar_ind][0];\n", " var tooltip = mpl.toolbar_items[toolbar_ind][1];\n", " var image = mpl.toolbar_items[toolbar_ind][2];\n", " var method_name = mpl.toolbar_items[toolbar_ind][3];\n", "\n", " if (!name) {\n", " /* Instead of a spacer, we start a new button group. */\n", " if (buttonGroup.hasChildNodes()) {\n", " toolbar.appendChild(buttonGroup);\n", " }\n", " buttonGroup = document.createElement('div');\n", " buttonGroup.classList = 'btn-group';\n", " continue;\n", " }\n", "\n", " button = fig.buttons[name] = document.createElement('button');\n", " button.classList = 'btn btn-default';\n", " button.href = '#';\n", " button.title = name;\n", " button.innerHTML = '';\n", " button.addEventListener('click', on_click_closure(method_name));\n", " button.addEventListener('mouseover', on_mouseover_closure(tooltip));\n", " buttonGroup.appendChild(button);\n", " }\n", "\n", " if (buttonGroup.hasChildNodes()) {\n", " toolbar.appendChild(buttonGroup);\n", " }\n", "\n", " // Add the status bar.\n", " var status_bar = document.createElement('span');\n", " status_bar.classList = 'mpl-message pull-right';\n", " toolbar.appendChild(status_bar);\n", " this.message = status_bar;\n", "\n", " // Add the close button to the window.\n", " var buttongrp = document.createElement('div');\n", " buttongrp.classList = 'btn-group inline pull-right';\n", " button = document.createElement('button');\n", " button.classList = 'btn btn-mini btn-primary';\n", " button.href = '#';\n", " button.title = 'Stop Interaction';\n", " button.innerHTML = '';\n", " button.addEventListener('click', function (_evt) {\n", " fig.handle_close(fig, {});\n", " });\n", " button.addEventListener(\n", " 'mouseover',\n", " on_mouseover_closure('Stop Interaction')\n", " );\n", " buttongrp.appendChild(button);\n", " var titlebar = this.root.querySelector('.ui-dialog-titlebar');\n", " titlebar.insertBefore(buttongrp, titlebar.firstChild);\n", "};\n", "\n", "mpl.figure.prototype._remove_fig_handler = function (event) {\n", " var fig = event.data.fig;\n", " if (event.target !== this) {\n", " // Ignore bubbled events from children.\n", " return;\n", " }\n", " fig.close_ws(fig, {});\n", "};\n", "\n", "mpl.figure.prototype._root_extra_style = function (el) {\n", " el.style.boxSizing = 'content-box'; // override notebook setting of border-box.\n", "};\n", "\n", "mpl.figure.prototype._canvas_extra_style = function (el) {\n", " // this is important to make the div 'focusable\n", " el.setAttribute('tabindex', 0);\n", " // reach out to IPython and tell the keyboard manager to turn it's self\n", " // off when our div gets focus\n", "\n", " // location in version 3\n", " if (IPython.notebook.keyboard_manager) {\n", " IPython.notebook.keyboard_manager.register_events(el);\n", " } else {\n", " // location in version 2\n", " IPython.keyboard_manager.register_events(el);\n", " }\n", "};\n", "\n", "mpl.figure.prototype._key_event_extra = function (event, _name) {\n", " // Check for shift+enter\n", " if (event.shiftKey && event.which === 13) {\n", " this.canvas_div.blur();\n", " // select the cell after this one\n", " var index = IPython.notebook.find_cell_index(this.cell_info[0]);\n", " IPython.notebook.select(index + 1);\n", " }\n", "};\n", "\n", "mpl.figure.prototype.handle_save = function (fig, _msg) {\n", " fig.ondownload(fig, null);\n", "};\n", "\n", "mpl.find_output_cell = function (html_output) {\n", " // Return the cell and output element which can be found *uniquely* in the notebook.\n", " // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n", " // IPython event is triggered only after the cells have been serialised, which for\n", " // our purposes (turning an active figure into a static one), is too late.\n", " var cells = IPython.notebook.get_cells();\n", " var ncells = cells.length;\n", " for (var i = 0; i < ncells; i++) {\n", " var cell = cells[i];\n", " if (cell.cell_type === 'code') {\n", " for (var j = 0; j < cell.output_area.outputs.length; j++) {\n", " var data = cell.output_area.outputs[j];\n", " if (data.data) {\n", " // IPython >= 3 moved mimebundle to data attribute of output\n", " data = data.data;\n", " }\n", " if (data['text/html'] === html_output) {\n", " return [cell, data, j];\n", " }\n", " }\n", " }\n", " }\n", "};\n", "\n", "// Register the function which deals with the matplotlib target/channel.\n", "// The kernel may be null if the page has been refreshed.\n", "if (IPython.notebook.kernel !== null) {\n", " IPython.notebook.kernel.comm_manager.register_target(\n", " 'matplotlib',\n", " mpl.mpl_figure_comm\n", " );\n", "}\n" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/plain": [ "" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ "(0.0, 15.0)" ] }, "execution_count": 110, "metadata": {}, "output_type": "execute_result" } ], "source": [ "fig = plt.figure()\n", "ax = fig.add_subplot(projection='3d')\n", "ax.set_xlim([-2,2])\n", "ax.set_ylim([-2,2])\n", "ax.set_zlim([0,15])" ] }, { "cell_type": "code", "execution_count": 111, "id": "banner-paragraph", "metadata": {}, "outputs": [], "source": [ "# smarter: sample 1000 tweaks to find a good initial_temp that gives a desired p_0\n", "# or: heat the system slowly until the % of worsening solutions is what you want\n", "initial_temp = 0.005\n", "alpha = 0.99\n", "final_temp = initial_temp / 1000\n", "trials_per_temp = 10000\n", "\n", "start = random_solution()\n", "while not satisfies_constraints(*start):\n", " start = random_solution()\n", "sol = start\n", "value = score(*sol)" ] }, { "cell_type": "code", "execution_count": 112, "id": "intended-theater", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Gen #1: temp = 0.005000, best score = 0.00498211, cur score = 0.02607645, worse accepted = 58.18%\n", "Gen #2: temp = 0.004950, best score = 0.00498211, cur score = 0.01496877, worse accepted = 64.49%\n", "Gen #3: temp = 0.004901, best score = 0.00434472, cur score = 0.01138213, worse accepted = 71.81%\n", "Gen #4: temp = 0.004851, best score = 0.00388479, cur score = 0.01106695, worse accepted = 71.14%\n", "Gen #5: temp = 0.004803, best score = 0.00388479, cur score = 0.01856064, worse accepted = 67.02%\n", "Gen #6: temp = 0.004755, best score = 0.00388479, cur score = 0.00749262, worse accepted = 59.51%\n", "Gen #7: temp = 0.004707, best score = 0.00323558, cur score = 0.02423678, worse accepted = 74.97%\n", "Gen #8: temp = 0.004660, best score = 0.00323558, cur score = 0.00634979, worse accepted = 61.76%\n", "Gen #9: temp = 0.004614, best score = 0.00323558, cur score = 0.00616578, worse accepted = 71.63%\n", "Gen #10: temp = 0.004568, best score = 0.00323558, cur score = 0.00973546, worse accepted = 69.72%\n", "Gen #11: temp = 0.004522, best score = 0.00323558, cur score = 0.02164761, worse accepted = 66.74%\n", "Gen #12: temp = 0.004477, best score = 0.00323558, cur score = 0.01649336, worse accepted = 61.20%\n", "Gen #13: temp = 0.004432, best score = 0.00320935, cur score = 0.00647400, worse accepted = 62.90%\n", "Gen #14: temp = 0.004388, best score = 0.00320935, cur score = 0.02131947, worse accepted = 68.12%\n", "Gen #15: temp = 0.004344, best score = 0.00320935, cur score = 0.00688105, worse accepted = 72.41%\n", "Gen #16: temp = 0.004300, best score = 0.00320935, cur score = 0.00707561, worse accepted = 73.75%\n", "Gen #17: temp = 0.004257, best score = 0.00316973, cur score = 0.01348438, worse accepted = 78.23%\n", "Gen #18: temp = 0.004215, best score = 0.00316973, cur score = 0.01670651, worse accepted = 62.47%\n", "Gen #19: temp = 0.004173, best score = 0.00316973, cur score = 0.01508901, worse accepted = 55.38%\n", "Gen #20: temp = 0.004131, best score = 0.00316973, cur score = 0.02436168, worse accepted = 64.19%\n", "Gen #21: temp = 0.004090, best score = 0.00316973, cur score = 0.01571275, worse accepted = 72.70%\n", "Gen #22: temp = 0.004049, best score = 0.00316973, cur score = 0.02007310, worse accepted = 66.36%\n", "Gen #23: temp = 0.004008, best score = 0.00316973, cur score = 0.01046813, worse accepted = 56.85%\n", "Gen #24: temp = 0.003968, best score = 0.00316973, cur score = 0.00850780, worse accepted = 61.51%\n", "Gen #25: temp = 0.003928, best score = 0.00316973, cur score = 0.01951624, worse accepted = 66.72%\n", "Gen #26: temp = 0.003889, best score = 0.00316973, cur score = 0.00493577, worse accepted = 66.91%\n", "Gen #27: temp = 0.003850, best score = 0.00316973, cur score = 0.00823362, worse accepted = 73.73%\n", "Gen #28: temp = 0.003812, best score = 0.00316973, cur score = 0.01327138, worse accepted = 66.78%\n", "Gen #29: temp = 0.003774, best score = 0.00316973, cur score = 0.00772271, worse accepted = 67.33%\n", "Gen #30: temp = 0.003736, best score = 0.00316973, cur score = 0.00342143, worse accepted = 71.81%\n", "Gen #31: temp = 0.003699, best score = 0.00316973, cur score = 0.00918479, worse accepted = 70.86%\n", "Gen #32: temp = 0.003662, best score = 0.00293984, cur score = 0.00619577, worse accepted = 70.89%\n", "Gen #33: temp = 0.003625, best score = 0.00293984, cur score = 0.01617627, worse accepted = 71.97%\n", "Gen #34: temp = 0.003589, best score = 0.00293984, cur score = 0.00376189, worse accepted = 69.49%\n", "Gen #35: temp = 0.003553, best score = 0.00293984, cur score = 0.00921942, worse accepted = 67.21%\n", "Gen #36: temp = 0.003517, best score = 0.00293984, cur score = 0.00954654, worse accepted = 66.22%\n", "Gen #37: temp = 0.003482, best score = 0.00293984, cur score = 0.00553437, worse accepted = 69.42%\n", "Gen #38: temp = 0.003447, best score = 0.00293984, cur score = 0.00610652, worse accepted = 75.52%\n", "Gen #39: temp = 0.003413, best score = 0.00293984, cur score = 0.00535047, worse accepted = 76.47%\n", "Gen #40: temp = 0.003379, best score = 0.00293984, cur score = 0.01145783, worse accepted = 70.42%\n", "Gen #41: temp = 0.003345, best score = 0.00293984, cur score = 0.01046131, worse accepted = 67.16%\n", "Gen #42: temp = 0.003311, best score = 0.00293984, cur score = 0.00938973, worse accepted = 67.25%\n", "Gen #43: temp = 0.003278, best score = 0.00293984, cur score = 0.01596308, worse accepted = 62.48%\n", "Gen #44: temp = 0.003246, best score = 0.00293984, cur score = 0.01605265, worse accepted = 55.37%\n", "Gen #45: temp = 0.003213, best score = 0.00293984, cur score = 0.00805685, worse accepted = 66.56%\n", "Gen #46: temp = 0.003181, best score = 0.00293984, cur score = 0.00469697, worse accepted = 66.39%\n", "Gen #47: temp = 0.003149, best score = 0.00293984, cur score = 0.00781537, worse accepted = 71.09%\n", "Gen #48: temp = 0.003118, best score = 0.00293984, cur score = 0.01305252, worse accepted = 67.26%\n", "Gen #49: temp = 0.003086, best score = 0.00293984, cur score = 0.00984354, worse accepted = 59.91%\n", "Gen #50: temp = 0.003056, best score = 0.00293984, cur score = 0.00462736, worse accepted = 61.29%\n", "Gen #51: temp = 0.003025, best score = 0.00293984, cur score = 0.00869072, worse accepted = 72.62%\n", "Gen #52: temp = 0.002995, best score = 0.00293984, cur score = 0.01243511, worse accepted = 67.12%\n", "Gen #53: temp = 0.002965, best score = 0.00293984, cur score = 0.00608910, worse accepted = 66.51%\n", "Gen #54: temp = 0.002935, best score = 0.00293984, cur score = 0.00772268, worse accepted = 68.07%\n", "Gen #55: temp = 0.002906, best score = 0.00293984, cur score = 0.00470201, worse accepted = 71.89%\n", "Gen #56: temp = 0.002877, best score = 0.00293984, cur score = 0.00821767, worse accepted = 67.15%\n", "Gen #57: temp = 0.002848, best score = 0.00293984, cur score = 0.01066847, worse accepted = 68.06%\n", "Gen #58: temp = 0.002820, best score = 0.00293984, cur score = 0.00724871, worse accepted = 64.60%\n", "Gen #59: temp = 0.002791, best score = 0.00293984, cur score = 0.00399199, worse accepted = 66.72%\n", "Gen #60: temp = 0.002763, best score = 0.00293984, cur score = 0.00881356, worse accepted = 69.16%\n", "Gen #61: temp = 0.002736, best score = 0.00293984, cur score = 0.00566503, worse accepted = 70.08%\n", "Gen #62: temp = 0.002708, best score = 0.00293984, cur score = 0.00601505, worse accepted = 65.74%\n", "Gen #63: temp = 0.002681, best score = 0.00293984, cur score = 0.00405679, worse accepted = 67.42%\n", "Gen #64: temp = 0.002655, best score = 0.00293984, cur score = 0.00789528, worse accepted = 67.63%\n", "Gen #65: temp = 0.002628, best score = 0.00293984, cur score = 0.00856971, worse accepted = 60.19%\n", "Gen #66: temp = 0.002602, best score = 0.00293984, cur score = 0.01027670, worse accepted = 70.92%\n", "Gen #67: temp = 0.002576, best score = 0.00293984, cur score = 0.00876102, worse accepted = 66.78%\n", "Gen #68: temp = 0.002550, best score = 0.00293984, cur score = 0.00652068, worse accepted = 61.42%\n", "Gen #69: temp = 0.002524, best score = 0.00293984, cur score = 0.01156628, worse accepted = 66.35%\n", "Gen #70: temp = 0.002499, best score = 0.00293984, cur score = 0.00486000, worse accepted = 62.43%\n", "Gen #71: temp = 0.002474, best score = 0.00293984, cur score = 0.00641640, worse accepted = 59.61%\n", "Gen #72: temp = 0.002449, best score = 0.00293984, cur score = 0.01189859, worse accepted = 66.22%\n", "Gen #73: temp = 0.002425, best score = 0.00293984, cur score = 0.00810955, worse accepted = 50.09%\n", "Gen #74: temp = 0.002401, best score = 0.00293984, cur score = 0.00499474, worse accepted = 60.35%\n", "Gen #75: temp = 0.002377, best score = 0.00293984, cur score = 0.00688942, worse accepted = 66.15%\n", "Gen #76: temp = 0.002353, best score = 0.00293984, cur score = 0.01014683, worse accepted = 61.89%\n", "Gen #77: temp = 0.002329, best score = 0.00293984, cur score = 0.00500918, worse accepted = 64.42%\n", "Gen #78: temp = 0.002306, best score = 0.00293984, cur score = 0.00656615, worse accepted = 64.52%\n", "Gen #79: temp = 0.002283, best score = 0.00293984, cur score = 0.01073041, worse accepted = 60.09%\n", "Gen #80: temp = 0.002260, best score = 0.00293984, cur score = 0.00703685, worse accepted = 65.26%\n", "Gen #81: temp = 0.002238, best score = 0.00293984, cur score = 0.01129775, worse accepted = 66.13%\n", "Gen #82: temp = 0.002215, best score = 0.00293984, cur score = 0.01161270, worse accepted = 60.41%\n", "Gen #83: temp = 0.002193, best score = 0.00293984, cur score = 0.00612174, worse accepted = 61.11%\n", "Gen #84: temp = 0.002171, best score = 0.00293984, cur score = 0.00602388, worse accepted = 64.55%\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Gen #85: temp = 0.002149, best score = 0.00293984, cur score = 0.00701622, worse accepted = 65.94%\n", "Gen #86: temp = 0.002128, best score = 0.00293984, cur score = 0.00846765, worse accepted = 58.20%\n", "Gen #87: temp = 0.002107, best score = 0.00293984, cur score = 0.01113894, worse accepted = 53.09%\n", "Gen #88: temp = 0.002086, best score = 0.00293984, cur score = 0.00797868, worse accepted = 46.85%\n", "Gen #89: temp = 0.002065, best score = 0.00293984, cur score = 0.00949566, worse accepted = 49.42%\n", "Gen #90: temp = 0.002044, best score = 0.00293984, cur score = 0.00594854, worse accepted = 58.51%\n", "Gen #91: temp = 0.002024, best score = 0.00293984, cur score = 0.00938367, worse accepted = 53.77%\n", "Gen #92: temp = 0.002003, best score = 0.00293984, cur score = 0.00754997, worse accepted = 49.80%\n", "Gen #93: temp = 0.001983, best score = 0.00293984, cur score = 0.00534766, worse accepted = 64.29%\n", "Gen #94: temp = 0.001964, best score = 0.00293984, cur score = 0.00585790, worse accepted = 61.24%\n", "Gen #95: temp = 0.001944, best score = 0.00293984, cur score = 0.00792139, worse accepted = 61.29%\n", "Gen #96: temp = 0.001924, best score = 0.00293984, cur score = 0.00879535, worse accepted = 64.22%\n", "Gen #97: temp = 0.001905, best score = 0.00293984, cur score = 0.00706841, worse accepted = 55.28%\n", "Gen #98: temp = 0.001886, best score = 0.00293984, cur score = 0.00478415, worse accepted = 54.55%\n", "Gen #99: temp = 0.001867, best score = 0.00293984, cur score = 0.00740354, worse accepted = 60.52%\n", "Gen #100: temp = 0.001849, best score = 0.00293984, cur score = 0.00353610, worse accepted = 60.83%\n", "Gen #101: temp = 0.001830, best score = 0.00293984, cur score = 0.00671362, worse accepted = 58.72%\n", "Gen #102: temp = 0.001812, best score = 0.00293984, cur score = 0.00668968, worse accepted = 52.36%\n", "Gen #103: temp = 0.001794, best score = 0.00293984, cur score = 0.00489673, worse accepted = 54.52%\n", "Gen #104: temp = 0.001776, best score = 0.00293984, cur score = 0.00343653, worse accepted = 63.11%\n", "Gen #105: temp = 0.001758, best score = 0.00289214, cur score = 0.00694999, worse accepted = 63.21%\n", "Gen #106: temp = 0.001740, best score = 0.00289214, cur score = 0.00510719, worse accepted = 60.40%\n", "Gen #107: temp = 0.001723, best score = 0.00289214, cur score = 0.00442856, worse accepted = 53.47%\n", "Gen #108: temp = 0.001706, best score = 0.00289214, cur score = 0.00568040, worse accepted = 58.73%\n", "Gen #109: temp = 0.001689, best score = 0.00289214, cur score = 0.00661033, worse accepted = 63.61%\n", "Gen #110: temp = 0.001672, best score = 0.00289214, cur score = 0.00809534, worse accepted = 61.39%\n", "Gen #111: temp = 0.001655, best score = 0.00289214, cur score = 0.00619205, worse accepted = 55.75%\n", "Gen #112: temp = 0.001639, best score = 0.00289214, cur score = 0.00404999, worse accepted = 61.48%\n", "Gen #113: temp = 0.001622, best score = 0.00289214, cur score = 0.00375326, worse accepted = 52.58%\n", "Gen #114: temp = 0.001606, best score = 0.00289214, cur score = 0.00517987, worse accepted = 62.17%\n", "Gen #115: temp = 0.001590, best score = 0.00289214, cur score = 0.00588510, worse accepted = 59.67%\n", "Gen #116: temp = 0.001574, best score = 0.00289214, cur score = 0.00337506, worse accepted = 58.79%\n", "Gen #117: temp = 0.001558, best score = 0.00289214, cur score = 0.00722834, worse accepted = 51.50%\n", "Gen #118: temp = 0.001543, best score = 0.00289214, cur score = 0.00431118, worse accepted = 55.31%\n", "Gen #119: temp = 0.001527, best score = 0.00289214, cur score = 0.00853383, worse accepted = 55.84%\n", "Gen #120: temp = 0.001512, best score = 0.00289214, cur score = 0.00705353, worse accepted = 50.67%\n", "Gen #121: temp = 0.001497, best score = 0.00289214, cur score = 0.00834104, worse accepted = 54.30%\n", "Gen #122: temp = 0.001482, best score = 0.00289214, cur score = 0.00691734, worse accepted = 59.65%\n", "Gen #123: temp = 0.001467, best score = 0.00289214, cur score = 0.00588851, worse accepted = 45.63%\n", "Gen #124: temp = 0.001452, best score = 0.00289214, cur score = 0.01201016, worse accepted = 33.85%\n", "Gen #125: temp = 0.001438, best score = 0.00289214, cur score = 0.01378857, worse accepted = 28.27%\n", "Gen #126: temp = 0.001424, best score = 0.00289214, cur score = 0.00773124, worse accepted = 48.08%\n", "Gen #127: temp = 0.001409, best score = 0.00289214, cur score = 0.00409184, worse accepted = 52.43%\n", "Gen #128: temp = 0.001395, best score = 0.00289214, cur score = 0.00752872, worse accepted = 52.25%\n", "Gen #129: temp = 0.001381, best score = 0.00289214, cur score = 0.00653795, worse accepted = 51.90%\n", "Gen #130: temp = 0.001367, best score = 0.00288544, cur score = 0.00513341, worse accepted = 57.75%\n", "Gen #131: temp = 0.001354, best score = 0.00288544, cur score = 0.00888910, worse accepted = 36.94%\n", "Gen #132: temp = 0.001340, best score = 0.00288544, cur score = 0.00529295, worse accepted = 55.05%\n", "Gen #133: temp = 0.001327, best score = 0.00288544, cur score = 0.00431520, worse accepted = 55.23%\n", "Gen #134: temp = 0.001314, best score = 0.00288544, cur score = 0.00722524, worse accepted = 52.65%\n", "Gen #135: temp = 0.001300, best score = 0.00288544, cur score = 0.00321848, worse accepted = 52.09%\n", "Gen #136: temp = 0.001287, best score = 0.00288544, cur score = 0.00731232, worse accepted = 54.58%\n", "Gen #137: temp = 0.001275, best score = 0.00288544, cur score = 0.00540264, worse accepted = 51.81%\n", "Gen #138: temp = 0.001262, best score = 0.00288544, cur score = 0.00623905, worse accepted = 51.48%\n", "Gen #139: temp = 0.001249, best score = 0.00288544, cur score = 0.00620848, worse accepted = 51.78%\n", "Gen #140: temp = 0.001237, best score = 0.00288544, cur score = 0.00519825, worse accepted = 55.98%\n", "Gen #141: temp = 0.001224, best score = 0.00288544, cur score = 0.00517770, worse accepted = 53.68%\n", "Gen #142: temp = 0.001212, best score = 0.00288544, cur score = 0.00465451, worse accepted = 52.99%\n", "Gen #143: temp = 0.001200, best score = 0.00288544, cur score = 0.00425738, worse accepted = 51.62%\n", "Gen #144: temp = 0.001188, best score = 0.00288544, cur score = 0.00629126, worse accepted = 47.19%\n", "Gen #145: temp = 0.001176, best score = 0.00288544, cur score = 0.00506074, worse accepted = 48.47%\n", "Gen #146: temp = 0.001164, best score = 0.00288544, cur score = 0.00741684, worse accepted = 54.63%\n", "Gen #147: temp = 0.001153, best score = 0.00288544, cur score = 0.00723949, worse accepted = 52.07%\n", "Gen #148: temp = 0.001141, best score = 0.00286592, cur score = 0.00479152, worse accepted = 49.08%\n", "Gen #149: temp = 0.001130, best score = 0.00286592, cur score = 0.00545715, worse accepted = 45.44%\n", "Gen #150: temp = 0.001118, best score = 0.00286592, cur score = 0.00334246, worse accepted = 46.03%\n", "Gen #151: temp = 0.001107, best score = 0.00286592, cur score = 0.00489101, worse accepted = 52.00%\n", "Gen #152: temp = 0.001096, best score = 0.00286592, cur score = 0.00560472, worse accepted = 54.67%\n", "Gen #153: temp = 0.001085, best score = 0.00286592, cur score = 0.00966246, worse accepted = 51.34%\n", "Gen #154: temp = 0.001074, best score = 0.00286592, cur score = 0.00781910, worse accepted = 51.67%\n", "Gen #155: temp = 0.001064, best score = 0.00286592, cur score = 0.00669721, worse accepted = 44.47%\n", "Gen #156: temp = 0.001053, best score = 0.00286592, cur score = 0.00583131, worse accepted = 50.08%\n", "Gen #157: temp = 0.001042, best score = 0.00286592, cur score = 0.00470904, worse accepted = 51.91%\n", "Gen #158: temp = 0.001032, best score = 0.00286592, cur score = 0.00428196, worse accepted = 49.57%\n", "Gen #159: temp = 0.001022, best score = 0.00286592, cur score = 0.00391691, worse accepted = 50.26%\n", "Gen #160: temp = 0.001012, best score = 0.00286592, cur score = 0.00641513, worse accepted = 50.42%\n", "Gen #161: temp = 0.001001, best score = 0.00286592, cur score = 0.00470576, worse accepted = 51.96%\n", "Gen #162: temp = 0.000991, best score = 0.00286592, cur score = 0.00451301, worse accepted = 48.56%\n", "Gen #163: temp = 0.000981, best score = 0.00286592, cur score = 0.00471136, worse accepted = 48.74%\n", "Gen #164: temp = 0.000972, best score = 0.00286592, cur score = 0.00506477, worse accepted = 51.16%\n", "Gen #165: temp = 0.000962, best score = 0.00286592, cur score = 0.01025271, worse accepted = 43.82%\n", "Gen #166: temp = 0.000952, best score = 0.00286592, cur score = 0.00407577, worse accepted = 37.36%\n", "Gen #167: temp = 0.000943, best score = 0.00286592, cur score = 0.00471348, worse accepted = 44.21%\n", "Gen #168: temp = 0.000933, best score = 0.00286592, cur score = 0.00423911, worse accepted = 41.28%\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Gen #169: temp = 0.000924, best score = 0.00285677, cur score = 0.00566171, worse accepted = 49.48%\n", "Gen #170: temp = 0.000915, best score = 0.00285677, cur score = 0.00491238, worse accepted = 43.80%\n", "Gen #171: temp = 0.000906, best score = 0.00285677, cur score = 0.00445710, worse accepted = 44.08%\n", "Gen #172: temp = 0.000897, best score = 0.00285677, cur score = 0.00564290, worse accepted = 47.51%\n", "Gen #173: temp = 0.000888, best score = 0.00285677, cur score = 0.00762985, worse accepted = 48.89%\n", "Gen #174: temp = 0.000879, best score = 0.00285677, cur score = 0.00464120, worse accepted = 45.82%\n", "Gen #175: temp = 0.000870, best score = 0.00285677, cur score = 0.00494756, worse accepted = 49.59%\n", "Gen #176: temp = 0.000861, best score = 0.00285677, cur score = 0.00370834, worse accepted = 47.52%\n", "Gen #177: temp = 0.000853, best score = 0.00285677, cur score = 0.00573158, worse accepted = 45.04%\n", "Gen #178: temp = 0.000844, best score = 0.00285677, cur score = 0.00534699, worse accepted = 37.51%\n", "Gen #179: temp = 0.000836, best score = 0.00285677, cur score = 0.00849108, worse accepted = 45.09%\n", "Gen #180: temp = 0.000827, best score = 0.00285677, cur score = 0.00483264, worse accepted = 47.72%\n", "Gen #181: temp = 0.000819, best score = 0.00285677, cur score = 0.00614758, worse accepted = 50.03%\n", "Gen #182: temp = 0.000811, best score = 0.00285677, cur score = 0.00542142, worse accepted = 48.38%\n", "Gen #183: temp = 0.000803, best score = 0.00285677, cur score = 0.00467243, worse accepted = 42.12%\n", "Gen #184: temp = 0.000795, best score = 0.00285677, cur score = 0.00607135, worse accepted = 44.71%\n", "Gen #185: temp = 0.000787, best score = 0.00283286, cur score = 0.00346703, worse accepted = 46.60%\n", "Gen #186: temp = 0.000779, best score = 0.00283286, cur score = 0.00710627, worse accepted = 41.58%\n", "Gen #187: temp = 0.000771, best score = 0.00283286, cur score = 0.00503042, worse accepted = 42.96%\n", "Gen #188: temp = 0.000763, best score = 0.00283286, cur score = 0.00582675, worse accepted = 46.42%\n", "Gen #189: temp = 0.000756, best score = 0.00283286, cur score = 0.00487145, worse accepted = 47.37%\n", "Gen #190: temp = 0.000748, best score = 0.00283286, cur score = 0.00433111, worse accepted = 40.08%\n", "Gen #191: temp = 0.000741, best score = 0.00283286, cur score = 0.00389020, worse accepted = 49.89%\n", "Gen #192: temp = 0.000733, best score = 0.00283286, cur score = 0.00432172, worse accepted = 48.67%\n", "Gen #193: temp = 0.000726, best score = 0.00283286, cur score = 0.00589233, worse accepted = 46.93%\n", "Gen #194: temp = 0.000719, best score = 0.00283286, cur score = 0.00451202, worse accepted = 45.23%\n", "Gen #195: temp = 0.000712, best score = 0.00283286, cur score = 0.00407743, worse accepted = 45.53%\n", "Gen #196: temp = 0.000704, best score = 0.00283286, cur score = 0.00474800, worse accepted = 47.43%\n", "Gen #197: temp = 0.000697, best score = 0.00283286, cur score = 0.00566707, worse accepted = 29.68%\n", "Gen #198: temp = 0.000690, best score = 0.00283286, cur score = 0.00385099, worse accepted = 46.29%\n", "Gen #199: temp = 0.000684, best score = 0.00283286, cur score = 0.00543521, worse accepted = 39.55%\n", "Gen #200: temp = 0.000677, best score = 0.00283286, cur score = 0.00537149, worse accepted = 42.55%\n", "Gen #201: temp = 0.000670, best score = 0.00283286, cur score = 0.00455283, worse accepted = 40.46%\n", "Gen #202: temp = 0.000663, best score = 0.00283286, cur score = 0.00402849, worse accepted = 39.34%\n", "Gen #203: temp = 0.000657, best score = 0.00283286, cur score = 0.00379572, worse accepted = 44.72%\n", "Gen #204: temp = 0.000650, best score = 0.00283286, cur score = 0.00398947, worse accepted = 45.23%\n", "Gen #205: temp = 0.000644, best score = 0.00283286, cur score = 0.00434297, worse accepted = 40.37%\n", "Gen #206: temp = 0.000637, best score = 0.00283286, cur score = 0.00478209, worse accepted = 44.06%\n", "Gen #207: temp = 0.000631, best score = 0.00283286, cur score = 0.00593536, worse accepted = 41.34%\n", "Gen #208: temp = 0.000624, best score = 0.00283286, cur score = 0.00532431, worse accepted = 44.93%\n", "Gen #209: temp = 0.000618, best score = 0.00283286, cur score = 0.00488755, worse accepted = 40.82%\n", "Gen #210: temp = 0.000612, best score = 0.00283286, cur score = 0.00444786, worse accepted = 39.14%\n", "Gen #211: temp = 0.000606, best score = 0.00283286, cur score = 0.00393071, worse accepted = 43.77%\n", "Gen #212: temp = 0.000600, best score = 0.00283286, cur score = 0.00444914, worse accepted = 44.02%\n", "Gen #213: temp = 0.000594, best score = 0.00283286, cur score = 0.00568107, worse accepted = 42.20%\n", "Gen #214: temp = 0.000588, best score = 0.00283286, cur score = 0.00351399, worse accepted = 43.58%\n", "Gen #215: temp = 0.000582, best score = 0.00283286, cur score = 0.00578094, worse accepted = 44.22%\n", "Gen #216: temp = 0.000576, best score = 0.00283286, cur score = 0.00372442, worse accepted = 43.34%\n", "Gen #217: temp = 0.000570, best score = 0.00283286, cur score = 0.00600925, worse accepted = 42.99%\n", "Gen #218: temp = 0.000565, best score = 0.00283286, cur score = 0.00525079, worse accepted = 30.88%\n", "Gen #219: temp = 0.000559, best score = 0.00283286, cur score = 0.00338511, worse accepted = 33.87%\n", "Gen #220: temp = 0.000553, best score = 0.00283286, cur score = 0.00381173, worse accepted = 35.84%\n", "Gen #221: temp = 0.000548, best score = 0.00283286, cur score = 0.00471279, worse accepted = 42.82%\n", "Gen #222: temp = 0.000542, best score = 0.00283286, cur score = 0.00441376, worse accepted = 42.57%\n", "Gen #223: temp = 0.000537, best score = 0.00283286, cur score = 0.00329808, worse accepted = 39.53%\n", "Gen #224: temp = 0.000532, best score = 0.00283286, cur score = 0.00352525, worse accepted = 44.78%\n", "Gen #225: temp = 0.000526, best score = 0.00283286, cur score = 0.00561973, worse accepted = 40.58%\n", "Gen #226: temp = 0.000521, best score = 0.00283286, cur score = 0.00570239, worse accepted = 42.11%\n", "Gen #227: temp = 0.000516, best score = 0.00283286, cur score = 0.00334715, worse accepted = 39.36%\n", "Gen #228: temp = 0.000511, best score = 0.00283286, cur score = 0.00471296, worse accepted = 38.45%\n", "Gen #229: temp = 0.000506, best score = 0.00283286, cur score = 0.00438475, worse accepted = 41.59%\n", "Gen #230: temp = 0.000501, best score = 0.00283286, cur score = 0.00563376, worse accepted = 38.36%\n", "Gen #231: temp = 0.000496, best score = 0.00283286, cur score = 0.00509714, worse accepted = 39.67%\n", "Gen #232: temp = 0.000491, best score = 0.00283286, cur score = 0.00382472, worse accepted = 41.39%\n", "Gen #233: temp = 0.000486, best score = 0.00283286, cur score = 0.00458995, worse accepted = 39.16%\n", "Gen #234: temp = 0.000481, best score = 0.00283286, cur score = 0.00451853, worse accepted = 37.58%\n", "Gen #235: temp = 0.000476, best score = 0.00283286, cur score = 0.00501172, worse accepted = 33.96%\n", "Gen #236: temp = 0.000471, best score = 0.00283286, cur score = 0.00386481, worse accepted = 40.60%\n", "Gen #237: temp = 0.000467, best score = 0.00283286, cur score = 0.00361848, worse accepted = 44.81%\n", "Gen #238: temp = 0.000462, best score = 0.00283286, cur score = 0.00384121, worse accepted = 42.08%\n", "Gen #239: temp = 0.000457, best score = 0.00283286, cur score = 0.00502696, worse accepted = 40.66%\n", "Gen #240: temp = 0.000453, best score = 0.00283286, cur score = 0.00430842, worse accepted = 33.19%\n", "Gen #241: temp = 0.000448, best score = 0.00283286, cur score = 0.00445057, worse accepted = 40.46%\n", "Gen #242: temp = 0.000444, best score = 0.00283286, cur score = 0.00553863, worse accepted = 37.28%\n", "Gen #243: temp = 0.000439, best score = 0.00283286, cur score = 0.00458620, worse accepted = 37.91%\n", "Gen #244: temp = 0.000435, best score = 0.00283286, cur score = 0.00392041, worse accepted = 40.16%\n", "Gen #245: temp = 0.000430, best score = 0.00283286, cur score = 0.00543586, worse accepted = 35.35%\n", "Gen #246: temp = 0.000426, best score = 0.00283286, cur score = 0.00358179, worse accepted = 39.99%\n", "Gen #247: temp = 0.000422, best score = 0.00283286, cur score = 0.00392603, worse accepted = 38.21%\n", "Gen #248: temp = 0.000418, best score = 0.00283286, cur score = 0.00444539, worse accepted = 39.01%\n", "Gen #249: temp = 0.000414, best score = 0.00283286, cur score = 0.00393586, worse accepted = 40.65%\n", "Gen #250: temp = 0.000409, best score = 0.00283286, cur score = 0.00503606, worse accepted = 40.33%\n", "Gen #251: temp = 0.000405, best score = 0.00283286, cur score = 0.00516747, worse accepted = 33.05%\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Gen #252: temp = 0.000401, best score = 0.00283286, cur score = 0.00398456, worse accepted = 37.74%\n", "Gen #253: temp = 0.000397, best score = 0.00283286, cur score = 0.00317987, worse accepted = 42.28%\n", "Gen #254: temp = 0.000393, best score = 0.00283286, cur score = 0.00344424, worse accepted = 41.00%\n", "Gen #255: temp = 0.000389, best score = 0.00283286, cur score = 0.00347014, worse accepted = 38.31%\n", "Gen #256: temp = 0.000385, best score = 0.00283286, cur score = 0.00390225, worse accepted = 36.06%\n", "Gen #257: temp = 0.000382, best score = 0.00283286, cur score = 0.00403573, worse accepted = 38.86%\n", "Gen #258: temp = 0.000378, best score = 0.00283286, cur score = 0.00371763, worse accepted = 39.63%\n", "Gen #259: temp = 0.000374, best score = 0.00283286, cur score = 0.00397368, worse accepted = 38.27%\n", "Gen #260: temp = 0.000370, best score = 0.00283286, cur score = 0.00370070, worse accepted = 37.99%\n", "Gen #261: temp = 0.000367, best score = 0.00283286, cur score = 0.00305254, worse accepted = 32.54%\n", "Gen #262: temp = 0.000363, best score = 0.00283286, cur score = 0.00488960, worse accepted = 34.25%\n", "Gen #263: temp = 0.000359, best score = 0.00283286, cur score = 0.00360783, worse accepted = 35.06%\n", "Gen #264: temp = 0.000356, best score = 0.00283286, cur score = 0.00378066, worse accepted = 37.25%\n", "Gen #265: temp = 0.000352, best score = 0.00283286, cur score = 0.00372776, worse accepted = 38.75%\n", "Gen #266: temp = 0.000349, best score = 0.00283286, cur score = 0.00417886, worse accepted = 40.02%\n", "Gen #267: temp = 0.000345, best score = 0.00283286, cur score = 0.00351148, worse accepted = 40.39%\n", "Gen #268: temp = 0.000342, best score = 0.00283286, cur score = 0.00360247, worse accepted = 37.34%\n", "Gen #269: temp = 0.000338, best score = 0.00283286, cur score = 0.00342522, worse accepted = 35.61%\n", "Gen #270: temp = 0.000335, best score = 0.00283286, cur score = 0.00352514, worse accepted = 36.42%\n", "Gen #271: temp = 0.000331, best score = 0.00283286, cur score = 0.00466701, worse accepted = 36.22%\n", "Gen #272: temp = 0.000328, best score = 0.00283286, cur score = 0.00329234, worse accepted = 29.89%\n", "Gen #273: temp = 0.000325, best score = 0.00283286, cur score = 0.00386470, worse accepted = 41.76%\n", "Gen #274: temp = 0.000322, best score = 0.00283286, cur score = 0.00325174, worse accepted = 36.30%\n", "Gen #275: temp = 0.000318, best score = 0.00283286, cur score = 0.00506351, worse accepted = 34.11%\n", "Gen #276: temp = 0.000315, best score = 0.00283286, cur score = 0.00374008, worse accepted = 37.62%\n", "Gen #277: temp = 0.000312, best score = 0.00283286, cur score = 0.00371033, worse accepted = 33.32%\n", "Gen #278: temp = 0.000309, best score = 0.00283286, cur score = 0.00346140, worse accepted = 36.94%\n", "Gen #279: temp = 0.000306, best score = 0.00283286, cur score = 0.00339707, worse accepted = 33.07%\n", "Gen #280: temp = 0.000303, best score = 0.00283286, cur score = 0.00353344, worse accepted = 35.52%\n", "Gen #281: temp = 0.000300, best score = 0.00283286, cur score = 0.00358984, worse accepted = 39.84%\n", "Gen #282: temp = 0.000297, best score = 0.00283286, cur score = 0.00417689, worse accepted = 33.82%\n", "Gen #283: temp = 0.000294, best score = 0.00283286, cur score = 0.00346891, worse accepted = 33.16%\n", "Gen #284: temp = 0.000291, best score = 0.00283286, cur score = 0.00528340, worse accepted = 34.15%\n", "Gen #285: temp = 0.000288, best score = 0.00283286, cur score = 0.00378142, worse accepted = 38.39%\n", "Gen #286: temp = 0.000285, best score = 0.00283286, cur score = 0.00358550, worse accepted = 32.25%\n", "Gen #287: temp = 0.000282, best score = 0.00283286, cur score = 0.00480797, worse accepted = 35.43%\n", "Gen #288: temp = 0.000279, best score = 0.00283286, cur score = 0.00320541, worse accepted = 37.87%\n", "Gen #289: temp = 0.000277, best score = 0.00283286, cur score = 0.00362837, worse accepted = 32.76%\n", "Gen #290: temp = 0.000274, best score = 0.00283286, cur score = 0.00414744, worse accepted = 36.32%\n", "Gen #291: temp = 0.000271, best score = 0.00283286, cur score = 0.00407215, worse accepted = 37.88%\n", "Gen #292: temp = 0.000268, best score = 0.00283286, cur score = 0.00357880, worse accepted = 28.80%\n", "Gen #293: temp = 0.000266, best score = 0.00283286, cur score = 0.00326603, worse accepted = 35.55%\n", "Gen #294: temp = 0.000263, best score = 0.00283286, cur score = 0.00509531, worse accepted = 32.69%\n", "Gen #295: temp = 0.000260, best score = 0.00283286, cur score = 0.00338110, worse accepted = 28.71%\n", "Gen #296: temp = 0.000258, best score = 0.00283286, cur score = 0.00321034, worse accepted = 31.24%\n", "Gen #297: temp = 0.000255, best score = 0.00283286, cur score = 0.00334372, worse accepted = 32.75%\n", "Gen #298: temp = 0.000253, best score = 0.00283286, cur score = 0.00410281, worse accepted = 33.34%\n", "Gen #299: temp = 0.000250, best score = 0.00283286, cur score = 0.00425427, worse accepted = 35.23%\n", "Gen #300: temp = 0.000248, best score = 0.00283286, cur score = 0.00341289, worse accepted = 30.72%\n", "Gen #301: temp = 0.000245, best score = 0.00283286, cur score = 0.00344179, worse accepted = 34.85%\n", "Gen #302: temp = 0.000243, best score = 0.00283286, cur score = 0.00305624, worse accepted = 30.50%\n", "Gen #303: temp = 0.000240, best score = 0.00283286, cur score = 0.00379940, worse accepted = 32.50%\n", "Gen #304: temp = 0.000238, best score = 0.00283286, cur score = 0.00313089, worse accepted = 36.25%\n", "Gen #305: temp = 0.000236, best score = 0.00283286, cur score = 0.00393355, worse accepted = 30.48%\n", "Gen #306: temp = 0.000233, best score = 0.00283286, cur score = 0.00311796, worse accepted = 34.06%\n", "Gen #307: temp = 0.000231, best score = 0.00283286, cur score = 0.00446695, worse accepted = 31.34%\n", "Gen #308: temp = 0.000229, best score = 0.00283286, cur score = 0.00341489, worse accepted = 29.75%\n", "Gen #309: temp = 0.000226, best score = 0.00283286, cur score = 0.00367718, worse accepted = 31.13%\n", "Gen #310: temp = 0.000224, best score = 0.00283286, cur score = 0.00317520, worse accepted = 33.38%\n", "Gen #311: temp = 0.000222, best score = 0.00283286, cur score = 0.00411731, worse accepted = 32.21%\n", "Gen #312: temp = 0.000220, best score = 0.00283286, cur score = 0.00335890, worse accepted = 36.33%\n", "Gen #313: temp = 0.000217, best score = 0.00283286, cur score = 0.00368919, worse accepted = 34.54%\n", "Gen #314: temp = 0.000215, best score = 0.00283286, cur score = 0.00349258, worse accepted = 31.44%\n", "Gen #315: temp = 0.000213, best score = 0.00283286, cur score = 0.00328569, worse accepted = 32.69%\n", "Gen #316: temp = 0.000211, best score = 0.00283286, cur score = 0.00373043, worse accepted = 33.48%\n", "Gen #317: temp = 0.000209, best score = 0.00283286, cur score = 0.00301748, worse accepted = 30.24%\n", "Gen #318: temp = 0.000207, best score = 0.00283286, cur score = 0.00340946, worse accepted = 34.16%\n", "Gen #319: temp = 0.000205, best score = 0.00282915, cur score = 0.00351997, worse accepted = 31.61%\n", "Gen #320: temp = 0.000203, best score = 0.00282915, cur score = 0.00326983, worse accepted = 34.77%\n", "Gen #321: temp = 0.000201, best score = 0.00282915, cur score = 0.00359370, worse accepted = 28.82%\n", "Gen #322: temp = 0.000199, best score = 0.00282915, cur score = 0.00327773, worse accepted = 29.32%\n", "Gen #323: temp = 0.000197, best score = 0.00282915, cur score = 0.00339162, worse accepted = 29.82%\n", "Gen #324: temp = 0.000195, best score = 0.00282915, cur score = 0.00368515, worse accepted = 30.59%\n", "Gen #325: temp = 0.000193, best score = 0.00282915, cur score = 0.00344409, worse accepted = 33.38%\n", "Gen #326: temp = 0.000191, best score = 0.00282915, cur score = 0.00344444, worse accepted = 33.79%\n", "Gen #327: temp = 0.000189, best score = 0.00282915, cur score = 0.00342180, worse accepted = 30.77%\n", "Gen #328: temp = 0.000187, best score = 0.00282915, cur score = 0.00333168, worse accepted = 30.82%\n", "Gen #329: temp = 0.000185, best score = 0.00282915, cur score = 0.00329246, worse accepted = 31.33%\n", "Gen #330: temp = 0.000183, best score = 0.00282915, cur score = 0.00332176, worse accepted = 34.84%\n", "Gen #331: temp = 0.000181, best score = 0.00282915, cur score = 0.00296950, worse accepted = 33.80%\n", "Gen #332: temp = 0.000180, best score = 0.00282915, cur score = 0.00304534, worse accepted = 30.88%\n", "Gen #333: temp = 0.000178, best score = 0.00282915, cur score = 0.00297458, worse accepted = 31.67%\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Gen #334: temp = 0.000176, best score = 0.00282915, cur score = 0.00326508, worse accepted = 31.51%\n", "Gen #335: temp = 0.000174, best score = 0.00282915, cur score = 0.00360273, worse accepted = 28.95%\n", "Gen #336: temp = 0.000172, best score = 0.00282915, cur score = 0.00353117, worse accepted = 33.46%\n", "Gen #337: temp = 0.000171, best score = 0.00282915, cur score = 0.00304915, worse accepted = 31.52%\n", "Gen #338: temp = 0.000169, best score = 0.00282915, cur score = 0.00336499, worse accepted = 31.61%\n", "Gen #339: temp = 0.000167, best score = 0.00282915, cur score = 0.00347768, worse accepted = 30.24%\n", "Gen #340: temp = 0.000166, best score = 0.00282915, cur score = 0.00352157, worse accepted = 31.86%\n", "Gen #341: temp = 0.000164, best score = 0.00282915, cur score = 0.00323765, worse accepted = 30.65%\n", "Gen #342: temp = 0.000162, best score = 0.00282915, cur score = 0.00329003, worse accepted = 31.26%\n", "Gen #343: temp = 0.000161, best score = 0.00282915, cur score = 0.00362503, worse accepted = 31.05%\n", "Gen #344: temp = 0.000159, best score = 0.00282915, cur score = 0.00366605, worse accepted = 30.72%\n", "Gen #345: temp = 0.000158, best score = 0.00282915, cur score = 0.00320035, worse accepted = 30.75%\n", "Gen #346: temp = 0.000156, best score = 0.00282915, cur score = 0.00335306, worse accepted = 31.24%\n", "Gen #347: temp = 0.000154, best score = 0.00282915, cur score = 0.00346911, worse accepted = 31.70%\n", "Gen #348: temp = 0.000153, best score = 0.00282915, cur score = 0.00306865, worse accepted = 29.70%\n", "Gen #349: temp = 0.000151, best score = 0.00282915, cur score = 0.00308105, worse accepted = 30.64%\n", "Gen #350: temp = 0.000150, best score = 0.00282915, cur score = 0.00317424, worse accepted = 32.10%\n", "Gen #351: temp = 0.000148, best score = 0.00282915, cur score = 0.00350506, worse accepted = 29.39%\n", "Gen #352: temp = 0.000147, best score = 0.00282696, cur score = 0.00308641, worse accepted = 31.30%\n", "Gen #353: temp = 0.000145, best score = 0.00282696, cur score = 0.00317365, worse accepted = 30.33%\n", "Gen #354: temp = 0.000144, best score = 0.00282696, cur score = 0.00333100, worse accepted = 29.88%\n", "Gen #355: temp = 0.000143, best score = 0.00282696, cur score = 0.00326846, worse accepted = 30.04%\n", "Gen #356: temp = 0.000141, best score = 0.00282696, cur score = 0.00378269, worse accepted = 28.67%\n", "Gen #357: temp = 0.000140, best score = 0.00282696, cur score = 0.00344294, worse accepted = 32.24%\n", "Gen #358: temp = 0.000138, best score = 0.00282696, cur score = 0.00317573, worse accepted = 27.64%\n", "Gen #359: temp = 0.000137, best score = 0.00282696, cur score = 0.00329469, worse accepted = 28.54%\n", "Gen #360: temp = 0.000136, best score = 0.00282696, cur score = 0.00298672, worse accepted = 31.77%\n", "Gen #361: temp = 0.000134, best score = 0.00282696, cur score = 0.00361122, worse accepted = 30.74%\n", "Gen #362: temp = 0.000133, best score = 0.00282696, cur score = 0.00302898, worse accepted = 28.74%\n", "Gen #363: temp = 0.000131, best score = 0.00282696, cur score = 0.00345033, worse accepted = 29.86%\n", "Gen #364: temp = 0.000130, best score = 0.00282696, cur score = 0.00294771, worse accepted = 29.79%\n", "Gen #365: temp = 0.000129, best score = 0.00282696, cur score = 0.00351190, worse accepted = 29.21%\n", "Gen #366: temp = 0.000128, best score = 0.00282696, cur score = 0.00335300, worse accepted = 29.56%\n", "Gen #367: temp = 0.000126, best score = 0.00282696, cur score = 0.00335385, worse accepted = 27.52%\n", "Gen #368: temp = 0.000125, best score = 0.00282696, cur score = 0.00323086, worse accepted = 28.49%\n", "Gen #369: temp = 0.000124, best score = 0.00282672, cur score = 0.00333487, worse accepted = 29.64%\n", "Gen #370: temp = 0.000123, best score = 0.00282672, cur score = 0.00313950, worse accepted = 29.34%\n", "Gen #371: temp = 0.000121, best score = 0.00282672, cur score = 0.00314650, worse accepted = 29.18%\n", "Gen #372: temp = 0.000120, best score = 0.00282672, cur score = 0.00310468, worse accepted = 26.58%\n", "Gen #373: temp = 0.000119, best score = 0.00282672, cur score = 0.00329300, worse accepted = 25.48%\n", "Gen #374: temp = 0.000118, best score = 0.00282672, cur score = 0.00335052, worse accepted = 28.47%\n", "Gen #375: temp = 0.000117, best score = 0.00282672, cur score = 0.00312283, worse accepted = 24.87%\n", "Gen #376: temp = 0.000115, best score = 0.00282672, cur score = 0.00332992, worse accepted = 28.43%\n", "Gen #377: temp = 0.000114, best score = 0.00282672, cur score = 0.00303945, worse accepted = 27.75%\n", "Gen #378: temp = 0.000113, best score = 0.00282498, cur score = 0.00309897, worse accepted = 27.95%\n", "Gen #379: temp = 0.000112, best score = 0.00282498, cur score = 0.00367848, worse accepted = 27.09%\n", "Gen #380: temp = 0.000111, best score = 0.00282498, cur score = 0.00337377, worse accepted = 26.81%\n", "Gen #381: temp = 0.000110, best score = 0.00282498, cur score = 0.00313159, worse accepted = 24.40%\n", "Gen #382: temp = 0.000109, best score = 0.00282498, cur score = 0.00332116, worse accepted = 27.15%\n", "Gen #383: temp = 0.000108, best score = 0.00282498, cur score = 0.00314724, worse accepted = 26.03%\n", "Gen #384: temp = 0.000106, best score = 0.00282498, cur score = 0.00318869, worse accepted = 26.38%\n", "Gen #385: temp = 0.000105, best score = 0.00282498, cur score = 0.00340383, worse accepted = 26.45%\n", "Gen #386: temp = 0.000104, best score = 0.00282498, cur score = 0.00291268, worse accepted = 26.85%\n", "Gen #387: temp = 0.000103, best score = 0.00282498, cur score = 0.00331666, worse accepted = 26.19%\n", "Gen #388: temp = 0.000102, best score = 0.00282498, cur score = 0.00316063, worse accepted = 25.25%\n", "Gen #389: temp = 0.000101, best score = 0.00282498, cur score = 0.00307196, worse accepted = 24.62%\n", "Gen #390: temp = 0.000100, best score = 0.00282498, cur score = 0.00306756, worse accepted = 26.09%\n", "Gen #391: temp = 0.000099, best score = 0.00282498, cur score = 0.00313682, worse accepted = 25.65%\n", "Gen #392: temp = 0.000098, best score = 0.00282498, cur score = 0.00362581, worse accepted = 26.61%\n", "Gen #393: temp = 0.000097, best score = 0.00282498, cur score = 0.00332878, worse accepted = 25.92%\n", "Gen #394: temp = 0.000096, best score = 0.00282498, cur score = 0.00315909, worse accepted = 25.72%\n", "Gen #395: temp = 0.000095, best score = 0.00282498, cur score = 0.00324239, worse accepted = 25.86%\n", "Gen #396: temp = 0.000094, best score = 0.00282498, cur score = 0.00324753, worse accepted = 24.01%\n", "Gen #397: temp = 0.000093, best score = 0.00282498, cur score = 0.00314980, worse accepted = 26.27%\n", "Gen #398: temp = 0.000093, best score = 0.00282498, cur score = 0.00293839, worse accepted = 25.98%\n", "Gen #399: temp = 0.000092, best score = 0.00282498, cur score = 0.00298745, worse accepted = 25.30%\n", "Gen #400: temp = 0.000091, best score = 0.00282498, cur score = 0.00291775, worse accepted = 24.94%\n", "Gen #401: temp = 0.000090, best score = 0.00282498, cur score = 0.00300014, worse accepted = 23.77%\n", "Gen #402: temp = 0.000089, best score = 0.00282498, cur score = 0.00352130, worse accepted = 23.65%\n", "Gen #403: temp = 0.000088, best score = 0.00282498, cur score = 0.00305195, worse accepted = 25.18%\n", "Gen #404: temp = 0.000087, best score = 0.00282498, cur score = 0.00292317, worse accepted = 24.57%\n", "Gen #405: temp = 0.000086, best score = 0.00282498, cur score = 0.00323538, worse accepted = 23.26%\n", "Gen #406: temp = 0.000085, best score = 0.00282498, cur score = 0.00300814, worse accepted = 24.66%\n", "Gen #407: temp = 0.000085, best score = 0.00282498, cur score = 0.00305455, worse accepted = 22.42%\n", "Gen #408: temp = 0.000084, best score = 0.00282498, cur score = 0.00312020, worse accepted = 23.30%\n", "Gen #409: temp = 0.000083, best score = 0.00282498, cur score = 0.00295998, worse accepted = 23.95%\n", "Gen #410: temp = 0.000082, best score = 0.00282498, cur score = 0.00319882, worse accepted = 23.20%\n", "Gen #411: temp = 0.000081, best score = 0.00282498, cur score = 0.00298511, worse accepted = 23.54%\n", "Gen #412: temp = 0.000080, best score = 0.00282498, cur score = 0.00323272, worse accepted = 23.73%\n", "Gen #413: temp = 0.000080, best score = 0.00282498, cur score = 0.00291359, worse accepted = 23.00%\n", "Gen #414: temp = 0.000079, best score = 0.00282498, cur score = 0.00302526, worse accepted = 22.19%\n", "Gen #415: temp = 0.000078, best score = 0.00282498, cur score = 0.00308427, worse accepted = 22.41%\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Gen #416: temp = 0.000077, best score = 0.00282498, cur score = 0.00298631, worse accepted = 21.88%\n", "Gen #417: temp = 0.000076, best score = 0.00282498, cur score = 0.00301183, worse accepted = 23.23%\n", "Gen #418: temp = 0.000076, best score = 0.00282498, cur score = 0.00308927, worse accepted = 23.34%\n", "Gen #419: temp = 0.000075, best score = 0.00282498, cur score = 0.00302248, worse accepted = 22.73%\n", "Gen #420: temp = 0.000074, best score = 0.00282498, cur score = 0.00287342, worse accepted = 22.74%\n", "Gen #421: temp = 0.000073, best score = 0.00282498, cur score = 0.00289623, worse accepted = 22.65%\n", "Gen #422: temp = 0.000073, best score = 0.00282498, cur score = 0.00313268, worse accepted = 21.65%\n", "Gen #423: temp = 0.000072, best score = 0.00282498, cur score = 0.00304524, worse accepted = 21.00%\n", "Gen #424: temp = 0.000071, best score = 0.00282498, cur score = 0.00302269, worse accepted = 21.42%\n", "Gen #425: temp = 0.000071, best score = 0.00282498, cur score = 0.00303798, worse accepted = 20.22%\n", "Gen #426: temp = 0.000070, best score = 0.00282498, cur score = 0.00299335, worse accepted = 21.28%\n", "Gen #427: temp = 0.000069, best score = 0.00282498, cur score = 0.00311531, worse accepted = 20.92%\n", "Gen #428: temp = 0.000068, best score = 0.00282498, cur score = 0.00323849, worse accepted = 21.01%\n", "Gen #429: temp = 0.000068, best score = 0.00282498, cur score = 0.00294064, worse accepted = 20.92%\n", "Gen #430: temp = 0.000067, best score = 0.00282498, cur score = 0.00295463, worse accepted = 20.50%\n", "Gen #431: temp = 0.000066, best score = 0.00282498, cur score = 0.00310962, worse accepted = 18.76%\n", "Gen #432: temp = 0.000066, best score = 0.00282498, cur score = 0.00302224, worse accepted = 20.48%\n", "Gen #433: temp = 0.000065, best score = 0.00282498, cur score = 0.00309760, worse accepted = 19.30%\n", "Gen #434: temp = 0.000064, best score = 0.00282498, cur score = 0.00324279, worse accepted = 19.38%\n", "Gen #435: temp = 0.000064, best score = 0.00282498, cur score = 0.00311834, worse accepted = 19.97%\n", "Gen #436: temp = 0.000063, best score = 0.00282498, cur score = 0.00302654, worse accepted = 19.53%\n", "Gen #437: temp = 0.000063, best score = 0.00282498, cur score = 0.00291501, worse accepted = 19.13%\n", "Gen #438: temp = 0.000062, best score = 0.00282498, cur score = 0.00310176, worse accepted = 19.24%\n", "Gen #439: temp = 0.000061, best score = 0.00282498, cur score = 0.00290763, worse accepted = 19.02%\n", "Gen #440: temp = 0.000061, best score = 0.00282498, cur score = 0.00324834, worse accepted = 18.34%\n", "Gen #441: temp = 0.000060, best score = 0.00282498, cur score = 0.00314488, worse accepted = 18.22%\n", "Gen #442: temp = 0.000059, best score = 0.00282498, cur score = 0.00305639, worse accepted = 18.82%\n", "Gen #443: temp = 0.000059, best score = 0.00282498, cur score = 0.00302569, worse accepted = 17.70%\n", "Gen #444: temp = 0.000058, best score = 0.00282498, cur score = 0.00296730, worse accepted = 18.24%\n", "Gen #445: temp = 0.000058, best score = 0.00282498, cur score = 0.00324847, worse accepted = 17.67%\n", "Gen #446: temp = 0.000057, best score = 0.00282498, cur score = 0.00302956, worse accepted = 18.42%\n", "Gen #447: temp = 0.000057, best score = 0.00282498, cur score = 0.00294303, worse accepted = 17.67%\n", "Gen #448: temp = 0.000056, best score = 0.00282498, cur score = 0.00308367, worse accepted = 17.77%\n", "Gen #449: temp = 0.000055, best score = 0.00282498, cur score = 0.00300759, worse accepted = 17.36%\n", "Gen #450: temp = 0.000055, best score = 0.00282498, cur score = 0.00298864, worse accepted = 16.82%\n", "Gen #451: temp = 0.000054, best score = 0.00282498, cur score = 0.00294219, worse accepted = 17.18%\n", "Gen #452: temp = 0.000054, best score = 0.00282498, cur score = 0.00294316, worse accepted = 17.53%\n", "Gen #453: temp = 0.000053, best score = 0.00282498, cur score = 0.00328221, worse accepted = 15.95%\n", "Gen #454: temp = 0.000053, best score = 0.00282498, cur score = 0.00296507, worse accepted = 16.79%\n", "Gen #455: temp = 0.000052, best score = 0.00282498, cur score = 0.00290755, worse accepted = 16.19%\n", "Gen #456: temp = 0.000052, best score = 0.00282498, cur score = 0.00304525, worse accepted = 15.81%\n", "Gen #457: temp = 0.000051, best score = 0.00282498, cur score = 0.00287126, worse accepted = 16.78%\n", "Gen #458: temp = 0.000051, best score = 0.00282498, cur score = 0.00299961, worse accepted = 15.99%\n", "Gen #459: temp = 0.000050, best score = 0.00282498, cur score = 0.00292039, worse accepted = 15.17%\n", "Gen #460: temp = 0.000050, best score = 0.00282498, cur score = 0.00293049, worse accepted = 15.70%\n", "Gen #461: temp = 0.000049, best score = 0.00282498, cur score = 0.00318944, worse accepted = 16.24%\n", "Gen #462: temp = 0.000049, best score = 0.00282498, cur score = 0.00297401, worse accepted = 15.50%\n", "Gen #463: temp = 0.000048, best score = 0.00282498, cur score = 0.00303141, worse accepted = 15.19%\n", "Gen #464: temp = 0.000048, best score = 0.00282498, cur score = 0.00294327, worse accepted = 14.85%\n", "Gen #465: temp = 0.000047, best score = 0.00282498, cur score = 0.00288812, worse accepted = 15.55%\n", "Gen #466: temp = 0.000047, best score = 0.00282498, cur score = 0.00299089, worse accepted = 14.22%\n", "Gen #467: temp = 0.000046, best score = 0.00282498, cur score = 0.00300502, worse accepted = 14.47%\n", "Gen #468: temp = 0.000046, best score = 0.00282498, cur score = 0.00294352, worse accepted = 14.38%\n", "Gen #469: temp = 0.000045, best score = 0.00282498, cur score = 0.00290222, worse accepted = 13.21%\n", "Gen #470: temp = 0.000045, best score = 0.00282498, cur score = 0.00302945, worse accepted = 14.21%\n", "Gen #471: temp = 0.000044, best score = 0.00282460, cur score = 0.00284759, worse accepted = 14.32%\n", "Gen #472: temp = 0.000044, best score = 0.00282460, cur score = 0.00289458, worse accepted = 12.81%\n", "Gen #473: temp = 0.000044, best score = 0.00282460, cur score = 0.00294937, worse accepted = 14.17%\n", "Gen #474: temp = 0.000043, best score = 0.00282460, cur score = 0.00299939, worse accepted = 14.07%\n", "Gen #475: temp = 0.000043, best score = 0.00282460, cur score = 0.00285609, worse accepted = 12.66%\n", "Gen #476: temp = 0.000042, best score = 0.00282460, cur score = 0.00287451, worse accepted = 13.49%\n", "Gen #477: temp = 0.000042, best score = 0.00282460, cur score = 0.00290166, worse accepted = 13.75%\n", "Gen #478: temp = 0.000041, best score = 0.00282460, cur score = 0.00299110, worse accepted = 12.68%\n", "Gen #479: temp = 0.000041, best score = 0.00282460, cur score = 0.00298485, worse accepted = 12.84%\n", "Gen #480: temp = 0.000041, best score = 0.00282460, cur score = 0.00291696, worse accepted = 12.79%\n", "Gen #481: temp = 0.000040, best score = 0.00282460, cur score = 0.00297295, worse accepted = 12.64%\n", "Gen #482: temp = 0.000040, best score = 0.00282460, cur score = 0.00293133, worse accepted = 12.16%\n", "Gen #483: temp = 0.000039, best score = 0.00282460, cur score = 0.00300076, worse accepted = 12.05%\n", "Gen #484: temp = 0.000039, best score = 0.00282460, cur score = 0.00298259, worse accepted = 12.00%\n", "Gen #485: temp = 0.000039, best score = 0.00282460, cur score = 0.00293531, worse accepted = 11.29%\n", "Gen #486: temp = 0.000038, best score = 0.00282460, cur score = 0.00299139, worse accepted = 11.54%\n", "Gen #487: temp = 0.000038, best score = 0.00282460, cur score = 0.00295127, worse accepted = 11.05%\n", "Gen #488: temp = 0.000037, best score = 0.00282460, cur score = 0.00292514, worse accepted = 10.79%\n", "Gen #489: temp = 0.000037, best score = 0.00282460, cur score = 0.00295453, worse accepted = 11.42%\n", "Gen #490: temp = 0.000037, best score = 0.00282460, cur score = 0.00304656, worse accepted = 10.65%\n", "Gen #491: temp = 0.000036, best score = 0.00282460, cur score = 0.00293108, worse accepted = 10.84%\n", "Gen #492: temp = 0.000036, best score = 0.00282460, cur score = 0.00285729, worse accepted = 11.07%\n", "Gen #493: temp = 0.000036, best score = 0.00282460, cur score = 0.00289137, worse accepted = 10.77%\n", "Gen #494: temp = 0.000035, best score = 0.00282460, cur score = 0.00287572, worse accepted = 11.16%\n", "Gen #495: temp = 0.000035, best score = 0.00282460, cur score = 0.00291608, worse accepted = 10.27%\n", "Gen #496: temp = 0.000035, best score = 0.00282460, cur score = 0.00293257, worse accepted = 9.73%\n", "Gen #497: temp = 0.000034, best score = 0.00282460, cur score = 0.00292071, worse accepted = 9.88%\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Gen #498: temp = 0.000034, best score = 0.00282302, cur score = 0.00285795, worse accepted = 9.14%\n", "Gen #499: temp = 0.000034, best score = 0.00282302, cur score = 0.00291653, worse accepted = 9.67%\n", "Gen #500: temp = 0.000033, best score = 0.00282302, cur score = 0.00286959, worse accepted = 10.05%\n", "Gen #501: temp = 0.000033, best score = 0.00282302, cur score = 0.00286231, worse accepted = 9.17%\n", "Gen #502: temp = 0.000033, best score = 0.00282302, cur score = 0.00296747, worse accepted = 9.11%\n", "Gen #503: temp = 0.000032, best score = 0.00282302, cur score = 0.00290710, worse accepted = 9.33%\n", "Gen #504: temp = 0.000032, best score = 0.00282302, cur score = 0.00286387, worse accepted = 9.32%\n", "Gen #505: temp = 0.000032, best score = 0.00282302, cur score = 0.00286346, worse accepted = 9.28%\n", "Gen #506: temp = 0.000031, best score = 0.00282302, cur score = 0.00290621, worse accepted = 9.21%\n", "Gen #507: temp = 0.000031, best score = 0.00282302, cur score = 0.00297317, worse accepted = 8.72%\n", "Gen #508: temp = 0.000031, best score = 0.00282302, cur score = 0.00289008, worse accepted = 9.44%\n", "Gen #509: temp = 0.000030, best score = 0.00282302, cur score = 0.00293311, worse accepted = 8.36%\n", "Gen #510: temp = 0.000030, best score = 0.00282302, cur score = 0.00291671, worse accepted = 8.86%\n", "Gen #511: temp = 0.000030, best score = 0.00282302, cur score = 0.00298772, worse accepted = 7.67%\n", "Gen #512: temp = 0.000029, best score = 0.00282302, cur score = 0.00292590, worse accepted = 7.63%\n", "Gen #513: temp = 0.000029, best score = 0.00282302, cur score = 0.00292483, worse accepted = 8.11%\n", "Gen #514: temp = 0.000029, best score = 0.00282302, cur score = 0.00287872, worse accepted = 7.50%\n", "Gen #515: temp = 0.000029, best score = 0.00282302, cur score = 0.00295055, worse accepted = 8.25%\n", "Gen #516: temp = 0.000028, best score = 0.00282302, cur score = 0.00293276, worse accepted = 7.85%\n", "Gen #517: temp = 0.000028, best score = 0.00282302, cur score = 0.00287838, worse accepted = 7.60%\n", "Gen #518: temp = 0.000028, best score = 0.00282302, cur score = 0.00287226, worse accepted = 7.27%\n", "Gen #519: temp = 0.000027, best score = 0.00282302, cur score = 0.00286689, worse accepted = 8.10%\n", "Gen #520: temp = 0.000027, best score = 0.00282302, cur score = 0.00288782, worse accepted = 7.32%\n", "Gen #521: temp = 0.000027, best score = 0.00282302, cur score = 0.00295687, worse accepted = 7.40%\n", "Gen #522: temp = 0.000027, best score = 0.00282302, cur score = 0.00286980, worse accepted = 7.41%\n", "Gen #523: temp = 0.000026, best score = 0.00282302, cur score = 0.00288614, worse accepted = 7.25%\n", "Gen #524: temp = 0.000026, best score = 0.00282302, cur score = 0.00291369, worse accepted = 7.18%\n", "Gen #525: temp = 0.000026, best score = 0.00282302, cur score = 0.00294889, worse accepted = 6.76%\n", "Gen #526: temp = 0.000026, best score = 0.00282302, cur score = 0.00297005, worse accepted = 6.80%\n", "Gen #527: temp = 0.000025, best score = 0.00282302, cur score = 0.00285848, worse accepted = 6.86%\n", "Gen #528: temp = 0.000025, best score = 0.00282302, cur score = 0.00286972, worse accepted = 6.10%\n", "Gen #529: temp = 0.000025, best score = 0.00282302, cur score = 0.00290712, worse accepted = 5.74%\n", "Gen #530: temp = 0.000025, best score = 0.00282302, cur score = 0.00283068, worse accepted = 6.22%\n", "Gen #531: temp = 0.000024, best score = 0.00282302, cur score = 0.00284042, worse accepted = 6.14%\n", "Gen #532: temp = 0.000024, best score = 0.00282302, cur score = 0.00289473, worse accepted = 6.62%\n", "Gen #533: temp = 0.000024, best score = 0.00282302, cur score = 0.00291001, worse accepted = 6.13%\n", "Gen #534: temp = 0.000024, best score = 0.00282302, cur score = 0.00287514, worse accepted = 5.23%\n", "Gen #535: temp = 0.000023, best score = 0.00282302, cur score = 0.00285962, worse accepted = 5.29%\n", "Gen #536: temp = 0.000023, best score = 0.00282302, cur score = 0.00291572, worse accepted = 5.87%\n", "Gen #537: temp = 0.000023, best score = 0.00282302, cur score = 0.00296103, worse accepted = 5.81%\n", "Gen #538: temp = 0.000023, best score = 0.00282302, cur score = 0.00289307, worse accepted = 5.67%\n", "Gen #539: temp = 0.000022, best score = 0.00282302, cur score = 0.00303663, worse accepted = 5.33%\n", "Gen #540: temp = 0.000022, best score = 0.00282302, cur score = 0.00284231, worse accepted = 5.47%\n", "Gen #541: temp = 0.000022, best score = 0.00282302, cur score = 0.00286242, worse accepted = 4.88%\n", "Gen #542: temp = 0.000022, best score = 0.00282302, cur score = 0.00286294, worse accepted = 5.16%\n", "Gen #543: temp = 0.000022, best score = 0.00282302, cur score = 0.00291449, worse accepted = 5.07%\n", "Gen #544: temp = 0.000021, best score = 0.00282302, cur score = 0.00289717, worse accepted = 4.67%\n", "Gen #545: temp = 0.000021, best score = 0.00282292, cur score = 0.00282292, worse accepted = 4.93%\n", "Gen #546: temp = 0.000021, best score = 0.00282292, cur score = 0.00289283, worse accepted = 4.84%\n", "Gen #547: temp = 0.000021, best score = 0.00282292, cur score = 0.00287707, worse accepted = 4.35%\n", "Gen #548: temp = 0.000020, best score = 0.00282292, cur score = 0.00292117, worse accepted = 4.95%\n", "Gen #549: temp = 0.000020, best score = 0.00282292, cur score = 0.00292185, worse accepted = 4.79%\n", "Gen #550: temp = 0.000020, best score = 0.00282292, cur score = 0.00284967, worse accepted = 4.42%\n", "Gen #551: temp = 0.000020, best score = 0.00282292, cur score = 0.00288272, worse accepted = 4.45%\n", "Gen #552: temp = 0.000020, best score = 0.00282292, cur score = 0.00286053, worse accepted = 4.64%\n", "Gen #553: temp = 0.000019, best score = 0.00282292, cur score = 0.00291825, worse accepted = 3.76%\n", "Gen #554: temp = 0.000019, best score = 0.00282292, cur score = 0.00289067, worse accepted = 4.64%\n", "Gen #555: temp = 0.000019, best score = 0.00282292, cur score = 0.00286563, worse accepted = 4.01%\n", "Gen #556: temp = 0.000019, best score = 0.00282292, cur score = 0.00299948, worse accepted = 4.03%\n", "Gen #557: temp = 0.000019, best score = 0.00282292, cur score = 0.00297396, worse accepted = 4.43%\n", "Gen #558: temp = 0.000019, best score = 0.00282292, cur score = 0.00283697, worse accepted = 3.92%\n", "Gen #559: temp = 0.000018, best score = 0.00282292, cur score = 0.00293284, worse accepted = 3.48%\n", "Gen #560: temp = 0.000018, best score = 0.00282292, cur score = 0.00294356, worse accepted = 3.78%\n", "Gen #561: temp = 0.000018, best score = 0.00282233, cur score = 0.00285113, worse accepted = 3.51%\n", "Gen #562: temp = 0.000018, best score = 0.00282233, cur score = 0.00288097, worse accepted = 3.68%\n", "Gen #563: temp = 0.000018, best score = 0.00282233, cur score = 0.00292218, worse accepted = 3.36%\n", "Gen #564: temp = 0.000017, best score = 0.00282233, cur score = 0.00293494, worse accepted = 3.24%\n", "Gen #565: temp = 0.000017, best score = 0.00282233, cur score = 0.00287918, worse accepted = 3.94%\n", "Gen #566: temp = 0.000017, best score = 0.00282233, cur score = 0.00290054, worse accepted = 3.21%\n", "Gen #567: temp = 0.000017, best score = 0.00282233, cur score = 0.00286447, worse accepted = 3.80%\n", "Gen #568: temp = 0.000017, best score = 0.00282233, cur score = 0.00288946, worse accepted = 3.71%\n", "Gen #569: temp = 0.000017, best score = 0.00282233, cur score = 0.00283559, worse accepted = 2.74%\n", "Gen #570: temp = 0.000016, best score = 0.00282233, cur score = 0.00284116, worse accepted = 3.04%\n", "Gen #571: temp = 0.000016, best score = 0.00282233, cur score = 0.00286501, worse accepted = 3.23%\n", "Gen #572: temp = 0.000016, best score = 0.00282233, cur score = 0.00293920, worse accepted = 3.13%\n", "Gen #573: temp = 0.000016, best score = 0.00282233, cur score = 0.00284862, worse accepted = 3.01%\n", "Gen #574: temp = 0.000016, best score = 0.00282233, cur score = 0.00283368, worse accepted = 2.84%\n", "Gen #575: temp = 0.000016, best score = 0.00282233, cur score = 0.00285943, worse accepted = 2.44%\n", "Gen #576: temp = 0.000015, best score = 0.00282233, cur score = 0.00283915, worse accepted = 2.71%\n", "Gen #577: temp = 0.000015, best score = 0.00282233, cur score = 0.00286130, worse accepted = 2.83%\n", "Gen #578: temp = 0.000015, best score = 0.00282233, cur score = 0.00285153, worse accepted = 2.65%\n", "Gen #579: temp = 0.000015, best score = 0.00282233, cur score = 0.00283168, worse accepted = 2.79%\n", "Gen #580: temp = 0.000015, best score = 0.00282233, cur score = 0.00283506, worse accepted = 3.03%\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Gen #581: temp = 0.000015, best score = 0.00282233, cur score = 0.00287821, worse accepted = 2.21%\n", "Gen #582: temp = 0.000015, best score = 0.00282192, cur score = 0.00282888, worse accepted = 2.33%\n", "Gen #583: temp = 0.000014, best score = 0.00282192, cur score = 0.00286232, worse accepted = 2.13%\n", "Gen #584: temp = 0.000014, best score = 0.00282192, cur score = 0.00292006, worse accepted = 2.65%\n", "Gen #585: temp = 0.000014, best score = 0.00282192, cur score = 0.00286502, worse accepted = 2.24%\n", "Gen #586: temp = 0.000014, best score = 0.00282192, cur score = 0.00284576, worse accepted = 2.16%\n", "Gen #587: temp = 0.000014, best score = 0.00282192, cur score = 0.00289848, worse accepted = 2.29%\n", "Gen #588: temp = 0.000014, best score = 0.00282192, cur score = 0.00285102, worse accepted = 2.27%\n", "Gen #589: temp = 0.000014, best score = 0.00282192, cur score = 0.00288068, worse accepted = 2.03%\n", "Gen #590: temp = 0.000013, best score = 0.00282192, cur score = 0.00286061, worse accepted = 2.10%\n", "Gen #591: temp = 0.000013, best score = 0.00282192, cur score = 0.00285929, worse accepted = 1.84%\n", "Gen #592: temp = 0.000013, best score = 0.00282192, cur score = 0.00288388, worse accepted = 2.04%\n", "Gen #593: temp = 0.000013, best score = 0.00282192, cur score = 0.00284804, worse accepted = 2.26%\n", "Gen #594: temp = 0.000013, best score = 0.00282192, cur score = 0.00286161, worse accepted = 1.71%\n", "Gen #595: temp = 0.000013, best score = 0.00282192, cur score = 0.00292498, worse accepted = 1.79%\n", "Gen #596: temp = 0.000013, best score = 0.00282192, cur score = 0.00284958, worse accepted = 1.59%\n", "Gen #597: temp = 0.000013, best score = 0.00282192, cur score = 0.00283101, worse accepted = 1.79%\n", "Gen #598: temp = 0.000012, best score = 0.00282192, cur score = 0.00285347, worse accepted = 1.86%\n", "Gen #599: temp = 0.000012, best score = 0.00282192, cur score = 0.00286332, worse accepted = 1.71%\n", "Gen #600: temp = 0.000012, best score = 0.00282192, cur score = 0.00288490, worse accepted = 2.13%\n", "Gen #601: temp = 0.000012, best score = 0.00282192, cur score = 0.00283831, worse accepted = 1.74%\n", "Gen #602: temp = 0.000012, best score = 0.00282192, cur score = 0.00288006, worse accepted = 1.30%\n", "Gen #603: temp = 0.000012, best score = 0.00282192, cur score = 0.00289160, worse accepted = 1.78%\n", "Gen #604: temp = 0.000012, best score = 0.00282192, cur score = 0.00287103, worse accepted = 2.09%\n", "Gen #605: temp = 0.000012, best score = 0.00282192, cur score = 0.00286065, worse accepted = 1.55%\n", "Gen #606: temp = 0.000011, best score = 0.00282192, cur score = 0.00283071, worse accepted = 1.26%\n", "Gen #607: temp = 0.000011, best score = 0.00282192, cur score = 0.00289788, worse accepted = 1.63%\n", "Gen #608: temp = 0.000011, best score = 0.00282192, cur score = 0.00283877, worse accepted = 1.57%\n", "Gen #609: temp = 0.000011, best score = 0.00282192, cur score = 0.00295606, worse accepted = 1.56%\n", "Gen #610: temp = 0.000011, best score = 0.00282192, cur score = 0.00284553, worse accepted = 1.24%\n", "Gen #611: temp = 0.000011, best score = 0.00282192, cur score = 0.00284172, worse accepted = 1.32%\n", "Gen #612: temp = 0.000011, best score = 0.00282192, cur score = 0.00287113, worse accepted = 1.21%\n", "Gen #613: temp = 0.000011, best score = 0.00282192, cur score = 0.00286593, worse accepted = 1.20%\n", "Gen #614: temp = 0.000011, best score = 0.00282192, cur score = 0.00284686, worse accepted = 1.36%\n", "Gen #615: temp = 0.000010, best score = 0.00282192, cur score = 0.00284020, worse accepted = 0.99%\n", "Gen #616: temp = 0.000010, best score = 0.00282192, cur score = 0.00287625, worse accepted = 1.13%\n", "Gen #617: temp = 0.000010, best score = 0.00282192, cur score = 0.00285793, worse accepted = 1.15%\n", "Gen #618: temp = 0.000010, best score = 0.00282192, cur score = 0.00284067, worse accepted = 0.85%\n", "Gen #619: temp = 0.000010, best score = 0.00282192, cur score = 0.00283652, worse accepted = 1.07%\n", "Gen #620: temp = 0.000010, best score = 0.00282177, cur score = 0.00284482, worse accepted = 1.29%\n", "Gen #621: temp = 0.000010, best score = 0.00282177, cur score = 0.00289089, worse accepted = 1.43%\n", "Gen #622: temp = 0.000010, best score = 0.00282177, cur score = 0.00288093, worse accepted = 0.94%\n", "Gen #623: temp = 0.000010, best score = 0.00282177, cur score = 0.00283261, worse accepted = 1.10%\n", "Gen #624: temp = 0.000010, best score = 0.00282177, cur score = 0.00286658, worse accepted = 0.97%\n", "Gen #625: temp = 0.000009, best score = 0.00282177, cur score = 0.00283904, worse accepted = 0.98%\n", "Gen #626: temp = 0.000009, best score = 0.00282177, cur score = 0.00285393, worse accepted = 0.90%\n", "Gen #627: temp = 0.000009, best score = 0.00282177, cur score = 0.00286792, worse accepted = 0.84%\n", "Gen #628: temp = 0.000009, best score = 0.00282177, cur score = 0.00286144, worse accepted = 0.72%\n", "Gen #629: temp = 0.000009, best score = 0.00282177, cur score = 0.00288610, worse accepted = 0.93%\n", "Gen #630: temp = 0.000009, best score = 0.00282177, cur score = 0.00284435, worse accepted = 0.80%\n", "Gen #631: temp = 0.000009, best score = 0.00282177, cur score = 0.00283472, worse accepted = 0.93%\n", "Gen #632: temp = 0.000009, best score = 0.00282177, cur score = 0.00283528, worse accepted = 0.85%\n", "Gen #633: temp = 0.000009, best score = 0.00282177, cur score = 0.00285032, worse accepted = 0.91%\n", "Gen #634: temp = 0.000009, best score = 0.00282177, cur score = 0.00284142, worse accepted = 0.76%\n", "Gen #635: temp = 0.000009, best score = 0.00282177, cur score = 0.00286226, worse accepted = 0.53%\n", "Gen #636: temp = 0.000008, best score = 0.00282177, cur score = 0.00286365, worse accepted = 0.89%\n", "Gen #637: temp = 0.000008, best score = 0.00282177, cur score = 0.00283486, worse accepted = 0.60%\n", "Gen #638: temp = 0.000008, best score = 0.00282177, cur score = 0.00287001, worse accepted = 0.76%\n", "Gen #639: temp = 0.000008, best score = 0.00282177, cur score = 0.00283836, worse accepted = 0.72%\n", "Gen #640: temp = 0.000008, best score = 0.00282177, cur score = 0.00286493, worse accepted = 0.72%\n", "Gen #641: temp = 0.000008, best score = 0.00282177, cur score = 0.00283513, worse accepted = 0.65%\n", "Gen #642: temp = 0.000008, best score = 0.00282177, cur score = 0.00285249, worse accepted = 0.90%\n", "Gen #643: temp = 0.000008, best score = 0.00282177, cur score = 0.00282509, worse accepted = 0.67%\n", "Gen #644: temp = 0.000008, best score = 0.00282177, cur score = 0.00283658, worse accepted = 0.37%\n", "Gen #645: temp = 0.000008, best score = 0.00282177, cur score = 0.00284119, worse accepted = 0.50%\n", "Gen #646: temp = 0.000008, best score = 0.00282177, cur score = 0.00284179, worse accepted = 0.64%\n", "Gen #647: temp = 0.000008, best score = 0.00282177, cur score = 0.00286248, worse accepted = 0.40%\n", "Gen #648: temp = 0.000007, best score = 0.00282177, cur score = 0.00283066, worse accepted = 0.51%\n", "Gen #649: temp = 0.000007, best score = 0.00282177, cur score = 0.00284608, worse accepted = 0.60%\n", "Gen #650: temp = 0.000007, best score = 0.00282177, cur score = 0.00283523, worse accepted = 0.47%\n", "Gen #651: temp = 0.000007, best score = 0.00282177, cur score = 0.00283417, worse accepted = 0.43%\n", "Gen #652: temp = 0.000007, best score = 0.00282177, cur score = 0.00283175, worse accepted = 0.64%\n", "Gen #653: temp = 0.000007, best score = 0.00282177, cur score = 0.00283534, worse accepted = 0.54%\n", "Gen #654: temp = 0.000007, best score = 0.00282177, cur score = 0.00285217, worse accepted = 0.25%\n", "Gen #655: temp = 0.000007, best score = 0.00282177, cur score = 0.00285219, worse accepted = 0.44%\n", "Gen #656: temp = 0.000007, best score = 0.00282177, cur score = 0.00285448, worse accepted = 0.40%\n", "Gen #657: temp = 0.000007, best score = 0.00282177, cur score = 0.00284070, worse accepted = 0.44%\n", "Gen #658: temp = 0.000007, best score = 0.00282177, cur score = 0.00283573, worse accepted = 0.26%\n", "Gen #659: temp = 0.000007, best score = 0.00282177, cur score = 0.00283518, worse accepted = 0.45%\n", "Gen #660: temp = 0.000007, best score = 0.00282177, cur score = 0.00285004, worse accepted = 0.51%\n", "Gen #661: temp = 0.000007, best score = 0.00282177, cur score = 0.00284684, worse accepted = 0.50%\n", "Gen #662: temp = 0.000007, best score = 0.00282177, cur score = 0.00286895, worse accepted = 0.46%\n", "Gen #663: temp = 0.000006, best score = 0.00282177, cur score = 0.00283588, worse accepted = 0.45%\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "Gen #664: temp = 0.000006, best score = 0.00282177, cur score = 0.00285278, worse accepted = 0.56%\n", "Gen #665: temp = 0.000006, best score = 0.00282177, cur score = 0.00286040, worse accepted = 0.26%\n", "Gen #666: temp = 0.000006, best score = 0.00282177, cur score = 0.00284972, worse accepted = 0.51%\n", "Gen #667: temp = 0.000006, best score = 0.00282177, cur score = 0.00282732, worse accepted = 0.22%\n", "Gen #668: temp = 0.000006, best score = 0.00282177, cur score = 0.00284093, worse accepted = 0.30%\n", "Gen #669: temp = 0.000006, best score = 0.00282177, cur score = 0.00284471, worse accepted = 0.37%\n", "Gen #670: temp = 0.000006, best score = 0.00282177, cur score = 0.00283511, worse accepted = 0.33%\n", "Gen #671: temp = 0.000006, best score = 0.00282177, cur score = 0.00284310, worse accepted = 0.40%\n", "Gen #672: temp = 0.000006, best score = 0.00282177, cur score = 0.00284440, worse accepted = 0.39%\n", "Gen #673: temp = 0.000006, best score = 0.00282177, cur score = 0.00284997, worse accepted = 0.35%\n", "Gen #674: temp = 0.000006, best score = 0.00282177, cur score = 0.00283002, worse accepted = 0.45%\n", "Gen #675: temp = 0.000006, best score = 0.00282177, cur score = 0.00284513, worse accepted = 0.20%\n", "Gen #676: temp = 0.000006, best score = 0.00282177, cur score = 0.00285799, worse accepted = 0.28%\n", "Gen #677: temp = 0.000006, best score = 0.00282177, cur score = 0.00282318, worse accepted = 0.22%\n", "Gen #678: temp = 0.000006, best score = 0.00282177, cur score = 0.00285343, worse accepted = 0.17%\n", "Gen #679: temp = 0.000005, best score = 0.00282177, cur score = 0.00283190, worse accepted = 0.14%\n", "Gen #680: temp = 0.000005, best score = 0.00282177, cur score = 0.00283850, worse accepted = 0.22%\n", "Gen #681: temp = 0.000005, best score = 0.00282177, cur score = 0.00282934, worse accepted = 0.29%\n", "Gen #682: temp = 0.000005, best score = 0.00282177, cur score = 0.00287681, worse accepted = 0.37%\n", "Gen #683: temp = 0.000005, best score = 0.00282177, cur score = 0.00283938, worse accepted = 0.22%\n", "Gen #684: temp = 0.000005, best score = 0.00282177, cur score = 0.00283678, worse accepted = 0.15%\n", "Gen #685: temp = 0.000005, best score = 0.00282177, cur score = 0.00286002, worse accepted = 0.26%\n", "Gen #686: temp = 0.000005, best score = 0.00282177, cur score = 0.00282468, worse accepted = 0.25%\n", "Gen #687: temp = 0.000005, best score = 0.00282177, cur score = 0.00283057, worse accepted = 0.20%\n", "Gen #688: temp = 0.000005, best score = 0.00282177, cur score = 0.00283495, worse accepted = 0.13%\n" ] } ], "source": [ "temp = initial_temp\n", "generation = 0\n", "best_sol = None\n", "best_score = None\n", "\n", "while temp >= final_temp:\n", " generation += 1\n", " accepted_worse = 0\n", " total_worse = 0\n", " for i in range(trials_per_temp):\n", " new_sol = tweak(*sol)\n", " while not satisfies_constraints(*new_sol):\n", " new_sol = tweak(*sol)\n", "\n", " new_value = score(*new_sol)\n", " \n", " delta = new_value - value\n", " delta *= -1\n", " if delta >= 0:\n", " sol = new_sol\n", " value = new_value\n", " if best_score is None or value < best_score:\n", " best_sol = sol\n", " best_score = value\n", " else:\n", " total_worse += 1\n", " p = math.exp(delta/temp)\n", " r = random.random()\n", " if r <= p:\n", " accepted_worse += 1\n", " sol = new_sol\n", " value = new_value\n", " \n", " print(\n", " f\"Gen #{generation}: temp = {temp:.6f}, \"\n", " f\"best score = {best_score:.8f}, \"\n", " f\"cur score = {value:.8f}, \"\n", " f\"worse accepted = {round(accepted_worse/total_worse*100,2):.2f}%\"\n", " )\n", " show_spring(*sol)\n", " temp = temp * alpha\n", " \n" ] }, { "cell_type": "code", "execution_count": 97, "id": "fleet-textbook", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(2.0025702338411326, 0.281986151674571, 0.05000440580999947)" ] }, "execution_count": 97, "metadata": {}, "output_type": "execute_result" } ], "source": [ "best_sol" ] }, { "cell_type": "code", "execution_count": null, "id": "718dc410", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "38a0fddd", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "d25f9e94", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 99, "id": "suspended-supplier", "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "-0.000540241178286438 -0.23561867573374795 -43.10488527213303 -0.778672961676953\n" ] } ], "source": [ "sol = best_sol\n", "print(g1(*sol), g2(*sol), g3(*sol), g4(*sol))" ] }, { "cell_type": "code", "execution_count": 100, "id": "right-hydrogen", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0.0028221707348116552" ] }, "execution_count": 100, "metadata": {}, "output_type": "execute_result" } ], "source": [ "score(*sol)" ] }, { "cell_type": "code", "execution_count": null, "id": "backed-florence", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "4ae4edaa", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "2342003d", "metadata": { "scrolled": true }, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "b81ddddc", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "831e4b89", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "561d0440", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "id": "bc646c3d", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.11.2" } }, "nbformat": 4, "nbformat_minor": 5 }