mirror of
https://github.com/ANL-CEEESA/MIPLearn.git
synced 2025-12-06 17:38:51 -06:00
Docs: update benchmarks
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "546635ee",
|
||||
"id": "b54271ba",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Getting started with MIPLearn\n",
|
||||
@@ -32,7 +32,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "8b97258c",
|
||||
"id": "6135092d",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Installation\n",
|
||||
@@ -48,7 +48,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 1,
|
||||
"id": "2dbeacbc",
|
||||
"id": "c549d632",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -71,7 +71,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "b2f449e7",
|
||||
"id": "bc99f8c1",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"In addition to MIPLearn itself, we will also install a few other packages that are required for this tutorial:\n",
|
||||
@@ -85,7 +85,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 2,
|
||||
"id": "68f99568",
|
||||
"id": "d068ed52",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -110,7 +110,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "51e09fc9",
|
||||
"id": "9689bce5",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"<div class=\"alert alert-info\">\n",
|
||||
@@ -124,7 +124,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "18c300c4",
|
||||
"id": "9801f40d",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Modeling a simple optimization problem\n",
|
||||
@@ -160,7 +160,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 3,
|
||||
"id": "b12d6483",
|
||||
"id": "8ae84f9d",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -175,7 +175,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "55cdb64b",
|
||||
"id": "3d59466c",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Next, we create a function that converts this data structure into a concrete JuMP model. For more details on the JuMP syntax, see [the official JuMP documentation](https://jump.dev/JuMP.jl/stable/)."
|
||||
@@ -184,7 +184,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 4,
|
||||
"id": "1e38a266",
|
||||
"id": "e07e3633",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -213,7 +213,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "d28c4d5a",
|
||||
"id": "6e92b1d8",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"At this point, we can already use JuMP and any mixed-integer linear programming solver to find optimal solutions to any instance of this problem. To illustrate this, let us solve a small instance with three generators, using SCIP:"
|
||||
@@ -222,7 +222,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 5,
|
||||
"id": "9ff9f05c",
|
||||
"id": "e2b828da",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -260,7 +260,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "345de591",
|
||||
"id": "92e27701",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Running the code above, we found that the optimal solution for our small problem instance costs \\$1320. It is achieve by keeping generators 2 and 3 online and producing, respectively, 60 MW and 40 MW of power."
|
||||
@@ -268,7 +268,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "eb8904ef",
|
||||
"id": "06e538e5",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Generating training data\n",
|
||||
@@ -283,7 +283,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 6,
|
||||
"id": "7298bb0d",
|
||||
"id": "859e0e29",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -311,7 +311,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "c1feed43",
|
||||
"id": "92cb1931",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"In this example, for simplicity, only the demands change from one instance to the next. We could also have made the prices and the production limits random. The more randomization we have in the training data, however, the more challenging it is for the machine learning models to learn solution patterns.\n",
|
||||
@@ -322,7 +322,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 7,
|
||||
"id": "61d43994",
|
||||
"id": "cf7d09ba",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -333,7 +333,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "3fdeb8cd",
|
||||
"id": "8a03a93d",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Next, we write these data structures to individual files. MIPLearn uses files during the training process because, for large-scale optimization problems, it is often impractical to hold the entire training data, as well as the concrete JuMP models, in memory. Files also make it much easier to solve multiple instances simultaneously, potentially even on multiple machines. We will cover parallel and distributed computing in a future tutorial.\n",
|
||||
@@ -344,7 +344,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 8,
|
||||
"id": "31b48701",
|
||||
"id": "2433ed6f",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
@@ -359,7 +359,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "5cecea59",
|
||||
"id": "de0861c2",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Finally, we use `MIPLearn.LearningSolver` and `MIPLearn.solve!` to solve all the training instances. `LearningSolver` is the main component provided by MIPLearn, which integrates MIP solvers and ML. The `solve!` function can be used to solve either one or multiple instances, and requires: (i) the list of files containing the training data; and (ii) the function that converts the data structure into a concrete JuMP model:"
|
||||
@@ -368,7 +368,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 9,
|
||||
"id": "60732af0",
|
||||
"id": "bd7432e7",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -394,7 +394,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "bbc7ad82",
|
||||
"id": "ee2a0bac",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"The macro `@time` shows us how long did the code take to run. We can see that SCIP was able to solve all training instances in about 2 minutes. The solutions, and other useful training data, are stored by MIPLearn in `.h5` files, stored side-by-side with the original `.jld2` files."
|
||||
@@ -402,7 +402,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "73379180",
|
||||
"id": "f14f08f3",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Solving new instances\n",
|
||||
@@ -413,7 +413,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 10,
|
||||
"id": "e045d644",
|
||||
"id": "fd8161d0",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -432,7 +432,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "d8de7b26",
|
||||
"id": "cf0ed97d",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"The trained MIP solver was able to solve all test instances in about 6 seconds. To see that ML is being helpful here, let us repeat the code above, but remove the `fit!` line:"
|
||||
@@ -441,7 +441,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"id": "cf2a989e",
|
||||
"id": "d0812fbf",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -459,7 +459,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "e100b25d",
|
||||
"id": "ca64c7ca",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Without the help of the ML models, SCIP took around 10 seconds to solve the same test instances.\n",
|
||||
@@ -473,7 +473,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "af451e87",
|
||||
"id": "a80dc6a5",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Understanding the acceleration\n",
|
||||
@@ -484,7 +484,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 12,
|
||||
"id": "0c675452",
|
||||
"id": "e5ec48e6",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -553,7 +553,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "ff0b6858",
|
||||
"id": "714805e0",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"The log above is quite complicated if you have never seen it before, but the important line is the one starting with `feasible solution found [...] objective value 1.705169e+07`. This line indicates that MIPLearn was able to construct a warm start with value `1.705169e+07`. Using this warm start, SCIP then used the branch-and-cut method to either prove its optimality or to find an even better solution. Very quickly, however, SCIP proved that the solution produced by MIPLearn was indeed optimal. It was able to do this without generating a single cutting plane or running any other heuristics; it could tell the optimality by the root LP relaxation alone, which was very fast. \n",
|
||||
@@ -564,7 +564,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 13,
|
||||
"id": "1aa9230e",
|
||||
"id": "7f1da1e6",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -650,7 +650,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "9417bb85",
|
||||
"id": "033da453",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"In this log file, notice how the previous line about warm starts is missing. Since no warm starts were provided, SCIP had to find an initial solution using its own internal heuristics, which are not specifically tailored for this problem. The initial solution found by SCIP's heuristics has value `2.335200e+07`, which is significantly worse than the one constructed by MIPLearn. SCIP then proceeded to improve this solution, by generating cutting planes and repeatedly running additional primal heuristics. In the end, it was able to find the optimal solution, as expected, but it took longer.\n",
|
||||
@@ -660,7 +660,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "ab9c1ff4",
|
||||
"id": "76510d4a",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Accessing the solution\n",
|
||||
@@ -673,7 +673,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 14,
|
||||
"id": "79759e87",
|
||||
"id": "49fe62d5",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
@@ -705,7 +705,7 @@
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "b096dcf9",
|
||||
"id": "9414f027",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"We can then solve this model as before, with `MIPLearn.solve!`:"
|
||||
@@ -714,7 +714,7 @@
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 15,
|
||||
"id": "1b668c12",
|
||||
"id": "4b15a28d",
|
||||
"metadata": {},
|
||||
"outputs": [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user