{
"cells": [
{
"cell_type": "code",
"execution_count": 115,
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"text/html": [
"\n",
" \n",
" "
],
"text/plain": [
""
]
},
"execution_count": 115,
"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}{lcrcrcrcl}\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} \\\\\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} \\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} \\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} \\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} \\geq \\mspace{-6mu}&\\mspace{-6mu} 15 \\\\\n",
"\\end{array} \\\\\n",
"x_{1}, x_{2}, x_{3} \\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}}27250$$"
],
"text/plain": [
"27250"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(15,\\,25,\\,65\\right)$$"
],
"text/plain": [
"(15, 25, 65)"
]
},
"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}}{===================================}$$"
],
"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} & {\\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 & 1 & 0 & 0 & 0 & 0 & 400 \\\\\n",
"{\\color{green}{s}}_{2} & 5 & 4 & 5 & 0 & 1 & 0 & 0 & 0 & 500 \\\\\n",
"{\\color{green}{s}}_{3} & 2 & 3 & 3 & 0 & 0 & 1 & 0 & 0 & 300 \\\\\n",
"{\\color{red}{t}}_{4} & 1 & 0 & 0 & 0 & 0 & 0 & -1 & 1 & 15 \\\\\n",
"\\hline\n",
" {W_{ind}} & -1 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 15\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 s1 s2 s3 s4 t4|rhs]\n",
"[---+-------------------------------+---]\n",
"[ s1| 4 3 4 1 0 0 0 0|400]\n",
"[ s2| 5 4 5 0 1 0 0 0|500]\n",
"[ s3| 2 3 3 0 0 1 0 0|300]\n",
"[ t4| 1 0 0 0 0 0 -1 1| 15]\n",
"[---+-------------------------------+---]\n",
"[ W| -1 0 0 0 0 0 1 0| 15]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"tipo='max' # max o min\n",
"\n",
"n=3 # 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] ) # vector de costos\n",
"\n",
"A=matrix(QQ,m,n,[ # coeficientes de las variables x's\n",
"[4,3,4],\n",
"[5,4,5],\n",
"[2,3,3],\n",
"[1,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=(4,5,6,8) # 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": 132,
"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} & {\\color{red}{t}}_{4} & {b} \\\\\n",
"\\hline\n",
" {\\color{green}{s}}_{1} & 0 & 3 & 4 & 1 & 0 & 0 & 4 & -4 & 340 \\\\\n",
"{\\color{green}{s}}_{2} & 0 & 4 & 5 & 0 & 1 & 0 & 5 & -5 & 425 \\\\\n",
"{\\color{green}{s}}_{3} & 0 & 3 & 3 & 0 & 0 & 1 & 2 & -2 & 270 \\\\\n",
"{x}_{1} & 1 & 0 & 0 & 0 & 0 & 0 & -1 & 1 & 15 \\\\\n",
"\\hline\n",
" {W_{ind}} & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 s1 s2 s3 s4 t4|rhs]\n",
"[---+-------------------------------+---]\n",
"[ s1| 0 3 4 1 0 0 4 -4|340]\n",
"[ s2| 0 4 5 0 1 0 5 -5|425]\n",
"[ s3| 0 3 3 0 0 1 2 -2|270]\n",
"[ x1| 1 0 0 0 0 0 -1 1| 15]\n",
"[---+-------------------------------+---]\n",
"[ W| 0 0 0 0 0 0 0 1| 0]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"cambio(4,1)"
]
},
{
"cell_type": "code",
"execution_count": 133,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{rrrr}\n",
"1 & 0 & 0 & -4 \\\\\n",
"0 & 1 & 0 & -5 \\\\\n",
"0 & 0 & 1 & -2 \\\\\n",
"0 & 0 & 0 & 1\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ 1 0 0 -4]\n",
"[ 0 1 0 -5]\n",
"[ 0 0 1 -2]\n",
"[ 0 0 0 1]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"show(BM1)"
]
},
{
"cell_type": "code",
"execution_count": 118,
"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} & {\\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 & 1 & 0 & 0 & 4 & 340 \\\\\n",
"{\\color{green}{s}}_{2} & 0 & 4 & 5 & 0 & 1 & 0 & 5 & 425 \\\\\n",
"{\\color{green}{s}}_{3} & 0 & 3 & 3 & 0 & 0 & 1 & 2 & 270 \\\\\n",
"{x}_{1} & 1 & 0 & 0 & 0 & 0 & 0 & -1 & 15 \\\\\n",
"\\hline\n",
" {Z_{ind}} & 0 & 225 & 275 & 0 & 0 & 0 & 250 & 3750\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 s1 s2 s3 s4| rhs]\n",
"[----+----------------------------------+----]\n",
"[ s1| 0 3 4 1 0 0 4| 340]\n",
"[ s2| 0 4 5 0 1 0 5| 425]\n",
"[ s3| 0 3 3 0 0 1 2| 270]\n",
"[ x1| 1 0 0 0 0 0 -1| 15]\n",
"[----+----------------------------------+----]\n",
"[ Z| 0 225 275 0 0 0 250|3750]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"tt=[0,0,0,0];faseII(0,tt)"
]
},