[13.2] Production Problem#


Revised

24 Apr 2023


Programming Environment#

Hide code cell source
from fractions import Fraction

import numpy as np
import sympy as sp
from   sympy import init_printing,latex,nsimplify,solve,symbols
from   sympy.matrices import diag,eye,GramSchmidt,ones,Matrix,zeros
from   sympy.solvers.inequalities import reduce_inequalities

x1,x2,x3,x4,y1,y2,y3,y4=symbols('x1 x2 x3 x4 y1 y2 y3 y4')
init_printing(use_latex=True)

import matplotlib        as mpl
import matplotlib.pyplot as plt
plt.style.use('ggplot');
plt.rcParams.update({'text.usetex' : True});
%matplotlib inline

from IPython.display import display, Math

from   datetime import datetime as d
import locale                   as l
import platform                 as p
import sys                      as s

pad = 20
print(f"{'Executed'.upper():<{pad}}: {d.now()}")
print()
print(f"{'Platform'   :<{pad}}: "
      f"{p.mac_ver()[0]} | "
      f"{p.system()} | "
      f"{p.release()} | "
      f"{p.machine()}")
print(f"{''           :<{pad}}: {l.getpreferredencoding()}")
print()
print(f"{'Python'     :<{pad}}: {s.version}")
print(f"{''           :<{pad}}: {s.version_info}")
print(f"{''           :<{pad}}: {p.python_implementation()}")
print()
print(f"{'Matplotlib' :<{pad}}: {mpl.__version__}")
print(f"{'NumPy'      :<{pad}}: {np .__version__}")
print(f"{'SymPy'      :<{pad}}: {sp .__version__}")

def unitVector (vec : np.ndarray) -> np.ndarray:
  return vec/np.sqrt((vec[0]**2+vec[1]**2))
EXECUTED            : 2024-05-21 15:46:42.168814

Platform            : 14.4.1 | Darwin | 23.4.0 | arm64
                    : UTF-8

Python              : 3.11.9 | packaged by conda-forge | (main, Apr 19 2024, 18:34:54) [Clang 16.0.6 ]
                    : sys.version_info(major=3, minor=11, micro=9, releaselevel='final', serial=0)
                    : CPython

Matplotlib          : 3.8.4
NumPy               : 1.26.4
SymPy               : 1.12

Pivot Function#

# PIVOT FUNCTION FOR CONCISE ROW-COLUMN TABLEAU
def pivot (iStar,jStar,tab):
  nRows =tab.shape[0]-1
  nCols =tab.shape[1]-1
  newTab=tab[:,:]

  newTab[0,jStar]    =tab[iStar,nCols]
  newTab[iStar,nCols]=tab[0,jStar]
  newTab[iStar,0]    =-tab[nRows,jStar]
  newTab[nRows,jStar]=-tab[iStar,0]
  
  for i in range(1,nRows):
    for j in range(1,nCols):
      if   i==iStar and j==jStar:
        newTab[i,j]=1/tab[iStar,jStar]
      elif i==iStar and j!=jStar:
        newTab[i,j]=-tab[i,j]/tab[iStar,jStar]
      elif i!=iStar and j==jStar:
        newTab[i,j]= tab[i,j]/tab[iStar,jStar]
      elif i!=iStar and j!=jStar:
        newTab[i,j]= tab[i,j]-tab[iStar,j]*tab[i,jStar]/tab[iStar,jStar]
  return newTab

Production Scenario#

Product A [x1] (metal valve Type A)
    $500.00  sale price
    20 lb    material
    10 hr    labor
    25 unit demand per week

Product B [x2] (metal valve Type B)
    $750.00  sale price
    15 lb    material
    20 hr    labor
    20 unit demand per week

supply per week
    500 lb material
    400 hr labor = 10 employee x 40 hr/employee

extra
     $9.00/lb material  [p1]
    $22.50/hr labor     [p2] ($22.50/hr overtime = 1.5 x $15.00/hr normal) (capped at 40 additional hours)
    
initial cost D
    $40,800.00 = $28 .00/hr x 1000 hr + $4 .00/lb x 3200 lb

[A] What number of Type A and Type B valves maximizes weekly profit, without scheduling overtime or purchasing additional material?
[B] Is it profitable for the company to purchase additional material, without scheduling overtime? If so, how much additional material?
[C] Is it profitable for the company to schedule overtime, given the result of [B]? If so, how much overtime?
[D] Assuming the company has access to a given week's revenue minus costs incurred for additional resources prior to the start of the next week, how much additional capital does the company need to maximize profit?
[E] If the company only has $5,000.00 in capital for the purposes of increasing production (and not the amount determined to meet demand in [D]), what allocation of overtime and additional material maximizes the company's profit?
[F] Assuming the result of [C], what is the change in optimal revenue per unit
    increase in material
    decrease in material
    increase in labor
    decrease in labor
    increase in demand for Type A
    decrease in demand for Type A
    increase in demand for Type B
    decrease in demand for Type B
[G] What are the rates of change in [F] at the primal solution to [C]; to [D]?
[H] What is the change in the optimal profit per dollar capital at the solution to [E]?

\(\text{LP \& LP}^*\)#

\( \boxed{ \text{LP}= \begin{aligned} \max z(\mathbf{x})&=\mathbf{cx}+d \\ \mathbf{Ax}&\le\mathbf{b} \\ \mathbf{x}&\ge\mathbf{0} \end{aligned} \overset{\text{dual to}}{\iff} \begin{aligned} \min w(\mathbf{y})&=\mathbf{yb}+d \\ \mathbf{yA}&\ge\mathbf{c} \\ \mathbf{y}&\ge\mathbf{0} \end{aligned} =\text{LP}^* } \)

\( \text{LP}= \begin{aligned} \max z(\mathbf{x})&=500x_1+750x_2-d \\ g_1(\mathbf{x})&=20x_1+15x_2\le500=b_1 &&\text{material constraint} \\ g_2(\mathbf{x})&=10x_1+20x_2\le400=b_2 &&\text{labor constraint} \\ g_3(\mathbf{x})&=x_1\le25=b_3 &&\text{Type A valve demand constaint} \\ g_4(\mathbf{x})&=x_2\le20=b_4 &&\text{Type B valve demand constraint} \\ \mathbf{x}&\ge\mathbf{0} &&\text{no negative production} \end{aligned} \overset{\text{dual to}}{\iff} \begin{aligned} \min w(\mathbf{y})&=500y_1+400y_2+25y_3+20y_4-d \\ h_1(\mathbf{y})&= 20y_1+ 10y_2+ y_3 \ge500=c_1\\ h_2(\mathbf{y})&= 15y_1+ 20y_2+ y_4 \ge750=c_2\\ \mathbf{y}&\ge\mathbf{0} \end{aligned} =\text{LP}^* \)

LP          A       B
max z = 500x1 + 750x2  - d
   g1 =  20x1 +  15x2 <= 500 = b1   material            constraint
   g2 =  10x1 +  20x2 <= 400 = b2   labor               constraint
   g3 =   1x1 +   0x2 <=  25 = b3   Type A valve demand constraint
   g4 =   0x1 +   1x2 <=  20 = b4   Type B valve demand constraint
                    x >= 0          no negative production
d =  0
b1=500
b2=400
b3= 25
b4= 20

z =500*x1+750*x2- d
g1= 20*x1+ 15*x2-b1
g2= 10*x1+ 20*x2-b2
g3=  1*x1+  0*x2-b3
g4=  0*x1+  1*x2-b4

db1=0
db2=0
db3=0
db4=0

p1= 9.00
p2=22.50

A=np.array([[20,15],[10,20],[1,0],[0,1]])
b=np.array([500,400,25,20])
c=np.array([500,750])
d=np.array([0])
x=np.array([x1,x2])
y=np.array([y1,y2,y3,y4])

display(Math(
   r"\begin{aligned}"
  fr"\max z&={latex( c@x+d [0])}\\"
  fr"   g_1&={latex((A@x-b)[0])}\\"
  fr"   g_2&={latex((A@x-b)[1])}\\"
  fr"   g_3&={latex((A@x-b)[2])}\\"
  fr"   g_4&={latex((A@x-b)[3])}\\"
   r"\\"
  fr"\min w&={latex( y@b+d [0])}\\"
  fr"   h_1&={latex((y@A-c)[0])}\\"
  fr"   h_2&={latex((y@A-c)[1])}\\"
   r"\end{aligned}"),
)
\[\begin{split}\displaystyle \begin{aligned}\max z&=500 x_{1} + 750 x_{2}\\ g_1&=20 x_{1} + 15 x_{2} - 500\\ g_2&=10 x_{1} + 20 x_{2} - 400\\ g_3&=x_{1} - 25\\ g_4&=x_{2} - 20\\\\\min w&=500 y_{1} + 400 y_{2} + 25 y_{3} + 20 y_{4}\\ h_1&=20 y_{1} + 10 y_{2} + y_{3} - 500\\ h_2&=15 y_{1} + 20 y_{2} + y_{4} - 750\\\end{aligned}\end{split}\]

Gradients and directions#

\( \begin{aligned} \nabla z&=\langle500,750\rangle \\ \nabla g_1&=\langle20,15\rangle &&\langle500,750\rangle\cdot\langle15,-20\rangle &&\lt0 &&\implies\langle-15,20\rangle \\ \nabla g_2&=\langle10,20\rangle &&\langle500,750\rangle\cdot\langle20,-10\rangle &&\gt0 &&\implies\langle20,-10\rangle \\ \nabla g_3&=\langle1,0\rangle &&\langle500,750\rangle\cdot\langle0,-1\rangle &&\lt0 &&\implies\langle0,1\rangle \\ \nabla g_4&=\langle0,1\rangle &&\langle500,750\rangle\cdot\langle1,0\rangle &&\gt0 &&\implies\langle1,0\rangle \end{aligned} \)

delz  = <500,750>
delg1 = < 20, 15>
delg2 = < 10, 20>
delg3 = <  1,  0>
delg4 = <  0,  1>

<500,750><15,-20> <0 => <-15, 20> g1
<500,750><20,-10> >0 => < 20,-10> g2
<500,750>< 0, -1> <0 => <  0,  1> g3
<500,750>< 1,  0> >0 => <  1,  0> g4
delz =c
delg1=A[0] ; dg1=(delg1[1],-delg1[0]) if delz@(delg1[1],-delg1[0]) > 0 else (-delg1[1],delg1[0])
delg2=A[1] ; dg2=(delg2[1],-delg2[0]) if delz@(delg2[1],-delg2[0]) > 0 else (-delg2[1],delg2[0])
delg3=A[2] ; dg3=(delg3[1],-delg3[0]) if delz@(delg3[1],-delg3[0]) > 0 else (-delg3[1],delg3[0])
delg4=A[3] ; dg4=(delg4[1],-delg4[0]) if delz@(delg4[1],-delg4[0]) > 0 else (-delg4[1],delg4[0])

display(Math(
   r"\begin{aligned}"
  fr"\nabla z   &=\langle{ delz[0]},{ delz[1]}\rangle\\"
  fr"\nabla g_1 &=\langle{delg1[0]},{delg1[1]}\rangle && dg_1=\langle{dg1[0]},{dg1[1]}\rangle\\"
  fr"\nabla g_2 &=\langle{delg2[0]},{delg2[1]}\rangle && dg_2=\langle{dg2[0]},{dg2[1]}\rangle\\"
  fr"\nabla g_3 &=\langle{delg3[0]},{delg3[1]}\rangle && dg_3=\langle{dg3[0]},{dg3[1]}\rangle\\"
  fr"\nabla g_4 &=\langle{delg4[0]},{delg4[1]}\rangle && dg_4=\langle{dg4[0]},{dg4[1]}\rangle\\"
   r"\end{aligned}"),
)
\[\begin{split}\displaystyle \begin{aligned}\nabla z &=\langle500,750\rangle\\\nabla g_1 &=\langle20,15\rangle && dg_1=\langle-15,20\rangle\\\nabla g_2 &=\langle10,20\rangle && dg_2=\langle20,-10\rangle\\\nabla g_3 &=\langle1,0\rangle && dg_3=\langle0,1\rangle\\\nabla g_4 &=\langle0,1\rangle && dg_4=\langle1,0\rangle\\\end{aligned}\end{split}\]
# UNIT DIRECTION VECTORS
udg1=dg1/np.sqrt(dg1[0]**2+dg1[1]**2)
udg2=dg2/np.sqrt(dg2[0]**2+dg2[1]**2)
udg3=dg3/np.sqrt(dg3[0]**2+dg3[1]**2)
udg4=dg4/np.sqrt(dg4[0]**2+dg4[1]**2)

display(Math(
   r"\begin{aligned}"
   r"\hat{dg_1}&="
  fr"\langle{udg1[0]},{udg1[1]}\rangle\\"
   r"\hat{dg_2}&="
  fr"\langle{udg2[0]},{udg2[1]}\rangle\\"
   r"\hat{dg_3}&="
  fr"\langle{udg3[0]},{udg3[1]}\rangle\\"
   r"\hat{dg_4}&="
  fr"\langle{udg4[0]},{udg4[1]}\rangle\\"
   r"\end{aligned}"
))
\[\begin{split}\displaystyle \begin{aligned}\hat{dg_1}&=\langle-0.6,0.8\rangle\\\hat{dg_2}&=\langle0.8944271909999159,-0.4472135954999579\rangle\\\hat{dg_3}&=\langle0.0,1.0\rangle\\\hat{dg_4}&=\langle1.0,0.0\rangle\\\end{aligned}\end{split}\]

Simplex Algorithm#

# CONCISE ROW TABLEAU
rA = Matrix([
  [ 'c', 'x1', 'x2',     1, 'r'],
  ['y1',  -20,  -15,b1+db1,'s1'],
  ['y2',  -10,  -20,b2+db2,'s2'],
  ['y3',   -1,    0,b3+db3,'s3'],
  ['y4',    0,   -1,b4+db4,'s4'],
  [  -1, -500, -750, -d[0],'-z'],
  [ 'c','-v1','-v2',   'w', 'r'],
])
rB = pivot(1,1,rA)
rC = pivot(2,2,rB)

# CONCISE COLUMN TABLEAU
cA = Matrix([
  [ 'c',  'y1',  'y2',  'y3',  'y4',   1, 'r'],
  ['x1',    20,    10,     1,     0,-500,'v1'],
  ['x2',    15,    20,     0,     1,-750,'v2'],
  [  -1,b1+db1,b2+db2,b3+db3,b4+db4,d[0], 'w'],
  [ 'c', '-s1', '-s2', '-s3', '-s4','-z', 'r'],
])
cB = pivot(1,1,cA)
cC = pivot(2,2,cB)

display(Math(
   r'\begin{aligned}'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,rA = {latex(rA)}\,\,\,\,\,&&'
   r'\begin{aligned}&\text{START}\\&x_1=x_2=0\end{aligned}\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,rB = {latex(rB)}\,\,\,\,\,&&x_2=s_1=0\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,rC = {latex(rC)}\,\,\,\,\,&&'
   r'\begin{aligned}&\text{OPTIMAL}\\&s_1=s_2=0\end{aligned}\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,cA = {latex(cA)}\,\,\,\,\,&&'
   r'\begin{aligned}&\text{START}\\&x_1=x_2=0\end{aligned}\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,cB = {latex(cB)}\,\,\,\,\,&&x_2=s_1=0\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,cC = {latex(cC)}\,\,\,\,\,&&'
   r'\begin{aligned}&\text{OPTIMAL}\\&s_1=s_2=0\end{aligned}\\'
   r'\end{aligned}'
))
\[\begin{split}\displaystyle \begin{aligned}db &= (0,0,0,0)\,\,\,rA = \left[\begin{matrix}c & x_{1} & x_{2} & 1 & r\\y_{1} & -20 & -15 & 500 & s_{1}\\y_{2} & -10 & -20 & 400 & s_{2}\\y_{3} & -1 & 0 & 25 & s_{3}\\y_{4} & 0 & -1 & 20 & s_{4}\\-1 & -500 & -750 & 0 & - z\\c & - v_{1} & - v_{2} & w & r\end{matrix}\right]\,\,\,\,\,&&\begin{aligned}&\text{START}\\&x_1=x_2=0\end{aligned}\\db &= (0,0,0,0)\,\,\,rB = \left[\begin{matrix}c & s_{1} & x_{2} & 1 & r\\v_{1} & - \frac{1}{20} & - \frac{3}{4} & 25 & x_{1}\\y_{2} & \frac{1}{2} & - \frac{25}{2} & 150 & s_{2}\\y_{3} & \frac{1}{20} & \frac{3}{4} & 0 & s_{3}\\y_{4} & 0 & -1 & 20 & s_{4}\\-1 & 25 & -375 & -12500 & - z\\c & - y_{1} & - v_{2} & w & r\end{matrix}\right]\,\,\,\,\,&&x_2=s_1=0\\db &= (0,0,0,0)\,\,\,rC = \left[\begin{matrix}c & s_{1} & s_{2} & 1 & r\\v_{1} & - \frac{2}{25} & \frac{3}{50} & 16 & x_{1}\\v_{2} & \frac{1}{25} & - \frac{2}{25} & 12 & x_{2}\\y_{3} & \frac{2}{25} & - \frac{3}{50} & 9 & s_{3}\\y_{4} & - \frac{1}{25} & \frac{2}{25} & 8 & s_{4}\\-1 & 10 & 30 & -17000 & - z\\c & - y_{1} & - y_{2} & w & r\end{matrix}\right]\,\,\,\,\,&&\begin{aligned}&\text{OPTIMAL}\\&s_1=s_2=0\end{aligned}\\db &= (0,0,0,0)\,\,\,cA = \left[\begin{matrix}c & y_{1} & y_{2} & y_{3} & y_{4} & 1 & r\\x_{1} & 20 & 10 & 1 & 0 & -500 & v_{1}\\x_{2} & 15 & 20 & 0 & 1 & -750 & v_{2}\\-1 & 500 & 400 & 25 & 20 & 0 & w\\c & - s_{1} & - s_{2} & - s_{3} & - s_{4} & - z & r\end{matrix}\right]\,\,\,\,\,&&\begin{aligned}&\text{START}\\&x_1=x_2=0\end{aligned}\\db &= (0,0,0,0)\,\,\,cB = \left[\begin{matrix}c & v_{1} & y_{2} & y_{3} & y_{4} & 1 & r\\s_{1} & \frac{1}{20} & - \frac{1}{2} & - \frac{1}{20} & 0 & 25 & y_{1}\\x_{2} & \frac{3}{4} & \frac{25}{2} & - \frac{3}{4} & 1 & -375 & v_{2}\\-1 & 25 & 150 & 0 & 20 & 12500 & w\\c & - x_{1} & - s_{2} & - s_{3} & - s_{4} & - z & r\end{matrix}\right]\,\,\,\,\,&&x_2=s_1=0\\db &= (0,0,0,0)\,\,\,cC = \left[\begin{matrix}c & v_{1} & v_{2} & y_{3} & y_{4} & 1 & r\\s_{1} & \frac{2}{25} & - \frac{1}{25} & - \frac{2}{25} & \frac{1}{25} & 10 & y_{1}\\s_{2} & - \frac{3}{50} & \frac{2}{25} & \frac{3}{50} & - \frac{2}{25} & 30 & y_{2}\\-1 & 16 & 12 & 9 & 8 & 17000 & w\\c & - x_{1} & - x_{2} & - s_{3} & - s_{4} & - z & r\end{matrix}\right]\,\,\,\,\,&&\begin{aligned}&\text{OPTIMAL}\\&s_1=s_2=0\end{aligned}\\\end{aligned}\end{split}\]
Hide code cell source
xStar0=(16,12)
zStar0=z.subs([(x1,xStar0[0]),(x2,xStar0[1])])
yStar =(10,30,0,0)
ROI1  =round((yStar[0]-p1)/p1,2)
ROI2  =round((yStar[1]-p2)/p2,2)

display(Math(
  r"\begin{aligned}"

  r"x^*&="
  f"{xStar0}"
  r"\\"

  r"z^*&="
  f"\${int(zStar0):,.2f}"
  f"&&={latex(z)}"
  r"=w^*"
  r"\\"

  r"y^*&="
  f"{yStar}"
  r"\\"

  r"\text{ROI}_\text{material}&="
  f"{ROI1}"
  r"&&=\frac{y_1^*-p_1}{p_1}"
  r"\\"
  r"\text{ROI}_\text{labor}&="
  f"{ROI2}"
  r"&&=\frac{y_2^*-p_2}{p_2}"
  r"\\"

  r"\end{aligned}"
))
\[\begin{split}\displaystyle \begin{aligned}x^*&=(16, 12)\\z^*&=\$17,000.00&&=500 x_{1} + 750 x_{2}=w^*\\y^*&=(10, 30, 0, 0)\\\text{ROI}_\text{material}&=0.11&&=\frac{y_1^*-p_1}{p_1}\\\text{ROI}_\text{labor}&=0.33&&=\frac{y_2^*-p_2}{p_2}\\\end{aligned}\end{split}\]

Graphical#

display(
'LINES',
Math(f"g_1 : {latex(solve(g1,x2,dict=True)[0])}"),
Math(f"g_2 : {latex(solve(g2,x2,dict=True)[0])}"),
Math(f"g_4 : {latex(solve(g4,x2,dict=True)[0])}"),
'FEASIBLE SIDES',
Math(f"g_1 : {latex(reduce_inequalities(g1<=0,[x2]))}"),
Math(f"g_2 : {latex(reduce_inequalities(g2<=0,[x2]))}"),
Math(f"g_3 : {latex(reduce_inequalities(g3<=0,[x2]))}"),
Math(f"g_4 : {latex(reduce_inequalities(g4<=0,[x2]))}"),
'INTERSECTIONS',
Math(f"g_1=g_2    : {latex(solve([g1,g2],[x1,x2],dict=True)[0])}"),
Math(f"g_1=g_3    : {latex(solve([g1,g3],[x1,x2],dict=True)[0])}"),
Math(f"g_1=g_4    : {latex(solve([g1,g4],[x1,x2],dict=True)[0])}"),
Math(f"g_2=g_3    : {latex(solve([g2,g3],[x1,x2],dict=True)[0])}"),
Math(f"g_2=g_4    : {latex(solve([g2,g4],[x1,x2],dict=True)[0])}"),
Math(f"g_3=g_4    : {latex(solve([g3,g4],[x1,x2],dict=True)[0])}"),
Math(f"g_1[ 0,x2] : {latex(solve([g1,x1],[x1,x2],dict=True)[0])}"),
Math(f"g_1[x1, 0] : {latex(solve([g1,x2],[x1,x2],dict=True)[0])}"),
Math(f"g_2[ 0,x2] : {latex(solve([g2,x1],[x1,x2],dict=True)[0])}"),
Math(f"g_2[x1, 0] : {latex(solve([g2,x2],[x1,x2],dict=True)[0])}"),
Math(f"g_3[x1, 0] : {latex(solve([g3,x2],[x1,x2],dict=True)[0])}"),
Math(f"g_4[ 0,x2] : {latex(solve([g4,x1],[x1,x2],dict=True)[0])}"),
)
'LINES'
\[\displaystyle g_1 : \left\{ x_{2} : \frac{100}{3} - \frac{4 x_{1}}{3}\right\}\]
\[\displaystyle g_2 : \left\{ x_{2} : 20 - \frac{x_{1}}{2}\right\}\]
\[\displaystyle g_4 : \left\{ x_{2} : 20\right\}\]
'FEASIBLE SIDES'
\[\displaystyle g_1 : x_{2} \leq \frac{100}{3} - \frac{4 x_{1}}{3} \wedge -\infty < x_{2}\]
\[\displaystyle g_2 : x_{2} \leq 20 - \frac{x_{1}}{2} \wedge -\infty < x_{2}\]
\[\displaystyle g_3 : x_{1} \leq 25 \wedge -\infty < x_{1}\]
\[\displaystyle g_4 : x_{2} \leq 20 \wedge -\infty < x_{2}\]
'INTERSECTIONS'
\[\displaystyle g_1=g_2 : \left\{ x_{1} : 16, \ x_{2} : 12\right\}\]
\[\displaystyle g_1=g_3 : \left\{ x_{1} : 25, \ x_{2} : 0\right\}\]
\[\displaystyle g_1=g_4 : \left\{ x_{1} : 10, \ x_{2} : 20\right\}\]
\[\displaystyle g_2=g_3 : \left\{ x_{1} : 25, \ x_{2} : \frac{15}{2}\right\}\]
\[\displaystyle g_2=g_4 : \left\{ x_{1} : 0, \ x_{2} : 20\right\}\]
\[\displaystyle g_3=g_4 : \left\{ x_{1} : 25, \ x_{2} : 20\right\}\]
\[\displaystyle g_1[ 0,x2] : \left\{ x_{1} : 0, \ x_{2} : \frac{100}{3}\right\}\]
\[\displaystyle g_1[x1, 0] : \left\{ x_{1} : 25, \ x_{2} : 0\right\}\]
\[\displaystyle g_2[ 0,x2] : \left\{ x_{1} : 0, \ x_{2} : 20\right\}\]
\[\displaystyle g_2[x1, 0] : \left\{ x_{1} : 40, \ x_{2} : 0\right\}\]
\[\displaystyle g_3[x1, 0] : \left\{ x_{1} : 25, \ x_{2} : 0\right\}\]
\[\displaystyle g_4[ 0,x2] : \left\{ x_{1} : 0, \ x_{2} : 20\right\}\]
s =40
x =np.linspace(0,s,1001)

