{
"cells": [
{
"cell_type": "markdown",
"id": "8d434457-7996-4b76-a773-c2f77d63ff0b",
"metadata": {},
"source": [
"# Quickstart"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "2f1ecb89-84e4-4316-9db9-dbaf5b282bf0",
"metadata": {},
"outputs": [],
"source": [
"from optiwindnet.importer import load_repository\n",
"from optiwindnet.svg import svgplot\n",
"from optiwindnet.interarraylib import G_from_S\n",
"from optiwindnet.mesh import make_planar_embedding\n",
"from optiwindnet.pathfinding import PathFinder"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "1f2d7a49-6c57-49e9-bb85-cad2eb08d350",
"metadata": {},
"outputs": [],
"source": [
"locations = load_repository()"
]
},
{
"cell_type": "markdown",
"id": "1868a624-209c-4897-9762-1262a4a097bc",
"metadata": {},
"source": [
"## Quickest (sub-second)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "b6a65515-8573-4fb7-9f14-f741d78eb361",
"metadata": {},
"outputs": [],
"source": [
"from optiwindnet.heuristics import EW_presolver"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "e4218728-24ee-4e12-a597-0aff167ce84d",
"metadata": {},
"outputs": [],
"source": [
"L = locations.doggerA"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "db91b101-c598-4a53-859d-d2bd540c1bef",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"43.2 ms ± 9.56 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)\n"
]
}
],
"source": [
"%%timeit\n",
"P, A = make_planar_embedding(L)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "0d340d87-76a2-4537-8267-a5ae267b3ac2",
"metadata": {},
"outputs": [],
"source": [
"P, A = make_planar_embedding(L)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "842e6996-49a7-4354-b28a-c3c042b5a6a3",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"7.95 ms ± 608 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n"
]
}
],
"source": [
"%%timeit\n",
"S_pre = EW_presolver(A, capacity=8)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "db7316e3-173f-4f5f-9418-b2cf07ddcd5a",
"metadata": {},
"outputs": [],
"source": [
"S_pre = EW_presolver(A, capacity=8)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "f5a054d7-8755-4fa2-9243-1a42c3c31c6c",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"48.8 ms ± 2.91 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)\n"
]
}
],
"source": [
"%%timeit\n",
"G_tentative = G_from_S(S_pre, A)\n",
"G_pre = PathFinder(G_tentative, planar=P, A=A).create_detours()"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "a5dbd69a-16dc-48b0-b927-84b2a9bf567b",
"metadata": {},
"outputs": [],
"source": [
"G_tentative = G_from_S(S_pre, A)\n",
"G_pre = PathFinder(G_tentative, planar=P, A=A).create_detours()"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "a379f37d-9778-421b-a2c1-6f1bab4d3821",
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
""
],
"text/plain": [
""
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"svgplot(G_pre)"
]
},
{
"cell_type": "markdown",
"id": "fe9ac6af-923b-42aa-9ef0-90b1931c89d8",
"metadata": {},
"source": [
"## Quick (radial only, a second or two)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "9f143635-93f2-4acb-910b-4e2a4394693e",
"metadata": {},
"outputs": [],
"source": [
"from optiwindnet.baselines.hgs import hgs_multiroot\n",
"from optiwindnet.interarraylib import as_normalized"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "df6a5304-9dec-4981-91f4-aeabaf7e0600",
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
""
],
"text/plain": [
""
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"L = locations.doggerA\n",
"P, A = make_planar_embedding(L)\n",
"S_hgs = hgs_multiroot(as_normalized(A), capacity=8, time_limit=2)\n",
"G_tentative = G_from_S(S_hgs, A)\n",
"G_hgs = PathFinder(G_tentative, planar=P, A=A).create_detours()\n",
"svgplot(G_hgs)"
]
},
{
"cell_type": "markdown",
"id": "bdd24d65-4be1-451e-a129-9f72ad873fc8",
"metadata": {},
"source": [
"## With quality assurance (a few minutes)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "edc931f3-8beb-4d41-98e9-ec6af1701060",
"metadata": {},
"outputs": [],
"source": [
"from optiwindnet.MILP import solver_factory, ModelOptions"
]
},