{ "cells": [ { "cell_type": "markdown", "id": "f2c6d054", "metadata": {}, "source": [ "## Migrating from removed heuristic entry points\n\n", "The legacy heuristic entry points (`ClassicEW`, `CPEW`, `NBEW`, and `OBEW`) have been removed. Their closest replacements are methods of the unified `constructor()` entry point.\n\n", "This notebook is a migration reference, not a tutorial for a supported legacy API. Update existing code to call `constructor(A, capacity, method=...)` directly.\n" ] }, { "cell_type": "code", "execution_count": 1, "id": "b52b822e", "metadata": {}, "outputs": [], "source": [ "from optiwindnet.importer import load_repository\n", "from optiwindnet.mesh import make_planar_embedding\n", "from optiwindnet.pathfinding import PathFinder\n", "from optiwindnet.heuristics import constructor\n", "from optiwindnet.interarraylib import G_from_S, calcload\n", "from optiwindnet.svg import svgplot\n", "%config InlineBackend.figure_formats = ['svg']" ] }, { "cell_type": "code", "execution_count": 2, "id": "b5eb8470", "metadata": {}, "outputs": [], "source": [ "locations = load_repository()" ] }, { "cell_type": "markdown", "id": "dccb9185", "metadata": {}, "source": [ "### 1. Classic Esau-Williams (`method='esau_williams'`)\n", "Replaces `ClassicEW()`." ] }, { "cell_type": "code", "execution_count": 3, "id": "51c0f05a", "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "Σλ = 60 145 m(+1) [-1]: 9κ = 9, T = 66" ], "text/plain": [ "" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "L = locations.merkur\n", "capacity = 9\n", "P, A = make_planar_embedding(L)\n", "S_classic = constructor(A, capacity=capacity, method='esau_williams', weigh_detours=False)\n", "G_classic = PathFinder(G_from_S(S_classic, A), P, A).create_detours()\n", "svgplot(G_classic)" ] }, { "cell_type": "markdown", "id": "020bab37", "metadata": {}, "source": [ "### 2. Crossing-Preventing EW (`method='biased_EW'`)\n", "Replaces `CPEW()`." ] }, { "cell_type": "code", "execution_count": 4, "id": "8fc9e0d3", "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "Σλ = 59 902 m(+1) [-1]: 9κ = 9, T = 66" ], "text/plain": [ "" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "S_cpew = constructor(A, capacity=capacity, method='biased_EW', straight_feeder_route=True, weigh_detours=False)\n", "G_cpew = PathFinder(G_from_S(S_cpew, A), P, A).create_detours()\n", "svgplot(G_cpew)" ] }, { "cell_type": "markdown", "id": "dc8e5ea0", "metadata": {}, "source": [ "### 3. Non-Branching Radial EW (`method='radial_EW'`)\n", "Replaces `NBEW()`." ] }, { "cell_type": "code", "execution_count": 5, "id": "e7e002b9", "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "Σλ = 274 287 m(+3) OCP: 15κ = 9, T = 100" ], "text/plain": [ "" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "L_sofia = locations.sofia\n", "P_sofia, A_sofia = make_planar_embedding(L_sofia)\n", "S_nbew = constructor(A_sofia, capacity=capacity, method='radial_EW', straight_feeder_route=True, weigh_detours=False)\n", "G_nbew = PathFinder(G_from_S(S_nbew, A_sofia), P_sofia, A_sofia).create_detours()\n", "svgplot(G_nbew)" ] }, { "cell_type": "markdown", "id": "8fe20d19", "metadata": {}, "source": [ "### 4. Obstacle-Bypassing EW (`method='rootlust'`)\n", "Replaces `OBEW()`." ] }, { "cell_type": "code", "execution_count": 6, "id": "a09bfd65", "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "Σλ = 59 187 m(+2) OSS: 11κ = 6, T = 52" ], "text/plain": [ "" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "L_borkum = locations.borkum2\n", "cap = 6\n", "P_borkum, A_borkum = make_planar_embedding(L_borkum)\n", "S_obew = constructor(A_borkum, capacity=cap, method='rootlust', rootlust_=(0.0, 0.6 * (cap - 1) / cap))\n", "G_obew = PathFinder(G_from_S(S_obew, A_borkum), P_borkum, A_borkum).create_detours()\n", "svgplot(G_obew)" ] } ], "metadata": { "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 5 }