# Obtaining linear relaxation objective value from MILP model coded in Pyomo

I would like to seek some advice on modeling the following:

I am currently using Pyomo to generate my MILP model in Pyomo. It seems that it is not possible to cast the integer and binary variables to continuous variables for solving the model as a linear program for obtaining its linear relaxation.

Short of creating a similar model for linear relaxation due to model loading and solution time constraints, I would like to ask if there is any way to invoke the solver from Pyomo to solve the said model as a Linear Program?

Something like :

def my_model(model, continuous):

...

if continuous:
model.my_variable = Var(within=NonNegativeReals)
else:
model.my_variable = Var(within=PositiveIntegers)

...


and then model.solve().

I am not so familiar with Pyomo but with PuLP, depending on the solver that you are using, you can add a parameter mip=True/False which should do the trick. Perhaps it is possible to do the same with Pyomo ? In this case you wouldn't have to rebuild the model.

• Hi, I thought of doing so, but that would entail rebuilding up the model again after obtaining the linear relaxation, which would result in time overheads. Thanks – Mike Apr 23 at 12:27
• Hi, I am afraid not, cos I am unable to locate any literature that mentions anything along this line of thought. Thanks. – Mike Apr 23 at 12:58
• Are you sure ?pyomo.readthedocs.io/en/stable/working_abstractmodels/… – Kuifje Apr 23 at 13:00
• Hi, I do not see any mention of linear relaxation, or anything with regards to passing a flag to the solver to indicate the use of it. Thanks – Mike Apr 23 at 13:13
• Try pyomo solve --solver=cplex --solver-options="mip=False" – Kuifje Apr 23 at 13:16