Package org.jacop.set.core
Class SetDomainValueEnumeration
- java.lang.Object
-
- org.jacop.core.ValueEnumeration
-
- org.jacop.set.core.SetDomainValueEnumeration
-
public class SetDomainValueEnumeration extends ValueEnumeration
Defines a methods for enumerating values contained in the SetDomain.- Version:
- 4.7
-
-
Constructor Summary
Constructors Constructor Description SetDomainValueEnumeration(SetDomain dom)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
domainHasChanged()
This function is called to inform enumeration of the change of the domain it enumerates over.private int
getMaxPascal(int level)
Returns the maximum place number for an element in this levelprivate IntDomain
getPascal(int level, int place)
The number of elements at each level is described by Pascal's-triangle.private int
getPascalNbr(int level, int place)
Returns the value of a specific element in Pascal's triangle.boolean
hasMoreElements()
It checks if the value enumeration has more elements.int
nextElement()
The function nextElement has to return a Set.IntDomain
nextSetElement()
Returns the next element in the SetDomain.
-
-
-
Constructor Detail
-
SetDomainValueEnumeration
public SetDomainValueEnumeration(SetDomain dom)
- Parameters:
dom
- It specifies the SetDomain for which enumeration of sets is performed.
-
-
Method Detail
-
hasMoreElements
public boolean hasMoreElements()
Description copied from class:ValueEnumeration
It checks if the value enumeration has more elements.- Specified by:
hasMoreElements
in classValueEnumeration
- Returns:
- true if more elements can be enumerated, false otherwise.
-
nextElement
public int nextElement()
The function nextElement has to return a Set. Use nextSetElement instead.- Specified by:
nextElement
in classValueEnumeration
- Returns:
- the next element.
-
nextSetElement
public IntDomain nextSetElement()
Returns the next element in the SetDomain.- Returns:
- the next element in the SetDomain.
-
domainHasChanged
public void domainHasChanged()
Description copied from class:ValueEnumeration
This function is called to inform enumeration of the change of the domain it enumerates over. The enumeration will update its private data structure and if possible adapt next element to the closest (on the right) which is still in the domain.- Specified by:
domainHasChanged
in classValueEnumeration
-
getPascal
private IntDomain getPascal(int level, int place)
The number of elements at each level is described by Pascal's-triangle. Example: domain = {{}..{1..3} glb.size = 0 lub.size = 3 the level(pascalLevel) in Pascal's-triangle: level = 3-0 (lub.size-glb.size) This level(pascalLevel) in Pascal's-triangle is 1 3 3 1 And we get the elements: level 0 : {} level 1 : {1}, {2}, {3} level 2 : {1,2}, {1,3}, {2,3} level 3 : {1,2,3} So getPascal(2,2) returns the Set {1,3}occLevel = The level in Pascal's triangle that describes how many times the first value occurs.
occPos = the position in Pascal's triangle on row occLevel that describes how many times the first value occurs
occ = the number of times the first value occurs.
- Parameters:
level
- = Number of element from the ground set(lub\glb) that should be addedplace
- = The position in this level for the wanted element- Returns:
- domain that specifies Pascal triangle element at positions (level, place)
-
getMaxPascal
private int getMaxPascal(int level)
Returns the maximum place number for an element in this level- Parameters:
level
-- Returns:
- the maximum place number for an element in this level
-
getPascalNbr
private int getPascalNbr(int level, int place)
Returns the value of a specific element in Pascal's triangle.- Parameters:
level
- The level in Pascal's triangle.place
- The position in this level of Pascal's triangle.- Returns:
- The element on this position in Pascal's triangle.
-
-