KOccurrence

class KOccurrence : public 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

See

KConstraint

Since

2016.1

Public Functions

KOccurrence(const KOccurTerm &oc, const KIntVar &v1, const bool atLeast, const bool 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(const KOccurTerm &oc, const int cste, const bool atLeast, const bool 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(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(const KOccurrence &toCopy)

Copy constructor.

virtual ~KOccurrence()

Destructor.