### Question:
GateTranslator extends SolverDecorator<ISolver> { public void optimisationFunction(IVecInt literals, IVec<BigInteger> coefs, IVecInt result) throws ContradictionException { IVec<IVecInt> buckets = new Vec<IVecInt>(); IVecInt bucket; for (int i = 0; i < literals.size(); i++) { int p = literals.get(i); BigInteger a = coefs.get(i); for (int j = 0; j < a.bitLength(); j++) { bucket = createIfNull(buckets, j); if (a.testBit(j)) { bucket.push(p); } } } int x, y, z; int sum, carry; for (int i = 0; i < buckets.size(); i++) { bucket = buckets.get(i); while (bucket.size() >= 3) { x = bucket.get(0); y = bucket.get(1); z = bucket.get(2); bucket.remove(x); bucket.remove(y); bucket.remove(z); sum = nextFreeVarId(true); carry = nextFreeVarId(true); fullAdderSum(sum, x, y, z); fullAdderCarry(carry, x, y, z); additionalFullAdderConstraints(carry, sum, x, y, z); bucket.push(sum); createIfNull(buckets, i + 1).push(carry); } while (bucket.size() == 2) { x = bucket.get(0); y = bucket.get(1); bucket.remove(x); bucket.remove(y); sum = nextFreeVarId(true); carry = nextFreeVarId(true); halfAdderSum(sum, x, y); halfAdderCarry(carry, x, y); bucket.push(sum); createIfNull(buckets, i + 1).push(carry); } assert bucket.size() == 1; result.push(bucket.last()); bucket.pop(); assert bucket.isEmpty(); } } GateTranslator(ISolver solver); IConstr gateFalse(int y); IConstr gateTrue(int y); IConstr[] ite(int y, int x1, int x2, int x3); IConstr[] it(int y, int x1, int x2); IConstr[] and(int y, IVecInt literals); IConstr[] and(int y, int x1, int x2); IConstr[] or(int y, IVecInt literals); IConstr[] halfOr(int y, IVecInt literals); IConstr[] not(int y, int x); IConstr[] xor(int y, IVecInt literals); IConstr[] iff(int y, IVecInt literals); void xor(int x, int a, int b); void fullAdderSum(int x, int a, int b, int c); void fullAdderCarry(int x, int a, int b, int c); void additionalFullAdderConstraints(int xcarry, int xsum, int a,
            int b, int c); void halfAdderSum(int x, int a, int b); void halfAdderCarry(int x, int a, int b); void optimisationFunction(IVecInt literals, IVec<BigInteger> coefs,
            IVecInt result);  }### Answer:
@Test public void testTwoValues() throws ContradictionException { IVecInt literals = new VecInt().push(1).push(2); IVec<BigInteger> coefs = new Vec<BigInteger>().push( BigInteger.valueOf(3)).push(BigInteger.valueOf(6)); IVecInt result = new VecInt(); this.gator.optimisationFunction(literals, coefs, result); System.out.println(result); assertEquals(4, result.size()); }