Decision Optimization

Decision Optimization

Delivers prescriptive analytics capabilities and decision intelligence to improve decision-making.

 View Only
Expand all | Collapse all

CPLEX can't find a solution when I use binary vabriables

  • 1.  CPLEX can't find a solution when I use binary vabriables

    Posted Thu October 15, 2020 06:05 PM

    I'm using CPLEX to solve a MILP problem.

    I tried two approaches; I expected the same results, but while the first approach works, the second doesn't.

    1) First approach:

    This approach works successfully.

    I attached (at the end of this post) the generated ".lp" file (there's an objective function which has to be minimized and some constraints (each of them splitted in some sub-constraints, but it's not important)).

    As you can see in the ".lp" file, I setted x6, x7, x8, x9, x10, x11 as continuous variables, and all of them are equal to 500 (I defined both their upper and lower bounds equal to 500; so they're constants).

    **2) Second approach:**

    It returns CPLEX Error 1217: No solution exists, so, with this approach, CPLEX isn't able to find a solution, but I can't understand why.

    The only things that I changed are:

    • I setted x6, x7, x8, x9, x10, x11 as binary variables;
    • for each of them, I defined the lower bound equal to 0 and the upper bound equal to 500.

    So, the generated ".lp" file is very similar to the one generated by using the first approach; the only different things are that:

    • x6, x7, x8, x9, x10, x11 are defined as ranges (instead of constants), so:
    0 <= x6 <= 500 0 <= x7 <= 500 0 <= x8 <= 500 0 <= x9 <= 500 0 <= x10 <= 500 0 <= x11 <= 500
    • the Binaries section at the end of the ".lp" file now contains x6, x7, x8, x9, x10, x11 variables, too.

    Note:

    Even if (in the second approach) I would set both lower and upper bounds (of x6, x7, x8, x9, x10, x11) equal to 500, the problem persists.

    ************************************************************************

    ".lp" file obtained with the "First approach":

    Minimize obj: x0 + x1 + x2 + x3 + x4 + x5 Subject To c1: - x6 + x12 + x18 - Rgc1 = 18000 c2: - x7 + x13 - x18 + x19 - Rgc2 = 0 c3: - x8 + x14 - x19 + x20 - Rgc3 = 0 c4: - x9 + x15 - x20 + x21 - Rgc4 = 0 c5: - x10 + x16 - x21 + x22 - Rgc5 = 0 c6: - x11 + x17 - x22 + x23 - Rgc6 = 0 c7: x24 + x25 + x26 + x27 + x28 + x29 - Rgc7 = 1 c8: x24 + x25 - Rgc8 = 0 c9: x24 + x26 - Rgc9 = 0 c10: x24 + x27 - Rgc10 = 0 c11: x24 + x28 - Rgc11 = 0 c12: x24 + x29 - Rgc12 = 0 c13: x25 + x26 - Rgc13 = 0 c14: x25 + x27 - Rgc14 = 0 c15: x25 + x28 - Rgc15 = 0 c16: x25 + x29 - Rgc16 = 0 c17: x26 + x27 - Rgc17 = 0 c18: x26 + x28 - Rgc18 = 0 c19: x26 + x29 - Rgc19 = 0 c20: x27 + x28 - Rgc20 = 0 c21: x27 + x29 - Rgc21 = 0 c22: x30 + x31 + x32 + x33 + x34 + x35 - Rgc22 = 2 c23: x30 + x32 - Rgc23 = 0 c24: x30 + x33 - Rgc24 = 0 c25: x30 + x34 - Rgc25 = 0 c26: x30 + x35 - Rgc26 = 0 c27: x31 + x33 - Rgc27 = 0 c28: x31 + x34 - Rgc28 = 0 c29: x31 + x35 - Rgc29 = 0 c30: x32 + x34 - Rgc30 = 0 c31: x32 + x35 - Rgc31 = 0 c32: x36 + x37 + x38 + x39 + x40 + x41 - Rgc32 = 3 c33: x36 + x39 - Rgc33 = 0 c34: x36 + x40 - Rgc34 = 0 c35: x36 + x41 - Rgc35 = 0 c36: x37 + x40 - Rgc36 = 0 c37: x37 + x41 - Rgc37 = 0 c38: x0 + x12 - Rgc38 = 0 c39: x1 + x13 - Rgc39 = 0 c40: x2 + x14 - Rgc40 = 0 c41: x3 + x15 - Rgc41 = 0 c42: x4 + x16 - Rgc42 = 0 c43: x5 + x17 - Rgc43 = 0 c44: x0 - x6 + x12 - 152.8 x24 - 139.8 x30 - 44.8 x36 - Rgc44 = 0 c45: x1 - x7 + x13 - 152.8 x25 - 139.8 x31 - 44.8 x37 - Rgc45 = 0 c46: x2 - x8 + x14 - 152.8 x26 - 139.8 x32 - 44.8 x38 - Rgc46 = 0 c47: x3 - x9 + x15 - 152.8 x27 - 139.8 x33 - 44.8 x39 - Rgc47 = 0 c48: x4 - x10 + x16 - 152.8 x28 - 139.8 x34 - 44.8 x40 - Rgc48 = 0 c49: x5 - x11 + x17 - 152.8 x29 - 139.8 x35 - 44.8 x41 - Rgc49 = 0 c50: x6 + 152.8 x24 + 139.8 x30 + 44.8 x36 - Rgc50 = 0 c51: x7 + 152.8 x25 + 139.8 x31 + 44.8 x37 - Rgc51 = 0 c52: x8 + 152.8 x26 + 139.8 x32 + 44.8 x38 - Rgc52 = 0 c53: x9 + 152.8 x27 + 139.8 x33 + 44.8 x39 - Rgc53 = 0 c54: x10 + 152.8 x28 + 139.8 x34 + 44.8 x40 - Rgc54 = 0 c55: x11 + 152.8 x29 + 139.8 x35 + 44.8 x41 - Rgc55 = 0 Bounds 0 <= x0 <= 3000 0 <= x1 <= 3000 0 <= x2 <= 3000 0 <= x3 <= 3000 0 <= x4 <= 3000 0 <= x5 <= 3000 x6 = 500 x7 = 500 x8 = 500 x9 = 500 x10 = 500 x11 = 500 x12 = 0 x13 = 0 x14 = 0 x15 = 0 x16 = 0 x17 = 0 0 <= x18 <= 24000 0 <= x19 <= 24000 0 <= x20 <= 24000 0 <= x21 <= 24000 0 <= x22 <= 24000 21000 <= x23 <= 24000 0 <= x24 <= 1 0 <= x25 <= 1 0 <= x26 <= 1 0 <= x27 <= 1 0 <= x28 <= 1 0 <= x29 <= 1 0 <= x30 <= 1 0 <= x31 <= 1 0 <= x32 <= 1 0 <= x33 <= 1 0 <= x34 <= 1 0 <= x35 <= 1 0 <= x36 <= 1 0 <= x37 <= 1 0 <= x38 <= 1 0 <= x39 <= 1 0 <= x40 <= 1 0 <= x41 <= 1 Rgc1 = 0 Rgc2 = 0 Rgc3 = 0 Rgc4 = 0 Rgc5 = 0 Rgc6 = 0 Rgc7 = 0 0 <= Rgc8 <= 1 0 <= Rgc9 <= 1 0 <= Rgc10 <= 1 0 <= Rgc11 <= 1 0 <= Rgc12 <= 1 0 <= Rgc13 <= 1 0 <= Rgc14 <= 1 0 <= Rgc15 <= 1 0 <= Rgc16 <= 1 0 <= Rgc17 <= 1 0 <= Rgc18 <= 1 0 <= Rgc19 <= 1 0 <= Rgc20 <= 1 0 <= Rgc21 <= 1 Rgc22 = 0 0 <= Rgc23 <= 1 0 <= Rgc24 <= 1 0 <= Rgc25 <= 1 0 <= Rgc26 <= 1 0 <= Rgc27 <= 1 0 <= Rgc28 <= 1 0 <= Rgc29 <= 1 0 <= Rgc30 <= 1 0 <= Rgc31 <= 1 Rgc32 = 0 0 <= Rgc33 <= 1 0 <= Rgc34 <= 1 0 <= Rgc35 <= 1 0 <= Rgc36 <= 1 0 <= Rgc37 <= 1 0 <= Rgc38 <= 3000 0 <= Rgc39 <= 3000 0 <= Rgc40 <= 3000 0 <= Rgc41 <= 3000 0 <= Rgc42 <= 3000 0 <= Rgc43 <= 3000 Rgc44 = 0 Rgc45 = 0 Rgc46 = 0 Rgc47 = 0 Rgc48 = 0 Rgc49 = 0 0 <= Rgc50 <= 3000 0 <= Rgc51 <= 3000 0 <= Rgc52 <= 3000 0 <= Rgc53 <= 3000 0 <= Rgc54 <= 3000 0 <= Rgc55 <= 3000 Binaries x24 x25 x26 x27 x28 x29 x30 x31 x32 x33 x34 x35 x36 x37 x38 x39 x40 x41 End




    #DecisionOptimization
    #Support
    #SupportMigration


  • 2.  RE: CPLEX can't find a solution when I use binary vabriables

    Posted Mon November 02, 2020 01:00 PM

    Dear wobniar,

    I can reproduce the problem, and indeed it seems strange that binary vars cannot be constrained with 0 <= x <= 500 (even 0 <= x <= 1 fails!). Note that x == 500 MUST fail if x is binary since x binary means 0 <= x <= 1). We'll look at this issue, thank you for reporting it.






    #DecisionOptimization
    #Support
    #SupportMigration


  • 3.  RE: CPLEX can't find a solution when I use binary vabriables

    Posted Mon November 02, 2020 01:47 PM

    Dear wobniar,

    It appears that simply declaring these variable as boolean make the problem infeasible, since removing the constraints on them while leaving them in the binary section also leads to infeasibility. Please check your constraints!

    I hope this helps,






    #DecisionOptimization
    #Support
    #SupportMigration