Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

MixedIntegerLinearProgram strange behavior

I find missleading the following comportment

%display latex p = MixedIntegerLinearProgram(maximization=False, solver = "GLPK") w = p.new_variable(integer=True, nonnegative=True) p.add_constraint(w[0] + w[1] + w[2] - 14w[3] == 1) p.add_constraint(w[1] + 2w[2] - 8w[3] == 0) p.add_constraint(2w[2] - 3w[3] == 0) p.add_constraint(w[0] - w[1] - w[2] >= 0) p.add_constraint(w[3] >= 1) p.set_objective(w[2]+ 2w[3]) p.show()

Which gives the program in x[i] terms not in w[i]'s because later when I need the optimal value of the variables through the command

val=p.get_values(w or x)? Is there a way to have the resulting programs written in x and written in Latex ?

MixedIntegerLinearProgram strange behavior

This is a reedit of the initial question

I find missleading the following comportment

comportment (I have add name="w") according the suggestion of dsejas

%display latex latex p = MixedIntegerLinearProgram(maximization=False, = MixedIntegerLinearProgram(maximization=False, solver = "GLPK") "GLPK") w = p.new_variable(integer=True, nonnegative=True) = p.new_variable(integer=True, nonnegative=True,name="w") p.add_constraint(w[0] + w[1] + w[2] - - 14w[3] == 1) 1) p.add_constraint(w[1] + + 2w[2] - 8w[3] == 0) p.add_constraint(2w[2] - 3w[3] == 0) p.add_constraint(w[0] - w[1] - w[2] >= 0) >= 0) p.add_constraint(w[3] >= 1) p.set_objective(w[2]+ 25w[3]) w[3]) p.show()

but look at what is shown. The $x_i$'s are in the display. Then I have typpeset :

b = p.get_backend() b.solver_parameter("simplex_or_intopt", "simplex_only") b.solver_parameter("verbosity_simplex", "GLP_MSG_ALL") ans = p.solve() ans

Which gives the program in x[i] terms followed by

val=p.get_values(w) val

and finally

val0=p.get_values(w[2]) val0

Look at w[2]'s value. It is not in w[i]'s because later when I need the optimal value of the variables through the command

val=p.get_values(w or x)? Is there a way to have the resulting programs written in x and written in Latex ?an integer value.

MixedIntegerLinearProgram strange behavior

This is a reedit reedition of the my initial question

I find missleading the following comportment (I have add name="w") according the suggestion of dsejas

%display latex p = MixedIntegerLinearProgram(maximization=False, solver = "GLPK") w = p.new_variable(integer=True, nonnegative=True,name="w") p.add_constraint(w[0] + w[1] + w[2] - 14w[3] == 1) p.add_constraint(w[1] + 2w[2] - 8w[3] == 0) p.add_constraint(2w[2] - 3w[3] == 0) p.add_constraint(w[0] - w[1] - w[2] >= 0) p.add_constraint(w[3] >= 1) p.set_objective(w[2]+ 5w[3]) p.show()

but look at what is shown. The $x_i$'s are in the display. Then I have typpeset :

b = p.get_backend() b.solver_parameter("simplex_or_intopt", "simplex_only") b.solver_parameter("verbosity_simplex", "GLP_MSG_ALL") ans = p.solve() ans

followed by

val=p.get_values(w) val

and finally

val0=p.get_values(w[2]) val0

Look at w[2]'s value. It is not an integer value.

MixedIntegerLinearProgram strange behavior

This is a reedition of my initial question

I find missleading the following comportment (I have add name="w") according the suggestion of dsejas

%display latex latex p = MixedIntegerLinearProgram(maximization=False, =

MixedIntegerLinearProgram(maximization=False,

solver = "GLPK") "GLPK")

w = p.new_variable(integer=True, nonnegative=True,name="w") p.new_variable(integer=True,

nonnegative=True,name="w")

p.add_constraint(w[0] + w[1] + w[2] - 14w[3] - 14*w[3] == 1) 1)

p.add_constraint(w[1] + 2w[2] - 8w[2] - 8w[3] == 0) 0)

p.add_constraint(2w[2] - 3w[3] == 0) 0)

p.add_constraint(w[0] - w[1] - w[2] >= 0) >= 0)

p.add_constraint(w[3] >= 1) 1)

p.set_objective(w[2]+ 5w[3]) 5*w[3])

p.show()

but look at what is shown. The $x_i$'s are in the display. Then I have typpeset :

b = p.get_backend() p.get_backend()

b.solver_parameter("simplex_or_intopt", "simplex_only") "simplex_only")

b.solver_parameter("verbosity_simplex", "GLP_MSG_ALL") "GLP_MSG_ALL")

ans = p.solve() p.solve()

ans

followed by

val=p.get_values(w) val=p.get_values(w)

val

and finally

val0=p.get_values(w[2]) val0=p.get_values(w[2])

val0

Look at w[2]'s value. It is not an integer value.

click to hide/show revision 5
retagged

MixedIntegerLinearProgram strange behavior

This is a reedition of my initial question

I find missleading the following comportment (I have add name="w") according the suggestion of dsejas

%display latex p =

MixedIntegerLinearProgram(maximization=False,

solver = "GLPK")

w = p.new_variable(integer=True,

nonnegative=True,name="w")

p.add_constraint(w[0] + w[1] + w[2] - 14*w[3] == 1)

p.add_constraint(w[1] + 2w[2] - 8w[3] == 0)

p.add_constraint(2w[2] - 3w[3] == 0)

p.add_constraint(w[0] - w[1] - w[2] >= 0)

p.add_constraint(w[3] >= 1)

p.set_objective(w[2]+ 5*w[3])

p.show()

but look at what is shown. The $x_i$'s are in the display. Then I have typpeset :

b = p.get_backend()

b.solver_parameter("simplex_or_intopt", "simplex_only")

b.solver_parameter("verbosity_simplex", "GLP_MSG_ALL")

ans = p.solve()

ans

followed by

val=p.get_values(w)

val

and finally

val0=p.get_values(w[2])

val0

Look at w[2]'s value. It is not an integer value.