{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "9bc055d8",
"metadata": {
"scrolled": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"/usr/lib/python3/dist-packages/sage/misc/remote_file.py:46: DeprecationWarning: ssl.SSLContext() without protocol argument is deprecated.\n",
" content = urlopen(req, timeout=1, context=SSLContext())\n",
"/usr/lib/python3/dist-packages/sage/misc/remote_file.py:46: DeprecationWarning: ssl.PROTOCOL_TLS is deprecated\n",
" content = urlopen(req, timeout=1, context=SSLContext())\n"
]
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}{===================================}$$"
],
"text/plain": [
"ry"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}{===================================}$$"
],
"text/plain": [
"ry"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\begin{array}{l}\n",
"\\begin{array}{lcrcrcrcrcrcrcl}\n",
" \\max \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} 10 x_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 14 x_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 12 x_{3} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 18 x_{4} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 20 x_{5} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 16 x_{6} \\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} + \\mspace{-6mu}&\\mspace{-6mu} x_{3} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} x_{4} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} x_{5} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} x_{6} \\mspace{-6mu}&\\mspace{-6mu} = \\mspace{-6mu}&\\mspace{-6mu} 6 \\\\\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} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 3 x_{4} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 2 x_{5} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} x_{6} \\mspace{-6mu}&\\mspace{-6mu} = \\mspace{-6mu}&\\mspace{-6mu} 8 \\\\\n",
" \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} x_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 2 x_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} x_{3} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} x_{4} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} x_{5} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} = \\mspace{-6mu}&\\mspace{-6mu} 6 \\\\\n",
" \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} 3 x_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 4 x_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 2 x_{3} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 5 x_{4} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 4 x_{5} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 2 x_{6} \\mspace{-6mu}&\\mspace{-6mu} = \\mspace{-6mu}&\\mspace{-6mu} 20 \\\\\n",
"\\end{array} \\\\\n",
"x_{1}, x_{2}, x_{3}, x_{4}, x_{5}, x_{6} \\geq 0\n",
"\\end{array}$$"
],
"text/plain": [
"LP problem (use 'view(...)' or '%display typeset' for details)"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}104$$"
],
"text/plain": [
"104"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(0,\\,0,\\,2,\\,0,\\,4,\\,0\\right)$$"
],
"text/plain": [
"(0, 0, 2, 0, 4, 0)"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}{===================================}$$"
],
"text/plain": [
"ry"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}{===================================}$$"
],
"text/plain": [
"ry"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}{}$$"
],
"text/plain": [
"salto"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}{\\texttt{El dual es:}}$$"
],
"text/plain": [
"dual"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}{===================================}$$"
],
"text/plain": [
"ry"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/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} 6 y_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 8 y_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 6 y_{3} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 20 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} y_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} y_{3} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 3 y_{4} \\mspace{-6mu}&\\mspace{-6mu} \\geq \\mspace{-6mu}&\\mspace{-6mu} 10 \\\\\n",
" \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} y_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} y_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 2 y_{3} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 4 y_{4} \\mspace{-6mu}&\\mspace{-6mu} \\geq \\mspace{-6mu}&\\mspace{-6mu} 14 \\\\\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} y_{3} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 2 y_{4} \\mspace{-6mu}&\\mspace{-6mu} \\geq \\mspace{-6mu}&\\mspace{-6mu} 12 \\\\\n",
" \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} y_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 3 y_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} y_{3} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 5 y_{4} \\mspace{-6mu}&\\mspace{-6mu} \\geq \\mspace{-6mu}&\\mspace{-6mu} 18 \\\\\n",
" \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} y_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 2 y_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} y_{3} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 4 y_{4} \\mspace{-6mu}&\\mspace{-6mu} \\geq \\mspace{-6mu}&\\mspace{-6mu} 20 \\\\\n",
" \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} y_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} y_{2} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 2 y_{4} \\mspace{-6mu}&\\mspace{-6mu} \\geq \\mspace{-6mu}&\\mspace{-6mu} 16 \\\\\n",
"\\end{array} \\\\\n",
"\n",
"\\end{array}$$"
],
"text/plain": [
"LP problem (use 'view(...)' or '%display typeset' for details)"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}{===================================}$$"
],
"text/plain": [
"ry"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}104$$"
],
"text/plain": [
"104"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(0,\\,-10,\\,-16,\\,14\\right)$$"
],
"text/plain": [
"(0, -10, -16, 14)"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}{}$$"
],
"text/plain": [
"salto"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}{===================================}$$"
],
"text/plain": [
"ry"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}{\\ \\ \\ Fase\\ I}$$"
],
"text/plain": [
"FI"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}{===================================}$$"
],
"text/plain": [
"ry"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrrrrrr|r}\n",
"{Basic} & {x}_{1} & {x}_{2} & {x}_{3} & {x}_{4} & {x}_{5} & {x}_{6} & {\\color{red}{t}}_{1} & {\\color{red}{t}}_{2} & {\\color{red}{t}}_{3} & {\\color{red}{t}}_{4} & {b} \\\\\n",
"\\hline\n",
" {\\color{red}{t}}_{1} & 1 & 1 & 1 & 1 & 1 & 1 & 1 & 0 & 0 & 0 & 6 \\\\\n",
"{\\color{red}{t}}_{2} & 1 & 1 & 0 & 3 & 2 & 1 & 0 & 1 & 0 & 0 & 8 \\\\\n",
"{\\color{red}{t}}_{3} & 1 & 2 & 1 & 1 & 1 & 0 & 0 & 0 & 1 & 0 & 6 \\\\\n",
"{\\color{red}{t}}_{4} & 3 & 4 & 2 & 5 & 4 & 2 & 0 & 0 & 0 & 1 & 20 \\\\\n",
"\\hline\n",
" {W_{ind}} & -6 & -8 & -4 & -10 & -8 & -4 & 0 & 0 & 0 & 0 & 40\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 x4 x5 x6 t1 t2 t3 t4|rhs]\n",
"[---+---------------------------------------+---]\n",
"[ t1| 1 1 1 1 1 1 1 0 0 0| 6]\n",
"[ t2| 1 1 0 3 2 1 0 1 0 0| 8]\n",
"[ t3| 1 2 1 1 1 0 0 0 1 0| 6]\n",
"[ t4| 3 4 2 5 4 2 0 0 0 1| 20]\n",
"[---+---------------------------------------+---]\n",
"[ W| -6 -8 -4 -10 -8 -4 0 0 0 0| 40]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"cambio( 2 , 4 )\n"
]
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrrrrrr|r}\n",
"{Basic} & {x}_{1} & {x}_{2} & {x}_{3} & {x}_{4} & {x}_{5} & {x}_{6} & {\\color{red}{t}}_{1} & {\\color{red}{t}}_{2} & {\\color{red}{t}}_{3} & {\\color{red}{t}}_{4} & {b} \\\\\n",
"\\hline\n",
" {\\color{red}{t}}_{1} & \\frac{2}{3} & \\frac{2}{3} & 1 & 0 & \\frac{1}{3} & \\frac{2}{3} & 1 & -\\frac{1}{3} & 0 & 0 & \\frac{10}{3} \\\\\n",
"{x}_{4} & \\frac{1}{3} & \\frac{1}{3} & 0 & 1 & \\frac{2}{3} & \\frac{1}{3} & 0 & \\frac{1}{3} & 0 & 0 & \\frac{8}{3} \\\\\n",
"{\\color{red}{t}}_{3} & \\frac{2}{3} & \\frac{5}{3} & 1 & 0 & \\frac{1}{3} & -\\frac{1}{3} & 0 & -\\frac{1}{3} & 1 & 0 & \\frac{10}{3} \\\\\n",
"{\\color{red}{t}}_{4} & \\frac{4}{3} & \\frac{7}{3} & 2 & 0 & \\frac{2}{3} & \\frac{1}{3} & 0 & -\\frac{5}{3} & 0 & 1 & \\frac{20}{3} \\\\\n",
"\\hline\n",
" {W_{ind}} & -\\frac{8}{3} & -\\frac{14}{3} & -4 & 0 & -\\frac{4}{3} & -\\frac{2}{3} & 0 & \\frac{10}{3} & 0 & 0 & \\frac{40}{3}\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 x4 x5 x6 t1 t2 t3 t4| rhs]\n",
"[-----+-----------------------------------------------------------+-----]\n",
"[ t1| 2/3 2/3 1 0 1/3 2/3 1 -1/3 0 0| 10/3]\n",
"[ x4| 1/3 1/3 0 1 2/3 1/3 0 1/3 0 0| 8/3]\n",
"[ t3| 2/3 5/3 1 0 1/3 -1/3 0 -1/3 1 0| 10/3]\n",
"[ t4| 4/3 7/3 2 0 2/3 1/3 0 -5/3 0 1| 20/3]\n",
"[-----+-----------------------------------------------------------+-----]\n",
"[ W| -8/3 -14/3 -4 0 -4/3 -2/3 0 10/3 0 0| 40/3]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"cambio( 3 , 2 )\n"
]
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrrrrrr|r}\n",
"{Basic} & {x}_{1} & {x}_{2} & {x}_{3} & {x}_{4} & {x}_{5} & {x}_{6} & {\\color{red}{t}}_{1} & {\\color{red}{t}}_{2} & {\\color{red}{t}}_{3} & {\\color{red}{t}}_{4} & {b} \\\\\n",
"\\hline\n",
" {\\color{red}{t}}_{1} & \\frac{2}{5} & 0 & \\frac{3}{5} & 0 & \\frac{1}{5} & \\frac{4}{5} & 1 & -\\frac{1}{5} & -\\frac{2}{5} & 0 & 2 \\\\\n",
"{x}_{4} & \\frac{1}{5} & 0 & -\\frac{1}{5} & 1 & \\frac{3}{5} & \\frac{2}{5} & 0 & \\frac{2}{5} & -\\frac{1}{5} & 0 & 2 \\\\\n",
"{x}_{2} & \\frac{2}{5} & 1 & \\frac{3}{5} & 0 & \\frac{1}{5} & -\\frac{1}{5} & 0 & -\\frac{1}{5} & \\frac{3}{5} & 0 & 2 \\\\\n",
"{\\color{red}{t}}_{4} & \\frac{2}{5} & 0 & \\frac{3}{5} & 0 & \\frac{1}{5} & \\frac{4}{5} & 0 & -\\frac{6}{5} & -\\frac{7}{5} & 1 & 2 \\\\\n",
"\\hline\n",
" {W_{ind}} & -\\frac{4}{5} & 0 & -\\frac{6}{5} & 0 & -\\frac{2}{5} & -\\frac{8}{5} & 0 & \\frac{12}{5} & \\frac{14}{5} & 0 & 4\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 x4 x5 x6 t1 t2 t3 t4| rhs]\n",
"[----+-------------------------------------------------+----]\n",
"[ t1| 2/5 0 3/5 0 1/5 4/5 1 -1/5 -2/5 0| 2]\n",
"[ x4| 1/5 0 -1/5 1 3/5 2/5 0 2/5 -1/5 0| 2]\n",
"[ x2| 2/5 1 3/5 0 1/5 -1/5 0 -1/5 3/5 0| 2]\n",
"[ t4| 2/5 0 3/5 0 1/5 4/5 0 -6/5 -7/5 1| 2]\n",
"[----+-------------------------------------------------+----]\n",
"[ W|-4/5 0 -6/5 0 -2/5 -8/5 0 12/5 14/5 0| 4]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"cambio( 1 , 6 )\n"
]
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrrrrrr|r}\n",
"{Basic} & {x}_{1} & {x}_{2} & {x}_{3} & {x}_{4} & {x}_{5} & {x}_{6} & {\\color{red}{t}}_{1} & {\\color{red}{t}}_{2} & {\\color{red}{t}}_{3} & {\\color{red}{t}}_{4} & {b} \\\\\n",
"\\hline\n",
" {x}_{6} & \\frac{1}{2} & 0 & \\frac{3}{4} & 0 & \\frac{1}{4} & 1 & \\frac{5}{4} & -\\frac{1}{4} & -\\frac{1}{2} & 0 & \\frac{5}{2} \\\\\n",
"{x}_{4} & 0 & 0 & -\\frac{1}{2} & 1 & \\frac{1}{2} & 0 & -\\frac{1}{2} & \\frac{1}{2} & 0 & 0 & 1 \\\\\n",
"{x}_{2} & \\frac{1}{2} & 1 & \\frac{3}{4} & 0 & \\frac{1}{4} & 0 & \\frac{1}{4} & -\\frac{1}{4} & \\frac{1}{2} & 0 & \\frac{5}{2} \\\\\n",
"{\\color{red}{t}}_{4} & 0 & 0 & 0 & 0 & 0 & 0 & -1 & -1 & -1 & 1 & 0 \\\\\n",
"\\hline\n",
" {W_{ind}} & 0 & 0 & 0 & 0 & 0 & 0 & 2 & 2 & 2 & 0 & 0\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 x4 x5 x6 t1 t2 t3 t4| rhs]\n",
"[----+-------------------------------------------------+----]\n",
"[ x6| 1/2 0 3/4 0 1/4 1 5/4 -1/4 -1/2 0| 5/2]\n",
"[ x4| 0 0 -1/2 1 1/2 0 -1/2 1/2 0 0| 1]\n",
"[ x2| 1/2 1 3/4 0 1/4 0 1/4 -1/4 1/2 0| 5/2]\n",
"[ t4| 0 0 0 0 0 0 -1 -1 -1 1| 0]\n",
"[----+-------------------------------------------------+----]\n",
"[ W| 0 0 0 0 0 0 2 2 2 0| 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": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}{===================================}$$"
],
"text/plain": [
"ry"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}{\\ \\ \\ Fase\\ II}$$"
],
"text/plain": [
"FII"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}{===================================}$$"
],
"text/plain": [
"ry"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrr|r}\n",
"{Basic} & {x}_{1} & {x}_{2} & {x}_{3} & {x}_{4} & {x}_{5} & {x}_{6} & {b} \\\\\n",
"\\hline\n",
" {x}_{6} & \\frac{1}{2} & 0 & \\frac{3}{4} & 0 & \\frac{1}{4} & 1 & \\frac{5}{2} \\\\\n",
"{x}_{4} & 0 & 0 & -\\frac{1}{2} & 1 & \\frac{1}{2} & 0 & 1 \\\\\n",
"{x}_{2} & \\frac{1}{2} & 1 & \\frac{3}{4} & 0 & \\frac{1}{4} & 0 & \\frac{5}{2} \\\\\n",
"\\hline\n",
" {Z_{ind}} & -5 & 0 & -\\frac{3}{2} & 0 & \\frac{7}{2} & 0 & 93\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 x4 x5 x6| rhs]\n",
"[----+-----------------------------+----]\n",
"[ x6| 1/2 0 3/4 0 1/4 1| 5/2]\n",
"[ x4| 0 0 -1/2 1 1/2 0| 1]\n",
"[ x2| 1/2 1 3/4 0 1/4 0| 5/2]\n",
"[----+-----------------------------+----]\n",
"[ Z| -5 0 -3/2 0 7/2 0| 93]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"cambio( 2 , 5 )\n"
]
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrr|r}\n",
"{Basic} & {x}_{1} & {x}_{2} & {x}_{3} & {x}_{4} & {x}_{5} & {x}_{6} & {b} \\\\\n",
"\\hline\n",
" {x}_{6} & \\frac{1}{2} & 0 & 1 & -\\frac{1}{2} & 0 & 1 & 2 \\\\\n",
"{x}_{5} & 0 & 0 & -1 & 2 & 1 & 0 & 2 \\\\\n",
"{x}_{2} & \\frac{1}{2} & 1 & 1 & -\\frac{1}{2} & 0 & 0 & 2 \\\\\n",
"\\hline\n",
" {Z_{ind}} & -5 & 0 & 2 & -7 & 0 & 0 & 100\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 x4 x5 x6| rhs]\n",
"[----+-----------------------------+----]\n",
"[ x6| 1/2 0 1 -1/2 0 1| 2]\n",
"[ x5| 0 0 -1 2 1 0| 2]\n",
"[ x2| 1/2 1 1 -1/2 0 0| 2]\n",
"[----+-----------------------------+----]\n",
"[ Z| -5 0 2 -7 0 0| 100]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"cambio( 1 , 3 )\n"
]
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrr|r}\n",
"{Basic} & {x}_{1} & {x}_{2} & {x}_{3} & {x}_{4} & {x}_{5} & {x}_{6} & {b} \\\\\n",
"\\hline\n",
" {x}_{3} & \\frac{1}{2} & 0 & 1 & -\\frac{1}{2} & 0 & 1 & 2 \\\\\n",
"{x}_{5} & \\frac{1}{2} & 0 & 0 & \\frac{3}{2} & 1 & 1 & 4 \\\\\n",
"{x}_{2} & 0 & 1 & 0 & 0 & 0 & -1 & 0 \\\\\n",
"\\hline\n",
" {Z_{ind}} & -6 & 0 & 0 & -6 & 0 & -2 & 104\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 x4 x5 x6| rhs]\n",
"[----+-----------------------------+----]\n",
"[ x3| 1/2 0 1 -1/2 0 1| 2]\n",
"[ x5| 1/2 0 0 3/2 1 1| 4]\n",
"[ x2| 0 1 0 0 0 -1| 0]\n",
"[----+-----------------------------+----]\n",
"[ Z| -6 0 0 -6 0 -2| 104]"
]
},
"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=6 # 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,[10,14,12,18,20,16] ) # vector de costos\n",
"\n",
"A=matrix(QQ,m,n,[ # coeficientes de las variables x's\n",
"[1,1,1,1,1,1],\n",
"[1,1,0,3,2,1],\n",
"[1,2,1,1,1,0],\n",
"[3,4,2,5,4,2]\n",
"])\n",
"\n",
"b=matrix(QQ,m,1,[6,8,6,20]) # vector de la derecha\n",
"\n",
"\n",
"######################################################\n",
"############### VARIABLES DE HOLGURA ################\n",
"\n",
"\n",
"h=matrix(ZZ,1,m,[0,0,0,0]) # 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",
"\n",
"load('https://sage.unex.es/501708/simplex2023Auto.sage')\n"
]
},
{
"cell_type": "markdown",
"id": "f7f09020",
"metadata": {},
"source": [
"Veamos cómo cambia la solución del problema si cambiamos el coeficiente de costo de dos de sus variables, por ejemplo, la $x_1$ y la $x_2$\n",
"\n",
"Para ello resolvemos el problema doble paramétrico $\n",
"\\mathcal{P(\\lambda,\\mu)}: \\quad max \\;\\; z_{\\lambda}(x)= c^t x + \\lambda c_{1p}^t x + \\mu c_{2p}^t x,\\quad \\text{s.a.:} \\quad Ax=b, \\quad x\\geq 0\n",
"$\n",
"\n",
"para $c_{1p}=(1,0,0,0,0,0)$ y $c_{2p}=(0,1,0,0,0,0)$"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "7c54b7d7",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrr|r}\n",
"{Basic} & {x}_{1} & {x}_{2} & {x}_{3} & {x}_{4} & {x}_{5} & {x}_{6} & {b} \\\\\n",
"\\hline\n",
" {x}_{3} & \\frac{1}{2} & 0 & 1 & -\\frac{1}{2} & 0 & 1 & 2 \\\\\n",
"{x}_{5} & \\frac{1}{2} & 0 & 0 & \\frac{3}{2} & 1 & 1 & 4 \\\\\n",
"{x}_{2} & 0 & 1 & 0 & 0 & 0 & -1 & 0 \\\\\n",
"\\hline\n",
" {Z_{ind}} & -6 & 0 & 0 & -6 & 0 & -2 & 104 \\\\\n",
"{Z{1p}} & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\\\\n",
"{Z{2p}} & 0 & 0 & 0 & 0 & 0 & 1 & 0\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 x4 x5 x6| rhs]\n",
"[----+-----------------------------+----]\n",
"[ x3| 1/2 0 1 -1/2 0 1| 2]\n",
"[ x5| 1/2 0 0 3/2 1 1| 4]\n",
"[ x2| 0 1 0 0 0 -1| 0]\n",
"[----+-----------------------------+----]\n",
"[ Z| -6 0 0 -6 0 -2| 104]\n",
"[ Z1p| 1 0 0 0 0 0| 0]\n",
"[ Z2p| 0 0 0 0 0 1| 0]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"c1p=matrix(QQ,1,n,[1,0,0,0,0,0]); c2p=matrix(QQ,1,n,[0,1,0,0,0,0]) ; param2c(c1p,c2p)"
]
},
{
"cell_type": "markdown",
"id": "7b6d065e",
"metadata": {},
"source": [
"\n",
"¿Para qué valores del parámetro $\\lambda$ es este cuadro óptimo?"
]
},
{
"cell_type": "markdown",
"id": "a66c9c73",
"metadata": {},
"source": [
"Resolvamos el sistema de inecuaciones: \n",
"$$\n",
"-6 + \\lambda \\leq 0 \\\\\n",
"-6 \\leq 0 \\\\\n",
"-2 + \\mu \\leq 0 \n",
"$$\n",
"\n",
"Su solución es $\\lambda\\leq 6.\\;\\mu\\leq 2.$ Por tanto, el cuadro es óptimo para \n",
" esos valores de los parámetros. "
]
},
{
"cell_type": "markdown",
"id": "6688aeff",
"metadata": {},
"source": [
"Si quisiéramos resolver problemas $\\mathcal{P}(\\lambda,\\mu)$ para valores del parámetro $\\lambda$ mayores que 6 o para $\\mu$ mayores que 2, tendríamos que utilizar el método símplex. Por ejemplo, para el primer caso de los dos inmediatamente propuestos:"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "c48a9e2e",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrr|r}\n",
"{Basic} & {x}_{1} & {x}_{2} & {x}_{3} & {x}_{4} & {x}_{5} & {x}_{6} & {b} \\\\\n",
"\\hline\n",
" {x}_{1} & 1 & 0 & 2 & -1 & 0 & 2 & 4 \\\\\n",
"{x}_{5} & 0 & 0 & -1 & 2 & 1 & 0 & 2 \\\\\n",
"{x}_{2} & 0 & 1 & 0 & 0 & 0 & -1 & 0 \\\\\n",
"\\hline\n",
" {Z_{ind}} & 0 & 0 & 12 & -12 & 0 & 10 & 80 \\\\\n",
"{Z{1p}} & 0 & 0 & -2 & 1 & 0 & -2 & 4 \\\\\n",
"{Z{2p}} & 0 & 0 & 0 & 0 & 0 & 1 & 0\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 x4 x5 x6|rhs]\n",
"[---+-----------------------+---]\n",
"[ x1| 1 0 2 -1 0 2| 4]\n",
"[ x5| 0 0 -1 2 1 0| 2]\n",
"[ x2| 0 1 0 0 0 -1| 0]\n",
"[---+-----------------------+---]\n",
"[ Z| 0 0 12 -12 0 10| 80]\n",
"[Z1p| 0 0 -2 1 0 -2| 4]\n",
"[Z2p| 0 0 0 0 0 1| 0]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"cambio(1,1)"
]
},
{
"cell_type": "markdown",
"id": "7baad470",
"metadata": {},
"source": [
"Resolviendo el siguiente sistema de inecuaciones, descubrimos que éste cuadro resuelve el problema paramétrico $\\mathcal{P}(\\lambda)$ si\n",
"$$\n",
"12 -2\\lambda \\leq 0 \\\\\n",
"-12 + \\lambda \\leq 0 \\\\\n",
"10 - 2\\lambda + \\mu \\leq 0 \n",
"$$\n",
"esto es, para los valores de los parámetros $\\lambda$ y $\\mu$ que resuelven dicho sistema, el cuadro anterior es óptimo para $\\mathcal{P}(\\lambda,\\mu).$"
]
},
{
"cell_type": "markdown",
"id": "c75199c6",
"metadata": {},
"source": [
"etc"
]
}
],
"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
}