2

I am working with mixed integer quadratic programming (MIQP) on CPLEX 12.8.0, Python API. I generated a model to the .lp file. It turned out the model is integer infeasible. It is very weird, because I generated the exact same problem with Gurobi before and it is solvable.

I have attached a link to the .lp file here and the results from solving using CPLEX and Gurobi. I declared some semi-continuous variables. My objective function is quadratic, however I don't think it is the reason that causes integer infeasibility, isn't it? In the end, I really want to use CPLEX for my work due to some feature that CPLEX can do, but Gurobi cannot.

.lp file:

Minimize
 obj: - wi0k0 - wi1k0 - wi2k0 - wi3k0 - wi0k1 - wi1k1 - wi2k1 - wi3k1 + [ m0 ^2
      + m1 ^2 + 1.54315034142201 loss0 ^2 + 1.54315034142201 loss1 ^2
      + 1.54315034142201 loss2 ^2 + 1.54315034142201 loss3 ^2 ] / 2
Subject To
 c1i0k0:  - 2.98563348744947 zi0k0 - ti0k0 <= 0
 c2i0k0:  - 1.33632173341833 zi0k0 + ti0k0 <= 0
 c3i0k0:  m0 + 1.33632173341833 zi0k0 - ti0k0 <= 1.33632173341833
 c4i0k0:  - m0 + 2.98563348744947 zi0k0 + ti0k0 <= 2.98563348744947
 c5i0k0:  - 2.30258509299405 zi0k0 - wi0k0 <= 0
 c6i0k0:  0.22314355131421 zi0k0 + wi0k0 <= 0
 c7i0k0:  v0 - 0.22314355131421 zi0k0 - wi0k0 <= -0.22314355131421
 c8i0k0:  - v0 + 2.30258509299405 zi0k0 + wi0k0 <= 2.30258509299405
 c1i1k0:  - 2.98563348744947 zi1k0 - ti1k0 <= 0
 c2i1k0:  - 1.33632173341833 zi1k0 + ti1k0 <= 0
 c3i1k0:  m0 + 1.33632173341833 zi1k0 - ti1k0 <= 1.33632173341833
 c4i1k0:  - m0 + 2.98563348744947 zi1k0 + ti1k0 <= 2.98563348744947
 c5i1k0:  - 2.30258509299405 zi1k0 - wi1k0 <= 0
 c6i1k0:  0.22314355131421 zi1k0 + wi1k0 <= 0
 c7i1k0:  v0 - 0.22314355131421 zi1k0 - wi1k0 <= -0.22314355131421
 c8i1k0:  - v0 + 2.30258509299405 zi1k0 + wi1k0 <= 2.30258509299405
 c1i2k0:  - 2.98563348744947 zi2k0 - ti2k0 <= 0
 c2i2k0:  - 1.33632173341833 zi2k0 + ti2k0 <= 0
 c3i2k0:  m0 + 1.33632173341833 zi2k0 - ti2k0 <= 1.33632173341833
 c4i2k0:  - m0 + 2.98563348744947 zi2k0 + ti2k0 <= 2.98563348744947
 c5i2k0:  - 2.30258509299405 zi2k0 - wi2k0 <= 0
 c6i2k0:  0.22314355131421 zi2k0 + wi2k0 <= 0
 c7i2k0:  v0 - 0.22314355131421 zi2k0 - wi2k0 <= -0.22314355131421
 c8i2k0:  - v0 + 2.30258509299405 zi2k0 + wi2k0 <= 2.30258509299405
 c1i3k0:  - 2.98563348744947 zi3k0 - ti3k0 <= 0
 c2i3k0:  - 1.33632173341833 zi3k0 + ti3k0 <= 0
 c3i3k0:  m0 + 1.33632173341833 zi3k0 - ti3k0 <= 1.33632173341833
 c4i3k0:  - m0 + 2.98563348744947 zi3k0 + ti3k0 <= 2.98563348744947
 c5i3k0:  - 2.30258509299405 zi3k0 - wi3k0 <= 0
 c6i3k0:  0.22314355131421 zi3k0 + wi3k0 <= 0
 c7i3k0:  v0 - 0.22314355131421 zi3k0 - wi3k0 <= -0.22314355131421
 c8i3k0:  - v0 + 2.30258509299405 zi3k0 + wi3k0 <= 2.30258509299405
 c9k0:    - pi0 + omk0j1 + omk0j2 + omk0j3 + omk0j4  = 0
 c10k0:   - v0 + 5.78057663816274 omk0j1 - 2.88064275681032 gk0j1
          + 2.81415134341597 omk0j2 - 2.06487580075496 gk0j2
          + 1.87716609698306 omk0j3 - 1.64323243986015 gk0j3
          + 1.41062901675158 omk0j4 - 1.35164676471547 gk0j4  = 0
 c11k0:   gk0j1 + gk0j2 + gk0j3 + gk0j4  = 1
 c12k0j1: - omk0j1 + 0.1 gk0j1 <= 0
 c13k0j1: omk0j1 - 0.275 gk0j1 <= 0
 c12k0j2: - omk0j2 + 0.275 gk0j2 <= 0
 c13k0j2: omk0j2 - 0.45 gk0j2 <= 0
 c12k0j3: - omk0j3 + 0.45 gk0j3 <= 0
 c13k0j3: omk0j3 - 0.625 gk0j3 <= 0
 c12k0j4: - omk0j4 + 0.625 gk0j4 <= 0
 c13k0j4: omk0j4 - 0.8 gk0j4 <= 0
 c14k0:   - 4 pi0 + zi0k0 + zi1k0 + zi2k0 + zi3k0  = 0
 c15k0:   1.33632173341833 zi0k0 - ti0k0 - 1.17708699624777 zi1k0 - ti1k0
          - 2.28656128473847 zi2k0 - ti2k0 - 2.98563348744947 zi3k0 - ti3k0
           = 0
 c1i0k1:  - 2.98563348744947 zi0k1 - ti0k1 <= 0
 c2i0k1:  - 1.33632173341833 zi0k1 + ti0k1 <= 0
 c3i0k1:  m1 + 1.33632173341833 zi0k1 - ti0k1 <= 1.33632173341833
 c4i0k1:  - m1 + 2.98563348744947 zi0k1 + ti0k1 <= 2.98563348744947
 c5i0k1:  - 2.30258509299405 zi0k1 - wi0k1 <= 0
 c6i0k1:  0.22314355131421 zi0k1 + wi0k1 <= 0
 c7i0k1:  v1 - 0.22314355131421 zi0k1 - wi0k1 <= -0.22314355131421
 c8i0k1:  - v1 + 2.30258509299405 zi0k1 + wi0k1 <= 2.30258509299405
 c1i1k1:  - 2.98563348744947 zi1k1 - ti1k1 <= 0
 c2i1k1:  - 1.33632173341833 zi1k1 + ti1k1 <= 0
 c3i1k1:  m1 + 1.33632173341833 zi1k1 - ti1k1 <= 1.33632173341833
 c4i1k1:  - m1 + 2.98563348744947 zi1k1 + ti1k1 <= 2.98563348744947
 c5i1k1:  - 2.30258509299405 zi1k1 - wi1k1 <= 0
 c6i1k1:  0.22314355131421 zi1k1 + wi1k1 <= 0
 c7i1k1:  v1 - 0.22314355131421 zi1k1 - wi1k1 <= -0.22314355131421
 c8i1k1:  - v1 + 2.30258509299405 zi1k1 + wi1k1 <= 2.30258509299405
 c1i2k1:  - 2.98563348744947 zi2k1 - ti2k1 <= 0
 c2i2k1:  - 1.33632173341833 zi2k1 + ti2k1 <= 0
 c3i2k1:  m1 + 1.33632173341833 zi2k1 - ti2k1 <= 1.33632173341833
 c4i2k1:  - m1 + 2.98563348744947 zi2k1 + ti2k1 <= 2.98563348744947
 c5i2k1:  - 2.30258509299405 zi2k1 - wi2k1 <= 0
 c6i2k1:  0.22314355131421 zi2k1 + wi2k1 <= 0
 c7i2k1:  v1 - 0.22314355131421 zi2k1 - wi2k1 <= -0.22314355131421
 c8i2k1:  - v1 + 2.30258509299405 zi2k1 + wi2k1 <= 2.30258509299405
 c1i3k1:  - 2.98563348744947 zi3k1 - ti3k1 <= 0
 c2i3k1:  - 1.33632173341833 zi3k1 + ti3k1 <= 0
 c3i3k1:  m1 + 1.33632173341833 zi3k1 - ti3k1 <= 1.33632173341833
 c4i3k1:  - m1 + 2.98563348744947 zi3k1 + ti3k1 <= 2.98563348744947
 c5i3k1:  - 2.30258509299405 zi3k1 - wi3k1 <= 0
 c6i3k1:  0.22314355131421 zi3k1 + wi3k1 <= 0
 c7i3k1:  v1 - 0.22314355131421 zi3k1 - wi3k1 <= -0.22314355131421
 c8i3k1:  - v1 + 2.30258509299405 zi3k1 + wi3k1 <= 2.30258509299405
 c9k1:    - pi1 + omk1j1 + omk1j2 + omk1j3 + omk1j4  = 0
 c10k1:   - v1 + 5.78057663816274 omk1j1 - 2.88064275681032 gk1j1
          + 2.81415134341597 omk1j2 - 2.06487580075496 gk1j2
          + 1.87716609698306 omk1j3 - 1.64323243986015 gk1j3
          + 1.41062901675158 omk1j4 - 1.35164676471547 gk1j4  = 0
 c11k1:   gk1j1 + gk1j2 + gk1j3 + gk1j4  = 1
 c12k1j1: - omk1j1 + 0.1 gk1j1 <= 0
 c13k1j1: omk1j1 - 0.275 gk1j1 <= 0
 c12k1j2: - omk1j2 + 0.275 gk1j2 <= 0
 c13k1j2: omk1j2 - 0.45 gk1j2 <= 0
 c12k1j3: - omk1j3 + 0.45 gk1j3 <= 0
 c13k1j3: omk1j3 - 0.625 gk1j3 <= 0
 c12k1j4: - omk1j4 + 0.625 gk1j4 <= 0
 c13k1j4: omk1j4 - 0.8 gk1j4 <= 0
 c14k1:   - 4 pi1 + zi0k1 + zi1k1 + zi2k1 + zi3k1  = 0
 c15k1:   1.33632173341833 zi0k1 - ti0k1 - 1.17708699624777 zi1k1 - ti1k1
          - 2.28656128473847 zi2k1 - ti2k1 - 2.98563348744947 zi3k1 - ti3k1
           = 0
 c16i0:   zi0k0 + zi0k1  = 1
 c16i1:   zi1k0 + zi1k1  = 1
 c16i2:   zi2k0 + zi2k1  = 1
 c16i3:   zi3k0 + zi3k1  = 1
 c17k0:   zi0k0 + zi1k0 + zi2k0 + zi3k0 >= 0.4
 c18k0:   zi0k0 + zi1k0 + zi2k0 + zi3k0 <= 3.2
 c17k1:   zi0k1 + zi1k1 + zi2k1 + zi3k1 >= 0.4
 c18k1:   zi0k1 + zi1k1 + zi2k1 + zi3k1 <= 3.2
 c21k0:   m0 - m1 <= 0
 c22:     pi0 + pi1  = 1
 c23i0:   ti0k0 + ti0k1 + loss0  = 1.33632173341833
 c23i1:   ti1k0 + ti1k1 + loss1  = -1.17708699624777
 c23i2:   ti2k0 + ti2k1 + loss2  = -2.28656128473847
 c23i3:   ti3k0 + ti3k1 + loss3  = -2.98563348744947
