Decision Optimization

Decision Optimization

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


#Analytics
#DecisionOptimization
#DecisionOptimization
 View Only
  • 1.  count constraint on a tupleset constrained variable

    Posted 06/07/19 10:08 AM

    Originally posted by: Fab10


    Hi,

    assume I have intvararray variables X,Y and Z for which i define an allowedAssignments constraint.

    I also have an intvarMatrix variable K which should be made up with a fixed number of copies of X,Y and Z (say 3, 2 and 1).

    Is there a simple way to constrain the K variable to include exactly the number of copies of X,Y and Z i would like? (somehow similar to the COUNT constraint)

    Thank you.

    Fabio


    #CPOptimizer
    #DecisionOptimization


  • 2.  Re: count constraint on a tupleset constrained variable

    Posted 06/09/19 04:03 AM

    Originally posted by: Fab10


    Hi.

    To better explain my previous post, I would like to set the multiplicity of each allowed assignment of my variable X to a defined value in my variable K, much like I can do with the COUNT constraint with integer variables.

    Thanks.

    Fabio

     


    #CPOptimizer
    #DecisionOptimization


  • 3.  Re: count constraint on a tupleset constrained variable

    Posted 06/11/19 03:38 AM

    Originally posted by: Philippe_Refalo


    The simplest way to express your constraints is to use constraints as expressions. For the sake of simplicity, assume that K is an array, you can count and restrict the number of variables of K having the same value of X this way

    (X == K[0]) + (X == K[1]) + .... + (X == K[n]) == C

    I your case C is equal to 3.

    Is that the constraint that you want to state ? 

    It might be better for the search strategy to start to instantiate the X,Y and Z variables before the K variables to discover dead-ends earlier but it depends on other constraints of your model. 


    #CPOptimizer
    #DecisionOptimization


  • 4.  Re: count constraint on a tupleset constrained variable

    Posted 06/13/19 04:47 AM

    Originally posted by: Fab10


    Thank you for the suggestion.

    I almost did what you proposed using "&&" instead of "+" 

    (X == K[0]) && (X == K[1]) && .... && (X == K[n]) == C

    where C is an IloBoolVar (I need it for other constraints)

     

    Fabio


    #CPOptimizer
    #DecisionOptimization