# slopes
s1=-(4/3)
s2=-(1/2)
s4=0

y1=s1*x+(100/3)
y2=s2*x+( 20/1)
y4=s4*x+20
Hide code cell source
fig=plt.figure(dpi=300);

##########

ax =plt.subplot();
ax.set_aspect(1);

# LINES
ax.plot   (x,y1,label='g1=b1',linewidth=0.5,color='blue');
ax.plot   (x,y2,label='g2=b2',linewidth=0.5,color='yellow');
ax.axvline(  25,label='g3=b3',linewidth=0.5,color='green');
ax.plot   (x,y4,label='g4=b4',linewidth=0.5,color='red');

# DELZ
ax.arrow(10,10,*unitVector(  delz),width=0.01,head_width=0.2,length_includes_head=True,color='black');

# FEASIBLE SIDES <=
ax.arrow(10,10,*unitVector(-delg1),width=0.01,head_width=0.2,length_includes_head=True,color='blue');
ax.arrow(10,10,*unitVector(-delg2),width=0.01,head_width=0.2,length_includes_head=True,color='yellow');
ax.arrow(10,10,*unitVector(-delg3),width=0.01,head_width=0.2,length_includes_head=True,color='green');
ax.arrow(10,10,*unitVector(-delg4),width=0.01,head_width=0.2,length_includes_head=True,color='red');

# DIRECTIONS
ax.arrow(25, 0,*udg1*3,            width=0.3, head_width=1,  length_includes_head=True,color='blue');
ax.arrow( 0,20,*udg2*3,            width=0.3, head_width=1,  length_includes_head=True,color='yellow');
ax.arrow(25, 0,*udg3*3,            width=0.3, head_width=1,  length_includes_head=True,color='green');
ax.arrow( 0,20,*udg4*3,            width=0.3, head_width=1,  length_includes_head=True,color='red');

# FEASIBLE REGION
fx,fy=np.meshgrid(x,x)
plt.imshow(
  (
     (fy<=s1*fx+(100/3))
   & (fy<=s2*fx+( 20/1))
   & (fy<=s4*fx+20     )
  ).astype(int),
  extent=(fx.min(),fx.max(),fy.min(),fy.max()),
  origin='lower',
  cmap  ='Greys',
  alpha =0.3,
);

ax.set_xlim(0,s);
ax.set_ylim(0,s);
ax.legend();

# XSTAR
ax.scatter(*xStar0,s=1e2,color='purple');

sol=(
  r'\begin{eqnarray*}'
  f'x^*&=&{xStar0}'
  r'\\'
  f'z^*&=&\${round(float(zStar0),2):,.2f}=w^*'
  r'\\'
  f'y^*&=&{yStar}'
  r'\\'
  r'\mathrm{ROI}_\mathrm{material}'
  f'&=&{ROI1}'
  r'\\'
  r'\mathrm{ROI}_\mathrm{labor}'
  f'&=&{ROI2}'
  r'\end{eqnarray*}'
)
ax.text(10,35,sol,fontsize=10);

# SIMPLEX
dx,dy=1,1
ax.annotate('$A$',(        0+dx,        0+dy));
ax.annotate('$B$',(       25+dx,        0+dy));
ax.annotate('$C$',(xStar0[0]+dx,xStar0[1]+dy));
Error in callback <function _draw_all_if_interactive at 0x1302e8e00> (for post_execute), with arguments args (),kwargs {}:
---------------------------------------------------------------------------
PermissionError                           Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/pyplot.py:197, in _draw_all_if_interactive()
    195 def _draw_all_if_interactive() -> None:
    196     if matplotlib.is_interactive():
--> 197         draw_all()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/_pylab_helpers.py:132, in Gcf.draw_all(cls, force)
    130 for manager in cls.get_all_fig_managers():
    131     if force or manager.canvas.figure.stale:
--> 132         manager.canvas.draw_idle()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:1893, in FigureCanvasBase.draw_idle(self, *args, **kwargs)
   1891 if not self._is_idle_drawing:
   1892     with self._idle_draw_cntx():
-> 1893         self.draw(*args, **kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
    385 # Acquire a lock on the shared font cache.
    386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
    387       else nullcontext()):
--> 388     self.figure.draw(self.renderer)
    389     # A GUI class may be need to update a window using this draw, so
    390     # don't forget to call the superclass.
    391     super().draw()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
     93 @wraps(draw)
     94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95     result = draw(artist, renderer, *args, **kwargs)
     96     if renderer._rasterizing:
     97         renderer.stop_rasterizing()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
   3151         # ValueError can occur when resizing a window.
   3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
   3155     renderer, self, artists, self.suppressComposite)
   3157 for sfig in self.subfigs:
   3158     sfig.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    130 if not_composite or not has_images:
    131     for a in artists:
--> 132         a.draw(renderer)
    133 else:
    134     # Composite any adjacent images together
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axes/_base.py:3070, in _AxesBase.draw(self, renderer)
   3067 if artists_rasterized:
   3068     _draw_rasterized(self.figure, artists_rasterized, renderer)
-> 3070 mimage._draw_list_compositing_images(
   3071     renderer, self, artists, self.figure.suppressComposite)
   3073 renderer.close_group('axes')
   3074 self.stale = False

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    130 if not_composite or not has_images:
    131     for a in artists:
--> 132         a.draw(renderer)
    133 else:
    134     # Composite any adjacent images together
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1388, in Axis.draw(self, renderer, *args, **kwargs)
   1385 renderer.open_group(__name__, gid=self.get_gid())
   1387 ticks_to_draw = self._update_ticks()
-> 1388 tlb1, tlb2 = self._get_ticklabel_bboxes(ticks_to_draw, renderer)
   1390 for tick in ticks_to_draw:
   1391     tick.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in Axis._get_ticklabel_bboxes(self, ticks, renderer)
   1313 if renderer is None:
   1314     renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
   1316          for tick in ticks if tick.label1.get_visible()],
   1317         [tick.label2.get_window_extent(renderer)
   1318          for tick in ticks if tick.label2.get_visible()])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in <listcomp>(.0)
   1313 if renderer is None:
   1314     renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
   1316          for tick in ticks if tick.label1.get_visible()],
   1317         [tick.label2.get_window_extent(renderer)
   1318          for tick in ticks if tick.label2.get_visible()])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:956, in Text.get_window_extent(self, renderer, dpi)
    951     raise RuntimeError(
    952         "Cannot get window extent of text w/o renderer. You likely "
    953         "want to call 'figure.draw_without_rendering()' first.")
    955 with cbook._setattr_cm(self.figure, dpi=dpi):
--> 956     bbox, info, descent = self._get_layout(self._renderer)
    957     x, y = self.get_unitless_position()
    958     x, y = self.get_transform().transform((x, y))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
    370 ys = []
    372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
    374     renderer, "lp", self._fontproperties,
    375     ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
    376 min_dy = (lp_h - lp_d) * self._linespacing
    378 for i, line in enumerate(lines):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
     66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
     67 # Cached based on a copy of fontprop so that later in-place mutations of
     68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
     70     weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
     73 @functools.lru_cache(4096)
     74 def _get_text_metrics_with_cache_impl(
     75         renderer_ref, text, fontprop, ismath, dpi):
     76     # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77     return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
    211 _api.check_in_list(["TeX", True, False], ismath=ismath)
    212 if ismath == "TeX":
--> 213     return super().get_text_width_height_descent(s, prop, ismath)
    215 if ismath:
    216     ox, oy, width, height, descent, font_image = \
    217         self.mathtext_parser.parse(s, self.dpi, prop)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
    648 fontsize = prop.get_size_in_points()
    650 if ismath == 'TeX':
    651     # todo: handle properties
--> 652     return self.get_texmanager().get_text_width_height_descent(
    653         s, fontsize, renderer=self)
    655 dpi = self.points_to_pixels(72)
    656 if ismath:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
    364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
    365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366     page, = dvi
    367 # A total height (including the descent) needs to be returned.
    368 return page.width, page.height + page.descent, page.descent

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
    280 def __iter__(self):
    281     """
    282     Iterate through the pages of the file.
    283 
   (...)
    294         integers.
    295     """
--> 296     while self._read():
    297         yield self._output()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
    373 while True:
    374     byte = self.file.read(1)[0]
--> 375     self._dtable[byte](self, byte)
    376     name = self._dtable[byte].__name__
    377     if name == "_push":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
    225 if state is not None and self.state != state:
    226     raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
    524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
    525 def _fnt_def(self, k, c, s, d, a, l):
--> 526     self._fnt_def_real(k, c, s, d, a, l)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
    529 n = self.file.read(a + l)
    530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
    532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
    533     raise ValueError('tfm checksum mismatch: %s' % n)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
   1114 @lru_cache
   1115 def _fontfile(cls, suffix, texname):
-> 1116     return cls(find_tex_file(texname + suffix))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
   1079     filename = filename.decode('utf-8', errors='replace')
   1081 try:
-> 1082     lk = _LuatexKpsewhich()
   1083 except FileNotFoundError:
   1084     lk = None  # Fallback to directly calling kpsewhich, as below.

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
   1034 @lru_cache  # A singleton.
   1035 def __new__(cls):
   1036     self = object.__new__(cls)
-> 1037     self._proc = self._new_proc()
   1038     return self

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
   1040 def _new_proc(self):
-> 1041     return subprocess.Popen(
   1042         ["luatex", "--luaonly",
   1043          str(cbook._get_data_path("kpsewhich.lua"))],
   1044         stdin=subprocess.PIPE, stdout=subprocess.PIPE)

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
   1953     err_msg = os.strerror(errno_num)
   1954 if err_filename is not None:
-> 1955     raise child_exception_type(errno_num, err_msg, err_filename)
   1956 else:
   1957     raise child_exception_type(errno_num, err_msg)

PermissionError: [Errno 13] Permission denied: 'luatex'
---------------------------------------------------------------------------
PermissionError                           Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
    341     pass
    342 else:
--> 343     return printer(obj)
    344 # Finally look for special method names
    345 method = get_real_method(obj, self.print_method)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/pylabtools.py:152, in print_figure(fig, fmt, bbox_inches, base64, **kwargs)
    149     from matplotlib.backend_bases import FigureCanvasBase
    150     FigureCanvasBase(fig)
--> 152 fig.canvas.print_figure(bytes_io, **kw)
    153 data = bytes_io.getvalue()
    154 if fmt == 'svg':

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2164, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
   2161     # we do this instead of `self.figure.draw_without_rendering`
   2162     # so that we can inject the orientation
   2163     with getattr(renderer, "_draw_disabled", nullcontext)():
-> 2164         self.figure.draw(renderer)
   2165 if bbox_inches:
   2166     if bbox_inches == "tight":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
     93 @wraps(draw)
     94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95     result = draw(artist, renderer, *args, **kwargs)
     96     if renderer._rasterizing:
     97         renderer.stop_rasterizing()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
   3151         # ValueError can occur when resizing a window.
   3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
   3155     renderer, self, artists, self.suppressComposite)
   3157 for sfig in self.subfigs:
   3158     sfig.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    130 if not_composite or not has_images:
    131     for a in artists:
--> 132         a.draw(renderer)
    133 else:
    134     # Composite any adjacent images together
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axes/_base.py:3070, in _AxesBase.draw(self, renderer)
   3067 if artists_rasterized:
   3068     _draw_rasterized(self.figure, artists_rasterized, renderer)
-> 3070 mimage._draw_list_compositing_images(
   3071     renderer, self, artists, self.figure.suppressComposite)
   3073 renderer.close_group('axes')
   3074 self.stale = False

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    130 if not_composite or not has_images:
    131     for a in artists:
--> 132         a.draw(renderer)
    133 else:
    134     # Composite any adjacent images together
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1388, in Axis.draw(self, renderer, *args, **kwargs)
   1385 renderer.open_group(__name__, gid=self.get_gid())
   1387 ticks_to_draw = self._update_ticks()
-> 1388 tlb1, tlb2 = self._get_ticklabel_bboxes(ticks_to_draw, renderer)
   1390 for tick in ticks_to_draw:
   1391     tick.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in Axis._get_ticklabel_bboxes(self, ticks, renderer)
   1313 if renderer is None:
   1314     renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
   1316          for tick in ticks if tick.label1.get_visible()],
   1317         [tick.label2.get_window_extent(renderer)
   1318          for tick in ticks if tick.label2.get_visible()])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in <listcomp>(.0)
   1313 if renderer is None:
   1314     renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
   1316          for tick in ticks if tick.label1.get_visible()],
   1317         [tick.label2.get_window_extent(renderer)
   1318          for tick in ticks if tick.label2.get_visible()])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:956, in Text.get_window_extent(self, renderer, dpi)
    951     raise RuntimeError(
    952         "Cannot get window extent of text w/o renderer. You likely "
    953         "want to call 'figure.draw_without_rendering()' first.")
    955 with cbook._setattr_cm(self.figure, dpi=dpi):
--> 956     bbox, info, descent = self._get_layout(self._renderer)
    957     x, y = self.get_unitless_position()
    958     x, y = self.get_transform().transform((x, y))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
    370 ys = []
    372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
    374     renderer, "lp", self._fontproperties,
    375     ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
    376 min_dy = (lp_h - lp_d) * self._linespacing
    378 for i, line in enumerate(lines):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
     66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
     67 # Cached based on a copy of fontprop so that later in-place mutations of
     68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
     70     weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
     73 @functools.lru_cache(4096)
     74 def _get_text_metrics_with_cache_impl(
     75         renderer_ref, text, fontprop, ismath, dpi):
     76     # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77     return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
    211 _api.check_in_list(["TeX", True, False], ismath=ismath)
    212 if ismath == "TeX":
--> 213     return super().get_text_width_height_descent(s, prop, ismath)
    215 if ismath:
    216     ox, oy, width, height, descent, font_image = \
    217         self.mathtext_parser.parse(s, self.dpi, prop)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
    648 fontsize = prop.get_size_in_points()
    650 if ismath == 'TeX':
    651     # todo: handle properties
--> 652     return self.get_texmanager().get_text_width_height_descent(
    653         s, fontsize, renderer=self)
    655 dpi = self.points_to_pixels(72)
    656 if ismath:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
    364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
    365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366     page, = dvi
    367 # A total height (including the descent) needs to be returned.
    368 return page.width, page.height + page.descent, page.descent

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
    280 def __iter__(self):
    281     """
    282     Iterate through the pages of the file.
    283 
   (...)
    294         integers.
    295     """
--> 296     while self._read():
    297         yield self._output()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
    373 while True:
    374     byte = self.file.read(1)[0]
--> 375     self._dtable[byte](self, byte)
    376     name = self._dtable[byte].__name__
    377     if name == "_push":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
    225 if state is not None and self.state != state:
    226     raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
    524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
    525 def _fnt_def(self, k, c, s, d, a, l):
--> 526     self._fnt_def_real(k, c, s, d, a, l)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
    529 n = self.file.read(a + l)
    530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
    532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
    533     raise ValueError('tfm checksum mismatch: %s' % n)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
   1114 @lru_cache
   1115 def _fontfile(cls, suffix, texname):
-> 1116     return cls(find_tex_file(texname + suffix))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
   1079     filename = filename.decode('utf-8', errors='replace')
   1081 try:
-> 1082     lk = _LuatexKpsewhich()
   1083 except FileNotFoundError:
   1084     lk = None  # Fallback to directly calling kpsewhich, as below.

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
   1034 @lru_cache  # A singleton.
   1035 def __new__(cls):
   1036     self = object.__new__(cls)
-> 1037     self._proc = self._new_proc()
   1038     return self

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
   1040 def _new_proc(self):
-> 1041     return subprocess.Popen(
   1042         ["luatex", "--luaonly",
   1043          str(cbook._get_data_path("kpsewhich.lua"))],
   1044         stdin=subprocess.PIPE, stdout=subprocess.PIPE)

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
   1953     err_msg = os.strerror(errno_num)
   1954 if err_filename is not None:
-> 1955     raise child_exception_type(errno_num, err_msg, err_filename)
   1956 else:
   1957     raise child_exception_type(errno_num, err_msg)

PermissionError: [Errno 13] Permission denied: 'luatex'
<Figure size 1920x1440 with 1 Axes>

[B] Is it profitable for the company to purchase additional material?#

\( \begin{aligned} \text{change in revenue per unit change in material}\,\,\, \partial z^*&=y_1^*\partial b_1 \impliedby y_1^*=\frac{\partial z^*}{\partial b_1} \\ \text{profit}\,\,\, &=\text{change in revenue}-\text{cost of material} \\ &=y_1^*\partial b_1-p_1\partial b_1 \\ &=(y_1^*-p_1)\partial b_1 \end{aligned} \)

Hide code cell source
g2g3  =solve([g2,g3])
xStar1=(g2g3[x1],g2g3[x2])
g1n   =s1*(x1-xStar1[0])+xStar1[1]
b1n   =Fraction(float(g1.subs([(x1,xStar1[0]),(x2,xStar1[1])])+b1)).limit_denominator(2)
db1   =b1n-b1
rc    =p1*db1
zStar1=z.subs([(x1,xStar1[0]),(x2,xStar1[1])])-rc
dzStar=yStar[0]*db1-rc

# db1=symbols('db1')
# solve([
#   g1.subs([(x1,25)])-db1,
#   g2.subs([(x1,25)]),
# ],[db1,x2])

display(Math(
  r"\begin{aligned}"

  r"y_1^*\overset{?}{\gt}p_1&\implies"
  f"{yStar[0]}"
  r"\overset{?}{\gt}"
  f"{p1}"
  r"\\"

  r"g_2=g_3&\implies"
  f"{latex(g2g3)}"
  r"\\"

  r"x^*(\text{new})&="
  f"{xStar1}"
  r"\\"

  r"g_1(\text{new})&="
  f"{latex(nsimplify(g1n))}"
  r"\\"

  r"g_1(\text{new})=x_2&\implies x_1="
  f"{latex(nsimplify(solve([g1n,x2])[x1]))}"
  r"\\"

  r" b_1(\text{new})&="
  f"{b1n}"
  r"\\"

 fr"db_1&={db1}"
  r"&&=b_1(\text{new})-b_1"
  r"\\"

  r"\text{cost}_\text{material}&="
  f"\${rc:,.2f}"
  r"&&=p_1\partial b_1"
  r"\\"

  r"z^*(\text{new})&="
  f"\${zStar1:,.2f}"
  f"&&={latex(z-rc)}"
  r"=w^*\\"

  r"\partial z^*&="
  f"\${dzStar:,.2f}"
  r"&&=y_1^*\partial b_1=z^*(\text{new})-z^*"
  r"\\"

  r"\end{aligned}"
))
\[\begin{split}\displaystyle \begin{aligned}y_1^*\overset{?}{\gt}p_1&\implies10\overset{?}{\gt}9.0\\g_2=g_3&\implies\left\{ x_{1} : 25, \ x_{2} : \frac{15}{2}\right\}\\x^*(\text{new})&=(25, 15/2)\\g_1(\text{new})&=\frac{245}{6} - \frac{4 x_{1}}{3}\\g_1(\text{new})=x_2&\implies x_1=\frac{245}{8}\\ b_1(\text{new})&=1225/2\\db_1&=225/2&&=b_1(\text{new})-b_1\\\text{cost}_\text{material}&=\$1,012.50&&=p_1\partial b_1\\z^*(\text{new})&=\$17,112.50&&=500 x_{1} + 750 x_{2} - 1012.5=w^*\\\partial z^*&=\$112.50&&=y_1^*\partial b_1=z^*(\text{new})-z^*\\\end{aligned}\end{split}\]
Hide code cell source
fig=plt.figure(dpi=300);

##########

ax =plt.subplot();
ax.set_aspect(1);

# LINES
ax.plot   (x,y1,                        label='g1=b1',    linewidth=0.5,linestyle=(0,(5,10)),color='blue');
ax.plot   (x,s1*(x-xStar1[0])+xStar1[1],label='g1=b1+db1',linewidth=0.5,                     color='blue');
ax.plot   (x,y2,                        label='g2=b2',    linewidth=0.5,                     color='yellow');
ax.axvline(  25,                        label='g3=b3',    linewidth=0.5,                     color='green');
ax.plot   (x,y4,                        label='g4=b4',    linewidth=0.5,                     color='red');

# DELZ
ax.arrow(10,10,*unitVector(  delz),width=0.01,head_width=0.2,length_includes_head=True,color='black');

# FEASIBLE SIDES <=
ax.arrow(10,10,*unitVector(-delg1),width=0.01,head_width=0.2,length_includes_head=True,color='blue');
ax.arrow(10,10,*unitVector(-delg2),width=0.01,head_width=0.2,length_includes_head=True,color='yellow');
ax.arrow(10,10,*unitVector(-delg3),width=0.01,head_width=0.2,length_includes_head=True,color='green');
ax.arrow(10,10,*unitVector(-delg4),width=0.01,head_width=0.2,length_includes_head=True,color='red');

# DIRECTIONS
ax.arrow(25, 0,*udg1*3,            width=0.3, head_width=1,  length_includes_head=True,color='blue');
ax.arrow( 0,20,*udg2*3,            width=0.3, head_width=1,  length_includes_head=True,color='yellow');
ax.arrow(25, 0,*udg3*3,            width=0.3, head_width=1,  length_includes_head=True,color='green');
ax.arrow( 0,20,*udg4*3,            width=0.3, head_width=1,  length_includes_head=True,color='red');

