{
"cells": [
{
"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}{lcrcrcl}\n",
" \\max \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} 220 x_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 200 x_{2} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\\\\n",
" \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\frac{5}{2} x_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 3 x_{2} \\mspace{-6mu}&\\mspace{-6mu} \\leq \\mspace{-6mu}&\\mspace{-6mu} 4500 \\\\\n",
" \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} 3 x_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} \\frac{3}{5} x_{2} \\mspace{-6mu}&\\mspace{-6mu} \\leq \\mspace{-6mu}&\\mspace{-6mu} 3400 \\\\\n",
" \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} 14 x_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 10 x_{2} \\mspace{-6mu}&\\mspace{-6mu} \\leq \\mspace{-6mu}&\\mspace{-6mu} 20000 \\\\\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} 1700 \\\\\n",
" \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} x_{1} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\geq \\mspace{-6mu}&\\mspace{-6mu} 600 \\\\\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": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\frac{5900000}{17}$$"
],
"text/plain": [
"5900000/17"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\frac{15000}{17},\\,\\frac{13000}{17}\\right)$$"
],
"text/plain": [
"(15000/17, 13000/17)"
]
},
"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}{lcrcrcrcrcrcl}\n",
" \\min \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} 4500 y_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 3400 y_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 20000 y_{3} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 1700 y_{4} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 600 y_{5} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\\\\n",
" \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\frac{5}{2} y_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 3 y_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 14 y_{3} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} y_{4} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} y_{5} \\mspace{-6mu}&\\mspace{-6mu} \\geq \\mspace{-6mu}&\\mspace{-6mu} 220 \\\\\n",
" \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} 3 y_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} \\frac{3}{5} y_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 10 y_{3} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} y_{4} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\geq \\mspace{-6mu}&\\mspace{-6mu} 200 \\\\\n",
"\\end{array} \\\\\n",
"y_{1} \\geq 0,\\ y_{2} \\geq 0,\\ y_{3} \\geq 0,\\ y_{4} \\geq 0,\\ y_{5} \\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{5900000}{17}$$"
],
"text/plain": [
"5900000/17"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\frac{600}{17},\\,0,\\,\\frac{160}{17},\\,0,\\,0\\right)$$"
],
"text/plain": [
"(600/17, 0, 160/17, 0, 0)"
]
},
"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|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{green}{s}}_{5} & {\\color{red}{t}}_{5} & {b} \\\\\n",
"\\hline\n",
" {\\color{green}{s}}_{1} & \\frac{5}{2} & 3 & 1 & 0 & 0 & 0 & 0 & 0 & 4500 \\\\\n",
"{\\color{green}{s}}_{2} & 3 & \\frac{3}{5} & 0 & 1 & 0 & 0 & 0 & 0 & 3400 \\\\\n",
"{\\color{green}{s}}_{3} & 14 & 10 & 0 & 0 & 1 & 0 & 0 & 0 & 20000 \\\\\n",
"{\\color{green}{s}}_{4} & 1 & 1 & 0 & 0 & 0 & 1 & 0 & 0 & 1700 \\\\\n",
"{\\color{red}{t}}_{5} & 1 & 0 & 0 & 0 & 0 & 0 & -1 & 1 & 600 \\\\\n",
"\\hline\n",
" {W_{ind}} & -1 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 600\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 s1 s2 s3 s4 s5 t5| rhs]\n",
"[-----+-----------------------------------------------+-----]\n",
"[ s1| 5/2 3 1 0 0 0 0 0| 4500]\n",
"[ s2| 3 3/5 0 1 0 0 0 0| 3400]\n",
"[ s3| 14 10 0 0 1 0 0 0|20000]\n",
"[ s4| 1 1 0 0 0 1 0 0| 1700]\n",
"[ t5| 1 0 0 0 0 0 -1 1| 600]\n",
"[-----+-----------------------------------------------+-----]\n",
"[ W| -1 0 0 0 0 0 1 0| 600]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"cambio( 5 , 1 )\n"
]
},
{
"data": {
"text/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{green}{s}}_{5} & {\\color{red}{t}}_{5} & {b} \\\\\n",
"\\hline\n",
" {\\color{green}{s}}_{1} & 0 & 3 & 1 & 0 & 0 & 0 & \\frac{5}{2} & -\\frac{5}{2} & 3000 \\\\\n",
"{\\color{green}{s}}_{2} & 0 & \\frac{3}{5} & 0 & 1 & 0 & 0 & 3 & -3 & 1600 \\\\\n",
"{\\color{green}{s}}_{3} & 0 & 10 & 0 & 0 & 1 & 0 & 14 & -14 & 11600 \\\\\n",
"{\\color{green}{s}}_{4} & 0 & 1 & 0 & 0 & 0 & 1 & 1 & -1 & 1100 \\\\\n",
"{x}_{1} & 1 & 0 & 0 & 0 & 0 & 0 & -1 & 1 & 600 \\\\\n",
"\\hline\n",
" {W_{ind}} & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 s1 s2 s3 s4 s5 t5| rhs]\n",
"[-----+-----------------------------------------------+-----]\n",
"[ s1| 0 3 1 0 0 0 5/2 -5/2| 3000]\n",
"[ s2| 0 3/5 0 1 0 0 3 -3| 1600]\n",
"[ s3| 0 10 0 0 1 0 14 -14|11600]\n",
"[ s4| 0 1 0 0 0 1 1 -1| 1100]\n",
"[ x1| 1 0 0 0 0 0 -1 1| 600]\n",
"[-----+-----------------------------------------------+-----]\n",
"[ W| 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|rrrrrrr|r}\n",
"{Basic} & {x}_{1} & {x}_{2} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {\\color{green}{s}}_{4} & {\\color{green}{s}}_{5} & {b} \\\\\n",
"\\hline\n",
" {\\color{green}{s}}_{1} & 0 & 3 & 1 & 0 & 0 & 0 & \\frac{5}{2} & 3000 \\\\\n",
"{\\color{green}{s}}_{2} & 0 & \\frac{3}{5} & 0 & 1 & 0 & 0 & 3 & 1600 \\\\\n",
"{\\color{green}{s}}_{3} & 0 & 10 & 0 & 0 & 1 & 0 & 14 & 11600 \\\\\n",
"{\\color{green}{s}}_{4} & 0 & 1 & 0 & 0 & 0 & 1 & 1 & 1100 \\\\\n",
"{x}_{1} & 1 & 0 & 0 & 0 & 0 & 0 & -1 & 600 \\\\\n",
"\\hline\n",
" {Z_{ind}} & 0 & 200 & 0 & 0 & 0 & 0 & 220 & 132000\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 s1 s2 s3 s4 s5| rhs]\n",
"[------+------------------------------------------------+------]\n",
"[ s1| 0 3 1 0 0 0 5/2| 3000]\n",
"[ s2| 0 3/5 0 1 0 0 3| 1600]\n",
"[ s3| 0 10 0 0 1 0 14| 11600]\n",
"[ s4| 0 1 0 0 0 1 1| 1100]\n",
"[ x1| 1 0 0 0 0 0 -1| 600]\n",
"[------+------------------------------------------------+------]\n",
"[ Z| 0 200 0 0 0 0 220|132000]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"cambio( 2 , 7 )\n"
]
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrrr|r}\n",
"{Basic} & {x}_{1} & {x}_{2} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {\\color{green}{s}}_{4} & {\\color{green}{s}}_{5} & {b} \\\\\n",
"\\hline\n",
" {\\color{green}{s}}_{1} & 0 & \\frac{5}{2} & 1 & -\\frac{5}{6} & 0 & 0 & 0 & \\frac{5000}{3} \\\\\n",
"{\\color{green}{s}}_{5} & 0 & \\frac{1}{5} & 0 & \\frac{1}{3} & 0 & 0 & 1 & \\frac{1600}{3} \\\\\n",
"{\\color{green}{s}}_{3} & 0 & \\frac{36}{5} & 0 & -\\frac{14}{3} & 1 & 0 & 0 & \\frac{12400}{3} \\\\\n",
"{\\color{green}{s}}_{4} & 0 & \\frac{4}{5} & 0 & -\\frac{1}{3} & 0 & 1 & 0 & \\frac{1700}{3} \\\\\n",
"{x}_{1} & 1 & \\frac{1}{5} & 0 & \\frac{1}{3} & 0 & 0 & 0 & \\frac{3400}{3} \\\\\n",
"\\hline\n",
" {Z_{ind}} & 0 & 156 & 0 & -\\frac{220}{3} & 0 & 0 & 0 & \\frac{748000}{3}\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 s1 s2 s3 s4 s5| rhs]\n",
"[--------+--------------------------------------------------------------+--------]\n",
"[ s1| 0 5/2 1 -5/6 0 0 0| 5000/3]\n",
"[ s5| 0 1/5 0 1/3 0 0 1| 1600/3]\n",
"[ s3| 0 36/5 0 -14/3 1 0 0| 12400/3]\n",
"[ s4| 0 4/5 0 -1/3 0 1 0| 1700/3]\n",
"[ x1| 1 1/5 0 1/3 0 0 0| 3400/3]\n",
"[--------+--------------------------------------------------------------+--------]\n",
"[ Z| 0 156 0 -220/3 0 0 0|748000/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|rrrrrrr|r}\n",
"{Basic} & {x}_{1} & {x}_{2} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {\\color{green}{s}}_{4} & {\\color{green}{s}}_{5} & {b} \\\\\n",
"\\hline\n",
" {\\color{green}{s}}_{1} & 0 & 0 & 1 & \\frac{85}{108} & -\\frac{25}{72} & 0 & 0 & \\frac{6250}{27} \\\\\n",
"{\\color{green}{s}}_{5} & 0 & 0 & 0 & \\frac{25}{54} & -\\frac{1}{36} & 0 & 1 & \\frac{11300}{27} \\\\\n",
"{x}_{2} & 0 & 1 & 0 & -\\frac{35}{54} & \\frac{5}{36} & 0 & 0 & \\frac{15500}{27} \\\\\n",
"{\\color{green}{s}}_{4} & 0 & 0 & 0 & \\frac{5}{27} & -\\frac{1}{9} & 1 & 0 & \\frac{2900}{27} \\\\\n",
"{x}_{1} & 1 & 0 & 0 & \\frac{25}{54} & -\\frac{1}{36} & 0 & 0 & \\frac{27500}{27} \\\\\n",
"\\hline\n",
" {Z_{ind}} & 0 & 0 & 0 & \\frac{250}{9} & -\\frac{65}{3} & 0 & 0 & \\frac{3050000}{9}\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 s1 s2 s3 s4 s5| rhs]\n",
"[---------+---------------------------------------------------------------------+---------]\n",
"[ s1| 0 0 1 85/108 -25/72 0 0| 6250/27]\n",
"[ s5| 0 0 0 25/54 -1/36 0 1| 11300/27]\n",
"[ x2| 0 1 0 -35/54 5/36 0 0| 15500/27]\n",
"[ s4| 0 0 0 5/27 -1/9 1 0| 2900/27]\n",
"[ x1| 1 0 0 25/54 -1/36 0 0| 27500/27]\n",
"[---------+---------------------------------------------------------------------+---------]\n",
"[ Z| 0 0 0 250/9 -65/3 0 0|3050000/9]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"cambio( 1 , 4 )\n"
]
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrrr|r}\n",
"{Basic} & {x}_{1} & {x}_{2} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {\\color{green}{s}}_{4} & {\\color{green}{s}}_{5} & {b} \\\\\n",
"\\hline\n",
" {\\color{green}{s}}_{2} & 0 & 0 & \\frac{108}{85} & 1 & -\\frac{15}{34} & 0 & 0 & \\frac{5000}{17} \\\\\n",
"{\\color{green}{s}}_{5} & 0 & 0 & -\\frac{10}{17} & 0 & \\frac{3}{17} & 0 & 1 & \\frac{4800}{17} \\\\\n",
"{x}_{2} & 0 & 1 & \\frac{14}{17} & 0 & -\\frac{5}{34} & 0 & 0 & \\frac{13000}{17} \\\\\n",
"{\\color{green}{s}}_{4} & 0 & 0 & -\\frac{4}{17} & 0 & -\\frac{1}{34} & 1 & 0 & \\frac{900}{17} \\\\\n",
"{x}_{1} & 1 & 0 & -\\frac{10}{17} & 0 & \\frac{3}{17} & 0 & 0 & \\frac{15000}{17} \\\\\n",
"\\hline\n",
" {Z_{ind}} & 0 & 0 & -\\frac{600}{17} & 0 & -\\frac{160}{17} & 0 & 0 & \\frac{5900000}{17}\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 s1 s2 s3 s4 s5| rhs]\n",
"[----------+----------------------------------------------------------------------------+----------]\n",
"[ s2| 0 0 108/85 1 -15/34 0 0| 5000/17]\n",
"[ s5| 0 0 -10/17 0 3/17 0 1| 4800/17]\n",
"[ x2| 0 1 14/17 0 -5/34 0 0| 13000/17]\n",
"[ s4| 0 0 -4/17 0 -1/34 1 0| 900/17]\n",
"[ x1| 1 0 -10/17 0 3/17 0 0| 15000/17]\n",
"[----------+----------------------------------------------------------------------------+----------]\n",
"[ Z| 0 0 -600/17 0 -160/17 0 0|5900000/17]"
]
},
"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=5 # número de restricciones (distintas de las de signo)\n",
"\n",
"c=matrix(QQ,1,n,[220,200] ) # vector de costos\n",
"\n",
"A=matrix(QQ,m,n,[ # coeficientes de las variables x's\n",
"[2.5,3],\n",
"[3,0.6],\n",
"[14,10],\n",
"[1,1],\n",
"[1,0]\n",
"])\n",
"\n",
"b=matrix(QQ,m,1,[4500,3400,20000,1700,600]) # vector de la derecha\n",
"\n",
"\n",
"h=matrix(ZZ,1,m,[1,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",
"load('https://sage.unex.es/501708/simplex2023Auto.sage')\n",
"#load('https://sage.unex.es/501708/simplex2023Manual.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": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{rrrrrrr}\n",
"\\frac{1}{5} & -\\frac{3}{10} & 0 & -\\frac{3}{10} & -1 & -\\frac{13}{20} & 0 \\\\\n",
"0 & \\frac{1}{4} & 0 & -\\frac{1}{4} & 0 & -\\frac{1}{8} & -1 \\\\\n",
"-\\frac{3}{5} & \\frac{11}{40} & 1 & -\\frac{19}{40} & 0 & \\frac{61}{80} & 0 \\\\\n",
"0 & 0 & 0 & 1 & 0 & 0 & 0 \\\\\n",
"\\frac{1}{5} & -\\frac{3}{10} & 0 & -\\frac{3}{10} & 0 & -\\frac{13}{20} & 0 \\\\\n",
"0 & 0 & 0 & 0 & 0 & 1 & 0 \\\\\n",
"0 & \\frac{1}{4} & 0 & -\\frac{1}{4} & 0 & -\\frac{1}{8} & 0\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ 1/5 -3/10 0 -3/10 -1 -13/20 0]\n",
"[ 0 1/4 0 -1/4 0 -1/8 -1]\n",
"[ -3/5 11/40 1 -19/40 0 61/80 0]\n",
"[ 0 0 0 1 0 0 0]\n",
"[ 1/5 -3/10 0 -3/10 0 -13/20 0]\n",
"[ 0 0 0 0 0 1 0]\n",
"[ 0 1/4 0 -1/4 0 -1/8 0]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"show(BM1)"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[108/85]\n",
"[-10/17]\n",
"[ 14/17]\n",
"[ -4/17]\n",
"[-10/17]"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"bp=matrix(QQ,m,1,[1,0,0,0,0]); BM1*bp "
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrrr|rr}\n",
"{Basic} & {x}_{1} & {x}_{2} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {\\color{green}{s}}_{4} & {\\color{green}{s}}_{5} & {b} & {b_1} \\\\\n",
"\\hline\n",
" {\\color{green}{s}}_{2} & 0 & 0 & \\frac{108}{85} & 1 & -\\frac{15}{34} & 0 & 0 & \\frac{5000}{17} & \\frac{108}{85} \\\\\n",
"{\\color{green}{s}}_{5} & 0 & 0 & -\\frac{10}{17} & 0 & \\frac{3}{17} & 0 & 1 & \\frac{4800}{17} & -\\frac{10}{17} \\\\\n",
"{x}_{2} & 0 & 1 & \\frac{14}{17} & 0 & -\\frac{5}{34} & 0 & 0 & \\frac{13000}{17} & \\frac{14}{17} \\\\\n",
"{\\color{green}{s}}_{4} & 0 & 0 & -\\frac{4}{17} & 0 & -\\frac{1}{34} & 1 & 0 & \\frac{900}{17} & -\\frac{4}{17} \\\\\n",
"{x}_{1} & 1 & 0 & -\\frac{10}{17} & 0 & \\frac{3}{17} & 0 & 0 & \\frac{15000}{17} & -\\frac{10}{17} \\\\\n",
"\\hline\n",
" {Z_{ind}} & 0 & 0 & -\\frac{600}{17} & 0 & -\\frac{160}{17} & 0 & 0 & \\frac{5900000}{17} & \\frac{600}{17}\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 s1 s2 s3 s4 s5| rhs rhs1]\n",
"[----------+----------------------------------------------------------------------------+---------------------]\n",
"[ s2| 0 0 108/85 1 -15/34 0 0| 5000/17 108/85]\n",
"[ s5| 0 0 -10/17 0 3/17 0 1| 4800/17 -10/17]\n",
"[ x2| 0 1 14/17 0 -5/34 0 0| 13000/17 14/17]\n",
"[ s4| 0 0 -4/17 0 -1/34 1 0| 900/17 -4/17]\n",
"[ x1| 1 0 -10/17 0 3/17 0 0| 15000/17 -10/17]\n",
"[----------+----------------------------------------------------------------------------+---------------------]\n",
"[ Z| 0 0 -600/17 0 -160/17 0 0|5900000/17 600/17]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"param1b(bp)"
]
}
],
"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
}