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.pyThanks,
------------------------------
Louis Luo
------------------------------
#DecisionOptimization