
{
"cell_type": "code",
"execution_count": 119,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[85.000]\n",
"[85.000]\n",
"[90.000]\n",
"[ NO]"
]
},
"execution_count": 119,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cocientes(3)\n"
]
},
{
"cell_type": "code",
"execution_count": 120,
"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} & {\\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{1}{4} & 0 & 0 & 1 & 85 \\\\\n",
"{\\color{green}{s}}_{2} & 0 & \\frac{1}{4} & 0 & -\\frac{5}{4} & 1 & 0 & 0 & 0 \\\\\n",
"{\\color{green}{s}}_{3} & 0 & \\frac{3}{4} & 0 & -\\frac{3}{4} & 0 & 1 & -1 & 15 \\\\\n",
"{x}_{1} & 1 & 0 & 0 & 0 & 0 & 0 & -1 & 15 \\\\\n",
"\\hline\n",
" {Z_{ind}} & 0 & \\frac{75}{4} & 0 & -\\frac{275}{4} & 0 & 0 & -25 & 27125\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 s1 s2 s3 s4| rhs]\n",
"[------+------------------------------------------------+------]\n",
"[ x3| 0 3/4 1 1/4 0 0 1| 85]\n",
"[ s2| 0 1/4 0 -5/4 1 0 0| 0]\n",
"[ s3| 0 3/4 0 -3/4 0 1 -1| 15]\n",
"[ x1| 1 0 0 0 0 0 -1| 15]\n",
"[------+------------------------------------------------+------]\n",
"[ Z| 0 75/4 0 -275/4 0 0 -25| 27125]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"cambio(1,3)"
]
},
{
"cell_type": "code",
"execution_count": 121,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{rrrr}\n",
"\\frac{1}{4} & 0 & 0 & -1 \\\\\n",
"-\\frac{5}{4} & 1 & 0 & 0 \\\\\n",
"-\\frac{3}{4} & 0 & 1 & 1 \\\\\n",
"0 & 0 & 0 & 1\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ 1/4 0 0 -1]\n",
"[-5/4 1 0 0]\n",
"[-3/4 0 1 1]\n",
"[ 0 0 0 1]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{rrrr}\n",
"\\frac{1}{4} & 0 & 0 & 0 \\\\\n",
"-\\frac{5}{4} & 1 & 0 & 0 \\\\\n",
"-\\frac{3}{4} & 0 & 1 & 0 \\\\\n",
"0 & 0 & 0 & 1\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ 1/4 0 0 0]\n",
"[-5/4 1 0 0]\n",
"[-3/4 0 1 0]\n",
"[ 0 0 0 1]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"show(BM1); show(P)"
]
},
{
"cell_type": "code",
"execution_count": 122,
"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} & {\\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 & 4 & -3 & 0 & 1 & 85 \\\\\n",
"{x}_{2} & 0 & 1 & 0 & -5 & 4 & 0 & 0 & 0 \\\\\n",
"{\\color{green}{s}}_{3} & 0 & 0 & 0 & 3 & -3 & 1 & -1 & 15 \\\\\n",
"{x}_{1} & 1 & 0 & 0 & 0 & 0 & 0 & -1 & 15 \\\\\n",
"\\hline\n",
" {Z_{ind}} & 0 & 0 & 0 & 25 & -75 & 0 & -25 & 27125\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 s1 s2 s3 s4| rhs]\n",
"[-----+-----------------------------------------+-----]\n",
"[ x3| 0 0 1 4 -3 0 1| 85]\n",
"[ x2| 0 1 0 -5 4 0 0| 0]\n",
"[ s3| 0 0 0 3 -3 1 -1| 15]\n",
"[ x1| 1 0 0 0 0 0 -1| 15]\n",
"[-----+-----------------------------------------+-----]\n",
"[ Z| 0 0 0 25 -75 0 -25|27125]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"cambio(2,2)"
]
},