mirror of
https://github.com/ANL-CEEESA/MIPLearn.git
synced 2025-12-06 01:18:52 -06:00
Minor fixes to docs and setup.py
This commit is contained in:
@@ -33,6 +33,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"attachments": {},
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "02f0a927",
|
"id": "02f0a927",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
@@ -44,53 +45,17 @@
|
|||||||
"- Python version, compatible with the Pyomo and Gurobipy modeling languages,\n",
|
"- Python version, compatible with the Pyomo and Gurobipy modeling languages,\n",
|
||||||
"- Julia version, compatible with the JuMP modeling language.\n",
|
"- Julia version, compatible with the JuMP modeling language.\n",
|
||||||
"\n",
|
"\n",
|
||||||
"In this tutorial, we will demonstrate how to use and install the Python/Gurobipy version of the package. The first step is to install Python 3.8+ in your computer. See the [official Python website for more instructions](https://www.python.org/downloads/). After Python is installed, we proceed to install MIPLearn using `pip`:"
|
"In this tutorial, we will demonstrate how to use and install the Python/Gurobipy version of the package. The first step is to install Python 3.8+ in your computer. See the [official Python website for more instructions](https://www.python.org/downloads/). After Python is installed, we proceed to install MIPLearn using `pip`:\n",
|
||||||
]
|
"\n",
|
||||||
},
|
"```\n",
|
||||||
{
|
"$ pip install MIPLearn==0.3\n",
|
||||||
"cell_type": "code",
|
"```\n",
|
||||||
"execution_count": 1,
|
"\n",
|
||||||
"id": "cd8a69c1",
|
"In addition to MIPLearn itself, we will also install Gurobi 10.0, a state-of-the-art commercial MILP solver. This step also install a demo license for Gurobi, which should able to solve the small optimization problems in this tutorial. A license is required for solving larger-scale problems.\n",
|
||||||
"metadata": {
|
"\n",
|
||||||
"ExecuteTime": {
|
"```\n",
|
||||||
"end_time": "2023-06-06T20:18:02.381829278Z",
|
"$ pip install 'gurobipy>=10,<10.1'\n",
|
||||||
"start_time": "2023-06-06T20:18:02.381532300Z"
|
"```"
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"# !pip install MIPLearn==0.3.0"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "markdown",
|
|
||||||
"id": "e8274543",
|
|
||||||
"metadata": {},
|
|
||||||
"source": [
|
|
||||||
"In addition to MIPLearn itself, we will also install Gurobi 10.0, a state-of-the-art commercial MILP solver. This step also install a demo license for Gurobi, which should able to solve the small optimization problems in this tutorial. A license is required for solving larger-scale problems."
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 2,
|
|
||||||
"id": "dcc8756c",
|
|
||||||
"metadata": {
|
|
||||||
"ExecuteTime": {
|
|
||||||
"end_time": "2023-06-06T20:18:15.537811992Z",
|
|
||||||
"start_time": "2023-06-06T20:18:13.449177860Z"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"Requirement already satisfied: gurobipy<10.1,>=10 in /home/axavier/Software/anaconda3/envs/miplearn/lib/python3.8/site-packages (10.0.1)\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"!pip install 'gurobipy>=10,<10.1'"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -214,6 +179,7 @@
|
|||||||
"from miplearn.io import read_pkl_gz\n",
|
"from miplearn.io import read_pkl_gz\n",
|
||||||
"from miplearn.solvers.gurobi import GurobiModel\n",
|
"from miplearn.solvers.gurobi import GurobiModel\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
"\n",
|
||||||
"def build_uc_model(data: Union[str, UnitCommitmentData]) -> GurobiModel:\n",
|
"def build_uc_model(data: Union[str, UnitCommitmentData]) -> GurobiModel:\n",
|
||||||
" if isinstance(data, str):\n",
|
" if isinstance(data, str):\n",
|
||||||
" data = read_pkl_gz(data)\n",
|
" data = read_pkl_gz(data)\n",
|
||||||
@@ -223,9 +189,7 @@
|
|||||||
" x = model._x = model.addVars(n, vtype=GRB.BINARY, name=\"x\")\n",
|
" x = model._x = model.addVars(n, vtype=GRB.BINARY, name=\"x\")\n",
|
||||||
" y = model._y = model.addVars(n, name=\"y\")\n",
|
" y = model._y = model.addVars(n, name=\"y\")\n",
|
||||||
" model.setObjective(\n",
|
" model.setObjective(\n",
|
||||||
" quicksum(\n",
|
" quicksum(data.cfix[i] * x[i] + data.cvar[i] * y[i] for i in range(n))\n",
|
||||||
" data.cfix[i] * x[i] + data.cvar[i] * y[i] for i in range(n)\n",
|
|
||||||
" )\n",
|
|
||||||
" )\n",
|
" )\n",
|
||||||
" model.addConstrs(y[i] <= data.pmax[i] * x[i] for i in range(n))\n",
|
" model.addConstrs(y[i] <= data.pmax[i] * x[i] for i in range(n))\n",
|
||||||
" model.addConstrs(y[i] >= data.pmin[i] * x[i] for i in range(n))\n",
|
" model.addConstrs(y[i] >= data.pmin[i] * x[i] for i in range(n))\n",
|
||||||
@@ -588,7 +552,7 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"solver_ml = LearningSolver(components=[comp])\n",
|
"solver_ml = LearningSolver(components=[comp])\n",
|
||||||
"solver_ml.fit(train_data)\n",
|
"solver_ml.fit(train_data)\n",
|
||||||
"solver_ml.optimize(test_data[0], build_uc_model);"
|
"solver_ml.optimize(test_data[0], build_uc_model)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -690,7 +654,7 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"solver_baseline = LearningSolver(components=[])\n",
|
"solver_baseline = LearningSolver(components=[])\n",
|
||||||
"solver_baseline.fit(train_data)\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)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"attachments": {},
|
||||||
"cell_type": "markdown",
|
"cell_type": "markdown",
|
||||||
"id": "02f0a927",
|
"id": "02f0a927",
|
||||||
"metadata": {},
|
"metadata": {},
|
||||||
@@ -44,53 +45,17 @@
|
|||||||
"- Python version, compatible with the Pyomo and Gurobipy modeling languages,\n",
|
"- Python version, compatible with the Pyomo and Gurobipy modeling languages,\n",
|
||||||
"- Julia version, compatible with the JuMP modeling language.\n",
|
"- Julia version, compatible with the JuMP modeling language.\n",
|
||||||
"\n",
|
"\n",
|
||||||
"In this tutorial, we will demonstrate how to use and install the Python/Pyomo version of the package. The first step is to install Python 3.8+ in your computer. See the [official Python website for more instructions](https://www.python.org/downloads/). After Python is installed, we proceed to install MIPLearn using `pip`:"
|
"In this tutorial, we will demonstrate how to use and install the Python/Pyomo version of the package. The first step is to install Python 3.8+ in your computer. See the [official Python website for more instructions](https://www.python.org/downloads/). After Python is installed, we proceed to install MIPLearn using `pip`:\n",
|
||||||
]
|
"\n",
|
||||||
},
|
"```\n",
|
||||||
{
|
"$ pip install MIPLearn==0.3\n",
|
||||||
"cell_type": "code",
|
"```\n",
|
||||||
"execution_count": 1,
|
"\n",
|
||||||
"id": "cd8a69c1",
|
"In addition to MIPLearn itself, we will also install Gurobi 10.0, a state-of-the-art commercial MILP solver. This step also install a demo license for Gurobi, which should able to solve the small optimization problems in this tutorial. A license is required for solving larger-scale problems.\n",
|
||||||
"metadata": {
|
"\n",
|
||||||
"ExecuteTime": {
|
"```\n",
|
||||||
"end_time": "2023-06-06T19:57:33.202580815Z",
|
"$ pip install 'gurobipy>=10,<10.1'\n",
|
||||||
"start_time": "2023-06-06T19:57:33.198341886Z"
|
"```"
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": [],
|
|
||||||
"source": [
|
|
||||||
"# !pip install MIPLearn==0.3.0"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "markdown",
|
|
||||||
"id": "e8274543",
|
|
||||||
"metadata": {},
|
|
||||||
"source": [
|
|
||||||
"In addition to MIPLearn itself, we will also install Gurobi 10.0, a state-of-the-art commercial MILP solver. This step also install a demo license for Gurobi, which should able to solve the small optimization problems in this tutorial. A license is required for solving larger-scale problems."
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"execution_count": 2,
|
|
||||||
"id": "dcc8756c",
|
|
||||||
"metadata": {
|
|
||||||
"ExecuteTime": {
|
|
||||||
"end_time": "2023-06-06T19:57:35.756831801Z",
|
|
||||||
"start_time": "2023-06-06T19:57:33.201767088Z"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"name": "stdout",
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"Requirement already satisfied: gurobipy<10.1,>=10 in /home/axavier/Software/anaconda3/envs/miplearn/lib/python3.8/site-packages (10.0.1)\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"source": [
|
|
||||||
"!pip install 'gurobipy>=10,<10.1'"
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -600,7 +565,7 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"solver_ml = LearningSolver(components=[comp])\n",
|
"solver_ml = LearningSolver(components=[comp])\n",
|
||||||
"solver_ml.fit(train_data)\n",
|
"solver_ml.fit(train_data)\n",
|
||||||
"solver_ml.optimize(test_data[0], build_uc_model);"
|
"solver_ml.optimize(test_data[0], build_uc_model)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -706,7 +671,7 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"solver_baseline = LearningSolver(components=[])\n",
|
"solver_baseline = LearningSolver(components=[])\n",
|
||||||
"solver_baseline.fit(train_data)\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)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
2
setup.py
2
setup.py
@@ -6,7 +6,7 @@ from setuptools import setup, find_namespace_packages
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="miplearn",
|
name="miplearn",
|
||||||
version="0.3.0.dev1",
|
version="0.3.0",
|
||||||
author="Alinson S. Xavier",
|
author="Alinson S. Xavier",
|
||||||
author_email="axavier@anl.gov",
|
author_email="axavier@anl.gov",
|
||||||
description="Extensible Framework for Learning-Enhanced Mixed-Integer Optimization",
|
description="Extensible Framework for Learning-Enhanced Mixed-Integer Optimization",
|
||||||
|
|||||||
Reference in New Issue
Block a user