# FEASIBLE REGION
fx,fy=np.meshgrid(x,x)
plt.imshow(
  (
     (fy<=s1*(fx-float(xStar1[0]))+float(xStar1[1]))
   & (fy<=s2*fx+20)
   & (fx<=25)
   & (fy<= 0*fx+20)
  ).astype(int),
  extent=(fx.min(),fx.max(),fy.min(),fy.max()),
  origin='lower',
  cmap  ='Greys',
  alpha =0.3,
);

ax.set_xlim(0,s);
ax.set_ylim(0,s);
ax.legend();

# XSTAR
ax.scatter(*xStar1,s=1e2,color='purple');

sol=(
  r'\begin{eqnarray*}'
  f'x^*&=&{xStar1}'
  r'\\'
  f'z^*&=&\${round(zStar1,2):,.2f}=w^*'
  r'\\'
  r'\end{eqnarray*}'
)
ax.text(10,35,sol,fontsize=10);

# SIMPLEX
# dx,dy=1,1
# ax.annotate('$A$',(       0+dx,       0+dy));
# ax.annotate('$B$',( (245/8)+dx,       0+dy));
# ax.annotate('$C$',(xStar1[0]+dx,xStar1[1]+dy));
Error in callback <function _draw_all_if_interactive at 0x1302e8e00> (for post_execute), with arguments args (),kwargs {}:
---------------------------------------------------------------------------
PermissionError                           Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/pyplot.py:197, in _draw_all_if_interactive()
    195 def _draw_all_if_interactive() -> None:
    196     if matplotlib.is_interactive():
--> 197         draw_all()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/_pylab_helpers.py:132, in Gcf.draw_all(cls, force)
    130 for manager in cls.get_all_fig_managers():
    131     if force or manager.canvas.figure.stale:
--> 132         manager.canvas.draw_idle()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:1893, in FigureCanvasBase.draw_idle(self, *args, **kwargs)
   1891 if not self._is_idle_drawing:
   1892     with self._idle_draw_cntx():
-> 1893         self.draw(*args, **kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
    385 # Acquire a lock on the shared font cache.
    386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
    387       else nullcontext()):
--> 388     self.figure.draw(self.renderer)
    389     # A GUI class may be need to update a window using this draw, so
    390     # don't forget to call the superclass.
    391     super().draw()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
     93 @wraps(draw)
     94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95     result = draw(artist, renderer, *args, **kwargs)
     96     if renderer._rasterizing:
     97         renderer.stop_rasterizing()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
   3151         # ValueError can occur when resizing a window.
   3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
   3155     renderer, self, artists, self.suppressComposite)
   3157 for sfig in self.subfigs:
   3158     sfig.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    130 if not_composite or not has_images:
    131     for a in artists:
--> 132         a.draw(renderer)
    133 else:
    134     # Composite any adjacent images together
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axes/_base.py:3070, in _AxesBase.draw(self, renderer)
   3067 if artists_rasterized:
   3068     _draw_rasterized(self.figure, artists_rasterized, renderer)
-> 3070 mimage._draw_list_compositing_images(
   3071     renderer, self, artists, self.figure.suppressComposite)
   3073 renderer.close_group('axes')
   3074 self.stale = False

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    130 if not_composite or not has_images:
    131     for a in artists:
--> 132         a.draw(renderer)
    133 else:
    134     # Composite any adjacent images together
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1388, in Axis.draw(self, renderer, *args, **kwargs)
   1385 renderer.open_group(__name__, gid=self.get_gid())
   1387 ticks_to_draw = self._update_ticks()
-> 1388 tlb1, tlb2 = self._get_ticklabel_bboxes(ticks_to_draw, renderer)
   1390 for tick in ticks_to_draw:
   1391     tick.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in Axis._get_ticklabel_bboxes(self, ticks, renderer)
   1313 if renderer is None:
   1314     renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
   1316          for tick in ticks if tick.label1.get_visible()],
   1317         [tick.label2.get_window_extent(renderer)
   1318          for tick in ticks if tick.label2.get_visible()])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in <listcomp>(.0)
   1313 if renderer is None:
   1314     renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
   1316          for tick in ticks if tick.label1.get_visible()],
   1317         [tick.label2.get_window_extent(renderer)
   1318          for tick in ticks if tick.label2.get_visible()])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:956, in Text.get_window_extent(self, renderer, dpi)
    951     raise RuntimeError(
    952         "Cannot get window extent of text w/o renderer. You likely "
    953         "want to call 'figure.draw_without_rendering()' first.")
    955 with cbook._setattr_cm(self.figure, dpi=dpi):
--> 956     bbox, info, descent = self._get_layout(self._renderer)
    957     x, y = self.get_unitless_position()
    958     x, y = self.get_transform().transform((x, y))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
    370 ys = []
    372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
    374     renderer, "lp", self._fontproperties,
    375     ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
    376 min_dy = (lp_h - lp_d) * self._linespacing
    378 for i, line in enumerate(lines):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
     66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
     67 # Cached based on a copy of fontprop so that later in-place mutations of
     68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
     70     weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
     73 @functools.lru_cache(4096)
     74 def _get_text_metrics_with_cache_impl(
     75         renderer_ref, text, fontprop, ismath, dpi):
     76     # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77     return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
    211 _api.check_in_list(["TeX", True, False], ismath=ismath)
    212 if ismath == "TeX":
--> 213     return super().get_text_width_height_descent(s, prop, ismath)
    215 if ismath:
    216     ox, oy, width, height, descent, font_image = \
    217         self.mathtext_parser.parse(s, self.dpi, prop)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
    648 fontsize = prop.get_size_in_points()
    650 if ismath == 'TeX':
    651     # todo: handle properties
--> 652     return self.get_texmanager().get_text_width_height_descent(
    653         s, fontsize, renderer=self)
    655 dpi = self.points_to_pixels(72)
    656 if ismath:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
    364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
    365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366     page, = dvi
    367 # A total height (including the descent) needs to be returned.
    368 return page.width, page.height + page.descent, page.descent

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
    280 def __iter__(self):
    281     """
    282     Iterate through the pages of the file.
    283 
   (...)
    294         integers.
    295     """
--> 296     while self._read():
    297         yield self._output()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
    373 while True:
    374     byte = self.file.read(1)[0]
--> 375     self._dtable[byte](self, byte)
    376     name = self._dtable[byte].__name__
    377     if name == "_push":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
    225 if state is not None and self.state != state:
    226     raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
    524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
    525 def _fnt_def(self, k, c, s, d, a, l):
--> 526     self._fnt_def_real(k, c, s, d, a, l)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
    529 n = self.file.read(a + l)
    530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
    532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
    533     raise ValueError('tfm checksum mismatch: %s' % n)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
   1114 @lru_cache
   1115 def _fontfile(cls, suffix, texname):
-> 1116     return cls(find_tex_file(texname + suffix))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
   1079     filename = filename.decode('utf-8', errors='replace')
   1081 try:
-> 1082     lk = _LuatexKpsewhich()
   1083 except FileNotFoundError:
   1084     lk = None  # Fallback to directly calling kpsewhich, as below.

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
   1034 @lru_cache  # A singleton.
   1035 def __new__(cls):
   1036     self = object.__new__(cls)
-> 1037     self._proc = self._new_proc()
   1038     return self

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
   1040 def _new_proc(self):
-> 1041     return subprocess.Popen(
   1042         ["luatex", "--luaonly",
   1043          str(cbook._get_data_path("kpsewhich.lua"))],
   1044         stdin=subprocess.PIPE, stdout=subprocess.PIPE)

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
   1953     err_msg = os.strerror(errno_num)
   1954 if err_filename is not None:
-> 1955     raise child_exception_type(errno_num, err_msg, err_filename)
   1956 else:
   1957     raise child_exception_type(errno_num, err_msg)

PermissionError: [Errno 13] Permission denied: 'luatex'
---------------------------------------------------------------------------
PermissionError                           Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
    341     pass
    342 else:
--> 343     return printer(obj)
    344 # Finally look for special method names
    345 method = get_real_method(obj, self.print_method)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/pylabtools.py:152, in print_figure(fig, fmt, bbox_inches, base64, **kwargs)
    149     from matplotlib.backend_bases import FigureCanvasBase
    150     FigureCanvasBase(fig)
--> 152 fig.canvas.print_figure(bytes_io, **kw)
    153 data = bytes_io.getvalue()
    154 if fmt == 'svg':

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2164, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
   2161     # we do this instead of `self.figure.draw_without_rendering`
   2162     # so that we can inject the orientation
   2163     with getattr(renderer, "_draw_disabled", nullcontext)():
-> 2164         self.figure.draw(renderer)
   2165 if bbox_inches:
   2166     if bbox_inches == "tight":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
     93 @wraps(draw)
     94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95     result = draw(artist, renderer, *args, **kwargs)
     96     if renderer._rasterizing:
     97         renderer.stop_rasterizing()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
   3151         # ValueError can occur when resizing a window.
   3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
   3155     renderer, self, artists, self.suppressComposite)
   3157 for sfig in self.subfigs:
   3158     sfig.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    130 if not_composite or not has_images:
    131     for a in artists:
--> 132         a.draw(renderer)
    133 else:
    134     # Composite any adjacent images together
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axes/_base.py:3070, in _AxesBase.draw(self, renderer)
   3067 if artists_rasterized:
   3068     _draw_rasterized(self.figure, artists_rasterized, renderer)
-> 3070 mimage._draw_list_compositing_images(
   3071     renderer, self, artists, self.figure.suppressComposite)
   3073 renderer.close_group('axes')
   3074 self.stale = False

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    130 if not_composite or not has_images:
    131     for a in artists:
--> 132         a.draw(renderer)
    133 else:
    134     # Composite any adjacent images together
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1388, in Axis.draw(self, renderer, *args, **kwargs)
   1385 renderer.open_group(__name__, gid=self.get_gid())
   1387 ticks_to_draw = self._update_ticks()
-> 1388 tlb1, tlb2 = self._get_ticklabel_bboxes(ticks_to_draw, renderer)
   1390 for tick in ticks_to_draw:
   1391     tick.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in Axis._get_ticklabel_bboxes(self, ticks, renderer)
   1313 if renderer is None:
   1314     renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
   1316          for tick in ticks if tick.label1.get_visible()],
   1317         [tick.label2.get_window_extent(renderer)
   1318          for tick in ticks if tick.label2.get_visible()])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in <listcomp>(.0)
   1313 if renderer is None:
   1314     renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
   1316          for tick in ticks if tick.label1.get_visible()],
   1317         [tick.label2.get_window_extent(renderer)
   1318          for tick in ticks if tick.label2.get_visible()])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:956, in Text.get_window_extent(self, renderer, dpi)
    951     raise RuntimeError(
    952         "Cannot get window extent of text w/o renderer. You likely "
    953         "want to call 'figure.draw_without_rendering()' first.")
    955 with cbook._setattr_cm(self.figure, dpi=dpi):
--> 956     bbox, info, descent = self._get_layout(self._renderer)
    957     x, y = self.get_unitless_position()
    958     x, y = self.get_transform().transform((x, y))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
    370 ys = []
    372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
    374     renderer, "lp", self._fontproperties,
    375     ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
    376 min_dy = (lp_h - lp_d) * self._linespacing
    378 for i, line in enumerate(lines):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
     66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
     67 # Cached based on a copy of fontprop so that later in-place mutations of
     68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
     70     weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
     73 @functools.lru_cache(4096)
     74 def _get_text_metrics_with_cache_impl(
     75         renderer_ref, text, fontprop, ismath, dpi):
     76     # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77     return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
    211 _api.check_in_list(["TeX", True, False], ismath=ismath)
    212 if ismath == "TeX":
--> 213     return super().get_text_width_height_descent(s, prop, ismath)
    215 if ismath:
    216     ox, oy, width, height, descent, font_image = \
    217         self.mathtext_parser.parse(s, self.dpi, prop)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
    648 fontsize = prop.get_size_in_points()
    650 if ismath == 'TeX':
    651     # todo: handle properties
--> 652     return self.get_texmanager().get_text_width_height_descent(
    653         s, fontsize, renderer=self)
    655 dpi = self.points_to_pixels(72)
    656 if ismath:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
    364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
    365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366     page, = dvi
    367 # A total height (including the descent) needs to be returned.
    368 return page.width, page.height + page.descent, page.descent

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
    280 def __iter__(self):
    281     """
    282     Iterate through the pages of the file.
    283 
   (...)
    294         integers.
    295     """
--> 296     while self._read():
    297         yield self._output()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
    373 while True:
    374     byte = self.file.read(1)[0]
--> 375     self._dtable[byte](self, byte)
    376     name = self._dtable[byte].__name__
    377     if name == "_push":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
    225 if state is not None and self.state != state:
    226     raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
    524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
    525 def _fnt_def(self, k, c, s, d, a, l):
--> 526     self._fnt_def_real(k, c, s, d, a, l)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
    529 n = self.file.read(a + l)
    530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
    532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
    533     raise ValueError('tfm checksum mismatch: %s' % n)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
   1114 @lru_cache
   1115 def _fontfile(cls, suffix, texname):
-> 1116     return cls(find_tex_file(texname + suffix))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
   1079     filename = filename.decode('utf-8', errors='replace')
   1081 try:
-> 1082     lk = _LuatexKpsewhich()
   1083 except FileNotFoundError:
   1084     lk = None  # Fallback to directly calling kpsewhich, as below.

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
   1034 @lru_cache  # A singleton.
   1035 def __new__(cls):
   1036     self = object.__new__(cls)
-> 1037     self._proc = self._new_proc()
   1038     return self

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
   1040 def _new_proc(self):
-> 1041     return subprocess.Popen(
   1042         ["luatex", "--luaonly",
   1043          str(cbook._get_data_path("kpsewhich.lua"))],
   1044         stdin=subprocess.PIPE, stdout=subprocess.PIPE)

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
   1953     err_msg = os.strerror(errno_num)
   1954 if err_filename is not None:
-> 1955     raise child_exception_type(errno_num, err_msg, err_filename)
   1956 else:
   1957     raise child_exception_type(errno_num, err_msg)

PermissionError: [Errno 13] Permission denied: 'luatex'
<Figure size 1920x1440 with 1 Axes>

[C] Is it profitable for the company to schedule overtime, having purchased additional material?#

Hide code cell source
d  =d-rc

# CONCISE ROW TABLEAU
rA = Matrix([
  [ 'c', 'x1', 'x2',     1, 'r'],
  ['y1',  -20,  -15,b1+db1,'s1'],
  ['y2',  -10,  -20,b2+db2,'s2'],
  ['y3',   -1,    0,b3+db3,'s3'],
  ['y4',    0,   -1,b4+db4,'s4'],
  [  -1, -500, -750, -d[0],'-z'],
  [ 'c','-v1','-v2',   'w', 'r'],
])
rB = pivot(1,1,rA)
rC = pivot(2,2,rB)
rD = pivot(3,1,rC)

# CONCISE COLUMN TABLEAU
cA = Matrix([
  [ 'c',  'y1',  'y2',  'y3',  'y4',   1, 'r'],
  ['x1',    20,    10,     1,     0,-500,'v1'],
  ['x2',    15,    20,     0,     1,-750,'v2'],
  [  -1,b1+db1,b2+db2,b3+db3,b4+db4,d[0], 'w'],
  [ 'c', '-s1', '-s2', '-s3', '-s4','-z', 'r'],
])
cB = pivot(1,1,cA)
cC = pivot(2,2,cB)
cD = pivot(1,3,cC)

display(Math(
   r'\begin{aligned}'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,rA = {latex(rA)}\,\,\,\,\,&&'
   r'\begin{aligned}&\text{START}\\&x_1=x_2=0\end{aligned}\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,rB = {latex(rB)}\,\,\,\,\,&&x_2=s_1=0\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,rC = {latex(rC)}\,\,\,\,\,&&'
   r'\begin{aligned}&\text{OPTIMAL}\\&s_1=s_2=0\end{aligned}\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,rD = {latex(rD)}\,\,\,\,\,&&'
   r'\begin{aligned}&\text{LEVEL SET}\\&s_2=s_3=0\end{aligned}\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,cA = {latex(cA)}\,\,\,\,\,&&'
   r'\begin{aligned}&\text{START}\\&x_1=x_2=0\end{aligned}\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,cB = {latex(cB)}\,\,\,\,\,&&x_2=s_1=0\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,cC = {latex(cC)}\,\,\,\,\,&&'
   r'\begin{aligned}&\text{OPTIMAL}\\&s_1=s_2=0\end{aligned}\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,cD = {latex(cD)}\,\,\,\,\,&&'
   r'\begin{aligned}&\text{LEVEL SET}\\&s_2=s_3=0\end{aligned}\\'
   r'\end{aligned}'
))
\[\begin{split}\displaystyle \begin{aligned}db &= (225/2,0,0,0)\,\,\,rA = \left[\begin{matrix}c & x_{1} & x_{2} & 1 & r\\y_{1} & -20 & -15 & \frac{1225}{2} & s_{1}\\y_{2} & -10 & -20 & 400 & s_{2}\\y_{3} & -1 & 0 & 25 & s_{3}\\y_{4} & 0 & -1 & 20 & s_{4}\\-1 & -500 & -750 & 1012.5 & - z\\c & - v_{1} & - v_{2} & w & r\end{matrix}\right]\,\,\,\,\,&&\begin{aligned}&\text{START}\\&x_1=x_2=0\end{aligned}\\db &= (225/2,0,0,0)\,\,\,rB = \left[\begin{matrix}c & s_{1} & x_{2} & 1 & r\\v_{1} & - \frac{1}{20} & - \frac{3}{4} & \frac{245}{8} & x_{1}\\y_{2} & \frac{1}{2} & - \frac{25}{2} & \frac{375}{4} & s_{2}\\y_{3} & \frac{1}{20} & \frac{3}{4} & - \frac{45}{8} & s_{3}\\y_{4} & 0 & -1 & 20 & s_{4}\\-1 & 25 & -375 & -14300.0 & - z\\c & - y_{1} & - v_{2} & w & r\end{matrix}\right]\,\,\,\,\,&&x_2=s_1=0\\db &= (225/2,0,0,0)\,\,\,rC = \left[\begin{matrix}c & s_{1} & s_{2} & 1 & r\\v_{1} & - \frac{2}{25} & \frac{3}{50} & 25 & x_{1}\\v_{2} & \frac{1}{25} & - \frac{2}{25} & \frac{15}{2} & x_{2}\\y_{3} & \frac{2}{25} & - \frac{3}{50} & 0 & s_{3}\\y_{4} & - \frac{1}{25} & \frac{2}{25} & \frac{25}{2} & s_{4}\\-1 & 10 & 30 & -17112.5 & - z\\c & - y_{1} & - y_{2} & w & r\end{matrix}\right]\,\,\,\,\,&&\begin{aligned}&\text{OPTIMAL}\\&s_1=s_2=0\end{aligned}\\db &= (225/2,0,0,0)\,\,\,rD = \left[\begin{matrix}c & s_{3} & s_{2} & 1 & r\\v_{1} & -1 & 0 & 25 & x_{1}\\v_{2} & \frac{1}{2} & - \frac{1}{20} & \frac{15}{2} & x_{2}\\y_{1} & \frac{25}{2} & \frac{3}{4} & 0 & s_{1}\\y_{4} & - \frac{1}{2} & \frac{1}{20} & \frac{25}{2} & s_{4}\\-1 & 125 & \frac{75}{2} & -17112.5 & - z\\c & - y_{3} & - y_{2} & w & r\end{matrix}\right]\,\,\,\,\,&&\begin{aligned}&\text{LEVEL SET}\\&s_2=s_3=0\end{aligned}\\db &= (225/2,0,0,0)\,\,\,cA = \left[\begin{matrix}c & y_{1} & y_{2} & y_{3} & y_{4} & 1 & r\\x_{1} & 20 & 10 & 1 & 0 & -500 & v_{1}\\x_{2} & 15 & 20 & 0 & 1 & -750 & v_{2}\\-1 & \frac{1225}{2} & 400 & 25 & 20 & -1012.5 & w\\c & - s_{1} & - s_{2} & - s_{3} & - s_{4} & - z & r\end{matrix}\right]\,\,\,\,\,&&\begin{aligned}&\text{START}\\&x_1=x_2=0\end{aligned}\\db &= (225/2,0,0,0)\,\,\,cB = \left[\begin{matrix}c & v_{1} & y_{2} & y_{3} & y_{4} & 1 & r\\s_{1} & \frac{1}{20} & - \frac{1}{2} & - \frac{1}{20} & 0 & 25 & y_{1}\\x_{2} & \frac{3}{4} & \frac{25}{2} & - \frac{3}{4} & 1 & -375 & v_{2}\\-1 & \frac{245}{8} & \frac{375}{4} & - \frac{45}{8} & 20 & 14300.0 & w\\c & - x_{1} & - s_{2} & - s_{3} & - s_{4} & - z & r\end{matrix}\right]\,\,\,\,\,&&x_2=s_1=0\\db &= (225/2,0,0,0)\,\,\,cC = \left[\begin{matrix}c & v_{1} & v_{2} & y_{3} & y_{4} & 1 & r\\s_{1} & \frac{2}{25} & - \frac{1}{25} & - \frac{2}{25} & \frac{1}{25} & 10 & y_{1}\\s_{2} & - \frac{3}{50} & \frac{2}{25} & \frac{3}{50} & - \frac{2}{25} & 30 & y_{2}\\-1 & 25 & \frac{15}{2} & 0 & \frac{25}{2} & 17112.5 & w\\c & - x_{1} & - x_{2} & - s_{3} & - s_{4} & - z & r\end{matrix}\right]\,\,\,\,\,&&\begin{aligned}&\text{OPTIMAL}\\&s_1=s_2=0\end{aligned}\\db &= (225/2,0,0,0)\,\,\,cD = \left[\begin{matrix}c & v_{1} & v_{2} & y_{1} & y_{4} & 1 & r\\s_{3} & 1 & - \frac{1}{2} & - \frac{25}{2} & \frac{1}{2} & 125 & y_{3}\\s_{2} & 0 & \frac{1}{20} & - \frac{3}{4} & - \frac{1}{20} & \frac{75}{2} & y_{2}\\-1 & 25 & \frac{15}{2} & 0 & \frac{25}{2} & 17112.5 & w\\c & - x_{1} & - x_{2} & - s_{1} & - s_{4} & - z & r\end{matrix}\right]\,\,\,\,\,&&\begin{aligned}&\text{LEVEL SET}\\&s_2=s_3=0\end{aligned}\\\end{aligned}\end{split}\]
Hide code cell source
ycStar1=yStar
ydStar1=(0,75/2,125,0)

ROI1c=round((ycStar1[0]-p1)/p1,2)
ROI2c=round((ycStar1[1]-p2)/p2,2)
ROI1d=round((ydStar1[0]-p1)/p1,2)
ROI2d=round((ydStar1[1]-p2)/p2,2)

