3
$\begingroup$

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?

$\endgroup$
2
$\begingroup$

Can't you add a parameter to your model which defines the nature of your variables ?

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.

$\endgroup$
10
  • $\begingroup$ 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 $\endgroup$
    – Mike
    Apr 23 at 12:27
  • $\begingroup$ Hi, I am afraid not, cos I am unable to locate any literature that mentions anything along this line of thought. Thanks. $\endgroup$
    – Mike
    Apr 23 at 12:58
  • $\begingroup$ Are you sure ?pyomo.readthedocs.io/en/stable/working_abstractmodels/… $\endgroup$
    – Kuifje
    Apr 23 at 13:00
  • $\begingroup$ 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 $\endgroup$
    – Mike
    Apr 23 at 13:13
  • $\begingroup$ Try pyomo solve --solver=cplex --solver-options="mip=False" $\endgroup$
    – Kuifje
    Apr 23 at 13:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.