LP displayed objective two long for one line

asked 2022-08-12 12:07:07 +0200

Cyrille gravatar image

updated 2022-08-12 12:07:28 +0200

No problems with the following code up to the fact that I would like the objective displayed on two lines (else it is not complete on my computer). Is there a trick ?

 %display latex
m=10 #nombre de contraintes
n=18 #nombre de variables
c=matrix(1,n,(5,2,7,10,3,5,7,3,2,7,6,2,9,8,8,9,6,2)) 
ptb = MixedIntegerLinearProgram(maximization=False, solver = "GLPK") # Création du MILP
# on peut remplacer GLPK par PPL pour obtenir une optimisation fractionnaire.
x = ptb.new_variable(real=True, nonnegative=True, indices=[0..n-1])# les nouvelles variables seront x[0]... x[17]
ptb.add_constraint(x[0] + x[1] + x[2] <= 320)
ptb.add_constraint(x[3] + x[4] + x[5] <= 500)
ptb.add_constraint(x[6] + x[10] + x[14] <= 220)
ptb.add_constraint(x[7] + x[11] + x[15] <= 100)
ptb.add_constraint(x[8] + x[12] + x[16] <= 300)
ptb.add_constraint(x[9] + x[13] + x[17] <= 200)
ptb.add_constraint(x[0] + x[3] - x[6] - x[7] - x[8] - x[9] == 0)
ptb.add_constraint(x[1] + x[4] - x[10] - x[11] - x[12] - x[13] == 0)
ptb.add_constraint(x[2] + x[5] - x[14] - x[15] - x[16] - x[17] == 0)
Z=sum(c[0][i]*x[i] for i in range(len(c[0])))
ptb.set_objective(Z)# définition de l'objectif    
ptb.show() # Vérification
edit retag flag offensive close merge delete

Comments

I can not reproduce your problem (on Sage 9.7.beta8): both on the command line and in jupyter, the objective is displayed in two ot three lines. Could you please be more precise on your issue and show us a picture ?

tmonteil gravatar imagetmonteil ( 2022-08-12 12:12:14 +0200 )edit