Class TuplesFactory


  • public class TuplesFactory
    extends Object
    A Factory to ease generation of tuples. One may keep in mind that tuples generation directly depends on the product of domain cardinality, but also on the algorithm defines in the filter. and thus may be time consuming!
    Since:
    24/04/2014
    Author:
    Charles Prud'homme
    • Method Detail

      • generateTuples

        public static Tuples generateTuples​(TupleValidator filter,
                                            boolean feasible,
                                            int[]... doms)
        A method that generates all tuples from a set of variables and stores (and returns) the valid tuples wrt to the filter. One may keep in mind that tuples generation directly depends on the product of domain cardinality, but also on the algorithm defines in the filter.
        Parameters:
        filter - tuple validator
        feasible - are tuples feasible (or infeasible)
        doms - domains
        Returns:
        the valid tuples wrt to filter
        See Also:
        source
      • generateTuples

        public static Tuples generateTuples​(TupleValidator filter,
                                            boolean feasible,
                                            IntVar... vars)
        A method that generates all tuples from a set of variables and stores (and returns) the valid tuples wrt to the filter. One may keep in mind that tuples generation directly depends on the product of domain cardinality, but also on the algorithm defines in the filter.
        Parameters:
        filter - tuple validator
        feasible - are tuples feasible (or infeasible)
        vars - concerned variables
        Returns:
        the valid tuples wrt to filter
      • absolute

        public static Tuples absolute​(IntVar VAR1,
                                      IntVar VAR2)
        Generate valid tuples for absolute constraint: VAR1 = |VAR2|
        Returns:
        a Tuples object, reserved for a table constraint
      • arithm

        public static Tuples arithm​(IntVar VAR1,
                                    String OP,
                                    IntVar VAR2)
        Generate valid tuples for VAR1 OP VAR2, where OP in {"=", "!=", ">","<",">=","<="}
        Returns:
        a Tuples object, reserved for a table constraint
      • element

        public static Tuples element​(IntVar VALUE,
                                     int[] TABLE,
                                     IntVar INDEX,
                                     int OFFSET)
        Generate valid tuples for an element constraint : TABLE[INDEX-OFFSET] = VALUE
        Parameters:
        VALUE - an integer variable taking its value in TABLE
        TABLE - an array of integer values
        INDEX - an integer variable representing the value of VALUE in TABLE
        OFFSET - offset matching INDEX.LB and TABLE[0] (Generally 0)
        Returns:
        a Tuples object, reserved for a table constraint
      • modulo

        public static Tuples modulo​(IntVar VAR1,
                                    int m,
                                    IntVar VAR2)
        Generate valid tuples for minimum constraint: VAR1 % m = VAR2
        Returns:
        a Tuples object, reserved for a table constraint
      • power

        public static Tuples power​(IntVar VAR1,
                                   IntVar VAR2,
                                   int POWER)
        Generate valid tuples for absolute constraint: VAR1 = VAR2^POWER
        Returns:
        a Tuples object, reserved for a table constraint
      • square

        public static Tuples square​(IntVar VAR1,
                                    IntVar VAR2)
        Generate valid tuples for absolute constraint: VAR1 = VAR2^2
        Returns:
        a Tuples object, reserved for a table constraint
      • eucl_div

        public static Tuples eucl_div​(IntVar DIVIDEND,
                                      IntVar DIVISOR,
                                      IntVar RESULT)
        Generate valid tuples for euclidean division constraint: DIVIDEND / DIVISOR = RESULT, rounding towards 0
        Returns:
        a Tuples object, reserved for a table constraint
      • maximum

        public static Tuples maximum​(IntVar VAR1,
                                     IntVar VAR2,
                                     IntVar MAX)
        Generate valid tuples for minus constraint: MAX = max(VAR1,VAR2)
        Returns:
        a Tuples object, reserved for a table constraint
      • minimum

        public static Tuples minimum​(IntVar VAR1,
                                     IntVar VAR2,
                                     IntVar MIN)
        Generate valid tuples for minimum constraint: MIN = min(VAR1,VAR2)
        Returns:
        a Tuples object, reserved for a table constraint
      • modulo

        public static Tuples modulo​(IntVar VAR1,
                                    IntVar VAR2,
                                    IntVar RES)
        Generate valid tuples for minimum constraint: VAR1 % VAR2 = RES
        Returns:
        a Tuples object, reserved for a table constraint
      • minus

        public static Tuples minus​(IntVar VAR1,
                                   IntVar VAR2,
                                   IntVar RESULT)
        Generate valid tuples for minus constraint: VAR1 - VAR2 = RESULT
        Returns:
        a Tuples object, reserved for a table constraint
      • plus

        public static Tuples plus​(IntVar VAR1,
                                  IntVar VAR2,
                                  IntVar RESULT)
        Generate valid tuples for plus constraint: VAR1 + VAR2 = RESULT
        Returns:
        a Tuples object, reserved for a table constraint
      • times

        public static Tuples times​(IntVar VAR1,
                                   IntVar VAR2,
                                   IntVar RESULT)
        Generate valid tuples for times constraint: VAR1 * VAR2 = RESULT
        Returns:
        a Tuples object, reserved for a table constraint
      • allDifferent

        public static Tuples allDifferent​(IntVar... VARS)
        Generate valid tuples for allDifferent constraint
        Parameters:
        VARS - concerned variables
        Returns:
        a Tuples object, reserved for a table constraint
      • allEquals

        public static Tuples allEquals​(IntVar... VARS)
        Generate valid tuples for allEquals constraint
        Parameters:
        VARS - concerned variables
        Returns:
        a Tuples object, reserved for a table constraint
      • lex_chain_less

        public static Tuples lex_chain_less​(IntVar... VARS)
        Generate valid tuples for lexChainLess constraint
        Parameters:
        VARS - concerned variables
        Returns:
        a Tuples object, reserved for a table constraint
      • lex_chain_less_eq

        public static Tuples lex_chain_less_eq​(IntVar... VARS)
        Generate valid tuples for lexChainLessEq constraint
        Parameters:
        VARS - concerned variables
        Returns:
        a Tuples object, reserved for a table constraint
      • scalar

        public static Tuples scalar​(IntVar[] VARS,
                                    int[] COEFFS,
                                    IntVar SCALAR,
                                    int SCALAR_COEFF)
        Generate valid tuples for ∑i in |VARS|VARSi*COEFFSi OPERATOR SCALAR
        Parameters:
        VARS - concerned variables
        Returns:
        a Tuples object, reserved for a table constraint
      • scalar

        public static Tuples scalar​(IntVar[] VARS,
                                    int[] COEFFS,
                                    String OPERATOR,
                                    IntVar SCALAR,
                                    int SCALAR_COEFF,
                                    int CSTE)
        Generate valid tuples for ∑i in |VARS|VARSi*COEFFSi OPERATOR SCALAR + CSTE with OPERATOR in {"=", "!=", ">","<",">=","<="}
        Parameters:
        VARS - concerned variables
        Returns:
        a Tuples object, reserved for a table constraint
      • sum

        public static Tuples sum​(IntVar[] VARS,
                                 String OPERATOR,
                                 IntVar SUM,
                                 int CSTE)
        Generate valid tuples for ∑i in |VARS|VARSi OPERATOR SUM + CSTE with OPERATOR in {"=", "!=", ">","<",">=","<="}
        Parameters:
        VARS - concerned variables
        Returns:
        a Tuples object, reserved for a table constraint
      • canBeTupled

        public static boolean canBeTupled​(IntVar... VARS)
        Check whether the intension constraint to extension constraint substitution is enabled and can be achieved
        Parameters:
        VARS - list of variables involved
        Returns:
        a boolean