Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  IloTupleSet.add() returns wrong tuple

    Posted 05/25/16 10:34 PM

    Originally posted by: isczg


    Hi all,

    The ref doc states that IloTupleSet.add() method will return the tuple added or already existing, but I find it is not the case for "sorted" tuple sets.

    Please run the following code, then you'll find that the return value not always equals the added value.

    tuple T {
      key string s;
      int a;
    }
    sorted {T} ts;

    execute {
      for (var i=0; i<100; i++) {
        var obj = ts.add(i.toString(), i);
        if (obj.a != i)  writeln(obj);  
      }
    }

    My Cplex Studio version is 12.6.0, and does  the problem above exist in newer version?

    Is that a bug or just an implementary option forgotten to write on the doc?

     


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 2.  Re: IloTupleSet.add() returns wrong tuple

    Posted 05/26/16 04:46 AM

    Hi,

    as a workaround you could write:

    tuple T {
      key string s;
      int a;
    }
    {T} ts;

    execute {
      for (var i=0; i<100; i++) {
        var obj = ts.add(i.toString(), i);
        if (obj.a != i)  writeln(obj,i);  
      }
    }

    sorted {T} ts2={i | i in ts};

    execute
    {
    ts2;
    }

    regards


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 3.  Re: IloTupleSet.add() returns wrong tuple

    Posted 05/26/16 05:28 AM

    Originally posted by: isczg


    Alex,

    Thank you for the quick reply.

    The example I wrote is a simplified one. The actual situation is much more complicated, such as storing the returned tuple of add() as an attribute of  other tuples and using the sorted set as index for kinds of arrays.  Anyway, there's always workarounds. I just wonder if they have fixed the bug(if it's really a bug) in the 12.6.3 release.

    Regards


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 4.  Re: IloTupleSet.add() returns wrong tuple

    Posted 05/26/16 05:33 AM

    Hi,

    this is not ok in 12.6.3 unfortunately.

    Using an ordered set is not possible for you ? (This is the overall workaround I suggested)

    regards

    PS: are you a commercial user or a researcher ?


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 5.  Re: IloTupleSet.add() returns wrong tuple

    Posted 05/26/16 05:50 AM

    Originally posted by: isczg


    Hello,

    I want  sorted set for indexing purpose. I've sorted the ordered set using javascript sort() function after all tuples'd been added to the set, just like the workaround you suggested.

    I'm a commercial user.

    regards


    #DecisionOptimization
    #OPLusingCPOptimizer


  • 6.  Re: IloTupleSet.add() returns wrong tuple

    Posted 05/26/16 05:52 AM