display(Math(
  r"\begin{aligned}"

  r"x^*&="
  f"{xStar1}"
  r"\\"

  r"z^*&="
  f"\${zStar1:,.2f}"
  f"&&={latex(z-rc)}"
  r"=w^*\\"

  r"yc^*&="
  f"{ycStar1}"
  r"&&=\left(yc_1^*=\frac{\partial z^*}{\partial b_1},yc_2^*=\frac{\partial z^*}{\partial b_2},yc_3^*=\frac{\partial z^*}{\partial b_3},yc_4^*=\frac{\partial z^*}{\partial b_4}\right)"
  r"\\"

  r"\text{ROI}_\text{material}&="
  f"{ROI1c}"
  r"&&=\frac{yc_1^*-p_1}{p_1}"
  r"\\"
  r"\text{ROI}_\text{labor}&="
  f"{ROI2c}"
  r"&&=\frac{yc_2^*-p_2}{p_2}"
  r"\\"

  r"yd^*&="
  f"{ydStar1}"
  r"&&=\left(yd_1^*=\frac{\partial z^*}{\partial b_1},yd_2^*=\frac{\partial z^*}{\partial b_2},yd_3^*=\frac{\partial z^*}{\partial b_3},yd_4^*=\frac{\partial z^*}{\partial b_4}\right)"
  r"\\"

  r"\text{ROI}_\text{material}&="
  f"{ROI1d}"
  r"&&=\frac{yd_1^*-p_1}{p_1}"
  r"\\"
  r"\text{ROI}_\text{labor}&="
  f"{ROI2d}"
  r"&&=\frac{yd_2^*-p_2}{p_2}"
  r"\\"

  r"\end{aligned}"
))
\[\begin{split}\displaystyle \begin{aligned}x^*&=(25, 15/2)\\z^*&=\$17,112.50&&=500 x_{1} + 750 x_{2} - 1012.5=w^*\\yc^*&=(10, 30, 0, 0)&&=\left(yc_1^*=\frac{\partial z^*}{\partial b_1},yc_2^*=\frac{\partial z^*}{\partial b_2},yc_3^*=\frac{\partial z^*}{\partial b_3},yc_4^*=\frac{\partial z^*}{\partial b_4}\right)\\\text{ROI}_\text{material}&=0.11&&=\frac{yc_1^*-p_1}{p_1}\\\text{ROI}_\text{labor}&=0.33&&=\frac{yc_2^*-p_2}{p_2}\\yd^*&=(0, 37.5, 125, 0)&&=\left(yd_1^*=\frac{\partial z^*}{\partial b_1},yd_2^*=\frac{\partial z^*}{\partial b_2},yd_3^*=\frac{\partial z^*}{\partial b_3},yd_4^*=\frac{\partial z^*}{\partial b_4}\right)\\\text{ROI}_\text{material}&=-1.0&&=\frac{yd_1^*-p_1}{p_1}\\\text{ROI}_\text{labor}&=0.67&&=\frac{yd_2^*-p_2}{p_2}\\\end{aligned}\end{split}\]
Hide code cell source
g1ng4 =solve([g1n-x2,g4])
#g1ng4=solve([g1-db1,g4])
xStar2=(g1ng4[x1],g1ng4[x2])
g2n   =s2*(x1-xStar2[0])+xStar2[1]
b2n   =float(g2.subs([(x1,xStar2[0]),(x2,xStar2[1])])+b2)
db2   =b2n-b2
rc2   =p2*db2
zStar2=z.subs([(x1,xStar2[0]),(x2,xStar2[1])])-rc2-rc
dzStar=yStar[0]*db2

# db1=symbols('db1')
# solve([
#   g1.subs([(x1,25)])-db1,
#   g2.subs([(x1,25)]),
# ],[db1,x2])

display(Math(
  r"\begin{aligned}"

  r"y_2^*\overset{?}{\gt}p_2&\implies"
  f"{yStar[1]}"
  r"\overset{?}{\gt}"
  f"{p2}"
  r"\\"

  r"g_1(\text{new})=g_4&\implies"
  f"{latex(g1ng4)}"
  r"\\"

  r"x^*(\text{new})&="
  f"{nsimplify(xStar2[0]),nsimplify(xStar2[1])}"
  r"\\"

  r"g_2(\text{new})&="
  f"{latex(nsimplify(g2n))}"
  r"\\"

  r"g_2(\text{new})=x_1&\implies x_1="
  # f"{latex(nsimplify(solve([g2n,x1])[x2]))}"
  r"\\"

  r" b_2(\text{new})&="
  f"{b2n}"
  r"\\"

 fr"db_2&={db2}"
  r"&&=b_2(\text{new})-b_2"
  r"\\"

  r"\text{cost}&="
  f"\${rc2:,.2f}"
  r"&&=p_2\partial b_2"
  r"\\"

  r"z^*(\text{new})&="
  f"\${zStar2:,.2f}"
  f"&&={latex(z-rc2)}"
  r"=w^*\\"

  r"\partial z^*&="
  f"\${dzStar:,.2f}"
  r"&&=y_2^*\partial b_2=z^*(\text{new})-z^*"
  r"\\"

  r"\end{aligned}"
))
\[\begin{split}\displaystyle \begin{aligned}y_2^*\overset{?}{\gt}p_2&\implies30\overset{?}{\gt}22.5\\g_1(\text{new})=g_4&\implies\left\{ x_{1} : 15.625, \ x_{2} : 20.0\right\}\\x^*(\text{new})&=(125/8, 20)\\g_2(\text{new})&=\frac{445}{16} - \frac{x_{1}}{2}\\g_2(\text{new})=x_1&\implies x_1=\\ b_2(\text{new})&=556.25\\db_2&=156.25&&=b_2(\text{new})-b_2\\\text{cost}&=\$3,515.62&&=p_2\partial b_2\\z^*(\text{new})&=\$18,284.38&&=500 x_{1} + 750 x_{2} - 3515.625=w^*\\\partial z^*&=\$1,562.50&&=y_2^*\partial b_2=z^*(\text{new})-z^*\\\end{aligned}\end{split}\]
Hide code cell source
fig=plt.figure(dpi=300,figsize=(8,16));

##########

ax =plt.subplot(121);
ax.set_aspect(1);

# LINES
ax.plot   (x,y1,                        label='g1=b1',    linewidth=0.5,linestyle=(0,(5,10)),color='blue');
ax.plot   (x,s1*(x-xStar1[0])+xStar1[1],label='g1=b1+db1',linewidth=0.5,                     color='blue');
ax.plot   (x,y2,                        label='g2=b2',    linewidth=0.5,                     color='yellow');
ax.axvline(  25,                        label='g3=b3',    linewidth=0.5,                     color='green');
ax.plot   (x,y4,                        label='g4=b4',    linewidth=0.5,                     color='red');

# DELZ
ax.arrow(10,10,*unitVector(  delz),width=0.01,head_width=0.2,length_includes_head=True,color='black');

# FEASIBLE SIDES <=
ax.arrow(10,10,*unitVector(-delg1),width=0.01,head_width=0.2,length_includes_head=True,color='blue');
ax.arrow(10,10,*unitVector(-delg2),width=0.01,head_width=0.2,length_includes_head=True,color='yellow');
ax.arrow(10,10,*unitVector(-delg3),width=0.01,head_width=0.2,length_includes_head=True,color='green');
ax.arrow(10,10,*unitVector(-delg4),width=0.01,head_width=0.2,length_includes_head=True,color='red');

# DIRECTIONS
ax.arrow(25, 0,*udg1*3,            width=0.3, head_width=1,  length_includes_head=True,color='blue');
ax.arrow( 0,20,*udg2*3,            width=0.3, head_width=1,  length_includes_head=True,color='yellow');
ax.arrow(25, 0,*udg3*3,            width=0.3, head_width=1,  length_includes_head=True,color='green');
ax.arrow( 0,20,*udg4*3,            width=0.3, head_width=1,  length_includes_head=True,color='red');

# FEASIBLE REGION
fx,fy=np.meshgrid(x,x)
plt.imshow(
  (
     (fy<=s1*(fx-float(xStar1[0]))+float(xStar1[1]))
   & (fy<=s2*fx+20)
   & (fx<=25)
   & (fy<= 0*fx+20)
  ).astype(int),
  extent=(fx.min(),fx.max(),fy.min(),fy.max()),
  origin='lower',
  cmap  ='Greys',
  alpha =0.3,
);

ax.set_xlim(0,s);
ax.set_ylim(0,s);
#ax.legend();

# XSTAR
ax.scatter(*xStar1,s=1e2,color='purple');

sol=(
  r'\begin{eqnarray*}'
  f'x^*&=&{xStar1}'
  r'\\'
  f'z^*&=&\${round(zStar1,2):,.2f}=w^*'
  r'\\'
  f'yc^*&=&{ycStar1}'
  r'\\'
  f'yd^*&=&{ydStar1}'
  r'\\'
  r'\mathrm{ROI}_\mathrm{material}'
  f'&=&{ROI1d}'
  r'\\'
  r'\mathrm{ROI}_\mathrm{labor}'
  f'&=&{ROI2d}'
  r'\end{eqnarray*}'
)
ax.text(10,35,sol,fontsize=10);

# SIMPLEX
dx,dy=1,1
ax.annotate('$A$',(        0+dx,        0+dy));
ax.annotate('$B$',(  (245/8)+dx,        0+dy));
ax.annotate('$C$',(xStar1[0]+dx,xStar1[1]+dy));

##########

ax2 =plt.subplot(122);
ax2.set_aspect(1);

# LINES
ax2.plot   (x,y1,                        label='g1=b1',    linewidth=0.5,linestyle=(0,(5,10)),color='blue');
ax2.plot   (x,s1*(x-xStar1[0])+xStar1[1],label='g1=b1+db1',linewidth=0.5,                     color='blue');
ax2.plot   (x,y2,                        label='g2=b2',    linewidth=0.5,linestyle=(0,(5,10)),color='yellow');
ax2.plot   (x,s2*(x-xStar2[0])+xStar2[1],label='g2=b2+db2',linewidth=0.5,                     color='yellow');
ax2.axvline(  25,                        label='g3=b3',    linewidth=0.5,                     color='green');
ax2.plot   (x,y4,                        label='g4=b4',    linewidth=0.5,                     color='red');

# DELZ
ax2.arrow(10,10,*unitVector(  delz),width=0.01,head_width=0.2,length_includes_head=True,color='black');

# FEASIBLE SIDES <=
ax2.arrow(10,10,*unitVector(-delg1),width=0.01,head_width=0.2,length_includes_head=True,color='blue');
ax2.arrow(10,10,*unitVector(-delg2),width=0.01,head_width=0.2,length_includes_head=True,color='yellow');
ax2.arrow(10,10,*unitVector(-delg3),width=0.01,head_width=0.2,length_includes_head=True,color='green');
ax2.arrow(10,10,*unitVector(-delg4),width=0.01,head_width=0.2,length_includes_head=True,color='red');

# DIRECTIONS
ax2.arrow(25, 0,*udg1*3,            width=0.3, head_width=1,  length_includes_head=True,color='blue');
ax2.arrow( 0,20,*udg2*3,            width=0.3, head_width=1,  length_includes_head=True,color='yellow');
ax2.arrow(25, 0,*udg3*3,            width=0.3, head_width=1,  length_includes_head=True,color='green');
ax2.arrow( 0,20,*udg4*3,            width=0.3, head_width=1,  length_includes_head=True,color='red');

# FEASIBLE REGION
fx,fy=np.meshgrid(x,x)
plt.imshow(
  (
     (fy<=s1*(fx-float(xStar1[0]))+float(xStar1[1]))
   & (fy<=s2*(fx-float(xStar2[0]))+float(xStar2[1]))
   & (fx<=25)
   & (fy<=0*fx+20)
  ).astype(int),
  extent=(fx.min(),fx.max(),fy.min(),fy.max()),
  origin='lower',
  cmap  ='Greys',
  alpha =0.3,
);

ax2.set_xlim(0,s);
ax2.set_ylim(0,s);
#ax2.legend();

# XSTAR
ax2.scatter(*xStar2,s=1e2,color='purple');

sol=(
  r'\begin{eqnarray*}'
  f'x^*&=&({Fraction(float(xStar2[0])).limit_denominator(10)},{Fraction(float(xStar2[1])).limit_denominator(10)})'
  r'\\'
  f'z^*&=&\${round(zStar2,2):,.2f}=w^*'
  r'\end{eqnarray*}'
)
ax2.text(10,35,sol,fontsize=10);

# SIMPLEX
dx,dy=1,1
ax2.annotate('$A$',(        0+dx,        0+dy));
ax2.annotate('$B$',(  (245/8)+dx,        0+dy));
ax2.annotate('$C$',(xStar2[0]+dx,xStar2[1]+dy));
Error in callback <function _draw_all_if_interactive at 0x1302e8e00> (for post_execute), with arguments args (),kwargs {}:
---------------------------------------------------------------------------
PermissionError                           Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/pyplot.py:197, in _draw_all_if_interactive()
    195 def _draw_all_if_interactive() -> None:
    196     if matplotlib.is_interactive():
--> 197         draw_all()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/_pylab_helpers.py:132, in Gcf.draw_all(cls, force)
    130 for manager in cls.get_all_fig_managers():
    131     if force or manager.canvas.figure.stale:
--> 132         manager.canvas.draw_idle()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:1893, in FigureCanvasBase.draw_idle(self, *args, **kwargs)
   1891 if not self._is_idle_drawing:
   1892     with self._idle_draw_cntx():
-> 1893         self.draw(*args, **kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
    385 # Acquire a lock on the shared font cache.
    386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
    387       else nullcontext()):
--> 388     self.figure.draw(self.renderer)
    389     # A GUI class may be need to update a window using this draw, so
    390     # don't forget to call the superclass.
    391     super().draw()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
     93 @wraps(draw)
     94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95     result = draw(artist, renderer, *args, **kwargs)
     96     if renderer._rasterizing:
     97         renderer.stop_rasterizing()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
   3151         # ValueError can occur when resizing a window.
   3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
   3155     renderer, self, artists, self.suppressComposite)
   3157 for sfig in self.subfigs:
   3158     sfig.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    130 if not_composite or not has_images:
    131     for a in artists:
--> 132         a.draw(renderer)
    133 else:
    134     # Composite any adjacent images together
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axes/_base.py:3070, in _AxesBase.draw(self, renderer)
   3067 if artists_rasterized:
   3068     _draw_rasterized(self.figure, artists_rasterized, renderer)
-> 3070 mimage._draw_list_compositing_images(
   3071     renderer, self, artists, self.figure.suppressComposite)
   3073 renderer.close_group('axes')
   3074 self.stale = False

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    130 if not_composite or not has_images:
    131     for a in artists:
--> 132         a.draw(renderer)
    133 else:
    134     # Composite any adjacent images together
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1388, in Axis.draw(self, renderer, *args, **kwargs)
   1385 renderer.open_group(__name__, gid=self.get_gid())
   1387 ticks_to_draw = self._update_ticks()
-> 1388 tlb1, tlb2 = self._get_ticklabel_bboxes(ticks_to_draw, renderer)
   1390 for tick in ticks_to_draw:
   1391     tick.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in Axis._get_ticklabel_bboxes(self, ticks, renderer)
   1313 if renderer is None:
   1314     renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
   1316          for tick in ticks if tick.label1.get_visible()],
   1317         [tick.label2.get_window_extent(renderer)
   1318          for tick in ticks if tick.label2.get_visible()])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in <listcomp>(.0)
   1313 if renderer is None:
   1314     renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
   1316          for tick in ticks if tick.label1.get_visible()],
   1317         [tick.label2.get_window_extent(renderer)
   1318          for tick in ticks if tick.label2.get_visible()])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:956, in Text.get_window_extent(self, renderer, dpi)
    951     raise RuntimeError(
    952         "Cannot get window extent of text w/o renderer. You likely "
    953         "want to call 'figure.draw_without_rendering()' first.")
    955 with cbook._setattr_cm(self.figure, dpi=dpi):
--> 956     bbox, info, descent = self._get_layout(self._renderer)
    957     x, y = self.get_unitless_position()
    958     x, y = self.get_transform().transform((x, y))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
    370 ys = []
    372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
    374     renderer, "lp", self._fontproperties,
    375     ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
    376 min_dy = (lp_h - lp_d) * self._linespacing
    378 for i, line in enumerate(lines):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
     66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
     67 # Cached based on a copy of fontprop so that later in-place mutations of
     68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
     70     weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
     73 @functools.lru_cache(4096)
     74 def _get_text_metrics_with_cache_impl(
     75         renderer_ref, text, fontprop, ismath, dpi):
     76     # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77     return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
    211 _api.check_in_list(["TeX", True, False], ismath=ismath)
    212 if ismath == "TeX":
--> 213     return super().get_text_width_height_descent(s, prop, ismath)
    215 if ismath:
    216     ox, oy, width, height, descent, font_image = \
    217         self.mathtext_parser.parse(s, self.dpi, prop)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
    648 fontsize = prop.get_size_in_points()
    650 if ismath == 'TeX':
    651     # todo: handle properties
--> 652     return self.get_texmanager().get_text_width_height_descent(
    653         s, fontsize, renderer=self)
    655 dpi = self.points_to_pixels(72)
    656 if ismath:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
    364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
    365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366     page, = dvi
    367 # A total height (including the descent) needs to be returned.
    368 return page.width, page.height + page.descent, page.descent

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
    280 def __iter__(self):
    281     """
    282     Iterate through the pages of the file.
    283 
   (...)
    294         integers.
    295     """
--> 296     while self._read():
    297         yield self._output()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
    373 while True:
    374     byte = self.file.read(1)[0]
--> 375     self._dtable[byte](self, byte)
    376     name = self._dtable[byte].__name__
    377     if name == "_push":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
    225 if state is not None and self.state != state:
    226     raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
    524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
    525 def _fnt_def(self, k, c, s, d, a, l):
--> 526     self._fnt_def_real(k, c, s, d, a, l)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
    529 n = self.file.read(a + l)
    530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
    532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
    533     raise ValueError('tfm checksum mismatch: %s' % n)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
   1114 @lru_cache
   1115 def _fontfile(cls, suffix, texname):
-> 1116     return cls(find_tex_file(texname + suffix))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
   1079     filename = filename.decode('utf-8', errors='replace')
   1081 try:
-> 1082     lk = _LuatexKpsewhich()
   1083 except FileNotFoundError:
   1084     lk = None  # Fallback to directly calling kpsewhich, as below.

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
   1034 @lru_cache  # A singleton.
   1035 def __new__(cls):
   1036     self = object.__new__(cls)
-> 1037     self._proc = self._new_proc()
   1038     return self

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
   1040 def _new_proc(self):
-> 1041     return subprocess.Popen(
   1042         ["luatex", "--luaonly",
   1043          str(cbook._get_data_path("kpsewhich.lua"))],
   1044         stdin=subprocess.PIPE, stdout=subprocess.PIPE)

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
   1953     err_msg = os.strerror(errno_num)
   1954 if err_filename is not None:
-> 1955     raise child_exception_type(errno_num, err_msg, err_filename)
   1956 else:
   1957     raise child_exception_type(errno_num, err_msg)

PermissionError: [Errno 13] Permission denied: 'luatex'
---------------------------------------------------------------------------
PermissionError                           Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
    341     pass
    342 else:
--> 343     return printer(obj)
    344 # Finally look for special method names
    345 method = get_real_method(obj, self.print_method)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/pylabtools.py:152, in print_figure(fig, fmt, bbox_inches, base64, **kwargs)
    149     from matplotlib.backend_bases import FigureCanvasBase
    150     FigureCanvasBase(fig)
--> 152 fig.canvas.print_figure(bytes_io, **kw)
    153 data = bytes_io.getvalue()
    154 if fmt == 'svg':

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2164, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
   2161     # we do this instead of `self.figure.draw_without_rendering`
   2162     # so that we can inject the orientation
   2163     with getattr(renderer, "_draw_disabled", nullcontext)():
-> 2164         self.figure.draw(renderer)
   2165 if bbox_inches:
   2166     if bbox_inches == "tight":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
     93 @wraps(draw)
     94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95     result = draw(artist, renderer, *args, **kwargs)
     96     if renderer._rasterizing:
     97         renderer.stop_rasterizing()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
   3151         # ValueError can occur when resizing a window.
   3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
   3155     renderer, self, artists, self.suppressComposite)
   3157 for sfig in self.subfigs:
   3158     sfig.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    130 if not_composite or not has_images:
    131     for a in artists:
--> 132         a.draw(renderer)
    133 else:
    134     # Composite any adjacent images together
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axes/_base.py:3070, in _AxesBase.draw(self, renderer)
   3067 if artists_rasterized:
   3068     _draw_rasterized(self.figure, artists_rasterized, renderer)
-> 3070 mimage._draw_list_compositing_images(
   3071     renderer, self, artists, self.figure.suppressComposite)
   3073 renderer.close_group('axes')
   3074 self.stale = False

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    130 if not_composite or not has_images:
    131     for a in artists:
--> 132         a.draw(renderer)
    133 else:
    134     # Composite any adjacent images together
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1388, in Axis.draw(self, renderer, *args, **kwargs)
   1385 renderer.open_group(__name__, gid=self.get_gid())
   1387 ticks_to_draw = self._update_ticks()
-> 1388 tlb1, tlb2 = self._get_ticklabel_bboxes(ticks_to_draw, renderer)
   1390 for tick in ticks_to_draw:
   1391     tick.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in Axis._get_ticklabel_bboxes(self, ticks, renderer)
   1313 if renderer is None:
   1314     renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
   1316          for tick in ticks if tick.label1.get_visible()],
   1317         [tick.label2.get_window_extent(renderer)
   1318          for tick in ticks if tick.label2.get_visible()])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in <listcomp>(.0)
   1313 if renderer is None:
   1314     renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
   1316          for tick in ticks if tick.label1.get_visible()],
   1317         [tick.label2.get_window_extent(renderer)
   1318          for tick in ticks if tick.label2.get_visible()])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:956, in Text.get_window_extent(self, renderer, dpi)
    951     raise RuntimeError(
    952         "Cannot get window extent of text w/o renderer. You likely "
    953         "want to call 'figure.draw_without_rendering()' first.")
    955 with cbook._setattr_cm(self.figure, dpi=dpi):
--> 956     bbox, info, descent = self._get_layout(self._renderer)
    957     x, y = self.get_unitless_position()
    958     x, y = self.get_transform().transform((x, y))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
    370 ys = []
    372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
    374     renderer, "lp", self._fontproperties,
    375     ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
    376 min_dy = (lp_h - lp_d) * self._linespacing
    378 for i, line in enumerate(lines):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
     66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
     67 # Cached based on a copy of fontprop so that later in-place mutations of
     68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
     70     weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
     73 @functools.lru_cache(4096)
     74 def _get_text_metrics_with_cache_impl(
     75         renderer_ref, text, fontprop, ismath, dpi):
     76     # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77     return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
    211 _api.check_in_list(["TeX", True, False], ismath=ismath)
    212 if ismath == "TeX":
--> 213     return super().get_text_width_height_descent(s, prop, ismath)
    215 if ismath:
    216     ox, oy, width, height, descent, font_image = \
    217         self.mathtext_parser.parse(s, self.dpi, prop)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
    648 fontsize = prop.get_size_in_points()
    650 if ismath == 'TeX':
    651     # todo: handle properties
--> 652     return self.get_texmanager().get_text_width_height_descent(
    653         s, fontsize, renderer=self)
    655 dpi = self.points_to_pixels(72)
    656 if ismath:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
    364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
    365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366     page, = dvi
    367 # A total height (including the descent) needs to be returned.
    368 return page.width, page.height + page.descent, page.descent

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
    280 def __iter__(self):
    281     """
    282     Iterate through the pages of the file.
    283 
   (...)
    294         integers.
    295     """
--> 296     while self._read():
    297         yield self._output()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
    373 while True:
    374     byte = self.file.read(1)[0]
--> 375     self._dtable[byte](self, byte)
    376     name = self._dtable[byte].__name__
    377     if name == "_push":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
    225 if state is not None and self.state != state:
    226     raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
    524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
    525 def _fnt_def(self, k, c, s, d, a, l):