Bounds
 0.1 <= pi0 <= 0.8
-2.98563348744947 <= m0 <= 1.33632173341833
-2.30258509299405 <= v0 <= -0.22314355131421
 0 <= zi0k0 <= 1
-2.98563348744947 <= ti0k0 <= 1.33632173341833
-2.30258509299405 <= wi0k0 <= -0.22314355131421
 0 <= zi1k0 <= 1
-2.98563348744947 <= ti1k0 <= 1.33632173341833
-2.30258509299405 <= wi1k0 <= -0.22314355131421
 0 <= zi2k0 <= 1
-2.98563348744947 <= ti2k0 <= 1.33632173341833
-2.30258509299405 <= wi2k0 <= -0.22314355131421
 0 <= zi3k0 <= 1
-2.98563348744947 <= ti3k0 <= 1.33632173341833
-2.30258509299405 <= wi3k0 <= -0.22314355131421
 0.1 <= omk0j1 <= 0.8
 0 <= gk0j1 <= 1
 0.1 <= omk0j2 <= 0.8
 0 <= gk0j2 <= 1
 0.1 <= omk0j3 <= 0.8
 0 <= gk0j3 <= 1
 0.1 <= omk0j4 <= 0.8
 0 <= gk0j4 <= 1
 0.1 <= pi1 <= 0.8
