A question of presentation
Here is a code which works as expected
nl=3
nc=2
ring=QQ
A=matrix(ring,nl,nc,[3,2,1,4,1,1])
b=vector(ring,[3,5,6])
c=vector(ring,[4,7])
sign=list([">=",">=","<="])
vsign=list([">=",">="])
show(LatexExpr(r"\boldsymbol{A}="),A)
show(LatexExpr(r"\boldsymbol{b}="),b)
show(LatexExpr(r"\boldsymbol{c}="),c)
show(LatexExpr(r"\boldsymbol{Signs}="),sign)
show(LatexExpr(r"\boldsymbol{Vsigns}="),vsign)
def primal_lp(opt,A,b,c,signAb,signx):
nc=A.ncols()
x = var("x_", n=nc)
X=[xj for xj in x]
Zer1 =[0 for v in x]
Zer2 =[0 for v in range(len(signAb))]
con=A*vector(X)
z=c*vector(X)
from _operator import le, ge, eq
op1=[ge if v==">=" else (le if v=='<=' else eq) for v in signx]
tt1=list(map(lambda u,v:u(*v), op1 ,zip(X,Zer1)))
op2=[ge if v==">=" else (le if v=='<=' else eq) for v in signAb]
tt2=list(map(lambda u,v:u(*v), op1 ,zip(con,Zer2)))
z1=flatten([opt,z,tt2,tt1])
return show(z1)
primal_lp('max',A,b,c,sign,vsign)
I would like to present the results like
max4x0+7x1
3x0+2x1≥0
x0+4x1≤0
x0+x1=0
x0≥0
x1≤0
I have tried to use table
but I haven't found any way to obtain the desired representation. Any idea ?