Decision Optimization

 View Only
  • 1.  Inconsistent bound behavior

    Posted Mon March 29, 2021 03:39 PM
    Edited by System Fri January 20, 2023 04:21 PM
    Hi,

    I have been experiencing some odd behaviour with the CPOptimizer from COS 20.1.0, in that either the search for optimality appears to terminate too early, or the lower bound is not updated after finding an optimal solution. I have compiled a minimum example (reduced from [1]) with the code attached below. I am accessing CPOptimizer via Docplex (v2.20.204) in Python3.6 and have tested on both Linux and Windows10 installations. Only default parameters were used. 

    This is the output of the msol object:
    (model: <stdin>, solve: Optimal, search: SearchCompleted, solution: (objs: (11,), bnds: (8,), gaps: (0.272727,))

    Note that "bnds" is 8 and "objs" is 11, while the solve status is optimal. 

    Is this behaviour indeed expected? 

    from docplex.cp.model import CpoModel
    from collections import namedtuple

    Order = namedtuple("Order", ['id', 'weight'])

    ORDERS = (
    Order( 1, 22),
    Order( 2, 9),
    )

    AVAILABLE_SLAB_WEIGHTS = [16, 26]

    # Upper bound for the number of slabs to use
    MAX_SLABS = len(ORDERS)
    max_slab_weight = max(AVAILABLE_SLAB_WEIGHTS)
    loss = [0] + [min([sw - use for sw in AVAILABLE_SLAB_WEIGHTS if sw >= use]) for use in range(1, max_slab_weight + 1)]

    # Create model
    mdl = CpoModel()

    # Index of the slab used to produce each coil order
    production_slab = mdl.integer_var_list(len(ORDERS), 0, MAX_SLABS - 1, "production_slab")

    # Usage of each slab
    slab_use = mdl.integer_var_list(MAX_SLABS, 0, max_slab_weight, "slab_use")

    mdl.add(mdl.pack(slab_use, production_slab, [o.weight for o in ORDERS]))


    # Minimize the total loss
    total_loss = sum([mdl.element(slab_use[s], loss) for s in range(MAX_SLABS)])
    mdl.add(mdl.minimize(total_loss))

    # Solve model
    print("Solving model....")
    msol = mdl.solve()

    print(msol)

    [1] https://raw.githubusercontent.com/IBMDecisionOptimization/docplex-examples/a26c8b05b2ab5dcbe07ded6d4658395b87737743/examples/cp/basic/steelmill.py

    Thanks,

    ------------------------------
    Louis Luo
    ------------------------------
    #DecisionOptimization


  • 2.  RE: Inconsistent bound behavior

    Posted Tue March 30, 2021 03:42 AM
    Edited by System Fri January 20, 2023 04:49 PM
    Hello Luis,

    This behaviour is not correct.
    It has already been fixed, and will be available in the next COS release.

    Anyway, this is a problem limited to the final display of bounds and gap, the optimal value and proof is correct.

    ------------------------------
    Olivier Oudot
    ------------------------------



  • 3.  RE: Inconsistent bound behavior

    Posted Tue March 30, 2021 11:05 AM
    Thank you for the prompt response, and that is good to know. Whenabout will the next COS be released?

    I have a followup issue that I thought was due to my original question, but I guess not. I noticed that in my experiments, after giving the CP model a warm starting point and after the search terminates by time limit, the resulting solve status is always 'Optimal', even though a better solution can be found by not feeding in that warm start solution. Is this also an issue that has been addressed already?

    Thanks,

    ------------------------------
    Louis Luo
    ------------------------------



  • 4.  RE: Inconsistent bound behavior

    Posted Thu April 01, 2021 03:48 AM
    Dear Louis, 

    We were able to reproduce the problem you have found. Thanks for reporting this. It is a new issue. 
    I'll keep you posted about when we will provide a fix pack that fixes these problems.

    Regards 

    Philippe

    ------------------------------
    Philippe Refalo
    IBM ILOG CP Optimizer
    ------------------------------