Decision Optimization

Decision Optimization

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

 View Only
  • 1.  Obtain reduced domains after propagation in docplex.cp

    Posted Thu July 27, 2023 09:44 AM

    Hello everyone, 

    I am currently on a "bigger" constraint programming problem in doplex.cp with Python 3.10. To make sure that all constraints are propagated I set

    my_params = CpoParameters(AllDiffInferenceLevel='Extended')

    since I only use all_different constraints. Please let me know if this line is not needed or it is an incorrect usage. To then start the propagation:
    psol = model.propagate(execfile='my path to cpoptimizer')
    Now my issue arises: How do I obtain the reduced domains? My first instinct is to iterate over the domains with the domains iterator. Unfortunately this does not work 
    for d in predecessor_result[0].domain_iterator():
    gives a Value error: too many values to unpack (expected 2). Is that due to the reason that the domain of that specific variable (CpoIntVarSolution) is
    predecessor_0=((0, 1999, 'holes'),)? Unfortunately, also predecessor_result[0].domain_contains(x) gives me this error. 
    I am convinced that there is an easy way to receive the domains (only integer variables). 
    I'd be grateful for any hints or help. 
    Cheers


    ------------------------------
    Justus Kilian Wolff
    ------------------------------


  • 2.  RE: Obtain reduced domains after propagation in docplex.cp

    Posted Mon July 31, 2023 11:39 AM

    Setting AllDiffInferenceLevel to Extended ensures that CP Optimizer will achieve the strongest reduction on each alldifferent constraint of the model, that is for any value remaining in the domain of a variable appearing in an Alldiff there exists a solution to that constraint using values in the domains of the other variables. You don't need to do this to have all constraint propagated, but this gives more domain reductions at a higher computationla cost however.

    Concerning the result of propagate, you should be able to iterate over the reduced domains contained in the psol result (type CpoSolveResult). It's hard to see where the problem comes from without the model. But displaying the content of psol using write() should help. (see https://ibmdecisionoptimization.github.io/docplex-doc/cp/docplex.cp.solution.py.html#docplex.cp.solution.CpoSolveResult ).

    Regards.

    Philippe



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