Decision Optimization

 View Only
  • 1.  Optimal Cost changes everytime I run the code for same input

    Posted Tue August 31, 2021 04:51 AM
    Edited by System Fri January 20, 2023 04:41 PM
    I am solving a multiple, parallel machine task scheduling problem where wtasks are optional. My code is very similar to the Example provided.

    However, my optimal cost changes every time I run the code for same input. I am amazed to see this happening.
    My code for the cost is:
    obj= model.sum([model.length_of(span) for span in list_of_line_spans])
    model.add(model.minimize(obj))

    where, list_of_line_spans is the list of spans of each line/machine.

    Can anyone tell me why is this happening and how can I get consistent results?

    Solution:


    I am understanding the CPLEX more now.
    The problem was FailLimit. As it reached the limit in a different manner every time, the optimal solution was changing. I am fixing it now.

    ------------------------------
    Avinash Kumar
    ------------------------------
    #DecisionOptimization


  • 2.  RE: Optimal Cost changes everytime I run the code for same input
    Best Answer

    Posted Tue August 31, 2021 04:55 AM
    Hi

    do you have a time limit like

    msol = mdl.solve(TimeLimit=10)​

    ?

    If yes can you try with a branch limit ?

    regards



    ------------------------------
    [Alex] [Fleischer]
    [EMEA CPLEX Optimization Technical Sales]
    [IBM]
    ------------------------------



  • 3.  RE: Optimal Cost changes everytime I run the code for same input

    Posted Tue August 31, 2021 04:59 AM
    ​Hi,

    No, this is the solve command in my code.
    model_solve = model.solve(url=url, key=key, FailLimit=30000)​


    ------------------------------
    Avinash Kumar
    ------------------------------



  • 4.  RE: Optimal Cost changes everytime I run the code for same input

    Posted Tue August 31, 2021 05:03 AM
    Edited by System Fri January 20, 2023 04:31 PM
    And this is the log of the solver.
    Apologies, I don't know why it is appearing as single row here.
    Solving model....
     ! --------------------------------------------------- CP Optimizer 20.1.0.0 --
     ! Minimization problem - 934 variables, 118 constraints
     ! FailLimit            = 30000
     ! Initial process time : 0.03s (0.03s extraction + 0.01s propagation)
     !  . Log search space  : 986.6 (before), 986.6 (after)
     !  . Memory usage      : 4.5 MB (before), 4.5 MB (after)
     ! Using parallel search with 8 workers.
     ! ----------------------------------------------------------------------------
     !          Best Branches  Non-fixed    W       Branch decision
                            0        934                 -
     + New bound is 120
     ! Using iterative diving.
     ! Using temporal relaxation.
                         1043         30    1   F          presenceOf(line_11_material_57)
                         1043         30    2   F          presenceOf(line_11_material_57)
                         1029         46    3   F          presenceOf(line_11_material_17)
                         1065         35    5   F          presenceOf(line_17_material_55)
                         1007         31    6   F          presenceOf(line_13_material_22)
                         1061         31    4   F          presenceOf(line_10_material_11)
                         2109         23    5   F          presenceOf(line_17_material_42)
                         2049         26    6   F          presenceOf(line_14_material_14)
                         2095         19    1   F          presenceOf(line_14_material_35)
                         2095         19    2   F          presenceOf(line_14_material_35)
                         2065         31    3   F          presenceOf(line_10_material_36)
                         2109         27    4   F          presenceOf(line_14_material_14)
     *          3780     2733  2.55s        5      (gap is 96.83%)
     *          3765     2782  2.55s        6      (gap is 96.81%)
     *          3755     2831  2.55s        4      (gap is 96.80%)
                3755     3000         19    4       425  = startOf(line_15_material_10)
                3755     3000         16    5              presenceOf(line_16_material_83)
                3755     3000         13    6              presenceOf(line_12_material_44)
                3755     3000         16    1              presenceOf(line_10_material_24)
     ! Time = 3.16s, Average fail depth = 17, Memory usage = 39.7 MB
     ! Current bound is 120 (gap is 96.80%)
     !          Best Branches  Non-fixed    W       Branch decision
                3755     3000         16    2              presenceOf(line_10_material_24)
                3755     3000         16    3              presenceOf(line_15_material_2)
                3755     4000          8    6   F          presenceOf(line_12_material_59)
                3755     4000         20    1             !presenceOf(line_17_material_18)
                3755     4000         20    2             !presenceOf(line_17_material_18)
                3755     4000         20    3   F          presenceOf(line_12_material_48)
     *          3725     3639  3.41s        5      (gap is 96.78%)
                3725     4000         16    5             !presenceOf(line_13_material_57)
                3725     4000          7    4             !presenceOf(line_12_material_18)
                3725     5000         29    5   F    90  = startOf(line_17_material_58)
                3725     5000          9    3       450  = startOf(line_15_material_54)
                3725     5000          4    4   F          presenceOf(line_14_material_65)
                3725     5000          5    6       460 != startOf(line_11_material_9)
                3725     5000        113    1   F          presenceOf(line_10_material_83)
                3725     5000        113    2   F          presenceOf(line_10_material_83)
                3725     6000          8    3              presenceOf(line_17_material_94)
                3725     7000          4    3       370  = startOf(line_14_material_75)
                3725     6000         43    4       100  = startOf(line_12_material_15)
                3725     7000          8    4       440 != startOf(line_14_material_11)
                3725     6000          5    5             !presenceOf(line_15_material_11)
     ! Time = 4.13s, Average fail depth = 75, Memory usage = 40.4 MB
     ! Current bound is 120 (gap is 96.78%)
     !          Best Branches  Non-fixed    W       Branch decision
                3725     7000         50    5   F          presenceOf(line_10_material_57)
                3725     6000          9    6   F   212 <= startOf(line_12_material_95)
                3725     7000         18    6             !presenceOf(line_17_material_62)
                3725     6000        112    1             !presenceOf(line_10_material_45)
                3725     6000        112    2             !presenceOf(line_10_material_45)
                3725     8000          8    4   F   295  = startOf(line_11_material_68)
                3725     9000        118    4   F          presenceOf(line_12_material_79)
                3725     8000          8    5   F          presenceOf(line_17_material_61)
                3725     8000         30    6             !presenceOf(line_13_material_57)
                3725     9000          5    6   F          presenceOf(line_13_material_14)
                3725     7000        114    1       197 != startOf(line_16_material_7)
                3725     7000        114    2       197 != startOf(line_16_material_7)
                3725     8000         43    3             !presenceOf(line_10_material_8)
                3725     9000        113    3       250  = startOf(line_12_material_101)
                3725    10000          4    4       455  = startOf(line_14_material_26)
                3725     9000         33    5   F    90  = startOf(line_16_material_25)
                3725    10000         30    5   F          presenceOf(line_16_material_64)
                3725     8000        118    1       242  = startOf(line_17_material_38)
                3725     9000        125    1   F   145  = startOf(line_11_material_70)
                3725     8000        118    2       242  = startOf(line_17_material_38)
     ! Time = 5.35s, Average fail depth = 92, Memory usage = 40.2 MB
     ! Current bound is 120 (gap is 96.78%)
     !          Best Branches  Non-fixed    W       Branch decision
                3725     9000        125    2   F   145  = startOf(line_11_material_70)
                3725    10000          5    3       330  = startOf(line_11_material_37)
                3725    11000         19    3   F          presenceOf(line_12_material_57)
                3725    11000          4    4       206 != startOf(line_14_material_13)
                3725    12000         61    4             !presenceOf(line_16_material_59)
                3725    10000          5    6             !presenceOf(line_13_material_86)
                3725    11000         49    6              presenceOf(line_12_material_35)
                3725    12000        158    6              presenceOf(line_12_material_72)
                3725    10000         31    1             !presenceOf(line_11_material_18)
                3725    10000         31    2             !presenceOf(line_11_material_18)
                3725    12000         54    3       377  = startOf(line_16_material_99)
                3725    13000         78    4   F         !presenceOf(line_12_material_1)
                3725    14000         31    4       150  = startOf(line_15_material_20)
                3725    13000        118    6   F     0  = startOf(line_11_material_64)
     *          3710    10573  5.73s        1      (gap is 96.77%)
                3710    11000          3    1             !presenceOf(line_15_material_8)
                3710    11000          3    2             !presenceOf(line_15_material_8)
                3710    13000         91    3         0  = startOf(line_14_material_96)
                3710    14000         92    3   F          presenceOf(line_12_material_5)
                3710    15000          3    4             !presenceOf(line_11_material_55)
     ! Time = 6.04s, Average fail depth = 92, Memory usage = 42.0 MB
     ! Current bound is 120 (gap is 96.77%)
     !          Best Branches  Non-fixed    W       Branch decision
                3710    11000          2    5             !presenceOf(line_13_material_27)
                3710    12000         13    5             !presenceOf(line_13_material_59)
    
    
    
    
    
                3710    14000        120    6   F          presenceOf(line_15_material_47)
                3710    15000        108    6        45  = startOf(line_10_material_88)
                3710    12000         39    1              presenceOf(line_16_material_33)
                3710    13000         33    1         0  = startOf(line_13_material_12)
                3710    12000         39    2              presenceOf(line_16_material_33)
                3710    13000         33    2         0  = startOf(line_13_material_12)
     *          3700    15361  6.04s        4      (gap is 96.76%)
                3700    13000         22    5        70  = startOf(line_10_material_32)
                3700    14000         14    5       390 != startOf(line_10_material_64)
                3700    16000          8    6       455  = startOf(line_12_material_11)
                3700    17000          9    6         0  = startOf(line_17_material_85)
                3700    14000          6    1   F   225  = startOf(line_17_material_59)
                3700    15000         78    1       100  = startOf(line_14_material_86)
                3700    14000          6    2   F   225  = startOf(line_17_material_59)
                3700    15000         78    2       100  = startOf(line_14_material_86)
                3700    15000         49    3   F          presenceOf(line_17_material_60)
                3700    16000          4    4             !presenceOf(line_12_material_53)
                3700    17000        143    4   F          presenceOf(line_15_material_10)
     ! Time = 6.32s, Average fail depth = 91, Memory usage = 42.1 MB
     ! Current bound is 120 (gap is 96.76%)
     !          Best Branches  Non-fixed    W       Branch decision
                3700    18000         17    4             !presenceOf(line_16_material_20)
                3700    15000         31    5   F   335  = startOf(line_17_material_42)
                3700    16000         31    5             !presenceOf(line_11_material_64)
                3700    17000         39    5   F    95  = startOf(line_13_material_97)
     ! ----------------------------------------------------------------------------
     ! Search terminated by limit, 6 solutions found.
     ! Best objective         : 3700 (gap is 96.76%)
     ! Best bound             : 120
     ! ----------------------------------------------------------------------------
     ! Number of branches     : 813381
     ! Number of fails        : 43673
     ! Total memory usage     : 41.9 MB (41.5 MB CP Optimizer + 0.4 MB Concert)
     ! Time spent in solve    : 7.13s (7.10s engine + 0.03s extraction)
     ! Search speed (br. / s) : 114560.7
     ! ----------------------------------------------------------------------------
    
    ​


    ------------------------------
    Avinash Kumar
    ------------------------------