{ "cells": [ { "cell_type": "code", "execution_count": 15, "metadata": { "scrolled": false }, "outputs": [ { "data": { "text/html": [ "\n", " \n", " " ], "text/plain": [ "" ] }, "execution_count": 15, "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": 16, "metadata": { "scrolled": false }, "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}}{===================================}$$" ], "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": [ "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", "\\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}}27250$$" ], "text/plain": [ "27250" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/latex": [ "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(0,\\,50,\\,\\frac{25}{3},\\,-\\frac{50}{3}\\right)$$" ], "text/plain": [ "(0, 50, 25/3, -50/3)" ] }, "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} & {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" }, { "name": "stdout", "output_type": "stream", "text": [ "cambio( 4 , 1 )\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} & {\\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" }, { "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} & {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" }, { "name": "stdout", "output_type": "stream", "text": [ "cambio( 1 , 3 )\n" ] }, { "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" }, { "name": "stdout", "output_type": "stream", "text": [ "cambio( 2 , 2 )\n" ] }, { "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" }, { "name": "stdout", "output_type": "stream", "text": [ "cambio( 3 , 4 )\n" ] }, { "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" }, { "name": "stdout", "output_type": "stream", "text": [ "El problema es óptimo\n" ] } ], "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": 17, "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": 18, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/latex": [ "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrrr|rr}\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} & {b_1} \\\\\n", "\\hline\n", " {x}_{3} & 0 & 0 & 1 & 0 & 1 & -\\frac{4}{3} & \\frac{7}{3} & 65 & 1 \\\\\n", "{x}_{2} & 0 & 1 & 0 & 0 & -1 & \\frac{5}{3} & -\\frac{5}{3} & 25 & -1 \\\\\n", "{\\color{green}{s}}_{1} & 0 & 0 & 0 & 1 & -1 & \\frac{1}{3} & -\\frac{1}{3} & 5 & -2 \\\\\n", "{x}_{1} & 1 & 0 & 0 & 0 & 0 & 0 & -1 & 15 & 0 \\\\\n", "\\hline\n", " {Z_{ind}} & 0 & 0 & 0 & 0 & -50 & -\\frac{25}{3} & -\\frac{50}{3} & 27250 & 50\n", "\\end{array}\\right)$$" ], "text/plain": [ "[ B| x1 x2 x3 s1 s2 s3 s4| rhs rhs1]\n", "[-----+-----------------------------------------+-----------]\n", "[ x3| 0 0 1 0 1 -4/3 7/3| 65 1]\n", "[ x2| 0 1 0 0 -1 5/3 -5/3| 25 -1]\n", "[ s1| 0 0 0 1 -1 1/3 -1/3| 5 -2]\n", "[ x1| 1 0 0 0 0 0 -1| 15 0]\n", "[-----+-----------------------------------------+-----------]\n", "[ Z| 0 0 0 0 -50 -25/3 -50/3|27250 50]" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "bp1=matrix(QQ,m,1,[-1,1,0,0]); param1b(bp1)" ] }, { "cell_type": "code", "execution_count": 19, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[ NO NO NO NO NO 6.2500 NO]" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cocientesD(1)" ] }, { "cell_type": "code", "execution_count": 20, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/latex": [ "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrrr|rr}\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} & {b_1} \\\\\n", "\\hline\n", " {x}_{3} & 0 & 0 & 1 & 7 & -6 & 1 & 0 & 100 & -13 \\\\\n", "{x}_{2} & 0 & 1 & 0 & -5 & 4 & 0 & 0 & 0 & 9 \\\\\n", "{\\color{green}{s}}_{4} & 0 & 0 & 0 & -3 & 3 & -1 & 1 & -15 & 6 \\\\\n", "{x}_{1} & 1 & 0 & 0 & -3 & 3 & -1 & 0 & 0 & 6 \\\\\n", "\\hline\n", " {Z_{ind}} & 0 & 0 & 0 & -50 & 0 & -25 & 0 & 27500 & -50\n", "\\end{array}\\right)$$" ], "text/plain": [ "[ B| x1 x2 x3 s1 s2 s3 s4| rhs rhs1]\n", "[-----+-----------------------------------------+-----------]\n", "[ x3| 0 0 1 7 -6 1 0| 100 -13]\n", "[ x2| 0 1 0 -5 4 0 0| 0 9]\n", "[ s4| 0 0 0 -3 3 -1 1| -15 6]\n", "[ x1| 1 0 0 -3 3 -1 0| 0 6]\n", "[-----+-----------------------------------------+-----------]\n", "[ Z| 0 0 0 -50 0 -25 0|27500 -50]" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "cambio(3,7)" ] } ], "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 }