From 52ed34784d37022af3fef01c7f5c0b3049f3369c Mon Sep 17 00:00:00 2001 From: "Alinson S. Xavier" Date: Wed, 8 May 2024 09:19:52 -0500 Subject: [PATCH] Docs: Use single-thread example --- docs/tutorials/getting-started-gurobipy.ipynb | 121 +++++++++--------- 1 file changed, 62 insertions(+), 59 deletions(-) diff --git a/docs/tutorials/getting-started-gurobipy.ipynb b/docs/tutorials/getting-started-gurobipy.ipynb index e9e7648..62e5f2c 100644 --- a/docs/tutorials/getting-started-gurobipy.ipynb +++ b/docs/tutorials/getting-started-gurobipy.ipynb @@ -220,11 +220,12 @@ "name": "stdout", "output_type": "stream", "text": [ + "Set parameter Threads to value 1\n", "Restricted license - for non-production use only - expires 2024-10-28\n", "Gurobi Optimizer version 10.0.3 build v10.0.3rc0 (linux64)\n", "\n", "CPU model: 13th Gen Intel(R) Core(TM) i7-13800H, instruction set [SSE2|AVX|AVX2]\n", - "Thread count: 10 physical cores, 20 logical processors, using up to 20 threads\n", + "Thread count: 10 physical cores, 20 logical processors, using up to 1 threads\n", "\n", "Optimize a model with 7 rows, 6 columns and 15 nonzeros\n", "Model fingerprint: 0x58dfdd53\n", @@ -250,12 +251,14 @@ "* 0 0 0 1320.0000000 1320.00000 0.00% - 0s\n", "\n", "Explored 1 nodes (5 simplex iterations) in 0.01 seconds (0.00 work units)\n", - "Thread count was 20 (of 20 available processors)\n", + "Thread count was 1 (of 20 available processors)\n", "\n", "Solution count 2: 1320 1400 \n", "\n", "Optimal solution found (tolerance 1.00e-04)\n", "Best objective 1.320000000000e+03, best bound 1.320000000000e+03, gap 0.0000%\n", + "\n", + "User-callback calls 371, time in user-callback 0.00 sec\n", "obj = 1320.0\n", "x = [-0.0, 1.0, 1.0]\n", "y = [0.0, 60.0, 40.0]\n" @@ -401,7 +404,7 @@ "from miplearn.collectors.basic import BasicCollector\n", "\n", "bc = BasicCollector()\n", - "bc.collect(train_data, build_uc_model, n_jobs=4)" + "bc.collect(train_data, build_uc_model)" ] }, { @@ -483,7 +486,7 @@ "Gurobi Optimizer version 10.0.3 build v10.0.3rc0 (linux64)\n", "\n", "CPU model: 13th Gen Intel(R) Core(TM) i7-13800H, instruction set [SSE2|AVX|AVX2]\n", - "Thread count: 10 physical cores, 20 logical processors, using up to 20 threads\n", + "Thread count: 10 physical cores, 20 logical processors, using up to 1 threads\n", "\n", "Optimize a model with 1001 rows, 1000 columns and 2500 nonzeros\n", "Model fingerprint: 0xa8b70287\n", @@ -493,22 +496,24 @@ " Bounds range [1e+00, 1e+00]\n", " RHS range [3e+08, 3e+08]\n", "Presolve removed 1000 rows and 500 columns\n", - "Presolve time: 0.01s\n", + "Presolve time: 0.00s\n", "Presolved: 1 rows, 500 columns, 500 nonzeros\n", "\n", "Iteration Objective Primal Inf. Dual Inf. Time\n", " 0 6.6166537e+09 5.648803e+04 0.000000e+00 0s\n", " 1 8.2906219e+09 0.000000e+00 0.000000e+00 0s\n", "\n", - "Solved in 1 iterations and 0.01 seconds (0.00 work units)\n", + "Solved in 1 iterations and 0.00 seconds (0.00 work units)\n", "Optimal objective 8.290621916e+09\n", + "\n", + "User-callback calls 56, time in user-callback 0.00 sec\n", "Gurobi Optimizer version 10.0.3 build v10.0.3rc0 (linux64)\n", "\n", "CPU model: 13th Gen Intel(R) Core(TM) i7-13800H, instruction set [SSE2|AVX|AVX2]\n", - "Thread count: 10 physical cores, 20 logical processors, using up to 20 threads\n", + "Thread count: 10 physical cores, 20 logical processors, using up to 1 threads\n", "\n", "Optimize a model with 1001 rows, 1000 columns and 2500 nonzeros\n", - "Model fingerprint: 0xcf27855a\n", + "Model fingerprint: 0x892e56b2\n", "Variable types: 500 continuous, 500 integer (500 binary)\n", "Coefficient statistics:\n", " Matrix range [1e+00, 2e+06]\n", @@ -538,19 +543,21 @@ " Gomory: 1\n", " Flow cover: 2\n", "\n", - "Explored 1 nodes (565 simplex iterations) in 0.03 seconds (0.01 work units)\n", - "Thread count was 20 (of 20 available processors)\n", + "Explored 1 nodes (565 simplex iterations) in 0.02 seconds (0.01 work units)\n", + "Thread count was 1 (of 20 available processors)\n", "\n", "Solution count 1: 8.29153e+09 \n", "\n", "Optimal solution found (tolerance 1.00e-04)\n", - "Best objective 8.291528276179e+09, best bound 8.290733258025e+09, gap 0.0096%\n" + "Best objective 8.291528276179e+09, best bound 8.290733258025e+09, gap 0.0096%\n", + "\n", + "User-callback calls 193, time in user-callback 0.00 sec\n" ] }, { "data": { "text/plain": [ - "{'WS: Count': 1, 'WS: Number of variables set': 482.0}" + "{'WS: Count': 1, 'WS: Number of variables set': 477.0}" ] }, "execution_count": 8, @@ -592,7 +599,7 @@ "Gurobi Optimizer version 10.0.3 build v10.0.3rc0 (linux64)\n", "\n", "CPU model: 13th Gen Intel(R) Core(TM) i7-13800H, instruction set [SSE2|AVX|AVX2]\n", - "Thread count: 10 physical cores, 20 logical processors, using up to 20 threads\n", + "Thread count: 10 physical cores, 20 logical processors, using up to 1 threads\n", "\n", "Optimize a model with 1001 rows, 1000 columns and 2500 nonzeros\n", "Model fingerprint: 0xa8b70287\n", @@ -611,10 +618,12 @@ "\n", "Solved in 1 iterations and 0.01 seconds (0.00 work units)\n", "Optimal objective 8.290621916e+09\n", + "\n", + "User-callback calls 56, time in user-callback 0.00 sec\n", "Gurobi Optimizer version 10.0.3 build v10.0.3rc0 (linux64)\n", "\n", "CPU model: 13th Gen Intel(R) Core(TM) i7-13800H, instruction set [SSE2|AVX|AVX2]\n", - "Thread count: 10 physical cores, 20 logical processors, using up to 20 threads\n", + "Thread count: 10 physical cores, 20 logical processors, using up to 1 threads\n", "\n", "Optimize a model with 1001 rows, 1000 columns and 2500 nonzeros\n", "Model fingerprint: 0x4cbbf7c7\n", @@ -643,39 +652,36 @@ " 0 0 8.2907e+09 0 5 8.2940e+09 8.2907e+09 0.04% - 0s\n", " 0 0 8.2907e+09 0 1 8.2940e+09 8.2907e+09 0.04% - 0s\n", " 0 0 8.2907e+09 0 2 8.2940e+09 8.2907e+09 0.04% - 0s\n", - " 0 0 8.2908e+09 0 1 8.2940e+09 8.2908e+09 0.04% - 0s\n", - " 0 0 8.2908e+09 0 4 8.2940e+09 8.2908e+09 0.04% - 0s\n", - " 0 0 8.2908e+09 0 4 8.2940e+09 8.2908e+09 0.04% - 0s\n", - "H 0 0 8.291465e+09 8.2908e+09 0.01% - 0s\n", + " 0 0 8.2907e+09 0 2 8.2940e+09 8.2907e+09 0.04% - 0s\n", + " 0 2 8.2908e+09 0 2 8.2940e+09 8.2908e+09 0.04% - 0s\n", + "H 9 9 8.292131e+09 8.2908e+09 0.02% 1.0 0s\n", + "H 132 88 8.292121e+09 8.2908e+09 0.02% 2.0 0s\n", + "* 133 88 28 8.292121e+09 8.2908e+09 0.02% 2.2 0s\n", + "H 216 136 8.291918e+09 8.2909e+09 0.01% 2.4 0s\n", + "* 232 136 28 8.291664e+09 8.2909e+09 0.01% 2.4 0s\n", "\n", "Cutting planes:\n", " Gomory: 2\n", + " Cover: 1\n", " MIR: 1\n", + " Inf proof: 3\n", "\n", - "Explored 1 nodes (1031 simplex iterations) in 0.15 seconds (0.03 work units)\n", - "Thread count was 20 (of 20 available processors)\n", + "Explored 233 nodes (1577 simplex iterations) in 0.09 seconds (0.06 work units)\n", + "Thread count was 1 (of 20 available processors)\n", "\n", - "Solution count 4: 8.29147e+09 8.29398e+09 8.29827e+09 9.75713e+09 \n", + "Solution count 7: 8.29166e+09 8.29192e+09 8.29212e+09 ... 9.75713e+09\n", "\n", "Optimal solution found (tolerance 1.00e-04)\n", - "Best objective 8.291465302389e+09, best bound 8.290781665333e+09, gap 0.0082%\n" + "Best objective 8.291663722826e+09, best bound 8.290885027548e+09, gap 0.0094%\n", + "\n", + "User-callback calls 708, time in user-callback 0.00 sec\n" ] - }, - { - "data": { - "text/plain": [ - "{}" - ] - }, - "execution_count": 9, - "metadata": {}, - "output_type": "execute_result" } ], "source": [ "solver_baseline = LearningSolver(components=[])\n", "solver_baseline.fit(train_data)\n", - "solver_baseline.optimize(test_data[0], build_uc_model)" + "solver_baseline.optimize(test_data[0], build_uc_model);" ] }, { @@ -716,7 +722,7 @@ "Gurobi Optimizer version 10.0.3 build v10.0.3rc0 (linux64)\n", "\n", "CPU model: 13th Gen Intel(R) Core(TM) i7-13800H, instruction set [SSE2|AVX|AVX2]\n", - "Thread count: 10 physical cores, 20 logical processors, using up to 20 threads\n", + "Thread count: 10 physical cores, 20 logical processors, using up to 1 threads\n", "\n", "Optimize a model with 1001 rows, 1000 columns and 2500 nonzeros\n", "Model fingerprint: 0x19042f12\n", @@ -735,13 +741,15 @@ "\n", "Solved in 1 iterations and 0.01 seconds (0.00 work units)\n", "Optimal objective 8.253596777e+09\n", + "\n", + "User-callback calls 56, time in user-callback 0.00 sec\n", "Gurobi Optimizer version 10.0.3 build v10.0.3rc0 (linux64)\n", "\n", "CPU model: 13th Gen Intel(R) Core(TM) i7-13800H, instruction set [SSE2|AVX|AVX2]\n", - "Thread count: 10 physical cores, 20 logical processors, using up to 20 threads\n", + "Thread count: 10 physical cores, 20 logical processors, using up to 1 threads\n", "\n", "Optimize a model with 1001 rows, 1000 columns and 2500 nonzeros\n", - "Model fingerprint: 0xf97cde91\n", + "Model fingerprint: 0x6926c32f\n", "Variable types: 500 continuous, 500 integer (500 binary)\n", "Coefficient statistics:\n", " Matrix range [1e+00, 2e+06]\n", @@ -749,14 +757,15 @@ " Bounds range [1e+00, 1e+00]\n", " RHS range [3e+08, 3e+08]\n", "\n", - "User MIP start produced solution with objective 8.25814e+09 (0.00s)\n", + "User MIP start produced solution with objective 8.25814e+09 (0.01s)\n", "User MIP start produced solution with objective 8.25512e+09 (0.01s)\n", - "User MIP start produced solution with objective 8.25483e+09 (0.01s)\n", - "User MIP start produced solution with objective 8.25483e+09 (0.01s)\n", - "User MIP start produced solution with objective 8.25483e+09 (0.01s)\n", - "User MIP start produced solution with objective 8.25459e+09 (0.01s)\n", - "User MIP start produced solution with objective 8.25459e+09 (0.01s)\n", - "Loaded user MIP start with objective 8.25459e+09\n", + "User MIP start produced solution with objective 8.2551e+09 (0.01s)\n", + "User MIP start produced solution with objective 8.25508e+09 (0.01s)\n", + "User MIP start produced solution with objective 8.25508e+09 (0.01s)\n", + "User MIP start produced solution with objective 8.25499e+09 (0.01s)\n", + "User MIP start produced solution with objective 8.25448e+09 (0.02s)\n", + "User MIP start produced solution with objective 8.25448e+09 (0.02s)\n", + "Loaded user MIP start with objective 8.25448e+09\n", "\n", "Presolve time: 0.00s\n", "Presolved: 1001 rows, 1000 columns, 2500 nonzeros\n", @@ -767,29 +776,23 @@ " Nodes | Current Node | Objective Bounds | Work\n", " Expl Unexpl | Obj Depth IntInf | Incumbent BestBd Gap | It/Node Time\n", "\n", - " 0 0 8.2536e+09 0 1 8.2546e+09 8.2536e+09 0.01% - 0s\n", - " 0 0 8.2537e+09 0 3 8.2546e+09 8.2537e+09 0.01% - 0s\n", - " 0 0 8.2537e+09 0 1 8.2546e+09 8.2537e+09 0.01% - 0s\n", - " 0 0 8.2537e+09 0 4 8.2546e+09 8.2537e+09 0.01% - 0s\n", - " 0 0 8.2537e+09 0 4 8.2546e+09 8.2537e+09 0.01% - 0s\n", - " 0 0 8.2538e+09 0 4 8.2546e+09 8.2538e+09 0.01% - 0s\n", - " 0 0 8.2538e+09 0 5 8.2546e+09 8.2538e+09 0.01% - 0s\n", - " 0 0 8.2538e+09 0 6 8.2546e+09 8.2538e+09 0.01% - 0s\n", + " 0 0 8.2536e+09 0 1 8.2545e+09 8.2536e+09 0.01% - 0s\n", + " 0 0 8.2537e+09 0 3 8.2545e+09 8.2537e+09 0.01% - 0s\n", "\n", "Cutting planes:\n", " Cover: 1\n", - " MIR: 2\n", - " StrongCG: 1\n", - " Flow cover: 1\n", + " Flow cover: 2\n", "\n", - "Explored 1 nodes (575 simplex iterations) in 0.05 seconds (0.01 work units)\n", - "Thread count was 20 (of 20 available processors)\n", + "Explored 1 nodes (515 simplex iterations) in 0.03 seconds (0.02 work units)\n", + "Thread count was 1 (of 20 available processors)\n", "\n", - "Solution count 4: 8.25459e+09 8.25483e+09 8.25512e+09 8.25814e+09 \n", + "Solution count 6: 8.25448e+09 8.25499e+09 8.25508e+09 ... 8.25814e+09\n", "\n", "Optimal solution found (tolerance 1.00e-04)\n", - "Best objective 8.254590409970e+09, best bound 8.253768093811e+09, gap 0.0100%\n", - "obj = 8254590409.969726\n", + "Best objective 8.254479145594e+09, best bound 8.253689731796e+09, gap 0.0096%\n", + "\n", + "User-callback calls 203, time in user-callback 0.00 sec\n", + "obj = 8254479145.594168\n", "x = [1.0, 1.0, 0.0]\n", "y = [935662.0949262811, 1604270.0218116897, 0.0]\n" ]