Class 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 the IpogAlgorithm 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 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 or CombinationUtil.NO_VALUE,if the value for the parameter is not set in this combination.
        Parameters:
        combinations - the combinations to be partitioned. Must not be null and all combinations must have at least enough parameters so that the partitioning parameter is contained and must not be null. At least one combination must be given
        partitioningParameter - the parameter with which the combinations will be split. Must not be smaller than zero or larger than the size of the combinations - 1
        numberOfValues - the number of values of the partitioning parameter. Must be greater than 0
        Throws:
        NullPointerException - if combinations is null or one of the contained combinations is null
        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 be null and must contain the partitioning parameter
        Throws:
        NullPointerException - if combination is null
        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 be null and must contain the partitioning parameter
        Throws:
        NullPointerException - if combination is null
        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 be null and must contain the partitioning parameter
        constraintChecker - 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 is null
        IllegalArgumentException - if the combination does not contain the partitioning parameter