-2.98563348744947 <= m1 <= 1.33632173341833
-2.30258509299405 <= v1 <= -0.22314355131421
 0 <= zi0k1 <= 1
-2.98563348744947 <= ti0k1 <= 1.33632173341833
-2.30258509299405 <= wi0k1 <= -0.22314355131421
 0 <= zi1k1 <= 1
-2.98563348744947 <= ti1k1 <= 1.33632173341833
-2.30258509299405 <= wi1k1 <= -0.22314355131421
 0 <= zi2k1 <= 1
-2.98563348744947 <= ti2k1 <= 1.33632173341833
-2.30258509299405 <= wi2k1 <= -0.22314355131421
 0 <= zi3k1 <= 1
-2.98563348744947 <= ti3k1 <= 1.33632173341833
-2.30258509299405 <= wi3k1 <= -0.22314355131421
 0.1 <= omk1j1 <= 0.8
 0 <= gk1j1 <= 1
 0.1 <= omk1j2 <= 0.8
 0 <= gk1j2 <= 1
 0.1 <= omk1j3 <= 0.8
 0 <= gk1j3 <= 1
 0.1 <= omk1j4 <= 0.8
 0 <= gk1j4 <= 1
 0 <= loss0 <= 4.3219552208678
-2.5134087296661 <= loss1 <= 1.80854649120169
-3.6228830181568 <= loss2 <= 0.699072202710996
-4.3219552208678 <= loss3 <= 0
Binaries
 zi0k0  zi1k0  zi2k0  zi3k0  gk0j1  gk0j2  gk0j3  gk0j4  zi0k1  zi1k1  zi2k1 
 zi3k1  gk1j1  gk1j2  gk1j3  gk1j4 
