Skip to content

Commit

Permalink
update answers, using the latest Scryer Prolog development version
Browse files Browse the repository at this point in the history
  • Loading branch information
triska committed Sep 10, 2023
1 parent 61f0b1b commit 8854afc
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 23 deletions.
4 changes: 2 additions & 2 deletions clpb/independent.pl
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

%?- independent_set(Sat), time(sat_count(Sat, Count)).
%@ % CPU time: 6.306s
%@ Sat = *(...), Count = 211954906
%@ % CPU time: 3.809s
%@ Sat = *(...), Count = 211954906.

independent_set(*(NBs)) :-
findall(U-V, edge(U, V), Edges),
Expand Down
37 changes: 16 additions & 21 deletions clpb/kernels.pl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
:- use_module(library(between)).
:- use_module(library(pairs)).
:- use_module(library(time)).
:- use_module(library(assoc)).

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Independent sets, maximal independent sets (kernels) and maximal
Expand All @@ -15,24 +16,20 @@
(1) Independent sets:
?- time((independent_set(I,_),sat_count(I,N))).
%@ % CPU time: 0.999s
%@ I = *(....), N = 792070839848372253127
%@ ; % CPU time: 0.000s
%@ false.
%@ % CPU time: 0.661s
%@ I = *(...), N = 792070839848372253127.
(2) Maximal independent sets:
?- time((kernel(K,_),sat_count(K,N))).
%@ % CPU time: 3.893s
%@ K = *(...)* *(...), N = 1630580875002
%@ ; % CPU time: 0.000s
%@ false.
%@ % CPU time: 3.178s
%@ K = *(...)* *(...), N = 1630580875002.
(3) Maximal independent sets with maximum weight:
%?- time(maximum_thue_morse_kernel(Is, Negatives, Max)).
%@ % CPU time: 122.740s
%@ Is = [1,3,6,9,12,15,18,20,23,25,27,30,33,36,39,41,43,46,48,51,...], Negatives = [1,25,41,73,97], Max = 28
%@ % CPU time: 10.928s
%@ Is = [1,3,6,9,12,15,18,20,23,25,27,30,33,36,39,41,43,46,48,51|...], Negatives = [1,25,41,73,97], Max = 28
%@ ; ... .
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
Expand Down Expand Up @@ -116,12 +113,12 @@
include(Goal_1, Es, Rs).

%?- time(maximum_thue_morse_kernel(Is, Negatives, Max)).
%@ % CPU time: 124.214s
%@ Is = [1,3,6,9,12,15,18,20,23,25,27,30,33,36,39,41,43,46,48,51,...], Negatives = [1,25,41,73,97], Max = 28
%@ ; % CPU time: 0.039s
%@ Is = [1,3,6,9,12,15,18,20,23,25,27,30,33,36,39,41,43,46,48,51,...], Negatives = [1,25,41,73,94], Max = 28
%@ ; % CPU time: 1.020s
%@ Is = [1,3,6,9,12,15,18,20,23,25,27,30,33,36,39,41,43,46,48,51,...], Negatives = [1,25,41,73,97], Max = 28
%@ % CPU time: 11.111s
%@ Is = [1,3,6,9,12,15,18,20,23,25,27,30,33,36,39,41,43,46,48,51|...], Negatives = [1,25,41,73,97], Max = 28
%@ ; % CPU time: 0.004s
%@ Is = [1,3,6,9,12,15,18,20,23,25,27,30,33,36,39,41,43,46,48,51|...], Negatives = [1,25,41,73,94], Max = 28
%@ ; % CPU time: 0.089s
%@ Is = [1,3,6,9,12,15,18,20,23,25,27,30,33,36,39,41,43,46,48,51|...], Negatives = [1,25,41,73,97], Max = 28
%@ ; ... .

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand All @@ -131,9 +128,8 @@
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

%?- time((independent_set(I,_),sat_count(I,N))).
%@ % 2,101,745 inferences, 0.245 CPU in 0.256 seconds (96% CPU, 8594864 Lips)
%@ I = *([~_G69+ ~_G70, ~_G70+ ~_G71, ~_G71+ ~_G72, ~_G72+ ~_G73, ~_G73+ ~_G74, ~_G74+ ~_G75, ~ ... + ~ ..., ... + ...|...]),
%@ N = 792070839848372253127.
%@ % CPU time: 0.656s
%@ I = *(...), N = 792070839848372253127.


independent_set(*(NBs), Assoc) :-
Expand Down Expand Up @@ -165,5 +161,4 @@
u_to_var(Assoc, Node, Var) :- get_assoc(Node, Assoc, Var).

%?- kernel(Sat, _), sat_count(Sat, C).
%@ Sat = *(...)* *(...), C = 1630580875002
%@ ; ... .
%@ Sat = *(...)* *(...), C = 1630580875002.

0 comments on commit 8854afc

Please sign in to comment.