(this question regards search/6.)
i wondering if there way -rather manual tracing- pause execution of search/6 every time new solution single variable found?
i accomplish further investigate happening during search in constrained models.
for example, if trying solve classic sudoku problem, , have written set of constraints , print method board, can useful print board after setting constraints, before searching, in order evaluate strongness of constraints. however, once search called solve sudoku, don't have overview of single results being built underneath unless trace.
it useful if possible in likes of:
(this abstract example)
% let's imagine (very poorly) constrained sudoku board ?- problem(sudoku),constraint(sudoku),print(sudoku). [[1,3,_,2,_,_,7,4,_], [_,2,5,_,1,_,_,_,_], [4,8,_,_,6,_,_,5,_], [_,_,_,7,8,_,2,1,_], [5,_,_,_,9,_,3,7,_], [9,_,_,_,3,_,_,_,5], [_,4,_,_,_,6,8,9,_], [_,5,3,_,_,1,4,_,_], [6,_,_,_,_,_,_,_,_]]
now search:
?- problem(sudoku),constraint(sudoku),search_pause(sudoku,bt),print(sudoku,bt). [[1,3,6,2,_,_,7,4,_], [_,2,5,_,1,_,_,_,_], [4,8,_,_,6,_,_,5,_], [_,_,_,7,8,_,2,1,_], [5,_,_,_,9,_,3,7,_], [9,_,_,_,3,_,_,_,5], [_,4,_,_,_,6,8,9,_], [_,5,3,_,_,1,4,_,_], [6,_,_,_,_,_,_,_,_]] board[1,3] = 6 backtracks = 1 more ;
using existing visualization tools
have @ visualization tools manual. can kind of matrix display want adding viewable_create/2 annotation code, , launching visualisation client tkeclipse's tools-menu.
using own instrumented search routine
you can replace indomain_xxx
choice methods in search/6 user-defined 1 can print information before and/or after propagation.
if not enough, can replace whole built-in search/6
own, not difficult, see e.g. eclipse tutorial chapter on tree search or answer this question.
tracing using data-driven facilities
using eclipse's data-driven control facilities, can quite display information when things happen variables. in simplest case on variable instantiation:
?- suspend(printf("x instantiated %w%n",[x]), 1, x->inst), writeln(start), x=3, writeln(end). start x instantiated 3 end
based on idea, can write code allows follow labeling , propagation steps when happen inside black-box search routine. see link details.
Comments
Post a Comment