ORSpecialist
ORSpecialist

Reputation: 401

LP-Relaxation in Gurobipy

I want to find an LP-relaxation solution to my problem by using Gurobi.py (a Python package for solving LP). I could do it by rewriting .lp file by changing all Integrality constraints to continuous. However, I do not want to write .lp file again.

Upvotes: 1

Views: 1142

Answers (1)

Greg Glockner
Greg Glockner

Reputation: 5653

There are several ways to do this, depending on your needs. Here are my recommended methods:

  1. Easiest: create the relaxed copy by calling the Model.relax() method, which creates a copy of the model as the relaxed model.
  2. Modify the model by iterating over all variables and set the VType attribute to 'C' for continuous.
  3. Most complex: write a callback function that calls Model.cbGetNodeRel() to get the relaxed solution at MIP nodes.

Upvotes: 4

Related Questions