diff --git a/com/google/ortools/constraintsolver/samples/LeastDiff.java b/com/google/ortools/constraintsolver/samples/LeastDiff.java new file mode 100644 index 0000000000..3e22d6b4f7 --- /dev/null +++ b/com/google/ortools/constraintsolver/samples/LeastDiff.java @@ -0,0 +1,115 @@ +// Copyright 2011 Hakan Kjellerstrand hakank@bonetmail.com +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.ortools.constraintsolver.samples; + +import java.io.*; +import java.util.*; +import java.text.*; + +import com.google.ortools.constraintsolver.DecisionBuilder; +import com.google.ortools.constraintsolver.IntVar; +import com.google.ortools.constraintsolver.Solver; +import com.google.ortools.constraintsolver.*; + +public class LeastDiff { + + static { + System.loadLibrary("jniconstraintsolver"); + } + + + /** + * + * Solves the Least Diff problem. + * See http://www.hakank.org/google_or_tools/least_diff.py + * + */ + private static void solve() { + int base = 10; + + Solver solver = new Solver("LeastDiff"); + + // + // Variables + // + IntVar a = solver.makeIntVar(0, base-1, "a"); + IntVar b = solver.makeIntVar(0, base-1, "b"); + IntVar c = solver.makeIntVar(0, base-1, "c"); + IntVar d = solver.makeIntVar(0, base-1, "d"); + IntVar e = solver.makeIntVar(0, base-1, "e"); + + IntVar f = solver.makeIntVar(0, base-1, "f"); + IntVar g = solver.makeIntVar(0, base-1, "g"); + IntVar h = solver.makeIntVar(0, base-1, "h"); + IntVar i = solver.makeIntVar(0, base-1, "i"); + IntVar j = solver.makeIntVar(0, base-1, "j"); + + IntVar[] all = {a,b,c,d,e,f,g,h,i,j}; + + IntVar x = solver.makeIntVar(0, 99999, "x"); + IntVar y = solver.makeIntVar(0, 99999, "y"); + IntVar diff = solver.makeIntVar(0, 99999, "y"); + + // + // Constraints + // + int [] coeffs = {10000, 1000, 100, 10, 1}; + solver.addConstraint(solver.makeEquality(x, + solver.makeScalProd(new IntVar[]{a,b,c,d,e}, coeffs).Var())); + solver.addConstraint(solver.makeEquality(y, + solver.makeScalProd(new IntVar[]{f,g,h,i,j}, coeffs).Var())); + + // a > 0 + solver.addConstraint(solver.makeGreater(a, 0)); + // f > 0 + solver.addConstraint(solver.makeGreater(f, 0)); + + // diff = x - y + solver.addConstraint( + solver.makeEquality(diff.Var(), + solver.makeDifference(x, y).Var())); + + solver.addConstraint(solver.makeAllDifferent(all, true)); + + // + // Objective + // + OptimizeVar obj = solver.makeMinimize(diff, 1); + + // + // Search + // + DecisionBuilder db = solver.makePhase(all, + solver.CHOOSE_PATH, + solver.ASSIGN_MIN_VALUE); + solver.newSearch(db, obj); + while (solver.nextSolution()) { + System.out.println("" + x.value() + "-" + + y.value() + "=" + diff.value()); + } + solver.endSearch(); + + // Statistics + System.out.println(); + System.out.println("Solutions: " + solver.solutions()); + System.out.println("Failures: " + solver.failures()); + System.out.println("Branches: " + solver.branches()); + System.out.println("Wall time: " + solver.wall_time() + "ms"); + + } + + public static void main(String[] args) throws Exception { + LeastDiff.solve(); + } +} diff --git a/com/google/ortools/constraintsolver/samples/MagicSquare.java b/com/google/ortools/constraintsolver/samples/MagicSquare.java new file mode 100644 index 0000000000..d398e7fc5b --- /dev/null +++ b/com/google/ortools/constraintsolver/samples/MagicSquare.java @@ -0,0 +1,145 @@ +// Copyright 2011 Hakan Kjellerstrand hakank@bonetmail.com +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.ortools.constraintsolver.samples; + +import java.io.*; +import java.util.*; +import java.text.*; + +import com.google.ortools.constraintsolver.DecisionBuilder; +import com.google.ortools.constraintsolver.IntVar; +import com.google.ortools.constraintsolver.Solver; + +public class MagicSquare { + + static { + System.loadLibrary("jniconstraintsolver"); + } + + + /** + * + * Solves the Magic Square problem. + * See http://www.hakank.org/google_or_tools/magic_square.py + * + */ + private static void solve(int n, int num) { + + Solver solver = new Solver("MagicSquare"); + + System.out.println("n: " + n); + + // + // variables + // + IntVar x[][] = new IntVar[n][n]; + + // for the branching + IntVar x_flat[] = new IntVar[n*n]; + + // + // constraints + // + long s = (n*(n*n+1))/2; + System.out.println("s: " + s); + // IntVar s = solver.makeIntVar(0, n*n*n, "s"); + + ArrayList diag1 = new ArrayList(); + ArrayList diag2 = new ArrayList(); + for(int i = 0; i < n; i++) { + ArrayList row = new ArrayList(); + for(int j = 0; j < n; j++) { + x[i][j] = solver.makeIntVar(1, n*n, "x["+i+","+j+"]"); + x_flat[i*n+j] = x[i][j]; + + row.add(x[i][j]); + } + // sum row to s + solver.addConstraint( + solver.makeSumEquality(row.toArray(new IntVar[1]), s)); + + diag1.add(x[i][i]); + diag2.add(x[i][n-i-1]); + + } + // sum diagonals to s + solver.addConstraint( + solver.makeSumEquality(diag1.toArray(new IntVar[1]), s)); + solver.addConstraint( + solver.makeSumEquality(diag2.toArray(new IntVar[1]), s)); + + // sum columns to s + for(int j = 0; j < n; j++) { + ArrayList col = new ArrayList(); + for(int i = 0; i < n; i++) { + col.add(x[i][j]); + } + solver.addConstraint( + solver.makeSumEquality(col.toArray(new IntVar[1]), s)); + } + + // all are different + solver.addConstraint(solver.makeAllDifferent(x_flat, true)); + + // symmetry breaking: upper left is 1 + // solver.addConstraint(solver.makeEquality(x[0][0], 1)); + + + // + // Solve + // + DecisionBuilder db = solver.makePhase(x_flat, + solver.CHOOSE_FIRST_UNBOUND, + solver.ASSIGN_CENTER_VALUE); + solver.newSearch(db); + int c = 0; + while (solver.nextSolution()) { + for(int i = 0; i < n; i++) { + for(int j = 0; j < n; j++) { + System.out.print(x[i][j].value() + " "); + } + System.out.println(); + } + System.out.println(); + c++; + if (num > 0 && c >= num) { + break; + } + } + solver.endSearch(); + + // Statistics + System.out.println(); + System.out.println("Solutions: " + solver.solutions()); + System.out.println("Failures: " + solver.failures()); + System.out.println("Branches: " + solver.branches()); + System.out.println("Wall time: " + solver.wall_time() + "ms"); + + } + + public static void main(String[] args) throws Exception { + int n = 4; + int num = 0; + + if (args.length > 0) { + n = Integer.parseInt(args[0]); + } + + if (args.length > 1) { + num = Integer.parseInt(args[1]); + } + + MagicSquare.solve(n, num); + } +} diff --git a/com/google/ortools/constraintsolver/samples/NQueens.java b/com/google/ortools/constraintsolver/samples/NQueens.java new file mode 100644 index 0000000000..4b5ef2492d --- /dev/null +++ b/com/google/ortools/constraintsolver/samples/NQueens.java @@ -0,0 +1,122 @@ +// Copyright 2011 Hakan Kjellerstrand hakank@bonetmail.com +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.ortools.constraintsolver.samples; + +import java.io.*; +import java.util.*; +import java.text.*; + +import com.google.ortools.constraintsolver.DecisionBuilder; +import com.google.ortools.constraintsolver.IntVar; +import com.google.ortools.constraintsolver.Solver; + +public class NQueens { + + static { + System.loadLibrary("jniconstraintsolver"); + } + + + /** + * + * Solves the N Queens problem. + * See http://www.hakank.org/google_or_tools/nqueens2.py + * + */ + private static void solve(int n, int num, int print) { + + Solver solver = new Solver("NQueens"); + + System.out.println("n: " + n); + + // + // variables + // + IntVar[] q = solver.makeIntVarArray(n, 0, n-1, "q"); + + // + // constraints + // + solver.addConstraint(solver.makeAllDifferent(q, true)); + + IntVar b = solver.makeIntVar(1, 1, "b"); + IntVar[] q1 = new IntVar[n]; + IntVar[] q2 = new IntVar[n]; + for(int i = 0; i < n; i++) { + for(int j = 0; j < i; j++) { + // // q[i]+i != q[j]+j + solver.addConstraint( + solver.makeNonEquality( + solver.makeSum(q[i],i).Var(), + solver.makeSum(q[j],j).Var())); + + // q[i]-i != q[j]-j + solver.addConstraint( + solver.makeNonEquality(solver.makeSum(q[i],-i).Var(), + solver.makeSum(q[j],-j).Var())); + } + } + + // + // Solve + // + DecisionBuilder db = solver.makePhase(q, + solver.CHOOSE_MIN_SIZE_LOWEST_MAX, + solver.ASSIGN_CENTER_VALUE); + solver.newSearch(db); + int c = 0; + while (solver.nextSolution()) { + if (print != 0) { + for(int i = 0; i < n; i++) { + System.out.print(q[i].value() + " "); + } + System.out.println(); + } + c++; + if (num > 0 && c >= num) { + break; + } + } + solver.endSearch(); + + // Statistics + System.out.println(); + System.out.println("Solutions: " + solver.solutions()); + System.out.println("Failures: " + solver.failures()); + System.out.println("Branches: " + solver.branches()); + System.out.println("Wall time: " + solver.wall_time() + "ms"); + + } + + public static void main(String[] args) throws Exception { + int n = 8; + int num = 0; + int print = 1; + + if (args.length > 0) { + n = Integer.parseInt(args[0]); + } + + if (args.length > 1) { + num = Integer.parseInt(args[1]); + } + + if (args.length > 2) { + print = Integer.parseInt(args[2]); + } + + + NQueens.solve(n, num, print); + } +} diff --git a/com/google/ortools/constraintsolver/samples/NQueens2.java b/com/google/ortools/constraintsolver/samples/NQueens2.java new file mode 100644 index 0000000000..da9e9d934a --- /dev/null +++ b/com/google/ortools/constraintsolver/samples/NQueens2.java @@ -0,0 +1,114 @@ +// Copyright 2011 Hakan Kjellerstrand hakank@bonetmail.com +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.ortools.constraintsolver.samples; + +import java.io.*; +import java.util.*; +import java.text.*; + +import com.google.ortools.constraintsolver.DecisionBuilder; +import com.google.ortools.constraintsolver.IntVar; +import com.google.ortools.constraintsolver.Solver; + +public class NQueens2 { + + static { + System.loadLibrary("jniconstraintsolver"); + } + + + /** + * + * Solves the N Queens problem. + * See http://www.hakank.org/google_or_tools/nqueens2.py + * + */ + private static void solve(int n, int num, int print) { + + Solver solver = new Solver("NQueens"); + + System.out.println("n: " + n); + + // + // variables + // + IntVar[] q = solver.makeIntVarArray(n, 0, n-1, "q"); + + // + // constraints + // + solver.addConstraint(solver.makeAllDifferent(q, true)); + + IntVar b = solver.makeIntVar(1, 1, "b"); + IntVar[] q1 = new IntVar[n]; + IntVar[] q2 = new IntVar[n]; + for(int i = 0; i < n; i++) { + q1[i] = solver.makeSum(q[i],i).Var(); + q2[i] = solver.makeSum(q[i],-i).Var(); + } + solver.addConstraint(solver.makeAllDifferent(q1, true)); + solver.addConstraint(solver.makeAllDifferent(q2, true)); + + // + // Solve + // + DecisionBuilder db = solver.makePhase(q, + solver.CHOOSE_MIN_SIZE_LOWEST_MAX, + solver.ASSIGN_CENTER_VALUE); + solver.newSearch(db); + int c = 0; + while (solver.nextSolution()) { + if (print != 0) { + for(int i = 0; i < n; i++) { + System.out.print(q[i].value() + " "); + } + System.out.println(); + } + c++; + if (num > 0 && c >= num) { + break; + } + } + solver.endSearch(); + + // Statistics + System.out.println(); + System.out.println("Solutions: " + solver.solutions()); + System.out.println("Failures: " + solver.failures()); + System.out.println("Branches: " + solver.branches()); + System.out.println("Wall time: " + solver.wall_time() + "ms"); + + } + + public static void main(String[] args) throws Exception { + int n = 8; + int num = 0; + int print = 1; + + if (args.length > 0) { + n = Integer.parseInt(args[0]); + } + + if (args.length > 1) { + num = Integer.parseInt(args[1]); + } + + if (args.length > 2) { + print = Integer.parseInt(args[2]); + } + + + NQueens2.solve(n, num, print); + } +} diff --git a/com/google/ortools/constraintsolver/samples/SendMoreMoney.java b/com/google/ortools/constraintsolver/samples/SendMoreMoney.java new file mode 100644 index 0000000000..511fbe9983 --- /dev/null +++ b/com/google/ortools/constraintsolver/samples/SendMoreMoney.java @@ -0,0 +1,96 @@ +// Copyright 2011 Hakan Kjellerstrand hakank@bonetmail.com +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.ortools.constraintsolver.samples; + +import java.io.*; +import java.util.*; +import java.text.*; + +import com.google.ortools.constraintsolver.DecisionBuilder; +import com.google.ortools.constraintsolver.IntVar; +import com.google.ortools.constraintsolver.Solver; + +public class SendMoreMoney { + + static { + System.loadLibrary("jniconstraintsolver"); + } + + + /** + * + * Solves the SEND+MORE=MONEY problem. + * + */ + private static void solve() { + int base = 10; + + Solver solver = new Solver("SendMoreMoney"); + IntVar s = solver.makeIntVar(0, base-1, "s"); + IntVar e = solver.makeIntVar(0, base-1, "e"); + IntVar n = solver.makeIntVar(0, base-1, "n"); + IntVar d = solver.makeIntVar(0, base-1, "d"); + IntVar m = solver.makeIntVar(0, base-1, "m"); + IntVar o = solver.makeIntVar(0, base-1, "o"); + IntVar r = solver.makeIntVar(0, base-1, "r"); + IntVar y = solver.makeIntVar(0, base-1, "y"); + + IntVar[] x = {s,e,n,d,m,o,r,y}; + + IntVar[] eq = {s,e,n,d, m,o,r,e, m,o,n,e,y}; + int[] coeffs = {1000, 100, 10, 1, // S E N D + + 1000, 100, 10, 1, // M O R E + -10000,-1000, -100,-10,-1 // == M O N E Y + }; + solver.addConstraint(solver.makeScalProdEquality(eq, coeffs, 0)); + + // alternative: + solver.addConstraint( + solver.makeScalProdEquality(new IntVar[] {s,e,n,d, m,o,r,e, m,o,n,e,y}, + new int[] {1000, 100, 10, 1, + 1000, 100, 10, 1, + -10000,-1000, -100,-10,-1}, 0)); + + // s > 0 + solver.addConstraint(solver.makeGreater(s, 0)); + // m > 0 + solver.addConstraint(solver.makeGreater(m, 0)); + + solver.addConstraint(solver.makeAllDifferent(x, true)); + + DecisionBuilder db = solver.makePhase(x, + solver.INT_VAR_DEFAULT, + solver.INT_VALUE_DEFAULT); + solver.newSearch(db); + while (solver.nextSolution()) { + for(int i = 0; i < 8; i++) { + System.out.print(x[i].toString() + " "); + } + System.out.println(); + } + solver.endSearch(); + + // Statistics + System.out.println(); + System.out.println("Solutions: " + solver.solutions()); + System.out.println("Failures: " + solver.failures()); + System.out.println("Branches: " + solver.branches()); + System.out.println("Wall time: " + solver.wall_time() + "ms"); + + } + + public static void main(String[] args) throws Exception { + SendMoreMoney.solve(); + } +} diff --git a/com/google/ortools/constraintsolver/samples/SendMoreMoney2.java b/com/google/ortools/constraintsolver/samples/SendMoreMoney2.java new file mode 100644 index 0000000000..e665bb00de --- /dev/null +++ b/com/google/ortools/constraintsolver/samples/SendMoreMoney2.java @@ -0,0 +1,221 @@ +// Copyright 2011 Hakan Kjellerstrand hakank@bonetmail.com +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package com.google.ortools.constraintsolver.samples; + +import java.io.*; +import java.util.*; +import java.text.*; + +import com.google.ortools.constraintsolver.DecisionBuilder; +import com.google.ortools.constraintsolver.IntVar; +import com.google.ortools.constraintsolver.Solver; +import com.google.ortools.constraintsolver.*; +import com.google.ortools.constraintsolver.Solver.*; + +public class SendMoreMoney2 { + + static Solver sol; + + static { + System.loadLibrary("jniconstraintsolver"); + } + + // + // Some helper methods + // + static IntExpr p(IntExpr a, int b, IntExpr c) { + return sol.makeSum(sol.makeProd(a, b), c); + } + + static IntExpr p(IntVar a, int b) { + return sol.makeProd(a, b); + } + + // a slighly more intelligent scalar product + static IntExpr sp(IntVar[] a) { + int len = a.length; + int c = 1; + int[] t = new int[len]; + for(int i = len-1; i >= 0; i--) { + t[i] = c; + c *= 10; + } + return sol.makeScalProd(a, t); + } + + + /** + * + * Solves the SEND+MORE=MONEY problem with different approaches. + * + */ + private static void solve(int alt) { + + sol = new Solver("SendMoreMoney"); + + int base = 10; + + // + // variables + // + IntVar s = sol.makeIntVar(0, base-1, "s"); + IntVar e = sol.makeIntVar(0, base-1, "e"); + IntVar n = sol.makeIntVar(0, base-1, "n"); + IntVar d = sol.makeIntVar(0, base-1, "d"); + IntVar m = sol.makeIntVar(0, base-1, "m"); + IntVar o = sol.makeIntVar(0, base-1, "o"); + IntVar r = sol.makeIntVar(0, base-1, "r"); + IntVar y = sol.makeIntVar(0, base-1, "y"); + + IntVar[] x = {s,e,n,d,m,o,r,y}; + + // + // Constraints + // + + /* + * + * Below are some alternatives encodings of the + * same idea: + * + * 1000*s + 100*e + 10*n + d + + * 1000*m + 100*o + 10*r + e == + * 10000*m + 1000*o + 100*n + 10*e + y + * + */ + + + if (alt == 0) { + // + // First, a version approach which is just too noisy. + // + sol.addConstraint( + sol.makeEquality( + sol.makeSum(sol.makeSum( + sol.makeProd(s,1000), + sol.makeSum(sol.makeProd(e,100), + sol.makeSum(sol.makeProd(n,10), + sol.makeProd(d,1)))), + sol.makeSum( + sol.makeProd(m,1000), + sol.makeSum(sol.makeProd(o,100), + sol.makeSum(sol.makeProd(r,10), + sol.makeProd(e,1)))) + ).Var(), + sol.makeSum(sol.makeProd(m,10000), + sol.makeSum( + sol.makeProd(o,1000), + sol.makeSum( + sol.makeProd(n,100), + sol.makeSum( + sol.makeProd(e,10), + sol.makeProd(y,1))))).Var())); + + } else if (alt == 1) { + + // + // Alternative 1, using the helper methods + // + // p(IntExpr, int, IntExpr) and + // p(IntVar, int) + // + sol.addConstraint( + sol.makeEquality( + sol.makeSum(p(s,1000,p(e,100,p(n,10,p(d,1)))), + p(m,1000,p(o,100,p(r,10,p(e,1))))).Var(), + p(m,10000,p(o,1000,p(n,100,p(e,10,p(y,1))))).Var())); + + } else if (alt == 2) { + + // + // Alternative 2 + // + sol.addConstraint( + sol.makeEquality( + sol.makeSum( + sol.makeScalProd(new IntVar[] {s,e,n,d}, + new int[] {1000,100,10,1}), + sol.makeScalProd(new IntVar[] {m,o,r,e}, + new int[] {1000,100,10,1})).Var(), + sol.makeScalProd(new IntVar[] {m,o,n,e,y}, + new int[] {10000,1000,100,10,1}).Var())); + + } else if (alt == 3) { + + + // + // alternative 3: same approach as 2, with some helper methods + // + sol.addConstraint( + sol.makeEquality(sol.makeSum(sp(new IntVar[] {s,e,n,d}), + sp(new IntVar[] {m,o,r,e})).Var(), + sp(new IntVar[] {m,o,n,e,y}).Var())); + + } else if (alt == 4) { + + // + // Alternative 4, using explicit variables + // + IntExpr send = sol.makeScalProd(new IntVar[] {s,e,n,d}, + new int[] {1000,100,10,1}); + IntExpr more = sol.makeScalProd(new IntVar[] {m,o,r,e}, + new int[] {1000,100,10,1}); + IntExpr money = sol.makeScalProd(new IntVar[] {m,o,n,e,y}, + new int[] {10000,1000,100,10,1}); + sol.addConstraint( + sol.makeEquality(sol.makeSum(send, more).Var(), money.Var())); + + } + + + // s > 0 + sol.addConstraint(sol.makeGreater(s, 0)); + // m > 0 + sol.addConstraint(sol.makeGreater(m, 0)); + + sol.addConstraint(sol.makeAllDifferent(x, true)); + + // + // Search + // + DecisionBuilder db = sol.makePhase(x, + sol.INT_VAR_DEFAULT, + sol.INT_VALUE_DEFAULT); + sol.newSearch(db); + while (sol.nextSolution()) { + for(int i = 0; i < 8; i++) { + System.out.print(x[i].toString() + " "); + } + System.out.println(); + } + sol.endSearch(); + + // + // Statistics + // + System.out.println(); + System.out.println("Solutions: " + sol.solutions()); + System.out.println("Failures: " + sol.failures()); + System.out.println("Branches: " + sol.branches()); + System.out.println("Wall time: " + sol.wall_time() + "ms"); + + } + + public static void main(String[] args) throws Exception { + for (int i = 0; i < 5; i++) { + System.out.println("\nalternative #" + i); + SendMoreMoney2.solve(i); + } + } +}