@Test(groups = "1s") public void testBoundsForMultiplication() throws Exception { int[] values = {-10,-2,-1,0,1,2,10}; int n = values.length; for(int l1 = 0; l1 < n; l1++){ for(int u1 = l1; u1 < n; u1++){ for(int l2 = 0; l2 < n; l2++){ for(int u2 = l2; u2 < n; u2++){ Model model = new Model(); IntVar x = model.intVar(values[l1], values[u1]); IntVar y = model.intVar(values[l2], values[u2]); int[] bounds = VariableUtils.boundsForMultiplication( x, y); IntVar z = model.intVar(bounds[0], bounds[1]); model.arithm(x, "*", y,"=", z).post(); model.getSolver().findAllSolutions(); Assert.assertEquals(model.getSolver().getSolutionCount(), listForMultiplication(values[l1],values[u1],values[l2],values[u2]).size()); } } } } }
public static int[] boundsForMultiplication(IntVar x, IntVar y) { return bound( x.getLB() * y.getLB(), x.getLB() * y.getUB(), x.getUB() * y.getLB(), x.getUB() * y.getUB() ); }
VariableUtils { public static int[] boundsForMultiplication(IntVar x, IntVar y) { return bound( x.getLB() * y.getLB(), x.getLB() * y.getUB(), x.getUB() * y.getLB(), x.getUB() * y.getUB() ); } }
VariableUtils { public static int[] boundsForMultiplication(IntVar x, IntVar y) { return bound( x.getLB() * y.getLB(), x.getLB() * y.getUB(), x.getUB() * y.getLB(), x.getUB() * y.getUB() ); }  }
VariableUtils { public static int[] boundsForMultiplication(IntVar x, IntVar y) { return bound( x.getLB() * y.getLB(), x.getLB() * y.getUB(), x.getUB() * y.getLB(), x.getUB() * y.getUB() ); }  static int[] boundsForAddition(IntVar... vars); static int[] boundsForScalar(IntVar[] vars, int[] coeffs); static double[] boundsForAddition(RealVar... vars); static int[] boundsForSubstraction(IntVar x, IntVar y); static double[] boundsForSubstraction(RealVar x, RealVar y); static int[] boundsForMultiplication(IntVar x, IntVar y); static double[] boundsForMultiplication(RealVar x, RealVar y); static int[] boundsForDivision(IntVar x, IntVar y); static double[] boundsForDivision(RealVar x, RealVar y); static int[] boundsForModulo(IntVar x, IntVar y); static int[] boundsForPow(IntVar x, IntVar y); static double[] boundsForPow(RealVar x, RealVar y); static double[] boundsForPow(RealVar x, double y); static double[] boundsForAtan2(RealVar x, RealVar y); static int[] boundsForMinimum(IntVar... vars); static double[] boundsForMinimum(RealVar... vars); static int[] boundsForMaximum(IntVar... vars); static double[] boundsForMaximum(RealVar... vars); static long domainCardinality(IntVar... vars); static double searchSpaceSize(IntVar[] vars); static boolean intersect(IntVar x, IntVar y); static IntVar[] toIntVar(Model model, int... values); static boolean isConstant(Variable var); static boolean isView(Variable var); static boolean isInt(Variable var); static boolean isSet(Variable var); static boolean isReal(Variable var); }
VariableUtils { public static int[] boundsForMultiplication(IntVar x, IntVar y) { return bound( x.getLB() * y.getLB(), x.getLB() * y.getUB(), x.getUB() * y.getLB(), x.getUB() * y.getUB() ); }  static int[] boundsForAddition(IntVar... vars); static int[] boundsForScalar(IntVar[] vars, int[] coeffs); static double[] boundsForAddition(RealVar... vars); static int[] boundsForSubstraction(IntVar x, IntVar y); static double[] boundsForSubstraction(RealVar x, RealVar y); static int[] boundsForMultiplication(IntVar x, IntVar y); static double[] boundsForMultiplication(RealVar x, RealVar y); static int[] boundsForDivision(IntVar x, IntVar y); static double[] boundsForDivision(RealVar x, RealVar y); static int[] boundsForModulo(IntVar x, IntVar y); static int[] boundsForPow(IntVar x, IntVar y); static double[] boundsForPow(RealVar x, RealVar y); static double[] boundsForPow(RealVar x, double y); static double[] boundsForAtan2(RealVar x, RealVar y); static int[] boundsForMinimum(IntVar... vars); static double[] boundsForMinimum(RealVar... vars); static int[] boundsForMaximum(IntVar... vars); static double[] boundsForMaximum(RealVar... vars); static long domainCardinality(IntVar... vars); static double searchSpaceSize(IntVar[] vars); static boolean intersect(IntVar x, IntVar y); static IntVar[] toIntVar(Model model, int... values); static boolean isConstant(Variable var); static boolean isView(Variable var); static boolean isInt(Variable var); static boolean isSet(Variable var); static boolean isReal(Variable var);  }