protected internal virtual void StartSearch() { var thisSolverStrategy = SolverStrategy; solver = new DefaultSolver(network, option); SolverStrategy = thisSolverStrategy; solution = solver.FindFirst(); }
protected internal override void StartSearch() { ClearTaboo(); var thisSolverStrategy = SolverStrategy; solver = new DefaultSolver(network, option); SolverStrategy = thisSolverStrategy; solution = solver.FindFirst(); }
protected internal virtual void StartSearch() { var thisSolverStrategy = SolverStrategy; solver = new DefaultSolver(network, option) {SolverStrategy = thisSolverStrategy}; solution = solver.FindFirst(); }
protected internal override void StartSearch() { ClearTaboo(); var solverStrategy = SolverStrategy; solver = new DefaultSolver(network, option) {SolverStrategy = solverStrategy}; solution = solver.FindFirst(); }
public void sudoku(int[][] v0) { Network net = new Network(); int n = 9; IntVariable[][] v = new IntVariable[n][]; for (int i = 0; i < n; i++) { v[i] = new IntVariable[n]; } IntVariable[] vs = new IntVariable[n]; for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) { if (v0[i][j] == 0) v[i][j] = new IntVariable(net, 1, n); else v[i][j] = new IntVariable(net, v0[i][j]); } } for (int i = 0; i < n; i++) { for (int j = 0; j < n; j++) vs[j] = v[i][j]; new NotEquals(net, vs); } for (int j = 0; j < n; j++) { for (int i = 0; i < n; i++) vs[i] = v[i][j]; new NotEquals(net, vs); } for (int i0 = 0; i0 < n; i0 += 3) { for (int j0 = 0; j0 < n; j0 += 3) { int k = 0; for (int i = i0; i < i0 + 3; i++) for (int j = j0; j < j0 + 3; j++) vs[k++] = v[i][j]; new NotEquals(net, vs); } } Solver solver = new DefaultSolver(net); Int64 timer = DateTime.Now.Ticks; //for (solver.start(); solver.waitNext(); solver.resume()) //solver.start(); //solver.waitNext(); { Solution solution = solver.FindFirst(); sol = new int[9][]; for (int i = 0; i < n; i++) { sol[i] = new int[9]; for (int j = 0; j < n; j++) { sol[i][j] = solution.GetIntValue(v[i][j]); } } } timer = DateTime.Now.Ticks - timer; solver.Stop(); Console.WriteLine("Time = " + timer / 10000); }