Semi-Continuous
 ti0k0  wi0k0  ti1k0  wi1k0  ti2k0  wi2k0  ti3k0  wi3k0  omk0j1  omk0j2 
 omk0j3  omk0j4  ti0k1  wi0k1  ti1k1  wi1k1  ti2k1  wi2k1  ti3k1  wi3k1 
 omk1j1  omk1j2  omk1j3  omk1j4 
End

Here Gurobi can solve the model, but not CPLEX.

CPLEX output:

CPLEX output

Gurobi output:

Gurobi output

  • 2
    Hello! Welcome to Stack Overflow! It seems you have good question! To help us help you, include the parts of your code you think relevant to answering the question. Please avoid posting links to file downloads, and instead provide a clear code snippet of the problem. I hope you find an answer soon! – cosinepenguin Feb 22 '19 at 02:56
  • Thank you for your suggestion. I have removed the link to file and reposted the .lp file. I would say that I am quite new to CPLEX and I generated this .lp from CPLEX. It contains no error. Here, there are decision binary variables: zi#k#, gk#j#. There are semi-continuous variables: wi#k#, ti#k#, and omk#j#. Constraints c1i#k# - c4i#k# and c5i#k# - c8i#k# define the bound and property of the semi-continuous variables: wi#k# and ti#k#, respectively. – sadlittlebunny Feb 22 '19 at 06:06
  • ALSO NOTE: .lp-formats are NOT standardized across solvers! Please try to use the .mps-format. Also note, .lp-files are meant to be human-readable. Therefore, when writing .lp-files with Gurobi, parameters will NOT be written with full decimal precision! for reference: https://support.gurobi.com/hc/en-us/articles/360013420131-What-are-the-differences-between-LP-and-MPS-file-format- https://support.gurobi.com/hc/en-us/articles/360013195612-Why-is-Gurobi-unable-to-read-an-LP-model-file-that-another-solver-can-successfully-read- – Tobias Triesch Jun 08 '20 at 11:39

2 Answers2

4

I think your LP file specification is wrong. For example, you have

-2.98563348744947 <= ti0k0 <= 1.33632173341833

but at the same time ti0k0 is marked as "semi-continuous". What is that supposed to mean? "semi-continuous" says "must be 0 or within the specified bounds". If the specified bounds include 0 then the variable could be just semi-continuous. Does it help to fix this?

I am not sure what Gurobi does with variables like this. What happens if you read the LP with Gurobi, then write it out and feed the newly created LP file to CPLEX? Did you check that the solution provided by Gurobi actually satisfies all your constraints?

2

In addition to the weirdness I mentioned in my other answer (cannot edit my answer because I am not registered here), your LP file is actually wrong for CPLEX. If you look at https://www.ibm.com/support/knowledgecenter/SSSA5P_12.8.0/ilog.odms.cplex.help/CPLEX/UsrMan/topics/discr_optim/semi_cont_var/02_SemiCont_defn.html then you can read

The semi-continuous lower bound (sclb) must be greater than or equal to 0 (zero). An attempt to use a negative value for the semi-continuous lower bound (sclb) will result in that bound being treated as 0 (zero).

So your semi-continuous variables that are "0 or negative" are probably what render the model infeasible since their lower bound is set to 0 and that then results in contradictory bounds for the variable.

You will have to multiply these variables by -1 so that they become "0 or within positive bounds".

  • Thank you, Daniel! It must be the reason. I will look into my semi-continuous variables. I just realized that it is treated differently in CPLEX comparing to Gurobi, where "a semi-continous variable has the property that it takes a value of 0, or a value between the specified lower and upper bounds" without a restriction that the lower bound must be positive. – sadlittlebunny Feb 22 '19 at 20:48
  • Another update. I got it to work by adjusting the semi-continuous variables according to CPLEX. Thank again! – sadlittlebunny Feb 22 '19 at 21:20