Я попытался следовать примеру решателя SlitherLink C ++ C ++ и некоторых онлайн-ресурсах для создания решателя SlitherLink в Java.
К сожалению, я продолжаю получать невозможный результат.
Я должен неправильно понимать, как использовать какую-либо руководство. /> Вот мой класс решателя: < /p>
package ortools;
import com.google.ortools.Loader;
import com.google.ortools.sat.BoolVar;
import com.google.ortools.sat.CircuitConstraint;
import com.google.ortools.sat.CpModel;
import com.google.ortools.sat.CpSolver;
import com.google.ortools.sat.CpSolverStatus;
import com.google.ortools.sat.LinearExpr;
/**
* This implements the following simple slitherlink:
* +-+-+
* | |3|
* +-+-+
* |3| |
* +-+-+
* NOTE: This slitherlink has multiple solutions. That is
* intentional so we can ensure the solver identifies such
* situations.
*/
public class SlitherlinkTest {
public void run() {
Loader.loadNativeLibraries();
CpModel model = new CpModel();
// Create the circuit
CircuitConstraint circuit = model.addCircuit();
// Create an array to hold the lines
// The entry at [i,j] holds a line from point i to point j
int numPoints = 3*3;
BoolVar[][] lines = new BoolVar[numPoints][numPoints];
// Loop over the points
for( int row=0; row
Я включил журнал, и это дало мне этот вывод: < /p>
Starting CP-SAT solver v9.14.6206
Parameters: log_search_progress: true enumerate_all_solutions: true log_to_stdout: true
Forcing presolve to keep all feasible solution given that enumerate_all_solutions is true
Initial satisfaction model '': (model_fingerprint: 0xa37d3fb182edcf5e)
#Variables: 21 (19 primary variables)
- 21 Booleans in [0,1]
#kCircuit: 1
#kLinearN: 2 (#terms: 8)
Starting presolve at 0.00s
INFEASIBLE: 'var #3 as empty domain after intersecting with [0]'
Unsat after presolving constraint #0 (warning, dump might be inconsistent): circuit { tails: 1 tails: 1 tails: 2 tails: 3 tails: 3 tails: 4 tails: 4 tails: 6 tails: 0 tails: 1 tails: 2 tails: 3 tails: 4 tails: 5 tails: 6 tails: 7 tails: 8 heads: 2 heads: 4 heads: 5 heads: 4 heads: 6 heads: 5 heads: 7 heads: 7 heads: 0 heads: 1 heads: 2 heads: 3 heads: 4 heads: 5 heads: 6 heads: 7 heads: 8 literals: 2 literals: 3 literals: 2 literals: 5 literals: 6 literals: -4 literals: -6 literals: 6 literals: 12 literals: 13 literals: -3 literals: 15 literals: 16 literals: 17 literals: -7 literals: 19 literals: 20 }
4.17e-04s 0.00e+00d [operations_research::sat::CpModelPresolver::PresolveToFixPoint]
Presolve summary:
- 6 affine relations were detected.
- rule 'affine: new relation' was applied 6 times.
- rule 'circuit: degree 2' was applied 4 times.
- rule 'circuit: fixed singleton arcs.' was applied 1 time.
- rule 'circuit: removed false arcs.' was applied 1 time.
- rule 'circuit: set literal to false.' was applied 8 times.
- rule 'exactly_one: duplicate literals' was applied 2 times.
- rule 'exactly_one: removed literals' was applied 2 times.
- rule 'exactly_one: size two' was applied 2 times.
- rule 'linear: negative equal one' was applied 2 times.
- rule 'presolve: iteration' was applied 1 time.
Problem closed by presolve.
CpSolverResponse summary:
status: INFEASIBLE
objective: NA
best_bound: NA
integers: 0
booleans: 0
conflicts: 0
branches: 0
propagations: 0
integer_propagations: 0
restarts: 0
lp_iterations: 0
walltime: 0.002724
usertime: 0.002724
deterministic_time: 0
gap_integral: 0
< /code>
Итак, у Var#3 есть проблема. Если это нулевой индексирование, то это бульвар, который представляет вертикальную полосу между двумя верхними квадратами. Он пуст после пересечения с [0], который, как я предполагаю, является линейным выражением для подсчета в правой верхней коробке. Я не вижу ничего, что помогает мне понять, почему это не работает.
Подробнее здесь: https://stackoverflow.com/questions/797 ... nk-puzzles
Написание решателя CP-SAT для SlitherLink Buzzles ⇐ JAVA
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение