{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
"ry"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
"ry"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
"LP problem (use typeset mode to see details)"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
"22475000/7"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
"(300, 8200/7, 400, 500)"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
"FI"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
"ry"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
"[ B| x1 x2 x3 x4 s1 s2 s3 s4 s5 s6 s7 t5 t6| rhs]\n",
"[-----+-----------------------------------------------------------------------------+-----]\n",
"[ s1| 8 6 7 7 1 0 0 0 0 0 0 0 0|20000]\n",
"[ s2| 6 7 5 8 0 1 0 0 0 0 0 0 0|16000]\n",
"[ s3| 4 4 2 8 0 0 1 0 0 0 0 0 0|14000]\n",
"[ s4| 1 0 0 0 0 0 0 1 0 0 0 0 0| 300]\n",
"[ t5| 0 1 0 0 0 0 0 0 -1 0 0 1 0| 200]\n",
"[ t6| 0 0 1 0 0 0 0 0 0 -1 0 0 1| 400]\n",
"[ s7| 0 0 0 1 0 0 0 0 0 0 1 0 0| 500]\n",
"[-----+-----------------------------------------------------------------------------+-----]\n",
"[ W| 0 -1 -1 0 0 0 0 0 1 1 0 0 0| 600]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"cambio( 5 , 2 )\n",
"cambio( 6 , 3 )\n"
]
},
{
"data": {
"text/html": [
""
],
"text/plain": [
"[ B| x1 x2 x3 x4 s1 s2 s3 s4 s5 s6 s7 t5 t6| rhs]\n",
"[-----+-----------------------------------------------------------------------------+-----]\n",
"[ s1| 8 0 0 7 1 0 0 0 6 7 0 -6 -7|16000]\n",
"[ s2| 6 0 0 8 0 1 0 0 7 5 0 -7 -5|12600]\n",
"[ s3| 4 0 0 8 0 0 1 0 4 2 0 -4 -2|12400]\n",
"[ s4| 1 0 0 0 0 0 0 1 0 0 0 0 0| 300]\n",
"[ x2| 0 1 0 0 0 0 0 0 -1 0 0 1 0| 200]\n",
"[ x3| 0 0 1 0 0 0 0 0 0 -1 0 0 1| 400]\n",
"[ s7| 0 0 0 1 0 0 0 0 0 0 1 0 0| 500]\n",
"[-----+-----------------------------------------------------------------------------+-----]\n",
"[ W| 0 0 0 0 0 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/plain": [
"ry"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
"FII"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
"ry"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
""
],
"text/plain": [
"[ B| x1 x2 x3 x4 s1 s2 s3 s4 s5 s6 s7| rhs]\n",
"[------+----------------------------------------------------------------------------+------]\n",
"[ s1| 8 0 0 7 1 0 0 0 6 7 0| 16000]\n",
"[ s2| 6 0 0 8 0 1 0 0 7 5 0| 12600]\n",
"[ s3| 4 0 0 8 0 0 1 0 4 2 0| 12400]\n",
"[ s4| 1 0 0 0 0 0 0 1 0 0 0| 300]\n",
"[ x2| 0 1 0 0 0 0 0 0 -1 0 0| 200]\n",
"[ x3| 0 0 1 0 0 0 0 0 0 -1 0| 400]\n",
"[ s7| 0 0 0 1 0 0 0 0 0 0 1| 500]\n",
"[------+----------------------------------------------------------------------------+------]\n",
"[ Z| 1750 0 0 2000 0 0 0 0 1200 700 0|520000]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"cambio( 7 , 4 )\n",
"cambio( 4 , 1 )\n",
"cambio( 2 , 9 )\n"
]
},
{
"data": {
"text/html": [
""
],
"text/plain": [
"[ B| x1 x2 x3 x4 s1 s2 s3 s4 s5 s6 s7| rhs]\n",
"[----------+------------------------------------------------------------------------------------------------------------------------+----------]\n",
"[ s1| 0 0 0 0 1 -6/7 0 -20/7 0 19/7 -1/7| 29900/7]\n",
"[ s5| 0 0 0 0 0 1/7 0 -6/7 1 5/7 -8/7| 6800/7]\n",
"[ s3| 0 0 0 0 0 -4/7 1 -4/7 0 -6/7 -24/7| 23200/7]\n",
"[ x1| 1 0 0 0 0 0 0 1 0 0 0| 300]\n",
"[ x2| 0 1 0 0 0 1/7 0 -6/7 0 5/7 -8/7| 8200/7]\n",
"[ x3| 0 0 1 0 0 0 0 0 0 -1 0| 400]\n",
"[ x4| 0 0 0 1 0 0 0 0 0 0 1| 500]\n",
"[----------+------------------------------------------------------------------------------------------------------------------------+----------]\n",
"[ Z| 0 0 0 0 0 -1200/7 0 -5050/7 0 -1100/7 -4400/7|22475000/7]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"El problema es óptimo\n"
]
}
],
"source": [
"n=4 # número de variables x's\n",
"m=7 # número de restricciones (distintas de las de signo)\n",
"\n",
"c=matrix(QQ,1,n,[1750,1200,700,2000] ) # Vector de costos\n",
"\n",
"A=matrix(QQ,m,n,[ # coeficientes de las variables x's\n",
"[8,6,7,7],\n",
"[6,7,5,8],\n",
"[4,4,2,8],\n",
"[1,0,0,0],\n",
"[0,1,0,0],\n",
"[0,0,1,0],\n",
"[0,0,0,1]\n",
"])\n",
"\n",
"b=matrix(QQ,m,1,[20000,16000,14000,300,200,400,500]) # En miles de unidades. Vector de la derecha\n",
"\n",
"\n",
"######################################################\n",
"############### VARIABLES DE HOLGURA ################\n",
"\n",
"\n",
"h=matrix(ZZ,1,m,[1,1,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",
"\n",
"\n",
"######################################################\n",
"######### Problemas Paramétricos ###########\n",
" \n",
"prmtr_b=0 # 1 si quieres usar un parámetro en b\n",
" # 0 en caso contrario\n",
"\n",
"bp=matrix(QQ,m,1,[1,0,0,0,0,0,0]) # vector de la derecha para problemas paramétricos.\n",
"\n",
"###################################################### \n",
" \n",
"prmtr_c=0 # 1 si quieres usar un parámetro en c\n",
" # 0 en caso contrario\n",
"\n",
" \n",
"cp=matrix(QQ,1,n,[0,0,0,0] ) # vector de costos adicional para problemas paramétricos.\n",
"\n",
"######################################################\n",
"\n",
"\n",
"##############################################################################\n",
"####### Usando el paquete de programación lineal Pinteractive de Sage ########\n",
"##############################################################################\n",
"signos=[]\n",
"for i in range(m):\n",
" if h[0,i] == -1:\n",
" signos.append(\">=\")\n",
" elif h[0,i] == 1:\n",
" signos.append(\"<=\")\n",
" elif h[0,i] == 0:\n",
" signos.append(\"==\")\n",
"\n",
"var_nam = []\n",
"for i in range(n):\n",
" k=i+1\n",
" var_nam.append('x_%s' %k)\n",
" \n",
" \n",
"PPL = InteractiveLPProblem(A, b, c, var_nam,\n",
"constraint_type=signos, variable_type=\">=\", problem_type=\"max\") \n",
"\n",
"##############################################################################\n",
"##############################################################################\n",
"\n",
"\n",
"####################################################################\n",
"############ HASTA AQUÍ LOS DATOS ################################\n",
"####################################################################\n",
"\n",
"salto=var('salto', latex_name='')\n",
"raya=var('ry', latex_name='===================================')\n",
"show(ry)\n",
"show(ry)\n",
"show(PPL)\n",
"show(PPL.optimal_value())\n",
"show(PPL.optimal_solution())\n",
"\n",
"#load('https://sage.unex.es/501708/SAGE/simplex2021Nov.sage')\n",
"#load('https://sage.unex.es/501708/SAGE/simplex2022OctAutoMAX.sage')\n",
"load('https://sage.unex.es/501708/SAGE/simplex2022OctAutoMAX_MenosCuadros.sage')"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1171.42857142857"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"8200/7."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"########################################\n",
"\n",
"Añadimos $x_2 \\geq 1172$"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
"[ B| x1 x2 x3 x4 s1 s2 s3 s4 s5 s6 s7 s8| rhs]\n",
"[----------+-----------------------------------------------------------------------------------------------------------------------------------+----------]\n",
"[ s1| 0 0 0 0 1 -6/7 0 -20/7 0 19/7 -1/7 0| 29900/7]\n",
"[ s5| 0 0 0 0 0 1/7 0 -6/7 1 5/7 -8/7 0| 6800/7]\n",
"[ s3| 0 0 0 0 0 -4/7 1 -4/7 0 -6/7 -24/7 0| 23200/7]\n",
"[ x1| 1 0 0 0 0 0 0 1 0 0 0 0| 300]\n",
"[ x2| 0 1 0 0 0 1/7 0 -6/7 0 5/7 -8/7 0| 8200/7]\n",
"[ x3| 0 0 1 0 0 0 0 0 0 -1 0 0| 400]\n",
"[ x4| 0 0 0 1 0 0 0 0 0 0 1 0| 500]\n",
"[ s8| 0 0 0 0 0 1/7 0 -6/7 0 5/7 -8/7 1| -4/7]\n",
"[----------+-----------------------------------------------------------------------------------------------------------------------------------+----------]\n",
"[ Z| 0 0 0 0 0 -1200/7 0 -5050/7 0 -1100/7 -4400/7 0|22475000/7]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"\n",
"v=matrix(QQ,1,nv,[0,-1,0,0,0,0,0,0,0,0,0]) ; R=-1172\n",
"añadeRes(v,R)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[ NO NO NO NO NO NO NO 841.67 NO NO 550.00 NO]"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cocientesD(8)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
"[ B| x1 x2 x3 x4 s1 s2 s3 s4 s5 s6 s7 s8| rhs]\n",
"[-------+-----------------------------------------------------------------------------------------------+-------]\n",
"[ s1| 0 0 0 0 1 -7/8 0 -11/4 0 21/8 0 -1/8| 8543/2]\n",
"[ s5| 0 0 0 0 0 0 0 0 1 0 0 -1| 972]\n",
"[ s3| 0 0 0 0 0 -1 1 2 0 -3 0 -3| 3316]\n",
"[ x1| 1 0 0 0 0 0 0 1 0 0 0 0| 300]\n",
"[ x2| 0 1 0 0 0 0 0 0 0 0 0 -1| 1172]\n",
"[ x3| 0 0 1 0 0 0 0 0 0 -1 0 0| 400]\n",
"[ x4| 0 0 0 1 0 1/8 0 -3/4 0 5/8 0 7/8| 999/2]\n",
"[ s7| 0 0 0 0 0 -1/8 0 3/4 0 -5/8 1 -7/8| 1/2]\n",
"[-------+-----------------------------------------------------------------------------------------------+-------]\n",
"[ Z| 0 0 0 0 0 -250 0 -250 0 -550 0 -550|3210400]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"cambio(8,11)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"########################################\n",
"\n",
"Añadimos $x_2 \\leq 499$"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
"[ B| x1 x2 x3 x4 s1 s2 s3 s4 s5 s6 s7 s8 s9| rhs]\n",
"[-------+-------------------------------------------------------------------------------------------------------+-------]\n",
"[ s1| 0 0 0 0 1 -7/8 0 -11/4 0 21/8 0 -1/8 0| 8543/2]\n",
"[ s5| 0 0 0 0 0 0 0 0 1 0 0 -1 0| 972]\n",
"[ s3| 0 0 0 0 0 -1 1 2 0 -3 0 -3 0| 3316]\n",
"[ x1| 1 0 0 0 0 0 0 1 0 0 0 0 0| 300]\n",
"[ x2| 0 1 0 0 0 0 0 0 0 0 0 -1 0| 1172]\n",
"[ x3| 0 0 1 0 0 0 0 0 0 -1 0 0 0| 400]\n",
"[ x4| 0 0 0 1 0 1/8 0 -3/4 0 5/8 0 7/8 0| 999/2]\n",
"[ s7| 0 0 0 0 0 -1/8 0 3/4 0 -5/8 1 -7/8 0| 1/2]\n",
"[ s9| 0 0 0 0 0 -1/8 0 3/4 0 -5/8 0 -7/8 1| -1/2]\n",
"[-------+-------------------------------------------------------------------------------------------------------+-------]\n",
"[ Z| 0 0 0 0 0 -250 0 -250 0 -550 0 -550 0|3210400]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"v=matrix(QQ,1,nv,[0,0,0,1,0,0,0,0,0,0,0,0]) ; R=499\n",
"añadeRes(v,R)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[ NO NO NO NO NO 2000.0 NO NO NO 880.00 NO 628.57 NO]"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"cocientesD(9)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
"[ B| x1 x2 x3 x4 s1 s2 s3 s4 s5 s6 s7 s8 s9| rhs]\n",
"[----------+----------------------------------------------------------------------------------------------------------------------------------------------+----------]\n",
"[ s1| 0 0 0 0 1 -6/7 0 -20/7 0 19/7 0 0 -1/7| 29901/7]\n",
"[ s5| 0 0 0 0 0 1/7 0 -6/7 1 5/7 0 0 -8/7| 6808/7]\n",
"[ s3| 0 0 0 0 0 -4/7 1 -4/7 0 -6/7 0 0 -24/7| 23224/7]\n",
"[ x1| 1 0 0 0 0 0 0 1 0 0 0 0 0| 300]\n",
"[ x2| 0 1 0 0 0 1/7 0 -6/7 0 5/7 0 0 -8/7| 8208/7]\n",
"[ x3| 0 0 1 0 0 0 0 0 0 -1 0 0 0| 400]\n",
"[ x4| 0 0 0 1 0 0 0 0 0 0 0 0 1| 499]\n",
"[ s7| 0 0 0 0 0 0 0 0 0 0 1 0 -1| 1]\n",
"[ s8| 0 0 0 0 0 1/7 0 -6/7 0 5/7 0 1 -8/7| 4/7]\n",
"[----------+----------------------------------------------------------------------------------------------------------------------------------------------+----------]\n",
"[ Z| 0 0 0 0 0 -1200/7 0 -5050/7 0 -1100/7 0 0 -4400/7|22470600/7]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"cambio(9,12)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"########################################\n",
"\n",
"Añadimos $x_2 \\geq 1173$"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
"[ B| x1 x2 x3 x4 s1 s2 s3 s4 s5 s6 s7 s8 s9 s10| rhs]\n",
"[----------+---------------------------------------------------------------------------------------------------------------------------------------------------------+----------]\n",
"[ s1| 0 0 0 0 1 -6/7 0 -20/7 0 19/7 0 0 -1/7 0| 29901/7]\n",
"[ s5| 0 0 0 0 0 1/7 0 -6/7 1 5/7 0 0 -8/7 0| 6808/7]\n",
"[ s3| 0 0 0 0 0 -4/7 1 -4/7 0 -6/7 0 0 -24/7 0| 23224/7]\n",
"[ x1| 1 0 0 0 0 0 0 1 0 0 0 0 0 0| 300]\n",
"[ x2| 0 1 0 0 0 1/7 0 -6/7 0 5/7 0 0 -8/7 0| 8208/7]\n",
"[ x3| 0 0 1 0 0 0 0 0 0 -1 0 0 0 0| 400]\n",
"[ x4| 0 0 0 1 0 0 0 0 0 0 0 0 1 0| 499]\n",
"[ s7| 0 0 0 0 0 0 0 0 0 0 1 0 -1 0| 1]\n",
"[ s8| 0 0 0 0 0 1/7 0 -6/7 0 5/7 0 1 -8/7 0| 4/7]\n",
"[ s10| 0 0 0 0 0 1/7 0 -6/7 0 5/7 0 0 -8/7 1| -3/7]\n",
"[----------+---------------------------------------------------------------------------------------------------------------------------------------------------------+----------]\n",
"[ Z| 0 0 0 0 0 -1200/7 0 -5050/7 0 -1100/7 0 0 -4400/7 0|22470600/7]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"v=matrix(QQ,1,nv,[0,-1,0,0,0,0,0,0,0,0,0,0,0]) ; R=-1173\n",
"añadeRes(v,R)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
"[ B| x1 x2 x3 x4 s1 s2 s3 s4 s5 s6 s7 s8 s9 s10| rhs]\n",
"[-------+---------------------------------------------------------------------------------------------------------------+-------]\n",
"[ s1| 0 0 0 0 1 -7/8 0 -11/4 0 21/8 0 0 0 -1/8|34173/8]\n",
"[ s5| 0 0 0 0 0 0 0 0 1 0 0 0 0 -1| 973]\n",
"[ s3| 0 0 0 0 0 -1 1 2 0 -3 0 0 0 -3| 3319]\n",
"[ x1| 1 0 0 0 0 0 0 1 0 0 0 0 0 0| 300]\n",
"[ x2| 0 1 0 0 0 0 0 0 0 0 0 0 0 -1| 1173]\n",
"[ x3| 0 0 1 0 0 0 0 0 0 -1 0 0 0 0| 400]\n",
"[ x4| 0 0 0 1 0 1/8 0 -3/4 0 5/8 0 0 0 7/8| 3989/8]\n",
"[ s7| 0 0 0 0 0 -1/8 0 3/4 0 -5/8 1 0 0 -7/8| 11/8]\n",
"[ s8| 0 0 0 0 0 0 0 0 0 0 0 1 0 -1| 1]\n",
"[ s9| 0 0 0 0 0 -1/8 0 3/4 0 -5/8 0 0 1 -7/8| 3/8]\n",
"[-------+---------------------------------------------------------------------------------------------------------------+-------]\n",
"[ Z| 0 0 0 0 0 -250 0 -250 0 -550 0 0 0 -550|3209850]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"cambio(10,13)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"########################################\n",
"\n",
"Añadimos $x_4 \\leq 498$ (P7)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
"[ B| x1 x2 x3 x4 s1 s2 s3 s4 s5 s6 s7 s8 s9 s10 s11| rhs]\n",
"[-------+-----------------------------------------------------------------------------------------------------------------------+-------]\n",
"[ s1| 0 0 0 0 1 -7/8 0 -11/4 0 21/8 0 0 0 -1/8 0|34173/8]\n",
"[ s5| 0 0 0 0 0 0 0 0 1 0 0 0 0 -1 0| 973]\n",
"[ s3| 0 0 0 0 0 -1 1 2 0 -3 0 0 0 -3 0| 3319]\n",
"[ x1| 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0| 300]\n",
"[ x2| 0 1 0 0 0 0 0 0 0 0 0 0 0 -1 0| 1173]\n",
"[ x3| 0 0 1 0 0 0 0 0 0 -1 0 0 0 0 0| 400]\n",
"[ x4| 0 0 0 1 0 1/8 0 -3/4 0 5/8 0 0 0 7/8 0| 3989/8]\n",
"[ s7| 0 0 0 0 0 -1/8 0 3/4 0 -5/8 1 0 0 -7/8 0| 11/8]\n",
"[ s8| 0 0 0 0 0 0 0 0 0 0 0 1 0 -1 0| 1]\n",
"[ s9| 0 0 0 0 0 -1/8 0 3/4 0 -5/8 0 0 1 -7/8 0| 3/8]\n",
"[ s11| 0 0 0 0 0 -1/8 0 3/4 0 -5/8 0 0 0 -7/8 1| -5/8]\n",
"[-------+-----------------------------------------------------------------------------------------------------------------------+-------]\n",
"[ Z| 0 0 0 0 0 -250 0 -250 0 -550 0 0 0 -550 0|3209850]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"v=matrix(QQ,1,nv,[0,0,0,1,0,0,0,0,0,0,0,0,0,0]) ; R=498\n",
"añadeRes(v,R)"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
"[ B| x1 x2 x3 x4 s1 s2 s3 s4 s5 s6 s7 s8 s9 s10 s11| rhs]\n",
"[----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------]\n",
"[ s1| 0 0 0 0 1 -6/7 0 -20/7 0 19/7 0 0 0 0 -1/7| 29902/7]\n",
"[ s5| 0 0 0 0 0 1/7 0 -6/7 1 5/7 0 0 0 0 -8/7| 6816/7]\n",
"[ s3| 0 0 0 0 0 -4/7 1 -4/7 0 -6/7 0 0 0 0 -24/7| 23248/7]\n",
"[ x1| 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0| 300]\n",
"[ x2| 0 1 0 0 0 1/7 0 -6/7 0 5/7 0 0 0 0 -8/7| 8216/7]\n",
"[ x3| 0 0 1 0 0 0 0 0 0 -1 0 0 0 0 0| 400]\n",
"[ x4| 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1| 498]\n",
"[ s7| 0 0 0 0 0 0 0 0 0 0 1 0 0 0 -1| 2]\n",
"[ s8| 0 0 0 0 0 1/7 0 -6/7 0 5/7 0 1 0 0 -8/7| 12/7]\n",
"[ s9| 0 0 0 0 0 0 0 0 0 0 0 0 1 0 -1| 1]\n",
"[ s10| 0 0 0 0 0 1/7 0 -6/7 0 5/7 0 0 0 1 -8/7| 5/7]\n",
"[----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------]\n",
"[ Z| 0 0 0 0 0 -1200/7 0 -5050/7 0 -1100/7 0 0 0 0 -4400/7|22466200/7]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"cambio(11,14)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"########################################\n",
"\n",
"Añadimos $x_2 \\leq 1173$ (P9)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
"[ B| x1 x2 x3 x4 s1 s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 s12| rhs]\n",
"[----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------]\n",
"[ s1| 0 0 0 0 1 -6/7 0 -20/7 0 19/7 0 0 0 0 -1/7 0| 29902/7]\n",
"[ s5| 0 0 0 0 0 1/7 0 -6/7 1 5/7 0 0 0 0 -8/7 0| 6816/7]\n",
"[ s3| 0 0 0 0 0 -4/7 1 -4/7 0 -6/7 0 0 0 0 -24/7 0| 23248/7]\n",
"[ x1| 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0| 300]\n",
"[ x2| 0 1 0 0 0 1/7 0 -6/7 0 5/7 0 0 0 0 -8/7 0| 8216/7]\n",
"[ x3| 0 0 1 0 0 0 0 0 0 -1 0 0 0 0 0 0| 400]\n",
"[ x4| 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0| 498]\n",
"[ s7| 0 0 0 0 0 0 0 0 0 0 1 0 0 0 -1 0| 2]\n",
"[ s8| 0 0 0 0 0 1/7 0 -6/7 0 5/7 0 1 0 0 -8/7 0| 12/7]\n",
"[ s9| 0 0 0 0 0 0 0 0 0 0 0 0 1 0 -1 0| 1]\n",
"[ s10| 0 0 0 0 0 1/7 0 -6/7 0 5/7 0 0 0 1 -8/7 0| 5/7]\n",
"[ s12| 0 0 0 0 0 -1/7 0 6/7 0 -5/7 0 0 0 0 8/7 1| -5/7]\n",
"[----------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------]\n",
"[ Z| 0 0 0 0 0 -1200/7 0 -5050/7 0 -1100/7 0 0 0 0 -4400/7 0|22466200/7]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"v=matrix(QQ,1,nv,[0,1,0,0,0,0,0,0,0,0,0,0,0,0,0]) ; R=1173\n",
"añadeRes(v,R)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
""
],
"text/plain": [
"[ B| x1 x2 x3 x4 s1 s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 s12| rhs]\n",
"[-------+-------------------------------------------------------------------------------------------------------------------------------+-------]\n",
"[ s1| 0 0 0 0 1 -7/5 0 2/5 0 0 0 0 0 0 21/5 19/5| 4269]\n",
"[ s5| 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 1| 973]\n",
"[ s3| 0 0 0 0 0 -2/5 1 -8/5 0 0 0 0 0 0 -24/5 -6/5| 3322]\n",
"[ x1| 1 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0| 300]\n",
"[ x2| 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 1| 1173]\n",
"[ x3| 0 0 1 0 0 1/5 0 -6/5 0 0 0 0 0 0 -8/5 -7/5| 401]\n",
"[ x4| 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0| 498]\n",
"[ s7| 0 0 0 0 0 0 0 0 0 0 1 0 0 0 -1 0| 2]\n",
"[ s8| 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1| 1]\n",
"[ s9| 0 0 0 0 0 0 0 0 0 0 0 0 1 0 -1 0| 1]\n",
"[ s10| 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 1| 0]\n",
"[ s6| 0 0 0 0 0 1/5 0 -6/5 0 1 0 0 0 0 -8/5 -7/5| 1]\n",
"[-------+-------------------------------------------------------------------------------------------------------------------------------+-------]\n",
"[ Z| 0 0 0 0 0 -140 0 -910 0 0 0 0 0 0 -880 -220|3209300]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"cambio(12,10)"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "SageMath 9.1",
"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.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}