{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "a398338b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}{===================================}</script></html>"
      ],
      "text/latex": [
       "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}{===================================}$$"
      ],
      "text/plain": [
       "ry"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}{===================================}</script></html>"
      ],
      "text/latex": [
       "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}{===================================}$$"
      ],
      "text/plain": [
       "ry"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\begin{array}{l}\n",
       "\\begin{array}{lcrcrcl}\n",
       " \\max \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu} 90 x_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 100 x_{2} \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu} \\\\\n",
       " \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu} x_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} x_{2} \\mspace{-6mu}&\\mspace{-6mu} \\leq \\mspace{-6mu}&\\mspace{-6mu} 75 \\\\\n",
       " \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu} 5 x_{1} \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu} \\geq \\mspace{-6mu}&\\mspace{-6mu} 80 \\\\\n",
       " \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu} 4 x_{2} \\mspace{-6mu}&\\mspace{-6mu} \\geq \\mspace{-6mu}&\\mspace{-6mu} 60 \\\\\n",
       " \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu} 6 x_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 10 x_{2} \\mspace{-6mu}&\\mspace{-6mu} \\leq \\mspace{-6mu}&\\mspace{-6mu} 354 \\\\\n",
       "\\end{array} \\\\\n",
       "x_{1}, x_{2} \\geq 0\n",
       "\\end{array}</script></html>"
      ],
      "text/latex": [
       "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\begin{array}{l}\n",
       "\\begin{array}{lcrcrcl}\n",
       " \\max \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu} 90 x_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 100 x_{2} \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu} \\\\\n",
       " \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu} x_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} x_{2} \\mspace{-6mu}&\\mspace{-6mu} \\leq \\mspace{-6mu}&\\mspace{-6mu} 75 \\\\\n",
       " \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu} 5 x_{1} \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu} \\geq \\mspace{-6mu}&\\mspace{-6mu} 80 \\\\\n",
       " \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu} 4 x_{2} \\mspace{-6mu}&\\mspace{-6mu} \\geq \\mspace{-6mu}&\\mspace{-6mu} 60 \\\\\n",
       " \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu} 6 x_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 10 x_{2} \\mspace{-6mu}&\\mspace{-6mu} \\leq \\mspace{-6mu}&\\mspace{-6mu} 354 \\\\\n",
       "\\end{array} \\\\\n",
       "x_{1}, x_{2} \\geq 0\n",
       "\\end{array}$$"
      ],
      "text/plain": [
       "LP problem (use 'view(...)' or '%display typeset' for details)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}4560</script></html>"
      ],
      "text/latex": [
       "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}4560$$"
      ],
      "text/plain": [
       "4560"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(34,\\,15\\right)</script></html>"
      ],
      "text/latex": [
       "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(34,\\,15\\right)$$"
      ],
      "text/plain": [
       "(34, 15)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}{===================================}</script></html>"
      ],
      "text/latex": [
       "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}{===================================}$$"
      ],
      "text/plain": [
       "ry"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}{===================================}</script></html>"
      ],
      "text/latex": [
       "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}{===================================}$$"
      ],
      "text/plain": [
       "ry"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}{}</script></html>"
      ],
      "text/latex": [
       "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}{}$$"
      ],
      "text/plain": [
       "salto"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}{\\texttt{El dual es:}}</script></html>"
      ],
      "text/latex": [
       "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}{\\texttt{El dual es:}}$$"
      ],
      "text/plain": [
       "dual"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}{===================================}</script></html>"
      ],
      "text/latex": [
       "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}{===================================}$$"
      ],
      "text/plain": [
       "ry"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\begin{array}{l}\n",
       "\\begin{array}{lcrcrcrcrcl}\n",
       " \\min \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu} 75 y_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 80 y_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 60 y_{3} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 354 y_{4} \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu} \\\\\n",
       " \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu} y_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 5 y_{2} \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 6 y_{4} \\mspace{-6mu}&\\mspace{-6mu} \\geq \\mspace{-6mu}&\\mspace{-6mu} 90 \\\\\n",
       " \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu} y_{1} \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 4 y_{3} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 10 y_{4} \\mspace{-6mu}&\\mspace{-6mu} \\geq \\mspace{-6mu}&\\mspace{-6mu} 100 \\\\\n",
       "\\end{array} \\\\\n",
       "y_{1} \\geq 0,\\ y_{2} \\leq 0,\\ y_{3} \\leq 0,\\ y_{4} \\geq 0\n",
       "\\end{array}</script></html>"
      ],
      "text/latex": [
       "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\begin{array}{l}\n",
       "\\begin{array}{lcrcrcrcrcl}\n",
       " \\min \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu} 75 y_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 80 y_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 60 y_{3} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 354 y_{4} \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu} \\\\\n",
       " \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu} y_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 5 y_{2} \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 6 y_{4} \\mspace{-6mu}&\\mspace{-6mu} \\geq \\mspace{-6mu}&\\mspace{-6mu} 90 \\\\\n",
       " \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu} y_{1} \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu}  \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 4 y_{3} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 10 y_{4} \\mspace{-6mu}&\\mspace{-6mu} \\geq \\mspace{-6mu}&\\mspace{-6mu} 100 \\\\\n",
       "\\end{array} \\\\\n",
       "y_{1} \\geq 0,\\ y_{2} \\leq 0,\\ y_{3} \\leq 0,\\ y_{4} \\geq 0\n",
       "\\end{array}$$"
      ],
      "text/plain": [
       "LP problem (use 'view(...)' or '%display typeset' for details)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}{===================================}</script></html>"
      ],
      "text/latex": [
       "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}{===================================}$$"
      ],
      "text/plain": [
       "ry"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}4560</script></html>"
      ],
      "text/latex": [
       "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}4560$$"
      ],
      "text/plain": [
       "4560"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(0,\\,0,\\,-\\frac{25}{2},\\,15\\right)</script></html>"
      ],
      "text/latex": [
       "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(0,\\,0,\\,-\\frac{25}{2},\\,15\\right)$$"
      ],
      "text/plain": [
       "(0, 0, -25/2, 15)"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}{}</script></html>"
      ],
      "text/latex": [
       "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}{}$$"
      ],
      "text/plain": [
       "salto"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}{===================================}</script></html>"
      ],
      "text/latex": [
       "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}{===================================}$$"
      ],
      "text/plain": [
       "ry"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}{\\ \\ \\ Fase\\ I}</script></html>"
      ],
      "text/latex": [
       "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}{\\ \\ \\ Fase\\ I}$$"
      ],
      "text/plain": [
       "FI"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}{===================================}</script></html>"
      ],
      "text/latex": [
       "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}{===================================}$$"
      ],
      "text/plain": [
       "ry"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrrrr|r}\n",
       "{Basic} & {x}_{1} & {x}_{2} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {\\color{green}{s}}_{4} & {\\color{red}{t}}_{2} & {\\color{red}{t}}_{3} & {b} \\\\\n",
       "\\hline\n",
       " {\\color{green}{s}}_{1} & 1 & 1 & 1 & 0 & 0 & 0 & 0 & 0 & 75 \\\\\n",
       "{\\color{red}{t}}_{2} & 5 & 0 & 0 & -1 & 0 & 0 & 1 & 0 & 80 \\\\\n",
       "{\\color{red}{t}}_{3} & 0 & 4 & 0 & 0 & -1 & 0 & 0 & 1 & 60 \\\\\n",
       "{\\color{green}{s}}_{4} & 6 & 10 & 0 & 0 & 0 & 1 & 0 & 0 & 354 \\\\\n",
       "\\hline\n",
       " {W_{ind}} & -5 & -4 & 0 & 1 & 1 & 0 & 0 & 0 & 140\n",
       "\\end{array}\\right)</script></html>"
      ],
      "text/latex": [
       "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrrrr|r}\n",
       "{Basic} & {x}_{1} & {x}_{2} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {\\color{green}{s}}_{4} & {\\color{red}{t}}_{2} & {\\color{red}{t}}_{3} & {b} \\\\\n",
       "\\hline\n",
       " {\\color{green}{s}}_{1} & 1 & 1 & 1 & 0 & 0 & 0 & 0 & 0 & 75 \\\\\n",
       "{\\color{red}{t}}_{2} & 5 & 0 & 0 & -1 & 0 & 0 & 1 & 0 & 80 \\\\\n",
       "{\\color{red}{t}}_{3} & 0 & 4 & 0 & 0 & -1 & 0 & 0 & 1 & 60 \\\\\n",
       "{\\color{green}{s}}_{4} & 6 & 10 & 0 & 0 & 0 & 1 & 0 & 0 & 354 \\\\\n",
       "\\hline\n",
       " {W_{ind}} & -5 & -4 & 0 & 1 & 1 & 0 & 0 & 0 & 140\n",
       "\\end{array}\\right)$$"
      ],
      "text/plain": [
       "[  B| x1  x2  s1  s2  s3  s4  t2  t3|rhs]\n",
       "[---+-------------------------------+---]\n",
       "[ s1|  1   1   1   0   0   0   0   0| 75]\n",
       "[ t2|  5   0   0  -1   0   0   1   0| 80]\n",
       "[ t3|  0   4   0   0  -1   0   0   1| 60]\n",
       "[ s4|  6  10   0   0   0   1   0   0|354]\n",
       "[---+-------------------------------+---]\n",
       "[  W| -5  -4   0   1   1   0   0   0|140]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "cambio( 2 , 1 )\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrrrr|r}\n",
       "{Basic} & {x}_{1} & {x}_{2} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {\\color{green}{s}}_{4} & {\\color{red}{t}}_{2} & {\\color{red}{t}}_{3} & {b} \\\\\n",
       "\\hline\n",
       " {\\color{green}{s}}_{1} & 0 & 1 & 1 & \\frac{1}{5} & 0 & 0 & -\\frac{1}{5} & 0 & 59 \\\\\n",
       "{x}_{1} & 1 & 0 & 0 & -\\frac{1}{5} & 0 & 0 & \\frac{1}{5} & 0 & 16 \\\\\n",
       "{\\color{red}{t}}_{3} & 0 & 4 & 0 & 0 & -1 & 0 & 0 & 1 & 60 \\\\\n",
       "{\\color{green}{s}}_{4} & 0 & 10 & 0 & \\frac{6}{5} & 0 & 1 & -\\frac{6}{5} & 0 & 258 \\\\\n",
       "\\hline\n",
       " {W_{ind}} & 0 & -4 & 0 & 0 & 1 & 0 & 1 & 0 & 60\n",
       "\\end{array}\\right)</script></html>"
      ],
      "text/latex": [
       "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrrrr|r}\n",
       "{Basic} & {x}_{1} & {x}_{2} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {\\color{green}{s}}_{4} & {\\color{red}{t}}_{2} & {\\color{red}{t}}_{3} & {b} \\\\\n",
       "\\hline\n",
       " {\\color{green}{s}}_{1} & 0 & 1 & 1 & \\frac{1}{5} & 0 & 0 & -\\frac{1}{5} & 0 & 59 \\\\\n",
       "{x}_{1} & 1 & 0 & 0 & -\\frac{1}{5} & 0 & 0 & \\frac{1}{5} & 0 & 16 \\\\\n",
       "{\\color{red}{t}}_{3} & 0 & 4 & 0 & 0 & -1 & 0 & 0 & 1 & 60 \\\\\n",
       "{\\color{green}{s}}_{4} & 0 & 10 & 0 & \\frac{6}{5} & 0 & 1 & -\\frac{6}{5} & 0 & 258 \\\\\n",
       "\\hline\n",
       " {W_{ind}} & 0 & -4 & 0 & 0 & 1 & 0 & 1 & 0 & 60\n",
       "\\end{array}\\right)$$"
      ],
      "text/plain": [
       "[   B|  x1   x2   s1   s2   s3   s4   t2   t3| rhs]\n",
       "[----+---------------------------------------+----]\n",
       "[  s1|   0    1    1  1/5    0    0 -1/5    0|  59]\n",
       "[  x1|   1    0    0 -1/5    0    0  1/5    0|  16]\n",
       "[  t3|   0    4    0    0   -1    0    0    1|  60]\n",
       "[  s4|   0   10    0  6/5    0    1 -6/5    0| 258]\n",
       "[----+---------------------------------------+----]\n",
       "[   W|   0   -4    0    0    1    0    1    0|  60]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "cambio( 3 , 2 )\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrrrr|r}\n",
       "{Basic} & {x}_{1} & {x}_{2} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {\\color{green}{s}}_{4} & {\\color{red}{t}}_{2} & {\\color{red}{t}}_{3} & {b} \\\\\n",
       "\\hline\n",
       " {\\color{green}{s}}_{1} & 0 & 0 & 1 & \\frac{1}{5} & \\frac{1}{4} & 0 & -\\frac{1}{5} & -\\frac{1}{4} & 44 \\\\\n",
       "{x}_{1} & 1 & 0 & 0 & -\\frac{1}{5} & 0 & 0 & \\frac{1}{5} & 0 & 16 \\\\\n",
       "{x}_{2} & 0 & 1 & 0 & 0 & -\\frac{1}{4} & 0 & 0 & \\frac{1}{4} & 15 \\\\\n",
       "{\\color{green}{s}}_{4} & 0 & 0 & 0 & \\frac{6}{5} & \\frac{5}{2} & 1 & -\\frac{6}{5} & -\\frac{5}{2} & 108 \\\\\n",
       "\\hline\n",
       " {W_{ind}} & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 1 & 0\n",
       "\\end{array}\\right)</script></html>"
      ],
      "text/latex": [
       "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrrrr|r}\n",
       "{Basic} & {x}_{1} & {x}_{2} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {\\color{green}{s}}_{4} & {\\color{red}{t}}_{2} & {\\color{red}{t}}_{3} & {b} \\\\\n",
       "\\hline\n",
       " {\\color{green}{s}}_{1} & 0 & 0 & 1 & \\frac{1}{5} & \\frac{1}{4} & 0 & -\\frac{1}{5} & -\\frac{1}{4} & 44 \\\\\n",
       "{x}_{1} & 1 & 0 & 0 & -\\frac{1}{5} & 0 & 0 & \\frac{1}{5} & 0 & 16 \\\\\n",
       "{x}_{2} & 0 & 1 & 0 & 0 & -\\frac{1}{4} & 0 & 0 & \\frac{1}{4} & 15 \\\\\n",
       "{\\color{green}{s}}_{4} & 0 & 0 & 0 & \\frac{6}{5} & \\frac{5}{2} & 1 & -\\frac{6}{5} & -\\frac{5}{2} & 108 \\\\\n",
       "\\hline\n",
       " {W_{ind}} & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 1 & 0\n",
       "\\end{array}\\right)$$"
      ],
      "text/plain": [
       "[   B|  x1   x2   s1   s2   s3   s4   t2   t3| rhs]\n",
       "[----+---------------------------------------+----]\n",
       "[  s1|   0    0    1  1/5  1/4    0 -1/5 -1/4|  44]\n",
       "[  x1|   1    0    0 -1/5    0    0  1/5    0|  16]\n",
       "[  x2|   0    1    0    0 -1/4    0    0  1/4|  15]\n",
       "[  s4|   0    0    0  6/5  5/2    1 -6/5 -5/2| 108]\n",
       "[----+---------------------------------------+----]\n",
       "[   W|   0    0    0    0    0    0    1    1|   0]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "El problema de la fase I es óptimo y Wopt=0. Por tanto, el original es factible\n",
      "Preparemos el cuadro inicial de la fase II\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}{===================================}</script></html>"
      ],
      "text/latex": [
       "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}{===================================}$$"
      ],
      "text/plain": [
       "ry"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}{\\ \\ \\ Fase\\ II}</script></html>"
      ],
      "text/latex": [
       "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}{\\ \\ \\ Fase\\ II}$$"
      ],
      "text/plain": [
       "FII"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}{===================================}</script></html>"
      ],
      "text/latex": [
       "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}{===================================}$$"
      ],
      "text/plain": [
       "ry"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrr|r}\n",
       "{Basic} & {x}_{1} & {x}_{2} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {\\color{green}{s}}_{4} & {b} \\\\\n",
       "\\hline\n",
       " {\\color{green}{s}}_{1} & 0 & 0 & 1 & \\frac{1}{5} & \\frac{1}{4} & 0 & 44 \\\\\n",
       "{x}_{1} & 1 & 0 & 0 & -\\frac{1}{5} & 0 & 0 & 16 \\\\\n",
       "{x}_{2} & 0 & 1 & 0 & 0 & -\\frac{1}{4} & 0 & 15 \\\\\n",
       "{\\color{green}{s}}_{4} & 0 & 0 & 0 & \\frac{6}{5} & \\frac{5}{2} & 1 & 108 \\\\\n",
       "\\hline\n",
       " {Z_{ind}} & 0 & 0 & 0 & 18 & 25 & 0 & 2940\n",
       "\\end{array}\\right)</script></html>"
      ],
      "text/latex": [
       "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrr|r}\n",
       "{Basic} & {x}_{1} & {x}_{2} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {\\color{green}{s}}_{4} & {b} \\\\\n",
       "\\hline\n",
       " {\\color{green}{s}}_{1} & 0 & 0 & 1 & \\frac{1}{5} & \\frac{1}{4} & 0 & 44 \\\\\n",
       "{x}_{1} & 1 & 0 & 0 & -\\frac{1}{5} & 0 & 0 & 16 \\\\\n",
       "{x}_{2} & 0 & 1 & 0 & 0 & -\\frac{1}{4} & 0 & 15 \\\\\n",
       "{\\color{green}{s}}_{4} & 0 & 0 & 0 & \\frac{6}{5} & \\frac{5}{2} & 1 & 108 \\\\\n",
       "\\hline\n",
       " {Z_{ind}} & 0 & 0 & 0 & 18 & 25 & 0 & 2940\n",
       "\\end{array}\\right)$$"
      ],
      "text/plain": [
       "[   B|  x1   x2   s1   s2   s3   s4| rhs]\n",
       "[----+-----------------------------+----]\n",
       "[  s1|   0    0    1  1/5  1/4    0|  44]\n",
       "[  x1|   1    0    0 -1/5    0    0|  16]\n",
       "[  x2|   0    1    0    0 -1/4    0|  15]\n",
       "[  s4|   0    0    0  6/5  5/2    1| 108]\n",
       "[----+-----------------------------+----]\n",
       "[   Z|   0    0    0   18   25    0|2940]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "cambio( 4 , 5 )\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrr|r}\n",
       "{Basic} & {x}_{1} & {x}_{2} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {\\color{green}{s}}_{4} & {b} \\\\\n",
       "\\hline\n",
       " {\\color{green}{s}}_{1} & 0 & 0 & 1 & \\frac{2}{25} & 0 & -\\frac{1}{10} & \\frac{166}{5} \\\\\n",
       "{x}_{1} & 1 & 0 & 0 & -\\frac{1}{5} & 0 & 0 & 16 \\\\\n",
       "{x}_{2} & 0 & 1 & 0 & \\frac{3}{25} & 0 & \\frac{1}{10} & \\frac{129}{5} \\\\\n",
       "{\\color{green}{s}}_{3} & 0 & 0 & 0 & \\frac{12}{25} & 1 & \\frac{2}{5} & \\frac{216}{5} \\\\\n",
       "\\hline\n",
       " {Z_{ind}} & 0 & 0 & 0 & 6 & 0 & -10 & 4020\n",
       "\\end{array}\\right)</script></html>"
      ],
      "text/latex": [
       "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrr|r}\n",
       "{Basic} & {x}_{1} & {x}_{2} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {\\color{green}{s}}_{4} & {b} \\\\\n",
       "\\hline\n",
       " {\\color{green}{s}}_{1} & 0 & 0 & 1 & \\frac{2}{25} & 0 & -\\frac{1}{10} & \\frac{166}{5} \\\\\n",
       "{x}_{1} & 1 & 0 & 0 & -\\frac{1}{5} & 0 & 0 & 16 \\\\\n",
       "{x}_{2} & 0 & 1 & 0 & \\frac{3}{25} & 0 & \\frac{1}{10} & \\frac{129}{5} \\\\\n",
       "{\\color{green}{s}}_{3} & 0 & 0 & 0 & \\frac{12}{25} & 1 & \\frac{2}{5} & \\frac{216}{5} \\\\\n",
       "\\hline\n",
       " {Z_{ind}} & 0 & 0 & 0 & 6 & 0 & -10 & 4020\n",
       "\\end{array}\\right)$$"
      ],
      "text/plain": [
       "[    B|   x1    x2    s1    s2    s3    s4|  rhs]\n",
       "[-----+-----------------------------------+-----]\n",
       "[   s1|    0     0     1  2/25     0 -1/10|166/5]\n",
       "[   x1|    1     0     0  -1/5     0     0|   16]\n",
       "[   x2|    0     1     0  3/25     0  1/10|129/5]\n",
       "[   s3|    0     0     0 12/25     1   2/5|216/5]\n",
       "[-----+-----------------------------------+-----]\n",
       "[    Z|    0     0     0     6     0   -10| 4020]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "cambio( 4 , 4 )\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrr|r}\n",
       "{Basic} & {x}_{1} & {x}_{2} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {\\color{green}{s}}_{4} & {b} \\\\\n",
       "\\hline\n",
       " {\\color{green}{s}}_{1} & 0 & 0 & 1 & 0 & -\\frac{1}{6} & -\\frac{1}{6} & 26 \\\\\n",
       "{x}_{1} & 1 & 0 & 0 & 0 & \\frac{5}{12} & \\frac{1}{6} & 34 \\\\\n",
       "{x}_{2} & 0 & 1 & 0 & 0 & -\\frac{1}{4} & 0 & 15 \\\\\n",
       "{\\color{green}{s}}_{2} & 0 & 0 & 0 & 1 & \\frac{25}{12} & \\frac{5}{6} & 90 \\\\\n",
       "\\hline\n",
       " {Z_{ind}} & 0 & 0 & 0 & 0 & -\\frac{25}{2} & -15 & 4560\n",
       "\\end{array}\\right)</script></html>"
      ],
      "text/latex": [
       "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrr|r}\n",
       "{Basic} & {x}_{1} & {x}_{2} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {\\color{green}{s}}_{4} & {b} \\\\\n",
       "\\hline\n",
       " {\\color{green}{s}}_{1} & 0 & 0 & 1 & 0 & -\\frac{1}{6} & -\\frac{1}{6} & 26 \\\\\n",
       "{x}_{1} & 1 & 0 & 0 & 0 & \\frac{5}{12} & \\frac{1}{6} & 34 \\\\\n",
       "{x}_{2} & 0 & 1 & 0 & 0 & -\\frac{1}{4} & 0 & 15 \\\\\n",
       "{\\color{green}{s}}_{2} & 0 & 0 & 0 & 1 & \\frac{25}{12} & \\frac{5}{6} & 90 \\\\\n",
       "\\hline\n",
       " {Z_{ind}} & 0 & 0 & 0 & 0 & -\\frac{25}{2} & -15 & 4560\n",
       "\\end{array}\\right)$$"
      ],
      "text/plain": [
       "[    B|   x1    x2    s1    s2    s3    s4|  rhs]\n",
       "[-----+-----------------------------------+-----]\n",
       "[   s1|    0     0     1     0  -1/6  -1/6|   26]\n",
       "[   x1|    1     0     0     0  5/12   1/6|   34]\n",
       "[   x2|    0     1     0     0  -1/4     0|   15]\n",
       "[   s2|    0     0     0     1 25/12   5/6|   90]\n",
       "[-----+-----------------------------------+-----]\n",
       "[    Z|    0     0     0     0 -25/2   -15| 4560]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "El problema es óptimo\n"
     ]
    }
   ],
   "source": [
    "tipo='max'  # max o min\n",
    "\n",
    "n=2 #  número de variables x's\n",
    "m=4 #  número de restricciones (distintas de las de signo)\n",
    "\n",
    "c=matrix(QQ,1,n,[90,100] )  # vector de costos\n",
    "\n",
    "A=matrix(QQ,m,n,[   # coeficientes de las variables x's\n",
    "[1,1],\n",
    "[5,0],\n",
    "[0,4],\n",
    "[6,10]\n",
    "])\n",
    "\n",
    "b=matrix(QQ,m,1,[75,80,60,354])  # vector de la derecha\n",
    "\n",
    "\n",
    "######################################################\n",
    "############### VARIABLES DE HOLGURA  ################\n",
    "\n",
    "\n",
    "h=matrix(ZZ,1,m,[1,-1,-1,1])  # variables de holgura: \n",
    "                            # Pon 1 si va sumando, \n",
    "                            # -1 si va restando y \n",
    "                            # 0 si no hay variable de holgura.\n",
    "\n",
    "\n",
    "\n",
    "\n",
    "####################################################################\n",
    "############  HASTA AQUÍ LOS DATOS  ################################\n",
    "####################################################################\n",
    "\n",
    "\n",
    "load('https://sage.unex.es/501708/simplex2023Auto.sage')\n",
    "#load('https://sage.unex.es/501708/simplex2023AutoREVISED.sage')\n",
    "#load('https://sage.unex.es/501708/simplex2023CompletamenteManual.sage')\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "3e455866",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{rrrr}\n",
       "1 & 0 & \\frac{1}{6} & -\\frac{1}{6} \\\\\n",
       "0 & 0 & -\\frac{5}{12} & \\frac{1}{6} \\\\\n",
       "0 & 0 & \\frac{1}{4} & 0 \\\\\n",
       "0 & -1 & -\\frac{25}{12} & \\frac{5}{6}\n",
       "\\end{array}\\right)</script></html>"
      ],
      "text/latex": [
       "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{rrrr}\n",
       "1 & 0 & \\frac{1}{6} & -\\frac{1}{6} \\\\\n",
       "0 & 0 & -\\frac{5}{12} & \\frac{1}{6} \\\\\n",
       "0 & 0 & \\frac{1}{4} & 0 \\\\\n",
       "0 & -1 & -\\frac{25}{12} & \\frac{5}{6}\n",
       "\\end{array}\\right)$$"
      ],
      "text/plain": [
       "[     1      0    1/6   -1/6]\n",
       "[     0      0  -5/12    1/6]\n",
       "[     0      0    1/4      0]\n",
       "[     0     -1 -25/12    5/6]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "show(BM1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "c296dac0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<html><script type=\"math/tex; mode=display\">\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrr|rr}\n",
       "{Basic} & {x}_{1} & {x}_{2} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {\\color{green}{s}}_{4} & {b} & {b_1} \\\\\n",
       "\\hline\n",
       " {\\color{green}{s}}_{1} & 0 & 0 & 1 & 0 & -\\frac{1}{6} & -\\frac{1}{6} & 26 & -\\frac{4}{3} \\\\\n",
       "{x}_{1} & 1 & 0 & 0 & 0 & \\frac{5}{12} & \\frac{1}{6} & 34 & \\frac{7}{12} \\\\\n",
       "{x}_{2} & 0 & 1 & 0 & 0 & -\\frac{1}{4} & 0 & 15 & -\\frac{1}{4} \\\\\n",
       "{\\color{green}{s}}_{2} & 0 & 0 & 0 & 1 & \\frac{25}{12} & \\frac{5}{6} & 90 & \\frac{23}{12} \\\\\n",
       "\\hline\n",
       " {Z_{ind}} & 0 & 0 & 0 & 0 & -\\frac{25}{2} & -15 & 4560 & \\frac{55}{2}\n",
       "\\end{array}\\right)</script></html>"
      ],
      "text/latex": [
       "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrr|rr}\n",
       "{Basic} & {x}_{1} & {x}_{2} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {\\color{green}{s}}_{4} & {b} & {b_1} \\\\\n",
       "\\hline\n",
       " {\\color{green}{s}}_{1} & 0 & 0 & 1 & 0 & -\\frac{1}{6} & -\\frac{1}{6} & 26 & -\\frac{4}{3} \\\\\n",
       "{x}_{1} & 1 & 0 & 0 & 0 & \\frac{5}{12} & \\frac{1}{6} & 34 & \\frac{7}{12} \\\\\n",
       "{x}_{2} & 0 & 1 & 0 & 0 & -\\frac{1}{4} & 0 & 15 & -\\frac{1}{4} \\\\\n",
       "{\\color{green}{s}}_{2} & 0 & 0 & 0 & 1 & \\frac{25}{12} & \\frac{5}{6} & 90 & \\frac{23}{12} \\\\\n",
       "\\hline\n",
       " {Z_{ind}} & 0 & 0 & 0 & 0 & -\\frac{25}{2} & -15 & 4560 & \\frac{55}{2}\n",
       "\\end{array}\\right)$$"
      ],
      "text/plain": [
       "[    B|   x1    x2    s1    s2    s3    s4|  rhs  rhs1]\n",
       "[-----+-----------------------------------+-----------]\n",
       "[   s1|    0     0     1     0  -1/6  -1/6|   26  -4/3]\n",
       "[   x1|    1     0     0     0  5/12   1/6|   34  7/12]\n",
       "[   x2|    0     1     0     0  -1/4     0|   15  -1/4]\n",
       "[   s2|    0     0     0     1 25/12   5/6|   90 23/12]\n",
       "[-----+-----------------------------------+-----------]\n",
       "[    Z|    0     0     0     0 -25/2   -15| 4560  55/2]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "bp=matrix(QQ,m,1,[-1,1,-1,1]); param1b(bp) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b79e6d44",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "SageMath 9.5",
   "language": "sage",
   "name": "sagemath"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