--> 526     self._fnt_def_real(k, c, s, d, a, l)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
    529 n = self.file.read(a + l)
    530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
    532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
    533     raise ValueError('tfm checksum mismatch: %s' % n)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
   1114 @lru_cache
   1115 def _fontfile(cls, suffix, texname):
-> 1116     return cls(find_tex_file(texname + suffix))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
   1079     filename = filename.decode('utf-8', errors='replace')
   1081 try:
-> 1082     lk = _LuatexKpsewhich()
   1083 except FileNotFoundError:
   1084     lk = None  # Fallback to directly calling kpsewhich, as below.

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
   1034 @lru_cache  # A singleton.
   1035 def __new__(cls):
   1036     self = object.__new__(cls)
-> 1037     self._proc = self._new_proc()
   1038     return self

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
   1040 def _new_proc(self):
-> 1041     return subprocess.Popen(
   1042         ["luatex", "--luaonly",
   1043          str(cbook._get_data_path("kpsewhich.lua"))],
   1044         stdin=subprocess.PIPE, stdout=subprocess.PIPE)

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
   1953     err_msg = os.strerror(errno_num)
   1954 if err_filename is not None:
-> 1955     raise child_exception_type(errno_num, err_msg, err_filename)
   1956 else:
   1957     raise child_exception_type(errno_num, err_msg)

PermissionError: [Errno 13] Permission denied: 'luatex'
<Figure size 2400x4800 with 2 Axes>

Hide code cell source
d  =d-rc2

# CONCISE ROW TABLEAU
rA = Matrix([
  [ 'c', 'x1', 'x2',     1, 'r'],
  ['y1',  -20,  -15,b1+db1,'s1'],
  ['y2',  -10,  -20,b2+db2,'s2'],
  ['y3',   -1,    0,b3+db3,'s3'],
  ['y4',    0,   -1,b4+db4,'s4'],
  [  -1, -500, -750, -d[0],'-z'],
  [ 'c','-v1','-v2',   'w', 'r'],
])
rB = pivot(1,1,rA)
rC = pivot(2,2,rB)
rD = pivot(4,2,rC)

# CONCISE COLUMN TABLEAU
cA = Matrix([
  [ 'c',  'y1',  'y2',  'y3',  'y4',   1, 'r'],
  ['x1',    20,    10,     1,     0,-500,'v1'],
  ['x2',    15,    20,     0,     1,-750,'v2'],
  [  -1,b1+db1,b2+db2,b3+db3,b4+db4,d[0], 'w'],
  [ 'c', '-s1', '-s2', '-s3', '-s4','-z', 'r'],
])
cB = pivot(1,1,cA)
cC = pivot(2,2,cB)
cD = pivot(2,4,cC)

display(Math(
   r'\begin{aligned}'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,rA = {latex(rA)}\,\,\,\,\,&&'
   r'\begin{aligned}&\text{START}\\&x_1=x_2=0\end{aligned}\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,rB = {latex(rB)}\,\,\,\,\,&&x_2=s_1=0\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,rC = {latex(rC)}\,\,\,\,\,&&'
   r'\begin{aligned}&\text{OPTIMAL}\\&s_1=s_2=0\end{aligned}\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,rD = {latex(rD)}\,\,\,\,\,&&'
   r'\begin{aligned}&\text{LEVEL SET}\\&s_1=s_4=0\end{aligned}\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,cA = {latex(cA)}\,\,\,\,\,&&'
   r'\begin{aligned}&\text{START}\\&x_1=x_2=0\end{aligned}\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,cB = {latex(cB)}\,\,\,\,\,&&x_2=s_1=0\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,cC = {latex(cC)}\,\,\,\,\,&&'
   r'\begin{aligned}&\text{OPTIMAL}\\&s_1=s_2=0\end{aligned}\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,cD = {latex(cD)}\,\,\,\,\,&&'
   r'\begin{aligned}&\text{LEVEL SET}\\&s_1=s_4=0\end{aligned}\\'
   r'\end{aligned}'
))
\[\begin{split}\displaystyle \begin{aligned}db &= (225/2,156.25,0,0)\,\,\,rA = \left[\begin{matrix}c & x_{1} & x_{2} & 1 & r\\y_{1} & -20 & -15 & \frac{1225}{2} & s_{1}\\y_{2} & -10 & -20 & 556.25 & s_{2}\\y_{3} & -1 & 0 & 25 & s_{3}\\y_{4} & 0 & -1 & 20 & s_{4}\\-1 & -500 & -750 & 4528.125 & - z\\c & - v_{1} & - v_{2} & w & r\end{matrix}\right]\,\,\,\,\,&&\begin{aligned}&\text{START}\\&x_1=x_2=0\end{aligned}\\db &= (225/2,156.25,0,0)\,\,\,rB = \left[\begin{matrix}c & s_{1} & x_{2} & 1 & r\\v_{1} & - \frac{1}{20} & - \frac{3}{4} & \frac{245}{8} & x_{1}\\y_{2} & \frac{1}{2} & - \frac{25}{2} & 250.0 & s_{2}\\y_{3} & \frac{1}{20} & \frac{3}{4} & - \frac{45}{8} & s_{3}\\y_{4} & 0 & -1 & 20 & s_{4}\\-1 & 25 & -375 & -10784.375 & - z\\c & - y_{1} & - v_{2} & w & r\end{matrix}\right]\,\,\,\,\,&&x_2=s_1=0\\db &= (225/2,156.25,0,0)\,\,\,rC = \left[\begin{matrix}c & s_{1} & s_{2} & 1 & r\\v_{1} & - \frac{2}{25} & \frac{3}{50} & 15.625 & x_{1}\\v_{2} & \frac{1}{25} & - \frac{2}{25} & 20.0 & x_{2}\\y_{3} & \frac{2}{25} & - \frac{3}{50} & 9.375 & s_{3}\\y_{4} & - \frac{1}{25} & \frac{2}{25} & 0 & s_{4}\\-1 & 10 & 30 & -18284.375 & - z\\c & - y_{1} & - y_{2} & w & r\end{matrix}\right]\,\,\,\,\,&&\begin{aligned}&\text{OPTIMAL}\\&s_1=s_2=0\end{aligned}\\db &= (225/2,156.25,0,0)\,\,\,rD = \left[\begin{matrix}c & s_{1} & s_{4} & 1 & r\\v_{1} & - \frac{1}{20} & \frac{3}{4} & 15.625 & x_{1}\\v_{2} & 0 & -1 & 20.0 & x_{2}\\y_{3} & \frac{1}{20} & - \frac{3}{4} & 9.375 & s_{3}\\y_{2} & \frac{1}{2} & \frac{25}{2} & 0 & s_{2}\\-1 & 25 & 375 & -18284.375 & - z\\c & - y_{1} & - y_{4} & w & r\end{matrix}\right]\,\,\,\,\,&&\begin{aligned}&\text{LEVEL SET}\\&s_1=s_4=0\end{aligned}\\db &= (225/2,156.25,0,0)\,\,\,cA = \left[\begin{matrix}c & y_{1} & y_{2} & y_{3} & y_{4} & 1 & r\\x_{1} & 20 & 10 & 1 & 0 & -500 & v_{1}\\x_{2} & 15 & 20 & 0 & 1 & -750 & v_{2}\\-1 & \frac{1225}{2} & 556.25 & 25 & 20 & -4528.125 & w\\c & - s_{1} & - s_{2} & - s_{3} & - s_{4} & - z & r\end{matrix}\right]\,\,\,\,\,&&\begin{aligned}&\text{START}\\&x_1=x_2=0\end{aligned}\\db &= (225/2,156.25,0,0)\,\,\,cB = \left[\begin{matrix}c & v_{1} & y_{2} & y_{3} & y_{4} & 1 & r\\s_{1} & \frac{1}{20} & - \frac{1}{2} & - \frac{1}{20} & 0 & 25 & y_{1}\\x_{2} & \frac{3}{4} & \frac{25}{2} & - \frac{3}{4} & 1 & -375 & v_{2}\\-1 & \frac{245}{8} & 250.0 & - \frac{45}{8} & 20 & 10784.375 & w\\c & - x_{1} & - s_{2} & - s_{3} & - s_{4} & - z & r\end{matrix}\right]\,\,\,\,\,&&x_2=s_1=0\\db &= (225/2,156.25,0,0)\,\,\,cC = \left[\begin{matrix}c & v_{1} & v_{2} & y_{3} & y_{4} & 1 & r\\s_{1} & \frac{2}{25} & - \frac{1}{25} & - \frac{2}{25} & \frac{1}{25} & 10 & y_{1}\\s_{2} & - \frac{3}{50} & \frac{2}{25} & \frac{3}{50} & - \frac{2}{25} & 30 & y_{2}\\-1 & 15.625 & 20.0 & 9.375 & 0 & 18284.375 & w\\c & - x_{1} & - x_{2} & - s_{3} & - s_{4} & - z & r\end{matrix}\right]\,\,\,\,\,&&\begin{aligned}&\text{OPTIMAL}\\&s_1=s_2=0\end{aligned}\\db &= (225/2,156.25,0,0)\,\,\,cD = \left[\begin{matrix}c & v_{1} & v_{2} & y_{3} & y_{2} & 1 & r\\s_{1} & \frac{1}{20} & 0 & - \frac{1}{20} & - \frac{1}{2} & 25 & y_{1}\\s_{4} & - \frac{3}{4} & 1 & \frac{3}{4} & - \frac{25}{2} & 375 & y_{4}\\-1 & 15.625 & 20.0 & 9.375 & 0 & 18284.375 & w\\c & - x_{1} & - x_{2} & - s_{3} & - s_{2} & - z & r\end{matrix}\right]\,\,\,\,\,&&\begin{aligned}&\text{LEVEL SET}\\&s_1=s_4=0\end{aligned}\\\end{aligned}\end{split}\]
Hide code cell source
ycStar2=yStar
ydStar2=(25,0,0,375)

ROI3c=round((ycStar2[0]-p1)/p1,2)
ROI4c=round((ycStar2[1]-p2)/p2,2)
ROI3d=round((ydStar2[0]-p1)/p1,2)
ROI4d=round((ydStar2[1]-p2)/p2,2)

display(Math(
  r"\begin{aligned}"

  r"x^*&="
  f"({Fraction(float(xStar2[0])).limit_denominator(10)},{Fraction(float(xStar2[1])).limit_denominator(10)})"
  r"\\"

  r"z^*&="
  f"\${zStar2:,.2f}"
  f"&&={latex(z-rc2-rc)}"
  r"=w^*\\"

  r"yc^*&="
  f"{ycStar2}"
  r"\\"

  r"\text{ROI}_\text{material}&="
  f"{ROI3c}"
  r"&&=\frac{yc_1^*-p_1}{p_1}"
  r"\\"
  r"\text{ROI}_\text{labor}&="
  f"{ROI4c}"
  r"&&=\frac{yc_2^*-p_2}{p_2}"
  r"\\"

  r"yd^*&="
  f"{ydStar2}"
  r"\\"

  r"\text{ROI}_\text{material}&="
  f"{ROI3d}"
  r"&&=\frac{yd_1^*-p_1}{p_1}"
  r"\\"
  r"\text{ROI}_\text{labor}&="
  f"{ROI4d}"
  r"&&=\frac{yd_2^*-p_2}{p_2}"
  r"\\"

  r"\end{aligned}"
))
\[\begin{split}\displaystyle \begin{aligned}x^*&=(125/8,20)\\z^*&=\$18,284.38&&=500 x_{1} + 750 x_{2} - 4528.125=w^*\\yc^*&=(10, 30, 0, 0)\\\text{ROI}_\text{material}&=0.11&&=\frac{yc_1^*-p_1}{p_1}\\\text{ROI}_\text{labor}&=0.33&&=\frac{yc_2^*-p_2}{p_2}\\yd^*&=(25, 0, 0, 375)\\\text{ROI}_\text{material}&=1.78&&=\frac{yd_1^*-p_1}{p_1}\\\text{ROI}_\text{labor}&=-1.0&&=\frac{yd_2^*-p_2}{p_2}\\\end{aligned}\end{split}\]
Hide code cell source
fig=plt.figure(dpi=300,figsize=(8,16));

##########

ax =plt.subplot(121);
ax.set_aspect(1);

# LINES
ax.plot   (x,y1,                        label='g1=b1',    linewidth=0.5,linestyle=(0,(5,10)),color='blue');
ax.plot   (x,s1*(x-xStar1[0])+xStar1[1],label='g1=b1+db1',linewidth=0.5,                     color='blue');
ax.plot   (x,y2,                        label='g2=b2',    linewidth=0.5,                     color='yellow');
ax.axvline(  25,                        label='g3=b3',    linewidth=0.5,                     color='green');
ax.plot   (x,y4,                        label='g4=b4',    linewidth=0.5,                     color='red');

# DELZ
ax.arrow(10,10,*unitVector(  delz),width=0.01,head_width=0.2,length_includes_head=True,color='black');

# FEASIBLE SIDES <=
ax.arrow(10,10,*unitVector(-delg1),width=0.01,head_width=0.2,length_includes_head=True,color='blue');
ax.arrow(10,10,*unitVector(-delg2),width=0.01,head_width=0.2,length_includes_head=True,color='yellow');
ax.arrow(10,10,*unitVector(-delg3),width=0.01,head_width=0.2,length_includes_head=True,color='green');
ax.arrow(10,10,*unitVector(-delg4),width=0.01,head_width=0.2,length_includes_head=True,color='red');

# DIRECTIONS
ax.arrow(25, 0,*udg1*3,            width=0.3, head_width=1,  length_includes_head=True,color='blue');
ax.arrow( 0,20,*udg2*3,            width=0.3, head_width=1,  length_includes_head=True,color='yellow');
ax.arrow(25, 0,*udg3*3,            width=0.3, head_width=1,  length_includes_head=True,color='green');
ax.arrow( 0,20,*udg4*3,            width=0.3, head_width=1,  length_includes_head=True,color='red');

# FEASIBLE REGION
fx,fy=np.meshgrid(x,x)
plt.imshow(
  (
     (fy<=s1*(fx-float(xStar1[0]))+float(xStar1[1]))
   & (fy<=s2*fx+20)
   & (fx<=25)
   & (fy<= 0*fx+20)
  ).astype(int),
  extent=(fx.min(),fx.max(),fy.min(),fy.max()),
  origin='lower',
  cmap  ='Greys',
  alpha =0.3,
);

ax.set_xlim(0,s);
ax.set_ylim(0,s);
#ax.legend();

# XSTAR
ax.scatter(*xStar1,s=1e2,color='purple');

sol=(
  r'\begin{eqnarray*}'
  f'x^*&=&{xStar1}'
  r'\\'
  f'z^*&=&\${round(zStar1,2):,.2f}=w^*'
  r'\\'
  f'yc^*&=&{ycStar1}'
  r'\\'
  f'yd^*&=&{ydStar1}'
  r'\\'
  r'\mathrm{ROI}_\mathrm{material}'
  f'&=&{ROI1d}'
  r'\\'
  r'\mathrm{ROI}_\mathrm{labor}'
  f'&=&{ROI2d}'
  r'\end{eqnarray*}'
)
ax.text(10,35,sol,fontsize=10);

# SIMPLEX
dx,dy=1,1
ax.annotate('$A$',(        0+dx,        0+dy));
ax.annotate('$B$',(  (245/8)+dx,        0+dy));
ax.annotate('$C$',(xStar1[0]+dx,xStar1[1]+dy));

##########

ax2 =plt.subplot(122);
ax2.set_aspect(1);

# LINES
ax2.plot   (x,y1,                        label='g1=b1',    linewidth=0.5,linestyle=(0,(5,10)),color='blue');
ax2.plot   (x,s1*(x-xStar1[0])+xStar1[1],label='g1=b1+db1',linewidth=0.5,                     color='blue');
ax2.plot   (x,y2,                        label='g2=b2',    linewidth=0.5,linestyle=(0,(5,10)),color='yellow');
ax2.plot   (x,s2*(x-xStar2[0])+xStar2[1],label='g2=b2+db2',linewidth=0.5,                     color='yellow');
ax2.axvline(  25,                        label='g3=b3',    linewidth=0.5,                     color='green');
ax2.plot   (x,y4,                        label='g4=b4',    linewidth=0.5,                     color='red');

# DELZ
ax2.arrow(10,10,*unitVector(  delz),width=0.01,head_width=0.2,length_includes_head=True,color='black');

# FEASIBLE SIDES <=
ax2.arrow(10,10,*unitVector(-delg1),width=0.01,head_width=0.2,length_includes_head=True,color='blue');
ax2.arrow(10,10,*unitVector(-delg2),width=0.01,head_width=0.2,length_includes_head=True,color='yellow');
ax2.arrow(10,10,*unitVector(-delg3),width=0.01,head_width=0.2,length_includes_head=True,color='green');
ax2.arrow(10,10,*unitVector(-delg4),width=0.01,head_width=0.2,length_includes_head=True,color='red');

# DIRECTIONS
ax2.arrow(25, 0,*udg1*3,            width=0.3, head_width=1,  length_includes_head=True,color='blue');
ax2.arrow( 0,20,*udg2*3,            width=0.3, head_width=1,  length_includes_head=True,color='yellow');
ax2.arrow(25, 0,*udg3*3,            width=0.3, head_width=1,  length_includes_head=True,color='green');
ax2.arrow( 0,20,*udg4*3,            width=0.3, head_width=1,  length_includes_head=True,color='red');

# FEASIBLE REGION
fx,fy=np.meshgrid(x,x)
plt.imshow(
  (
     (fy<=s1*(fx-float(xStar1[0]))+float(xStar1[1]))
   & (fy<=s2*(fx-float(xStar2[0]))+float(xStar2[1]))
   & (fx<=25)
   & (fy<=0*fx+20)
  ).astype(int),
  extent=(fx.min(),fx.max(),fy.min(),fy.max()),
  origin='lower',
  cmap  ='Greys',
  alpha =0.3,
);

ax2.set_xlim(0,s);
ax2.set_ylim(0,s);
#ax2.legend();

# XSTAR
ax2.scatter(*xStar2,s=1e2,color='purple');

sol=(
  r'\begin{eqnarray*}'
  f'x^*&=&({Fraction(float(xStar2[0])).limit_denominator(10)},{Fraction(float(xStar2[1])).limit_denominator(10)})'
  r'\\'
  f'z^*&=&\${round(zStar2,2):,.2f}=w^*'
  r'\\'
  f'yc^*&=&{ycStar2}'
  r'\\'
  f'yd^*&=&{ydStar2}'
  r'\\'
  r'\mathrm{ROI}_\mathrm{material}'
  f'&=&{ROI3d}'
  r'\\'
  r'\mathrm{ROI}_\mathrm{labor}'
  f'&=&{ROI4d}'
  r'\end{eqnarray*}'
)
ax2.text(10,35,sol,fontsize=10);

# SIMPLEX
dx,dy=1,1
ax2.annotate('$A$',(        0+dx,        0+dy));
ax2.annotate('$B$',(  (245/8)+dx,        0+dy));
ax2.annotate('$C$',(xStar2[0]+dx,xStar2[1]+dy));
Error in callback <function _draw_all_if_interactive at 0x1302e8e00> (for post_execute), with arguments args (),kwargs {}:
---------------------------------------------------------------------------
PermissionError                           Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/pyplot.py:197, in _draw_all_if_interactive()
    195 def _draw_all_if_interactive() -> None:
    196     if matplotlib.is_interactive():
--> 197         draw_all()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/_pylab_helpers.py:132, in Gcf.draw_all(cls, force)
    130 for manager in cls.get_all_fig_managers():
    131     if force or manager.canvas.figure.stale:
--> 132         manager.canvas.draw_idle()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:1893, in FigureCanvasBase.draw_idle(self, *args, **kwargs)
   1891 if not self._is_idle_drawing:
   1892     with self._idle_draw_cntx():
-> 1893         self.draw(*args, **kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
    385 # Acquire a lock on the shared font cache.
    386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
    387       else nullcontext()):
--> 388     self.figure.draw(self.renderer)
    389     # A GUI class may be need to update a window using this draw, so
    390     # don't forget to call the superclass.
    391     super().draw()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
     93 @wraps(draw)
     94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95     result = draw(artist, renderer, *args, **kwargs)
     96     if renderer._rasterizing:
     97         renderer.stop_rasterizing()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
   3151         # ValueError can occur when resizing a window.
   3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
   3155     renderer, self, artists, self.suppressComposite)
   3157 for sfig in self.subfigs:
   3158     sfig.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    130 if not_composite or not has_images:
    131     for a in artists:
--> 132         a.draw(renderer)
    133 else:
    134     # Composite any adjacent images together
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axes/_base.py:3070, in _AxesBase.draw(self, renderer)
   3067 if artists_rasterized:
   3068     _draw_rasterized(self.figure, artists_rasterized, renderer)
-> 3070 mimage._draw_list_compositing_images(
   3071     renderer, self, artists, self.figure.suppressComposite)
   3073 renderer.close_group('axes')
   3074 self.stale = False

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    130 if not_composite or not has_images:
    131     for a in artists:
--> 132         a.draw(renderer)
    133 else:
    134     # Composite any adjacent images together
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1388, in Axis.draw(self, renderer, *args, **kwargs)
   1385 renderer.open_group(__name__, gid=self.get_gid())
   1387 ticks_to_draw = self._update_ticks()
-> 1388 tlb1, tlb2 = self._get_ticklabel_bboxes(ticks_to_draw, renderer)
   1390 for tick in ticks_to_draw:
   1391     tick.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in Axis._get_ticklabel_bboxes(self, ticks, renderer)
   1313 if renderer is None:
   1314     renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
   1316          for tick in ticks if tick.label1.get_visible()],
   1317         [tick.label2.get_window_extent(renderer)
   1318          for tick in ticks if tick.label2.get_visible()])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in <listcomp>(.0)
   1313 if renderer is None:
   1314     renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
   1316          for tick in ticks if tick.label1.get_visible()],
   1317         [tick.label2.get_window_extent(renderer)
   1318          for tick in ticks if tick.label2.get_visible()])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:956, in Text.get_window_extent(self, renderer, dpi)
    951     raise RuntimeError(
    952         "Cannot get window extent of text w/o renderer. You likely "
    953         "want to call 'figure.draw_without_rendering()' first.")
    955 with cbook._setattr_cm(self.figure, dpi=dpi):
--> 956     bbox, info, descent = self._get_layout(self._renderer)
    957     x, y = self.get_unitless_position()
    958     x, y = self.get_transform().transform((x, y))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
    370 ys = []
    372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
    374     renderer, "lp", self._fontproperties,
    375     ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
    376 min_dy = (lp_h - lp_d) * self._linespacing
    378 for i, line in enumerate(lines):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
     66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
     67 # Cached based on a copy of fontprop so that later in-place mutations of
     68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
     70     weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
     73 @functools.lru_cache(4096)
     74 def _get_text_metrics_with_cache_impl(
     75         renderer_ref, text, fontprop, ismath, dpi):
     76     # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77     return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
    211 _api.check_in_list(["TeX", True, False], ismath=ismath)
    212 if ismath == "TeX":
--> 213     return super().get_text_width_height_descent(s, prop, ismath)
    215 if ismath:
    216     ox, oy, width, height, descent, font_image = \
    217         self.mathtext_parser.parse(s, self.dpi, prop)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
    648 fontsize = prop.get_size_in_points()
    650 if ismath == 'TeX':
    651     # todo: handle properties
