Class CombinationPartitioner
- java.lang.Object
-
- de.rwth.swc.coffee4j.algorithmic.sequential.generator.ipog.CombinationPartitioner
-
public class CombinationPartitioner extends Object
Class to partition given combinations according to one parameter. This is used to make the search for fitting combinations in theIpogAlgorithm
algorithm more efficient as only some potentially matching combinations have to be searched for a match.In all methods the indexing schema described in
IpogAlgorithm
is used.
-
-
Constructor Summary
Constructors Constructor Description CombinationPartitioner(Collection<int[]> combinations, int partitioningParameter, int numberOfValues)
Creates a new combination partitioner according to the given parameter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCombination(int[] combination)
Adds the given combination to the partition determined by the value at the partitioning parameter.Optional<int[]>
extendSuitableCombination(int[] combination, ConstraintChecker constraintChecker)
Tries to find a matching combination to which the given combination can be added.void
removeCombination(int[] combination)
Removes the given combination from the partition determined by the value at the partitioning parameter.
-
-
-
Constructor Detail
-
CombinationPartitioner
public CombinationPartitioner(Collection<int[]> combinations, int partitioningParameter, int numberOfValues)
Creates a new combination partitioner according to the given parameter. This means that all given combinations are split according to the value they have for the parameter. The value can either be one of the values of the partitioning parameter orCombinationUtil.NO_VALUE
,if the value for the parameter is not set in this combination.- Parameters:
combinations
- the combinations to be partitioned. Must not benull
and all combinations must have at least enough parameters so that the partitioning parameter is contained and must not benull
. At least one combination must be givenpartitioningParameter
- the parameter with which the combinations will be split. Must not be smaller than zero or larger than the size of the combinations - 1numberOfValues
- the number of values of the partitioning parameter. Must be greater than 0- Throws:
NullPointerException
- if combinations isnull
or one of the contained combinations isnull
IllegalArgumentException
- if one of the other constraints for the method parameters is not met
-
-
Method Detail
-
addCombination
public void addCombination(int[] combination)
Adds the given combination to the partition determined by the value at the partitioning parameter.- Parameters:
combination
- the combination to be added. Must not benull
and must contain the partitioning parameter- Throws:
NullPointerException
- if combination isnull
IllegalArgumentException
- if the combination does not contain the partitioning parameter
-
removeCombination
public void removeCombination(int[] combination)
Removes the given combination from the partition determined by the value at the partitioning parameter.- Parameters:
combination
- the combination to be removed. Must not benull
and must contain the partitioning parameter- Throws:
NullPointerException
- if combination isnull
IllegalArgumentException
- if the combination does not contain the partitioning parameter
-
extendSuitableCombination
public Optional<int[]> extendSuitableCombination(int[] combination, ConstraintChecker constraintChecker)
Tries to find a matching combination to which the given combination can be added. The potential matching combination is found by looking only at combinations form partitions which can support the added combination.- Parameters:
combination
- the combination to be added to an existing combination. Must not benull
and must contain the partitioning parameterconstraintChecker
- checker that is used for extending the existing combination without creating invalid combinations.- Returns:
- the combination to which the given combination has been added
or an empty
Optional
if no match could be found - Throws:
NullPointerException
- if combination isnull
IllegalArgumentException
- if the combination does not contain the partitioning parameter
-
-