{ "cells": [ { "cell_type": "markdown", "metadata": { "toc": true }, "source": [ "

Table of Contents

\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Une prise en main rapide de Jupyter / Julia / JuMP\n", "\n", "## Qu'est-ce qu'un Jupyter notebook ?\n", "\n", "Un Jupyter notebook est un document qui contient \n", "+ du texte \n", " - que l'on peut formatter à l'aide de Markdown\n", " - qui peut contenir des maths à l'aide de $\\LaTeX$\n", "+ du code\n", " - avec lequel on peut intéragir en ligne\n", " \n", "Un notebook est une succession de cellule, chacune pouvant être soit du code, soit du texte.\n", "Quelques astuces :\n", "+ double-clicker pour rentrer dans une cellule\n", "+ M / Y pour changer le type de cellule\n", "+ Ctrl-enter pour éxecuter la cellule\n", "+ shift-enter pour éxecuter la cellule et passer à la suivante\n", "+ Alt-enter pour éxecuter la cellule et en ajouter une nouvelle\n", "\n", "Vous pouvez télécharger le fichier .ipynb via l'onglet \"file\" en haut à gauche. Vous pouvez aussi télécharger un pdf." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Qu'est-ce que Julia ?\n", "\n", "Julia est un langage de programmation, comparable à Python. C'est un langage récent, développé pour le calcul scientifique. \n", "\n", "Quelques éléments intéressant :\n", "+ langage open-source\n", "+ langage compilé \"Just-in-time\"\n", "+ langage disposant d'un terminal (comme python)\n", "+ ...\n", "\n", "Faisons nos premiers pas avec Julia. Exécuter les cellules suivantes (shift-enter), n'hésitez pas à modifier pour prendre en main :" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "2" ] }, "execution_count": 1, "metadata": {}, "output_type": "execute_result" } ], "source": [ "1+1" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "a = [0 5 10 15]\n", "a[1]" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "30" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sum(a)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "350" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sum(x^2 for x in a)" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "4" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "length(a)" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1×4 Array{Float64,2}:\n", " 1.0 143.413 22016.5 3.269e6" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "exp.(a) .- a #to apply an operation or function componentwise just add . " ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "\\begin{verbatim}\n", "exp(x)\n", "\\end{verbatim}\n", "Compute the natural base exponential of \\texttt{x}, in other words $e^x$.\n", "\n", "\\section{Examples}\n", "\\begin{verbatim}\n", "julia> exp(1.0)\n", "2.718281828459045\n", "\\end{verbatim}\n", "\\begin{verbatim}\n", "exp(A::AbstractMatrix)\n", "\\end{verbatim}\n", "Compute the matrix exponential of \\texttt{A}, defined by\n", "\n", "$$e^A = \\sum_{n=0}^{\\infty} \\frac{A^n}{n!}.$$\n", "For symmetric or Hermitian \\texttt{A}, an eigendecomposition (\\href{@ref}{\\texttt{eigen}}) is used, otherwise the scaling and squaring algorithm (see \\footnotemark[H05]) is chosen.\n", "\n", "\\footnotetext[H05]{Nicholas J. Higham, \"The squaring and scaling method for the matrix exponential revisited\", SIAM Journal on Matrix Analysis and Applications, 26(4), 2005, 1179-1193. \\href{https://doi.org/10.1137/090768539}{doi:10.1137/090768539}\n", "\n", "}\n", "\\section{Examples}\n", "\\begin{verbatim}\n", "julia> A = Matrix(1.0I, 2, 2)\n", "2×2 Array{Float64,2}:\n", " 1.0 0.0\n", " 0.0 1.0\n", "\n", "julia> exp(A)\n", "2×2 Array{Float64,2}:\n", " 2.71828 0.0\n", " 0.0 2.71828\n", "\\end{verbatim}\n" ], "text/markdown": [ "```\n", "exp(x)\n", "```\n", "\n", "Compute the natural base exponential of `x`, in other words $e^x$.\n", "\n", "# Examples\n", "\n", "```jldoctest\n", "julia> exp(1.0)\n", "2.718281828459045\n", "```\n", "\n", "```\n", "exp(A::AbstractMatrix)\n", "```\n", "\n", "Compute the matrix exponential of `A`, defined by\n", "\n", "$$\n", "e^A = \\sum_{n=0}^{\\infty} \\frac{A^n}{n!}.\n", "$$\n", "\n", "For symmetric or Hermitian `A`, an eigendecomposition ([`eigen`](@ref)) is used, otherwise the scaling and squaring algorithm (see [^H05]) is chosen.\n", "\n", "[^H05]: Nicholas J. Higham, \"The squaring and scaling method for the matrix exponential revisited\", SIAM Journal on Matrix Analysis and Applications, 26(4), 2005, 1179-1193. [doi:10.1137/090768539](https://doi.org/10.1137/090768539)\n", "\n", "# Examples\n", "\n", "```jldoctest\n", "julia> A = Matrix(1.0I, 2, 2)\n", "2×2 Array{Float64,2}:\n", " 1.0 0.0\n", " 0.0 1.0\n", "\n", "julia> exp(A)\n", "2×2 Array{Float64,2}:\n", " 2.71828 0.0\n", " 0.0 2.71828\n", "```\n" ], "text/plain": [ "\u001b[36m exp(x)\u001b[39m\n", "\n", " Compute the natural base exponential of \u001b[36mx\u001b[39m, in other words \u001b[35me^x\u001b[39m.\n", "\n", "\u001b[1m Examples\u001b[22m\n", "\u001b[1m ≡≡≡≡≡≡≡≡≡≡\u001b[22m\n", "\n", "\u001b[36m julia> exp(1.0)\u001b[39m\n", "\u001b[36m 2.718281828459045\u001b[39m\n", "\n", "\u001b[36m exp(A::AbstractMatrix)\u001b[39m\n", "\n", " Compute the matrix exponential of \u001b[36mA\u001b[39m, defined by\n", "\n", "\u001b[35me^A = \\sum_{n=0}^{\\infty} \\frac{A^n}{n!}.\u001b[39m\n", "\n", " For symmetric or Hermitian \u001b[36mA\u001b[39m, an eigendecomposition (\u001b[36meigen\u001b[39m) is used,\n", " otherwise the scaling and squaring algorithm (see \u001b[1m[^H05]\u001b[22m) is chosen.\n", "\n", " │ \u001b[0m\u001b[1m[^H05]\u001b[22m\n", " │\n", " │ Nicholas J. Higham, \"The squaring and scaling method for the\n", " │ matrix exponential revisited\", SIAM Journal on Matrix Analysis and\n", " │ Applications, 26(4), 2005, 1179-1193. doi:10.1137/090768539\n", " │ (https://doi.org/10.1137/090768539)\n", "\n", "\u001b[1m Examples\u001b[22m\n", "\u001b[1m ≡≡≡≡≡≡≡≡≡≡\u001b[22m\n", "\n", "\u001b[36m julia> A = Matrix(1.0I, 2, 2)\u001b[39m\n", "\u001b[36m 2×2 Array{Float64,2}:\u001b[39m\n", "\u001b[36m 1.0 0.0\u001b[39m\n", "\u001b[36m 0.0 1.0\u001b[39m\n", "\u001b[36m \u001b[39m\n", "\u001b[36m julia> exp(A)\u001b[39m\n", "\u001b[36m 2×2 Array{Float64,2}:\u001b[39m\n", "\u001b[36m 2.71828 0.0\u001b[39m\n", "\u001b[36m 0.0 2.71828\u001b[39m" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "@doc exp # to get documentation on a function" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "itération 1\n", "itération 2\n", "itération 3\n", "itération 4\n", "itération 5\n" ] } ], "source": [ "for i = 1:5\n", " println(\"itération \",i)\n", "end" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "factorielle (generic function with 1 method)" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "function factorielle(n)\n", " if n == 0\n", " return 1\n", " end\n", " res = 1\n", " for i=1:n\n", " res = res * i\n", " end\n", " return res\n", "end" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "120" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "factorielle(5)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1.9" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "round(1.9453;sigdigits=2)" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "3-element Array{Float64,1}:\n", " 0.37598526505599716\n", " 0.48392184544210703\n", " 0.10913191064537564" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rand(3)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Further info can be found [here](https://learnxinyminutes.com/docs/julia/) or in the [documentation](https://docs.julialang.org/en/v1/)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "\n", "## Qu'est-ce que JuMP ?\n", "\n", "JuMP est l'un des packages phare de Julia.\n", "\n", "Il s'agit d'un package de modélisation, qui permet d'écrire un problème d'optimisation de manière simple puis de demander à un Solver de le résoudre.\n", "\n", "Nous allons maintenant faire nos premiers pas avec JuMP.\n", "\n", "Plus d'information sur http://www.juliaopt.org/JuMP.jl/v0.20.0/quickstart/ " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Mise en place\n", "\n", "Avant toute chose il faut installer puis appeler les bibliothèques utiles.\n" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "scrolled": true }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "\u001b[32m\u001b[1m Updating\u001b[22m\u001b[39m registry at `~/.julia/registries/General`\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\u001b[?25l " ] }, { "name": "stderr", "output_type": "stream", "text": [ "\u001b[32m\u001b[1m Updating\u001b[22m\u001b[39m git-repo `https://github.com/JuliaRegistries/General.git`\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [> ] 0.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=> ] 0.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=> ] 0.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=> ] 0.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=> ] 0.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=> ] 0.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=> ] 0.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=> ] 0.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=> ] 0.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=> ] 1.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=> ] 1.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=> ] 1.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=> ] 1.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=> ] 1.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=> ] 1.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=> ] 1.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=> ] 1.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=> ] 1.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=> ] 2.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=> ] 2.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=> ] 2.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=> ] 2.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=> ] 2.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==> ] 2.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==> ] 2.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==> ] 2.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==> ] 2.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==> ] 3.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==> ] 3.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==> ] 3.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==> ] 3.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==> ] 3.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==> ] 3.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==> ] 3.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==> ] 3.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==> ] 4.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==> ] 4.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==> ] 4.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==> ] 4.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==> ] 4.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==> ] 4.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==> ] 4.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==> ] 4.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==> ] 4.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==> ] 5.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===> ] 5.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===> ] 5.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===> ] 5.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===> ] 5.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===> ] 5.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===> ] 5.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===> ] 5.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===> ] 5.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===> ] 6.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===> ] 6.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===> ] 6.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===> ] 6.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===> ] 6.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===> ] 6.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===> ] 6.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===> ] 6.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===> ] 6.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===> ] 7.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===> ] 7.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===> ] 7.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===> ] 7.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===> ] 7.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====> ] 7.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====> ] 7.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====> ] 7.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====> ] 7.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====> ] 8.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====> ] 8.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====> ] 8.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====> ] 8.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====> ] 8.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====> ] 8.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====> ] 8.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====> ] 8.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====> ] 8.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====> ] 9.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====> ] 9.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====> ] 9.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====> ] 9.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====> ] 9.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====> ] 9.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====> ] 9.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====> ] 9.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====> ] 10.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====> ] 10.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====> ] 10.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====> ] 10.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====> ] 10.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====> ] 10.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====> ] 10.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====> ] 10.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====> ] 10.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====> ] 11.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====> ] 11.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====> ] 11.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====> ] 11.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====> ] 11.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====> ] 11.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====> ] 11.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====> ] 11.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====> ] 11.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====> ] 12.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====> ] 12.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====> ] 12.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====> ] 12.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====> ] 12.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======> ] 12.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======> ] 12.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======> ] 12.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======> ] 12.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======> ] 13.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======> ] 13.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======> ] 13.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======> ] 13.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======> ] 13.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======> ] 13.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======> ] " ] }, { "name": "stdout", "output_type": "stream", "text": [ "13.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======> ] 13.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======> ] 13.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======> ] 14.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======> ] 14.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======> ] 14.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======> ] 14.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======> ] 14.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======> ] 14.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======> ] 14.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======> ] 14.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======> ] 14.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=======> ] 15.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=======> ] 15.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=======> ] 15.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=======> ] 15.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=======> ] 15.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=======> ] 15.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=======> ] 15.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=======> ] 15.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=======> ] 16.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=======> ] 16.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=======> ] 16.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=======> ] 16.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=======> ] 16.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=======> ] 16.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=======> ] 16.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=======> ] 16.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=======> ] 16.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=======> ] 17.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=======> ] 17.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=======> ] 17.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=======> ] 17.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=======> ] 17.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [========> ] 17.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [========> ] 17.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [========> ] 17.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [========> ] 17.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [========> ] 18.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [========> ] 18.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [========> ] 18.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [========> ] 18.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [========> ] 18.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [========> ] 18.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [========> ] 18.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [========> ] 18.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [========> ] 18.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [========> ] 19.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [========> ] 19.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [========> ] 19.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [========> ] 19.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [========> ] 19.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [========> ] 19.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [========> ] 19.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [========> ] 19.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [========> ] 19.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=========> ] 20.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=========> ] 20.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=========> ] 20.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=========> ] 20.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=========> ] 20.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=========> ] 20.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=========> ] 20.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=========> ] 20.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=========> ] 21.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=========> ] 21.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=========> ] 21.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=========> ] 21.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=========> ] 21.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=========> ] 21.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=========> ] 21.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=========> ] 21.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=========> ] 21.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=========> ] 22.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=========> ] 22.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=========> ] 22.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=========> ] 22.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=========> ] 22.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==========> ] 22.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==========> ] 22.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==========> ] 22.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==========> ] 22.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==========> ] 23.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==========> ] 23.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==========> ] 23.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==========> ] 23.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==========> ] 23.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==========> ] 23.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==========> ] 23.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==========> ] 23.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==========> ] 23.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==========> ] 24.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==========> ] 24.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==========> ] 24.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==========> ] 24.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==========> ] 24.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==========> ] 24.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==========> ] 24.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==========> ] 24.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==========> ] 24.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===========> ] 25.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===========> ] 25.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===========> ] 25.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===========> ] 25.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===========> ] 25.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===========> ] 25.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===========> ] 25.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===========> ] 25.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===========> ] 25.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===========> ] 26.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===========> ] 26.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===========> ] 26.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===========> ] 26.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===========> ] 26.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===========> ] 26.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===========> ] 26.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===========> ] 26.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===========> ] 27.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===========> ] 27.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===========> ] 27.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===========> ] 27.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===========" ] }, { "name": "stdout", "output_type": "stream", "text": [ "> ] 27.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [============> ] 27.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [============> ] 27.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [============> ] 27.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [============> ] 27.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [============> ] 28.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [============> ] 28.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [============> ] 28.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [============> ] 28.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [============> ] 28.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [============> ] 28.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [============> ] 28.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [============> ] 28.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [============> ] 28.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [============> ] 29.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [============> ] 29.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [============> ] 29.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [============> ] 29.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [============> ] 29.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [============> ] 29.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [============> ] 29.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [============> ] 29.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [============> ] 29.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=============> ] 30.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=============> ] 30.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=============> ] 30.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=============> ] 30.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=============> ] 30.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=============> ] 30.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=============> ] 30.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=============> ] 30.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=============> ] 30.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=============> ] 31.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=============> ] 31.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=============> ] 31.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=============> ] 31.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=============> ] 31.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=============> ] 31.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=============> ] 31.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=============> ] 31.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=============> ] 31.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=============> ] 32.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=============> ] 32.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=============> ] 32.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=============> ] 32.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==============> ] 32.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==============> ] 32.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==============> ] 32.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==============> ] 32.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==============> ] 33.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==============> ] 33.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==============> ] 33.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==============> ] 33.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==============> ] 33.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==============> ] 33.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==============> ] 33.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==============> ] 33.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==============> ] 33.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==============> ] 34.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==============> ] 34.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==============> ] 34.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==============> ] 34.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==============> ] 34.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==============> ] 34.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==============> ] 34.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==============> ] 34.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==============> ] 34.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==============> ] 35.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===============> ] 35.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===============> ] 35.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===============> ] 35.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===============> ] 35.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===============> ] 35.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===============> ] 35.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===============> ] 35.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===============> ] 35.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===============> ] 36.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===============> ] 36.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===============> ] 36.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===============> ] 36.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===============> ] 36.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===============> ] 36.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===============> ] 36.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===============> ] 36.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===============> ] 36.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===============> ] 37.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===============> ] 37.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===============> ] 37.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===============> ] 37.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===============> ] 37.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [================> ] 37.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [================> ] 37.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [================> ] 37.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [================> ] 37.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [================> ] 38.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [================> ] 38.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [================> ] 38.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [================> ] 38.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [================> ] 38.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [================> ] 38.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [================> ] 38.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [================> ] 38.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [================> ] 39.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [================> ] 39.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [================> ] 39.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [================> ] 39.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [================> ] 39.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [================> ] 39.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [================> ] 39.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [================> ] 39.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [================> ] 39.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [================> ] 40.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=================> ] 40.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=================> ] 40.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=================> ] 40.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=================> ] 40.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=================> ] 40.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=================> ] 40.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=================> ] 40.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=================> ] 40.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=================> ] 41.0 %\r" ] }, { "name": "stdout", "output_type": "stream", "text": [ " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=================> ] 41.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=================> ] 41.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=================> ] 41.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=================> ] 41.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=================> ] 41.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=================> ] 41.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=================> ] 41.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=================> ] 41.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=================> ] 42.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=================> ] 42.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=================> ] 42.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=================> ] 42.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=================> ] 42.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==================> ] 42.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==================> ] 42.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==================> ] 42.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==================> ] 42.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==================> ] 43.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==================> ] 43.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==================> ] 43.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==================> ] 43.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==================> ] 43.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==================> ] 43.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==================> ] 43.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==================> ] 43.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==================> ] 43.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==================> ] 44.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==================> ] 44.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==================> ] 44.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==================> ] 44.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==================> ] 44.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==================> ] 44.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==================> ] 44.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==================> ] 44.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [==================> ] 45.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===================> ] 45.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===================> ] 45.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===================> ] 45.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===================> ] 45.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===================> ] 45.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===================> ] 45.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===================> ] 45.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===================> ] 45.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===================> ] 46.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===================> ] 46.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===================> ] 46.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===================> ] 46.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===================> ] 46.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===================> ] 46.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===================> ] 46.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===================> ] 46.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===================> ] 46.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===================> ] 47.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===================> ] 47.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===================> ] 47.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===================> ] 47.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [===================> ] 47.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====================> ] 47.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====================> ] 47.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====================> ] 47.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====================> ] 47.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====================> ] 48.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====================> ] 48.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====================> ] 48.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====================> ] 48.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====================> ] 48.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====================> ] 48.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====================> ] 48.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====================> ] 48.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====================> ] 48.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====================> ] 49.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====================> ] 49.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====================> ] 49.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====================> ] 49.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====================> ] 49.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====================> ] 49.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====================> ] 49.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====================> ] 49.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [====================> ] 49.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====================> ] 50.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====================> ] 50.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====================> ] 50.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====================> ] 50.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====================> ] 50.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====================> ] 50.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====================> ] 50.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====================> ] 50.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====================> ] 51.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====================> ] 51.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====================> ] 51.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====================> ] 51.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====================> ] 51.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====================> ] 51.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====================> ] 51.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====================> ] 51.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====================> ] 51.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====================> ] 52.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====================> ] 52.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====================> ] 52.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====================> ] 52.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [=====================> ] 52.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======================> ] 52.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======================> ] 52.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======================> ] 52.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======================> ] 52.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======================> ] 53.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======================> ] 53.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======================> ] 53.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======================> ] 53.3 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======================> ] 53.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======================> ] 53.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======================> ] 53.7 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======================> ] 53.8 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======================> ] 53.9 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======================> ] 54.0 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======================> ] 54.1 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======================> ] 54.2 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======================> ] 54.4 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======================> ] 54.5 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======================> ] 54.6 %\r", " \u001b[36m\u001b[1mFetching:\u001b[22m\u001b[39m [======================" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\u001b[2K\u001b[?25h[1mFetching:\u001b[22m\u001b[39m [========================================>] 100.0 % ] 70.9 %==================================> ] 84.6 %" ] }, { "name": "stderr", "output_type": "stream", "text": [ "\u001b[32m\u001b[1m Resolving\u001b[22m\u001b[39m package versions...\n", "\u001b[32m\u001b[1m Updating\u001b[22m\u001b[39m `~/.julia/environments/v1.4/Project.toml`\n", "\u001b[90m [no changes]\u001b[39m\n", "\u001b[32m\u001b[1m Updating\u001b[22m\u001b[39m `~/.julia/environments/v1.4/Manifest.toml`\n", "\u001b[90m [no changes]\u001b[39m\n", "\u001b[32m\u001b[1m Resolving\u001b[22m\u001b[39m package versions...\n", "\u001b[32m\u001b[1m Updating\u001b[22m\u001b[39m `~/.julia/environments/v1.4/Project.toml`\n", "\u001b[90m [no changes]\u001b[39m\n", "\u001b[32m\u001b[1m Updating\u001b[22m\u001b[39m `~/.julia/environments/v1.4/Manifest.toml`\n", "\u001b[90m [no changes]\u001b[39m\n", "\u001b[32m\u001b[1m Resolving\u001b[22m\u001b[39m package versions...\n", "\u001b[32m\u001b[1m Updating\u001b[22m\u001b[39m `~/.julia/environments/v1.4/Project.toml`\n", "\u001b[90m [no changes]\u001b[39m\n", "\u001b[32m\u001b[1m Updating\u001b[22m\u001b[39m `~/.julia/environments/v1.4/Manifest.toml`\n", "\u001b[90m [no changes]\u001b[39m\n" ] } ], "source": [ "import Pkg;\n", "Pkg.add(\"GLPK\")\n", "Pkg.add(\"Ipopt\")\n", "Pkg.add(\"JuMP\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "On peut faire la liste des packages installés et leur version en executant la commande suivante." ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\u001b[32m\u001b[1mStatus\u001b[22m\u001b[39m `~/.julia/environments/v1.4/Project.toml`\n", " \u001b[90m [a076750e]\u001b[39m\u001b[37m CPLEX v0.6.5\u001b[39m\n", " \u001b[90m [e2554f3b]\u001b[39m\u001b[37m Clp v0.7.1\u001b[39m\n", " \u001b[90m [f6369f11]\u001b[39m\u001b[37m ForwardDiff v0.10.10\u001b[39m\n", " \u001b[90m [60bf3e95]\u001b[39m\u001b[37m GLPK v0.13.0\u001b[39m\n", " \u001b[90m [a2cc645c]\u001b[39m\u001b[37m GraphPlot v0.3.1\u001b[39m\n", " \u001b[90m [2e9cd046]\u001b[39m\u001b[37m Gurobi v0.7.6\u001b[39m\n", " \u001b[90m [7073ff75]\u001b[39m\u001b[37m IJulia v1.21.1\u001b[39m\n", " \u001b[90m [c601a237]\u001b[39m\u001b[37m Interact v0.10.3\u001b[39m\n", " \u001b[90m [b6b21f68]\u001b[39m\u001b[37m Ipopt v0.6.1\u001b[39m\n", " \u001b[90m [4076af6c]\u001b[39m\u001b[37m JuMP v0.21.2\u001b[39m\n", " \u001b[90m [093fc24a]\u001b[39m\u001b[37m LightGraphs v1.3.2\u001b[39m\n", " \u001b[90m [626554b9]\u001b[39m\u001b[37m MetaGraphs v0.6.5\u001b[39m\n", " \u001b[90m [429524aa]\u001b[39m\u001b[37m Optim v0.19.3\u001b[39m\n", " \u001b[90m [91a5bcdd]\u001b[39m\u001b[37m Plots v1.0.9\u001b[39m\n", " \u001b[90m [d330b81b]\u001b[39m\u001b[37m PyPlot v2.9.0\u001b[39m\n", " \u001b[90m [f4570300]\u001b[39m\u001b[37m SDDP v0.3.2\u001b[39m\n" ] } ], "source": [ "Pkg.status()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Nous allons maintenant dire que nous souhaitons utiliser ces packages (comparable à \"from packet import *\" en python)" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [], "source": [ "using JuMP, Ipopt, GLPK" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n", "## Construction d'un premier problème linéaire\n", "\n", "Nous souhaitons résoudre le problème linéaire suivant\n", "$$ \\begin{align*} \n", "\\min_{x,y} \\quad & 2x+3y \\\\\n", "s.c. \\quad & x+y \\geq 1 \\\\\n", "& x \\geq 0, y\\geq 0 \\\\\n", "\\end{align*}$$\n", "\n", "Commençons par construire le problème" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "data": { "text/latex": [ "$ x + y \\geq 1.0 $" ], "text/plain": [ "x + y ≥ 1.0" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "OPTIMIZER = GLPK.Optimizer # On définit un optimizer\n", "m = Model(OPTIMIZER) # On construit un problème d'optimisation\n", "\n", "@variable(m,x>=0) # x est une variable réelle positive de m\n", "@variable(m,y>=0) # y est une variable réelle positive de m\n", "\n", "### Remarque les fonctions @variable / @objective / @constraint sont des fonctions spécifiques (des macros) \n", "# qui autorise de donner un argument comme 2*x+3*y sans qu'il soit évalué. \n", "# Ce n'est pas un comportement générique des fonctions julia.\n", "\n", "@objective(m,Min, 2*x+3*y) # l'objectif de m est de Minimiser 2*x+3*y\n", "\n", "@constraint(m,x+y >= 1 ) # m a pour contrainte x+y <=1" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "On peut vérifier que m est bien ce que l'on souhaite" ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Min 2 x + 3 y\n", "Subject to\n", " x + y ≥ 1.0\n", " x ≥ 0.0\n", " y ≥ 0.0\n" ] } ], "source": [ "print(m)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "On peut également résoudre m" ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "OPTIMAL\n", "FEASIBLE_POINT\n", "FEASIBLE_POINT\n" ] } ], "source": [ "optimize!(m)\n", "println(termination_status(m))\n", "println(primal_status(m))\n", "println(dual_status(m))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Et si on souhaite connaître la valeur optimale du problème ou des solutions optimales on peut les avoir de la manière suivante" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "2.0\n", "x = 1.0\n", "y = 0.0\n" ] } ], "source": [ "println(JuMP.objective_value(m))\n", "println(\"x = \",JuMP.value(x))\n", "println(\"y = \",JuMP.value(y))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Un second problème linéaire\n", "\n", "Nous allons maintenant construire un problème linéaire plus complexe.\n", "$$\n", "\\begin{align*}\n", "\\min_{x\\in R^n} \\quad & \\sum_{i=1}^n c_i x_i \\\\\n", "s.c. \\quad & \\sum_{i=1}^n x_i \\geq n \\\\\n", "& -1 \\leq x_i \\leq 2 & \\forall i\n", "\\end{align*}\n", "$$" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Min 0.45634144350285943 x[1] + 0.768874364759796 x[2] + 0.09501857945060732 x[3] + 0.011099617576066478 x[4] + 0.413651878451194 x[5] + 0.39026554986036177 x[6] + 0.11827003149661186 x[7] + 0.2067100982992276 x[8] + 0.6860949238856013 x[9] + 0.5140247917094147 x[10]\n", "Subject to\n", " x[1] + x[2] + x[3] + x[4] + x[5] + x[6] + x[7] + x[8] + x[9] + x[10] ≥ 10.0\n", " x[1] ≥ -1.0\n", " x[2] ≥ -1.0\n", " x[3] ≥ -1.0\n", " x[4] ≥ -1.0\n", " x[5] ≥ -1.0\n", " x[6] ≥ -1.0\n", " x[7] ≥ -1.0\n", " x[8] ≥ -1.0\n", " x[9] ≥ -1.0\n", " x[10] ≥ -1.0\n", " x[1] ≤ 2.0\n", " x[2] ≤ 2.0\n", " x[3] ≤ 2.0\n", " x[4] ≤ 2.0\n", " x[5] ≤ 2.0\n", " x[6] ≤ 2.0\n", " x[7] ≤ 2.0\n", " x[8] ≤ 2.0\n", " x[9] ≤ 2.0\n", " x[10] ≤ 2.0\n" ] } ], "source": [ "m2 = Model(OPTIMIZER)\n", "n = 10 # on choisit n = 10, mais vous pouvez le modifier\n", "c = rand(n) # c est choisi ici de manière aléatoire \n", "\n", "@variable(m2, -1<= x[1:n] <= 2) # x est une variable de m2 contenant n éléments x[1], x[2],...,x[n] tous compris entre -1 et 2\n", "\n", "@objective(m2,Min, sum(c[i]*x[i] for i=1:n) )\n", "\n", "@constraint(m2,sum(x[i] for i=1:n) >= n)\n", " \n", "print(m2) " ] }, { "cell_type": "code", "execution_count": 21, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "OPTIMAL\n" ] } ], "source": [ "optimize!(m2)\n", "println(termination_status(m2))" ] }, { "cell_type": "code", "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "10-element Array{Float64,1}:\n", " 1.0\n", " -1.0\n", " 2.0\n", " 2.0\n", " 2.0\n", " 2.0\n", " 2.0\n", " 2.0\n", " -1.0\n", " -1.0" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "value.(x)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Ajoutons maintenant une série de contraintes de la forme\n", "$$ x_i + x_{i+1} \\leq 1, \\qquad \\forall i \\in 2, \\dots, n-1$$" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [], "source": [ "for i = 1 : n-1\n", " @constraint(m2, x[i]+x[i+1] <= 2)\n", "end" ] }, { "cell_type": "code", "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "10-element Array{Float64,1}:\n", " 2.0\n", " 0.0\n", " 0.0\n", " 2.0\n", " 0.0\n", " 2.0\n", " 0.0\n", " 2.0\n", " 0.0\n", " 2.0" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "optimize!(m2)\n", "value.(x)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Un problème non-linéaire\n", "\n", "Nous allons terminer avec un problème non-linéaire simple.\n", "\n", "$$\n", "\\begin{align*}\n", "\\min_{x \\in R^{n.m}} \\quad & \\sum_{i,j} x_{i,j}^2 \\\\\n", "s.c. \\quad & \\sum_{i=1}^n x_{i,j} = 1 & \\forall j \\in [m] \n", "\\end{align*}\n", "$$" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [], "source": [ "using Ipopt" ] }, { "cell_type": "code", "execution_count": 26, "metadata": {}, "outputs": [], "source": [ "OPTIMIZER_NL = Ipopt.Optimizer\n", "\n", "m3 = Model(OPTIMIZER_NL)\n", "\n", "N,M = 5,7 \n", "\n", "@variable(m3, x[i=1:N, j=1:M])\n", "\n", "@objective(m3, Max, sum(x[i,j]^2 for i=1:N, j=1:M))\n", "\n", "for j=1:M\n", " @constraint(m3, sum(x[i,j] for i =1:N)==1)\n", "end" ] }, { "cell_type": "code", "execution_count": 27, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Max x[1,1]² + x[1,2]² + x[1,3]² + x[1,4]² + x[1,5]² + x[1,6]² + x[1,7]² + x[2,1]² + x[2,2]² + x[2,3]² + x[2,4]² + x[2,5]² + x[2,6]² + x[2,7]² + x[3,1]² + x[3,2]² + x[3,3]² + x[3,4]² + x[3,5]² + x[3,6]² + x[3,7]² + x[4,1]² + x[4,2]² + x[4,3]² + x[4,4]² + x[4,5]² + x[4,6]² + x[4,7]² + x[5,1]² + x[5,2]² + x[5,3]² + x[5,4]² + x[5,5]² + x[5,6]² + x[5,7]²\n", "Subject to\n", " x[1,1] + x[2,1] + x[3,1] + x[4,1] + x[5,1] = 1.0\n", " x[1,2] + x[2,2] + x[3,2] + x[4,2] + x[5,2] = 1.0\n", " x[1,3] + x[2,3] + x[3,3] + x[4,3] + x[5,3] = 1.0\n", " x[1,4] + x[2,4] + x[3,4] + x[4,4] + x[5,4] = 1.0\n", " x[1,5] + x[2,5] + x[3,5] + x[4,5] + x[5,5] = 1.0\n", " x[1,6] + x[2,6] + x[3,6] + x[4,6] + x[5,6] = 1.0\n", " x[1,7] + x[2,7] + x[3,7] + x[4,7] + x[5,7] = 1.0\n" ] } ], "source": [ "print(m3)" ] }, { "cell_type": "code", "execution_count": 28, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "******************************************************************************\n", "This program contains Ipopt, a library for large-scale nonlinear optimization.\n", " Ipopt is released as open source code under the Eclipse Public License (EPL).\n", " For more information visit http://projects.coin-or.org/Ipopt\n", "******************************************************************************\n", "\n", "This is Ipopt version 3.12.10, running with linear solver mumps.\n", "NOTE: Other linear solvers might be more efficient (see Ipopt documentation).\n", "\n", "Number of nonzeros in equality constraint Jacobian...: 35\n", "Number of nonzeros in inequality constraint Jacobian.: 0\n", "Number of nonzeros in Lagrangian Hessian.............: 35\n", "\n", "Total number of variables............................: 35\n", " variables with only lower bounds: 0\n", " variables with lower and upper bounds: 0\n", " variables with only upper bounds: 0\n", "Total number of equality constraints.................: 7\n", "Total number of inequality constraints...............: 0\n", " inequality constraints with only lower bounds: 0\n", " inequality constraints with lower and upper bounds: 0\n", " inequality constraints with only upper bounds: 0\n", "\n", "iter objective inf_pr inf_du lg(mu) ||d|| lg(rg) alpha_du alpha_pr ls\n", " 0 -0.0000000e+00 1.00e+00 0.00e+00 -1.0 0.00e+00 - 0.00e+00 0.00e+00 0\n", " 1 -1.4000000e+00 0.00e+00 2.00e+01 -1.7 2.00e-01 2.0 1.00e+00 1.00e+00h 1\n", " 2 -1.4000000e+00 2.22e-16 1.50e-15 -1.7 2.58e-17 1.5 1.00e+00 1.00e+00 0\n", "\n", "Number of Iterations....: 2\n", "\n", " (scaled) (unscaled)\n", "Objective...............: -1.4000000000000010e+00 -1.4000000000000010e+00\n", "Dual infeasibility......: 1.4988010832439613e-15 1.4988010832439613e-15\n", "Constraint violation....: 2.2204460492503131e-16 2.2204460492503131e-16\n", "Complementarity.........: 0.0000000000000000e+00 0.0000000000000000e+00\n", "Overall NLP error.......: 1.4988010832439613e-15 1.4988010832439613e-15\n", "\n", "\n", "Number of objective function evaluations = 3\n", "Number of objective gradient evaluations = 3\n", "Number of equality constraint evaluations = 3\n", "Number of inequality constraint evaluations = 0\n", "Number of equality constraint Jacobian evaluations = 1\n", "Number of inequality constraint Jacobian evaluations = 0\n", "Number of Lagrangian Hessian evaluations = 1\n", "Total CPU secs in IPOPT (w/o function evaluations) = 1.833\n", "Total CPU secs in NLP function evaluations = 0.614\n", "\n", "EXIT: Optimal Solution Found.\n", "1.400000000000001\n" ] } ], "source": [ "optimize!(m3)\n", "println(objective_value(m3))" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "5×7 Array{Float64,2}:\n", " 0.2 0.2 0.2 0.2 0.2 0.2 0.2\n", " 0.2 0.2 0.2 0.2 0.2 0.2 0.2\n", " 0.2 0.2 0.2 0.2 0.2 0.2 0.2\n", " 0.2 0.2 0.2 0.2 0.2 0.2 0.2\n", " 0.2 0.2 0.2 0.2 0.2 0.2 0.2" ] }, "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ "value.(x)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Tested Version :\n", "- JuMP 0.20 / Julia 1.4" ] } ], "metadata": { "@webio": { "lastCommId": null, "lastKernelId": null }, "kernelspec": { "display_name": "Julia 1.4.0", "language": "julia", "name": "julia-1.4" }, "language_info": { "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", "version": "1.4.0" }, "toc": { "base_numbering": 1, "nav_menu": {}, "number_sections": true, "sideBar": true, "skip_h1_title": true, "title_cell": "Table of Contents", "title_sidebar": "Contents", "toc_cell": true, "toc_position": {}, "toc_section_display": true, "toc_window_display": false } }, "nbformat": 4, "nbformat_minor": 2 }