{
"cells": [
{
"cell_type": "code",
"execution_count": 16,
"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}}{\\ \\ \\ 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"
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}4$$"
],
"text/plain": [
"4"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"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",
"############ HASTA AQUÍ LOS DATOS ################################\n",
"####################################################################\n",
"\n",
"\n",
"\n",
"\n",
"\n",
"load('https://sage.unex.es/501708/simplex2023ManualRevisada.sage')\n"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{rr|rr}\n",
"{Basic} & {b} & {Col\\ Entr} & {Cocientes} \\\\\n",
"{\\color{red}{t}}_{1} & 6 & 1 & 6.0000 \\\\\n",
"{\\color{red}{t}}_{2} & 8 & 3 & 2.6667 \\\\\n",
"{\\color{red}{t}}_{3} & 6 & 1 & 6.0000 \\\\\n",
"{\\color{red}{t}}_{4} & 20 & 5 & 4.0000\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B rhs| Ent Coc]\n",
"[ t1 6| 1 6.0000]\n",
"[ t2 8| 3 2.6667]\n",
"[ t3 6| 1 6.0000]\n",
"[ t4 20| 5 4.0000]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"cocientes(4)"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" \n",
" Matriz Inversa\n"
]
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrr|r}\n",
"{Basic} & {\\color{red}{t}}_{1} & {x}_{4} & {\\color{red}{t}}_{3} & {\\color{red}{t}}_{4} & {b} \\\\\n",
"\\hline\n",
" {\\color{red}{t}}_{1} & 1 & -\\frac{1}{3} & 0 & 0 & \\frac{10}{3} \\\\\n",
"{x}_{4} & 0 & \\frac{1}{3} & 0 & 0 & \\frac{8}{3} \\\\\n",
"{\\color{red}{t}}_{3} & 0 & -\\frac{1}{3} & 1 & 0 & \\frac{10}{3} \\\\\n",
"{\\color{red}{t}}_{4} & 0 & -\\frac{5}{3} & 0 & 1 & \\frac{20}{3} \\\\\n",
"\\hline\n",
" {\\pi_B} & 1 & -\\frac{7}{3} & 1 & 1 & \\frac{40}{3}\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| t1 x4 t3 t4| rhs]\n",
"[----+-------------------+----]\n",
"[ t1| 1 -1/3 0 0|10/3]\n",
"[ x4| 0 1/3 0 0| 8/3]\n",
"[ t3| 0 -1/3 1 0|10/3]\n",
"[ t4| 0 -5/3 0 1|20/3]\n",
"[----+-------------------+----]\n",
"[ WPI| 1 -7/3 1 1|40/3]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Fila Indicadora\n"
]
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{rrrrrrrrrr}\n",
"{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} \\\\\n",
"\\hline\n",
" -\\frac{8}{3} & -\\frac{14}{3} & -4 & 0 & -\\frac{4}{3} & -\\frac{2}{3} & 0 & \\frac{10}{3} & 0 & 0\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ x1 x2 x3 x4 x5 x6 t1 t2 t3 t4]\n",
"[-----------------------------------------------------------]\n",
"[ -8/3 -14/3 -4 0 -4/3 -2/3 0 10/3 0 0]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" \n"
]
}
],
"source": [
"cambio(2,4)"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{rr|rr}\n",
"{Basic} & {b} & {Col\\ Entr} & {Cocientes} \\\\\n",
"{\\color{red}{t}}_{1} & \\frac{10}{3} & \\frac{2}{3} & 5.0000 \\\\\n",
"{x}_{4} & \\frac{8}{3} & \\frac{1}{3} & 8.0000 \\\\\n",
"{\\color{red}{t}}_{3} & \\frac{10}{3} & \\frac{5}{3} & 2.0000 \\\\\n",
"{\\color{red}{t}}_{4} & \\frac{20}{3} & \\frac{7}{3} & 2.8571\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B rhs| Ent Coc]\n",
"[ t1 10/3| 2/3 5.0000]\n",
"[ x4 8/3| 1/3 8.0000]\n",
"[ t3 10/3| 5/3 2.0000]\n",
"[ t4 20/3| 7/3 2.8571]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"cocientes(2)"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" \n",
" Matriz Inversa\n"
]
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrr|r}\n",
"{Basic} & {\\color{red}{t}}_{1} & {x}_{4} & {x}_{2} & {\\color{red}{t}}_{4} & {b} \\\\\n",
"\\hline\n",
" {\\color{red}{t}}_{1} & 1 & -\\frac{1}{5} & -\\frac{2}{5} & 0 & 2 \\\\\n",
"{x}_{4} & 0 & \\frac{2}{5} & -\\frac{1}{5} & 0 & 2 \\\\\n",
"{x}_{2} & 0 & -\\frac{1}{5} & \\frac{3}{5} & 0 & 2 \\\\\n",
"{\\color{red}{t}}_{4} & 0 & -\\frac{6}{5} & -\\frac{7}{5} & 1 & 2 \\\\\n",
"\\hline\n",
" {\\pi_B} & 1 & -\\frac{7}{5} & -\\frac{9}{5} & 1 & 4\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| t1 x4 x2 t4| rhs]\n",
"[----+-------------------+----]\n",
"[ t1| 1 -1/5 -2/5 0| 2]\n",
"[ x4| 0 2/5 -1/5 0| 2]\n",
"[ x2| 0 -1/5 3/5 0| 2]\n",
"[ t4| 0 -6/5 -7/5 1| 2]\n",
"[----+-------------------+----]\n",
"[ WPI| 1 -7/5 -9/5 1| 4]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Fila Indicadora\n"
]
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{rrrrrrrrrr}\n",
"{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} \\\\\n",
"\\hline\n",
" -\\frac{4}{5} & 0 & -\\frac{6}{5} & 0 & -\\frac{2}{5} & -\\frac{8}{5} & 0 & \\frac{12}{5} & \\frac{14}{5} & 0\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ x1 x2 x3 x4 x5 x6 t1 t2 t3 t4]\n",
"[-------------------------------------------------]\n",
"[-4/5 0 -6/5 0 -2/5 -8/5 0 12/5 14/5 0]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" \n"
]
}
],
"source": [
"cambio(3,2)"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{rr|rr}\n",
"{Basic} & {b} & {Col\\ Entr} & {Cocientes} \\\\\n",
"{\\color{red}{t}}_{1} & 2 & \\frac{4}{5} & 2.5000 \\\\\n",
"{x}_{4} & 2 & \\frac{2}{5} & 5.0000 \\\\\n",
"{x}_{2} & 2 & -\\frac{1}{5} & \\mathit{NO} \\\\\n",
"{\\color{red}{t}}_{4} & 2 & \\frac{4}{5} & 2.5000\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B rhs| Ent Coc]\n",
"[ t1 2| 4/5 2.5000]\n",
"[ x4 2| 2/5 5.0000]\n",
"[ x2 2| -1/5 NO]\n",
"[ t4 2| 4/5 2.5000]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"cocientes(6)"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" \n",
" Matriz Inversa\n"
]
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrr|r}\n",
"{Basic} & {x}_{6} & {x}_{4} & {x}_{2} & {\\color{red}{t}}_{4} & {b} \\\\\n",
"\\hline\n",
" {x}_{6} & \\frac{5}{4} & -\\frac{1}{4} & -\\frac{1}{2} & 0 & \\frac{5}{2} \\\\\n",
"{x}_{4} & -\\frac{1}{2} & \\frac{1}{2} & 0 & 0 & 1 \\\\\n",
"{x}_{2} & \\frac{1}{4} & -\\frac{1}{4} & \\frac{1}{2} & 0 & \\frac{5}{2} \\\\\n",
"{\\color{red}{t}}_{4} & -1 & -1 & -1 & 1 & 0 \\\\\n",
"\\hline\n",
" {\\pi_B} & -1 & -1 & -1 & 1 & 0\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x6 x4 x2 t4| rhs]\n",
"[----+-------------------+----]\n",
"[ x6| 5/4 -1/4 -1/2 0| 5/2]\n",
"[ x4|-1/2 1/2 0 0| 1]\n",
"[ x2| 1/4 -1/4 1/2 0| 5/2]\n",
"[ t4| -1 -1 -1 1| 0]\n",
"[----+-------------------+----]\n",
"[ WPI| -1 -1 -1 1| 0]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Fila Indicadora\n"
]
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{rrrrrrrrrr}\n",
"{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} \\\\\n",
"\\hline\n",
" 0 & 0 & 0 & 0 & 0 & 0 & 2 & 2 & 2 & 0\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[x1 x2 x3 x4 x5 x6 t1 t2 t3 t4]\n",
"[-----------------------------]\n",
"[ 0 0 0 0 0 0 2 2 2 0]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" \n"
]
}
],
"source": [
"cambio(1,6)"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {},
"outputs": [
{
"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"
}
],
"source": [
"cuadroI()"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {},
"outputs": [
{
"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",
" {W_{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",
"[ W| -5 0 -3/2 0 7/2 0| 93]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"nnart=1; tt=[0,0,0,1]; faseII(nnart,tt)"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{rr|rr}\n",
"{Basic} & {b} & {Col\\ Entr} & {Cocientes} \\\\\n",
"{x}_{6} & \\frac{5}{2} & \\frac{1}{4} & 10.000 \\\\\n",
"{x}_{4} & 1 & \\frac{1}{2} & 2.0000 \\\\\n",
"{x}_{2} & \\frac{5}{2} & \\frac{1}{4} & 10.000\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B rhs| Ent Coc]\n",
"[ x6 5/2| 1/4 10.000]\n",
"[ x4 1| 1/2 2.0000]\n",
"[ x2 5/2| 1/4 10.000]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"cocientes(5)"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" \n",
" Matriz Inversa\n"
]
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrr|r}\n",
"{Basic} & {x}_{6} & {x}_{5} & {x}_{2} & {b} \\\\\n",
"\\hline\n",
" {x}_{6} & \\frac{3}{2} & -\\frac{1}{2} & -\\frac{1}{2} & 2 \\\\\n",
"{x}_{5} & -1 & 1 & 0 & 2 \\\\\n",
"{x}_{2} & \\frac{1}{2} & -\\frac{1}{2} & \\frac{1}{2} & 2 \\\\\n",
"\\hline\n",
" {\\pi_B} & 11 & 5 & -1 & 100\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x6 x5 x2| rhs]\n",
"[----+--------------+----]\n",
"[ x6| 3/2 -1/2 -1/2| 2]\n",
"[ x5| -1 1 0| 2]\n",
"[ x2| 1/2 -1/2 1/2| 2]\n",
"[----+--------------+----]\n",
"[ ZPI| 11 5 -1| 100]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Fila Indicadora\n"
]
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{rrrrrr}\n",
"{x}_{1} & {x}_{2} & {x}_{3} & {x}_{4} & {x}_{5} & {x}_{6} \\\\\n",
"\\hline\n",
" -5 & 0 & 2 & -7 & 0 & 0\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[x1 x2 x3 x4 x5 x6]\n",
"[-----------------]\n",
"[-5 0 2 -7 0 0]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" \n"
]
}
],
"source": [
"cambio(2,5)"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{rr|rr}\n",
"{Basic} & {b} & {Col\\ Entr} & {Cocientes} \\\\\n",
"{x}_{6} & 2 & 1 & 2.0000 \\\\\n",
"{x}_{5} & 2 & -1 & \\mathit{NO} \\\\\n",
"{x}_{2} & 2 & 1 & 2.0000\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B rhs| Ent Coc]\n",
"[ x6 2| 1 2.0000]\n",
"[ x5 2| -1 NO]\n",
"[ x2 2| 1 2.0000]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"cocientes(3)"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" \n",
" Matriz Inversa\n"
]
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrr|r}\n",
"{Basic} & {x}_{3} & {x}_{5} & {x}_{2} & {b} \\\\\n",
"\\hline\n",
" {x}_{3} & \\frac{3}{2} & -\\frac{1}{2} & -\\frac{1}{2} & 2 \\\\\n",
"{x}_{5} & \\frac{1}{2} & \\frac{1}{2} & -\\frac{1}{2} & 4 \\\\\n",
"{x}_{2} & -1 & 0 & 1 & 0 \\\\\n",
"\\hline\n",
" {\\pi_B} & 14 & 4 & -2 & 104\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x3 x5 x2| rhs]\n",
"[----+--------------+----]\n",
"[ x3| 3/2 -1/2 -1/2| 2]\n",
"[ x5| 1/2 1/2 -1/2| 4]\n",
"[ x2| -1 0 1| 0]\n",
"[----+--------------+----]\n",
"[ ZPI| 14 4 -2| 104]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Fila Indicadora\n"
]
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{rrrrrr}\n",
"{x}_{1} & {x}_{2} & {x}_{3} & {x}_{4} & {x}_{5} & {x}_{6} \\\\\n",
"\\hline\n",
" -6 & 0 & 0 & -6 & 0 & -2\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[x1 x2 x3 x4 x5 x6]\n",
"[-----------------]\n",
"[-6 0 0 -6 0 -2]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" \n"
]
}
],
"source": [
"cambio(1,3)"
]
},