--> 652     return self.get_texmanager().get_text_width_height_descent(
    653         s, fontsize, renderer=self)
    655 dpi = self.points_to_pixels(72)
    656 if ismath:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
    364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
    365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366     page, = dvi
    367 # A total height (including the descent) needs to be returned.
    368 return page.width, page.height + page.descent, page.descent

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
    280 def __iter__(self):
    281     """
    282     Iterate through the pages of the file.
    283 
   (...)
    294         integers.
    295     """
--> 296     while self._read():
    297         yield self._output()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
    373 while True:
    374     byte = self.file.read(1)[0]
--> 375     self._dtable[byte](self, byte)
    376     name = self._dtable[byte].__name__
    377     if name == "_push":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
    225 if state is not None and self.state != state:
    226     raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
    524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
    525 def _fnt_def(self, k, c, s, d, a, l):
--> 526     self._fnt_def_real(k, c, s, d, a, l)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
    529 n = self.file.read(a + l)
    530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
    532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
    533     raise ValueError('tfm checksum mismatch: %s' % n)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
   1114 @lru_cache
   1115 def _fontfile(cls, suffix, texname):
-> 1116     return cls(find_tex_file(texname + suffix))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
   1079     filename = filename.decode('utf-8', errors='replace')
   1081 try:
-> 1082     lk = _LuatexKpsewhich()
   1083 except FileNotFoundError:
   1084     lk = None  # Fallback to directly calling kpsewhich, as below.

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
   1034 @lru_cache  # A singleton.
   1035 def __new__(cls):
   1036     self = object.__new__(cls)
-> 1037     self._proc = self._new_proc()
   1038     return self

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
   1040 def _new_proc(self):
-> 1041     return subprocess.Popen(
   1042         ["luatex", "--luaonly",
   1043          str(cbook._get_data_path("kpsewhich.lua"))],
   1044         stdin=subprocess.PIPE, stdout=subprocess.PIPE)

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
   1953     err_msg = os.strerror(errno_num)
   1954 if err_filename is not None:
-> 1955     raise child_exception_type(errno_num, err_msg, err_filename)
   1956 else:
   1957     raise child_exception_type(errno_num, err_msg)

PermissionError: [Errno 13] Permission denied: 'luatex'
---------------------------------------------------------------------------
PermissionError                           Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
    341     pass
    342 else:
--> 343     return printer(obj)
    344 # Finally look for special method names
    345 method = get_real_method(obj, self.print_method)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/pylabtools.py:152, in print_figure(fig, fmt, bbox_inches, base64, **kwargs)
    149     from matplotlib.backend_bases import FigureCanvasBase
    150     FigureCanvasBase(fig)
--> 152 fig.canvas.print_figure(bytes_io, **kw)
    153 data = bytes_io.getvalue()
    154 if fmt == 'svg':

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2164, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
   2161     # we do this instead of `self.figure.draw_without_rendering`
   2162     # so that we can inject the orientation
   2163     with getattr(renderer, "_draw_disabled", nullcontext)():
-> 2164         self.figure.draw(renderer)
   2165 if bbox_inches:
   2166     if bbox_inches == "tight":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
     93 @wraps(draw)
     94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95     result = draw(artist, renderer, *args, **kwargs)
     96     if renderer._rasterizing:
     97         renderer.stop_rasterizing()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
   3151         # ValueError can occur when resizing a window.
   3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
   3155     renderer, self, artists, self.suppressComposite)
   3157 for sfig in self.subfigs:
   3158     sfig.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    130 if not_composite or not has_images:
    131     for a in artists:
--> 132         a.draw(renderer)
    133 else:
    134     # Composite any adjacent images together
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axes/_base.py:3070, in _AxesBase.draw(self, renderer)
   3067 if artists_rasterized:
   3068     _draw_rasterized(self.figure, artists_rasterized, renderer)
-> 3070 mimage._draw_list_compositing_images(
   3071     renderer, self, artists, self.figure.suppressComposite)
   3073 renderer.close_group('axes')
   3074 self.stale = False

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    130 if not_composite or not has_images:
    131     for a in artists:
--> 132         a.draw(renderer)
    133 else:
    134     # Composite any adjacent images together
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1388, in Axis.draw(self, renderer, *args, **kwargs)
   1385 renderer.open_group(__name__, gid=self.get_gid())
   1387 ticks_to_draw = self._update_ticks()
-> 1388 tlb1, tlb2 = self._get_ticklabel_bboxes(ticks_to_draw, renderer)
   1390 for tick in ticks_to_draw:
   1391     tick.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in Axis._get_ticklabel_bboxes(self, ticks, renderer)
   1313 if renderer is None:
   1314     renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
   1316          for tick in ticks if tick.label1.get_visible()],
   1317         [tick.label2.get_window_extent(renderer)
   1318          for tick in ticks if tick.label2.get_visible()])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in <listcomp>(.0)
   1313 if renderer is None:
   1314     renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
   1316          for tick in ticks if tick.label1.get_visible()],
   1317         [tick.label2.get_window_extent(renderer)
   1318          for tick in ticks if tick.label2.get_visible()])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:956, in Text.get_window_extent(self, renderer, dpi)
    951     raise RuntimeError(
    952         "Cannot get window extent of text w/o renderer. You likely "
    953         "want to call 'figure.draw_without_rendering()' first.")
    955 with cbook._setattr_cm(self.figure, dpi=dpi):
--> 956     bbox, info, descent = self._get_layout(self._renderer)
    957     x, y = self.get_unitless_position()
    958     x, y = self.get_transform().transform((x, y))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
    370 ys = []
    372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
    374     renderer, "lp", self._fontproperties,
    375     ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
    376 min_dy = (lp_h - lp_d) * self._linespacing
    378 for i, line in enumerate(lines):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
     66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
     67 # Cached based on a copy of fontprop so that later in-place mutations of
     68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
     70     weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
     73 @functools.lru_cache(4096)
     74 def _get_text_metrics_with_cache_impl(
     75         renderer_ref, text, fontprop, ismath, dpi):
     76     # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77     return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
    211 _api.check_in_list(["TeX", True, False], ismath=ismath)
    212 if ismath == "TeX":
--> 213     return super().get_text_width_height_descent(s, prop, ismath)
    215 if ismath:
    216     ox, oy, width, height, descent, font_image = \
    217         self.mathtext_parser.parse(s, self.dpi, prop)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
    648 fontsize = prop.get_size_in_points()
    650 if ismath == 'TeX':
    651     # todo: handle properties
--> 652     return self.get_texmanager().get_text_width_height_descent(
    653         s, fontsize, renderer=self)
    655 dpi = self.points_to_pixels(72)
    656 if ismath:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
    364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
    365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366     page, = dvi
    367 # A total height (including the descent) needs to be returned.
    368 return page.width, page.height + page.descent, page.descent

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
    280 def __iter__(self):
    281     """
    282     Iterate through the pages of the file.
    283 
   (...)
    294         integers.
    295     """
--> 296     while self._read():
    297         yield self._output()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
    373 while True:
    374     byte = self.file.read(1)[0]
--> 375     self._dtable[byte](self, byte)
    376     name = self._dtable[byte].__name__
    377     if name == "_push":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
    225 if state is not None and self.state != state:
    226     raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
    524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
    525 def _fnt_def(self, k, c, s, d, a, l):
--> 526     self._fnt_def_real(k, c, s, d, a, l)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
    529 n = self.file.read(a + l)
    530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
    532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
    533     raise ValueError('tfm checksum mismatch: %s' % n)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
   1114 @lru_cache
   1115 def _fontfile(cls, suffix, texname):
-> 1116     return cls(find_tex_file(texname + suffix))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
   1079     filename = filename.decode('utf-8', errors='replace')
   1081 try:
-> 1082     lk = _LuatexKpsewhich()
   1083 except FileNotFoundError:
   1084     lk = None  # Fallback to directly calling kpsewhich, as below.

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
   1034 @lru_cache  # A singleton.
   1035 def __new__(cls):
   1036     self = object.__new__(cls)
-> 1037     self._proc = self._new_proc()
   1038     return self

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
   1040 def _new_proc(self):
-> 1041     return subprocess.Popen(
   1042         ["luatex", "--luaonly",
   1043          str(cbook._get_data_path("kpsewhich.lua"))],
   1044         stdin=subprocess.PIPE, stdout=subprocess.PIPE)

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
   1953     err_msg = os.strerror(errno_num)
   1954 if err_filename is not None:
-> 1955     raise child_exception_type(errno_num, err_msg, err_filename)
   1956 else:
   1957     raise child_exception_type(errno_num, err_msg)

PermissionError: [Errno 13] Permission denied: 'luatex'
<Figure size 2400x4800 with 2 Axes>

[D] How much additional capital does the company need to maximize profit?#

Hide code cell source
xStar4=(25,20)
db1   =g1.subs([(x1,xStar4[0]),(x2,xStar4[1])])
db2   =g2.subs([(x1,xStar4[0]),(x2,xStar4[1])])
rc4   =p1*db1+p2*db2
zStar4=z.subs([(x1,xStar4[0]),(x2,xStar4[1])])

display(Math(
  r"\begin{aligned}"

  f"g_1(25,20)&={latex(db1+b1)}"
  r"\,\,\,\text{hrs total}"
  r"\\"
  f"g_2(25,20)&={latex(g2.subs([(x1,25),(x2,20)])+b2)}"
  r"\,\,\,\text{lbs total}"
  r"\\"
  f"g_1(25,20)-b_1&={latex(db1)}"
  r"\,\,\,\text{hrs additional}"
  r"\\"
  f"g_2(25,20)-b_2&={latex(db2)}"
  r"\,\,\,\text{lbs additional}"
  r"\\"
  r"\text{cost of additional material and labor}&="
  f"\${rc4:,.2f}"
  r"\\"

  r"z^*"
  f"{xStar4}"
  r"&="
  f"\${zStar4-rc4:,.2f}"

  r"\end{aligned}"
))
\[\begin{split}\displaystyle \begin{aligned}g_1(25,20)&=800\,\,\,\text{hrs total}\\g_2(25,20)&=650\,\,\,\text{lbs total}\\g_1(25,20)-b_1&=300\,\,\,\text{hrs additional}\\g_2(25,20)-b_2&=250\,\,\,\text{lbs additional}\\\text{cost of additional material and labor}&=\$8,325.00\\z^*(25, 20)&=\$19,175.00\end{aligned}\end{split}\]
Hide code cell source
d  =np.array([-rc4])

# CONCISE ROW TABLEAU
rA = Matrix([
  [ 'c', 'x1',  'x2',     1, 'r'],
  ['y1',  -20,   -15,b1+db1,'s1'],
  ['y2',  -10,   -20,b2+db2,'s2'],
  ['y3',   -1,     0,b3+db3,'s3'],
  ['y4',    0,    -1,b4+db4,'s4'],
  [  -1, -500,  -750, -d[0],'-z'],
  [ 'c','-v1', '-v2',   'w', 'r'],
])
rB = pivot(1,1,rA)
rC = pivot(2,2,rB)
rD = pivot(4,2,rC)
rE = pivot(3,1,rD)

# CONCISE COLUMN TABLEAU
cA = Matrix([
  [ 'c',  'y1',  'y2',  'y3',  'y4',   1, 'r'],
  ['x1',    20,    10,     1,     0,-500,'v1'],
  ['x2',    15,    20,     0,     1,-750,'v2'],
  [  -1,b1+db1,b2+db2,b3+db3,b4+db4,d[0], 'w'],
  [ 'c', '-s1', '-s2', '-s3', '-s4','-z', 'r'],
])
cB = pivot(1,1,cA)
cC = pivot(2,2,cB)
cD = pivot(2,4,cC)
cE = pivot(1,3,cD)

display(Math(
   r'\begin{aligned}'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,rA = {latex(rA)}\,\,\,\,\,&&'
   r'\begin{aligned}&\text{START}\\&x_1=x_2=0\end{aligned}\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,rB = {latex(rB)}\,\,\,\,\,&&x_2=s_1=0\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,rC = {latex(rC)}\,\,\,\,\,&&'
   r'\begin{aligned}&\text{OPTIMAL}\\&s_1=s_2=0\end{aligned}\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,rD = {latex(rD)}\,\,\,\,\,&&'
   r'\begin{aligned}&\text{LEVEL SET}\\&s_1=s_4=0\end{aligned}\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,rE = {latex(rE)}\,\,\,\,\,&&'
   r'\begin{aligned}&\text{LEVEL SET}\\&s_3=s_4=0\end{aligned}\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,cA = {latex(cA)}\,\,\,\,\,&&'
   r'\begin{aligned}&\text{START}\\&x_1=x_2=0\end{aligned}\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,cB = {latex(cB)}\,\,\,\,\,&&x_2=s_1=0\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,cC = {latex(cC)}\,\,\,\,\,&&'
   r'\begin{aligned}&\text{OPTIMAL}\\&s_1=s_2=0\end{aligned}\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,cD = {latex(cD)}\,\,\,\,\,&&'
   r'\begin{aligned}&\text{LEVEL SET}\\&s_1=s_4=0\end{aligned}\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,cE = {latex(cE)}\,\,\,\,\,&&'
   r'\begin{aligned}&\text{LEVEL SET}\\&s_3=s_4=0\end{aligned}\\'
   r'\end{aligned}'
))
\[\begin{split}\displaystyle \begin{aligned}db &= (300,250,0,0)\,\,\,rA = \left[\begin{matrix}c & x_{1} & x_{2} & 1 & r\\y_{1} & -20 & -15 & 800 & s_{1}\\y_{2} & -10 & -20 & 650 & s_{2}\\y_{3} & -1 & 0 & 25 & s_{3}\\y_{4} & 0 & -1 & 20 & s_{4}\\-1 & -500 & -750 & 8325.0 & - z\\c & - v_{1} & - v_{2} & w & r\end{matrix}\right]\,\,\,\,\,&&\begin{aligned}&\text{START}\\&x_1=x_2=0\end{aligned}\\db &= (300,250,0,0)\,\,\,rB = \left[\begin{matrix}c & s_{1} & x_{2} & 1 & r\\v_{1} & - \frac{1}{20} & - \frac{3}{4} & 40 & x_{1}\\y_{2} & \frac{1}{2} & - \frac{25}{2} & 250 & s_{2}\\y_{3} & \frac{1}{20} & \frac{3}{4} & -15 & s_{3}\\y_{4} & 0 & -1 & 20 & s_{4}\\-1 & 25 & -375 & -11675.0 & - z\\c & - y_{1} & - v_{2} & w & r\end{matrix}\right]\,\,\,\,\,&&x_2=s_1=0\\db &= (300,250,0,0)\,\,\,rC = \left[\begin{matrix}c & s_{1} & s_{2} & 1 & r\\v_{1} & - \frac{2}{25} & \frac{3}{50} & 25 & x_{1}\\v_{2} & \frac{1}{25} & - \frac{2}{25} & 20 & x_{2}\\y_{3} & \frac{2}{25} & - \frac{3}{50} & 0 & s_{3}\\y_{4} & - \frac{1}{25} & \frac{2}{25} & 0 & s_{4}\\-1 & 10 & 30 & -19175.0 & - z\\c & - y_{1} & - y_{2} & w & r\end{matrix}\right]\,\,\,\,\,&&\begin{aligned}&\text{OPTIMAL}\\&s_1=s_2=0\end{aligned}\\db &= (300,250,0,0)\,\,\,rD = \left[\begin{matrix}c & s_{1} & s_{4} & 1 & r\\v_{1} & - \frac{1}{20} & \frac{3}{4} & 25 & x_{1}\\v_{2} & 0 & -1 & 20 & x_{2}\\y_{3} & \frac{1}{20} & - \frac{3}{4} & 0 & s_{3}\\y_{2} & \frac{1}{2} & \frac{25}{2} & 0 & s_{2}\\-1 & 25 & 375 & -19175.0 & - z\\c & - y_{1} & - y_{4} & w & r\end{matrix}\right]\,\,\,\,\,&&\begin{aligned}&\text{LEVEL SET}\\&s_1=s_4=0\end{aligned}\\db &= (300,250,0,0)\,\,\,rE = \left[\begin{matrix}c & s_{3} & s_{4} & 1 & r\\v_{1} & -1 & 0 & 25 & x_{1}\\v_{2} & 0 & -1 & 20 & x_{2}\\y_{1} & 20 & 15 & 0 & s_{1}\\y_{2} & 10 & 20 & 0 & s_{2}\\-1 & 500 & 750 & -19175.0 & - z\\c & - y_{3} & - y_{4} & w & r\end{matrix}\right]\,\,\,\,\,&&\begin{aligned}&\text{LEVEL SET}\\&s_3=s_4=0\end{aligned}\\db &= (300,250,0,0)\,\,\,cA = \left[\begin{matrix}c & y_{1} & y_{2} & y_{3} & y_{4} & 1 & r\\x_{1} & 20 & 10 & 1 & 0 & -500 & v_{1}\\x_{2} & 15 & 20 & 0 & 1 & -750 & v_{2}\\-1 & 800 & 650 & 25 & 20 & -8325.0 & w\\c & - s_{1} & - s_{2} & - s_{3} & - s_{4} & - z & r\end{matrix}\right]\,\,\,\,\,&&\begin{aligned}&\text{START}\\&x_1=x_2=0\end{aligned}\\db &= (300,250,0,0)\,\,\,cB = \left[\begin{matrix}c & v_{1} & y_{2} & y_{3} & y_{4} & 1 & r\\s_{1} & \frac{1}{20} & - \frac{1}{2} & - \frac{1}{20} & 0 & 25 & y_{1}\\x_{2} & \frac{3}{4} & \frac{25}{2} & - \frac{3}{4} & 1 & -375 & v_{2}\\-1 & 40 & 250 & -15 & 20 & 11675.0 & w\\c & - x_{1} & - s_{2} & - s_{3} & - s_{4} & - z & r\end{matrix}\right]\,\,\,\,\,&&x_2=s_1=0\\db &= (300,250,0,0)\,\,\,cC = \left[\begin{matrix}c & v_{1} & v_{2} & y_{3} & y_{4} & 1 & r\\s_{1} & \frac{2}{25} & - \frac{1}{25} & - \frac{2}{25} & \frac{1}{25} & 10 & y_{1}\\s_{2} & - \frac{3}{50} & \frac{2}{25} & \frac{3}{50} & - \frac{2}{25} & 30 & y_{2}\\-1 & 25 & 20 & 0 & 0 & 19175.0 & w\\c & - x_{1} & - x_{2} & - s_{3} & - s_{4} & - z & r\end{matrix}\right]\,\,\,\,\,&&\begin{aligned}&\text{OPTIMAL}\\&s_1=s_2=0\end{aligned}\\db &= (300,250,0,0)\,\,\,cD = \left[\begin{matrix}c & v_{1} & v_{2} & y_{3} & y_{2} & 1 & r\\s_{1} & \frac{1}{20} & 0 & - \frac{1}{20} & - \frac{1}{2} & 25 & y_{1}\\s_{4} & - \frac{3}{4} & 1 & \frac{3}{4} & - \frac{25}{2} & 375 & y_{4}\\-1 & 25 & 20 & 0 & 0 & 19175.0 & w\\c & - x_{1} & - x_{2} & - s_{3} & - s_{2} & - z & r\end{matrix}\right]\,\,\,\,\,&&\begin{aligned}&\text{LEVEL SET}\\&s_1=s_4=0\end{aligned}\\db &= (300,250,0,0)\,\,\,cE = \left[\begin{matrix}c & v_{1} & v_{2} & y_{1} & y_{2} & 1 & r\\s_{3} & 1 & 0 & -20 & -10 & 500 & y_{3}\\s_{4} & 0 & 1 & -15 & -20 & 750 & y_{4}\\-1 & 25 & 20 & 0 & 0 & 19175.0 & w\\c & - x_{1} & - x_{2} & - s_{1} & - s_{2} & - z & r\end{matrix}\right]\,\,\,\,\,&&\begin{aligned}&\text{LEVEL SET}\\&s_3=s_4=0\end{aligned}\\\end{aligned}\end{split}\]
ycStar4=yStar
ydStar4=(25,0,0,375)
yeStar4=(0,0,500,750)

ROI5c=round((ycStar4[0]-p1)/p1,2)
ROI6c=round((ycStar4[1]-p2)/p2,2)
ROI5d=round((ydStar4[0]-p1)/p1,2)
ROI6d=round((ydStar4[1]-p2)/p2,2)
ROI5e=round((yeStar4[0]-p1)/p1,2)
ROI6e=round((yeStar4[1]-p2)/p2,2)
Hide code cell source
fig=plt.figure(dpi=300,figsize=(8,16));

##########

ax2 =plt.subplot();
ax2.set_aspect(1);

# LINES
ax2.plot   (x,y1,                        label='g1=b1',    linewidth=0.8,linestyle=(0,(5,10)),color='blue');
ax2.plot   (x,s1*(x-xStar4[0])+xStar4[1],label='g1=b1+db1',linewidth=0.8,                     color='blue');
ax2.plot   (x,y2,                        label='g2=b2',    linewidth=0.8,linestyle=(0,(5,10)),color='yellow');
ax2.plot   (x,s2*(x-xStar4[0])+xStar4[1],label='g2=b2+db2',linewidth=0.8,                     color='yellow');
ax2.axvline(  25,                        label='g3=b3',    linewidth=0.5,                     color='green');
ax2.plot   (x,y4,                        label='g4=b4',    linewidth=0.5,                     color='red');

# DELZ
ax2.arrow(10,10,*unitVector(  delz),width=0.01,head_width=0.2,length_includes_head=True,color='black');

# FEASIBLE SIDES <=
ax2.arrow(10,10,*unitVector(-delg1),width=0.01,head_width=0.2,length_includes_head=True,color='blue');
ax2.arrow(10,10,*unitVector(-delg2),width=0.01,head_width=0.2,length_includes_head=True,color='yellow');
ax2.arrow(10,10,*unitVector(-delg3),width=0.01,head_width=0.2,length_includes_head=True,color='green');
ax2.arrow(10,10,*unitVector(-delg4),width=0.01,head_width=0.2,length_includes_head=True,color='red');

# DIRECTIONS
ax2.arrow(25, 0,*udg1*3,            width=0.3, head_width=1,  length_includes_head=True,color='blue');
ax2.arrow( 0,20,*udg2*3,            width=0.3, head_width=1,  length_includes_head=True,color='yellow');
ax2.arrow(25, 0,*udg3*3,            width=0.3, head_width=1,  length_includes_head=True,color='green');
ax2.arrow( 0,20,*udg4*3,            width=0.3, head_width=1,  length_includes_head=True,color='red');

# FEASIBLE REGION
fx,fy=np.meshgrid(x,x)
plt.imshow(
  (
     (fy<=s1*(fx-float(xStar4[0]))+float(xStar4[1]))
   & (fy<=s2*(fx-float(xStar4[0]))+float(xStar4[1]))
   & (fx<=25)
   & (fy<=0*fx+20)
  ).astype(int),
  extent=(fx.min(),fx.max(),fy.min(),fy.max()),
  origin='lower',
  cmap  ='Greys',
  alpha =0.3,
);

ax2.set_xlim(0,s);
ax2.set_ylim(0,s);
ax2.legend();

# XSTAR
ax2.scatter(*xStar4,s=1e2,color='purple');

sol=(
  r'\begin{eqnarray*}'
  f'x^*&=&({Fraction(float(xStar4[0])).limit_denominator(10)},{Fraction(float(xStar4[1])).limit_denominator(10)})'
  r'\\'
  f'z^*&=&\${round(zStar4-rc4,2):,.2f}=w^*'
  r'\\'
  f'yc^*&=&{ycStar4}'
  r'\\'
  f'yd^*&=&{ydStar4}'
  r'\\'
  r'\mathrm{ROI}_\mathrm{material}'
  f'&=&{ROI5e}'
  r'\\'
  r'\mathrm{ROI}_\mathrm{labor}'
  f'&=&{ROI6e}'
  r'\end{eqnarray*}'
)
ax2.text(10,35,sol,fontsize=10);

