{
"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": {},
"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.00s\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",
" 5.68e-04s 0.00e+00d [DetectDominanceRelations] \n",
" 1.08e-02s 0.00e+00d [operations_research::sat::CpModelPresolver::PresolveToFixPoint] #num_loops=2 #num_dual_strengthening=1 \n",
" 9.36e-05s 0.00e+00d [operations_research::sat::CpModelPresolver::ExtractEncodingFromLinear] #potential_supersets=687 \n",
" 3.69e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateColumns] \n",
" 4.91e-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.0011216 dtime: 0.00140614\n",
" 3.99e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraintsWithDifferentEnforcements] \n",
" 1.20e-02s 3.70e-03d [operations_research::sat::CpModelPresolver::Probe] #probed=1'536 \n",
" 7.54e-04s 3.94e-04d [MaxClique] Merged 613(1'918 literals) into 303(1'298 literals) at_most_ones. \n",
" 4.18e-04s 0.00e+00d [DetectDominanceRelations] \n",
" 3.82e-03s 0.00e+00d [operations_research::sat::CpModelPresolver::PresolveToFixPoint] #num_loops=1 #num_dual_strengthening=1 \n",
" 6.64e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::ProcessAtMostOneAndLinear] \n",
" 3.67e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraints] \n",
" 4.42e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraintsWithDifferentEnforcements] \n",
" 6.15e-04s 1.30e-05d [operations_research::sat::CpModelPresolver::DetectDominatedLinearConstraints] #relevant_constraints=151 #num_inclusions=75 \n",
" 6.35e-05s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDifferentVariables] \n",
" 5.02e-03s 3.02e-04d [operations_research::sat::CpModelPresolver::ProcessSetPPC] #relevant_constraints=379 #num_inclusions=377 \n",
" 5.70e-05s 0.00e+00d [operations_research::sat::CpModelPresolver::FindAlmostIdenticalLinearConstraints] \n",
" 6.12e-04s 2.40e-04d [operations_research::sat::CpModelPresolver::FindBigAtMostOneAndLinearOverlap] \n",
" 5.24e-04s 2.83e-04d [operations_research::sat::CpModelPresolver::FindBigVerticalLinearOverlap] \n",
" 1.22e-04s 1.15e-05d [operations_research::sat::CpModelPresolver::FindBigHorizontalLinearOverlap] #linears=148 \n",
" 1.70e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::MergeClauses] \n",
" 4.27e-04s 0.00e+00d [DetectDominanceRelations] \n",
" 4.44e-03s 0.00e+00d [operations_research::sat::CpModelPresolver::PresolveToFixPoint] #num_loops=1 #num_dual_strengthening=1 \n",
" 4.63e-04s 0.00e+00d [DetectDominanceRelations] \n",
" 4.34e-03s 0.00e+00d [operations_research::sat::CpModelPresolver::PresolveToFixPoint] #num_loops=1 #num_dual_strengthening=1 \n",
" 1.93e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateColumns] \n",
" 3.62e-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.0008038 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] [6.38e-05s] clauses:37 literals:74 vars:74 one_side_vars:74 simple_definition:0 singleton_clauses:0\n",
"[SAT presolve] [0.0001108s] clauses:37 literals:74 vars:74 one_side_vars:74 simple_definition:0 singleton_clauses:0\n",
" 3.67e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraintsWithDifferentEnforcements] \n",
" 1.12e-02s 3.42e-03d [operations_research::sat::CpModelPresolver::Probe] #probed=1'536 \n",
" 1.32e-03s 3.83e-04d [MaxClique] \n",
" 4.08e-04s 0.00e+00d [DetectDominanceRelations] \n",
" 4.25e-03s 0.00e+00d [operations_research::sat::CpModelPresolver::PresolveToFixPoint] #num_loops=1 #num_dual_strengthening=1 \n",
" 4.04e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::ProcessAtMostOneAndLinear] \n",
" 3.85e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraints] \n",
" 3.77e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraintsWithDifferentEnforcements] \n",
" 3.98e-04s 9.77e-06d [operations_research::sat::CpModelPresolver::DetectDominatedLinearConstraints] #relevant_constraints=150 #num_inclusions=74 \n",
" 4.11e-05s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDifferentVariables] \n",
" 3.17e-04s 6.39e-06d [operations_research::sat::CpModelPresolver::ProcessSetPPC] #relevant_constraints=378 \n",
" 6.94e-05s 0.00e+00d [operations_research::sat::CpModelPresolver::FindAlmostIdenticalLinearConstraints] \n",
" 6.71e-04s 2.37e-04d [operations_research::sat::CpModelPresolver::FindBigAtMostOneAndLinearOverlap] \n",
" 6.60e-04s 2.83e-04d [operations_research::sat::CpModelPresolver::FindBigVerticalLinearOverlap] \n",
" 2.56e-04s 1.15e-05d [operations_research::sat::CpModelPresolver::FindBigHorizontalLinearOverlap] #linears=148 \n",
" 9.08e-05s 0.00e+00d [operations_research::sat::CpModelPresolver::MergeClauses] \n",
" 4.17e-04s 0.00e+00d [DetectDominanceRelations] \n",
" 3.82e-03s 0.00e+00d [operations_research::sat::CpModelPresolver::PresolveToFixPoint] #num_loops=1 #num_dual_strengthening=1 \n",
" 6.33e-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.0007205 dtime: 0.00121832\n",
"\n",
"Preloading model.\n",
"#Bound 0.09s best:inf next:[123610.947,1028471.61] initial_domain\n",
"#1 0.09s best:139656.479 next:[123610.947,139656.479] complete_hint\n",
"#Model 0.10s var:1536/1536 constraints:2063/2063\n",
"\n",
"Starting search at 0.10s 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.15s best:139656.479 next:[123610.951,139656.479] am1_presolve (num_literals=694 num_am1=20 increase=4458 work_done=2551)\n",
"#2 0.16s 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.17s best:139650.831 next:[131572.567,139650.831] default_lp\n",
"#Bound 0.18s 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.37s best:139650.831 next:[135848.957,139650.831] max_lp\n",
"#3 0.50s 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.55s best:139650.831 next:[136118.437,139650.831] max_lp\n",
"#Model 0.69s var:1504/1536 constraints:2030/2063\n",
"#Bound 0.78s best:139650.831 next:[136183.946,139650.831] max_lp\n",
"#4 0.79s 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.80s 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 1.02s best:139645.183 next:[136221.036,139645.183] max_lp\n",
"#Model 1.09s var:1478/1536 constraints:2003/2063\n",
"#Bound 1.67s best:139645.183 next:[136284.537,139645.183] max_lp\n",
"#Bound 2.41s best:139645.183 next:[136351.677,139645.183] max_lp\n",
"#Bound 2.42s best:139645.183 next:[136355.681,139645.183] reduced_costs\n",
"#Bound 2.62s best:139645.183 next:[136401.974,139645.183] reduced_costs\n",
"#Bound 2.82s best:139645.183 next:[136464.159,139645.183] reduced_costs\n",
"#Model 2.90s var:1472/1536 constraints:1997/2063\n",
"#Bound 3.32s best:139645.183 next:[136498.186,139645.183] max_lp\n",
"#Bound 4.23s best:139645.183 next:[136576.285,139645.183] 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 [ 2.06s, 2.06s] 2.06s 0.00ns 2.06s\n",
" 'default_lp': 1 [ 4.91s, 4.91s] 4.91s 0.00ns 4.91s 1 [332.84ms, 332.84ms] 332.84ms 0.00ns 332.84ms\n",
" 'feasibility_pump': 2 [ 16.13ms, 1.13s] 570.82ms 554.69ms 1.14s 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 [154.58ms, 459.67ms] 303.79ms 141.69ms 1.22s 4 [ 23.03ms, 100.07ms] 54.85ms 32.82ms 219.38ms\n",
" 'graph_cst_lns': 6 [ 14.10ms, 362.02ms] 148.58ms 139.04ms 891.46ms 5 [612.00ns, 100.27ms] 43.38ms 46.72ms 216.90ms\n",
" 'graph_dec_lns': 6 [ 9.26ms, 470.98ms] 197.58ms 193.69ms 1.19s 6 [ 10.00ns, 100.06ms] 36.86ms 45.01ms 221.16ms\n",
" 'graph_var_lns': 5 [ 14.43ms, 569.29ms] 254.03ms 203.64ms 1.27s 5 [ 50.00ns, 100.03ms] 50.49ms 41.80ms 252.43ms\n",
" 'ls': 5 [185.09ms, 228.85ms] 202.80ms 15.43ms 1.01s 5 [ 80.90ms, 100.01ms] 96.19ms 7.64ms 480.94ms\n",
" 'max_lp': 1 [ 4.91s, 4.91s] 4.91s 0.00ns 4.91s 0 [ 0.00ns, 0.00ns] 0.00ns 0.00ns 0.00ns\n",
" 'no_lp': 1 [ 4.90s, 4.90s] 4.90s 0.00ns 4.90s 1 [ 1.46s, 1.46s] 1.46s 0.00ns 1.46s\n",
" 'quick_restart': 1 [ 4.91s, 4.91s] 4.91s 0.00ns 4.91s 1 [558.93ms, 558.93ms] 558.93ms 0.00ns 558.93ms\n",
" 'reduced_costs': 1 [ 4.90s, 4.90s] 4.90s 0.00ns 4.90s 1 [ 1.27s, 1.27s] 1.27s 0.00ns 1.27s\n",
" 'rins/rens': 6 [ 17.69ms, 593.41ms] 203.79ms 220.67ms 1.22s 5 [162.19us, 100.20ms] 40.78ms 48.45ms 203.89ms\n",
" 'rnd_cst_lns': 5 [ 14.68ms, 424.10ms] 175.15ms 176.68ms 875.77ms 4 [692.00ns, 100.13ms] 46.55ms 46.57ms 186.21ms\n",
" 'rnd_var_lns': 5 [ 20.16ms, 424.75ms] 197.11ms 166.07ms 985.53ms 5 [ 55.00ns, 100.13ms] 43.06ms 46.86ms 215.32ms\n",
"\n",
"Search stats Bools Conflicts Branches Restarts BoolPropag IntegerPropag\n",
" 'core': 788 55'090 148'503 4'912 1'070'912 2'912'113\n",
" 'default_lp': 768 14 1'710 1'541 12'559 44'270\n",
" 'fs_random_no_lp': 0 0 0 0 0 0\n",
" 'max_lp': 768 0 1'536 1'536 11'765 39'153\n",
" 'no_lp': 768 17'780 42'678 9'409 1'585'808 6'398'964\n",
" 'quick_restart': 768 20 1'712 1'538 13'187 47'109\n",
" 'reduced_costs': 774 265 9'880 4'626 48'319 297'880\n",
"\n",
"SAT stats ClassicMinim LitRemoved LitLearned LitForgotten Subsumed MClauses MDecisions MLitTrue MSubsumed MLitRemoved MReused\n",
" 'core': 51'636 1'097'712 4'818'085 3'293'151 591 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': 17'301 1'064'945 1'216'762 305'727 138 770 7'347 0 6 139 3\n",
" 'quick_restart': 19 1'205 1'952 0 0 0 0 0 0 0 0\n",
" 'reduced_costs': 242 11'060 56'679 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 8'761 3'123 227 0 1\n",
" 'max_lp': 1 2'543 1'734 19 0 0\n",
" 'quick_restart': 1 7'665 2'868 249 1 5\n",
" 'reduced_costs': 1 20'326 1'961 438 126 75\n",
"\n",
"Lp dimension Final dimension of first component\n",
" 'default_lp': 1774 rows, 1462 columns, 18415 entries\n",
" 'max_lp': 3134 rows, 1536 columns, 25288 entries\n",
" 'quick_restart': 1797 rows, 1462 columns, 21883 entries\n",
" 'reduced_costs': 1278 rows, 1536 columns, 12388 entries\n",
"\n",
"Lp debug CutPropag CutEqPropag Adjust Overflow Bad BadScaling\n",
" 'default_lp': 0 0 217 0 13'115 0\n",
" 'max_lp': 0 0 19 0 23'273 0\n",
" 'quick_restart': 0 0 239 0 13'710 0\n",
" 'reduced_costs': 0 0 595 0 6'601 0\n",
"\n",
"Lp pool Constraints Updates Simplif Merged Shortened Split Strenghtened Cuts/Call\n",
" 'default_lp': 5'695 126 1'863 0 1'316 51 61 3'123/6'005\n",
" 'max_lp': 4'565 252 1'697 0 1'157 173 14 1'734/3'482\n",
" 'quick_restart': 5'440 123 1'655 0 1'188 23 125 2'868/5'948\n",
" 'reduced_costs': 4'792 65 1'061 0 518 34 24 1'961/4'036\n",
"\n",
"Lp Cut reduced_costs default_lp max_lp quick_restart\n",
" CG_FF: 25 46 10 22\n",
" CG_K: 17 21 5 14\n",
" CG_KL: 1 1 - 1\n",
" CG_R: 42 40 19 40\n",
" CG_RB: 67 104 53 89\n",
" CG_RBP: 10 36 22 43\n",
" IB: 709 627 - 617\n",
" MIR_1_FF: 41 134 57 119\n",
" MIR_1_K: 4 49 1 31\n",
" MIR_1_KL: - 23 - 20\n",
" MIR_1_R: - 3 1 1\n",
" MIR_1_RB: 27 95 32 70\n",
" MIR_1_RBP: 6 55 6 67\n",
" MIR_2_FF: 76 145 89 116\n",
" MIR_2_K: 11 56 3 65\n",
" MIR_2_KL: 7 15 3 16\n",
" MIR_2_R: 4 23 6 4\n",
" MIR_2_RB: 77 148 103 126\n",
" MIR_2_RBP: 21 74 22 105\n",
" MIR_3_FF: 81 82 115 77\n",
" MIR_3_K: 17 66 20 68\n",
" MIR_3_KL: 6 7 5 8\n",
" MIR_3_R: 10 8 12 5\n",
" MIR_3_RB: 64 98 112 99\n",
" MIR_3_RBP: 19 58 25 52\n",
" MIR_4_FF: 48 68 102 50\n",
" MIR_4_K: 20 70 36 45\n",
" MIR_4_KL: 3 5 11 2\n",
" MIR_4_R: 6 6 13 3\n",
" MIR_4_RB: 51 70 70 52\n",
" MIR_4_RBP: 18 63 48 56\n",
" MIR_5_FF: 24 33 69 33\n",
" MIR_5_K: 21 42 41 43\n",
" MIR_5_KL: 8 7 10 6\n",
" MIR_5_R: 3 3 6 5\n",
" MIR_5_RB: 28 29 49 40\n",
" MIR_5_RBP: 20 48 54 59\n",
" MIR_6_FF: 32 24 43 20\n",
" MIR_6_K: 22 49 35 39\n",
" MIR_6_KL: 7 14 14 6\n",
" MIR_6_R: 2 3 5 2\n",
" MIR_6_RB: 17 19 33 24\n",
" MIR_6_RBP: 13 43 41 38\n",
" ZERO_HALF_FF: 31 58 13 44\n",
" ZERO_HALF_K: 4 19 1 16\n",
" ZERO_HALF_KL: 3 1 - 3\n",
" ZERO_HALF_R: 205 328 279 341\n",
" ZERO_HALF_RB: 27 80 26 36\n",
" ZERO_HALF_RBP: 6 27 14 30\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/5 60% 7.29e-01 0.10\n",
" 'graph_dec_lns': 0/6 67% 8.34e-01 0.10\n",
" 'graph_var_lns': 1/5 60% 7.00e-01 0.10\n",
" 'rins/rens': 4/6 67% 8.25e-01 0.10\n",
" 'rnd_cst_lns': 0/4 75% 8.21e-01 0.10\n",
" 'rnd_var_lns': 0/5 60% 7.48e-01 0.10\n",
"\n",
"LS stats Batches Restarts/Perturbs LinMoves GenMoves CompoundMoves Bactracks WeightUpdates ScoreComputed\n",
" 'ls_restart_compound': 1 1 0 16'305 1'608 7'348 67 392'083\n",
" 'ls_restart_compound_perturb': 1 1 0 12'871 1'335 5'768 90 325'294\n",
" 'ls_restart_decay': 1 1 14'497 0 0 0 277 314'922\n",
" 'ls_restart_decay_compound': 1 1 0 13'103 2'246 5'427 40 335'823\n",
" 'ls_restart_perturb': 1 1 12'015 0 0 0 2'617 358'925\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': 9\n",
" 'reduced_costs': 4\n",
"\n",
"Solution repositories Added Queried Synchro\n",
" 'feasible solutions': 5 83 5\n",
" 'fj solution hints': 0 0 0\n",
" 'lp solutions': 26 6 21\n",
" 'pump': 0 0\n",
"\n",
"Improving bounds shared Num Sym\n",
" 'default_lp': 32 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: 136576 corrected_bound: 136576 delta: -2.56434e-06\n",
"CpSolverResponse summary:\n",
"status: FEASIBLE\n",
"objective: 139645.18265364\n",
"best_bound: 136576.2851673974\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.05009\n",
"usertime: 5.05009\n",
"deterministic_time: 8.15161\n",
"gap_integral: 65.546\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": [
""
],
"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": {},
"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",
" 3.48e-04s 0.00e+00d [DetectDominanceRelations] \n",
" 8.90e-03s 0.00e+00d [operations_research::sat::CpModelPresolver::PresolveToFixPoint] #num_loops=2 #num_dual_strengthening=1 \n",
" 5.12e-05s 0.00e+00d [operations_research::sat::CpModelPresolver::ExtractEncodingFromLinear] #potential_supersets=493 \n",
" 3.20e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateColumns] \n",
" 4.34e-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.000752 dtime: 0.00080437\n",
" 9.61e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraintsWithDifferentEnforcements] \n",
" 8.61e-03s 2.33e-03d [operations_research::sat::CpModelPresolver::Probe] #probed=1'192 \n",
" 7.72e-04s 2.25e-04d [MaxClique] Merged 419(1'216 literals) into 234(846 literals) at_most_ones. \n",
" 3.30e-04s 0.00e+00d [DetectDominanceRelations] \n",
" 3.16e-03s 0.00e+00d [operations_research::sat::CpModelPresolver::PresolveToFixPoint] #num_loops=1 #num_dual_strengthening=1 \n",
" 4.10e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::ProcessAtMostOneAndLinear] \n",
" 3.17e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraints] \n",
" 3.03e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraintsWithDifferentEnforcements] \n",
" 4.90e-04s 1.01e-05d [operations_research::sat::CpModelPresolver::DetectDominatedLinearConstraints] #relevant_constraints=151 #num_inclusions=75 \n",
" 5.16e-05s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDifferentVariables] \n",
" 4.11e-03s 1.92e-04d [operations_research::sat::CpModelPresolver::ProcessSetPPC] #relevant_constraints=310 #num_inclusions=308 \n",
" 4.95e-05s 2.00e-07d [operations_research::sat::CpModelPresolver::FindAlmostIdenticalLinearConstraints] #num_tested_pairs=4 \n",
" 3.94e-04s 1.84e-04d [operations_research::sat::CpModelPresolver::FindBigAtMostOneAndLinearOverlap] \n",
" 3.36e-04s 2.07e-04d [operations_research::sat::CpModelPresolver::FindBigVerticalLinearOverlap] \n",
" 5.24e-05s 8.71e-06d [operations_research::sat::CpModelPresolver::FindBigHorizontalLinearOverlap] #linears=136 \n",
" 3.67e-05s 0.00e+00d [operations_research::sat::CpModelPresolver::MergeClauses] \n",
" 3.15e-04s 0.00e+00d [DetectDominanceRelations] \n",
" 2.81e-03s 0.00e+00d [operations_research::sat::CpModelPresolver::PresolveToFixPoint] #num_loops=1 #num_dual_strengthening=1 \n",
" 3.67e-04s 0.00e+00d [DetectDominanceRelations] \n",
" 4.87e-03s 0.00e+00d [operations_research::sat::CpModelPresolver::PresolveToFixPoint] #num_loops=1 #num_dual_strengthening=1 \n",
" 2.22e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateColumns] \n",
" 3.35e-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.0005567 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] [3.89e-05s] clauses:76 literals:152 vars:152 one_side_vars:152 simple_definition:0 singleton_clauses:0\n",
"[SAT presolve] [9.03e-05s] clauses:76 literals:152 vars:152 one_side_vars:152 simple_definition:0 singleton_clauses:0\n",
" 2.47e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraintsWithDifferentEnforcements] \n",
" 6.84e-03s 2.15e-03d [operations_research::sat::CpModelPresolver::Probe] #probed=1'192 \n",
" 3.49e-04s 2.19e-04d [MaxClique] \n",
" 8.13e-04s 0.00e+00d [DetectDominanceRelations] \n",
" 4.39e-03s 0.00e+00d [operations_research::sat::CpModelPresolver::PresolveToFixPoint] #num_loops=1 #num_dual_strengthening=1 \n",
" 4.68e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::ProcessAtMostOneAndLinear] \n",
" 4.03e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraints] \n",
" 3.75e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraintsWithDifferentEnforcements] \n",
" 4.62e-04s 7.55e-06d [operations_research::sat::CpModelPresolver::DetectDominatedLinearConstraints] #relevant_constraints=150 #num_inclusions=74 \n",
" 5.72e-05s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDifferentVariables] \n",
" 2.96e-04s 4.60e-06d [operations_research::sat::CpModelPresolver::ProcessSetPPC] #relevant_constraints=309 \n",
" 7.81e-05s 1.90e-07d [operations_research::sat::CpModelPresolver::FindAlmostIdenticalLinearConstraints] #num_tested_pairs=2 \n",
" 5.55e-04s 1.82e-04d [operations_research::sat::CpModelPresolver::FindBigAtMostOneAndLinearOverlap] \n",
" 3.61e-04s 2.07e-04d [operations_research::sat::CpModelPresolver::FindBigVerticalLinearOverlap] \n",
" 6.64e-05s 8.71e-06d [operations_research::sat::CpModelPresolver::FindBigHorizontalLinearOverlap] #linears=136 \n",
" 2.65e-05s 0.00e+00d [operations_research::sat::CpModelPresolver::MergeClauses] \n",
" 3.21e-04s 0.00e+00d [DetectDominanceRelations] \n",
" 3.03e-03s 0.00e+00d [operations_research::sat::CpModelPresolver::PresolveToFixPoint] #num_loops=1 #num_dual_strengthening=1 \n",
" 4.46e-04s 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.0005342 dtime: 0.00073413\n",
"\n",
"Preloading model.\n",
"#Bound 0.07s best:inf next:[93516.0522,1236251.99] initial_domain\n",
"#1 0.07s best:136451.277 next:[93516.0522,136451.277] complete_hint\n",
"#Model 0.08s var:1192/1192 constraints:1650/1650\n",
"\n",
"Starting search at 0.08s 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.11s best:136451.277 next:[95755.9972,136451.277] am1_presolve (num_literals=522 num_am1=19 increase=2348752631 work_done=1852)\n",
"#2 0.11s best:136417.955 next:[95755.9972,136417.955] no_lp [hint] (fixed_bools=0/596)\n",
"#Bound 0.12s best:136417.955 next:[104424.449,136417.955] quick_restart\n",
"#Bound 0.14s best:136417.955 next:[106103.007,136417.955] reduced_costs\n",
"#Bound 0.14s best:136417.955 next:[127628.142,136417.955] max_lp\n",
"#3 0.17s best:135518.936 next:[127628.142,135518.936] graph_arc_lns (d=5.00e-01 s=9 t=0.10 p=0.00 stall=0 h=base)\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.24s 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",
"#Bound 0.44s best:135031.477 next:[129244.173,135031.477] max_lp\n",
"#Bound 0.65s best:135031.477 next:[129611.049,135031.477] max_lp\n",
"#6 0.80s best:134786.792 next:[129611.049,134786.792] rins_lp_lns (d=7.07e-01 s=23 t=0.10 p=1.00 stall=1 h=base)\n",
"#Bound 0.95s best:134786.792 next:[129817.488,134786.792] max_lp\n",
"#Model 1.02s var:1186/1192 constraints:1643/1650\n",
"#Bound 1.69s best:134786.792 next:[130126.924,134786.792] max_lp\n",
"#Model 1.93s var:1178/1192 constraints:1634/1650\n",
"#Bound 2.51s best:134786.792 next:[130294.755,134786.792] max_lp\n",
"#Model 2.59s var:1158/1192 constraints:1613/1650\n",
"#Model 3.05s var:1156/1192 constraints:1611/1650\n",
"#Bound 3.26s best:134786.792 next:[130386.84,134786.792] max_lp\n",
"#Model 3.52s var:1154/1192 constraints:1609/1650\n",
"#Bound 4.02s best:134786.792 next:[130524.724,134786.792] max_lp\n",
"#Bound 5.00s best:134786.792 next:[130587.993,134786.792] max_lp\n",
"\n",
"Task timing n [ min, max] avg dev time n [ min, max] avg dev dtime\n",
" 'core': 1 [ 4.92s, 4.92s] 4.92s 0.00ns 4.92s 1 [ 2.75s, 2.75s] 2.75s 0.00ns 2.75s\n",
" 'default_lp': 1 [ 4.92s, 4.92s] 4.92s 0.00ns 4.92s 1 [393.30ms, 393.30ms] 393.30ms 0.00ns 393.30ms\n",
" 'feasibility_pump': 10 [ 42.30us, 899.19ms] 91.29ms 269.33ms 912.92ms 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': 4 [ 79.26ms, 421.92ms] 248.60ms 161.43ms 994.39ms 4 [ 2.87ms, 100.02ms] 54.08ms 46.08ms 216.32ms\n",
" 'graph_cst_lns': 5 [ 42.66ms, 491.89ms] 235.36ms 199.48ms 1.18s 5 [ 97.91us, 100.02ms] 43.42ms 46.32ms 217.09ms\n",
" 'graph_dec_lns': 6 [ 7.35ms, 475.01ms] 170.54ms 199.49ms 1.02s 5 [ 10.00ns, 100.08ms] 38.77ms 46.84ms 193.85ms\n",
" 'graph_var_lns': 6 [ 9.15ms, 436.03ms] 183.74ms 173.33ms 1.10s 6 [ 10.00ns, 100.06ms] 41.78ms 43.98ms 250.68ms\n",
" 'ls': 5 [209.70ms, 236.42ms] 221.73ms 10.77ms 1.11s 5 [100.01ms, 100.01ms] 100.01ms 2.14us 500.04ms\n",
" 'max_lp': 1 [ 4.95s, 4.95s] 4.95s 0.00ns 4.95s 0 [ 0.00ns, 0.00ns] 0.00ns 0.00ns 0.00ns\n",
" 'no_lp': 1 [ 4.97s, 4.97s] 4.97s 0.00ns 4.97s 1 [ 2.40s, 2.40s] 2.40s 0.00ns 2.40s\n",
" 'quick_restart': 1 [ 4.92s, 4.92s] 4.92s 0.00ns 4.92s 1 [695.76ms, 695.76ms] 695.76ms 0.00ns 695.76ms\n",
" 'reduced_costs': 1 [ 4.92s, 4.92s] 4.92s 0.00ns 4.92s 1 [991.88ms, 991.88ms] 991.88ms 0.00ns 991.88ms\n",
" 'rins/rens': 7 [983.30us, 504.62ms] 176.07ms 183.12ms 1.23s 5 [156.16us, 100.05ms] 44.31ms 38.25ms 221.56ms\n",
" 'rnd_cst_lns': 5 [ 16.61ms, 446.21ms] 213.85ms 180.47ms 1.07s 5 [201.00ns, 100.04ms] 44.98ms 45.70ms 224.88ms\n",
" 'rnd_var_lns': 7 [ 15.19ms, 419.24ms] 163.17ms 162.48ms 1.14s 7 [ 71.00ns, 100.06ms] 34.88ms 43.76ms 244.17ms\n",
"\n",
"Search stats Bools Conflicts Branches Restarts BoolPropag IntegerPropag\n",
" 'core': 615 62'106 153'970 7'180 954'872 2'734'964\n",
" 'default_lp': 607 16 1'450 1'193 8'534 31'587\n",
" 'fs_random_no_lp': 0 0 0 0 0 0\n",
" 'max_lp': 596 0 1'192 1'192 7'268 24'807\n",
" 'no_lp': 596 44'900 70'781 7'390 2'235'610 7'390'471\n",
" 'quick_restart': 596 22 1'429 1'194 8'877 33'056\n",
" 'reduced_costs': 596 88 3'992 2'333 18'065 85'300\n",
"\n",
"SAT stats ClassicMinim LitRemoved LitLearned LitForgotten Subsumed MClauses MDecisions MLitTrue MSubsumed MLitRemoved MReused\n",
" 'core': 57'478 565'496 4'040'406 3'363'080 739 3'065 29'317 0 635 9'445 688\n",
" 'default_lp': 13 788 1'659 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': 44'126 365'727 3'252'330 2'214'012 246 1'258 10'948 0 139 1'751 461\n",
" 'quick_restart': 21 771 2'330 0 0 0 0 0 0 0 0\n",
" 'reduced_costs': 85 2'842 5'608 0 0 146 1'008 0 0 0 0\n",
"\n",
"Lp stats Component Iterations AddedCuts OPTIMAL DUAL_F. DUAL_U.\n",
" 'default_lp': 1 5'750 3'081 284 0 0\n",
" 'max_lp': 1 1'630 1'820 19 1 0\n",
" 'quick_restart': 1 8'167 2'947 310 1 0\n",
" 'reduced_costs': 1 12'276 2'524 347 77 6\n",
"\n",
"Lp dimension Final dimension of first component\n",
" 'default_lp': 1551 rows, 1119 columns, 17070 entries\n",
" 'max_lp': 2639 rows, 1192 columns, 21942 entries\n",
" 'quick_restart': 1542 rows, 1119 columns, 18674 entries\n",
" 'reduced_costs': 1539 rows, 1192 columns, 16595 entries\n",
"\n",
"Lp debug CutPropag CutEqPropag Adjust Overflow Bad BadScaling\n",
" 'default_lp': 0 0 279 0 15'182 0\n",
" 'max_lp': 2 0 20 0 25'924 0\n",
" 'quick_restart': 0 27 306 0 13'574 0\n",
" 'reduced_costs': 0 0 413 0 12'493 0\n",
"\n",
"Lp pool Constraints Updates Simplif Merged Shortened Split Strenghtened Cuts/Call\n",
" 'default_lp': 5'032 106 690 0 620 20 109 3'081/6'020\n",
" 'max_lp': 4'066 267 1'535 0 1'292 108 24 1'820/3'528\n",
" 'quick_restart': 4'898 151 1'980 0 1'824 36 84 2'947/5'472\n",
" 'reduced_costs': 4'770 141 938 0 814 38 111 2'524/4'422\n",
"\n",
"Lp Cut default_lp quick_restart reduced_costs max_lp\n",
" CG_FF: 25 26 20 6\n",
" CG_K: 14 6 13 5\n",
" CG_KL: - 1 1 -\n",
" CG_R: 32 37 24 23\n",
" CG_RB: 74 93 75 46\n",
" CG_RBP: 39 32 24 19\n",
" IB: 549 572 574 -\n",
" MIR_1_FF: 155 159 66 70\n",
" MIR_1_K: 51 48 13 3\n",
" MIR_1_KL: 21 25 7 1\n",
" MIR_1_R: 7 - 2 5\n",
" MIR_1_RB: 103 84 41 48\n",
" MIR_1_RBP: 73 82 23 7\n",
" MIR_1_RLT: - - 3 -\n",
" MIR_2_FF: 174 174 119 92\n",
" MIR_2_K: 61 64 13 7\n",
" MIR_2_KL: 21 21 6 3\n",
" MIR_2_R: 8 10 13 14\n",
" MIR_2_RB: 134 124 143 98\n",
" MIR_2_RBP: 86 88 31 22\n",
" MIR_3_FF: 120 97 134 109\n",
" MIR_3_K: 62 73 26 18\n",
" MIR_3_KL: 9 3 7 3\n",
" MIR_3_R: 5 8 12 18\n",
" MIR_3_RB: 106 82 144 140\n",
" MIR_3_RBP: 65 77 59 41\n",
" MIR_4_FF: 81 60 104 100\n",
" MIR_4_K: 54 51 22 42\n",
" MIR_4_KL: 7 3 5 3\n",
" MIR_4_R: 5 5 12 12\n",
" MIR_4_RB: 68 50 111 92\n",
" MIR_4_RBP: 73 49 17 55\n",
" MIR_5_FF: 54 50 59 49\n",
" MIR_5_K: 59 51 17 28\n",
" MIR_5_KL: 18 13 12 12\n",
" MIR_5_R: 2 6 6 12\n",
" MIR_5_RB: 27 35 58 57\n",
" MIR_5_RBP: 68 53 19 47\n",
" MIR_6_FF: 48 29 37 34\n",
" MIR_6_K: 50 44 14 45\n",
" MIR_6_KL: 22 21 21 22\n",
" MIR_6_R: 2 1 1 8\n",
" MIR_6_RB: 19 12 35 32\n",
" MIR_6_RBP: 54 43 24 67\n",
" ZERO_HALF_FF: 29 39 29 15\n",
" ZERO_HALF_K: 9 8 4 1\n",
" ZERO_HALF_KL: 1 3 - 2\n",
" ZERO_HALF_R: 249 281 276 243\n",
" ZERO_HALF_RB: 62 38 38 31\n",
" ZERO_HALF_RBP: 26 16 10 13\n",
"\n",
"LNS stats Improv/Calls Closed Difficulty TimeLimit\n",
" 'graph_arc_lns': 1/4 50% 5.54e-01 0.10\n",
" 'graph_cst_lns': 0/5 60% 7.29e-01 0.10\n",
" 'graph_dec_lns': 0/5 80% 8.73e-01 0.10\n",
" 'graph_var_lns': 0/6 67% 7.92e-01 0.10\n",
" 'rins/rens': 5/6 67% 8.12e-01 0.10\n",
" 'rnd_cst_lns': 1/5 60% 7.48e-01 0.10\n",
" 'rnd_var_lns': 0/7 71% 8.65e-01 0.10\n",
"\n",
"LS stats Batches Restarts/Perturbs LinMoves GenMoves CompoundMoves Bactracks WeightUpdates ScoreComputed\n",
" 'ls_restart_decay': 2 2 36'626 0 0 0 808 782'211\n",
" 'ls_restart_decay_compound_perturb': 2 2 0 33'700 5'458 14'116 103 848'321\n",
" 'ls_restart_decay_perturb': 1 1 18'453 0 0 0 413 382'808\n",
"\n",
"Solutions (6) Num Rank\n",
" 'complete_hint': 1 [1,1]\n",
" 'graph_arc_lns': 2 [3,4]\n",
" 'no_lp': 1 [2,2]\n",
" 'rins_lp_lns': 1 [6,6]\n",
" 'rnd_cst_lns': 1 [5,5]\n",
"\n",
"Objective bounds Num\n",
" 'am1_presolve': 1\n",
" 'initial_domain': 1\n",
" 'max_lp': 10\n",
" 'quick_restart': 1\n",
" 'reduced_costs': 1\n",
"\n",
"Solution repositories Added Queried Synchro\n",
" 'feasible solutions': 6 88 6\n",
" 'fj solution hints': 0 0 0\n",
" 'lp solutions': 5 7 5\n",
" 'pump': 0 0\n",
"\n",
"Improving bounds shared Num Sym\n",
" 'default_lp': 6 0\n",
" 'max_lp': 22 0\n",
" 'quick_restart': 10 0\n",
" 'reduced_costs': 2 0\n",
"\n",
"Clauses shared Num\n",
" 'core': 16\n",
" 'reduced_costs': 1\n",
"\n",
"[Scaling] scaled_objective_bound: 130588 corrected_bound: 130588 delta: -3.69953e-07\n",
"CpSolverResponse summary:\n",
"status: FEASIBLE\n",
"objective: 134786.7922581253\n",
"best_bound: 130587.9932321433\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.06474\n",
"usertime: 5.06474\n",
"deterministic_time: 9.67307\n",
"gap_integral: 80.9823\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": [
""
],
"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([(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), (24, -1, 2), (17, 26, 1), (26, 25, 1), (18, 19, 0), (19, 28, 0), (28, 27, 1), (21, 32, 2), (32, -1, 2), (23, 33, 2), (33, -1, 2), (25, 34, 2), (34, -1, 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), (46, -1, 2), (37, 48, 1), (48, 47, 1), (39, 50, 1), (39, 52, 1), (50, 49, 2), (41, 52, 1), (41, 54, 0), (45, -1, 2), (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), (47, -1, 2), (49, -1, 2), (65, 66, 1), (65, 80, 1), (56, -1, 2), (56, 80, 1), (67, 68, 1), (67, 57, 2), (57, -1, 2), (59, 58, 2), (58, -1, 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": [
"[[ 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",
" [24 -1 2]\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",
" [32 -1 2]\n",
" [23 33 2]\n",
" [33 -1 2]\n",
" [25 34 2]\n",
" [34 -1 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",
" [46 -1 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",
" [45 -1 2]\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",
" [47 -1 2]\n",
" [49 -1 2]\n",
" [66 65 1]\n",
" [65 80 1]\n",
" [56 -1 2]\n",
" [80 56 1]\n",
" [68 67 1]\n",
" [67 57 2]\n",
" [57 -1 2]\n",
" [59 58 2]\n",
" [58 -1 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)\n"
]
},
{
"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": [
"[[ 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",
" [55 -1 1]\n",
" [47 65 0]\n",
" [65 58 1]\n",
" [48 65 0]\n",
" [58 61 1]\n",
" [61 64 1]\n",
" [60 -1 2]\n",
" [64 71 2]\n",
" [69 63 1]\n",
" [71 81 2]\n",
" [70 -1 2]\n",
" [73 80 2]\n",
" [21 15 0]\n",
" [19 9 0]\n",
" [66 21 0]\n",
" [46 44 1]\n",
" [25 -1 2]\n",
" [28 -1 2]\n",
" [33 -1 2]\n",
" [63 39 2]\n",
" [39 -1 2]\n",
" [72 57 0]\n",
" [41 -1 2]\n",
" [49 -1 2]\n",
" [80 -1 2]\n",
" [81 -1 2]]\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": {
"kernelspec": {
"display_name": "OptiWindNet",
"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.12.9"
}
},
"nbformat": 4,
"nbformat_minor": 5
}