{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"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} x_{1} \\mspace{-6mu}&\\mspace{-6mu} - \\mspace{-6mu}&\\mspace{-6mu} x_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} x_{3} \\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} + \\mspace{-6mu}&\\mspace{-6mu} x_{3} \\mspace{-6mu}&\\mspace{-6mu} \\leq \\mspace{-6mu}&\\mspace{-6mu} 1 \\\\\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} + \\mspace{-6mu}&\\mspace{-6mu} x_{3} \\mspace{-6mu}&\\mspace{-6mu} \\geq \\mspace{-6mu}&\\mspace{-6mu} 1 \\\\\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} x_{3} \\mspace{-6mu}&\\mspace{-6mu} \\leq \\mspace{-6mu}&\\mspace{-6mu} 1 \\\\\n",
" \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} x_{3} \\mspace{-6mu}&\\mspace{-6mu} \\leq \\mspace{-6mu}&\\mspace{-6mu} 2 \\\\\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} + \\mspace{-6mu}&\\mspace{-6mu} 2 x_{3} \\mspace{-6mu}&\\mspace{-6mu} \\leq \\mspace{-6mu}&\\mspace{-6mu} 2 \\\\\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}}1$$"
],
"text/plain": [
"1"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(0,\\,0,\\,1\\right)$$"
],
"text/plain": [
"(0, 0, 1)"
]
},
"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}{lcrcrcrcrcrcl}\n",
" \\min \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} y_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} y_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} y_{3} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 2 y_{4} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 2 y_{5} \\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} y_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} y_{3} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} y_{5} \\mspace{-6mu}&\\mspace{-6mu} \\geq \\mspace{-6mu}&\\mspace{-6mu} -1 \\\\\n",
" \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} y_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} y_{2} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} y_{5} \\mspace{-6mu}&\\mspace{-6mu} \\geq \\mspace{-6mu}&\\mspace{-6mu} -1 \\\\\n",
" \\mspace{-6mu}&\\mspace{-6mu} \\mspace{-6mu}&\\mspace{-6mu} y_{1} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} y_{2} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} y_{3} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} y_{4} \\mspace{-6mu}&\\mspace{-6mu} + \\mspace{-6mu}&\\mspace{-6mu} 2 y_{5} \\mspace{-6mu}&\\mspace{-6mu} \\geq \\mspace{-6mu}&\\mspace{-6mu} 1 \\\\\n",
"\\end{array} \\\\\n",
"y_{1} \\geq 0,\\ y_{2} \\leq 0,\\ y_{3} \\geq 0,\\ y_{4} \\geq 0,\\ y_{5} \\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}}1$$"
],
"text/plain": [
"1"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(0,\\,-3,\\,0,\\,0,\\,2\\right)$$"
],
"text/plain": [
"(0, -3, 0, 0, 2)"
]
},
"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|rrrrrrrrr|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{green}{s}}_{5} & {\\color{red}{t}}_{2} & {b} \\\\\n",
"\\hline\n",
" {\\color{green}{s}}_{1} & 1 & 1 & 1 & 1 & 0 & 0 & 0 & 0 & 0 & 1 \\\\\n",
"{\\color{red}{t}}_{2} & 1 & 1 & 1 & 0 & -1 & 0 & 0 & 0 & 1 & 1 \\\\\n",
"{\\color{green}{s}}_{3} & 1 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 1 \\\\\n",
"{\\color{green}{s}}_{4} & 0 & 0 & 1 & 0 & 0 & 0 & 1 & 0 & 0 & 2 \\\\\n",
"{\\color{green}{s}}_{5} & 1 & 1 & 2 & 0 & 0 & 0 & 0 & 1 & 0 & 2 \\\\\n",
"\\hline\n",
" {W_{ind}} & -1 & -1 & -1 & 0 & 1 & 0 & 0 & 0 & 0 & 1\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 s1 s2 s3 s4 s5 t2|rhs]\n",
"[---+-----------------------------------+---]\n",
"[ s1| 1 1 1 1 0 0 0 0 0| 1]\n",
"[ t2| 1 1 1 0 -1 0 0 0 1| 1]\n",
"[ s3| 1 0 1 0 0 1 0 0 0| 1]\n",
"[ s4| 0 0 1 0 0 0 1 0 0| 2]\n",
"[ s5| 1 1 2 0 0 0 0 1 0| 2]\n",
"[---+-----------------------------------+---]\n",
"[ W| -1 -1 -1 0 1 0 0 0 0| 1]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"cambio( 1 , 1 )\n"
]
},
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}\\left(\\begin{array}{r|rrrrrrrrr|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{green}{s}}_{5} & {\\color{red}{t}}_{2} & {b} \\\\\n",
"\\hline\n",
" {x}_{1} & 1 & 1 & 1 & 1 & 0 & 0 & 0 & 0 & 0 & 1 \\\\\n",
"{\\color{red}{t}}_{2} & 0 & 0 & 0 & -1 & -1 & 0 & 0 & 0 & 1 & 0 \\\\\n",
"{\\color{green}{s}}_{3} & 0 & -1 & 0 & -1 & 0 & 1 & 0 & 0 & 0 & 0 \\\\\n",
"{\\color{green}{s}}_{4} & 0 & 0 & 1 & 0 & 0 & 0 & 1 & 0 & 0 & 2 \\\\\n",
"{\\color{green}{s}}_{5} & 0 & 0 & 1 & -1 & 0 & 0 & 0 & 1 & 0 & 1 \\\\\n",
"\\hline\n",
" {W_{ind}} & 0 & 0 & 0 & 1 & 1 & 0 & 0 & 0 & 0 & 0\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 s1 s2 s3 s4 s5 t2|rhs]\n",
"[---+-----------------------------------+---]\n",
"[ x1| 1 1 1 1 0 0 0 0 0| 1]\n",
"[ t2| 0 0 0 -1 -1 0 0 0 1| 0]\n",
"[ s3| 0 -1 0 -1 0 1 0 0 0| 0]\n",
"[ s4| 0 0 1 0 0 0 1 0 0| 2]\n",
"[ s5| 0 0 1 -1 0 0 0 1 0| 1]\n",
"[---+-----------------------------------+---]\n",
"[ W| 0 0 0 1 1 0 0 0 0| 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}}\\left(\\begin{array}{r|rrrrrrrrr|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{green}{s}}_{5} & {\\color{red}{t}}_{2} & {b} \\\\\n",
"\\hline\n",
" {x}_{1} & 1 & 1 & 1 & 0 & -1 & 0 & 0 & 0 & 1 & 1 \\\\\n",
"{\\color{green}{s}}_{1} & 0 & 0 & 0 & 1 & 1 & 0 & 0 & 0 & -1 & 0 \\\\\n",
"{\\color{green}{s}}_{3} & 0 & -1 & 0 & 0 & 1 & 1 & 0 & 0 & -1 & 0 \\\\\n",
"{\\color{green}{s}}_{4} & 0 & 0 & 1 & 0 & 0 & 0 & 1 & 0 & 0 & 2 \\\\\n",
"{\\color{green}{s}}_{5} & 0 & 0 & 1 & 0 & 1 & 0 & 0 & 1 & -1 & 1 \\\\\n",
"\\hline\n",
" {W_{ind}} & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 s1 s2 s3 s4 s5 t2|rhs]\n",
"[---+-----------------------------------+---]\n",
"[ x1| 1 1 1 0 -1 0 0 0 1| 1]\n",
"[ s1| 0 0 0 1 1 0 0 0 -1| 0]\n",
"[ s3| 0 -1 0 0 1 1 0 0 -1| 0]\n",
"[ s4| 0 0 1 0 0 0 1 0 0| 2]\n",
"[ s5| 0 0 1 0 1 0 0 1 -1| 1]\n",
"[---+-----------------------------------+---]\n",
"[ W| 0 0 0 0 0 0 0 0 1| 0]"
]
},
"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} & {\\color{green}{s}}_{1} & {\\color{green}{s}}_{2} & {\\color{green}{s}}_{3} & {\\color{green}{s}}_{4} & {\\color{green}{s}}_{5} & {\\color{red}{t}}_{2} & {b} \\\\\n",
"\\hline\n",
" {x}_{1} & 1 & 1 & 1 & 1 & 0 & 0 & 0 & 0 & 0 & 1 \\\\\n",
"{\\color{green}{s}}_{2} & 0 & 0 & 0 & 1 & 1 & 0 & 0 & 0 & -1 & 0 \\\\\n",
"{\\color{green}{s}}_{3} & 0 & -1 & 0 & -1 & 0 & 1 & 0 & 0 & 0 & 0 \\\\\n",
"{\\color{green}{s}}_{4} & 0 & 0 & 1 & 0 & 0 & 0 & 1 & 0 & 0 & 2 \\\\\n",
"{\\color{green}{s}}_{5} & 0 & 0 & 1 & -1 & 0 & 0 & 0 & 1 & 0 & 1 \\\\\n",
"\\hline\n",
" {W_{ind}} & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 s1 s2 s3 s4 s5 t2|rhs]\n",
"[---+-----------------------------------+---]\n",
"[ x1| 1 1 1 1 0 0 0 0 0| 1]\n",
"[ s2| 0 0 0 1 1 0 0 0 -1| 0]\n",
"[ s3| 0 -1 0 -1 0 1 0 0 0| 0]\n",
"[ s4| 0 0 1 0 0 0 1 0 0| 2]\n",
"[ s5| 0 0 1 -1 0 0 0 1 0| 1]\n",
"[---+-----------------------------------+---]\n",
"[ W| 0 0 0 0 0 0 0 0 1| 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}}{\\ \\ \\ 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|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{green}{s}}_{5} & {b} \\\\\n",
"\\hline\n",
" {x}_{1} & 1 & 1 & 1 & 1 & 0 & 0 & 0 & 0 & 1 \\\\\n",
"{\\color{green}{s}}_{2} & 0 & 0 & 0 & 1 & 1 & 0 & 0 & 0 & 0 \\\\\n",
"{\\color{green}{s}}_{3} & 0 & -1 & 0 & -1 & 0 & 1 & 0 & 0 & 0 \\\\\n",
"{\\color{green}{s}}_{4} & 0 & 0 & 1 & 0 & 0 & 0 & 1 & 0 & 2 \\\\\n",
"{\\color{green}{s}}_{5} & 0 & 0 & 1 & -1 & 0 & 0 & 0 & 1 & 1 \\\\\n",
"\\hline\n",
" {Z_{ind}} & 0 & 0 & 2 & 1 & 0 & 0 & 0 & 0 & -1\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 s1 s2 s3 s4 s5|rhs]\n",
"[---+-------------------------------+---]\n",
"[ x1| 1 1 1 1 0 0 0 0| 1]\n",
"[ s2| 0 0 0 1 1 0 0 0| 0]\n",
"[ s3| 0 -1 0 -1 0 1 0 0| 0]\n",
"[ s4| 0 0 1 0 0 0 1 0| 2]\n",
"[ s5| 0 0 1 -1 0 0 0 1| 1]\n",
"[---+-------------------------------+---]\n",
"[ Z| 0 0 2 1 0 0 0 0| -1]"
]
},
"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|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{green}{s}}_{5} & {b} \\\\\n",
"\\hline\n",
" {x}_{3} & 1 & 1 & 1 & 1 & 0 & 0 & 0 & 0 & 1 \\\\\n",
"{\\color{green}{s}}_{2} & 0 & 0 & 0 & 1 & 1 & 0 & 0 & 0 & 0 \\\\\n",
"{\\color{green}{s}}_{3} & 0 & -1 & 0 & -1 & 0 & 1 & 0 & 0 & 0 \\\\\n",
"{\\color{green}{s}}_{4} & -1 & -1 & 0 & -1 & 0 & 0 & 1 & 0 & 1 \\\\\n",
"{\\color{green}{s}}_{5} & -1 & -1 & 0 & -2 & 0 & 0 & 0 & 1 & 0 \\\\\n",
"\\hline\n",
" {Z_{ind}} & -2 & -2 & 0 & -1 & 0 & 0 & 0 & 0 & 1\n",
"\\end{array}\\right)$$"
],
"text/plain": [
"[ B| x1 x2 x3 s1 s2 s3 s4 s5|rhs]\n",
"[---+-------------------------------+---]\n",
"[ x3| 1 1 1 1 0 0 0 0| 1]\n",
"[ s2| 0 0 0 1 1 0 0 0| 0]\n",
"[ s3| 0 -1 0 -1 0 1 0 0| 0]\n",
"[ s4| -1 -1 0 -1 0 0 1 0| 1]\n",
"[ s5| -1 -1 0 -2 0 0 0 1| 0]\n",
"[---+-------------------------------+---]\n",
"[ Z| -2 -2 0 -1 0 0 0 0| 1]"
]
},
"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=5 # número de restricciones (distintas de las de signo)\n",
"\n",
"c=matrix(QQ,1,n,[-1,-1,1] ) # vector de costos\n",
"\n",
"A=matrix(QQ,m,n,[ # coeficientes de las variables x's\n",
"[1,1,1],\n",
"[1,1,1],\n",
"[1,0,1],\n",
"[0,0,1],\n",
"[1,1,2]\n",
"])\n",
"\n",
"b=matrix(QQ,m,1,[1,1,1,2,2]) # vector de la derecha\n",
"\n",
"\n",
"h=matrix(ZZ,1,m,[1,-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",
"load('https://sage.unex.es/501708/simplex2023Auto.sage')\n",
"#load('https://sage.unex.es/501708/simplex2023AutoREVISED.sage')\n",
"#load('https://sage.unex.es/501708/simplex2023AutoRevisada.sage')"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/latex": [
"$$\\newcommand{\\Bold}[1]{\\mathbf{#1}}8$$"
],
"text/plain": [
"8"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"\n",
"show(nvar)"
]
},
{
"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
}