{ "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}{lcrcrcrcrcl}\n", " \\max \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} 7 x_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 12 x_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 17 x_{3} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 12 x_{4} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\\\\n", " \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} 3 x_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 6 x_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 7 x_{3} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 7 x_{4} \\mspace{-6mu}&\\mspace{-6mu} \\leq \\mspace{-6mu}&\\mspace{-6mu} 19 \\\\\n", " \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} 6 x_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 7 x_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 5 x_{3} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} x_{4} \\mspace{-6mu}&\\mspace{-6mu} \\leq \\mspace{-6mu}&\\mspace{-6mu} 19 \\\\\n", " \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} 5 x_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 3 x_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 2 x_{3} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 2 x_{4} \\mspace{-6mu}&\\mspace{-6mu} \\leq \\mspace{-6mu}&\\mspace{-6mu} 19 \\\\\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{323}{7}$$" ], "text/plain": [ "323/7" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/latex": [ "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(0,\\,0,\\,\\frac{19}{7},\\,0\\right)$$" ], "text/plain": [ "(0, 0, 19/7, 0)" ] }, "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}{lcrcrcrcl}\n", " \\min \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} 19 y_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 19 y_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 19 y_{3} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\\\\n", " \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} 3 y_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 6 y_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 5 y_{3} \\mspace{-6mu}&\\mspace{-6mu} \\geq \\mspace{-6mu}&\\mspace{-6mu} 7 \\\\\n", " \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} 6 y_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 7 y_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 3 y_{3} \\mspace{-6mu}&\\mspace{-6mu} \\geq \\mspace{-6mu}&\\mspace{-6mu} 12 \\\\\n", " \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} 7 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} \\geq \\mspace{-6mu}&\\mspace{-6mu} 17 \\\\\n", " \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} 7 y_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} y_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 2 y_{3} \\mspace{-6mu}&\\mspace{-6mu} \\geq \\mspace{-6mu}&\\mspace{-6mu} 12 \\\\\n", "\\end{array} \\\\\n", "y_{1}, y_{2}, y_{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}}{===================================}$$" ], "text/plain": [ "ry" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/latex": [ "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\frac{323}{7}$$" ], "text/plain": [ "323/7" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/latex": [ "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\frac{17}{7},\\,0,\\,0\\right)$$" ], "text/plain": [ "(17/7, 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}}\\left(\\begin{array}{r|rrrrrrr|r}\n", "{Basic} & {x}_{1} & {x}_{2} & {x}_{3} & {x}_{4} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {b} \\\\\n", "\\hline\n", " {\\color{green}{s}}_{1} & 3 & 6 & 7 & 7 & 1 & 0 & 0 & 19 \\\\\n", "{\\color{green}{s}}_{2} & 6 & 7 & 5 & 1 & 0 & 1 & 0 & 19 \\\\\n", "{\\color{green}{s}}_{3} & 5 & 3 & 2 & 2 & 0 & 0 & 1 & 19 \\\\\n", "\\hline\n", " {Z_{ind}} & 7 & 12 & 17 & 12 & 0 & 0 & 0 & 0\n", "\\end{array}\\right)$$" ], "text/plain": [ "[ B| x1 x2 x3 x4 s1 s2 s3|rhs]\n", "[---+---------------------------+---]\n", "[ s1| 3 6 7 7 1 0 0| 19]\n", "[ s2| 6 7 5 1 0 1 0| 19]\n", "[ s3| 5 3 2 2 0 0 1| 19]\n", "[---+---------------------------+---]\n", "[ Z| 7 12 17 12 0 0 0| 0]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ " \n", "(Es un problema de tipo maximizar)\n", " \n", "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} & {x}_{4} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {b} \\\\\n", "\\hline\n", " {x}_{3} & \\frac{3}{7} & \\frac{6}{7} & 1 & 1 & \\frac{1}{7} & 0 & 0 & \\frac{19}{7} \\\\\n", "{\\color{green}{s}}_{2} & \\frac{27}{7} & \\frac{19}{7} & 0 & -4 & -\\frac{5}{7} & 1 & 0 & \\frac{38}{7} \\\\\n", "{\\color{green}{s}}_{3} & \\frac{29}{7} & \\frac{9}{7} & 0 & 0 & -\\frac{2}{7} & 0 & 1 & \\frac{95}{7} \\\\\n", "\\hline\n", " {Z_{ind}} & -\\frac{2}{7} & -\\frac{18}{7} & 0 & -5 & -\\frac{17}{7} & 0 & 0 & \\frac{323}{7}\n", "\\end{array}\\right)$$" ], "text/plain": [ "[ B| x1 x2 x3 x4 s1 s2 s3| rhs]\n", "[-----+-----------------------------------------+-----]\n", "[ x3| 3/7 6/7 1 1 1/7 0 0| 19/7]\n", "[ s2| 27/7 19/7 0 -4 -5/7 1 0| 38/7]\n", "[ s3| 29/7 9/7 0 0 -2/7 0 1| 95/7]\n", "[-----+-----------------------------------------+-----]\n", "[ Z| -2/7 -18/7 0 -5 -17/7 0 0|323/7]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "El problema es óptimo\n" ] } ], "source": [ "tipo='max' #max o min\n", "n=4 # número de variables x's\n", "m=3 # número de restricciones (distintas de las de signo)\n", "\n", "\n", "c=matrix(QQ,1,n,[7,12,17,12] ) # vector de costos\n", "\n", "A=matrix(QQ,m,n,[ # coeficientes de las variables x's\n", "[3,6,7,7],\n", "[6,7,5,1],\n", "[5,3,2,2]\n", "])\n", "\n", "b=matrix(QQ,m,1,[19,19,19]) # vector de la derecha\n", "\n", "\n", "\n", "######################################################\n", "############### VARIABLES DE HOLGURA ################\n", "\n", "\n", "h=matrix(ZZ,1,m,[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", "\n", "####################################################################\n", "############ HASTA AQUÍ LOS DATOS ################################\n", "####################################################################\n", "\n", "#load('https://sage.unex.es/501708/simplex2023Auto.sage')\n", "load('https://sage.unex.es/501708/simplex2023Auto_MC.sage')\n", "\n" ] }, { "cell_type": "code", "execution_count": 109, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/latex": [ "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left[1, 2, 3, 4, 5, 6, 7\\right]$$" ], "text/plain": [ "[1, 2, 3, 4, 5, 6, 7]" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ "[5/7, 3/7, 4/7]" ] }, "execution_count": 109, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pardec()" ] }, { "cell_type": "code", "execution_count": 110, "metadata": {}, "outputs": [], "source": [ "#corte(2) # 1" ] }, { "cell_type": "code", "execution_count": 111, "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} & {x}_{4} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {\\color{green}{s}}_{4} & {b} \\\\\n", "\\hline\n", " {x}_{3} & \\frac{3}{7} & \\frac{6}{7} & 1 & 1 & \\frac{1}{7} & 0 & 0 & 0 & \\frac{19}{7} \\\\\n", "{\\color{green}{s}}_{2} & \\frac{27}{7} & \\frac{19}{7} & 0 & -4 & -\\frac{5}{7} & 1 & 0 & 0 & \\frac{38}{7} \\\\\n", "{\\color{green}{s}}_{3} & \\frac{29}{7} & \\frac{9}{7} & 0 & 0 & -\\frac{2}{7} & 0 & 1 & 0 & \\frac{95}{7} \\\\\n", "{\\color{green}{s}}_{4} & -\\frac{3}{28} & -\\frac{3}{14} & 0 & 0 & -\\frac{2}{7} & 0 & 0 & 1 & -\\frac{3}{7} \\\\\n", "\\hline\n", " {Z_{ind}} & -\\frac{2}{7} & -\\frac{18}{7} & 0 & -5 & -\\frac{17}{7} & 0 & 0 & 0 & \\frac{323}{7}\n", "\\end{array}\\right)$$" ], "text/plain": [ "[ B| x1 x2 x3 x4 s1 s2 s3 s4| rhs]\n", "[-----+-----------------------------------------------+-----]\n", "[ x3| 3/7 6/7 1 1 1/7 0 0 0| 19/7]\n", "[ s2| 27/7 19/7 0 -4 -5/7 1 0 0| 38/7]\n", "[ s3| 29/7 9/7 0 0 -2/7 0 1 0| 95/7]\n", "[ s4|-3/28 -3/14 0 0 -2/7 0 0 1| -3/7]\n", "[-----+-----------------------------------------------+-----]\n", "[ Z| -2/7 -18/7 0 -5 -17/7 0 0 0|323/7]" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "v=matrix(QQ,1,nv,[-3/28,-3/14,0,0,-2/7,0,0] ); R=-3/7;\n", "añadeRes(v,R)" ] }, { "cell_type": "code", "execution_count": 112, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[2.6667 12.000 NO NO 8.5000 NO NO NO]" ] }, "execution_count": 112, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cocientesD(4)" ] }, { "cell_type": "code", "execution_count": 113, "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} & {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 & 1 & -1 & 0 & 0 & 4 & 1 \\\\\n", "{\\color{green}{s}}_{2} & 0 & -5 & 0 & -4 & -11 & 1 & 0 & 36 & -10 \\\\\n", "{\\color{green}{s}}_{3} & 0 & -7 & 0 & 0 & -\\frac{34}{3} & 0 & 1 & \\frac{116}{3} & -3 \\\\\n", "{x}_{1} & 1 & 2 & 0 & 0 & \\frac{8}{3} & 0 & 0 & -\\frac{28}{3} & 4 \\\\\n", "\\hline\n", " {Z_{ind}} & 0 & -2 & 0 & -5 & -\\frac{5}{3} & 0 & 0 & -\\frac{8}{3} & 45\n", "\\end{array}\\right)$$" ], "text/plain": [ "[ B| x1 x2 x3 x4 s1 s2 s3 s4| rhs]\n", "[-----+-----------------------------------------------+-----]\n", "[ x3| 0 0 1 1 -1 0 0 4| 1]\n", "[ s2| 0 -5 0 -4 -11 1 0 36| -10]\n", "[ s3| 0 -7 0 0 -34/3 0 1 116/3| -3]\n", "[ x1| 1 2 0 0 8/3 0 0 -28/3| 4]\n", "[-----+-----------------------------------------------+-----]\n", "[ Z| 0 -2 0 -5 -5/3 0 0 -8/3| 45]" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "cambio(4,1)" ] }, { "cell_type": "code", "execution_count": 114, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[ NO 0.28571 NO NO 0.14706 NO NO NO]" ] }, "execution_count": 114, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cocientesD(3)" ] }, { "cell_type": "code", "execution_count": 115, "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} & {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{21}{34} & 1 & 1 & 0 & 0 & -\\frac{3}{34} & \\frac{10}{17} & \\frac{43}{34} \\\\\n", "{\\color{green}{s}}_{2} & 0 & \\frac{61}{34} & 0 & -4 & 0 & 1 & -\\frac{33}{34} & -\\frac{26}{17} & -\\frac{241}{34} \\\\\n", "{\\color{green}{s}}_{1} & 0 & \\frac{21}{34} & 0 & 0 & 1 & 0 & -\\frac{3}{34} & -\\frac{58}{17} & \\frac{9}{34} \\\\\n", "{x}_{1} & 1 & \\frac{6}{17} & 0 & 0 & 0 & 0 & \\frac{4}{17} & -\\frac{4}{17} & \\frac{56}{17} \\\\\n", "\\hline\n", " {Z_{ind}} & 0 & -\\frac{33}{34} & 0 & -5 & 0 & 0 & -\\frac{5}{34} & -\\frac{142}{17} & \\frac{1515}{34}\n", "\\end{array}\\right)$$" ], "text/plain": [ "[ B| x1 x2 x3 x4 s1 s2 s3 s4| rhs]\n", "[-------+---------------------------------------------------------------+-------]\n", "[ x3| 0 21/34 1 1 0 0 -3/34 10/17| 43/34]\n", "[ s2| 0 61/34 0 -4 0 1 -33/34 -26/17|-241/34]\n", "[ s1| 0 21/34 0 0 1 0 -3/34 -58/17| 9/34]\n", "[ x1| 1 6/17 0 0 0 0 4/17 -4/17| 56/17]\n", "[-------+---------------------------------------------------------------+-------]\n", "[ Z| 0 -33/34 0 -5 0 0 -5/34 -142/17|1515/34]" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "cambio(3,5)" ] }, { "cell_type": "code", "execution_count": 116, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[ NO NO NO 1.2500 NO NO 0.15152 5.4615]" ] }, "execution_count": 116, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cocientesD(2)" ] }, { "cell_type": "code", "execution_count": 117, "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} & {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{5}{11} & 1 & \\frac{15}{11} & 0 & -\\frac{1}{11} & 0 & \\frac{8}{11} & \\frac{21}{11} \\\\\n", "{\\color{green}{s}}_{3} & 0 & -\\frac{61}{33} & 0 & \\frac{136}{33} & 0 & -\\frac{34}{33} & 1 & \\frac{52}{33} & \\frac{241}{33} \\\\\n", "{\\color{green}{s}}_{1} & 0 & \\frac{5}{11} & 0 & \\frac{4}{11} & 1 & -\\frac{1}{11} & 0 & -\\frac{36}{11} & \\frac{10}{11} \\\\\n", "{x}_{1} & 1 & \\frac{26}{33} & 0 & -\\frac{32}{33} & 0 & \\frac{8}{33} & 0 & -\\frac{20}{33} & \\frac{52}{33} \\\\\n", "\\hline\n", " {Z_{ind}} & 0 & -\\frac{41}{33} & 0 & -\\frac{145}{33} & 0 & -\\frac{5}{33} & 0 & -\\frac{268}{33} & \\frac{1435}{33}\n", "\\end{array}\\right)$$" ], "text/plain": [ "[ B| x1 x2 x3 x4 s1 s2 s3 s4| rhs]\n", "[-------+---------------------------------------------------------------+-------]\n", "[ x3| 0 5/11 1 15/11 0 -1/11 0 8/11| 21/11]\n", "[ s3| 0 -61/33 0 136/33 0 -34/33 1 52/33| 241/33]\n", "[ s1| 0 5/11 0 4/11 1 -1/11 0 -36/11| 10/11]\n", "[ x1| 1 26/33 0 -32/33 0 8/33 0 -20/33| 52/33]\n", "[-------+---------------------------------------------------------------+-------]\n", "[ Z| 0 -41/33 0 -145/33 0 -5/33 0 -268/33|1435/33]" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "cambio(2,7)" ] }, { "cell_type": "code", "execution_count": 118, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/latex": [ "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left[1, 2, 3, 4, 5, 6, 7, 8\\right]$$" ], "text/plain": [ "[1, 2, 3, 4, 5, 6, 7, 8]" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/plain": [ "[10/11, 10/33, 10/11, 19/33]" ] }, "execution_count": 118, "metadata": {}, "output_type": "execute_result" } ], "source": [ "pardec()" ] }, { "cell_type": "code", "execution_count": 119, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/latex": [ "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left[1, 2, 3, 4, 5, 6, 7, 8\\right]$$" ], "text/plain": [ "[1, 2, 3, 4, 5, 6, 7, 8]" ] }, "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{green}{s}}_{5} & {b} \\\\\n", "\\hline\n", " {x}_{3} & 0 & \\frac{5}{11} & 1 & \\frac{15}{11} & 0 & -\\frac{1}{11} & 0 & \\frac{8}{11} & 0 & \\frac{21}{11} \\\\\n", "{\\color{green}{s}}_{3} & 0 & -\\frac{61}{33} & 0 & \\frac{136}{33} & 0 & -\\frac{34}{33} & 1 & \\frac{52}{33} & 0 & \\frac{241}{33} \\\\\n", "{\\color{green}{s}}_{1} & 0 & \\frac{5}{11} & 0 & \\frac{4}{11} & 1 & -\\frac{1}{11} & 0 & -\\frac{36}{11} & 0 & \\frac{10}{11} \\\\\n", "{x}_{1} & 1 & \\frac{26}{33} & 0 & -\\frac{32}{33} & 0 & \\frac{8}{33} & 0 & -\\frac{20}{33} & 0 & \\frac{52}{33} \\\\\n", "{\\color{green}{s}}_{5} & 0 & -115 & 0 & -92 & 0 & -10 & 0 & -140 & 1 & -230 \\\\\n", "\\hline\n", " {Z_{ind}} & 0 & -\\frac{41}{33} & 0 & -\\frac{145}{33} & 0 & -\\frac{5}{33} & 0 & -\\frac{268}{33} & 0 & \\frac{1435}{33}\n", "\\end{array}\\right)$$" ], "text/plain": [ "[ B| x1 x2 x3 x4 s1 s2 s3 s4 s5| rhs]\n", "[-------+-----------------------------------------------------------------------+-------]\n", "[ x3| 0 5/11 1 15/11 0 -1/11 0 8/11 0| 21/11]\n", "[ s3| 0 -61/33 0 136/33 0 -34/33 1 52/33 0| 241/33]\n", "[ s1| 0 5/11 0 4/11 1 -1/11 0 -36/11 0| 10/11]\n", "[ x1| 1 26/33 0 -32/33 0 8/33 0 -20/33 0| 52/33]\n", "[ s5| 0 -115 0 -92 0 -10 0 -140 1| -230]\n", "[-------+-----------------------------------------------------------------------+-------]\n", "[ Z| 0 -41/33 0 -145/33 0 -5/33 0 -268/33 0|1435/33]" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "corte(2)" ] }, { "cell_type": "code", "execution_count": 120, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[ NO 0.010804 NO 0.047760 NO 0.015152 NO 0.058009 NO]" ] }, "execution_count": 120, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cocientesD(5)" ] }, { "cell_type": "code", "execution_count": 121, "metadata": {}, "outputs": [ { "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{green}{s}}_{5} & {b} \\\\\n", "\\hline\n", " {x}_{3} & 0 & 0 & 1 & 1 & 0 & -\\frac{3}{23} & 0 & \\frac{4}{23} & \\frac{1}{253} & 1 \\\\\n", "{\\color{green}{s}}_{3} & 0 & 0 & 0 & \\frac{28}{5} & 0 & -\\frac{20}{23} & 1 & \\frac{88}{23} & -\\frac{61}{3795} & 11 \\\\\n", "{\\color{green}{s}}_{1} & 0 & 0 & 0 & 0 & 1 & -\\frac{3}{23} & 0 & -\\frac{88}{23} & \\frac{1}{253} & 0 \\\\\n", "{x}_{1} & 1 & 0 & 0 & -\\frac{8}{5} & 0 & \\frac{4}{23} & 0 & -\\frac{36}{23} & \\frac{26}{3795} & 0 \\\\\n", "{x}_{2} & 0 & 1 & 0 & \\frac{4}{5} & 0 & \\frac{2}{23} & 0 & \\frac{28}{23} & -\\frac{1}{115} & 2 \\\\\n", "\\hline\n", " {Z_{ind}} & 0 & 0 & 0 & -\\frac{17}{5} & 0 & -\\frac{1}{23} & 0 & -\\frac{152}{23} & -\\frac{41}{3795} & 41\n", "\\end{array}\\right)$$" ], "text/plain": [ "[ B| x1 x2 x3 x4 s1 s2 s3 s4 s5| rhs]\n", "[--------+--------------------------------------------------------------------------------+--------]\n", "[ x3| 0 0 1 1 0 -3/23 0 4/23 1/253| 1]\n", "[ s3| 0 0 0 28/5 0 -20/23 1 88/23 -61/3795| 11]\n", "[ s1| 0 0 0 0 1 -3/23 0 -88/23 1/253| 0]\n", "[ x1| 1 0 0 -8/5 0 4/23 0 -36/23 26/3795| 0]\n", "[ x2| 0 1 0 4/5 0 2/23 0 28/23 -1/115| 2]\n", "[--------+--------------------------------------------------------------------------------+--------]\n", "[ Z| 0 0 0 -17/5 0 -1/23 0 -152/23 -41/3795| 41]" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "cambio(5,2)" ] }, { "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 }