# SIMPLEX
dx,dy=1,1
ax2.annotate('$A$',(        0+dx,        0+dy));
ax2.annotate('$B$',(       40+dx,        0+dy));
ax2.annotate('$C$',(xStar4[0]+dx,xStar4[1]+dy));
Error in callback <function _draw_all_if_interactive at 0x1302e8e00> (for post_execute), with arguments args (),kwargs {}:
---------------------------------------------------------------------------
PermissionError                           Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/pyplot.py:197, in _draw_all_if_interactive()
    195 def _draw_all_if_interactive() -> None:
    196     if matplotlib.is_interactive():
--> 197         draw_all()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/_pylab_helpers.py:132, in Gcf.draw_all(cls, force)
    130 for manager in cls.get_all_fig_managers():
    131     if force or manager.canvas.figure.stale:
--> 132         manager.canvas.draw_idle()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:1893, in FigureCanvasBase.draw_idle(self, *args, **kwargs)
   1891 if not self._is_idle_drawing:
   1892     with self._idle_draw_cntx():
-> 1893         self.draw(*args, **kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
    385 # Acquire a lock on the shared font cache.
    386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
    387       else nullcontext()):
--> 388     self.figure.draw(self.renderer)
    389     # A GUI class may be need to update a window using this draw, so
    390     # don't forget to call the superclass.
    391     super().draw()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
     93 @wraps(draw)
     94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95     result = draw(artist, renderer, *args, **kwargs)
     96     if renderer._rasterizing:
     97         renderer.stop_rasterizing()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
   3151         # ValueError can occur when resizing a window.
   3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
   3155     renderer, self, artists, self.suppressComposite)
   3157 for sfig in self.subfigs:
   3158     sfig.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    130 if not_composite or not has_images:
    131     for a in artists:
--> 132         a.draw(renderer)
    133 else:
    134     # Composite any adjacent images together
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axes/_base.py:3070, in _AxesBase.draw(self, renderer)
   3067 if artists_rasterized:
   3068     _draw_rasterized(self.figure, artists_rasterized, renderer)
-> 3070 mimage._draw_list_compositing_images(
   3071     renderer, self, artists, self.figure.suppressComposite)
   3073 renderer.close_group('axes')
   3074 self.stale = False

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    130 if not_composite or not has_images:
    131     for a in artists:
--> 132         a.draw(renderer)
    133 else:
    134     # Composite any adjacent images together
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1388, in Axis.draw(self, renderer, *args, **kwargs)
   1385 renderer.open_group(__name__, gid=self.get_gid())
   1387 ticks_to_draw = self._update_ticks()
-> 1388 tlb1, tlb2 = self._get_ticklabel_bboxes(ticks_to_draw, renderer)
   1390 for tick in ticks_to_draw:
   1391     tick.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in Axis._get_ticklabel_bboxes(self, ticks, renderer)
   1313 if renderer is None:
   1314     renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
   1316          for tick in ticks if tick.label1.get_visible()],
   1317         [tick.label2.get_window_extent(renderer)
   1318          for tick in ticks if tick.label2.get_visible()])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in <listcomp>(.0)
   1313 if renderer is None:
   1314     renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
   1316          for tick in ticks if tick.label1.get_visible()],
   1317         [tick.label2.get_window_extent(renderer)
   1318          for tick in ticks if tick.label2.get_visible()])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:956, in Text.get_window_extent(self, renderer, dpi)
    951     raise RuntimeError(
    952         "Cannot get window extent of text w/o renderer. You likely "
    953         "want to call 'figure.draw_without_rendering()' first.")
    955 with cbook._setattr_cm(self.figure, dpi=dpi):
--> 956     bbox, info, descent = self._get_layout(self._renderer)
    957     x, y = self.get_unitless_position()
    958     x, y = self.get_transform().transform((x, y))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
    370 ys = []
    372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
    374     renderer, "lp", self._fontproperties,
    375     ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
    376 min_dy = (lp_h - lp_d) * self._linespacing
    378 for i, line in enumerate(lines):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
     66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
     67 # Cached based on a copy of fontprop so that later in-place mutations of
     68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
     70     weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
     73 @functools.lru_cache(4096)
     74 def _get_text_metrics_with_cache_impl(
     75         renderer_ref, text, fontprop, ismath, dpi):
     76     # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77     return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
    211 _api.check_in_list(["TeX", True, False], ismath=ismath)
    212 if ismath == "TeX":
--> 213     return super().get_text_width_height_descent(s, prop, ismath)
    215 if ismath:
    216     ox, oy, width, height, descent, font_image = \
    217         self.mathtext_parser.parse(s, self.dpi, prop)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
    648 fontsize = prop.get_size_in_points()
    650 if ismath == 'TeX':
    651     # todo: handle properties
--> 652     return self.get_texmanager().get_text_width_height_descent(
    653         s, fontsize, renderer=self)
    655 dpi = self.points_to_pixels(72)
    656 if ismath:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
    364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
    365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366     page, = dvi
    367 # A total height (including the descent) needs to be returned.
    368 return page.width, page.height + page.descent, page.descent

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
    280 def __iter__(self):
    281     """
    282     Iterate through the pages of the file.
    283 
   (...)
    294         integers.
    295     """
--> 296     while self._read():
    297         yield self._output()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
    373 while True:
    374     byte = self.file.read(1)[0]
--> 375     self._dtable[byte](self, byte)
    376     name = self._dtable[byte].__name__
    377     if name == "_push":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
    225 if state is not None and self.state != state:
    226     raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
    524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
    525 def _fnt_def(self, k, c, s, d, a, l):
--> 526     self._fnt_def_real(k, c, s, d, a, l)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
    529 n = self.file.read(a + l)
    530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
    532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
    533     raise ValueError('tfm checksum mismatch: %s' % n)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
   1114 @lru_cache
   1115 def _fontfile(cls, suffix, texname):
-> 1116     return cls(find_tex_file(texname + suffix))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
   1079     filename = filename.decode('utf-8', errors='replace')
   1081 try:
-> 1082     lk = _LuatexKpsewhich()
   1083 except FileNotFoundError:
   1084     lk = None  # Fallback to directly calling kpsewhich, as below.

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
   1034 @lru_cache  # A singleton.
   1035 def __new__(cls):
   1036     self = object.__new__(cls)
-> 1037     self._proc = self._new_proc()
   1038     return self

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
   1040 def _new_proc(self):
-> 1041     return subprocess.Popen(
   1042         ["luatex", "--luaonly",
   1043          str(cbook._get_data_path("kpsewhich.lua"))],
   1044         stdin=subprocess.PIPE, stdout=subprocess.PIPE)

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
   1953     err_msg = os.strerror(errno_num)
   1954 if err_filename is not None:
-> 1955     raise child_exception_type(errno_num, err_msg, err_filename)
   1956 else:
   1957     raise child_exception_type(errno_num, err_msg)

PermissionError: [Errno 13] Permission denied: 'luatex'
---------------------------------------------------------------------------
PermissionError                           Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:343, in BaseFormatter.__call__(self, obj)
    341     pass
    342 else:
--> 343     return printer(obj)
    344 # Finally look for special method names
    345 method = get_real_method(obj, self.print_method)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/pylabtools.py:152, in print_figure(fig, fmt, bbox_inches, base64, **kwargs)
    149     from matplotlib.backend_bases import FigureCanvasBase
    150     FigureCanvasBase(fig)
--> 152 fig.canvas.print_figure(bytes_io, **kw)
    153 data = bytes_io.getvalue()
    154 if fmt == 'svg':

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2164, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
   2161     # we do this instead of `self.figure.draw_without_rendering`
   2162     # so that we can inject the orientation
   2163     with getattr(renderer, "_draw_disabled", nullcontext)():
-> 2164         self.figure.draw(renderer)
   2165 if bbox_inches:
   2166     if bbox_inches == "tight":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
     93 @wraps(draw)
     94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95     result = draw(artist, renderer, *args, **kwargs)
     96     if renderer._rasterizing:
     97         renderer.stop_rasterizing()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
   3151         # ValueError can occur when resizing a window.
   3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
   3155     renderer, self, artists, self.suppressComposite)
   3157 for sfig in self.subfigs:
   3158     sfig.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    130 if not_composite or not has_images:
    131     for a in artists:
--> 132         a.draw(renderer)
    133 else:
    134     # Composite any adjacent images together
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axes/_base.py:3070, in _AxesBase.draw(self, renderer)
   3067 if artists_rasterized:
   3068     _draw_rasterized(self.figure, artists_rasterized, renderer)
-> 3070 mimage._draw_list_compositing_images(
   3071     renderer, self, artists, self.figure.suppressComposite)
   3073 renderer.close_group('axes')
   3074 self.stale = False

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    130 if not_composite or not has_images:
    131     for a in artists:
--> 132         a.draw(renderer)
    133 else:
    134     # Composite any adjacent images together
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1388, in Axis.draw(self, renderer, *args, **kwargs)
   1385 renderer.open_group(__name__, gid=self.get_gid())
   1387 ticks_to_draw = self._update_ticks()
-> 1388 tlb1, tlb2 = self._get_ticklabel_bboxes(ticks_to_draw, renderer)
   1390 for tick in ticks_to_draw:
   1391     tick.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in Axis._get_ticklabel_bboxes(self, ticks, renderer)
   1313 if renderer is None:
   1314     renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
   1316          for tick in ticks if tick.label1.get_visible()],
   1317         [tick.label2.get_window_extent(renderer)
   1318          for tick in ticks if tick.label2.get_visible()])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/axis.py:1315, in <listcomp>(.0)
   1313 if renderer is None:
   1314     renderer = self.figure._get_renderer()
-> 1315 return ([tick.label1.get_window_extent(renderer)
   1316          for tick in ticks if tick.label1.get_visible()],
   1317         [tick.label2.get_window_extent(renderer)
   1318          for tick in ticks if tick.label2.get_visible()])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:956, in Text.get_window_extent(self, renderer, dpi)
    951     raise RuntimeError(
    952         "Cannot get window extent of text w/o renderer. You likely "
    953         "want to call 'figure.draw_without_rendering()' first.")
    955 with cbook._setattr_cm(self.figure, dpi=dpi):
--> 956     bbox, info, descent = self._get_layout(self._renderer)
    957     x, y = self.get_unitless_position()
    958     x, y = self.get_transform().transform((x, y))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
    370 ys = []
    372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
    374     renderer, "lp", self._fontproperties,
    375     ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
    376 min_dy = (lp_h - lp_d) * self._linespacing
    378 for i, line in enumerate(lines):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
     66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
     67 # Cached based on a copy of fontprop so that later in-place mutations of
     68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
     70     weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
     73 @functools.lru_cache(4096)
     74 def _get_text_metrics_with_cache_impl(
     75         renderer_ref, text, fontprop, ismath, dpi):
     76     # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77     return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
    211 _api.check_in_list(["TeX", True, False], ismath=ismath)
    212 if ismath == "TeX":
--> 213     return super().get_text_width_height_descent(s, prop, ismath)
    215 if ismath:
    216     ox, oy, width, height, descent, font_image = \
    217         self.mathtext_parser.parse(s, self.dpi, prop)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
    648 fontsize = prop.get_size_in_points()
    650 if ismath == 'TeX':
    651     # todo: handle properties
--> 652     return self.get_texmanager().get_text_width_height_descent(
    653         s, fontsize, renderer=self)
    655 dpi = self.points_to_pixels(72)
    656 if ismath:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
    364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
    365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366     page, = dvi
    367 # A total height (including the descent) needs to be returned.
    368 return page.width, page.height + page.descent, page.descent

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
    280 def __iter__(self):
    281     """
    282     Iterate through the pages of the file.
    283 
   (...)
    294         integers.
    295     """
--> 296     while self._read():
    297         yield self._output()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
    373 while True:
    374     byte = self.file.read(1)[0]
--> 375     self._dtable[byte](self, byte)
    376     name = self._dtable[byte].__name__
    377     if name == "_push":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
    225 if state is not None and self.state != state:
    226     raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
    524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
    525 def _fnt_def(self, k, c, s, d, a, l):
--> 526     self._fnt_def_real(k, c, s, d, a, l)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
    529 n = self.file.read(a + l)
    530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
    532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
    533     raise ValueError('tfm checksum mismatch: %s' % n)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
   1114 @lru_cache
   1115 def _fontfile(cls, suffix, texname):
-> 1116     return cls(find_tex_file(texname + suffix))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
   1079     filename = filename.decode('utf-8', errors='replace')
   1081 try:
-> 1082     lk = _LuatexKpsewhich()
   1083 except FileNotFoundError:
   1084     lk = None  # Fallback to directly calling kpsewhich, as below.

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
   1034 @lru_cache  # A singleton.
   1035 def __new__(cls):
   1036     self = object.__new__(cls)
-> 1037     self._proc = self._new_proc()
   1038     return self

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
   1040 def _new_proc(self):
-> 1041     return subprocess.Popen(
   1042         ["luatex", "--luaonly",
   1043          str(cbook._get_data_path("kpsewhich.lua"))],
   1044         stdin=subprocess.PIPE, stdout=subprocess.PIPE)

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
   1953     err_msg = os.strerror(errno_num)
   1954 if err_filename is not None:
-> 1955     raise child_exception_type(errno_num, err_msg, err_filename)
   1956 else:
   1957     raise child_exception_type(errno_num, err_msg)

PermissionError: [Errno 13] Permission denied: 'luatex'
<Figure size 2400x4800 with 1 Axes>

[E] If the company only has $5,000.00 in capital for the purposes of increasing production (and not the amount determined to meet demand in [D]), what allocation of overtime and additional material maximizes the company’s profit?#

Hide code cell source
display(Math(
  r"\begin{aligned}"
  r"\text{ROI}_\text{material}&="
  f"{ROI1}"
  r"&&\text{return on investment per dollar invested in material}"
  r"\\"
  r"\text{ROI}_\text{labor}&="
  f"{ROI2}"
  r"&&\text{return on investment per dollar invested in labor}"
  r"\\"
  r"\end{aligned}"
))
\[\begin{split}\displaystyle \begin{aligned}\text{ROI}_\text{material}&=0.11&&\text{return on investment per dollar invested in material}\\\text{ROI}_\text{labor}&=0.33&&\text{return on investment per dollar invested in labor}\\\end{aligned}\end{split}\]

Both purchasing additional material and scheduling overtime are profitable, but the limited budget constrains us to make certain considerations.

Scheduling overtime is more profitable than purchasing additional material since the return on its investment is higher.

Make the additional material purchased [db1=x3] and overtime schedule [db2=x4] new control variables.

\( \begin{aligned} g_i\le b_i+db_i &\iff g_i-db_i\le b_i \\ g_1\le b_1+db_1 &\iff g_1-db_1\le b_1 \implies g_1-x_3\le b_1 \\ g_2\le b_2+db_2 &\iff g_2-db_2\le b_2 \implies g_2-x_4\le b_2 \end{aligned} \)

\( \begin{aligned} \max z(\mathbf{x})&=500x_1+750x_2-(9.00x_3+22.50x_4) \\ g_1(\mathbf{x})&=20x_1+15x_2-x_3\le500=b_1 &&\text{material constraint} \\ g_2(\mathbf{x})&=10x_1+20x_2-x_4\le400=b_2 &&\text{labor constraint} \\ g_3(\mathbf{x})&=x_1\le25=b_3 &&\text{Type A valve demand constaint} \\ g_4(\mathbf{x})&=x_2\le20=b_4 &&\text{Type B valve demand constraint} \\ g_5(\mathbf{x})&=9.00x_3+22.50x_4\le5000=b_5 &&\text{budget constraint} \\ \mathbf{x}&\ge\mathbf{0} &&\text{no negative production} \end{aligned} \)

LP          A       B
max z = 500x1 + 750x2 - (9.00x3 + 22.50x4)
   g1 =  20x1 +  15x2 -     1x3 +     0x4  <=  500 = b1   material            constraint
   g2 =  10x1 +  20x2       0x3 -     1x4  <=  400 = b2   labor               constraint
   g3 =   1x1 +   0x2 +     0x3 +     0x4  <=   25 = b3   Type A valve demand constraint
   g4 =   0x1 +   1x2 +     0x3 +     0x4  <=   20 = b4   Type B valve demand constraint
   g5 =   0x1 +   0x2 +  9.00x3 + 22.50x4  <= 5000 = b5   budget              constraint
                                         x >= 0           no negative production
d =   0
b1= 500
b2= 400
b3=  25
b4=  20
b5=5000

z =500*x1+750*x2-9*x3-(45/2)*x4- d
g1= 20*x1+ 15*x2  -x3        -b1
g2= 10*x1+ 20*x2          -x4-b2
g3=  1*x1+  0*x2             -b3
g4=  0*x1+  1*x2             -b4
g5=              9*x3+(45/2)*x4-b5

db1=0
db2=0
db3=0
db4=0
db5=0
A=np.array([[20,15,-1,0],[10,20,0,-1],[1,0,0,0],[0,1,0,0],[0,0,9,(45/2)]])
b=np.array([500,400,25,20,5000])
c=np.array([500,750,-9,-(45/2)])
d=np.array([0])
x=np.array([x1,x2,x3,x4])

display(Math(
   r"\begin{aligned}"
  fr"  z&={latex( c@x+d [0])}\\"
  fr"g_1&={latex((A@x-b)[0])}\\"
  fr"g_2&={latex((A@x-b)[1])}\\"
  fr"g_3&={latex((A@x-b)[2])}\\"
  fr"g_4&={latex((A@x-b)[3])}\\"
  fr"g_5&={latex((A@x-b)[4])}\\"
   r"\end{aligned}"),
)
\[\begin{split}\displaystyle \begin{aligned} z&=500.0 x_{1} + 750.0 x_{2} - 9.0 x_{3} - 22.5 x_{4}\\g_1&=20.0 x_{1} + 15.0 x_{2} - 1.0 x_{3} - 500\\g_2&=10.0 x_{1} + 20.0 x_{2} - 1.0 x_{4} - 400\\g_3&=1.0 x_{1} - 25\\g_4&=1.0 x_{2} - 20\\g_5&=9.0 x_{3} + 22.5 x_{4} - 5000\\\end{aligned}\end{split}\]
Hide code cell source
# CONCISE ROW TABLEAU
rA = Matrix([
  [ 'c', 'x1', 'x2', 'x3',   'x4',      1, 'r'],
  ['y1',  -20,  -15,    1,      0, b1+db1,'s1'],
  ['y2',  -10,  -20,    0,      1, b2+db2,'s2'],
  ['y3',   -1,    0,    0,      0, b3+db3,'s3'],
  ['y4',    0,   -1,    0,      0, b4+db4,'s4'],
  ['y5',    0,    0,   -9,-(45/2), b5+db5,'s5'],
  [  -1, -500, -750,    9, (45/2),  -d[0],'-z'],
  [ 'c','-v1','-v2','-v3',  '-v4',    'w', 'r'],
])
rB = pivot(1,1,rA)
rC = pivot(2,2,rB)
rD = pivot(3,3,rC)
rE = pivot(5,4,rD)
rF = pivot(4,3,rE)

# CONCISE COLUMN TABLEAU
cA = Matrix([
  [ 'c',  'y1',  'y2',  'y3',  'y4',  'y5',     1, 'r'],
  ['x1',    20,    10,     1,     0,     0,  -500,'v1'],
  ['x2',    15,    20,     0,     1,     0,  -750,'v2'],
  ['x3',    -1,     0,     0,     0,     9,     9,'v3'],
  ['x4',     0,    -1,     0,     0,(45/2),(45/2),'v4'],
  [  -1,b1+db1,b2+db2,b3+db3,b4+db4,b5+db5,  d[0], 'w'],
  [ 'c', '-s1', '-s2', '-s3', '-s4', '-s5',  '-z', 'r'],
])
cB = pivot(1,1,cA)
cC = pivot(2,2,cB)
cD = pivot(3,3,cC)
cE = pivot(4,5,cD)
cF = pivot(3,4,cE)

