{ "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} 100 x_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 100 x_{2} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\\\\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} 75 \\\\\n", " \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} 5 x_{1} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\geq \\mspace{-6mu}&\\mspace{-6mu} 60 \\\\\n", " \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} 4 x_{2} \\mspace{-6mu}&\\mspace{-6mu} \\geq \\mspace{-6mu}&\\mspace{-6mu} 80 \\\\\n", " \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} 5 x_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 10 x_{2} \\mspace{-6mu}&\\mspace{-6mu} \\leq \\mspace{-6mu}&\\mspace{-6mu} 450 \\\\\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}}7000$$" ], "text/plain": [ "7000" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/latex": [ "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(50,\\,20\\right)$$" ], "text/plain": [ "(50, 20)" ] }, "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} 75 y_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 60 y_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 80 y_{3} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 450 y_{4} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\\\\n", " \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} y_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 5 y_{2} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 5 y_{4} \\mspace{-6mu}&\\mspace{-6mu} \\geq \\mspace{-6mu}&\\mspace{-6mu} 100 \\\\\n", " \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} y_{1} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 4 y_{3} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 10 y_{4} \\mspace{-6mu}&\\mspace{-6mu} \\geq \\mspace{-6mu}&\\mspace{-6mu} 100 \\\\\n", "\\end{array} \\\\\n", "y_{1} \\geq 0,\\ y_{2} \\leq 0,\\ y_{3} \\leq 0,\\ y_{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}}{===================================}$$" ], "text/plain": [ "ry" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/latex": [ "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}7000$$" ], "text/plain": [ "7000" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "text/html": [ "" ], "text/latex": [ "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(0,\\,0,\\,-25,\\,20\\right)$$" ], "text/plain": [ "(0, 0, -25, 20)" ] }, "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{red}{t}}_{2} & {\\color{red}{t}}_{3} & {b} \\\\\n", "\\hline\n", " {\\color{green}{s}}_{1} & 1 & 1 & 1 & 0 & 0 & 0 & 0 & 0 & 75 \\\\\n", "{\\color{red}{t}}_{2} & 5 & 0 & 0 & -1 & 0 & 0 & 1 & 0 & 60 \\\\\n", "{\\color{red}{t}}_{3} & 0 & 4 & 0 & 0 & -1 & 0 & 0 & 1 & 80 \\\\\n", "{\\color{green}{s}}_{4} & 5 & 10 & 0 & 0 & 0 & 1 & 0 & 0 & 450 \\\\\n", "\\hline\n", " {W_{ind}} & -5 & -4 & 0 & 1 & 1 & 0 & 0 & 0 & 140\n", "\\end{array}\\right)$$" ], "text/plain": [ "[ B| x1 x2 s1 s2 s3 s4 t2 t3|rhs]\n", "[---+-------------------------------+---]\n", "[ s1| 1 1 1 0 0 0 0 0| 75]\n", "[ t2| 5 0 0 -1 0 0 1 0| 60]\n", "[ t3| 0 4 0 0 -1 0 0 1| 80]\n", "[ s4| 5 10 0 0 0 1 0 0|450]\n", "[---+-------------------------------+---]\n", "[ W| -5 -4 0 1 1 0 0 0|140]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "cambio( 2 , 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{red}{t}}_{2} & {\\color{red}{t}}_{3} & {b} \\\\\n", "\\hline\n", " {\\color{green}{s}}_{1} & 0 & 1 & 1 & \\frac{1}{5} & 0 & 0 & -\\frac{1}{5} & 0 & 63 \\\\\n", "{x}_{1} & 1 & 0 & 0 & -\\frac{1}{5} & 0 & 0 & \\frac{1}{5} & 0 & 12 \\\\\n", "{\\color{red}{t}}_{3} & 0 & 4 & 0 & 0 & -1 & 0 & 0 & 1 & 80 \\\\\n", "{\\color{green}{s}}_{4} & 0 & 10 & 0 & 1 & 0 & 1 & -1 & 0 & 390 \\\\\n", "\\hline\n", " {W_{ind}} & 0 & -4 & 0 & 0 & 1 & 0 & 1 & 0 & 80\n", "\\end{array}\\right)$$" ], "text/plain": [ "[ B| x1 x2 s1 s2 s3 s4 t2 t3| rhs]\n", "[----+---------------------------------------+----]\n", "[ s1| 0 1 1 1/5 0 0 -1/5 0| 63]\n", "[ x1| 1 0 0 -1/5 0 0 1/5 0| 12]\n", "[ t3| 0 4 0 0 -1 0 0 1| 80]\n", "[ s4| 0 10 0 1 0 1 -1 0| 390]\n", "[----+---------------------------------------+----]\n", "[ W| 0 -4 0 0 1 0 1 0| 80]" ] }, "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|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{red}{t}}_{2} & {\\color{red}{t}}_{3} & {b} \\\\\n", "\\hline\n", " {\\color{green}{s}}_{1} & 0 & 0 & 1 & \\frac{1}{5} & \\frac{1}{4} & 0 & -\\frac{1}{5} & -\\frac{1}{4} & 43 \\\\\n", "{x}_{1} & 1 & 0 & 0 & -\\frac{1}{5} & 0 & 0 & \\frac{1}{5} & 0 & 12 \\\\\n", "{x}_{2} & 0 & 1 & 0 & 0 & -\\frac{1}{4} & 0 & 0 & \\frac{1}{4} & 20 \\\\\n", "{\\color{green}{s}}_{4} & 0 & 0 & 0 & 1 & \\frac{5}{2} & 1 & -1 & -\\frac{5}{2} & 190 \\\\\n", "\\hline\n", " {W_{ind}} & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 1 & 0\n", "\\end{array}\\right)$$" ], "text/plain": [ "[ B| x1 x2 s1 s2 s3 s4 t2 t3| rhs]\n", "[----+---------------------------------------+----]\n", "[ s1| 0 0 1 1/5 1/4 0 -1/5 -1/4| 43]\n", "[ x1| 1 0 0 -1/5 0 0 1/5 0| 12]\n", "[ x2| 0 1 0 0 -1/4 0 0 1/4| 20]\n", "[ s4| 0 0 0 1 5/2 1 -1 -5/2| 190]\n", "[----+---------------------------------------+----]\n", "[ W| 0 0 0 0 0 0 1 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|rrrrrr|r}\n", "{Basic} & {x}_{1} & {x}_{2} & {\\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 & 0 & 1 & \\frac{1}{5} & \\frac{1}{4} & 0 & 43 \\\\\n", "{x}_{1} & 1 & 0 & 0 & -\\frac{1}{5} & 0 & 0 & 12 \\\\\n", "{x}_{2} & 0 & 1 & 0 & 0 & -\\frac{1}{4} & 0 & 20 \\\\\n", "{\\color{green}{s}}_{4} & 0 & 0 & 0 & 1 & \\frac{5}{2} & 1 & 190 \\\\\n", "\\hline\n", " {Z_{ind}} & 0 & 0 & 0 & 20 & 25 & 0 & 3200\n", "\\end{array}\\right)$$" ], "text/plain": [ "[ B| x1 x2 s1 s2 s3 s4| rhs]\n", "[----+-----------------------------+----]\n", "[ s1| 0 0 1 1/5 1/4 0| 43]\n", "[ x1| 1 0 0 -1/5 0 0| 12]\n", "[ x2| 0 1 0 0 -1/4 0| 20]\n", "[ s4| 0 0 0 1 5/2 1| 190]\n", "[----+-----------------------------+----]\n", "[ Z| 0 0 0 20 25 0|3200]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "cambio( 4 , 5 )\n" ] }, { "data": { "text/html": [ "" ], "text/latex": [ "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrr|r}\n", "{Basic} & {x}_{1} & {x}_{2} & {\\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 & 0 & 1 & \\frac{1}{10} & 0 & -\\frac{1}{10} & 24 \\\\\n", "{x}_{1} & 1 & 0 & 0 & -\\frac{1}{5} & 0 & 0 & 12 \\\\\n", "{x}_{2} & 0 & 1 & 0 & \\frac{1}{10} & 0 & \\frac{1}{10} & 39 \\\\\n", "{\\color{green}{s}}_{3} & 0 & 0 & 0 & \\frac{2}{5} & 1 & \\frac{2}{5} & 76 \\\\\n", "\\hline\n", " {Z_{ind}} & 0 & 0 & 0 & 10 & 0 & -10 & 5100\n", "\\end{array}\\right)$$" ], "text/plain": [ "[ B| x1 x2 s1 s2 s3 s4| rhs]\n", "[-----+-----------------------------------+-----]\n", "[ s1| 0 0 1 1/10 0 -1/10| 24]\n", "[ x1| 1 0 0 -1/5 0 0| 12]\n", "[ x2| 0 1 0 1/10 0 1/10| 39]\n", "[ s3| 0 0 0 2/5 1 2/5| 76]\n", "[-----+-----------------------------------+-----]\n", "[ Z| 0 0 0 10 0 -10| 5100]" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "cambio( 4 , 4 )\n" ] }, { "data": { "text/html": [ "" ], "text/latex": [ "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrr|r}\n", "{Basic} & {x}_{1} & {x}_{2} & {\\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 & 0 & 1 & 0 & -\\frac{1}{4} & -\\frac{1}{5} & 5 \\\\\n", "{x}_{1} & 1 & 0 & 0 & 0 & \\frac{1}{2} & \\frac{1}{5} & 50 \\\\\n", "{x}_{2} & 0 & 1 & 0 & 0 & -\\frac{1}{4} & 0 & 20 \\\\\n", "{\\color{green}{s}}_{2} & 0 & 0 & 0 & 1 & \\frac{5}{2} & 1 & 190 \\\\\n", "\\hline\n", " {Z_{ind}} & 0 & 0 & 0 & 0 & -25 & -20 & 7000\n", "\\end{array}\\right)$$" ], "text/plain": [ "[ B| x1 x2 s1 s2 s3 s4| rhs]\n", "[----+-----------------------------+----]\n", "[ s1| 0 0 1 0 -1/4 -1/5| 5]\n", "[ x1| 1 0 0 0 1/2 1/5| 50]\n", "[ x2| 0 1 0 0 -1/4 0| 20]\n", "[ s2| 0 0 0 1 5/2 1| 190]\n", "[----+-----------------------------+----]\n", "[ Z| 0 0 0 0 -25 -20|7000]" ] }, "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=4 # número de restricciones (distintas de las de signo)\n", "\n", "c=matrix(QQ,1,n,[100,100] ) # vector de costos\n", "\n", "A=matrix(QQ,m,n,[ # coeficientes de las variables x's\n", "[1,1],\n", "[5,0],\n", "[0,4],\n", "[5,10]\n", "])\n", "\n", "b=matrix(QQ,m,1,[75,60,80,450]) # 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", "\n", "\n", "\n", "####################################################################\n", "############ HASTA AQUÍ LOS DATOS ################################\n", "####################################################################\n", "\n", "\n", "\n", "load('https://sage.unex.es/501708/SAGE/simplex2023Auto.sage')\n", "#load('https://sage.unex.es/501708/SAGE/simplex2023AutoREVISED.sage')\n", "\n", "\n" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [], "source": [ "#b1p=matrix(QQ,m,1,[1,0,0,0]); param1b(b1p) " ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/latex": [ "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrr|rr}\n", "{Basic} & {x}_{1} & {x}_{2} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {\\color{green}{s}}_{4} & {b} & {b_1} \\\\\n", "\\hline\n", " {\\color{green}{s}}_{1} & 0 & 0 & 1 & 0 & -\\frac{1}{4} & -\\frac{1}{5} & 5 & -\\frac{1}{5} \\\\\n", "{x}_{1} & 1 & 0 & 0 & 0 & \\frac{1}{2} & \\frac{1}{5} & 50 & \\frac{1}{5} \\\\\n", "{x}_{2} & 0 & 1 & 0 & 0 & -\\frac{1}{4} & 0 & 20 & 0 \\\\\n", "{\\color{green}{s}}_{2} & 0 & 0 & 0 & 1 & \\frac{5}{2} & 1 & 190 & 1 \\\\\n", "\\hline\n", " {Z_{ind}} & 0 & 0 & 0 & 0 & -25 & -20 & 7000 & 20\n", "\\end{array}\\right)$$" ], "text/plain": [ "[ B| x1 x2 s1 s2 s3 s4| rhs rhs1]\n", "[----+-----------------------------+---------]\n", "[ s1| 0 0 1 0 -1/4 -1/5| 5 -1/5]\n", "[ x1| 1 0 0 0 1/2 1/5| 50 1/5]\n", "[ x2| 0 1 0 0 -1/4 0| 20 0]\n", "[ s2| 0 0 0 1 5/2 1| 190 1]\n", "[----+-----------------------------+---------]\n", "[ Z| 0 0 0 0 -25 -20|7000 20]" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "b1p=matrix(QQ,m,1,[0,0,0,1]); param1b(b1p) " ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "[ NO NO NO NO 100.00 100.00]" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cocientesD(1)" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/latex": [ "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrr|rr}\n", "{Basic} & {x}_{1} & {x}_{2} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {\\color{green}{s}}_{4} & {b} & {b_1} \\\\\n", "\\hline\n", " {\\color{green}{s}}_{3} & 0 & 0 & -4 & 0 & 1 & \\frac{4}{5} & -20 & \\frac{4}{5} \\\\\n", "{x}_{1} & 1 & 0 & 2 & 0 & 0 & -\\frac{1}{5} & 60 & -\\frac{1}{5} \\\\\n", "{x}_{2} & 0 & 1 & -1 & 0 & 0 & \\frac{1}{5} & 15 & \\frac{1}{5} \\\\\n", "{\\color{green}{s}}_{2} & 0 & 0 & 10 & 1 & 0 & -1 & 240 & -1 \\\\\n", "\\hline\n", " {Z_{ind}} & 0 & 0 & -100 & 0 & 0 & 0 & 7500 & 0\n", "\\end{array}\\right)$$" ], "text/plain": [ "[ B| x1 x2 s1 s2 s3 s4| rhs rhs1]\n", "[----+-----------------------------+---------]\n", "[ s3| 0 0 -4 0 1 4/5| -20 4/5]\n", "[ x1| 1 0 2 0 0 -1/5| 60 -1/5]\n", "[ x2| 0 1 -1 0 0 1/5| 15 1/5]\n", "[ s2| 0 0 10 1 0 -1| 240 -1]\n", "[----+-----------------------------+---------]\n", "[ Z| 0 0 -100 0 0 0|7500 0]" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "cambio(1,5)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/latex": [ "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrr|rrr}\n", "{Basic} & {x}_{1} & {x}_{2} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {\\color{green}{s}}_{4} & {b} & {b_1} & {b_1} \\\\\n", "\\hline\n", " {\\color{green}{s}}_{3} & 0 & 0 & -4 & 0 & 1 & \\frac{4}{5} & -20 & \\frac{4}{5} & -4 \\\\\n", "{x}_{1} & 1 & 0 & 2 & 0 & 0 & -\\frac{1}{5} & 60 & -\\frac{1}{5} & 2 \\\\\n", "{x}_{2} & 0 & 1 & -1 & 0 & 0 & \\frac{1}{5} & 15 & \\frac{1}{5} & -1 \\\\\n", "{\\color{green}{s}}_{2} & 0 & 0 & 10 & 1 & 0 & -1 & 240 & -1 & 10 \\\\\n", "\\hline\n", " {Z_{ind}} & 0 & 0 & -100 & 0 & 0 & 0 & 7500 & 0 & 100\n", "\\end{array}\\right)$$" ], "text/plain": [ "[ B| x1 x2 s1 s2 s3 s4| rhs rhs1 rhs1]\n", "[----+-----------------------------+--------------]\n", "[ s3| 0 0 -4 0 1 4/5| -20 4/5 -4]\n", "[ x1| 1 0 2 0 0 -1/5| 60 -1/5 2]\n", "[ x2| 0 1 -1 0 0 1/5| 15 1/5 -1]\n", "[ s2| 0 0 10 1 0 -1| 240 -1 10]\n", "[----+-----------------------------+--------------]\n", "[ Z| 0 0 -100 0 0 0|7500 0 100]" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "b1p=matrix(QQ,m,1,[1,0,0,0]); param1b(b1p) " ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ], "text/latex": [ "$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrr|rrr}\n", "{Basic} & {x}_{1} & {x}_{2} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {\\color{green}{s}}_{4} & {b} & {b_1} & {b_1} \\\\\n", "\\hline\n", " {\\color{green}{s}}_{1} & 0 & 0 & 1 & 0 & -\\frac{1}{4} & -\\frac{1}{5} & 5 & -\\frac{1}{5} & 1 \\\\\n", "{x}_{1} & 1 & 0 & 0 & 0 & \\frac{1}{2} & \\frac{1}{5} & 50 & \\frac{1}{5} & 0 \\\\\n", "{x}_{2} & 0 & 1 & 0 & 0 & -\\frac{1}{4} & 0 & 20 & 0 & 0 \\\\\n", "{\\color{green}{s}}_{2} & 0 & 0 & 0 & 1 & \\frac{5}{2} & 1 & 190 & 1 & 0 \\\\\n", "\\hline\n", " {Z_{ind}} & 0 & 0 & 0 & 0 & -25 & -20 & 7000 & 20 & 0\n", "\\end{array}\\right)$$" ], "text/plain": [ "[ B| x1 x2 s1 s2 s3 s4| rhs rhs1 rhs1]\n", "[----+-----------------------------+--------------]\n", "[ s1| 0 0 1 0 -1/4 -1/5| 5 -1/5 1]\n", "[ x1| 1 0 0 0 1/2 1/5| 50 1/5 0]\n", "[ x2| 0 1 0 0 -1/4 0| 20 0 0]\n", "[ s2| 0 0 0 1 5/2 1| 190 1 0]\n", "[----+-----------------------------+--------------]\n", "[ Z| 0 0 0 0 -25 -20|7000 20 0]" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "cambio(1,3)" ] } ], "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 }