{
"cells": [
{
"cell_type": "code",
"execution_count": 35,
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" \n",
" "
],
"text/plain": [
""
]
},
"execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from IPython.display import IFrame\n",
"\n",
"# Inserta el nombre del archivo PDF en la siguiente línea\n",
"archivo_pdf = \"Relojes.pdf\"\n",
"\n",
"# Cargar el PDF\n",
"IFrame(archivo_pdf, width=1000, height=1500)\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"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}{lcrcrcrcrcl}\n",
" \\max \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} 250 x_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 225 x_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 275 x_{3} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 230 x_{4} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\\\\n",
" \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} 4 x_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 3 x_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 4 x_{3} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 3 x_{4} \\mspace{-6mu}&\\mspace{-6mu} \\leq \\mspace{-6mu}&\\mspace{-6mu} 400 \\\\\n",
" \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} 5 x_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 4 x_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 5 x_{3} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 4 x_{4} \\mspace{-6mu}&\\mspace{-6mu} \\leq \\mspace{-6mu}&\\mspace{-6mu} 500 \\\\\n",
" \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} 2 x_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 3 x_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 3 x_{3} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 2 x_{4} \\mspace{-6mu}&\\mspace{-6mu} \\leq \\mspace{-6mu}&\\mspace{-6mu} 300 \\\\\n",
" \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} x_{1} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\geq \\mspace{-6mu}&\\mspace{-6mu} 15 \\\\\n",
"\\end{array} \\\\\n",
"x_{1}, x_{2}, x_{3}, x_{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": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\frac{56375}{2}$$"
],
"text/plain": [
"56375/2"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(15,\\,0,\\,0,\\,\\frac{425}{4}\\right)$$"
],
"text/plain": [
"(15, 0, 0, 425/4)"
]
},
"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} 400 y_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 500 y_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 300 y_{3} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 15 y_{4} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\\\\n",
" \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} 4 y_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 5 y_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 2 y_{3} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} y_{4} \\mspace{-6mu}&\\mspace{-6mu} \\geq \\mspace{-6mu}&\\mspace{-6mu} 250 \\\\\n",
" \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} 3 y_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 4 y_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 3 y_{3} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\geq \\mspace{-6mu}&\\mspace{-6mu} 225 \\\\\n",
" \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} 4 y_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 5 y_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 3 y_{3} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\geq \\mspace{-6mu}&\\mspace{-6mu} 275 \\\\\n",
" \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} 3 y_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 4 y_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 2 y_{3} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\geq \\mspace{-6mu}&\\mspace{-6mu} 230 \\\\\n",
"\\end{array} \\\\\n",
"y_{1} \\geq 0,\\ y_{2} \\geq 0,\\ y_{3} \\geq 0,\\ y_{4} \\leq 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}}{===================================}$$"
],
"text/plain": [
"ry"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\frac{56375}{2}$$"
],
"text/plain": [
"56375/2"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(0,\\,\\frac{115}{2},\\,0,\\,-\\frac{75}{2}\\right)$$"
],
"text/plain": [
"(0, 115/2, 0, -75/2)"
]
},
"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|rrrrrrrrr|r}\n",
"{Basic} & {x}_{1} & {x}_{2} & {x}_{3} & {x}_{4} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {\\color{green}{s}}_{4} & {\\color{red}{t}}_{4} & {b} \\\\\n",
"\\hline\n",
" {\\color{green}{s}}_{1} & 4 & 3 & 4 & 3 & 1 & 0 & 0 & 0 & 0 & 400 \\\\\n",
"{\\color{green}{s}}_{2} & 5 & 4 & 5 & 4 & 0 & 1 & 0 & 0 & 0 & 500 \\\\\n",
"{\\color{green}{s}}_{3} & 2 & 3 & 3 & 2 & 0 & 0 & 1 & 0 & 0 & 300 \\\\\n",
"{\\color{red}{t}}_{4} & 1 & 0 & 0 & 0 & 0 & 0 & 0 & -1 & 1 & 15 \\\\\n",
"\\hline\n",
" {W_{ind}} & -1 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 15\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 x4 s1 s2 s3 s4 t4|rhs]\n",
"[---+-----------------------------------+---]\n",
"[ s1| 4 3 4 3 1 0 0 0 0|400]\n",
"[ s2| 5 4 5 4 0 1 0 0 0|500]\n",
"[ s3| 2 3 3 2 0 0 1 0 0|300]\n",
"[ t4| 1 0 0 0 0 0 0 -1 1| 15]\n",
"[---+-----------------------------------+---]\n",
"[ W| -1 0 0 0 0 0 0 1 0| 15]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"cambio( 4 , 1 )\n"
]
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrrrrr|r}\n",
"{Basic} & {x}_{1} & {x}_{2} & {x}_{3} & {x}_{4} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {\\color{green}{s}}_{4} & {\\color{red}{t}}_{4} & {b} \\\\\n",
"\\hline\n",
" {\\color{green}{s}}_{1} & 0 & 3 & 4 & 3 & 1 & 0 & 0 & 4 & -4 & 340 \\\\\n",
"{\\color{green}{s}}_{2} & 0 & 4 & 5 & 4 & 0 & 1 & 0 & 5 & -5 & 425 \\\\\n",
"{\\color{green}{s}}_{3} & 0 & 3 & 3 & 2 & 0 & 0 & 1 & 2 & -2 & 270 \\\\\n",
"{x}_{1} & 1 & 0 & 0 & 0 & 0 & 0 & 0 & -1 & 1 & 15 \\\\\n",
"\\hline\n",
" {W_{ind}} & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 x4 s1 s2 s3 s4 t4|rhs]\n",
"[---+-----------------------------------+---]\n",
"[ s1| 0 3 4 3 1 0 0 4 -4|340]\n",
"[ s2| 0 4 5 4 0 1 0 5 -5|425]\n",
"[ s3| 0 3 3 2 0 0 1 2 -2|270]\n",
"[ x1| 1 0 0 0 0 0 0 -1 1| 15]\n",
"[---+-----------------------------------+---]\n",
"[ W| 0 0 0 0 0 0 0 0 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": [
""
],
"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|rrrrrrrr|r}\n",
"{Basic} & {x}_{1} & {x}_{2} & {x}_{3} & {x}_{4} & {\\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 & 3 & 4 & 3 & 1 & 0 & 0 & 4 & 340 \\\\\n",
"{\\color{green}{s}}_{2} & 0 & 4 & 5 & 4 & 0 & 1 & 0 & 5 & 425 \\\\\n",
"{\\color{green}{s}}_{3} & 0 & 3 & 3 & 2 & 0 & 0 & 1 & 2 & 270 \\\\\n",
"{x}_{1} & 1 & 0 & 0 & 0 & 0 & 0 & 0 & -1 & 15 \\\\\n",
"\\hline\n",
" {Z_{ind}} & 0 & 225 & 275 & 230 & 0 & 0 & 0 & 250 & 3750\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 x4 s1 s2 s3 s4| rhs]\n",
"[----+---------------------------------------+----]\n",
"[ s1| 0 3 4 3 1 0 0 4| 340]\n",
"[ s2| 0 4 5 4 0 1 0 5| 425]\n",
"[ s3| 0 3 3 2 0 0 1 2| 270]\n",
"[ x1| 1 0 0 0 0 0 0 -1| 15]\n",
"[----+---------------------------------------+----]\n",
"[ Z| 0 225 275 230 0 0 0 250|3750]"
]
},
"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|rrrrrrrr|r}\n",
"{Basic} & {x}_{1} & {x}_{2} & {x}_{3} & {x}_{4} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {\\color{green}{s}}_{4} & {b} \\\\\n",
"\\hline\n",
" {x}_{3} & 0 & \\frac{3}{4} & 1 & \\frac{3}{4} & \\frac{1}{4} & 0 & 0 & 1 & 85 \\\\\n",
"{\\color{green}{s}}_{2} & 0 & \\frac{1}{4} & 0 & \\frac{1}{4} & -\\frac{5}{4} & 1 & 0 & 0 & 0 \\\\\n",
"{\\color{green}{s}}_{3} & 0 & \\frac{3}{4} & 0 & -\\frac{1}{4} & -\\frac{3}{4} & 0 & 1 & -1 & 15 \\\\\n",
"{x}_{1} & 1 & 0 & 0 & 0 & 0 & 0 & 0 & -1 & 15 \\\\\n",
"\\hline\n",
" {Z_{ind}} & 0 & \\frac{75}{4} & 0 & \\frac{95}{4} & -\\frac{275}{4} & 0 & 0 & -25 & 27125\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 x4 s1 s2 s3 s4| rhs]\n",
"[------+-------------------------------------------------------+------]\n",
"[ x3| 0 3/4 1 3/4 1/4 0 0 1| 85]\n",
"[ s2| 0 1/4 0 1/4 -5/4 1 0 0| 0]\n",
"[ s3| 0 3/4 0 -1/4 -3/4 0 1 -1| 15]\n",
"[ x1| 1 0 0 0 0 0 0 -1| 15]\n",
"[------+-------------------------------------------------------+------]\n",
"[ Z| 0 75/4 0 95/4 -275/4 0 0 -25| 27125]"
]
},
"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|rrrrrrrr|r}\n",
"{Basic} & {x}_{1} & {x}_{2} & {x}_{3} & {x}_{4} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {\\color{green}{s}}_{4} & {b} \\\\\n",
"\\hline\n",
" {x}_{3} & 0 & 0 & 1 & 0 & 4 & -3 & 0 & 1 & 85 \\\\\n",
"{x}_{4} & 0 & 1 & 0 & 1 & -5 & 4 & 0 & 0 & 0 \\\\\n",
"{\\color{green}{s}}_{3} & 0 & 1 & 0 & 0 & -2 & 1 & 1 & -1 & 15 \\\\\n",
"{x}_{1} & 1 & 0 & 0 & 0 & 0 & 0 & 0 & -1 & 15 \\\\\n",
"\\hline\n",
" {Z_{ind}} & 0 & -5 & 0 & 0 & 50 & -95 & 0 & -25 & 27125\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 x4 s1 s2 s3 s4| rhs]\n",
"[-----+-----------------------------------------------+-----]\n",
"[ x3| 0 0 1 0 4 -3 0 1| 85]\n",
"[ x4| 0 1 0 1 -5 4 0 0| 0]\n",
"[ s3| 0 1 0 0 -2 1 1 -1| 15]\n",
"[ x1| 1 0 0 0 0 0 0 -1| 15]\n",
"[-----+-----------------------------------------------+-----]\n",
"[ Z| 0 -5 0 0 50 -95 0 -25|27125]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"cambio( 1 , 5 )\n"
]
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrrrr|r}\n",
"{Basic} & {x}_{1} & {x}_{2} & {x}_{3} & {x}_{4} & {\\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 & \\frac{1}{4} & 0 & 1 & -\\frac{3}{4} & 0 & \\frac{1}{4} & \\frac{85}{4} \\\\\n",
"{x}_{4} & 0 & 1 & \\frac{5}{4} & 1 & 0 & \\frac{1}{4} & 0 & \\frac{5}{4} & \\frac{425}{4} \\\\\n",
"{\\color{green}{s}}_{3} & 0 & 1 & \\frac{1}{2} & 0 & 0 & -\\frac{1}{2} & 1 & -\\frac{1}{2} & \\frac{115}{2} \\\\\n",
"{x}_{1} & 1 & 0 & 0 & 0 & 0 & 0 & 0 & -1 & 15 \\\\\n",
"\\hline\n",
" {Z_{ind}} & 0 & -5 & -\\frac{25}{2} & 0 & 0 & -\\frac{115}{2} & 0 & -\\frac{75}{2} & \\frac{56375}{2}\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 x4 s1 s2 s3 s4| rhs]\n",
"[-------+---------------------------------------------------------------+-------]\n",
"[ s1| 0 0 1/4 0 1 -3/4 0 1/4| 85/4]\n",
"[ x4| 0 1 5/4 1 0 1/4 0 5/4| 425/4]\n",
"[ s3| 0 1 1/2 0 0 -1/2 1 -1/2| 115/2]\n",
"[ x1| 1 0 0 0 0 0 0 -1| 15]\n",
"[-------+---------------------------------------------------------------+-------]\n",
"[ Z| 0 -5 -25/2 0 0 -115/2 0 -75/2|56375/2]"
]
},
"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=4 # 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,[250,225,275,230] ) # vector de costos\n",
"\n",
"A=matrix(QQ,m,n,[ # coeficientes de las variables x's\n",
"[4,3,4,3],\n",
"[5,4,5,4],\n",
"[2,3,3,2],\n",
"[1,0,0,0]\n",
"])\n",
"\n",
"b=matrix(QQ,m,1,[400,500,300,15]) # 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",
"t=matrix(ZZ,1,m,[0,0 ,0,1]) # variables artificiales: \n",
" # pon 1 si utilizas variable artificial en la fila i-ésima\n",
" # 0 si no utilizas variable artificial en la fila i-ésima\n",
"\n",
"colId=(5,6,7,9) # posición de la matriz identidad\n",
"\n",
"\n",
"####################################################################\n",
"############ HASTA AQUÍ LOS DATOS ################################\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"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{rrrr}\n",
"0 & 1 & -\\frac{4}{3} & -\\frac{7}{3} \\\\\n",
"0 & -1 & \\frac{5}{3} & \\frac{5}{3} \\\\\n",
"1 & -1 & \\frac{1}{3} & \\frac{1}{3} \\\\\n",
"0 & 0 & 0 & 1\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ 0 1 -4/3 -7/3]\n",
"[ 0 -1 5/3 5/3]\n",
"[ 1 -1 1/3 1/3]\n",
"[ 0 0 0 1]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"show(BM1)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"\n",
"Añadimos un nuevo tipo de reloj, R4, $A_4^t=(3,4,2)$ y $c_4=230$\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"\n",
"\n"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{rrrr}\n",
"0 & 1 & -\\frac{4}{3} & -\\frac{7}{3} \\\\\n",
"0 & -1 & \\frac{5}{3} & \\frac{5}{3} \\\\\n",
"1 & -1 & \\frac{1}{3} & \\frac{1}{3} \\\\\n",
"0 & 0 & 0 & 1\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ 0 1 -4/3 -7/3]\n",
"[ 0 -1 5/3 5/3]\n",
"[ 1 -1 1/3 1/3]\n",
"[ 0 0 0 1]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"show(BM1) "
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{rrrr}\n",
"275 & 225 & 0 & 250\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[275 225 0 250]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"show(cB)"
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrrrr|r}\n",
"{Basic} & {x}_{1} & {x}_{2} & {x}_{3} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {\\color{green}{s}}_{4} & {x}_{4} & {b} \\\\\n",
"\\hline\n",
" {x}_{3} & 0 & 0 & 1 & 0 & 1 & -\\frac{4}{3} & \\frac{7}{3} & \\frac{4}{3} & 65 \\\\\n",
"{x}_{2} & 0 & 1 & 0 & 0 & -1 & \\frac{5}{3} & -\\frac{5}{3} & -\\frac{2}{3} & 25 \\\\\n",
"{\\color{green}{s}}_{1} & 0 & 0 & 0 & 1 & -1 & \\frac{1}{3} & -\\frac{1}{3} & -\\frac{1}{3} & 5 \\\\\n",
"{x}_{1} & 1 & 0 & 0 & 0 & 0 & 0 & -1 & 0 & 15 \\\\\n",
"\\hline\n",
" {Z_{ind}} & 0 & 0 & 0 & 0 & -50 & -\\frac{25}{3} & -\\frac{50}{3} & \\frac{40}{3} & 27250\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 s1 s2 s3 s4 x4| rhs]\n",
"[-----+-----------------------------------------------+-----]\n",
"[ x3| 0 0 1 0 1 -4/3 7/3 4/3| 65]\n",
"[ x2| 0 1 0 0 -1 5/3 -5/3 -2/3| 25]\n",
"[ s1| 0 0 0 1 -1 1/3 -1/3 -1/3| 5]\n",
"[ x1| 1 0 0 0 0 0 -1 0| 15]\n",
"[-----+-----------------------------------------------+-----]\n",
"[ Z| 0 0 0 0 -50 -25/3 -50/3 40/3|27250]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"v=matrix(QQ,m,1,[3,4,2,0]); c4=230;añadeVar(v,c4)"
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrrrr|r}\n",
"{Basic} & {x}_{1} & {x}_{2} & {x}_{3} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {\\color{green}{s}}_{4} & {x}_{4} & {b} \\\\\n",
"\\hline\n",
" {x}_{4} & 0 & 0 & \\frac{3}{4} & 0 & \\frac{3}{4} & -1 & \\frac{7}{4} & 1 & \\frac{195}{4} \\\\\n",
"{x}_{2} & 0 & 1 & \\frac{1}{2} & 0 & -\\frac{1}{2} & 1 & -\\frac{1}{2} & 0 & \\frac{115}{2} \\\\\n",
"{\\color{green}{s}}_{1} & 0 & 0 & \\frac{1}{4} & 1 & -\\frac{3}{4} & 0 & \\frac{1}{4} & 0 & \\frac{85}{4} \\\\\n",
"{x}_{1} & 1 & 0 & 0 & 0 & 0 & 0 & -1 & 0 & 15 \\\\\n",
"\\hline\n",
" {Z_{ind}} & 0 & 0 & -10 & 0 & -60 & 5 & -40 & 0 & 27900\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 s1 s2 s3 s4 x4| rhs]\n",
"[-----+-----------------------------------------------+-----]\n",
"[ x4| 0 0 3/4 0 3/4 -1 7/4 1|195/4]\n",
"[ x2| 0 1 1/2 0 -1/2 1 -1/2 0|115/2]\n",
"[ s1| 0 0 1/4 1 -3/4 0 1/4 0| 85/4]\n",
"[ x1| 1 0 0 0 0 0 -1 0| 15]\n",
"[-----+-----------------------------------------------+-----]\n",
"[ Z| 0 0 -10 0 -60 5 -40 0|27900]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"cambio(1,8)"
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrrrr|r}\n",
"{Basic} & {x}_{1} & {x}_{2} & {x}_{3} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {\\color{green}{s}}_{4} & {x}_{4} & {b} \\\\\n",
"\\hline\n",
" {x}_{4} & 0 & 1 & \\frac{5}{4} & 0 & \\frac{1}{4} & 0 & \\frac{5}{4} & 1 & \\frac{425}{4} \\\\\n",
"{\\color{green}{s}}_{3} & 0 & 1 & \\frac{1}{2} & 0 & -\\frac{1}{2} & 1 & -\\frac{1}{2} & 0 & \\frac{115}{2} \\\\\n",
"{\\color{green}{s}}_{1} & 0 & 0 & \\frac{1}{4} & 1 & -\\frac{3}{4} & 0 & \\frac{1}{4} & 0 & \\frac{85}{4} \\\\\n",
"{x}_{1} & 1 & 0 & 0 & 0 & 0 & 0 & -1 & 0 & 15 \\\\\n",
"\\hline\n",
" {Z_{ind}} & 0 & -5 & -\\frac{25}{2} & 0 & -\\frac{115}{2} & 0 & -\\frac{75}{2} & 0 & \\frac{56375}{2}\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 s1 s2 s3 s4 x4| rhs]\n",
"[-------+---------------------------------------------------------------+-------]\n",
"[ x4| 0 1 5/4 0 1/4 0 5/4 1| 425/4]\n",
"[ s3| 0 1 1/2 0 -1/2 1 -1/2 0| 115/2]\n",
"[ s1| 0 0 1/4 1 -3/4 0 1/4 0| 85/4]\n",
"[ x1| 1 0 0 0 0 0 -1 0| 15]\n",
"[-------+---------------------------------------------------------------+-------]\n",
"[ Z| 0 -5 -25/2 0 -115/2 0 -75/2 0|56375/2]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"cambio(2,6)"
]
}
],
"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": 4
}