IBMDecisionOptimization / Decision-Optimization-with-CPLEX-samples

20 stars 9 forks source link

LP gives different solve status for same model #5

Closed bhimabi closed 3 years ago

bhimabi commented 3 years ago

Context: I have an 'MILP' model where the binaries are defined as continuous variables(Will refer to these as binary variables below). Through other techniques, I generate the values of binary variables and fix their respective variables. All constraints that could cause infeasibility have slack variables; thus ANY combination of binary variable values should produce a feasible solution.

Problem: It is expected that the LPs always solve and produce a feasible solution. However, sometimes the solve fails during my random iterative search and I get the following solve status: "Optimal with Unscaled Infeasibilities". In debugging the issue, I get the binary values which had caused the error and re-run a single LP with those values. This time however, I do not get the error. Without being able to consistantly recreate this error, I am not able to find the source and fix it.

I have included a bit more information in case it helps. Operating System: CentOS Linux 8 (Core) CPE OS Name: cpe:/o:centos:centos:8 Kernel: Linux 4.18.0-193.28.1.el8_2.x86_64 Architecture: x86-64

Python(3.6.8) package versions: cplex 12.10.0.0 docplex 2.19.202

vlkong commented 3 years ago

Hi,

You can try with the datachecker on to see what it detects. https://www.ibm.com/support/pages/cplex-indicates-my-model-optimal-unscaled-infeasibilities

Best regards,

bhimabi commented 3 years ago

Hi

I had seen that article but that did not solve the primary issue. I have written a simple psuedo code below to try to shed some light into the issue.

generate() - Randomly assigns the 'binary' variables with either 0 or 1 assign_binaries() - Unfixes old values and refixes new values of binaries based on output of generate by setting ub & lb values of binaries run_LP() - LP with no slacks run_LP_slack() - LP with slacks for all infeasibilities

while True:
     generate()
     assign_binaries()
     run_LP()
     if model.solve_details.status_code == 1: #Optimal
          continue
     if model.solve_details.status_code == 3: #Infeasible
          run_LP_slack()     <-- THIS
          if model.solve_details.status_code == 1: #Optimal
               continue
          if model.solve_details.status_code != 1:
               # THIS SHOULD NEVER HAPPEN

               run_LP_slack()    <---- THAT

The error (Optimal with Unscaled Infeasibilities) usually occurs in the line of code labelled 'THIS'. However, when i solve the same model again(labelled 'THAT') but calling solve() again, it magically solves successfully(status_code ==1). How/why do I get 2 different solve outcomes when running the same model twice?

Because of this, when I look at the values of binaries that cause the issue and run it again myself, the solve is sucessful and am not able to recreate the issue