{ "cells": [ { "cell_type": "markdown", "id": "2cbb8035-80f9-463d-8ff9-b644ededf99f", "metadata": {}, "source": [ "# IEA Wind Task 55" ] }, { "cell_type": "markdown", "id": "eb9bfca9-7f96-4283-b8cb-e3a7a47c0085", "metadata": {}, "source": [ "This notebook applies *OptiWindNet* to design collector system networks for the two offshore wind plants described in the *IEA Wind TCP Task 55* report (740 MW, 10 MW turbines). Using both regular and irregular turbine layouts in WindIO format, we use `HGSRouter` for warmstarting and `MILPRouter` (OR-Tools solver) for final optimization.\n", "\n", "For more info about *IEA Wind TCP Task 55: The IEA Wind 740-10-MW Reference Offshore Wind Plants* read: " ] }, { "cell_type": "markdown", "id": "79a4be7f", "metadata": {}, "source": [ "## Load required data" ] }, { "cell_type": "markdown", "id": "1a347864", "metadata": {}, "source": [ "### Import required modules" ] }, { "cell_type": "code", "execution_count": 1, "id": "c42a3703-113b-4aee-8dfb-a0b3b54663e6", "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "from optiwindnet.api import WindFarmNetwork, HGSRouter, MILPRouter, ModelOptions" ] }, { "cell_type": "code", "execution_count": 2, "id": "025153f5", "metadata": {}, "outputs": [], "source": [ "# Display figures as SVG in Jupyter notebooks\n", "%config InlineBackend.figure_formats = ['svg']" ] }, { "cell_type": "markdown", "id": "3a9afd54", "metadata": {}, "source": [ "### Cable data" ] }, { "cell_type": "code", "execution_count": 3, "id": "9c25dfc9", "metadata": {}, "outputs": [], "source": [ "cables = [(2, 1500.0), (5, 1800.0), (7, 2000.0)]" ] }, { "cell_type": "markdown", "id": "62328cbf", "metadata": {}, "source": [ "### Load turbine layouts" ] }, { "cell_type": "markdown", "id": "8bd117fb-4c57-4dbd-acd7-854855e5b61b", "metadata": {}, "source": [ "Load turbine layouts from WindIO yaml files (Regular and Irregular turbine layouts)\n", "\n", "> `WinfFarmNetwork.from_windIO()`is specifically introduced in *OptiWindNet* for WindIO file formats." ] }, { "cell_type": "code", "execution_count": 4, "id": "1c6f3015", "metadata": {}, "outputs": [], "source": [ "wfn_reg = WindFarmNetwork.from_windIO(filepath='data/IEA37_Borssele_Regular_System.yaml', cables=cables)" ] }, { "cell_type": "code", "execution_count": 5, "id": "9dce7d32", "metadata": {}, "outputs": [], "source": [ "wfn_irr = WindFarmNetwork.from_windIO(filepath='data/IEA37_Borssele_Irregular_System.yaml', cables=cables)" ] }, { "cell_type": "markdown", "id": "63563bd9", "metadata": {}, "source": [ "### Plot locations' geometry." ] }, { "cell_type": "code", "execution_count": 6, "id": "c838598f", "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "" ], "text/plain": [ "" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "wfn_reg" ] }, { "cell_type": "code", "execution_count": 7, "id": "2e8059dc", "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "" ], "text/plain": [ "" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "wfn_irr" ] }, { "cell_type": "markdown", "id": "ea4c9980", "metadata": {}, "source": [ "## Choose the warmstart and main router" ] }, { "cell_type": "code", "execution_count": 8, "id": "7884b794", "metadata": {}, "outputs": [], "source": [ "warmstart_router = HGSRouter(time_limit=1, verbose=True)\n", "\n", "solver_options=dict(\n", " num_workers = 8,\n", " )\n", "\n", "model_options = ModelOptions(\n", " topology='branched',\n", " feeder_limit='unlimited',\n", " feeder_route='segmented',\n", " )\n", "milp_router = MILPRouter(solver_name='ortools', time_limit=5, mip_gap=0.005, solver_options=solver_options, model_options=model_options, verbose=True)" ] }, { "cell_type": "markdown", "id": "4a480be7", "metadata": {}, "source": [ "> For a detailed explanation about model_options and solver_options of MILP routers see [Model Options](a08_ModelOptions.ipynb) and [OR-Tools example](b03_MILPRouter.ipynb) Notebooks." ] }, { "cell_type": "markdown", "id": "86999bf7-1ec1-4d4c-92bd-cbff05b08b32", "metadata": {}, "source": [ "## Regular turbine layout" ] }, { "cell_type": "markdown", "id": "8054da8a", "metadata": {}, "source": [ "### Warmstart" ] }, { "cell_type": "code", "execution_count": 9, "id": "98fc84a8", "metadata": {}, "outputs": [], "source": [ "res_reg_warm = wfn_reg.optimize(router=warmstart_router)" ] }, { "cell_type": "markdown", "id": "f1e0075f-8276-481c-a211-5919386f7aa7", "metadata": {}, "source": [ "Check the total length of the warm-start solution:" ] }, { "cell_type": "code", "execution_count": 10, "id": "fbb5bb95", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "139656.4789599965" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "wfn_reg.length()" ] }, { "cell_type": "markdown", "id": "6d864ccc", "metadata": {}, "source": [ "### Optimize with MILP router" ] }, { "cell_type": "code", "execution_count": 11, "id": "6ca333aa-d791-4b13-a091-5d3db6170792", "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Using warm start: the model is initialized with the provided solution S.\n", "\n", "\n", "Starting CP-SAT solver v9.14.6206\n", "Parameters: max_time_in_seconds: 5 log_search_progress: true relative_gap_limit: 0.005 num_workers: 8\n", "\n", "Initial optimization model '': (model_fingerprint: 0xa6c6cb685fe1d85a)\n", "#Variables: 1'536 (#bools: 768 in floating point objective) (1'388 primary variables)\n", " - 768 Booleans in [0,1]\n", " - 694 in [0,6]\n", " - 74 in [0,7]\n", "#kAtMostOne: 613 (#literals: 1'918)\n", "#kLinear1: 1'536 (#enforced: 1'536)\n", "#kLinear3: 2\n", "#kLinearN: 223 (#terms: 3'834)\n", "\n", "Starting presolve at 0.01s\n", "The solution hint is complete and is feasible.\n", "[Scaling] Floating point objective has 768 terms with magnitude in [440.736, 14559.3] average = 2868.79\n", "[Scaling] Objective coefficient relative error: 6.70633e-10\n", "[Scaling] Objective worst-case absolute error: 7.704e-05\n", "[Scaling] Objective scaling factor: 1.04858e+06\n", " 4.75e-04s 0.00e+00d [DetectDominanceRelations] \n", " 1.25e-02s 0.00e+00d [operations_research::sat::CpModelPresolver::PresolveToFixPoint] #num_loops=2 #num_dual_strengthening=1 \n", " 8.70e-05s 0.00e+00d [operations_research::sat::CpModelPresolver::ExtractEncodingFromLinear] #potential_supersets=687 \n", " 2.98e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateColumns] \n", " 7.89e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraints] \n", "[Symmetry] Graph for symmetry has 5'789 nodes and 11'056 arcs.\n", "[Symmetry] Symmetry computation done. time: 0.0015825 dtime: 0.00140614\n", " 2.94e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraintsWithDifferentEnforcements] \n", " 1.25e-02s 3.70e-03d [operations_research::sat::CpModelPresolver::Probe] #probed=1'536 \n", " 7.74e-04s 3.94e-04d [MaxClique] Merged 613(1'918 literals) into 303(1'298 literals) at_most_ones. \n", " 1.19e-03s 0.00e+00d [DetectDominanceRelations] \n", " 8.02e-03s 0.00e+00d [operations_research::sat::CpModelPresolver::PresolveToFixPoint] #num_loops=1 #num_dual_strengthening=1 \n", " 8.67e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::ProcessAtMostOneAndLinear] \n", " 4.33e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraints] \n", " 8.89e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraintsWithDifferentEnforcements] \n", " 6.74e-04s 1.30e-05d [operations_research::sat::CpModelPresolver::DetectDominatedLinearConstraints] #relevant_constraints=151 #num_inclusions=75 \n", " 9.30e-05s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDifferentVariables] \n", " 9.37e-03s 3.02e-04d [operations_research::sat::CpModelPresolver::ProcessSetPPC] #relevant_constraints=379 #num_inclusions=377 \n", " 1.87e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::FindAlmostIdenticalLinearConstraints] \n", " 5.40e-04s 2.40e-04d [operations_research::sat::CpModelPresolver::FindBigAtMostOneAndLinearOverlap] \n", " 6.02e-04s 2.83e-04d [operations_research::sat::CpModelPresolver::FindBigVerticalLinearOverlap] \n", " 1.10e-04s 1.15e-05d [operations_research::sat::CpModelPresolver::FindBigHorizontalLinearOverlap] #linears=148 \n", " 3.43e-05s 0.00e+00d [operations_research::sat::CpModelPresolver::MergeClauses] \n", " 3.88e-04s 0.00e+00d [DetectDominanceRelations] \n", " 4.74e-03s 0.00e+00d [operations_research::sat::CpModelPresolver::PresolveToFixPoint] #num_loops=1 #num_dual_strengthening=1 \n", " 4.10e-04s 0.00e+00d [DetectDominanceRelations] \n", " 4.20e-03s 0.00e+00d [operations_research::sat::CpModelPresolver::PresolveToFixPoint] #num_loops=1 #num_dual_strengthening=1 \n", " 2.20e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateColumns] \n", " 3.85e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraints] \n", "[Symmetry] Graph for symmetry has 5'168 nodes and 9'048 arcs.\n", "[Symmetry] Symmetry computation done. time: 0.0013515 dtime: 0.00121764\n", "[SAT presolve] num removable Booleans: 0 / 768\n", "[SAT presolve] num trivial clauses: 0\n", "[SAT presolve] [0s] clauses:37 literals:74 vars:74 one_side_vars:74 simple_definition:0 singleton_clauses:0\n", "[SAT presolve] [0.0005984s] clauses:37 literals:74 vars:74 one_side_vars:74 simple_definition:0 singleton_clauses:0\n", "[SAT presolve] [0.0008458s] clauses:37 literals:74 vars:74 one_side_vars:74 simple_definition:0 singleton_clauses:0\n", " 6.82e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraintsWithDifferentEnforcements] \n", " 1.65e-02s 3.42e-03d [operations_research::sat::CpModelPresolver::Probe] #probed=1'536 \n", " 1.17e-03s 3.83e-04d [MaxClique] \n", " 5.58e-04s 0.00e+00d [DetectDominanceRelations] \n", " 5.29e-03s 0.00e+00d [operations_research::sat::CpModelPresolver::PresolveToFixPoint] #num_loops=1 #num_dual_strengthening=1 \n", " 5.20e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::ProcessAtMostOneAndLinear] \n", " 5.74e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraints] \n", " 4.85e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraintsWithDifferentEnforcements] \n", " 3.82e-04s 9.77e-06d [operations_research::sat::CpModelPresolver::DetectDominatedLinearConstraints] #relevant_constraints=150 #num_inclusions=74 \n", " 8.88e-05s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDifferentVariables] \n", " 2.72e-04s 6.39e-06d [operations_research::sat::CpModelPresolver::ProcessSetPPC] #relevant_constraints=378 \n", " 1.10e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::FindAlmostIdenticalLinearConstraints] \n", " 1.35e-03s 2.37e-04d [operations_research::sat::CpModelPresolver::FindBigAtMostOneAndLinearOverlap] \n", " 5.74e-04s 2.83e-04d [operations_research::sat::CpModelPresolver::FindBigVerticalLinearOverlap] \n", " 1.04e-04s 1.15e-05d [operations_research::sat::CpModelPresolver::FindBigHorizontalLinearOverlap] #linears=148 \n", " 4.83e-05s 0.00e+00d [operations_research::sat::CpModelPresolver::MergeClauses] \n", " 4.72e-04s 0.00e+00d [DetectDominanceRelations] \n", " 3.95e-03s 0.00e+00d [operations_research::sat::CpModelPresolver::PresolveToFixPoint] #num_loops=1 #num_dual_strengthening=1 \n", " 6.02e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::ExpandObjective] #entries=7'628 #tight_variables=768 #tight_constraints=74 \n", "\n", "Presolve summary:\n", " - 0 affine relations were detected.\n", " - rule 'TODO linear inclusion: superset is equality' was applied 149 times.\n", " - rule 'at_most_one: transformed into max clique.' was applied 1 time.\n", " - rule 'deductions: 1536 stored' was applied 1 time.\n", " - rule 'exactly_one: simplified objective' was applied 74 times.\n", " - rule 'linear: positive equal one' was applied 74 times.\n", " - rule 'objective: shifted cost with exactly ones' was applied 74 times.\n", " - rule 'presolve: 0 unused variables removed.' was applied 1 time.\n", " - rule 'presolve: iteration' was applied 2 times.\n", " - rule 'setppc: exactly_one included in linear' was applied 74 times.\n", " - rule 'setppc: reduced linear coefficients' was applied 73 times.\n", " - rule 'setppc: removed trivial linear constraint' was applied 1 time.\n", " - rule 'variables: detect fully reified value encoding' was applied 768 times.\n", " - rule 'variables: detect half reified value encoding' was applied 1'536 times.\n", "\n", "Presolved optimization model '': (model_fingerprint: 0x9cb918c826cc412f)\n", "#Variables: 1'536 (#bools: 694 in objective) (1'388 primary variables)\n", " - 768 Booleans in [0,1]\n", " - 694 in [0,6]\n", " - 74 in [0,7]\n", "#kAtMostOne: 266 (#literals: 1'224)\n", "#kBoolAnd: 37 (#enforced: 37) (#literals: 74)\n", "#kExactlyOne: 74 (#literals: 768)\n", "#kLinear1: 1'536 (#enforced: 1'536)\n", "#kLinear3: 2\n", "#kLinearN: 148 (#terms: 2'298)\n", "[Symmetry] Graph for symmetry has 5'168 nodes and 9'048 arcs.\n", "[Symmetry] Symmetry computation done. time: 0.0011734 dtime: 0.00121832\n", "\n", "Preloading model.\n", "#Bound 0.13s best:inf next:[123610.947,1028471.61] initial_domain\n", "#1 0.13s best:139656.479 next:[123610.947,139656.479] complete_hint\n", "#Model 0.14s var:1536/1536 constraints:2063/2063\n", "\n", "Starting search at 0.14s with 8 workers.\n", "6 full problem subsolvers: [core, default_lp, max_lp, no_lp, quick_restart, reduced_costs]\n", "2 first solution subsolvers: [fj, fs_random_no_lp]\n", "9 interleaved subsolvers: [feasibility_pump, graph_arc_lns, graph_cst_lns, graph_dec_lns, graph_var_lns, ls, rins/rens, rnd_cst_lns, rnd_var_lns]\n", "3 helper subsolvers: [neighborhood_helper, synchronization_agent, update_gap_integral]\n", "\n", "#Bound 0.18s best:139656.479 next:[123610.951,139656.479] am1_presolve (num_literals=694 num_am1=20 increase=4458 work_done=2551)\n", "#2 0.18s best:139650.831 next:[123610.951,139650.831] graph_cst_lns (d=5.00e-01 s=10 t=0.10 p=0.00 stall=0 h=base) [hint]\n", "#Bound 0.19s best:139650.831 next:[131572.567,139650.831] default_lp\n", "#Bound 0.19s best:139650.831 next:[131572.568,139650.831] reduced_costs\n", "#Bound 0.23s best:139650.831 next:[135687.687,139650.831] max_lp\n", "#Model 0.30s var:1526/1536 constraints:2053/2063\n", "#Bound 0.34s best:139650.831 next:[135848.957,139650.831] max_lp\n", "#3 0.47s best:139650.831 next:[135848.957,139650.831] rins_lp_lns (d=7.07e-01 s=18 t=0.10 p=1.00 stall=1 h=base)\n", "#Bound 0.48s best:139650.831 next:[136118.437,139650.831] max_lp\n", "#Model 0.56s var:1512/1536 constraints:2038/2063\n", "#Model 0.66s var:1504/1536 constraints:2030/2063\n", "#Bound 0.68s best:139650.831 next:[136183.946,139650.831] max_lp\n", "#4 0.73s best:139645.183 next:[136183.946,139645.183] graph_var_lns (d=7.07e-01 s=17 t=0.10 p=1.00 stall=1 h=base)\n", "#5 0.74s best:139645.183 next:[136183.946,139645.183] graph_var_lns (d=7.07e-01 s=17 t=0.10 p=1.00 stall=1 h=base) [combined with: rins_lp_lns (d=7.07e...]\n", "#Bound 0.86s best:139645.183 next:[136221.036,139645.183] max_lp\n", "#Model 0.87s var:1478/1536 constraints:2003/2063\n", "#Bound 1.32s best:139645.183 next:[136284.537,139645.183] max_lp\n", "#Bound 1.82s best:139645.183 next:[136351.677,139645.183] max_lp\n", "#Bound 1.93s best:139645.183 next:[136355.681,139645.183] reduced_costs\n", "#Bound 2.07s best:139645.183 next:[136401.974,139645.183] reduced_costs\n", "#Bound 2.19s best:139645.183 next:[136464.159,139645.183] reduced_costs\n", "#Model 2.19s var:1472/1536 constraints:1997/2063\n", "#Bound 2.48s best:139645.183 next:[136498.186,139645.183] max_lp\n", "#Bound 3.13s best:139645.183 next:[136576.285,139645.183] max_lp\n", "#Bound 3.96s best:139645.183 next:[136606.024,139645.183] max_lp\n", "#Model 3.97s var:1464/1536 constraints:1988/2063\n", "#Model 4.79s var:1462/1536 constraints:1986/2063\n", "#Bound 4.79s best:139645.183 next:[136644.126,139645.183] max_lp\n", "\n", "Task timing n [ min, max] avg dev time n [ min, max] avg dev dtime\n", " 'core': 1 [ 4.84s, 4.84s] 4.84s 0.00ns 4.84s 1 [ 3.38s, 3.38s] 3.38s 0.00ns 3.38s\n", " 'default_lp': 1 [ 4.87s, 4.87s] 4.87s 0.00ns 4.87s 1 [431.97ms, 431.97ms] 431.97ms 0.00ns 431.97ms\n", " 'feasibility_pump': 2 [ 11.76ms, 909.44ms] 460.60ms 448.84ms 921.20ms 1 [464.60ms, 464.60ms] 464.60ms 0.00ns 464.60ms\n", " 'fj': 0 [ 0.00ns, 0.00ns] 0.00ns 0.00ns 0.00ns 0 [ 0.00ns, 0.00ns] 0.00ns 0.00ns 0.00ns\n", " 'fs_random_no_lp': 0 [ 0.00ns, 0.00ns] 0.00ns 0.00ns 0.00ns 0 [ 0.00ns, 0.00ns] 0.00ns 0.00ns 0.00ns\n", " 'graph_arc_lns': 4 [118.54ms, 434.73ms] 276.68ms 150.26ms 1.11s 4 [ 23.03ms, 100.04ms] 61.79ms 38.25ms 247.15ms\n", " 'graph_cst_lns': 8 [ 19.21ms, 305.53ms] 141.28ms 105.52ms 1.13s 8 [612.00ns, 100.27ms] 35.93ms 40.47ms 287.48ms\n", " 'graph_dec_lns': 8 [ 9.33ms, 331.01ms] 145.30ms 136.80ms 1.16s 8 [ 10.00ns, 100.10ms] 34.70ms 41.86ms 277.57ms\n", " 'graph_var_lns': 6 [ 9.79ms, 418.82ms] 192.18ms 161.00ms 1.15s 6 [ 50.00ns, 100.09ms] 51.54ms 48.57ms 309.26ms\n", " 'ls': 6 [134.87ms, 190.95ms] 167.43ms 18.18ms 1.00s 6 [100.01ms, 100.03ms] 100.02ms 6.74us 600.09ms\n", " 'max_lp': 1 [ 4.86s, 4.86s] 4.86s 0.00ns 4.86s 0 [ 0.00ns, 0.00ns] 0.00ns 0.00ns 0.00ns\n", " 'no_lp': 1 [ 4.85s, 4.85s] 4.85s 0.00ns 4.85s 1 [ 2.85s, 2.85s] 2.85s 0.00ns 2.85s\n", " 'quick_restart': 1 [ 4.86s, 4.86s] 4.86s 0.00ns 4.86s 1 [ 1.40s, 1.40s] 1.40s 0.00ns 1.40s\n", " 'reduced_costs': 1 [ 4.86s, 4.86s] 4.86s 0.00ns 4.86s 1 [ 2.08s, 2.08s] 2.08s 0.00ns 2.08s\n", " 'rins/rens': 6 [ 14.12ms, 406.32ms] 191.42ms 156.84ms 1.15s 5 [162.19us, 100.20ms] 60.66ms 48.29ms 303.28ms\n", " 'rnd_cst_lns': 5 [ 21.10ms, 338.00ms] 190.79ms 130.60ms 953.96ms 5 [692.00ns, 100.00ms] 57.22ms 46.80ms 286.08ms\n", " 'rnd_var_lns': 7 [ 16.38ms, 312.55ms] 161.17ms 119.02ms 1.13s 7 [ 55.00ns, 100.12ms] 41.44ms 42.13ms 290.08ms\n", "\n", "Search stats Bools Conflicts Branches Restarts BoolPropag IntegerPropag\n", " 'core': 788 75'530 168'750 6'290 1'315'725 3'617'398\n", " 'default_lp': 768 14 1'710 1'541 12'560 44'274\n", " 'fs_random_no_lp': 0 0 0 0 0 0\n", " 'max_lp': 768 0 1'536 1'536 11'766 39'184\n", " 'no_lp': 768 42'925 70'966 12'273 3'083'778 9'887'908\n", " 'quick_restart': 768 30 7'548 4'600 38'042 215'708\n", " 'reduced_costs': 774 372 10'088 4'626 53'826 333'451\n", "\n", "SAT stats ClassicMinim LitRemoved LitLearned LitForgotten Subsumed MClauses MDecisions MLitTrue MSubsumed MLitRemoved MReused\n", " 'core': 71'209 1'125'077 6'001'195 4'566'624 860 434 3'262 0 14 100 16\n", " 'default_lp': 13 2'074 2'322 0 0 0 0 0 0 0 0\n", " 'fs_random_no_lp': 0 0 0 0 0 0 0 0 0 0 0\n", " 'max_lp': 0 0 0 0 0 0 0 0 0 0 0\n", " 'no_lp': 41'025 834'075 2'140'896 1'561'562 752 896 8'082 0 1 4 0\n", " 'quick_restart': 29 1'533 2'509 0 0 296 2'640 0 0 0 0\n", " 'reduced_costs': 347 14'084 76'673 0 1 296 2'654 0 0 0 0\n", "\n", "Lp stats Component Iterations AddedCuts OPTIMAL DUAL_F. DUAL_U.\n", " 'default_lp': 1 9'150 3'378 231 0 1\n", " 'max_lp': 1 2'872 1'929 23 0 0\n", " 'quick_restart': 1 12'364 2'983 335 1 10\n", " 'reduced_costs': 1 30'539 1'995 539 179 83\n", "\n", "Lp dimension Final dimension of first component\n", " 'default_lp': 1870 rows, 1462 columns, 23150 entries\n", " 'max_lp': 3232 rows, 1536 columns, 32309 entries\n", " 'quick_restart': 1644 rows, 1462 columns, 24942 entries\n", " 'reduced_costs': 1307 rows, 1536 columns, 13065 entries\n", "\n", "Lp debug CutPropag CutEqPropag Adjust Overflow Bad BadScaling\n", " 'default_lp': 0 0 221 0 18'509 0\n", " 'max_lp': 0 0 23 0 30'316 0\n", " 'quick_restart': 0 0 330 0 13'814 0\n", " 'reduced_costs': 0 0 757 0 6'601 0\n", "\n", "Lp pool Constraints Updates Simplif Merged Shortened Split Strenghtened Cuts/Call\n", " 'default_lp': 5'950 188 2'383 0 1'722 84 64 3'378/6'509\n", " 'max_lp': 4'760 324 2'065 0 1'328 266 29 1'929/3'922\n", " 'quick_restart': 5'555 138 2'057 0 1'472 34 187 2'983/6'130\n", " 'reduced_costs': 4'826 65 1'061 0 518 34 24 1'995/4'086\n", "\n", "Lp Cut default_lp max_lp quick_restart reduced_costs\n", " CG_FF: 46 10 23 25\n", " CG_K: 21 5 14 17\n", " CG_KL: 1 - 2 1\n", " CG_R: 40 19 46 42\n", " CG_RB: 104 53 91 67\n", " CG_RBP: 36 22 44 10\n", " IB: 630 - 652 743\n", " MIR_1_FF: 152 61 119 41\n", " MIR_1_K: 53 1 31 4\n", " MIR_1_KL: 25 - 19 -\n", " MIR_1_R: 3 1 1 -\n", " MIR_1_RB: 104 39 72 27\n", " MIR_1_RBP: 61 8 76 6\n", " MIR_2_FF: 155 100 119 76\n", " MIR_2_K: 58 4 62 11\n", " MIR_2_KL: 15 4 18 7\n", " MIR_2_R: 26 6 4 4\n", " MIR_2_RB: 154 125 130 77\n", " MIR_2_RBP: 86 26 109 21\n", " MIR_3_FF: 90 123 80 81\n", " MIR_3_K: 74 24 66 17\n", " MIR_3_KL: 7 5 7 6\n", " MIR_3_R: 8 13 5 10\n", " MIR_3_RB: 104 124 102 64\n", " MIR_3_RBP: 66 29 56 19\n", " MIR_4_FF: 75 110 46 48\n", " MIR_4_K: 74 42 45 20\n", " MIR_4_KL: 5 11 3 3\n", " MIR_4_R: 6 13 2 6\n", " MIR_4_RB: 76 75 54 51\n", " MIR_4_RBP: 74 55 60 18\n", " MIR_5_FF: 37 72 34 24\n", " MIR_5_K: 43 45 43 21\n", " MIR_5_KL: 8 10 4 8\n", " MIR_5_R: 3 6 5 3\n", " MIR_5_RB: 35 53 44 28\n", " MIR_5_RBP: 54 59 61 20\n", " MIR_6_FF: 28 43 21 32\n", " MIR_6_K: 58 39 41 22\n", " MIR_6_KL: 15 14 7 7\n", " MIR_6_R: 3 5 2 2\n", " MIR_6_RB: 20 37 25 17\n", " MIR_6_RBP: 55 45 45 13\n", " ZERO_HALF_FF: 58 13 48 31\n", " ZERO_HALF_K: 19 1 16 4\n", " ZERO_HALF_KL: 1 - 4 3\n", " ZERO_HALF_R: 388 331 358 205\n", " ZERO_HALF_RB: 95 31 36 27\n", " ZERO_HALF_RBP: 29 17 31 6\n", "\n", "LNS stats Improv/Calls Closed Difficulty TimeLimit\n", " 'graph_arc_lns': 0/4 50% 5.97e-01 0.10\n", " 'graph_cst_lns': 1/8 62% 8.06e-01 0.10\n", " 'graph_dec_lns': 0/8 62% 8.20e-01 0.10\n", " 'graph_var_lns': 1/6 50% 5.87e-01 0.10\n", " 'rins/rens': 4/6 50% 6.52e-01 0.10\n", " 'rnd_cst_lns': 0/5 60% 7.48e-01 0.10\n", " 'rnd_var_lns': 0/7 71% 8.75e-01 0.10\n", "\n", "LS stats Batches Restarts/Perturbs LinMoves GenMoves CompoundMoves Bactracks WeightUpdates ScoreComputed\n", " 'ls_restart_compound': 1 1 0 15'650 1'773 6'937 57 379'632\n", " 'ls_restart_decay': 1 1 14'497 0 0 0 277 314'922\n", " 'ls_restart_decay_compound': 2 2 0 26'979 4'587 11'193 76 656'724\n", " 'ls_restart_decay_compound_perturb': 1 1 0 13'747 2'317 5'705 36 334'772\n", " 'ls_restart_perturb': 1 1 12'562 0 0 0 2'394 383'878\n", "\n", "Solutions (5) Num Rank\n", " 'complete_hint': 1 [1,1]\n", " 'graph_cst_lns': 1 [2,2]\n", " 'graph_var_lns': 2 [4,5]\n", " 'rins_lp_lns': 1 [3,3]\n", "\n", "Objective bounds Num\n", " 'am1_presolve': 1\n", " 'default_lp': 1\n", " 'initial_domain': 1\n", " 'max_lp': 11\n", " 'reduced_costs': 4\n", "\n", "Solution repositories Added Queried Synchro\n", " 'feasible solutions': 5 98 5\n", " 'fj solution hints': 0 0 0\n", " 'lp solutions': 28 6 21\n", " 'pump': 0 0\n", "\n", "Improving bounds shared Num Sym\n", " 'default_lp': 34 0\n", " 'max_lp': 34 0\n", " 'reduced_costs': 6 0\n", "\n", "Clauses shared Num\n", " 'core': 9\n", " 'no_lp': 274\n", "\n", "[Scaling] scaled_objective_bound: 136644 corrected_bound: 136644 delta: -2.56905e-06\n", "CpSolverResponse summary:\n", "status: FEASIBLE\n", "objective: 139645.18265364\n", "best_bound: 136644.1257931651\n", "integers: 0\n", "booleans: 0\n", "conflicts: 0\n", "branches: 0\n", "propagations: 0\n", "integer_propagations: 0\n", "restarts: 0\n", "lp_iterations: 0\n", "walltime: 5.04096\n", "usertime: 5.04096\n", "deterministic_time: 13.2163\n", "gap_integral: 105.986\n", "solution_fingerprint: 0x6aa24a4cea96b19f\n", "\n" ] } ], "source": [ "res_reg = wfn_reg.optimize(router=milp_router, verbose=True)" ] }, { "cell_type": "code", "execution_count": 12, "id": "54e4cda4", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "139645.18265364" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "wfn_reg.length()" ] }, { "cell_type": "code", "execution_count": 13, "id": "a314938c-0c17-4d8d-b343-e9622c25f67c", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "248112330.12342116" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "wfn_reg.cost()" ] }, { "cell_type": "code", "execution_count": 14, "id": "1092b21b", "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "248 112 330 €Σλ = 139 645 m(+0) [-1]: 11κ = 7, T = 74" ], "text/plain": [ "" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "wfn_reg" ] }, { "cell_type": "markdown", "id": "e7cf5795-3baf-4549-92ee-6a6462e01b36", "metadata": {}, "source": [ "## Irregular turbine layout" ] }, { "cell_type": "code", "execution_count": 15, "id": "54f3f31b-7b64-4e35-ade8-8308163cce57", "metadata": {}, "outputs": [], "source": [ "res_irr_warmup = wfn_irr.optimize(router=warmstart_router)" ] }, { "cell_type": "markdown", "id": "6a4095a9-c2eb-4059-b2ee-fc08fa1b02e2", "metadata": {}, "source": [ "Check the total length of the warm-start solution:" ] }, { "cell_type": "code", "execution_count": 16, "id": "5921f255-d4c5-4aa6-84d5-88fa9fd36df8", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "136472.2480500915" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "wfn_irr.length()" ] }, { "cell_type": "markdown", "id": "adf7e5b9", "metadata": {}, "source": [ "### Optimize with MILP router" ] }, { "cell_type": "code", "execution_count": 17, "id": "37694cbf-221d-491a-b720-2806c3d82952", "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Using warm start: the model is initialized with the provided solution S.\n", "\n", "\n", "Starting CP-SAT solver v9.14.6206\n", "Parameters: max_time_in_seconds: 5 log_search_progress: true relative_gap_limit: 0.005 num_workers: 8\n", "\n", "Initial optimization model '': (model_fingerprint: 0xdce7638cf32cc953)\n", "#Variables: 1'192 (#bools: 596 in floating point objective) (1'044 primary variables)\n", " - 596 Booleans in [0,1]\n", " - 522 in [0,6]\n", " - 74 in [0,7]\n", "#kAtMostOne: 419 (#literals: 1'216)\n", "#kLinear1: 1'192 (#enforced: 1'192)\n", "#kLinear2: 4\n", "#kLinear3: 5\n", "#kLinearN: 216 (#terms: 2'957)\n", "\n", "Starting presolve at 0.00s\n", "The solution hint is complete and is feasible.\n", "[Scaling] Floating point objective has 596 terms with magnitude in [539.378, 15073.7] average = 3460.13\n", "[Scaling] Objective coefficient relative error: 4.51281e-10\n", "[Scaling] Objective worst-case absolute error: 7.28067e-05\n", "[Scaling] Objective scaling factor: 1.04858e+06\n", " 1.21e-03s 0.00e+00d [DetectDominanceRelations] \n", " 1.01e-02s 0.00e+00d [operations_research::sat::CpModelPresolver::PresolveToFixPoint] #num_loops=2 #num_dual_strengthening=1 \n", " 6.83e-05s 0.00e+00d [operations_research::sat::CpModelPresolver::ExtractEncodingFromLinear] #potential_supersets=493 \n", " 3.39e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateColumns] \n", " 3.79e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraints] \n", "[Symmetry] Graph for symmetry has 4'413 nodes and 8'226 arcs.\n", "[Symmetry] Symmetry computation done. time: 0.0012476 dtime: 0.00080437\n", " 8.73e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraintsWithDifferentEnforcements] \n", " 9.48e-03s 2.33e-03d [operations_research::sat::CpModelPresolver::Probe] #probed=1'192 \n", " 6.67e-04s 2.25e-04d [MaxClique] Merged 419(1'216 literals) into 234(846 literals) at_most_ones. \n", " 2.97e-04s 0.00e+00d [DetectDominanceRelations] \n", " 3.10e-03s 0.00e+00d [operations_research::sat::CpModelPresolver::PresolveToFixPoint] #num_loops=1 #num_dual_strengthening=1 \n", " 5.09e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::ProcessAtMostOneAndLinear] \n", " 7.61e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraints] \n", " 4.33e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraintsWithDifferentEnforcements] \n", " 5.10e-04s 1.01e-05d [operations_research::sat::CpModelPresolver::DetectDominatedLinearConstraints] #relevant_constraints=151 #num_inclusions=75 \n", " 5.93e-05s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDifferentVariables] \n", " 4.33e-03s 1.92e-04d [operations_research::sat::CpModelPresolver::ProcessSetPPC] #relevant_constraints=310 #num_inclusions=308 \n", " 2.20e-04s 2.00e-07d [operations_research::sat::CpModelPresolver::FindAlmostIdenticalLinearConstraints] #num_tested_pairs=4 \n", " 5.28e-04s 1.84e-04d [operations_research::sat::CpModelPresolver::FindBigAtMostOneAndLinearOverlap] \n", " 3.97e-04s 2.07e-04d [operations_research::sat::CpModelPresolver::FindBigVerticalLinearOverlap] \n", " 6.25e-05s 8.71e-06d [operations_research::sat::CpModelPresolver::FindBigHorizontalLinearOverlap] #linears=136 \n", " 3.60e-05s 0.00e+00d [operations_research::sat::CpModelPresolver::MergeClauses] \n", " 3.95e-04s 0.00e+00d [DetectDominanceRelations] \n", " 3.28e-03s 0.00e+00d [operations_research::sat::CpModelPresolver::PresolveToFixPoint] #num_loops=1 #num_dual_strengthening=1 \n", " 1.15e-03s 0.00e+00d [DetectDominanceRelations] \n", " 4.20e-03s 0.00e+00d [operations_research::sat::CpModelPresolver::PresolveToFixPoint] #num_loops=1 #num_dual_strengthening=1 \n", " 2.93e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateColumns] \n", " 4.32e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraints] \n", "[Symmetry] Graph for symmetry has 4'042 nodes and 6'890 arcs.\n", "[Symmetry] Symmetry computation done. time: 0.0005735 dtime: 0.00073496\n", "[SAT presolve] num removable Booleans: 0 / 596\n", "[SAT presolve] num trivial clauses: 0\n", "[SAT presolve] [0s] clauses:76 literals:152 vars:152 one_side_vars:152 simple_definition:0 singleton_clauses:0\n", "[SAT presolve] [0.0002767s] clauses:76 literals:152 vars:152 one_side_vars:152 simple_definition:0 singleton_clauses:0\n", "[SAT presolve] [0.0003772s] clauses:76 literals:152 vars:152 one_side_vars:152 simple_definition:0 singleton_clauses:0\n", " 4.51e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraintsWithDifferentEnforcements] \n", " 7.74e-03s 2.15e-03d [operations_research::sat::CpModelPresolver::Probe] #probed=1'192 \n", " 4.69e-04s 2.19e-04d [MaxClique] \n", " 6.22e-04s 0.00e+00d [DetectDominanceRelations] \n", " 5.01e-03s 0.00e+00d [operations_research::sat::CpModelPresolver::PresolveToFixPoint] #num_loops=1 #num_dual_strengthening=1 \n", " 3.23e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::ProcessAtMostOneAndLinear] \n", " 3.12e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraints] \n", " 3.61e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraintsWithDifferentEnforcements] \n", " 2.98e-04s 7.55e-06d [operations_research::sat::CpModelPresolver::DetectDominatedLinearConstraints] #relevant_constraints=150 #num_inclusions=74 \n", " 5.58e-05s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDifferentVariables] \n", " 4.23e-04s 4.60e-06d [operations_research::sat::CpModelPresolver::ProcessSetPPC] #relevant_constraints=309 \n", " 6.93e-05s 1.90e-07d [operations_research::sat::CpModelPresolver::FindAlmostIdenticalLinearConstraints] #num_tested_pairs=2 \n", " 6.84e-04s 1.82e-04d [operations_research::sat::CpModelPresolver::FindBigAtMostOneAndLinearOverlap] \n", " 4.46e-04s 2.07e-04d [operations_research::sat::CpModelPresolver::FindBigVerticalLinearOverlap] \n", " 8.69e-05s 8.71e-06d [operations_research::sat::CpModelPresolver::FindBigHorizontalLinearOverlap] #linears=136 \n", " 3.00e-05s 0.00e+00d [operations_research::sat::CpModelPresolver::MergeClauses] \n", " 4.17e-04s 0.00e+00d [DetectDominanceRelations] \n", " 4.84e-03s 0.00e+00d [operations_research::sat::CpModelPresolver::PresolveToFixPoint] #num_loops=1 #num_dual_strengthening=1 \n", " 1.08e-03s 0.00e+00d [operations_research::sat::CpModelPresolver::ExpandObjective] #entries=4'968 #tight_variables=596 #tight_constraints=74 \n", "\n", "Presolve summary:\n", " - 0 affine relations were detected.\n", " - rule 'TODO linear inclusion: superset is equality' was applied 149 times.\n", " - rule 'at_most_one: transformed into max clique.' was applied 1 time.\n", " - rule 'deductions: 1192 stored' was applied 1 time.\n", " - rule 'exactly_one: simplified objective' was applied 74 times.\n", " - rule 'linear: positive equal one' was applied 74 times.\n", " - rule 'objective: shifted cost with exactly ones' was applied 74 times.\n", " - rule 'presolve: 0 unused variables removed.' was applied 1 time.\n", " - rule 'presolve: iteration' was applied 2 times.\n", " - rule 'setppc: exactly_one included in linear' was applied 74 times.\n", " - rule 'setppc: reduced linear coefficients' was applied 73 times.\n", " - rule 'setppc: removed trivial linear constraint' was applied 1 time.\n", " - rule 'variables: detect fully reified value encoding' was applied 596 times.\n", " - rule 'variables: detect half reified value encoding' was applied 1'192 times.\n", "\n", "Presolved optimization model '': (model_fingerprint: 0xe724ee61a4757ecc)\n", "#Variables: 1'192 (#bools: 522 in objective) (1'044 primary variables)\n", " - 596 Booleans in [0,1]\n", " - 522 in [0,6]\n", " - 74 in [0,7]\n", "#kAtMostOne: 158 (#literals: 694)\n", "#kBoolAnd: 76 (#enforced: 76) (#literals: 152)\n", "#kExactlyOne: 74 (#literals: 596)\n", "#kLinear1: 1'192 (#enforced: 1'192)\n", "#kLinear2: 4\n", "#kLinear3: 1\n", "#kLinearN: 145 (#terms: 1'777)\n", "[Symmetry] Graph for symmetry has 4'042 nodes and 6'890 arcs.\n", "[Symmetry] Symmetry computation done. time: 0.0004448 dtime: 0.00073413\n", "\n", "Preloading model.\n", "#Bound 0.09s best:inf next:[93516.0522,1236251.99] initial_domain\n", "#1 0.09s best:136451.277 next:[93516.0522,136451.277] complete_hint\n", "#Model 0.09s var:1192/1192 constraints:1650/1650\n", "\n", "Starting search at 0.09s with 8 workers.\n", "6 full problem subsolvers: [core, default_lp, max_lp, no_lp, quick_restart, reduced_costs]\n", "2 first solution subsolvers: [fj, fs_random_no_lp]\n", "9 interleaved subsolvers: [feasibility_pump, graph_arc_lns, graph_cst_lns, graph_dec_lns, graph_var_lns, ls, rins/rens, rnd_cst_lns, rnd_var_lns]\n", "3 helper subsolvers: [neighborhood_helper, synchronization_agent, update_gap_integral]\n", "\n", "#Bound 0.12s best:136451.277 next:[95755.9972,136451.277] am1_presolve (num_literals=522 num_am1=19 increase=2348752631 work_done=1852)\n", "#2 0.13s best:136417.955 next:[95755.9972,136417.955] no_lp [hint] (fixed_bools=0/596)\n", "#Bound 0.13s best:136417.955 next:[104424.449,136417.955] default_lp\n", "#Bound 0.14s best:136417.955 next:[106103.007,136417.955] reduced_costs\n", "#Bound 0.15s best:136417.955 next:[106404.863,136417.955] reduced_costs\n", "#3 0.16s best:135518.936 next:[106404.863,135518.936] graph_arc_lns (d=5.00e-01 s=9 t=0.10 p=0.00 stall=0 h=base)\n", "#Bound 0.17s best:135518.936 next:[127628.142,135518.936] max_lp\n", "#4 0.17s best:135485.613 next:[127628.142,135485.613] graph_arc_lns (d=5.00e-01 s=9 t=0.10 p=0.00 stall=0 h=base) [combined with: no_lp [hint]...]\n", "#5 0.23s best:135031.477 next:[127628.142,135031.477] rnd_cst_lns (d=7.07e-01 s=15 t=0.10 p=1.00 stall=1 h=base)\n", "#Bound 0.27s best:135031.477 next:[128569.256,135031.477] max_lp\n", "#6 0.29s best:134995.892 next:[128569.256,134995.892] no_lp (fixed_bools=0/596)\n", "#Bound 0.36s best:134995.892 next:[129244.173,134995.892] max_lp\n", "#Bound 0.50s best:134995.892 next:[129611.049,134995.892] max_lp\n", "#7 0.57s best:134786.792 next:[129611.049,134786.792] rins_lp_lns (d=7.07e-01 s=18 t=0.10 p=1.00 stall=1 h=base)\n", "#Bound 0.71s best:134786.792 next:[129817.488,134786.792] max_lp\n", "#Model 0.79s var:1186/1192 constraints:1643/1650\n", "#Bound 1.22s best:134786.792 next:[130126.924,134786.792] max_lp\n", "#Model 1.38s var:1168/1192 constraints:1623/1650\n", "#Bound 1.79s best:134786.792 next:[130336.912,134786.792] max_lp\n", "#Model 1.85s var:1158/1192 constraints:1613/1650\n", "#Model 2.35s var:1156/1192 constraints:1611/1650\n", "#Bound 2.43s best:134786.792 next:[130414.9,134786.792] max_lp\n", "#Bound 3.02s best:134786.792 next:[130478.41,134786.792] max_lp\n", "#Model 3.05s var:1154/1192 constraints:1609/1650\n", "#Bound 3.72s best:134786.792 next:[130585.545,134786.792] max_lp\n", "#Bound 4.42s best:134786.792 next:[130682.423,134786.792] max_lp\n", "\n", "Task timing n [ min, max] avg dev time n [ min, max] avg dev dtime\n", " 'core': 1 [ 4.91s, 4.91s] 4.91s 0.00ns 4.91s 1 [ 3.67s, 3.67s] 3.67s 0.00ns 3.67s\n", " 'default_lp': 1 [ 4.91s, 4.91s] 4.91s 0.00ns 4.91s 1 [724.30ms, 724.30ms] 724.30ms 0.00ns 724.30ms\n", " 'feasibility_pump': 11 [ 31.90us, 590.12ms] 54.66ms 169.35ms 601.23ms 1 [362.47ms, 362.47ms] 362.47ms 0.00ns 362.47ms\n", " 'fj': 0 [ 0.00ns, 0.00ns] 0.00ns 0.00ns 0.00ns 0 [ 0.00ns, 0.00ns] 0.00ns 0.00ns 0.00ns\n", " 'fs_random_no_lp': 0 [ 0.00ns, 0.00ns] 0.00ns 0.00ns 0.00ns 0 [ 0.00ns, 0.00ns] 0.00ns 0.00ns 0.00ns\n", " 'graph_arc_lns': 6 [ 26.72ms, 337.19ms] 184.84ms 133.40ms 1.11s 6 [923.32us, 100.16ms] 52.37ms 47.77ms 314.24ms\n", " 'graph_cst_lns': 8 [ 21.73ms, 305.23ms] 128.06ms 120.35ms 1.02s 8 [ 97.91us, 100.02ms] 39.25ms 47.10ms 314.04ms\n", " 'graph_dec_lns': 9 [ 6.20ms, 399.27ms] 146.14ms 150.80ms 1.32s 9 [ 10.00ns, 100.04ms] 36.94ms 44.98ms 332.43ms\n", " 'graph_var_lns': 8 [ 8.74ms, 346.75ms] 133.66ms 135.99ms 1.07s 8 [ 10.00ns, 100.05ms] 39.48ms 47.00ms 315.85ms\n", " 'ls': 7 [121.53ms, 180.29ms] 163.18ms 18.71ms 1.14s 7 [100.01ms, 100.02ms] 100.01ms 3.61us 700.07ms\n", " 'max_lp': 1 [ 4.90s, 4.90s] 4.90s 0.00ns 4.90s 0 [ 0.00ns, 0.00ns] 0.00ns 0.00ns 0.00ns\n", " 'no_lp': 1 [ 4.91s, 4.91s] 4.91s 0.00ns 4.91s 1 [ 2.86s, 2.86s] 2.86s 0.00ns 2.86s\n", " 'quick_restart': 1 [ 4.91s, 4.91s] 4.91s 0.00ns 4.91s 1 [823.94ms, 823.94ms] 823.94ms 0.00ns 823.94ms\n", " 'reduced_costs': 1 [ 4.91s, 4.91s] 4.91s 0.00ns 4.91s 1 [ 1.64s, 1.64s] 1.64s 0.00ns 1.64s\n", " 'rins/rens': 5 [ 14.99ms, 355.43ms] 225.02ms 132.92ms 1.13s 5 [ 69.09us, 100.10ms] 62.01ms 42.70ms 310.07ms\n", " 'rnd_cst_lns': 7 [ 16.31ms, 407.07ms] 178.17ms 144.64ms 1.25s 7 [201.00ns, 100.20ms] 47.17ms 46.23ms 330.19ms\n", " 'rnd_var_lns': 7 [ 12.28ms, 382.47ms] 166.58ms 147.72ms 1.17s 7 [ 71.00ns, 100.04ms] 47.57ms 46.65ms 332.97ms\n", "\n", "Search stats Bools Conflicts Branches Restarts BoolPropag IntegerPropag\n", " 'core': 615 79'399 210'812 9'476 1'281'580 3'710'850\n", " 'default_lp': 608 51 1'528 1'194 10'614 40'329\n", " 'fs_random_no_lp': 0 0 0 0 0 0\n", " 'max_lp': 596 0 1'192 1'192 7'271 24'815\n", " 'no_lp': 596 58'125 79'832 7'171 3'325'101 10'738'191\n", " 'quick_restart': 596 22 3'550 2'315 16'272 69'736\n", " 'reduced_costs': 596 273 4'529 2'350 22'544 117'902\n", "\n", "SAT stats ClassicMinim LitRemoved LitLearned LitForgotten Subsumed MClauses MDecisions MLitTrue MSubsumed MLitRemoved MReused\n", " 'core': 73'439 797'687 5'215'798 4'035'116 937 4'458 41'741 0 801 11'765 988\n", " 'default_lp': 43 1'589 4'301 0 3 0 0 0 0 0 0\n", " 'fs_random_no_lp': 0 0 0 0 0 0 0 0 0 0 0\n", " 'max_lp': 0 0 0 0 0 0 0 0 0 0 0\n", " 'no_lp': 54'880 361'986 4'389'501 2'931'975 177 883 6'464 0 19 237 73\n", " 'quick_restart': 21 974 2'031 0 0 144 1'002 0 0 0 0\n", " 'reduced_costs': 267 16'410 12'088 0 0 146 1'018 0 0 0 0\n", "\n", "Lp stats Component Iterations AddedCuts OPTIMAL DUAL_F. DUAL_U.\n", " 'default_lp': 1 8'525 3'250 410 0 0\n", " 'max_lp': 1 1'755 2'059 23 0 0\n", " 'quick_restart': 1 8'571 3'187 267 0 0\n", " 'reduced_costs': 1 28'344 2'539 902 177 17\n", "\n", "Lp dimension Final dimension of first component\n", " 'default_lp': 1378 rows, 1119 columns, 16703 entries\n", " 'max_lp': 2685 rows, 1192 columns, 24203 entries\n", " 'quick_restart': 1842 rows, 1119 columns, 25681 entries\n", " 'reduced_costs': 1140 rows, 1192 columns, 9328 entries\n", "\n", "Lp debug CutPropag CutEqPropag Adjust Overflow Bad BadScaling\n", " 'default_lp': 0 2 405 0 19'308 0\n", " 'max_lp': 0 0 23 0 33'547 0\n", " 'quick_restart': 0 0 262 0 18'527 0\n", " 'reduced_costs': 0 0 1'079 0 11'576 0\n", "\n", "Lp pool Constraints Updates Simplif Merged Shortened Split Strenghtened Cuts/Call\n", " 'default_lp': 5'201 188 1'967 0 1'858 31 112 3'250/6'351\n", " 'max_lp': 4'305 353 1'994 0 1'623 150 22 2'059/4'034\n", " 'quick_restart': 5'138 176 1'993 0 1'840 39 91 3'187/5'898\n", " 'reduced_costs': 4'785 141 695 0 690 5 97 2'539/4'397\n", "\n", "Lp Cut max_lp default_lp quick_restart reduced_costs\n", " CG_FF: 6 25 26 24\n", " CG_K: 5 14 6 12\n", " CG_KL: - - 1 1\n", " CG_R: 26 32 38 44\n", " CG_RB: 49 74 95 92\n", " CG_RBP: 22 37 34 32\n", " Clique: - - - 1\n", " IB: - 579 575 726\n", " MIR_1_FF: 87 175 177 66\n", " MIR_1_K: 5 54 51 16\n", " MIR_1_KL: 4 27 28 6\n", " MIR_1_R: 7 5 1 3\n", " MIR_1_RB: 58 105 95 52\n", " MIR_1_RBP: 10 84 89 23\n", " MIR_1_RLT: - - - 1\n", " MIR_2_FF: 108 184 187 108\n", " MIR_2_K: 7 67 62 9\n", " MIR_2_KL: 5 24 18 6\n", " MIR_2_R: 15 9 10 10\n", " MIR_2_RB: 102 144 125 132\n", " MIR_2_RBP: 32 93 104 22\n", " MIR_3_FF: 122 128 110 103\n", " MIR_3_K: 24 70 83 24\n", " MIR_3_KL: 4 6 4 2\n", " MIR_3_R: 15 7 10 7\n", " MIR_3_RB: 137 118 83 145\n", " MIR_3_RBP: 56 83 94 45\n", " MIR_4_FF: 106 87 68 96\n", " MIR_4_K: 49 63 62 15\n", " MIR_4_KL: 5 8 3 3\n", " MIR_4_R: 14 5 5 10\n", " MIR_4_RB: 92 75 51 92\n", " MIR_4_RBP: 67 82 58 22\n", " MIR_5_FF: 56 49 53 55\n", " MIR_5_K: 35 61 60 16\n", " MIR_5_KL: 14 18 16 14\n", " MIR_5_R: 11 2 6 5\n", " MIR_5_RB: 53 32 38 64\n", " MIR_5_RBP: 68 66 67 20\n", " MIR_6_FF: 33 48 32 34\n", " MIR_6_K: 53 46 43 16\n", " MIR_6_KL: 24 22 23 13\n", " MIR_6_R: 7 2 1 5\n", " MIR_6_RB: 34 21 14 36\n", " MIR_6_RBP: 75 51 48 25\n", " ZERO_HALF_FF: 15 29 35 21\n", " ZERO_HALF_K: 1 9 8 3\n", " ZERO_HALF_KL: 2 2 1 -\n", " ZERO_HALF_R: 291 241 327 219\n", " ZERO_HALF_RB: 36 63 44 37\n", " ZERO_HALF_RBP: 12 24 18 6\n", "\n", "LNS stats Improv/Calls Closed Difficulty TimeLimit\n", " 'graph_arc_lns': 1/6 50% 5.64e-01 0.10\n", " 'graph_cst_lns': 0/8 62% 7.81e-01 0.10\n", " 'graph_dec_lns': 0/9 67% 8.72e-01 0.10\n", " 'graph_var_lns': 0/8 50% 6.11e-01 0.10\n", " 'rins/rens': 3/5 40% 4.32e-01 0.10\n", " 'rnd_cst_lns': 1/7 57% 7.63e-01 0.10\n", " 'rnd_var_lns': 0/7 57% 7.52e-01 0.10\n", "\n", "LS stats Batches Restarts/Perturbs LinMoves GenMoves CompoundMoves Bactracks WeightUpdates ScoreComputed\n", " 'ls_restart_decay': 1 1 18'244 0 0 0 405 386'155\n", " 'ls_restart_decay_compound_perturb': 1 1 0 17'113 3'414 6'849 56 436'927\n", " 'ls_restart_decay_perturb': 2 2 37'509 0 0 0 873 773'935\n", " 'ls_restart_perturb': 3 3 47'358 0 0 0 15'085 1'561'665\n", "\n", "Solutions (7) Num Rank\n", " 'complete_hint': 1 [1,1]\n", " 'graph_arc_lns': 2 [3,4]\n", " 'no_lp': 2 [2,6]\n", " 'rins_lp_lns': 1 [7,7]\n", " 'rnd_cst_lns': 1 [5,5]\n", "\n", "Objective bounds Num\n", " 'am1_presolve': 1\n", " 'default_lp': 1\n", " 'initial_domain': 1\n", " 'max_lp': 11\n", " 'reduced_costs': 2\n", "\n", "Solution repositories Added Queried Synchro\n", " 'feasible solutions': 8 112 8\n", " 'fj solution hints': 0 0 0\n", " 'lp solutions': 10 5 10\n", " 'pump': 0 0\n", "\n", "Improving bounds shared Num Sym\n", " 'default_lp': 6 0\n", " 'max_lp': 16 0\n", " 'quick_restart': 2 0\n", " 'reduced_costs': 18 0\n", "\n", "Clauses shared Num\n", " 'core': 16\n", " 'reduced_costs': 1\n", "\n", "[Scaling] scaled_objective_bound: 130682 corrected_bound: 130682 delta: -3.77913e-07\n", "CpSolverResponse summary:\n", "status: FEASIBLE\n", "objective: 134786.7922581253\n", "best_bound: 130682.4229892695\n", "integers: 0\n", "booleans: 0\n", "conflicts: 0\n", "branches: 0\n", "propagations: 0\n", "integer_propagations: 0\n", "restarts: 0\n", "lp_iterations: 0\n", "walltime: 5.04745\n", "usertime: 5.04745\n", "deterministic_time: 13.0334\n", "gap_integral: 108.723\n", "solution_fingerprint: 0x8de4169e43eb94c3\n", "\n" ] } ], "source": [ "res_irr = wfn_irr.optimize(router=milp_router)" ] }, { "cell_type": "code", "execution_count": 18, "id": "edf07b4b", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "134807.7634895362" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "wfn_irr.length()" ] }, { "cell_type": "code", "execution_count": 19, "id": "4dec60b8-7de5-4eed-a541-6278b9902b24", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "247033944.13135293" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "wfn_irr.cost()" ] }, { "cell_type": "code", "execution_count": 20, "id": "25ecb09f", "metadata": {}, "outputs": [ { "data": { "image/svg+xml": [ "247 033 944 €Σλ = 134 808 m(+0) [-1]: 11κ = 7, T = 74" ], "text/plain": [ "" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "wfn_irr" ] }, { "cell_type": "markdown", "id": "056732ea-9778-4405-949d-08c4f817ce09", "metadata": {}, "source": [ "## Layouts' edge list" ] }, { "cell_type": "markdown", "id": "b8450a23-c8d4-4091-af5f-b8f547407f52", "metadata": {}, "source": [ "These lists of 3-tuples has all the edges and their cable type (as an index to the `turbines_per_cable` list), i.e. (coordinate_A, coordinate_B, cable_type).\n", "\n", "Negative node indices represent substations, the node indices ranging from 0 to 73 represent the WT in the order they were given.\n", "\n", "If the network has contours or detours, indices will go beyond the number of coordinates (WT, SS, borders) provided, and the mapping of these additional indices to indices to the provided coordinates is presented." ] }, { "cell_type": "code", "execution_count": 21, "id": "7809e3c9", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "EdgeDataView([(-1, 47, 2), (-1, 56, 2), (-1, 46, 2), (-1, 33, 2), (-1, 45, 2), (-1, 57, 2), (-1, 34, 2), (-1, 24, 2), (-1, 49, 2), (-1, 58, 2), (-1, 32, 2), (0, 1, 0), (1, 4, 0), (4, 5, 1), (2, 3, 0), (3, 8, 0), (8, 14, 1), (5, 9, 1), (9, 15, 1), (6, 7, 0), (7, 12, 0), (12, 13, 1), (14, 22, 1), (15, 24, 2), (10, 11, 0), (11, 16, 0), (16, 17, 1), (13, 20, 1), (20, 21, 1), (22, 23, 1), (17, 26, 1), (26, 25, 1), (18, 19, 0), (19, 28, 0), (28, 27, 1), (21, 32, 2), (23, 33, 2), (25, 34, 2), (27, 36, 1), (36, 35, 1), (29, 38, 0), (29, 40, 0), (38, 37, 1), (30, 31, 0), (31, 44, 1), (31, 42, 0), (44, 45, 1), (44, 43, 0), (35, 46, 2), (37, 48, 1), (48, 47, 1), (39, 50, 1), (39, 52, 1), (50, 49, 2), (41, 52, 1), (41, 54, 0), (51, 62, 1), (51, 60, 1), (60, 59, 1), (53, 62, 0), (53, 64, 0), (61, 70, 0), (61, 69, 1), (69, 68, 1), (63, 70, 0), (54, 55, 0), (65, 66, 1), (65, 80, 1), (56, 80, 1), (67, 68, 1), (67, 57, 2), (59, 58, 2), (66, 71, 0), (66, 73, 0), (71, 72, 0)])" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "wfn_reg.G.edges(data='cable')" ] }, { "cell_type": "markdown", "id": "0e35581d", "metadata": {}, "source": [ "Alternatively we can use `get_network()` method, to get the final cabling network as a structured array of edge data, and then extract desired edge data from it." ] }, { "cell_type": "markdown", "id": "ff55bd2f", "metadata": {}, "source": [ "### Regular turbine layout" ] }, { "cell_type": "code", "execution_count": 22, "id": "9d1c6b70", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "('src', 'tgt', 'length', 'load', 'cable')\n" ] } ], "source": [ "network_reg = wfn_reg.get_network()\n", "print(network_reg.dtype.names)" ] }, { "cell_type": "code", "execution_count": 23, "id": "c09d6db6", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[[47 -1 2]\n", " [56 -1 2]\n", " [46 -1 2]\n", " [33 -1 2]\n", " [45 -1 2]\n", " [57 -1 2]\n", " [34 -1 2]\n", " [24 -1 2]\n", " [49 -1 2]\n", " [58 -1 2]\n", " [32 -1 2]\n", " [ 0 1 0]\n", " [ 1 4 0]\n", " [ 4 5 1]\n", " [ 2 3 0]\n", " [ 3 8 0]\n", " [ 8 14 1]\n", " [ 5 9 1]\n", " [ 9 15 1]\n", " [ 6 7 0]\n", " [ 7 12 0]\n", " [12 13 1]\n", " [14 22 1]\n", " [15 24 2]\n", " [10 11 0]\n", " [11 16 0]\n", " [16 17 1]\n", " [13 20 1]\n", " [20 21 1]\n", " [22 23 1]\n", " [17 26 1]\n", " [26 25 1]\n", " [18 19 0]\n", " [19 28 0]\n", " [28 27 1]\n", " [21 32 2]\n", " [23 33 2]\n", " [25 34 2]\n", " [27 36 1]\n", " [36 35 1]\n", " [29 38 0]\n", " [40 29 0]\n", " [38 37 1]\n", " [30 31 0]\n", " [31 44 1]\n", " [42 31 0]\n", " [44 45 1]\n", " [43 44 0]\n", " [35 46 2]\n", " [37 48 1]\n", " [48 47 1]\n", " [39 50 1]\n", " [52 39 1]\n", " [50 49 2]\n", " [41 52 1]\n", " [54 41 0]\n", " [62 51 1]\n", " [51 60 1]\n", " [60 59 1]\n", " [53 62 0]\n", " [64 53 0]\n", " [70 61 0]\n", " [61 69 1]\n", " [69 68 1]\n", " [63 70 0]\n", " [55 54 0]\n", " [66 65 1]\n", " [65 80 1]\n", " [80 56 1]\n", " [68 67 1]\n", " [67 57 2]\n", " [59 58 2]\n", " [71 66 0]\n", " [73 66 0]\n", " [72 71 0]]\n" ] } ], "source": [ "network_cable_reg = np.column_stack((network_reg['src'], network_reg['tgt'], network_reg['cable']))\n", "print(network_cable_reg)" ] }, { "cell_type": "markdown", "id": "3adb5fd5", "metadata": {}, "source": [ "### Irregular turbine layout" ] }, { "cell_type": "code", "execution_count": 24, "id": "6574b182-8a8a-488e-a82d-9353d347b634", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[[41 -1 2]\n", " [28 -1 2]\n", " [49 -1 2]\n", " [55 -1 1]\n", " [39 -1 2]\n", " [60 -1 2]\n", " [70 -1 2]\n", " [25 -1 2]\n", " [33 -1 2]\n", " [80 -1 2]\n", " [81 -1 2]\n", " [ 0 50 0]\n", " [50 46 0]\n", " [ 1 34 0]\n", " [34 20 0]\n", " [ 2 8 1]\n", " [ 7 2 1]\n", " [ 8 42 1]\n", " [ 3 12 1]\n", " [15 3 1]\n", " [12 45 1]\n", " [ 4 20 0]\n", " [20 37 1]\n", " [ 9 5 0]\n", " [ 5 32 1]\n", " [32 14 1]\n", " [ 6 35 0]\n", " [35 36 0]\n", " [42 25 2]\n", " [10 24 0]\n", " [24 17 0]\n", " [11 18 0]\n", " [18 59 0]\n", " [45 33 2]\n", " [13 26 0]\n", " [26 31 0]\n", " [14 68 1]\n", " [68 73 2]\n", " [16 29 1]\n", " [17 16 1]\n", " [29 53 1]\n", " [59 60 2]\n", " [52 59 1]\n", " [37 51 1]\n", " [44 22 1]\n", " [22 67 1]\n", " [67 70 2]\n", " [23 43 0]\n", " [43 7 0]\n", " [31 56 1]\n", " [27 52 0]\n", " [38 27 0]\n", " [53 28 2]\n", " [30 54 1]\n", " [56 30 1]\n", " [54 49 2]\n", " [36 62 1]\n", " [62 69 1]\n", " [51 41 2]\n", " [40 55 1]\n", " [57 40 0]\n", " [47 65 0]\n", " [65 58 1]\n", " [48 65 0]\n", " [58 61 1]\n", " [61 64 1]\n", " [64 71 2]\n", " [69 63 1]\n", " [71 81 2]\n", " [73 80 2]\n", " [21 15 0]\n", " [19 9 0]\n", " [66 21 0]\n", " [46 44 1]\n", " [63 39 2]\n", " [72 57 0]]\n" ] } ], "source": [ "network_irr = wfn_irr.get_network()\n", "network_cable_irr = np.column_stack((network_irr['src'], network_irr['tgt'], network_irr['cable']))\n", "print(network_cable_irr)" ] }, { "cell_type": "markdown", "id": "bca688ed", "metadata": {}, "source": [ "## Mapping of contour/detour" ] }, { "cell_type": "markdown", "id": "8894a308-87ef-411d-b0a3-04cae5a8431d", "metadata": {}, "source": [ "Mapping of contour/detour node to the index of its VertexC coordinate :" ] }, { "cell_type": "code", "execution_count": 25, "id": "810eeab3-dc37-4cc6-bc91-dd407142a5e6", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{80: 76}" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "wfn_reg.map_detour_vertex()" ] }, { "cell_type": "code", "execution_count": 26, "id": "9159a31e-2f3c-4c97-aa94-8bd3a46e21b1", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{80: 28, 81: 76}" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "wfn_irr.map_detour_vertex()" ] } ], "metadata": { "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 5 }