
{
"cell_type": "code",
"execution_count": 29,
"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",
" {W_{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",
"[ W| -6 0 0 -6 0 -2| 104]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"cuadroII()"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrrr|r}\n",
"{Basic} & {x}_{1} & {x}_{2} & {x}_{3} & {x}_{4} & {x}_{5} & {x}_{6} & {\\color{green}{s}}_{4} & {b} \\\\\n",
"\\hline\n",
" {x}_{3} & \\frac{1}{2} & 0 & 1 & -\\frac{1}{2} & 0 & 1 & 0 & 2 \\\\\n",
"{x}_{5} & \\frac{1}{2} & 0 & 0 & \\frac{3}{2} & 1 & 1 & 0 & 4 \\\\\n",
"{x}_{2} & 0 & 1 & 0 & 0 & 0 & -1 & 0 & 0 \\\\\n",
"{\\color{green}{s}}_{4} & -3 & 0 & 0 & -2 & 0 & 0 & 1 & -5 \\\\\n",
"\\hline\n",
" {Z_{ind}} & -6 & 0 & 0 & -6 & 0 & -2 & 0 & 104\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 x4 x5 x6 s4| rhs]\n",
"[----+----------------------------------+----]\n",
"[ x3| 1/2 0 1 -1/2 0 1 0| 2]\n",
"[ x5| 1/2 0 0 3/2 1 1 0| 4]\n",
"[ x2| 0 1 0 0 0 -1 0| 0]\n",
"[ s4| -3 0 0 -2 0 0 1| -5]\n",
"[----+----------------------------------+----]\n",
"[ Z| -6 0 0 -6 0 -2 0| 104]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"v=matrix(QQ,1,n,[1,2,3,4,5,6]); R=21; añade(v,R)"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrrr}\n",
"{Basic} & {x}_{1} & {x}_{2} & {x}_{3} & {x}_{4} & {x}_{5} & {x}_{6} & {\\color{green}{s}}_{4} \\\\\n",
"\\hline\n",
" {\\color{green}{s}}_{4} & -3 & 0 & 0 & -2 & 0 & 0 & 1 \\\\\n",
"\\hline\n",
" {Z_{ind}} & -6 & 0 & 0 & -6 & 0 & -2 & 0 \\\\\n",
"\\hline\n",
" {Cocientes} & 2.0000 & \\mathit{NO} & \\mathit{NO} & 3.0000 & \\mathit{NO} & \\mathit{NO} & \\mathit{NO}\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 x4 x5 x6 s4]\n",
"[------+------------------------------------------------]\n",
"[ s4| -3 0 0 -2 0 0 1]\n",
"[------+------------------------------------------------]\n",
"[ Z| -6 0 0 -6 0 -2 0]\n",
"[------+------------------------------------------------]\n",
"[ Coc|2.0000 NO NO 3.0000 NO NO NO]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"cocientesD(4)"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" \n",
" Matriz Inversa\n"
]
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrr|r}\n",
"{Basic} & {x}_{3} & {x}_{5} & {x}_{2} & {x}_{1} & {b} \\\\\n",
"\\hline\n",
" {x}_{3} & \\frac{2}{3} & -\\frac{2}{3} & -\\frac{1}{6} & \\frac{1}{6} & \\frac{7}{6} \\\\\n",
"{x}_{5} & -\\frac{1}{3} & \\frac{1}{3} & -\\frac{1}{6} & \\frac{1}{6} & \\frac{19}{6} \\\\\n",
"{x}_{2} & -1 & 0 & 1 & 0 & 0 \\\\\n",
"{x}_{1} & \\frac{5}{3} & \\frac{1}{3} & -\\frac{2}{3} & -\\frac{1}{3} & \\frac{5}{3} \\\\\n",
"\\hline\n",
" {\\pi_B} & 4 & 2 & 2 & 2 & 94\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x3 x5 x2 x1| rhs]\n",
"[----+-------------------+----]\n",
"[ x3| 2/3 -2/3 -1/6 1/6| 7/6]\n",
"[ x5|-1/3 1/3 -1/6 1/6|19/6]\n",
"[ x2| -1 0 1 0| 0]\n",
"[ x1| 5/3 1/3 -2/3 -1/3| 5/3]\n",
"[----+-------------------+----]\n",
"[ ZPI| 4 2 2 2| 94]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Fila Indicadora\n"
]
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{rrrrrrr}\n",
"{x}_{1} & {x}_{2} & {x}_{3} & {x}_{4} & {x}_{5} & {x}_{6} & {\\color{green}{s}}_{4} \\\\\n",
"\\hline\n",
" 0 & 0 & 0 & -2 & 0 & -2 & -2\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[x1 x2 x3 x4 x5 x6 s4]\n",
"[--------------------]\n",
"[ 0 0 0 -2 0 -2 -2]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
" \n"
]
}
],
"source": [
"cambio(4,1)"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrrr|r}\n",
"{Basic} & {x}_{1} & {x}_{2} & {x}_{3} & {x}_{4} & {x}_{5} & {x}_{6} & {\\color{green}{s}}_{4} & {b} \\\\\n",
"\\hline\n",
" {x}_{3} & 0 & 0 & 1 & -\\frac{5}{6} & 0 & 1 & \\frac{1}{6} & \\frac{7}{6} \\\\\n",
"{x}_{5} & 0 & 0 & 0 & \\frac{7}{6} & 1 & 1 & \\frac{1}{6} & \\frac{19}{6} \\\\\n",
"{x}_{2} & 0 & 1 & 0 & 0 & 0 & -1 & 0 & 0 \\\\\n",
"{x}_{1} & 1 & 0 & 0 & \\frac{2}{3} & 0 & 0 & -\\frac{1}{3} & \\frac{5}{3} \\\\\n",
"\\hline\n",
" {W_{ind}} & 0 & 0 & 0 & -2 & 0 & -2 & -2 & 94\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 x4 x5 x6 s4| rhs]\n",
"[----+----------------------------------+----]\n",
"[ x3| 0 0 1 -5/6 0 1 1/6| 7/6]\n",
"[ x5| 0 0 0 7/6 1 1 1/6|19/6]\n",
"[ x2| 0 1 0 0 0 -1 0| 0]\n",
"[ x1| 1 0 0 2/3 0 0 -1/3| 5/3]\n",
"[----+----------------------------------+----]\n",
"[ W| 0 0 0 -2 0 -2 -2| 94]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"cuadroII()"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [],
"source": [
"#b1p=matrix(QQ,m,1,[0,1,0,0]); b2p=matrix(QQ,m,1,[1,0,0,0]);param2b(b1p,b2p)"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrrr|r}\n",
"{Basic} & {x}_{1} & {x}_{2} & {x}_{3} & {x}_{4} & {x}_{5} & {x}_{6} & {\\color{green}{s}}_{4} & {b} \\\\\n",
"\\hline\n",
" {x}_{3} & 0 & 0 & 1 & -\\frac{5}{6} & 0 & 1 & \\frac{1}{6} & \\frac{7}{6} \\\\\n",
"{x}_{5} & 0 & 0 & 0 & \\frac{7}{6} & 1 & 1 & \\frac{1}{6} & \\frac{19}{6} \\\\\n",
"{x}_{2} & 0 & 1 & 0 & 0 & 0 & -1 & 0 & 0 \\\\\n",
"{x}_{1} & 1 & 0 & 0 & \\frac{2}{3} & 0 & 0 & -\\frac{1}{3} & \\frac{5}{3} \\\\\n",
"\\hline\n",
" {Z_{ind}} & 0 & 0 & 0 & -2 & 0 & -2 & -2 & 94 \\\\\n",
"{Z{1p}} & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\\\\n",
"{Z{2p}} & 0 & 0 & 0 & -\\frac{2}{3} & 0 & 0 & \\frac{1}{3} & \\frac{5}{3}\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 x4 x5 x6 s4| rhs]\n",
"[----+----------------------------------+----]\n",
"[ x3| 0 0 1 -5/6 0 1 1/6| 7/6]\n",
"[ x5| 0 0 0 7/6 1 1 1/6|19/6]\n",
"[ x2| 0 1 0 0 0 -1 0| 0]\n",
"[ x1| 1 0 0 2/3 0 0 -1/3| 5/3]\n",
"[----+----------------------------------+----]\n",
"[ Z| 0 0 0 -2 0 -2 -2| 94]\n",
"[ Z1p| 0 0 0 0 0 1 0| 0]\n",
"[ Z2p| 0 0 0 -2/3 0 0 1/3| 5/3]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"c1p=matrix(QQ,1,nvar,[0,1,0,0,0,0,0]); c2p=matrix(QQ,1,nvar,[1,0,0,0,0,0,0]);param2c(c1p,c2p)"
]
}
],
"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
}