Class VariableUtils


  • public class VariableUtils
    extends Object

    Project: choco-solver.

    Since:
    28/04/2016.
    Author:
    Charles Prud'homme
    • Constructor Detail

      • VariableUtils

        public VariableUtils()
    • Method Detail

      • boundsForAddition

        public static int[] boundsForAddition​(IntVar... vars)
        Parameters:
        vars - array of variables
        Returns:
        computes the bounds for the sum of vars
      • boundsForScalar

        public static int[] boundsForScalar​(IntVar[] vars,
                                            int[] coeffs)
        Parameters:
        vars - array of variables
        Returns:
        computes the bounds for the sum of vars
      • boundsForAddition

        public static double[] boundsForAddition​(RealVar... vars)
        Parameters:
        vars - array of variables
        Returns:
        computes the bounds for the sum of vars
      • boundsForSubstraction

        public static int[] boundsForSubstraction​(IntVar x,
                                                  IntVar y)
        Parameters:
        x - a variable
        y - a variable
        Returns:
        computes the bounds for "x - y"
      • boundsForSubstraction

        public static double[] boundsForSubstraction​(RealVar x,
                                                     RealVar y)
        Parameters:
        x - a variable
        y - a variable
        Returns:
        computes the bounds for "x - y"
      • boundsForMultiplication

        public static int[] boundsForMultiplication​(IntVar x,
                                                    IntVar y)
        Parameters:
        x - a variable
        y - a variable
        Returns:
        computes the bounds for "x * y"
      • boundsForMultiplication

        public static double[] boundsForMultiplication​(RealVar x,
                                                       RealVar y)
        Parameters:
        x - a variable
        y - a variable
        Returns:
        computes the bounds for "x * y"
      • boundsForDivision

        public static int[] boundsForDivision​(IntVar x,
                                              IntVar y)
        Parameters:
        x - a variable
        y - a variable
        Returns:
        computes the bounds for "x / y"
      • boundsForDivision

        public static double[] boundsForDivision​(RealVar x,
                                                 RealVar y)
        Parameters:
        x - a variable
        y - a variable
        Returns:
        computes the bounds for "x / y"
      • boundsForModulo

        public static int[] boundsForModulo​(IntVar x,
                                            IntVar y)
        Parameters:
        x - a variable
        y - a variable
        Returns:
        computes the bounds for "x % y"
      • boundsForPow

        public static int[] boundsForPow​(IntVar x,
                                         IntVar y)
        Parameters:
        x - a variable
        y - a variable (we consider that lb(y) >= 0
        Returns:
        computes the bounds for "x ^ y"
      • boundsForPow

        public static double[] boundsForPow​(RealVar x,
                                            RealVar y)
        Parameters:
        x - a variable
        y - a variable
        Returns:
        computes the bounds for "x ^ y"
      • boundsForAtan2

        public static double[] boundsForAtan2​(RealVar x,
                                              RealVar y)
        Parameters:
        x - a variable
        y - a variable
        Returns:
        computes the bounds for "atan2(x , y)"
      • boundsForMinimum

        public static int[] boundsForMinimum​(IntVar... vars)
        Parameters:
        vars - array of variables
        Returns:
        computes the bounds for the minimum among vars
      • boundsForMinimum

        public static double[] boundsForMinimum​(RealVar... vars)
        Parameters:
        vars - array of variables
        Returns:
        computes the bounds for the minimum among vars
      • boundsForMaximum

        public static int[] boundsForMaximum​(IntVar... vars)
        Parameters:
        vars - array of variables
        Returns:
        computes the bounds for the maximum among vars
      • boundsForMaximum

        public static double[] boundsForMaximum​(RealVar... vars)
        Parameters:
        vars - array of variables
        Returns:
        computes the bounds for the maximum among vars
      • domainCardinality

        public static long domainCardinality​(IntVar... vars)
        Parameters:
        vars - an array of variables
        Returns:
        the variables' domain cardinality or Integer.MAX_VALUE if too large.
      • searchSpaceSize

        public static double searchSpaceSize​(IntVar[] vars)
        Compute the search space size
        Returns:
        search space size
      • intersect

        public static boolean intersect​(IntVar x,
                                        IntVar y)
        Parameters:
        x - an int variable
        y - another int variable
        Returns:
        true if the two domains intersect
      • toIntVar

        public static IntVar[] toIntVar​(Model model,
                                        int... values)
        Transform an array of int to an array of fixed IntVar
        Parameters:
        values - array of ints
        model - model to create IntVar
        Returns:
      • isConstant

        public static boolean isConstant​(Variable var)
        Parameters:
        var - a variable
        Returns:
        true if the variable is a constant, based on its type, false otherwise
      • isView

        public static boolean isView​(Variable var)
        Parameters:
        var - a variable
        Returns:
        true if the variable is a view, based on its type, false otherwise
      • isReal

        public static boolean isReal​(Variable var)
        Parameters:
        var - a variable
        Returns:
        true if the variable is a real variable, based on its kind, false otherwise