
{
"cell_type": "code",
"execution_count": 15,
"id": "60446165-4fba-47a2-ab56-c5154cfa3b10",
"metadata": {},
"outputs": [],
"source": [
"solver = solver_factory('ortools')"
]
},
{
"cell_type": "code",
"execution_count": 16,
"id": "7db52bea-e902-4633-9783-dfa0b2df5268",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"topology in {\"radial\", \"branched\"} default: branched\n",
" Set the topology of subtrees in the solution.\n",
"\n",
"feeder_route in {\"straight\", \"segmented\"} default: segmented\n",
" If feeder routes must be \"straight\" or can be detoured (\"segmented\").\n",
"\n",
"feeder_limit in {\"unlimited\", \"specified\", \"minimum\", \"min_plus1\", \"min_plus2\", \"min_plus3\"} default: unlimited\n",
" Whether to limit the maximum number of feeders, if set to \"specified\", additional kwarg \"max_feeders\" must be given.\n",
"\n",
"balanced [bool] default: False\n",
" Whether to enforce balanced subtrees (subtree loads differ at most by one unit).\n",
"\n",
"max_feeders [int] default: 0\n",
" Maximum number of feeders (used only if )\n",
"\n"
]
}
],
"source": [
"ModelOptions.help()"
]
},
{
"cell_type": "code",
"execution_count": 17,
"id": "64e22c2f-1339-48b6-86a8-635874e8b382",
"metadata": {},
"outputs": [],
"source": [
"solver.set_problem(\n",
" P, A, S_hgs.graph['capacity'], ModelOptions(\n",
" topology='branched',\n",
" feeder_route='segmented',\n",
" feeder_limit='unlimited'\n",
" ), warmstart=S_hgs\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 18,
"id": "70aefef1-25ed-4011-bdf0-e335e5f76ba5",
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Starting CP-SAT solver v9.14.6206\n",
"Parameters: max_time_in_seconds: 40 log_search_progress: true relative_gap_limit: 0.005\n",
"Setting number of workers to 8\n",
"\n",
"Initial optimization model '': (model_fingerprint: 0xd731f65355c953ec)\n",
"#Variables: 1'690 (#bools: 845 in floating point objective) (1'500 primary variables)\n",
" - 845 Booleans in [0,1]\n",
" - 750 in [0,7]\n",
" - 95 in [0,8]\n",
"#kAtMostOne: 635 (#literals: 1'926)\n",
"#kLinear1: 1'690 (#enforced: 1'690)\n",
"#kLinear3: 4\n",
"#kLinearN: 284 (#terms: 4'213)\n",
"\n",
"Starting presolve at 0.01s\n",
"The solution hint is complete and is feasible.\n",
"[Scaling] Floating point objective has 845 terms with magnitude in [1409.66, 22631.9] average = 4594.28\n",
"[Scaling] Objective coefficient relative error: 1.60816e-10\n",
"[Scaling] Objective worst-case absolute error: 5.3597e-05\n",
"[Scaling] Objective scaling factor: 2.09715e+06\n",
" 1.77e-03s 0.00e+00d [DetectDominanceRelations] \n",
" 6.51e-02s 0.00e+00d [operations_research::sat::CpModelPresolver::PresolveToFixPoint] #num_loops=2 #num_dual_strengthening=1 \n",
" 2.82e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::ExtractEncodingFromLinear] #potential_supersets=730 \n",
" 1.69e-03s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateColumns] \n",
" 3.48e-03s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraints] \n",
"[Symmetry] Graph for symmetry has 6'328 nodes and 11'931 arcs.\n",
"[Symmetry] Symmetry computation done. time: 0.0016671 dtime: 0.00115685\n",
" 7.69e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraintsWithDifferentEnforcements] \n",
" 3.93e-02s 3.73e-03d [operations_research::sat::CpModelPresolver::Probe] #probed=1'690 \n",
" 1.26e-03s 3.79e-04d [MaxClique] Merged 635(1'926 literals) into 330(1'316 literals) at_most_ones. \n",
" 7.28e-04s 0.00e+00d [DetectDominanceRelations] \n",
" 9.31e-03s 0.00e+00d [operations_research::sat::CpModelPresolver::PresolveToFixPoint] #num_loops=1 #num_dual_strengthening=1 \n",
" 9.53e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::ProcessAtMostOneAndLinear] \n",
" 6.95e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraints] \n",
" 6.46e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraintsWithDifferentEnforcements] \n",
" 9.30e-04s 1.43e-05d [operations_research::sat::CpModelPresolver::DetectDominatedLinearConstraints] #relevant_constraints=193 #num_inclusions=96 \n",
" 7.03e-05s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDifferentVariables] \n",
" 1.23e-02s 3.72e-04d [operations_research::sat::CpModelPresolver::ProcessSetPPC] #relevant_constraints=427 #num_inclusions=425 \n",
" 1.34e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::FindAlmostIdenticalLinearConstraints] \n",
" 1.10e-03s 2.83e-04d [operations_research::sat::CpModelPresolver::FindBigAtMostOneAndLinearOverlap] \n",
" 7.51e-04s 3.25e-04d [operations_research::sat::CpModelPresolver::FindBigVerticalLinearOverlap] \n",
" 1.21e-04s 1.24e-05d [operations_research::sat::CpModelPresolver::FindBigHorizontalLinearOverlap] #linears=179 \n",
" 5.31e-05s 0.00e+00d [operations_research::sat::CpModelPresolver::MergeClauses] \n",
" 1.40e-03s 0.00e+00d [DetectDominanceRelations] \n",
" 7.41e-03s 0.00e+00d [operations_research::sat::CpModelPresolver::PresolveToFixPoint] #num_loops=1 #num_dual_strengthening=1 \n",
" 1.29e-03s 0.00e+00d [DetectDominanceRelations] \n",
" 1.06e-02s 0.00e+00d [operations_research::sat::CpModelPresolver::PresolveToFixPoint] #num_loops=1 #num_dual_strengthening=1 \n",
" 6.00e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateColumns] \n",
" 1.14e-03s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraints] \n",
"[Symmetry] Graph for symmetry has 5'717 nodes and 9'866 arcs.\n",
"[Symmetry] Symmetry computation done. time: 0.0023584 dtime: 0.00104489\n",
"[SAT presolve] num removable Booleans: 0 / 845\n",
"[SAT presolve] num trivial clauses: 0\n",
"[SAT presolve] [0s] clauses:70 literals:140 vars:140 one_side_vars:140 simple_definition:0 singleton_clauses:0\n",
"[SAT presolve] [0.0002579s] clauses:70 literals:140 vars:140 one_side_vars:140 simple_definition:0 singleton_clauses:0\n",
"[SAT presolve] [0.000431s] clauses:70 literals:140 vars:140 one_side_vars:140 simple_definition:0 singleton_clauses:0\n",
" 1.84e-03s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraintsWithDifferentEnforcements] \n",
" 3.44e-02s 3.45e-03d [operations_research::sat::CpModelPresolver::Probe] #probed=1'690 \n",
" 1.80e-03s 3.69e-04d [MaxClique] \n",
" 1.42e-03s 0.00e+00d [DetectDominanceRelations] \n",
" 1.53e-02s 0.00e+00d [operations_research::sat::CpModelPresolver::PresolveToFixPoint] #num_loops=1 #num_dual_strengthening=1 \n",
" 1.22e-03s 0.00e+00d [operations_research::sat::CpModelPresolver::ProcessAtMostOneAndLinear] \n",
" 1.19e-03s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraints] \n",
" 1.05e-03s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDuplicateConstraintsWithDifferentEnforcements] \n",
" 9.90e-04s 1.07e-05d [operations_research::sat::CpModelPresolver::DetectDominatedLinearConstraints] #relevant_constraints=192 #num_inclusions=95 \n",
" 1.14e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::DetectDifferentVariables] \n",
" 5.94e-04s 6.76e-06d [operations_research::sat::CpModelPresolver::ProcessSetPPC] #relevant_constraints=426 \n",
" 1.42e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::FindAlmostIdenticalLinearConstraints] \n",
" 1.20e-03s 2.79e-04d [operations_research::sat::CpModelPresolver::FindBigAtMostOneAndLinearOverlap] \n",
" 8.61e-04s 3.25e-04d [operations_research::sat::CpModelPresolver::FindBigVerticalLinearOverlap] \n",
" 1.32e-04s 1.24e-05d [operations_research::sat::CpModelPresolver::FindBigHorizontalLinearOverlap] #linears=179 \n",
" 7.18e-05s 0.00e+00d [operations_research::sat::CpModelPresolver::MergeClauses] \n",
" 1.02e-03s 0.00e+00d [DetectDominanceRelations] \n",
" 1.13e-02s 0.00e+00d [operations_research::sat::CpModelPresolver::PresolveToFixPoint] #num_loops=1 #num_dual_strengthening=1 \n",
" 1.92e-03s 0.00e+00d [operations_research::sat::CpModelPresolver::ExpandObjective] #entries=7'754 #tight_variables=845 #tight_constraints=95 \n",
"\n",
"Presolve summary:\n",
" - 0 affine relations were detected.\n",
" - rule 'TODO linear inclusion: superset is equality' was applied 191 times.\n",
" - rule 'at_most_one: transformed into max clique.' was applied 1 time.\n",
" - rule 'deductions: 1690 stored' was applied 1 time.\n",
" - rule 'exactly_one: simplified objective' was applied 95 times.\n",
" - rule 'linear: positive equal one' was applied 95 times.\n",
" - rule 'objective: shifted cost with exactly ones' was applied 95 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 95 times.\n",
" - rule 'setppc: reduced linear coefficients' was applied 94 times.\n",
" - rule 'setppc: removed trivial linear constraint' was applied 1 time.\n",
" - rule 'variables: detect fully reified value encoding' was applied 845 times.\n",
" - rule 'variables: detect half reified value encoding' was applied 1'690 times.\n",
"\n",
"Presolved optimization model '': (model_fingerprint: 0x9ac4469a2efff135)\n",
"#Variables: 1'690 (#bools: 750 in objective) (1'500 primary variables)\n",
" - 845 Booleans in [0,1]\n",
" - 750 in [0,7]\n",
" - 95 in [0,8]\n",
"#kAtMostOne: 260 (#literals: 1'176)\n",
"#kBoolAnd: 70 (#enforced: 70) (#literals: 140)\n",
"#kExactlyOne: 95 (#literals: 845)\n",
"#kLinear1: 1'690 (#enforced: 1'690)\n",
"#kLinear3: 4\n",
"#kLinearN: 188 (#terms: 2'523)\n",
"[Symmetry] Graph for symmetry has 5'717 nodes and 9'866 arcs.\n",
"[Symmetry] Symmetry computation done. time: 0.0009476 dtime: 0.00104362\n",
"\n",
"Preloading model.\n",
"#Bound 0.29s best:inf next:[160817.074,2309766.32] initial_domain\n",
"#1 0.29s best:243062.907 next:[160817.074,243062.907] complete_hint\n",
"#Model 0.30s var:1690/1690 constraints:2307/2307\n",
"\n",
"Starting search at 0.30s 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.42s best:243062.907 next:[188354.862,243062.907] quick_restart\n",
"#Bound 0.46s best:243062.907 next:[188355.856,243062.907] default_lp\n",
"#Bound 0.48s best:243062.907 next:[188888.882,243062.907] quick_restart\n",
"#Bound 0.55s best:243062.907 next:[188938.532,243062.907] quick_restart\n",
"#Bound 0.56s best:243062.907 next:[189781.728,243062.907] reduced_costs\n",
"#Bound 0.67s best:243062.907 next:[189787.863,243062.907] reduced_costs\n",
"#Bound 0.72s best:243062.907 next:[189886.17,243062.907] reduced_costs\n",
"#Bound 0.74s best:243062.907 next:[223973.897,243062.907] max_lp\n",
"#Bound 1.09s best:243062.907 next:[225385.939,243062.907] max_lp\n",
"#2 1.27s best:243061.638 next:[225385.939,243061.638] graph_arc_lns (d=5.00e-01 s=9 t=0.10 p=0.00 stall=0 h=base)\n",
"#Bound 1.53s best:243061.638 next:[226110.959,243061.638] max_lp\n",
"#3 1.87s best:242646.723 next:[226110.959,242646.723] rins_lp_lns (d=5.00e-01 s=15 t=0.10 p=0.00 stall=0 h=base)\n",
"#4 1.91s best:242646.088 next:[226110.959,242646.088] rins_lp_lns (d=5.00e-01 s=15 t=0.10 p=0.00 stall=0 h=base) [combined with: graph_arc_lns (d=5.0...]\n",
"#Bound 2.03s best:242646.088 next:[226518.351,242646.088] max_lp\n",
"#Bound 2.61s best:242646.088 next:[226990.815,242646.088] max_lp\n",
"#Bound 3.19s best:242646.088 next:[227472.946,242646.088] max_lp\n",
"#5 5.01s best:242630.476 next:[227472.946,242630.476] rins_lp_lns (d=2.93e-01 s=32 t=0.10 p=0.00 stall=0 h=base)\n",
"#Bound 5.05s best:242630.476 next:[227789.346,242630.476] max_lp\n",
"#6 6.20s best:242442.636 next:[227789.346,242442.636] graph_arc_lns (d=6.41e-01 s=38 t=0.10 p=0.67 stall=2 h=base)\n",
"#Bound 8.85s best:242442.636 next:[228055.107,242442.636] max_lp\n",
"#Bound 9.86s best:242442.636 next:[228351.766,242442.636] max_lp\n",
"#7 11.36s best:241056.097 next:[228351.766,241056.097] rins_pump_lns (d=4.81e-01 s=55 t=0.10 p=0.50 stall=0 h=base)\n",
"#Bound 11.91s best:241056.097 next:[228500.898,241056.097] max_lp\n",
"#Bound 15.09s best:241056.097 next:[228673.051,241056.097] max_lp\n",
"#Bound 18.27s best:241056.097 next:[228785.359,241056.097] max_lp\n",
"#8 25.99s best:240847.588 next:[228785.359,240847.588] graph_arc_lns (d=4.53e-01 s=106 t=0.10 p=0.50 stall=6 h=base)\n",
"\n",
"Task timing n [ min, max] avg dev time n [ min, max] avg dev dtime\n",
" 'core': 1 [ 39.70s, 39.70s] 39.70s 0.00ns 39.70s 1 [ 12.16s, 12.16s] 12.16s 0.00ns 12.16s\n",
" 'default_lp': 1 [ 39.69s, 39.69s] 39.69s 0.00ns 39.69s 1 [ 5.19s, 5.19s] 5.19s 0.00ns 5.19s\n",
" 'feasibility_pump': 82 [140.10us, 1.28s] 95.05ms 294.96ms 7.79s 8 [196.88ms, 322.49ms] 242.36ms 40.81ms 1.94s\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': 19 [ 34.05ms, 929.01ms] 461.42ms 316.87ms 8.77s 19 [ 86.30us, 100.26ms] 60.87ms 45.12ms 1.16s\n",
" 'graph_cst_lns': 18 [ 59.74ms, 2.51s] 521.94ms 567.87ms 9.39s 18 [109.30us, 101.61ms] 53.53ms 47.40ms 963.56ms\n",
" 'graph_dec_lns': 19 [ 4.13ms, 1.20s] 474.85ms 401.92ms 9.02s 16 [ 10.00ns, 100.11ms] 59.60ms 45.82ms 953.54ms\n",
" 'graph_var_lns': 19 [ 18.87ms, 1.36s] 446.28ms 396.40ms 8.48s 19 [ 10.00ns, 100.39ms] 51.93ms 47.26ms 986.75ms\n",
" 'ls': 22 [308.78ms, 719.49ms] 381.73ms 85.40ms 8.40s 22 [100.01ms, 100.02ms] 100.01ms 3.21us 2.20s\n",
" 'max_lp': 1 [ 39.69s, 39.69s] 39.69s 0.00ns 39.69s 1 [ 4.78s, 4.78s] 4.78s 0.00ns 4.78s\n",
" 'no_lp': 1 [ 39.70s, 39.70s] 39.70s 0.00ns 39.70s 1 [ 11.34s, 11.34s] 11.34s 0.00ns 11.34s\n",
" 'quick_restart': 1 [ 39.70s, 39.70s] 39.70s 0.00ns 39.70s 1 [ 6.96s, 6.96s] 6.96s 0.00ns 6.96s\n",
" 'reduced_costs': 1 [ 39.70s, 39.70s] 39.70s 0.00ns 39.70s 1 [ 5.01s, 5.01s] 5.01s 0.00ns 5.01s\n",
" 'rins/rens': 20 [ 6.91ms, 986.44ms] 464.36ms 352.46ms 9.29s 15 [502.69us, 100.05ms] 76.92ms 39.02ms 1.15s\n",
" 'rnd_cst_lns': 14 [ 43.17ms, 1.79s] 608.12ms 470.79ms 8.51s 14 [218.00ns, 100.38ms] 57.13ms 43.78ms 799.75ms\n",
" 'rnd_var_lns': 19 [ 50.22ms, 1.54s] 500.14ms 434.47ms 9.50s 19 [ 10.00ns, 100.38ms] 51.79ms 46.22ms 984.06ms\n",
"\n",
"Search stats Bools Conflicts Branches Restarts BoolPropag IntegerPropag\n",
" 'core': 879 257'245 561'016 23'197 3'894'553 11'353'253\n",
" 'default_lp': 917 746 11'455 5'151 92'425 388'892\n",
" 'fs_random_no_lp': 0 0 0 0 0 0\n",
" 'max_lp': 845 232 10'024 5'178 47'157 208'835\n",
" 'no_lp': 845 141'973 220'207 18'946 9'375'722 31'396'391\n",
" 'quick_restart': 913 156 50'169 25'906 208'162 895'064\n",
" 'reduced_costs': 845 493 30'818 13'878 119'821 580'696\n",
"\n",
"SAT stats ClassicMinim LitRemoved LitLearned LitForgotten Subsumed MClauses MDecisions MLitTrue MSubsumed MLitRemoved MReused\n",
" 'core': 245'640 2'626'066 17'091'805 15'459'542 2'193 7'771 81'762 0 586 8'933 1'598\n",
" 'default_lp': 627 28'164 75'815 0 2 397 3'146 0 6 66 0\n",
" 'fs_random_no_lp': 0 0 0 0 0 0 0 0 0 0 0\n",
" 'max_lp': 231 16'566 58'735 0 0 385 3'035 0 0 1 0\n",
" 'no_lp': 140'290 1'541'792 11'583'785 10'654'747 472 5'605 33'491 0 68 832 6'323\n",
" 'quick_restart': 141 6'293 11'868 0 0 2'771 21'648 0 9 54 30\n",
" 'reduced_costs': 440 16'680 74'961 0 0 1'330 10'500 0 0 0 0\n",
"\n",
"Lp stats Component Iterations AddedCuts OPTIMAL DUAL_F. DUAL_U.\n",
" 'default_lp': 1 71'078 3'542 3'656 0 187\n",
" 'max_lp': 1 37'705 3'257 1'642 87 9\n",
" 'quick_restart': 1 53'163 4'076 1'745 9 7\n",
" 'reduced_costs': 1 55'202 3'582 1'763 194 108\n",
"\n",
"Lp dimension Final dimension of first component\n",
" 'default_lp': 985 rows, 1596 columns, 7217 entries\n",
" 'max_lp': 845 rows, 1690 columns, 6168 entries\n",
" 'quick_restart': 1566 rows, 1596 columns, 17203 entries\n",
" 'reduced_costs': 1420 rows, 1690 columns, 16454 entries\n",
"\n",
"Lp debug CutPropag CutEqPropag Adjust Overflow Bad BadScaling\n",
" 'default_lp': 0 0 3'830 0 6'779 0\n",
" 'max_lp': 0 2 1'738 0 37'489 0\n",
" 'quick_restart': 0 0 1'755 0 17'537 0\n",
" 'reduced_costs': 0 0 2'012 0 21'525 0\n",
"\n",
"Lp pool Constraints Updates Simplif Merged Shortened Split Strenghtened Cuts/Call\n",
" 'default_lp': 6'342 30 0 0 0 22 130 3'542/7'755\n",
" 'max_lp': 6'409 324 0 0 0 467 31 3'257/6'196\n",
" 'quick_restart': 6'876 164 0 0 0 78 115 4'076/8'425\n",
" 'reduced_costs': 6'734 159 0 0 0 102 101 3'582/6'795\n",
"\n",
"Lp Cut default_lp max_lp quick_restart reduced_costs\n",
" CG_FF: 26 10 28 30\n",
" CG_K: 19 9 8 5\n",
" CG_KL: 5 3 1 1\n",
" CG_R: 57 37 44 39\n",
" CG_RB: 91 74 97 102\n",
" CG_RBP: 58 28 57 29\n",
" IB: 1'292 458 1'016 1'061\n",
" MIR_1_FF: 143 141 216 141\n",
" MIR_1_K: 56 11 71 20\n",
" MIR_1_KL: 30 6 37 7\n",
" MIR_1_R: 1 2 4 2\n",
" MIR_1_RB: 76 54 128 87\n",
" MIR_1_RBP: 54 19 99 28\n",
" MIR_2_FF: 147 180 210 200\n",
" MIR_2_K: 54 13 74 37\n",
" MIR_2_KL: 23 2 23 5\n",
" MIR_2_R: 9 8 10 9\n",
" MIR_2_RB: 130 176 178 160\n",
" MIR_2_RBP: 71 35 109 63\n",
" MIR_3_FF: 117 196 121 138\n",
" MIR_3_K: 63 30 77 31\n",
" MIR_3_KL: 20 - 17 4\n",
" MIR_3_R: 3 12 7 12\n",
" MIR_3_RB: 118 181 107 155\n",
" MIR_3_RBP: 63 57 92 59\n",
" MIR_4_FF: 66 157 84 104\n",
" MIR_4_K: 39 39 65 27\n",
" MIR_4_KL: 7 - 6 3\n",
" MIR_4_R: 6 16 6 13\n",
" MIR_4_RB: 73 149 65 125\n",
" MIR_4_RBP: 31 52 55 44\n",
" MIR_5_FF: 41 117 54 58\n",
" MIR_5_K: 34 27 41 22\n",
" MIR_5_KL: 4 3 4 2\n",
" MIR_5_R: 6 17 7 5\n",
" MIR_5_RB: 43 106 35 67\n",
" MIR_5_RBP: 24 37 29 16\n",
" MIR_6_FF: 21 88 28 38\n",
" MIR_6_K: 23 23 31 26\n",
" MIR_6_KL: 3 18 4 17\n",
" MIR_6_R: 1 7 1 3\n",
" MIR_6_RB: 15 52 22 37\n",
" MIR_6_RBP: 12 34 31 22\n",
" ZERO_HALF_FF: 43 13 32 21\n",
" ZERO_HALF_K: 14 3 8 7\n",
" ZERO_HALF_KL: 4 - 1 -\n",
" ZERO_HALF_R: 235 462 492 398\n",
" ZERO_HALF_RB: 52 81 99 79\n",
" ZERO_HALF_RBP: 19 14 45 23\n",
"\n",
"LNS stats Improv/Calls Closed Difficulty TimeLimit\n",
" 'graph_arc_lns': 3/19 47% 3.71e-01 0.10\n",
" 'graph_cst_lns': 1/18 50% 6.02e-01 0.10\n",
" 'graph_dec_lns': 1/16 50% 7.15e-01 0.10\n",
" 'graph_var_lns': 0/19 47% 5.28e-01 0.10\n",
" 'rins/rens': 18/20 50% 4.46e-01 0.10\n",
" 'rnd_cst_lns': 0/14 50% 6.75e-01 0.10\n",
" 'rnd_var_lns': 1/19 53% 7.53e-01 0.10\n",
"\n",
"LS stats Batches Restarts/Perturbs LinMoves GenMoves CompoundMoves Bactracks WeightUpdates ScoreComputed\n",
" 'ls_restart': 4 4 54'233 0 0 0 8'041 1'941'189\n",
" 'ls_restart_compound': 2 2 0 34'966 2'229 16'363 255 896'324\n",
" 'ls_restart_compound_perturb': 3 3 0 48'212 5'170 21'518 258 1'330'743\n",
" 'ls_restart_decay': 5 5 76'714 0 0 0 1'363 1'721'999\n",
" 'ls_restart_decay_compound': 1 1 0 12'866 2'777 5'038 35 442'133\n",
" 'ls_restart_decay_compound_perturb': 4 4 0 50'936 8'829 21'046 155 1'528'352\n",
" 'ls_restart_decay_perturb': 1 1 15'790 0 0 0 302 356'329\n",
" 'ls_restart_perturb': 2 2 25'490 0 0 0 3'219 954'995\n",
"\n",
"Solutions (8) Num Rank\n",
" 'complete_hint': 1 [1,1]\n",
" 'graph_arc_lns': 3 [2,8]\n",
" 'rins_lp_lns': 3 [3,5]\n",
" 'rins_pump_lns': 1 [7,7]\n",
"\n",
"Objective bounds Num\n",
" 'default_lp': 1\n",
" 'initial_domain': 1\n",
" 'max_lp': 12\n",
" 'quick_restart': 3\n",
" 'reduced_costs': 3\n",
"\n",
"Solution repositories Added Queried Synchro\n",
" 'feasible solutions': 16 293 14\n",
" 'fj solution hints': 0 0 0\n",
" 'lp solutions': 85 10 80\n",
" 'pump': 200 10\n",
"\n",
"[Scaling] scaled_objective_bound: 228785 corrected_bound: 228785 delta: -1.01182e-06\n",
"CpSolverResponse summary:\n",
"status: FEASIBLE\n",
"objective: 240847.587817601\n",
"best_bound: 228785.3590527162\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: 40.071\n",
"usertime: 40.071\n",
"deterministic_time: 56.5917\n",
"gap_integral: 532.551\n",
"solution_fingerprint: 0xfca1d0f2a1c38f02\n",
"\n"
]
},
{
"data": {
"text/plain": [
"SolutionInfo(runtime=40.070975000000004, bound=228785.35905271623, objective=240847.58781760104, relgap=0.05008241466806718, termination='FEASIBLE')"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# required to get the log inside the notebook (goes only to console otherwise)\n",
"solver.solver.log_callback = print\n",
"\n",
"solver.solve(\n",
" time_limit=40,\n",
" mip_gap=0.005,\n",
" verbose=True,\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "e7c0090b-01ca-4467-82eb-c1bab65fb6cb",
"metadata": {},
"outputs": [],
"source": [
"S, G = solver.get_solution()"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "4fc458e5-1a5f-4f26-9344-64fdeff731f2",
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
""
],
"text/plain": [
""
]
},
"execution_count": 20,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"svgplot(G)"
]
}
],
"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
}