
{
"cell_type": "code",
"execution_count": 123,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{rrrr}\n",
"4 & -3 & 0 & -1 \\\\\n",
"-5 & 4 & 0 & 0 \\\\\n",
"3 & -3 & 1 & 1 \\\\\n",
"0 & 0 & 0 & 1\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ 4 -3 0 -1]\n",
"[-5 4 0 0]\n",
"[ 3 -3 1 1]\n",
"[ 0 0 0 1]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{rrrr}\n",
"1 & -3 & 0 & 0 \\\\\n",
"0 & 4 & 0 & 0 \\\\\n",
"0 & -3 & 1 & 0 \\\\\n",
"0 & 0 & 0 & 1\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ 1 -3 0 0]\n",
"[ 0 4 0 0]\n",
"[ 0 -3 1 0]\n",
"[ 0 0 0 1]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"show(BM1);show(P)"
]
},
{
"cell_type": "code",
"execution_count": 124,
"metadata": {
"scrolled": true
},
"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} & {\\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 & 1 & -\\frac{4}{3} & \\frac{7}{3} & 65 \\\\\n",
"{x}_{2} & 0 & 1 & 0 & 0 & -1 & \\frac{5}{3} & -\\frac{5}{3} & 25 \\\\\n",
"{\\color{green}{s}}_{1} & 0 & 0 & 0 & 1 & -1 & \\frac{1}{3} & -\\frac{1}{3} & 5 \\\\\n",
"{x}_{1} & 1 & 0 & 0 & 0 & 0 & 0 & -1 & 15 \\\\\n",
"\\hline\n",
" {Z_{ind}} & 0 & 0 & 0 & 0 & -50 & -\\frac{25}{3} & -\\frac{50}{3} & 27250\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 s1 s2 s3 s4| rhs]\n",
"[-----+-----------------------------------------+-----]\n",
"[ x3| 0 0 1 0 1 -4/3 7/3| 65]\n",
"[ x2| 0 1 0 0 -1 5/3 -5/3| 25]\n",
"[ s1| 0 0 0 1 -1 1/3 -1/3| 5]\n",
"[ x1| 1 0 0 0 0 0 -1| 15]\n",
"[-----+-----------------------------------------+-----]\n",
"[ Z| 0 0 0 0 -50 -25/3 -50/3|27250]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"cambio(3,4)"
]
},
{
"cell_type": "code",
"execution_count": 125,
"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": 126,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r}\n",
"1 \\\\\n",
"-1 \\\\\n",
"-1 \\\\\n",
"0\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ 1]\n",
"[-1]\n",
"[-1]\n",
"[ 0]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"bp=matrix(QQ,m,1,[0,1,0,0]);bpprima=BM1*bp;show(bpprima)"
]
},
{
"cell_type": "code",
"execution_count": 127,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r}\n",
"50\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[50]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"show(cB*bpprima)"
]
},
{
"cell_type": "code",
"execution_count": 128,
"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} & {\\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 & 1 & 0 & -1 & 2 & 70 \\\\\n",
"{x}_{2} & 0 & 1 & 0 & -1 & 0 & \\frac{4}{3} & -\\frac{4}{3} & 20 \\\\\n",
"{\\color{green}{s}}_{2} & 0 & 0 & 0 & -1 & 1 & -\\frac{1}{3} & \\frac{1}{3} & -5 \\\\\n",
"{x}_{1} & 1 & 0 & 0 & 0 & 0 & 0 & -1 & 15 \\\\\n",
"\\hline\n",
" {Z_{ind}} & 0 & 0 & 0 & -50 & 0 & -25 & 0 & 27500\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 s1 s2 s3 s4| rhs]\n",
"[-----+-----------------------------------------+-----]\n",
"[ x3| 0 0 1 1 0 -1 2| 70]\n",
"[ x2| 0 1 0 -1 0 4/3 -4/3| 20]\n",
"[ s2| 0 0 0 -1 1 -1/3 1/3| -5]\n",
"[ x1| 1 0 0 0 0 0 -1| 15]\n",
"[-----+-----------------------------------------+-----]\n",
"[ Z| 0 0 0 -50 0 -25 0|27500]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"cambio(3,5)"
]
},
{
"cell_type": "code",
"execution_count": 129,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{rrrr}\n",
"1 & 0 & -1 & -2 \\\\\n",
"-1 & 0 & \\frac{4}{3} & \\frac{4}{3} \\\\\n",
"-1 & 1 & -\\frac{1}{3} & -\\frac{1}{3} \\\\\n",
"0 & 0 & 0 & 1\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ 1 0 -1 -2]\n",
"[ -1 0 4/3 4/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": 130,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r}\n",
"0 \\\\\n",
"0 \\\\\n",
"1 \\\\\n",
"0\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[0]\n",
"[0]\n",
"[1]\n",
"[0]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"bpprimaprima=BM1*bp;show(bpprimaprima)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "SageMath 9.5",
"language": "sage",
"name": "sagemath"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.2"
}
},
"nbformat": 4,
"nbformat_minor": 4
}