?- findall(X,between(1,400,X),L), findall(X,between(1,300,X),R), time(zdd_map(L, R, _)).
% 240,802 inferences, 0.062 CPU in 0.071 seconds (87% CPU, 3890618 Lips)
L = [1, 2, 3, 4, 5, 6, 7, 8, 9|...],
R = [1, 2, 3, 4, 5, 6, 7, 8, 9|...].
?- findall(X,between(1,200,X),L), findall(X,between(1,600,X),R), time(zdd_map(L, R, _)).
% 240,402 inferences, 0.064 CPU in 0.073 seconds (88% CPU, 3734806 Lips)
L = [1, 2, 3, 4, 5, 6, 7, 8, 9|...],
R = [1, 2, 3, 4, 5, 6, 7, 8, 9|...].
Code:
On May 19, 2018, at 0:01, j4n bur53 <janb...@xlog.ch> wrote:Well what the ROZ is doing is a blackbox, its only the
predicate cofact/2. It can be anything, provided it preserves
On May 19, 2018, at 1:46, j4n bur53 <janb...@xlog.ch> wrote:
An important property of the usuall R-O-BDD, is that the
reduction and ordering gives unique normal forms.
So you have this theorem for any variable ordering O:
A = B /* logical equivalent */
-- if and only-if --
ROBDD(O,A) == ROBDD(O,B) /* syntactic equivalent */
--
You received this message because you are subscribed to the Google Groups "SWI-Prolog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swi-prolog+...@googlegroups.com.
?- fun1(A,B,C), labeling([A,B,C]), write(A-B-C), nl, fail; true. 0-1-0 1-0-0 1-1-0 0-0-1 Yes
?- fun2(A,B,C), labeling([A,B,C]), write(A-B-C), nl, fail; true. 1-0-0 1-1-0 0-0-1 0-1-1 Yes
fun1: Missing Functional Dependency Confirmed
?- test(fun1). No
?- test(fun2). YesI guess you can use this for deep learning. Ha Ha.
:- use_module(library(finite/clpb)).
fun1(A,B,C) :- sat(C=:=(~A)*(~B)).
fun2(A,_,C) :- sat(C=:=(~A)).
test(F) :-
call(F,A,B,0),
call(F,A,C,1),
labeling([A,B,C]), !, fail.
test(_).
On May 20, 2018, at 0:28, Fernando Sáenz Pérez <fsaen...@gmail.com> wrote:Hi Kuniaki,In Windows 10 64 bit it seems to work:Welcome to SWI-Prolog (threaded, 64 bits, version 7.7.14)SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.Please run ?- license. for legal details.For online help and background, visit http://www.swi-prolog.orgFor built-in help, use ?- help(Topic). or ?- apropos(Word).?- cd('c:/tmp/zdd').true.
?- [zdd].true.?- module(zdd).true.zdd: ?- solve([X:=[[a,b],[c,d]]]), sets(X, R).X = 5,R = [[c, d], [a, b]].
zdd: ?-All the best,Fernando
--
You received this message because you are subscribed to the Google Groups "SWI-Prolog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swi-prolog+unsubscribe@googlegroups.com.
?- use_module('/Users/janburse/Desktop/zddfake').
ERROR: /Users/janburse/Desktop/zddfake.pl:2:
Domain error: `module_file' expected, found `'/Users/janburse/Desktop/zddfake.pl''
To unsubscribe from this group and stop receiving emails from it, send an email to swi-prolog+...@googlegroups.com.
:- module(clpb, [
op(300, fy, ~),
op(500, yfx, #),
sat/1,
taut/2,
labeling/1,
sat_count/2,
weighted_maximum/3,
random_labeling/2
]).
?- time((search([1,2,3,4,5,6,7,8,9,10,11,12,13], [], _), fail)). % Up 53,383 ms, GC 379 ms, Thread Cpu 51,941 ms (Current 05/20/18 11:13:47) No
?- time((findall(hit,search([1,2,3,4,5,6,7,8,9,10,11,12,13], [], _),L),
length(L,N), write(N), nl, fail)). 73712 % Up 50,160 ms, GC 431 ms, Thread Cpu 49,149 ms (Current 05/20/18 11:19:01) No
?- time((queens3(_), fail;true)). % Up 308 ms, GC 2 ms, Thread Cpu 301 ms (Current 05/20/18 11:26:37) Yes
?- time((queens(_), fail;true)). % Up 24 ms, GC 0 ms, Thread Cpu 23 ms (Current 05/20/18 11:10:30) Yes
On May 20, 2018, at 18:28, j4n bur53 <janb...@xlog.ch> wrote:There is something wrong with your "usual" queen. I
am now testing on a very slow machine of mine (an
old Mac laptop), and I get:
On May 20, 2018, at 18:28, j4n bur53 <janb...@xlog.ch> wrote:
On May 20, 2018, at 19:13, j4n bur53 <janb...@xlog.ch> wrote:
Your solution is procedural since you mistake ZDD as
a datatructure for union and length. But ZDD or
a SAT Solver schould deliver a little more intelligence
and declarative programming.
:- use_module(library(finite/clpb)). |
% ?- queens3(X), term_variables(X,L), labeling(L).Compare this with the traditional backtracking solution:
% X = [[0,0,0,1],[0,1,0,1],[1,0,0,0],[0,1,1,0],[0,0,1,1],[0,1,1,1],[0,0,1,0],[0,1,0,0]],
% L = [0,0,0,1,0,1,0,1,1,0,0,0,0,1,1,0,0,0,1,1,0,1,1,1,0,0,1,0,0,1,0,0] ;
% X = [[0,0,0,1],[0,1,1,0],[1,0,0,0],[0,0,1,1],[0,1,1,1],[0,1,0,0],[0,0,1,0],[0,1,0,1]],
% L = [0,0,0,1,0,1,1,0,1,0,0,0,0,0,1,1,0,1,1,1,0,1,0,0,0,0,1,0,0,1,0,1]
% ?- time((queens3(X), term_variables(X,L), sat_count(L,N), write(N), nl, fail)).
% 92
% % Up 1,453 ms, GC 21 ms, Thread Cpu 1,438 ms (Current 05/20/18 14:01:40)
% No
% ?- queens(X).
% X = [1,5,8,6,3,7,2,4] ;
% X = [1,6,8,3,7,4,2,5]
% ?- time((findall(hit,queens(_),L), length(L,N), write(N), nl, fail)).
% 92
% Up 18 ms, GC 0 ms, Thread Cpu 15 ms (Current 05/20/18 14:06:14)
% No
I don't know why the CLP(B) solution gives exactly the same
initial enumeration of solution. Maybe this is accidential,
since my CLP(B) has not yet some reordering during labeling.
On May 20, 2018, at 20:07, Kuniaki Mukai <kuniak...@gmail.com> wrote:I have found the “usual" codes usual_n_queens/2 with union replaced with appendis faster than ROZDD version n_queens/2 at both N= 13 and 14. As I believethat the replacement is safe, this is a little bit strange.
On May 20, 2018, at 21:30, j4n bur53 <janb...@xlog.ch> wrote:What do you add by maplist/3? I guess you make disjoint
solutions, so you can use append instead union.
:- use_module(library(finite/clpb)). |
% place inner queens firstHere are the results, the static ordering of outer
% queens3a(-List)
queens3a(X) :-
X = [A,B,C,D,E,F,G,H],
[C,D,E,F] ins 1..8,
[A,B,G,H] ins 1..8,
noattack_list(X),
all_different(X).
% place outer queens first
% queens3b(-List)
queens3b(X) :-
X = [A,B,C,D,E,F,G,H],
[A,B,G,H] ins 1..8,
[C,D,E,F] ins 1..8,
noattack_list(X),
all_different(X).
/* inner queens first is faster */
?- time((queens3a(X), term_variables(X, V), sat_count(V, N), write(N), nl, fail)). 92 % Up 1,347 ms, GC 16 ms, Thread Cpu 1,344 ms (Current 05/20/18 20:29:13) No
?- time((queens3b(X), term_variables(X, V),But a good labeling predicate would have some topological
sat_count(V, N), write(N), nl, fail)). 92 % Up 2,349 ms, GC 24 ms, Thread Cpu 2,328 ms (Current 05/20/18 20:29:05) No