From 8dd5bb416b151c8b8fa816ccacbac2d7442a8ea6 Mon Sep 17 00:00:00 2001 From: "Alinson S. Xavier" Date: Thu, 8 Jun 2023 12:37:11 -0500 Subject: [PATCH] Minor fixes to docs and setup.py --- docs/tutorials/getting-started-gurobipy.ipynb | 68 +++++-------------- docs/tutorials/getting-started-pyomo.ipynb | 63 ++++------------- setup.py | 2 +- 3 files changed, 31 insertions(+), 102 deletions(-) diff --git a/docs/tutorials/getting-started-gurobipy.ipynb b/docs/tutorials/getting-started-gurobipy.ipynb index 47d51dd..36f0d9d 100644 --- a/docs/tutorials/getting-started-gurobipy.ipynb +++ b/docs/tutorials/getting-started-gurobipy.ipynb @@ -33,6 +33,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "id": "02f0a927", "metadata": {}, @@ -44,53 +45,17 @@ "- Python version, compatible with the Pyomo and Gurobipy modeling languages,\n", "- Julia version, compatible with the JuMP modeling language.\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`:" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "cd8a69c1", - "metadata": { - "ExecuteTime": { - "end_time": "2023-06-06T20:18:02.381829278Z", - "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'" + "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", + "```\n", + "\n", + "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", + "\n", + "```\n", + "$ pip install 'gurobipy>=10,<10.1'\n", + "```" ] }, { @@ -214,6 +179,7 @@ "from miplearn.io import read_pkl_gz\n", "from miplearn.solvers.gurobi import GurobiModel\n", "\n", + "\n", "def build_uc_model(data: Union[str, UnitCommitmentData]) -> GurobiModel:\n", " if isinstance(data, str):\n", " data = read_pkl_gz(data)\n", @@ -223,9 +189,7 @@ " x = model._x = model.addVars(n, vtype=GRB.BINARY, name=\"x\")\n", " y = model._y = model.addVars(n, name=\"y\")\n", " model.setObjective(\n", - " quicksum(\n", - " data.cfix[i] * x[i] + data.cvar[i] * y[i] for i in range(n)\n", - " )\n", + " quicksum(data.cfix[i] * x[i] + data.cvar[i] * y[i] for i in range(n))\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", @@ -588,7 +552,7 @@ "\n", "solver_ml = LearningSolver(components=[comp])\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": [ "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)" ] }, { diff --git a/docs/tutorials/getting-started-pyomo.ipynb b/docs/tutorials/getting-started-pyomo.ipynb index c3b46a7..77e2c28 100644 --- a/docs/tutorials/getting-started-pyomo.ipynb +++ b/docs/tutorials/getting-started-pyomo.ipynb @@ -33,6 +33,7 @@ ] }, { + "attachments": {}, "cell_type": "markdown", "id": "02f0a927", "metadata": {}, @@ -44,53 +45,17 @@ "- Python version, compatible with the Pyomo and Gurobipy modeling languages,\n", "- Julia version, compatible with the JuMP modeling language.\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`:" - ] - }, - { - "cell_type": "code", - "execution_count": 1, - "id": "cd8a69c1", - "metadata": { - "ExecuteTime": { - "end_time": "2023-06-06T19:57:33.202580815Z", - "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'" + "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", + "```\n", + "\n", + "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", + "\n", + "```\n", + "$ pip install 'gurobipy>=10,<10.1'\n", + "```" ] }, { @@ -600,7 +565,7 @@ "\n", "solver_ml = LearningSolver(components=[comp])\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": [ "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)" ] }, { diff --git a/setup.py b/setup.py index 7873962..2ca2859 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ from setuptools import setup, find_namespace_packages setup( name="miplearn", - version="0.3.0.dev1", + version="0.3.0", author="Alinson S. Xavier", author_email="axavier@anl.gov", description="Extensible Framework for Learning-Enhanced Mixed-Integer Optimization",