Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

how to limit the verbosity in case of error

The following problem has no solution. But, often, I need only the last line of the Sagemath comments to debug the problem. I have tried use set_verbose() but it doesn't change any thing.

%display latex
m=3 #nombre de contraintes
n=2 # nombre de variables
A=matrix(m,n,(0,1,1,0,6,18))
bmin=[12,0,70]
bmax=[oo,10,70]
c=matrix(1,n,(4.1,8)) 
p = MixedIntegerLinearProgram(maximization=False, solver = "GLPK") # Création du MILP
# on peut remplacer GLPK par PPL pour obtenir une optimisation fractionnaire.
x = p.new_variable(integer=False, indices=[0..n-1]) # les nouvelles variables seront x[1]... x[7]}
B = A * x # m
# Construction des contraintes
for i in range(m):
    p.add_constraint(B[i], min=bmin[i], max=bmax[i])
    # remove_constraint() pour en retirer une
for i in range(n):
    p.set_min(x[i],0)
p.set_objective(4.1*x[0]+8*x[1])# définition de l'objectif    
sol=p.solve()
show(sol)