Obtaining linear relaxation objective value from MILP model coded in Pyomo

169 views
Skip to first unread message

blendm...@gmail.com

unread,
Jun 1, 2021, 11:48:52 AM6/1/21
to Pyomo Forum
Dear all,

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?

Thank you!

Yours sincerely,

Che Han

berna...@gmail.com

unread,
Jun 10, 2021, 12:45:51 PM6/10/21
to Pyomo Forum
Hi Che Han,
there is a transformation implemented in Pyomo to do exactly that, solve the continuous relaxation of a (Mixed-)Integer Problem.
You use it as follows:

from pyomo.environ import ConcreteModel, RangeSet, Var, TransformationFactory
xfrm = TransformationFactory('core.relax_integer_vars')
m = ConcreteModel()
"Here comes your model definition"
m2 = xfrm.apply_to(m)

Here m2 would be the continuous relaxation of your model m, which you can solve directly. If you do not add a return to the transformation, it will happen "in-place" meaning that m will be modified such as it becomes a continuous problem.

Cheers,
David 

blendm...@gmail.com

unread,
Jun 12, 2021, 1:57:54 PM6/12/21
to Pyomo Forum
Dear David,

Thank you for your help.

Let me try and get back to you should I encounter issues with it.

Thank you!

Yours sincerely,
Che Han

Reply all
Reply to author
Forward
0 new messages