@Test(groups="5m", timeOut=300000) public void test16to32() throws SetUpException { int[] size = {32, 36, 40, 44, 48, 52, 56, 60, 64}; int[] sols = {1, 1, 1, 1, 1, 1, 1, 1, 1}; for (int i = 0; i < size.length; i++) { Model sol = modeler(size[i]); sol.getSolver().solve(); Assert.assertEquals(sol.getSolver().getSolutionCount(), sols[i]); } }
@Override public void solve() { model.getSolver().solve(); StringBuilder st = new StringBuilder(); if (ESat.TRUE == model.getSolver().isFeasible()) { int sum1 = 0, sum2 = 0; int i = 0; st.append(vars[i].getValue()); sum1 += vars[i].getValue(); sum2 += vars[i].getValue() * vars[i++].getValue(); for (; i < N / 2; i++) { st.append(", ").append(vars[i].getValue()); sum1 += vars[i].getValue(); sum2 += vars[i].getValue() * vars[i].getValue(); } st.append(": (").append(sum1).append(")~(").append(sum2).append(")\n"); sum1 = sum2 = 0; st.append(vars[i].getValue()); sum1 += vars[i].getValue(); sum2 += vars[i].getValue() * vars[i++].getValue(); for (; i < N; i++) { st.append(", ").append(vars[i].getValue()); sum1 += vars[i].getValue(); sum2 += vars[i].getValue() * vars[i].getValue(); } st.append(": (").append(sum1).append(")~(").append(sum2).append(")\n"); } else { st.append("INFEASIBLE"); } System.out.println(st.toString()); }
Partition extends AbstractProblem { @Override public void solve() { model.getSolver().solve(); StringBuilder st = new StringBuilder(); if (ESat.TRUE == model.getSolver().isFeasible()) { int sum1 = 0, sum2 = 0; int i = 0; st.append(vars[i].getValue()); sum1 += vars[i].getValue(); sum2 += vars[i].getValue() * vars[i++].getValue(); for (; i < N / 2; i++) { st.append(", ").append(vars[i].getValue()); sum1 += vars[i].getValue(); sum2 += vars[i].getValue() * vars[i].getValue(); } st.append(": (").append(sum1).append(")~(").append(sum2).append(")\n"); sum1 = sum2 = 0; st.append(vars[i].getValue()); sum1 += vars[i].getValue(); sum2 += vars[i].getValue() * vars[i++].getValue(); for (; i < N; i++) { st.append(", ").append(vars[i].getValue()); sum1 += vars[i].getValue(); sum2 += vars[i].getValue() * vars[i].getValue(); } st.append(": (").append(sum1).append(")~(").append(sum2).append(")\n"); } else { st.append("INFEASIBLE"); } System.out.println(st.toString()); } }
Partition extends AbstractProblem { @Override public void solve() { model.getSolver().solve(); StringBuilder st = new StringBuilder(); if (ESat.TRUE == model.getSolver().isFeasible()) { int sum1 = 0, sum2 = 0; int i = 0; st.append(vars[i].getValue()); sum1 += vars[i].getValue(); sum2 += vars[i].getValue() * vars[i++].getValue(); for (; i < N / 2; i++) { st.append(", ").append(vars[i].getValue()); sum1 += vars[i].getValue(); sum2 += vars[i].getValue() * vars[i].getValue(); } st.append(": (").append(sum1).append(")~(").append(sum2).append(")\n"); sum1 = sum2 = 0; st.append(vars[i].getValue()); sum1 += vars[i].getValue(); sum2 += vars[i].getValue() * vars[i++].getValue(); for (; i < N; i++) { st.append(", ").append(vars[i].getValue()); sum1 += vars[i].getValue(); sum2 += vars[i].getValue() * vars[i].getValue(); } st.append(": (").append(sum1).append(")~(").append(sum2).append(")\n"); } else { st.append("INFEASIBLE"); } System.out.println(st.toString()); }  }
Partition extends AbstractProblem { @Override public void solve() { model.getSolver().solve(); StringBuilder st = new StringBuilder(); if (ESat.TRUE == model.getSolver().isFeasible()) { int sum1 = 0, sum2 = 0; int i = 0; st.append(vars[i].getValue()); sum1 += vars[i].getValue(); sum2 += vars[i].getValue() * vars[i++].getValue(); for (; i < N / 2; i++) { st.append(", ").append(vars[i].getValue()); sum1 += vars[i].getValue(); sum2 += vars[i].getValue() * vars[i].getValue(); } st.append(": (").append(sum1).append(")~(").append(sum2).append(")\n"); sum1 = sum2 = 0; st.append(vars[i].getValue()); sum1 += vars[i].getValue(); sum2 += vars[i].getValue() * vars[i++].getValue(); for (; i < N; i++) { st.append(", ").append(vars[i].getValue()); sum1 += vars[i].getValue(); sum2 += vars[i].getValue() * vars[i].getValue(); } st.append(": (").append(sum1).append(")~(").append(sum2).append(")\n"); } else { st.append("INFEASIBLE"); } System.out.println(st.toString()); }  @Override void buildModel(); @Override void configureSearch(); @Override void solve(); static void main(String[] args); }
Partition extends AbstractProblem { @Override public void solve() { model.getSolver().solve(); StringBuilder st = new StringBuilder(); if (ESat.TRUE == model.getSolver().isFeasible()) { int sum1 = 0, sum2 = 0; int i = 0; st.append(vars[i].getValue()); sum1 += vars[i].getValue(); sum2 += vars[i].getValue() * vars[i++].getValue(); for (; i < N / 2; i++) { st.append(", ").append(vars[i].getValue()); sum1 += vars[i].getValue(); sum2 += vars[i].getValue() * vars[i].getValue(); } st.append(": (").append(sum1).append(")~(").append(sum2).append(")\n"); sum1 = sum2 = 0; st.append(vars[i].getValue()); sum1 += vars[i].getValue(); sum2 += vars[i].getValue() * vars[i++].getValue(); for (; i < N; i++) { st.append(", ").append(vars[i].getValue()); sum1 += vars[i].getValue(); sum2 += vars[i].getValue() * vars[i].getValue(); } st.append(": (").append(sum1).append(")~(").append(sum2).append(")\n"); } else { st.append("INFEASIBLE"); } System.out.println(st.toString()); }  @Override void buildModel(); @Override void configureSearch(); @Override void solve(); static void main(String[] args);  }