Decision Optimization

Decision Optimization

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

 View Only
Expand all | Collapse all

CP Optimizer - Solution Issue?

  • 1.  CP Optimizer - Solution Issue?

    Posted Thu November 06, 2025 01:47 AM

    I have a model written in IBM Ilog Script, invoking and using CP optimizer [first line is using CP;]. IBM Optimization Studio reports 1 solution, but when reviewing the variables and constraints, the values don't compute.

    For example, a decision variable (dec3) equals -10, but the two decision variables (dec1 and dec2) don't add to -10 (call this constraint1). This occurs multiple times over other constraints involving other decision variables.

    ct 1: dec1 + dec2 == dec3;

    Yet, this is the solution I'm being provided with. There is nothing displayed in the relaxation tab. I don't get any errors that might suggest the programming language used is problematic, or any other issues.

    Is this supposed to be how it works?



    ------------------------------
    Stevie Turkington
    ------------------------------


  • 2.  RE: CP Optimizer - Solution Issue?

    Posted Thu November 06, 2025 01:55 AM
    Edited by ALEX FLEISCHER Thu November 06, 2025 02:44 AM

    Hi,

    can you share a small model so that other users could try ?

    And just to be sure , do you get the same issue if you turn

    ct 1: dec1 + dec2 == dec3;

    into

     dec1 + dec2 == dec3;

    ?

    regards



    ------------------------------
    [Alex] [Fleischer]
    [Data and AI Technical Sales]
    [IBM]
    ------------------------------



  • 3.  RE: CP Optimizer - Solution Issue?

    Posted Mon November 10, 2025 03:33 PM

    Thanks, I'll give that a go.

    I am also trying to define particular values three variables can take on. These variables are also mentioned in the subject to area, and I'm getting plenty of 'not a range type' through to 'Operator not available for dexpr int - {string}.' messages trying the various ways to get this done (I have no clue what to do, and suggestions from ChatGPT and other posts in this forum haven't resulted in no errors appearing).

    How do I go about doing this in ILOG Ilog scripting language? If there are multiple parts, where does each go (eg define parameters section, define decision variables section, subject to (constraints) section.



    ------------------------------
    Stevie Turkington
    ------------------------------



  • 4.  RE: CP Optimizer - Solution Issue?

    Posted Mon November 10, 2025 04:45 PM

    Hi,

    let me share a tiny example that works fine:

    using CP;
    
    range r=1..3;
    {int} s={1,3};
    
    dvar int x;
    dvar int y in r;
    dvar int z in 1..3;
    dvar int t;
    
    subject to
    {
      x in {1,2,3};
      y==z;
      t in s;
    }

    and I shared a few OPL scripting examples at here



    ------------------------------
    [Alex] [Fleischer]
    [Data and AI Technical Sales]
    [IBM]
    ------------------------------



  • 5.  RE: CP Optimizer - Solution Issue?

    Posted Mon November 17, 2025 10:39 PM

    Thanks for your help, Alex.

    I am encountering "Opl process is not responding, you must relaunch the run configuration" an awful lot. In cmd using oplrun.exe, I think the engine is stuck at node 0 - nothing further gets displayed. I don't believe any process stops responding in the cmd instance. I give up after a while, though.

    Are there equivalent settings for CP Optimizer I can set in IDE that refer to the following suggestions: here and here #2



    ------------------------------
    Stevie Turkington
    ------------------------------



  • 6.  RE: CP Optimizer - Solution Issue?

    Posted Tue November 18, 2025 06:08 AM

    Hi,

    if you get this issue after a while you could try

    execute {
      		cp.param.FailLimit = 5000;
    }
    

    in order not to let CPOptimizer explore for too long.

    You could also set a time limit.

    You can also first try with a smaller instance.

    regards

     



    ------------------------------
    [Alex] [Fleischer]
    [Data and AI Technical Sales]
    [IBM]
    ------------------------------



  • 7.  RE: CP Optimizer - Solution Issue?

    Posted Sat November 22, 2025 10:07 PM

    I am running the model on watsonx Machine Learning. Using the same code (but now with the data in the model), I get an optimal solution but I can't find out which values got assigned to the decision variables (DV). Note, I am using 'using CP;' at the top.

    What is required to obtain this data from the solution process? It displays 3 solutions were found but all I see is what the optimal value is. I'm more interested in the values assigned to the DVs.

    Note, there is no data in the prepare data section of the scenario. That is contained in the model itself. Uploading the .dat file, associated with the model, in the prepare data section doesn't upload cleanly.

    eg: int startnum4 = ...;

    becomes

    int startnum4 = 97;



    ------------------------------
    Stevie Turkington
    ------------------------------



  • 8.  RE: CP Optimizer - Solution Issue?

    Posted Sun November 23, 2025 12:17 PM

    Hi

    in the OPL documentation you can see

    have you done that ?

    regards

    regards



    ------------------------------
    [Alex] [Fleischer]
    [Data and AI Technical Sales]
    [IBM]
    ------------------------------



  • 9.  RE: CP Optimizer - Solution Issue?

    Posted Sat December 27, 2025 12:58 PM

    I am running the code directly in watsonx (decision optimization) cloud service, not through Optimization Studio to the cloud. I still cannot see what the feasible solutions are. How can I?



    ------------------------------
    Stevie Turkington
    ------------------------------



  • 10.  RE: CP Optimizer - Solution Issue?

    Posted Mon December 29, 2025 03:55 AM

    Hi,

    you need to have your solutions in a tuple set.

    Let me give your an example with the zoo example.

    In the studio within watsonx ai, in OPL you will write

    int nbKids=300;
    float costBus40=500;
    float costBus30=400;
    dvar int+ nbBus40;
    dvar int+ nbBus30;
    minimize
     costBus40*nbBus40  +nbBus30*costBus30;
    subject to
    {
     40*nbBus40+nbBus30*30>=nbKids;
    }
    tuple res{
        key int si;
        int nb;
    }
    {res} r= {};
    execute
    {
        r.add(40,nbBus40);
        r.add(30,nbBus30);
    }

    and then you will see

    image


    ------------------------------
    [Alex] [Fleischer]
    [Data and AI Technical Sales]
    [IBM]
    ------------------------------



  • 11.  RE: CP Optimizer - Solution Issue?

    Posted Mon December 29, 2025 07:16 PM

    Thanks, Alex! I managed to get this working for my model.

    Is there any way to have all feasible solution data downloadable after the run ends (via timeout), rather than only see the most recent feasible solution?



    ------------------------------
    Stevie Turkington
    ------------------------------



  • 12.  RE: CP Optimizer - Solution Issue?

    Posted Tue December 30, 2025 03:39 AM

    Hi,

    you could either handle that through the API call or directly in OPL.

    Let me change slightly this

    using CP;
    
    
    int nbKids=300;
    float costBus40=500;
    float costBus30=400;
    
    tuple res{
        key int si;
        int nb;
    }
    {res} r= {};
         
    dvar int+ nbBus40;
    dvar int+ nbBus30;
         
    minimize
         costBus40*nbBus40  +nbBus30*costBus30;
         
    subject to
    {
         40*nbBus40+nbBus30*30>=nbKids;
    }
    
    execute
    {
        writeln("nbBus40 = ",nbBus40," and nbBus30 = ",nbBus30," and the cost is ",costBus40*nbBus40  +nbBus30*costBus30);
        r.add(nbBus40,nbBus30);
    }
    
    
    
    main
    {
    cp.param.SearchType=24;
    cp.param.workers=1;
    
    thisOplModel.generate();
    cp.startNewSearch();
    while
    (cp.next()) {  thisOplModel.postProcess(); }
    
    writeln("r = ",thisOplModel.r);
    } 

    which gives

    nbBus40 = 8 and nbBus30 = 0 and the cost is 4000
    nbBus40 = 3 and nbBus30 = 6 and the cost is 3900
    nbBus40 = 6 and nbBus30 = 2 and the cost is 3800
    r =  {<8 0> <3 6> <6 2>}
    


    ------------------------------
    [Alex] [Fleischer]
    [Data and AI Technical Sales]
    [IBM]
    ------------------------------



  • 13.  RE: CP Optimizer - Solution Issue?

    Posted Thu January 01, 2026 02:53 AM

    Happy New Year, Alex!

    Is there a way to overcome this error:

    Tuple component type not supported., "2147483647".



    ------------------------------
    Stevie Turkington
    ------------------------------



  • 14.  RE: CP Optimizer - Solution Issue?

    Posted Thu January 01, 2026 05:46 AM

    Hi

    I get the same error with

    tuple t
    {
      string a;
      string b;
    }
    
    {t} s={};
    
    execute
    {
      s.add("a",1);
      writeln(s);
    }

    This error is linked to wrong type in the tuple set

    For new issues, better to log new questions.

    Best regards



    ------------------------------
    [Alex] [Fleischer]
    [Data and AI Technical Sales]
    [IBM]
    ------------------------------



  • 15.  RE: CP Optimizer - Solution Issue?

    Posted Tue November 18, 2025 10:03 AM

    thank for you help



    ------------------------------
    Nicole Silvera
    ------------------------------



  • 16.  RE: CP Optimizer - Solution Issue?

    Posted Sat November 29, 2025 02:03 AM

    Thanks for all your help so far, Alex. Really appreciated!

    I'm using dexpr int for calculating various decision variables.

    For example:

    dexpr int c = r + 135 + (2*num1) + number12;
    dexpr int d = o + 180 + number14 + number13;
    dexpr int p = c - d;

    From this, I've used the following both as (1) dexpr int, (2) a constraint within the subject to section and (3) sometimes both:

    finalDIF = p - minusDIF

    and get mixed results. finalDIF is constrained, set as a finalDIF == (value) constraint.

    Sometimes the "Opl process is not responding, you must relaunch the run configuration" appears.

    Sometimes I get told it equals the value, but when checking it myself it does not. I've even placed p == c - d as a constraint, removing it as a dexpr int.

    At times, I'm getting strange values for p, eg 500, and minusDIF 'optimized' to be 800000. This somehow equals a positive two digit number.

    What is the best way to impose constraints on variables calculated through dexpr int (eg c, d and p), the results of equations made up of decision variables?

    When is it appropriate to use dexpr int vs a constraint?



    ------------------------------
    Stevie Turkington
    ------------------------------



  • 17.  RE: CP Optimizer - Solution Issue?

    Posted Thu December 04, 2025 04:55 AM

    Hi,

    can you post the entire model you got errors with so that other users could try ?

    Regards



    ------------------------------
    [Alex] [Fleischer]
    [Data and AI Technical Sales]
    [IBM]
    ------------------------------



  • 18.  RE: CP Optimizer - Solution Issue?

    Posted Wed November 19, 2025 09:45 AM

    It looks like the solver is giving you a technically feasible solution but not one that matches your expected constraint logic. This can happen if a constraint is being relaxed internally or if variable bounds allow unexpected values. It's worth checking whether any constraints are optional, if domains are set correctly, and testing the equation in a smaller isolated model to confirm consistency.

    I've seen similar logic-checking issues while working on workflow projects and even when editing multi-layer sequences in KineMaster, where isolating each layer helps spot the mismatch. You can also review more structured notes here: https://kinemasterzone.com/



    ------------------------------
    Jackson Alban
    ------------------------------