Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  checking if i tuple is exsiting in the set before adding it.

    Posted 01/16/09 02:49 PM

    Originally posted by: SystemAdmin


    [shadi said:]

    hello,
    i have a set if tuple (pairCst) that has the following structure:


    tuple pairCst_T {
      int i;
      int v;
      int bc;
      int DrivingTime;
      int DrivingDistance;
      int BreakTime;
      int DutyPeriod;
    };
    {pairCst_T} pairCst = {};


    How can I check if one tuple (type pairCst_T) exists before adding it to the pairCst??
    i want to add one tuple only if there is no tuple like this in the set.


    thanks in advance,
    Kshieboun Shadi
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 2.  Re: checking if i tuple is exsiting in the set before adding it.

    Posted 01/16/09 07:38 PM

    Originally posted by: SystemAdmin


    [vblanchard said:]

    Hi,

    you can use the method "find(...)" on the set of tuples and check whether it returns a tuple or null

    if (pairCst.find(t.i, t.v, t.bc,t.DrivingTime, t.DrivingDistance, t.BreakTime, t.DutyPeriod) == null)) {
      pairCst.add(t)
    }

    However, note that duplicates in the set are automatically filtered. So whether or not you test that the tuple is in the set or not before adding it, the result set will not have any duplicate (by definition of a set).
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 3.  Re: checking if i tuple is exsiting in the set before adding it.

    Posted 01/17/09 12:43 PM

    Originally posted by: SystemAdmin


    [shadi said:]

    dear vblanchard,
    thank you very much, that what i was looking for.

    Kshieboun Shadi
    #DecisionOptimization
    #OPLusingCPOptimizer


  • 4.  Re: checking if i tuple is exsiting in the set before adding it.

    Posted 01/17/09 06:01 PM

    Originally posted by: SystemAdmin


    [shadi said:]

    Dear vblanchard,
    how i can use the find method for some element in the tuple (not all),
    becuase the first element in the tuple is an index and it is uniqe, so the find function alaways return null even if all the ather element are the same.

    thanks in advance,
    Kshieboun Shadi





    #DecisionOptimization
    #OPLusingCPOptimizer