@Test(groups = "1s", timeOut = 60000) public void testImpact() throws SetUpException { Model sol; int j = 3; sol = modeler(j); sol.getSolver().setSearch(new ImpactBased((IntVar[]) sol.getSolver().getSearch().getVariables(), 2, 3, 10, 29091981L, false)); while (sol.getSolver().solve()) ; long nbsol = sol.getSolver().getSolutionCount(); long node = sol.getSolver().getNodeCount(); sol = modeler(j); sol.getSolver().setSearch(new ImpactBased((IntVar[]) sol.getSolver().getSearch().getVariables(), 2, 3, 10, 29091981L, false)); while (sol.getSolver().solve()) ; assertEquals(sol.getSolver().getSolutionCount(), nbsol); assertEquals(sol.getSolver().getNodeCount(), node); }
@Override public void solve() { model.getSolver().solve(); StringBuilder st = new StringBuilder(); String line = "+"; for (int i = 0; i < n; i++) { line += "----+"; } line += "\n"; st.append(line); for (int i = 0; i < n; i++) { st.append("|"); for (int j = 0; j < n; j++) { st.append(StringUtils.pad(vars[i * n + j].getValue() + "", -3, " ")).append(" |"); } st.append(MessageFormat.format("\n{0}", line)); } st.append("\n\n\n"); System.out.println(st.toString()); }
MagicSquare extends AbstractProblem { @Override public void solve() { model.getSolver().solve(); StringBuilder st = new StringBuilder(); String line = "+"; for (int i = 0; i < n; i++) { line += "----+"; } line += "\n"; st.append(line); for (int i = 0; i < n; i++) { st.append("|"); for (int j = 0; j < n; j++) { st.append(StringUtils.pad(vars[i * n + j].getValue() + "", -3, " ")).append(" |"); } st.append(MessageFormat.format("\n{0}", line)); } st.append("\n\n\n"); System.out.println(st.toString()); } }
MagicSquare extends AbstractProblem { @Override public void solve() { model.getSolver().solve(); StringBuilder st = new StringBuilder(); String line = "+"; for (int i = 0; i < n; i++) { line += "----+"; } line += "\n"; st.append(line); for (int i = 0; i < n; i++) { st.append("|"); for (int j = 0; j < n; j++) { st.append(StringUtils.pad(vars[i * n + j].getValue() + "", -3, " ")).append(" |"); } st.append(MessageFormat.format("\n{0}", line)); } st.append("\n\n\n"); System.out.println(st.toString()); }  }
MagicSquare extends AbstractProblem { @Override public void solve() { model.getSolver().solve(); StringBuilder st = new StringBuilder(); String line = "+"; for (int i = 0; i < n; i++) { line += "----+"; } line += "\n"; st.append(line); for (int i = 0; i < n; i++) { st.append("|"); for (int j = 0; j < n; j++) { st.append(StringUtils.pad(vars[i * n + j].getValue() + "", -3, " ")).append(" |"); } st.append(MessageFormat.format("\n{0}", line)); } st.append("\n\n\n"); System.out.println(st.toString()); }  @Override void buildModel(); @Override void configureSearch(); @Override void solve(); static void main(String[] args); }
MagicSquare extends AbstractProblem { @Override public void solve() { model.getSolver().solve(); StringBuilder st = new StringBuilder(); String line = "+"; for (int i = 0; i < n; i++) { line += "----+"; } line += "\n"; st.append(line); for (int i = 0; i < n; i++) { st.append("|"); for (int j = 0; j < n; j++) { st.append(StringUtils.pad(vars[i * n + j].getValue() + "", -3, " ")).append(" |"); } st.append(MessageFormat.format("\n{0}", line)); } st.append("\n\n\n"); System.out.println(st.toString()); }  @Override void buildModel(); @Override void configureSearch(); @Override void solve(); static void main(String[] args);  }