Class KOccurrence


  • public class KOccurrence
    extends KConstraint
    This class creates an occurence constraint of a value in a list of variables

    Example :
    
    KIntVarArray Tab(...);
    KIntVar countVar(...);
    
    problem.post( KOccurTerm(0,Tab) <= 5 );        // No more than 5 occurence of 0 in Tab
    problem.post( KOccurTerm(1,Tab) < 5 );         // No more than 4 occurence of 1 in Tab
    problem.post( KOccurTerm(2,Tab) >= countVar ); // No Less than countVar occurence of 2 in Tab
    problem.post( KOccurTerm(3,Tab) > countVar );  // No Less than countVar occurence of 3 in Tab
    

    Since:
    2016.1
    See Also:
    KConstraint

    • Constructor Detail

      • KOccurrence

        protected KOccurrence​(long cPtr,
                              boolean cMemoryOwn)
      • KOccurrence

        public KOccurrence​(KOccurTerm oc,
                           KIntVar v1,
                           boolean atLeast,
                           boolean atMost)
        Constructor
        Parameters:
        oc - the occurence term
        v1 - the counting variable
        atLeast - constrain on inf the number of occurence Yes/No
        atMost - constrain on sup the number of occurence Yes/No
      • KOccurrence

        public KOccurrence​(KOccurTerm oc,
                           int cste,
                           boolean atLeast,
                           boolean atMost)
        Constructor
        Parameters:
        oc - the occurence term
        cste - the constant number of occurence
        atLeast - constrain on inf the number of occurence Yes/No
        atMost - constrain on sup the number of occurence Yes/No
      • KOccurrence

        public KOccurrence​(KIntVarArray variables,
                           KIntArray targets,
                           int minOccur,
                           int maxOccur)
        Constructor
        Parameters:
        variables - the variables array
        targets - the targets value to count
        minOccur - minimal number of occurrences
        maxOccur - maximal number of occurrences
      • KOccurrence

        public KOccurrence​(KOccurrence toCopy)
        Copy constructor