Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  IlcCount Or IlcExpr

    Posted 03/10/14 08:06 PM

    Originally posted by: Trust20092009


    Hi,

    I have a vector of integers  x ={ x1, ... ,xn } and i want to express that at least one component of x must be set to "k" (I.e IloCount(x,k) >0 in a model).

    I'm looking for similar functionnality of a IloCount or IloExpr to add this constraint to a cp during search (IlcCount doesn't exist ).

    Best regards,

    S.S


    #CPOptimizer
    #DecisionOptimization


  • 2.  Re: IlcCount Or IlcExpr

    Posted 03/11/14 09:36 AM

    Originally posted by: ol


    Hello,

    you could use:

       IlcConstraint IlcCardIntEqCst(const IlcIntExp var, IlcInt val, const IlcIntVarArray vars)

    In your specific case, you could add instead a constraint like

        x1==k || x2==k || ...

    Or:

       (x1==k) + (x2==k) +  ... > 0

    in some cases they may be more efficient.

    Finally, if you have several such constraints to add which share the same variables x, it may be more efficient to add a IlcDistribute constraint grouping these constraints together.

    Regards,

    Olivier

     


    #CPOptimizer
    #DecisionOptimization


  • 3.  Re: IlcCount Or IlcExpr

    Posted 03/11/14 12:15 PM

    Originally posted by: Trust20092009


    Hello Olivier,

    Thank you for your quick reply. Effectively IlcDistribute could meet my needs.

    But i do not understand the functionning of IlcCardIntEqCst I don't find it anywhere in the cp manuel can you explain more please?

    To use x1==k || x2==k || ...  Or:    (x1==k) + (x2==k) +  ... > 0 I need an expression. that's why I'm looking for a similar functionnality of IloExpr ( i.e IlcExpr).  am I right or I may be missing something important?

    Regards,

    S.S


    #CPOptimizer
    #DecisionOptimization


  • 4.  Re: IlcCount Or IlcExpr

    Posted 03/11/14 01:17 PM

    Originally posted by: ol


     IlcConstraint IlcCardIntEqCst(const IlcIntExp var, IlcInt val, const IlcIntVarArray vars) returns a constraint that ensures that val appears var times in the array vars.

    For building an expression at the Ilc level, you are right, this is exactly as at the Ilo Level, but with IlcIntExp, for example:

    IlcIntVarArray x(m,3,1,2);

    IlcIntVar xx(m,1,3,"xx");

    IlcIntExp e = IlcIntExp(x[0]==1);

    for(IlcInt i = 1;i<3;i++) {

    e = e + (x[i]==1);

    }

     

    Regards,

    Olivier

     


    #CPOptimizer
    #DecisionOptimization


  • 5.  Re: IlcCount Or IlcExpr

    Posted 03/11/14 03:25 PM

    Originally posted by: Trust20092009


    That's  exactly what i need. Thank's a lot Olivier. Have a good day :)

    Regards,

    S.S


    #CPOptimizer
    #DecisionOptimization