Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Unbrackable blanck

In the following code I am obliged to insert / to inside my fonction to obtain the desired result.

nl=3 #nombre de contraintes
nc=4  #nombre de variables
ring=QQ
A=matrix(ring,nl,nc,[1.5,2,4,3,4,1,2,1,2,3,1,2])
b=vector(ring,[550,700,200])
c=vector(ring,[4,6,3,1]) 

### code ####
def simplex_tableau_sf(A, b, c,cond=1) :
    # A matrice des contraintes
    # b vecteur des contraintes
    # c vecteur des paramètres de l'objectif
    # 1 (défaut) tableau

    I=identity_matrix(A.nrows())
    L=block_matrix([[A,I]],subdivide=False)
    L=L.augment(b)
    n=A.nrows()
    m=A.ncols()
    z1=vector([0 for i in range(n+1)])
    c=flatten(-c)
    z1=flatten(z1)
    zc=vector(c+z1)
    L=matrix(L.rows()+[zc])
    rows = list(L)
    hr=['$x_{}$'.format(i) for i in range(0,nc+nl)]
    #hc=hr[nl+1:]+list('z')
    hr=list('')+list(hr)+list('b')
    #hc=['','$\\epsilon_1$','$\\epsilon_2$','$\\epsilon_3$','z']
    hc=list('xc2')+['$x_{}$'.format(i) for i in range(4,7)]
    t = table(rows, header_row=hr, header_column=hc, frame=True)
    if cond == 1 :
        return t
    elif cond != 1 :
        return L

So is there a blank which can be used as a string

Unbrackable blanck

In the following code I am obliged to insert / to inside my fonction to obtain the desired result.

nl=3 #nombre de contraintes
nc=4  #nombre de variables
ring=QQ
A=matrix(ring,nl,nc,[1.5,2,4,3,4,1,2,1,2,3,1,2])
b=vector(ring,[550,700,200])
c=vector(ring,[4,6,3,1]) 

### code ####
def simplex_tableau_sf(A, b, c,cond=1) :
    # A matrice des contraintes
    # b vecteur des contraintes
    # c vecteur des paramètres de l'objectif
    # 1 (défaut) tableau

    I=identity_matrix(A.nrows())
    L=block_matrix([[A,I]],subdivide=False)
    L=L.augment(b)
    n=A.nrows()
    m=A.ncols()
    z1=vector([0 for i in range(n+1)])
    c=flatten(-c)
    z1=flatten(z1)
    zc=vector(c+z1)
    L=matrix(L.rows()+[zc])
    rows = list(L)
    hr=['$x_{}$'.format(i) for i in range(0,nc+nl)]
    #hc=hr[nl+1:]+list('z')
    hr=list('')+list(hr)+list('b')
    #hc=['','$\\epsilon_1$','$\\epsilon_2$','$\\epsilon_3$','z']
    hc=list('xc2')+['$x_{}$'.format(i) for i in range(4,7)]
    t = table(rows, header_row=hr, header_column=hc, frame=True)
    if cond == 1 :
        return t
    elif cond != 1 :
        return L

So is there a blank which can be used as a string