python-mip icon indicating copy to clipboard operation
python-mip copied to clipboard

Is it possible to set different types of integrality constraints?

Open hlukashonak opened this issue 3 years ago • 3 comments

Dear MIP Team,

thank you for the package! I am familiarizing myself with it and unfortunately I was not able to find the answer in the documentation. Is it possible to set various integrality constraints modes in MIP? (like e.g. in milp from scipy):

integrality 1D array_like, optional Indicates the type of integrality constraint on each decision variable. 0 : Continuous variable; no integrality constraint. 1 : Integer variable; decision variable must be an integer within bounds. 2 : Semi-continuous variable; decision variable must be within bounds or take value 0. 3 : Semi-integer variable; decision variable must be an integer within bounds or take value 0.

I found only the relax parameter of the optimize function, but this is not enough for my problem (I actually want to implement the case 3 of the listed above)

Many thanks!

hlukashonak avatar May 18 '22 15:05 hlukashonak

I don't think so. In the documentation of Var, the property var_type just gives the options:

(‘B’) BINARY, (‘C’) CONTINUOUS and (‘I’) INTEGER.

rschwarz avatar May 19 '22 07:05 rschwarz

It is not possible yet. The official gurobi python api supports the requested variable definition.

At this point, I have to remark, that the requested variable definition is just a "convenience" feature. You can use a pure integer variable and binary variable together with a set of constraints to model such semi-integer variables.

sebheger avatar May 20 '22 08:05 sebheger