display(Math(
   r'\begin{aligned}'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,rA = {latex(rA)}\,\,\,\,\,&&'
   r'\begin{aligned}&\text{START}\\&x_1=x_2=0\end{aligned}\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,rB = {latex(rB)}\,\,\,\,\,&&x_2=s_1=0\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,rC = {latex(rC)}\,\,\,\,\,&&s_1=s_2=0\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,rD = {latex(rD)}\,\,\,\,\,&&\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,rE = {latex(nsimplify(rE))}\,\,\,\,\,&&\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,rF = {latex(nsimplify(rF))}\,\,\,\,\,&&'
   r'\begin{aligned}&\text{OPTIMAL}\\&\end{aligned}\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,cA = {latex(cA)}\,\,\,\,\,&&'
   r'\begin{aligned}&\text{START}\\&x_1=x_2=0\end{aligned}\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,cB = {latex(cB)}\,\,\,\,\,&&x_2=s_1=0\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,cC = {latex(cC)}\,\,\,\,\,&&s_1=s_2=0\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,cD = {latex(cD)}\,\,\,\,\,&&\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,cE = {latex(nsimplify(cE))}\,\,\,\,\,&&\\'
  fr'db &= ({db1},{db2},{db3},{db4})\,\,\,cF = {latex(nsimplify(cF))}\,\,\,\,\,&&'
   r'\begin{aligned}&\text{OPTIMAL}\\&\end{aligned}\\'
   r'\end{aligned}'
))
\[\begin{split}\displaystyle \begin{aligned}db &= (0,0,0,0)\,\,\,rA = \left[\begin{matrix}c & x_{1} & x_{2} & x_{3} & x_{4} & 1 & r\\y_{1} & -20 & -15 & 1 & 0 & 500 & s_{1}\\y_{2} & -10 & -20 & 0 & 1 & 400 & s_{2}\\y_{3} & -1 & 0 & 0 & 0 & 25 & s_{3}\\y_{4} & 0 & -1 & 0 & 0 & 20 & s_{4}\\y_{5} & 0 & 0 & -9 & -22.5 & 5000 & s_{5}\\-1 & -500 & -750 & 9 & 22.5 & 0 & - z\\c & - v_{1} & - v_{2} & - v_{3} & - v_{4} & w & r\end{matrix}\right]\,\,\,\,\,&&\begin{aligned}&\text{START}\\&x_1=x_2=0\end{aligned}\\db &= (0,0,0,0)\,\,\,rB = \left[\begin{matrix}c & s_{1} & x_{2} & x_{3} & x_{4} & 1 & r\\v_{1} & - \frac{1}{20} & - \frac{3}{4} & \frac{1}{20} & 0 & 25 & x_{1}\\y_{2} & \frac{1}{2} & - \frac{25}{2} & - \frac{1}{2} & 1 & 150 & s_{2}\\y_{3} & \frac{1}{20} & \frac{3}{4} & - \frac{1}{20} & 0 & 0 & s_{3}\\y_{4} & 0 & -1 & 0 & 0 & 20 & s_{4}\\y_{5} & 0 & 0 & -9 & -22.5 & 5000 & s_{5}\\-1 & 25 & -375 & -16 & 22.5 & -12500 & - z\\c & - y_{1} & - v_{2} & - v_{3} & - v_{4} & w & r\end{matrix}\right]\,\,\,\,\,&&x_2=s_1=0\\db &= (0,0,0,0)\,\,\,rC = \left[\begin{matrix}c & s_{1} & s_{2} & x_{3} & x_{4} & 1 & r\\v_{1} & - \frac{2}{25} & \frac{3}{50} & \frac{2}{25} & - \frac{3}{50} & 16 & x_{1}\\v_{2} & \frac{1}{25} & - \frac{2}{25} & - \frac{1}{25} & \frac{2}{25} & 12 & x_{2}\\y_{3} & \frac{2}{25} & - \frac{3}{50} & - \frac{2}{25} & \frac{3}{50} & 9 & s_{3}\\y_{4} & - \frac{1}{25} & \frac{2}{25} & \frac{1}{25} & - \frac{2}{25} & 8 & s_{4}\\y_{5} & 0 & 0 & -9 & -22.5 & 5000 & s_{5}\\-1 & 10 & 30 & -1 & -7.5 & -17000 & - z\\c & - y_{1} & - y_{2} & - v_{3} & - v_{4} & w & r\end{matrix}\right]\,\,\,\,\,&&s_1=s_2=0\\db &= (0,0,0,0)\,\,\,rD = \left[\begin{matrix}c & s_{1} & s_{2} & s_{3} & x_{4} & 1 & r\\v_{1} & 0 & 0 & -1 & 0 & 25 & x_{1}\\v_{2} & 0 & - \frac{1}{20} & \frac{1}{2} & \frac{1}{20} & \frac{15}{2} & x_{2}\\v_{3} & 1 & - \frac{3}{4} & - \frac{25}{2} & \frac{3}{4} & \frac{225}{2} & x_{3}\\y_{4} & 0 & \frac{1}{20} & - \frac{1}{2} & - \frac{1}{20} & \frac{25}{2} & s_{4}\\y_{5} & -9 & \frac{27}{4} & \frac{225}{2} & -29.25 & \frac{7975}{2} & s_{5}\\-1 & 9 & \frac{123}{4} & \frac{25}{2} & -8.25 & - \frac{34225}{2} & - z\\c & - y_{1} & - y_{2} & - y_{3} & - v_{4} & w & r\end{matrix}\right]\,\,\,\,\,&&\\db &= (0,0,0,0)\,\,\,rE = \left[\begin{matrix}c & s_{1} & s_{2} & s_{3} & s_{5} & 1 & r\\v_{1} & 0 & 0 & -1 & 0 & 25 & x_{1}\\v_{2} & - \frac{1}{65} & - \frac{1}{26} & \frac{9}{13} & - \frac{1}{585} & \frac{143162393162393}{10000000000000} & x_{2}\\v_{3} & \frac{10}{13} & - \frac{15}{26} & - \frac{125}{13} & - \frac{1}{39} & \frac{21474358974359}{100000000000} & x_{3}\\y_{4} & \frac{1}{65} & \frac{1}{26} & - \frac{9}{13} & \frac{1}{585} & \frac{142094017094017}{25000000000000} & s_{4}\\v_{4} & - \frac{4}{13} & \frac{3}{13} & \frac{50}{13} & - \frac{4}{117} & \frac{68162393162393}{500000000000} & x_{4}\\-1 & \frac{150}{13} & \frac{375}{13} & - \frac{250}{13} & \frac{11}{39} & - \frac{36474358974359}{2000000000} & - z\\c & - y_{1} & - y_{2} & - y_{3} & - y_{5} & w & r\end{matrix}\right]\,\,\,\,\,&&\\db &= (0,0,0,0)\,\,\,rF = \left[\begin{matrix}c & s_{1} & s_{2} & s_{4} & s_{5} & 1 & r\\v_{1} & - \frac{1}{45} & - \frac{1}{18} & \frac{13}{9} & - \frac{1}{405} & \frac{167901234567901}{10000000000000} & x_{1}\\v_{2} & 0 & 0 & -1 & - \frac{216840434497101}{1000000000000000000000000000000000} & 20 & x_{2}\\v_{3} & \frac{5}{9} & - \frac{10}{9} & \frac{125}{9} & - \frac{4}{81} & \frac{67901234567901}{500000000000} & x_{3}\\y_{3} & \frac{1}{45} & \frac{1}{18} & - \frac{13}{9} & \frac{1}{405} & \frac{665}{81} & s_{3}\\v_{4} & - \frac{2}{9} & \frac{4}{9} & - \frac{50}{9} & - \frac{2}{81} & \frac{167901234567901}{1000000000000} & x_{4}\\-1 & \frac{100}{9} & \frac{250}{9} & \frac{250}{9} & \frac{19}{81} & - \frac{183950617283951}{10000000000} & - z\\c & - y_{1} & - y_{2} & - y_{4} & - y_{5} & w & r\end{matrix}\right]\,\,\,\,\,&&\begin{aligned}&\text{OPTIMAL}\\&\end{aligned}\\db &= (0,0,0,0)\,\,\,cA = \left[\begin{matrix}c & y_{1} & y_{2} & y_{3} & y_{4} & y_{5} & 1 & r\\x_{1} & 20 & 10 & 1 & 0 & 0 & -500 & v_{1}\\x_{2} & 15 & 20 & 0 & 1 & 0 & -750 & v_{2}\\x_{3} & -1 & 0 & 0 & 0 & 9 & 9 & v_{3}\\x_{4} & 0 & -1 & 0 & 0 & 22.5 & 22.5 & v_{4}\\-1 & 500 & 400 & 25 & 20 & 5000 & 0 & w\\c & - s_{1} & - s_{2} & - s_{3} & - s_{4} & - s_{5} & - z & r\end{matrix}\right]\,\,\,\,\,&&\begin{aligned}&\text{START}\\&x_1=x_2=0\end{aligned}\\db &= (0,0,0,0)\,\,\,cB = \left[\begin{matrix}c & v_{1} & y_{2} & y_{3} & y_{4} & y_{5} & 1 & r\\s_{1} & \frac{1}{20} & - \frac{1}{2} & - \frac{1}{20} & 0 & 0 & 25 & y_{1}\\x_{2} & \frac{3}{4} & \frac{25}{2} & - \frac{3}{4} & 1 & 0 & -375 & v_{2}\\x_{3} & - \frac{1}{20} & \frac{1}{2} & \frac{1}{20} & 0 & 9 & -16 & v_{3}\\x_{4} & 0 & -1 & 0 & 0 & 22.5 & 22.5 & v_{4}\\-1 & 25 & 150 & 0 & 20 & 5000 & 12500 & w\\c & - x_{1} & - s_{2} & - s_{3} & - s_{4} & - s_{5} & - z & r\end{matrix}\right]\,\,\,\,\,&&x_2=s_1=0\\db &= (0,0,0,0)\,\,\,cC = \left[\begin{matrix}c & v_{1} & v_{2} & y_{3} & y_{4} & y_{5} & 1 & r\\s_{1} & \frac{2}{25} & - \frac{1}{25} & - \frac{2}{25} & \frac{1}{25} & 0 & 10 & y_{1}\\s_{2} & - \frac{3}{50} & \frac{2}{25} & \frac{3}{50} & - \frac{2}{25} & 0 & 30 & y_{2}\\x_{3} & - \frac{2}{25} & \frac{1}{25} & \frac{2}{25} & - \frac{1}{25} & 9 & -1 & v_{3}\\x_{4} & \frac{3}{50} & - \frac{2}{25} & - \frac{3}{50} & \frac{2}{25} & 22.5 & -7.5 & v_{4}\\-1 & 16 & 12 & 9 & 8 & 5000 & 17000 & w\\c & - x_{1} & - x_{2} & - s_{3} & - s_{4} & - s_{5} & - z & r\end{matrix}\right]\,\,\,\,\,&&s_1=s_2=0\\db &= (0,0,0,0)\,\,\,cD = \left[\begin{matrix}c & v_{1} & v_{2} & v_{3} & y_{4} & y_{5} & 1 & r\\s_{1} & 0 & 0 & -1 & 0 & 9 & 9 & y_{1}\\s_{2} & 0 & \frac{1}{20} & \frac{3}{4} & - \frac{1}{20} & - \frac{27}{4} & \frac{123}{4} & y_{2}\\s_{3} & 1 & - \frac{1}{2} & \frac{25}{2} & \frac{1}{2} & - \frac{225}{2} & \frac{25}{2} & y_{3}\\x_{4} & 0 & - \frac{1}{20} & - \frac{3}{4} & \frac{1}{20} & 29.25 & -8.25 & v_{4}\\-1 & 25 & \frac{15}{2} & \frac{225}{2} & \frac{25}{2} & \frac{7975}{2} & \frac{34225}{2} & w\\c & - x_{1} & - x_{2} & - x_{3} & - s_{4} & - s_{5} & - z & r\end{matrix}\right]\,\,\,\,\,&&\\db &= (0,0,0,0)\,\,\,cE = \left[\begin{matrix}c & v_{1} & v_{2} & v_{3} & y_{4} & v_{4} & 1 & r\\s_{1} & 0 & \frac{1}{65} & - \frac{10}{13} & - \frac{1}{65} & \frac{4}{13} & \frac{150}{13} & y_{1}\\s_{2} & 0 & \frac{1}{26} & \frac{15}{26} & - \frac{1}{26} & - \frac{3}{13} & \frac{375}{13} & y_{2}\\s_{3} & 1 & - \frac{9}{13} & \frac{125}{13} & \frac{9}{13} & - \frac{50}{13} & - \frac{250}{13} & y_{3}\\s_{5} & 0 & \frac{1}{585} & \frac{1}{39} & - \frac{1}{585} & \frac{4}{117} & \frac{11}{39} & y_{5}\\-1 & 25 & \frac{143162393162393}{10000000000000} & \frac{21474358974359}{100000000000} & \frac{142094017094017}{25000000000000} & \frac{68162393162393}{500000000000} & \frac{36474358974359}{2000000000} & w\\c & - x_{1} & - x_{2} & - x_{3} & - s_{4} & - x_{4} & - z & r\end{matrix}\right]\,\,\,\,\,&&\\db &= (0,0,0,0)\,\,\,cF = \left[\begin{matrix}c & v_{1} & v_{2} & v_{3} & y_{3} & v_{4} & 1 & r\\s_{1} & \frac{1}{45} & 0 & - \frac{5}{9} & - \frac{1}{45} & \frac{2}{9} & \frac{100}{9} & y_{1}\\s_{2} & \frac{1}{18} & 0 & \frac{10}{9} & - \frac{1}{18} & - \frac{4}{9} & \frac{250}{9} & y_{2}\\s_{4} & - \frac{13}{9} & 1 & - \frac{125}{9} & \frac{13}{9} & \frac{50}{9} & \frac{250}{9} & y_{4}\\s_{5} & \frac{1}{405} & \frac{216840434497101}{1000000000000000000000000000000000} & \frac{4}{81} & - \frac{1}{405} & \frac{2}{81} & \frac{19}{81} & y_{5}\\-1 & \frac{167901234567901}{10000000000000} & 20 & \frac{67901234567901}{500000000000} & \frac{665}{81} & \frac{167901234567901}{1000000000000} & \frac{183950617283951}{10000000000} & w\\c & - x_{1} & - x_{2} & - x_{3} & - s_{3} & - x_{4} & - z & r\end{matrix}\right]\,\,\,\,\,&&\begin{aligned}&\text{OPTIMAL}\\&\end{aligned}\\\end{aligned}\end{split}\]
cF[-2,-2]
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:178, in _init_ipython_printing.<locals>._print_latex_png(o)
    177 try:
--> 178     return _preview_wrapper(s)
    179 except RuntimeError as e:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:89, in _init_ipython_printing.<locals>._preview_wrapper(o)
     88 try:
---> 89     preview(o, output='png', viewer='BytesIO', euler=euler,
     90             outputbuffer=exprbuffer, extra_preamble=extra_preamble,
     91             dvioptions=dvioptions, fontsize=fontsize)
     92 except Exception as e:
     93     # IPython swallows exceptions

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/printing/preview.py:308, in preview(expr, output, viewer, euler, packages, filename, outputbuffer, preamble, dvioptions, outputTexFile, extra_preamble, fontsize, **latex_settings)
    307 if not shutil.which('latex'):
--> 308     raise RuntimeError("latex program is not installed")
    310 try:

RuntimeError: latex program is not installed

During handling of the above exception, another exception occurred:

PermissionError                           Traceback (most recent call last)
File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/core/formatters.py:347, in BaseFormatter.__call__(self, obj)
    345     method = get_real_method(obj, self.print_method)
    346     if method is not None:
--> 347         return method()
    348     return None
    349 else:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:184, in _init_ipython_printing.<locals>._print_latex_png(o)
    182 if latex_mode != 'inline':
    183     s = latex(o, mode='inline', **settings)
--> 184 return _matplotlib_wrapper(s)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/sympy/interactive/printing.py:118, in _init_ipython_printing.<locals>._matplotlib_wrapper(o)
    116 try:
    117     try:
--> 118         return latex_to_png(o, color=forecolor, scale=scale)
    119     except TypeError: #  Old IPython version without color and scale
    120         return latex_to_png(o)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:105, in latex_to_png(s, encode, backend, wrap, color, scale)
    103 else:
    104     raise ValueError('No such backend {0}'.format(backend))
--> 105 bin_data = f(s, wrap, color, scale)
    106 if encode and bin_data:
    107     bin_data = encodebytes(bin_data)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/IPython/lib/latextools.py:135, in latex_to_png_mpl(s, wrap, color, scale)
    133     fig.text(0, depth / height, s, fontproperties=prop, color=color)
    134     backend_agg.FigureCanvasAgg(fig)
--> 135     fig.savefig(buffer, dpi=dpi, format="png", transparent=True)
    136     return buffer.getvalue()
    137 except (ValueError, RuntimeError, ParseFatalException):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3390, in Figure.savefig(self, fname, transparent, **kwargs)
   3388     for ax in self.axes:
   3389         _recursively_make_axes_transparent(stack, ax)
-> 3390 self.canvas.print_figure(fname, **kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
   2189 try:
   2190     # _get_renderer may change the figure dpi (as vector formats
   2191     # force the figure dpi to 72), so we need to set it again here.
   2192     with cbook._setattr_cm(self.figure, dpi=dpi):
-> 2193         result = print_method(
   2194             filename,
   2195             facecolor=facecolor,
   2196             edgecolor=edgecolor,
   2197             orientation=orientation,
   2198             bbox_inches_restore=_bbox_inches_restore,
   2199             **kwargs)
   2200 finally:
   2201     if bbox_inches and restore_bbox:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
   2039     optional_kws = {  # Passed by print_figure for other renderers.
   2040         "dpi", "facecolor", "edgecolor", "orientation",
   2041         "bbox_inches_restore"}
   2042     skip = optional_kws - {*inspect.signature(meth).parameters}
-> 2043     print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
   2044         *args, **{k: v for k, v in kwargs.items() if k not in skip}))
   2045 else:  # Let third-parties do as they see fit.
   2046     print_method = meth

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
    450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
    451     """
    452     Write the figure to a PNG file.
    453 
   (...)
    495         *metadata*, including the default 'Software' key.
    496     """
--> 497     self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
    440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
    441     """
    442     Draw the canvas, then save it using `.image.imsave` (to which
    443     *pil_kwargs* and *metadata* are forwarded).
    444     """
--> 445     FigureCanvasAgg.draw(self)
    446     mpl.image.imsave(
    447         filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper",
    448         dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:388, in FigureCanvasAgg.draw(self)
    385 # Acquire a lock on the shared font cache.
    386 with (self.toolbar._wait_cursor_for_draw_cm() if self.toolbar
    387       else nullcontext()):
--> 388     self.figure.draw(self.renderer)
    389     # A GUI class may be need to update a window using this draw, so
    390     # don't forget to call the superclass.
    391     super().draw()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:95, in _finalize_rasterization.<locals>.draw_wrapper(artist, renderer, *args, **kwargs)
     93 @wraps(draw)
     94 def draw_wrapper(artist, renderer, *args, **kwargs):
---> 95     result = draw(artist, renderer, *args, **kwargs)
     96     if renderer._rasterizing:
     97         renderer.stop_rasterizing()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/figure.py:3154, in Figure.draw(self, renderer)
   3151         # ValueError can occur when resizing a window.
   3153 self.patch.draw(renderer)
-> 3154 mimage._draw_list_compositing_images(
   3155     renderer, self, artists, self.suppressComposite)
   3157 for sfig in self.subfigs:
   3158     sfig.draw(renderer)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/image.py:132, in _draw_list_compositing_images(renderer, parent, artists, suppress_composite)
    130 if not_composite or not has_images:
    131     for a in artists:
--> 132         a.draw(renderer)
    133 else:
    134     # Composite any adjacent images together
    135     image_group = []

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/artist.py:72, in allow_rasterization.<locals>.draw_wrapper(artist, renderer)
     69     if artist.get_agg_filter() is not None:
     70         renderer.start_filter()
---> 72     return draw(artist, renderer)
     73 finally:
     74     if artist.get_agg_filter() is not None:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:748, in Text.draw(self, renderer)
    745 renderer.open_group('text', self.get_gid())
    747 with self._cm_set(text=self._get_wrapped_text()):
--> 748     bbox, info, descent = self._get_layout(renderer)
    749     trans = self.get_transform()
    751     # don't use self.get_position here, which refers to text
    752     # position in Text:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:373, in Text._get_layout(self, renderer)
    370 ys = []
    372 # Full vertical extent of font, including ascenders and descenders:
--> 373 _, lp_h, lp_d = _get_text_metrics_with_cache(
    374     renderer, "lp", self._fontproperties,
    375     ismath="TeX" if self.get_usetex() else False, dpi=self.figure.dpi)
    376 min_dy = (lp_h - lp_d) * self._linespacing
    378 for i, line in enumerate(lines):

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:69, in _get_text_metrics_with_cache(renderer, text, fontprop, ismath, dpi)
     66 """Call ``renderer.get_text_width_height_descent``, caching the results."""
     67 # Cached based on a copy of fontprop so that later in-place mutations of
     68 # the passed-in argument do not mess up the cache.
---> 69 return _get_text_metrics_with_cache_impl(
     70     weakref.ref(renderer), text, fontprop.copy(), ismath, dpi)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/text.py:77, in _get_text_metrics_with_cache_impl(renderer_ref, text, fontprop, ismath, dpi)
     73 @functools.lru_cache(4096)
     74 def _get_text_metrics_with_cache_impl(
     75         renderer_ref, text, fontprop, ismath, dpi):
     76     # dpi is unused, but participates in cache invalidation (via the renderer).
---> 77     return renderer_ref().get_text_width_height_descent(text, fontprop, ismath)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:213, in RendererAgg.get_text_width_height_descent(self, s, prop, ismath)
    211 _api.check_in_list(["TeX", True, False], ismath=ismath)
    212 if ismath == "TeX":
--> 213     return super().get_text_width_height_descent(s, prop, ismath)
    215 if ismath:
    216     ox, oy, width, height, descent, font_image = \
    217         self.mathtext_parser.parse(s, self.dpi, prop)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/backend_bases.py:652, in RendererBase.get_text_width_height_descent(self, s, prop, ismath)
    648 fontsize = prop.get_size_in_points()
    650 if ismath == 'TeX':
    651     # todo: handle properties
--> 652     return self.get_texmanager().get_text_width_height_descent(
    653         s, fontsize, renderer=self)
    655 dpi = self.points_to_pixels(72)
    656 if ismath:

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/texmanager.py:366, in TexManager.get_text_width_height_descent(cls, tex, fontsize, renderer)
    364 dpi_fraction = renderer.points_to_pixels(1.) if renderer else 1
    365 with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
--> 366     page, = dvi
    367 # A total height (including the descent) needs to be returned.
    368 return page.width, page.height + page.descent, page.descent

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:296, in Dvi.__iter__(self)
    280 def __iter__(self):
    281     """
    282     Iterate through the pages of the file.
    283 
   (...)
    294         integers.
    295     """
--> 296     while self._read():
    297         yield self._output()

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:375, in Dvi._read(self)
    373 while True:
    374     byte = self.file.read(1)[0]
--> 375     self._dtable[byte](self, byte)
    376     name = self._dtable[byte].__name__
    377     if name == "_push":

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:227, in _dispatch.<locals>.decorate.<locals>.wrapper(self, byte)
    225 if state is not None and self.state != state:
    226     raise ValueError("state precondition failed")
--> 227 return method(self, *[f(self, byte-min) for f in get_args])

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:526, in Dvi._fnt_def(self, k, c, s, d, a, l)
    524 @_dispatch(min=243, max=246, args=('olen1', 'u4', 'u4', 'u4', 'u1', 'u1'))
    525 def _fnt_def(self, k, c, s, d, a, l):
--> 526     self._fnt_def_real(k, c, s, d, a, l)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:531, in Dvi._fnt_def_real(self, k, c, s, d, a, l)
    529 n = self.file.read(a + l)
    530 fontname = n[-l:].decode('ascii')
--> 531 tfm = _tfmfile(fontname)
    532 if c != 0 and tfm.checksum != 0 and c != tfm.checksum:
    533     raise ValueError('tfm checksum mismatch: %s' % n)

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1116, in _fontfile(cls, suffix, texname)
   1114 @lru_cache
   1115 def _fontfile(cls, suffix, texname):
-> 1116     return cls(find_tex_file(texname + suffix))

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1082, in find_tex_file(filename)
   1079     filename = filename.decode('utf-8', errors='replace')
   1081 try:
-> 1082     lk = _LuatexKpsewhich()
   1083 except FileNotFoundError:
   1084     lk = None  # Fallback to directly calling kpsewhich, as below.

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1037, in _LuatexKpsewhich.__new__(cls)
   1034 @lru_cache  # A singleton.
   1035 def __new__(cls):
   1036     self = object.__new__(cls)
-> 1037     self._proc = self._new_proc()
   1038     return self

File ~/anaconda3/envs/ml/lib/python3.11/site-packages/matplotlib/dviread.py:1041, in _LuatexKpsewhich._new_proc(self)
   1040 def _new_proc(self):
-> 1041     return subprocess.Popen(
   1042         ["luatex", "--luaonly",
   1043          str(cbook._get_data_path("kpsewhich.lua"))],
   1044         stdin=subprocess.PIPE, stdout=subprocess.PIPE)

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1026, in Popen.__init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, user, group, extra_groups, encoding, errors, text, umask, pipesize, process_group)
   1022         if self.text_mode:
   1023             self.stderr = io.TextIOWrapper(self.stderr,
   1024                     encoding=encoding, errors=errors)
-> 1026     self._execute_child(args, executable, preexec_fn, close_fds,
   1027                         pass_fds, cwd, env,
   1028                         startupinfo, creationflags, shell,
   1029                         p2cread, p2cwrite,
   1030                         c2pread, c2pwrite,
   1031                         errread, errwrite,
   1032                         restore_signals,
   1033                         gid, gids, uid, umask,
   1034                         start_new_session, process_group)
   1035 except:
   1036     # Cleanup if the child failed starting.
   1037     for f in filter(None, (self.stdin, self.stdout, self.stderr)):

File ~/anaconda3/envs/ml/lib/python3.11/subprocess.py:1955, in Popen._execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, gid, gids, uid, umask, start_new_session, process_group)
   1953     err_msg = os.strerror(errno_num)
   1954 if err_filename is not None:
-> 1955     raise child_exception_type(errno_num, err_msg, err_filename)
   1956 else:
   1957     raise child_exception_type(errno_num, err_msg)

PermissionError: [Errno 13] Permission denied: 'luatex'
\[\displaystyle 18395.0617283951\]