From bf8fa1813c1504b20982bb8fd7989f9d86b48585 Mon Sep 17 00:00:00 2001 From: Wilf Wilson Date: Wed, 1 Dec 2021 14:00:14 +0000 Subject: [PATCH] Update search to use the constraint object of a refiner --- gap/BacktrackKit.gi | 11 +---------- gap/canonical.gi | 2 +- gap/constraints/tree/tree.g | 4 ++-- 3 files changed, 4 insertions(+), 13 deletions(-) diff --git a/gap/BacktrackKit.gi b/gap/BacktrackKit.gi index 16359e6..f91ea04 100644 --- a/gap/BacktrackKit.gi +++ b/gap/BacktrackKit.gi @@ -304,16 +304,7 @@ BTKit_GetCandidateSolution := function(ps, rbase) end; -BTKit_CheckPermutation := function(perm, con) - local check; - if IsBound(con!.check) then - check := con!.check(perm); - Assert(2, check = (con!.result() = con!.image(perm))); - else - return con!.result() = con!.image(perm); - fi; - return check; -end; +BTKit_CheckPermutation := {perm, con} -> Check(con!.constraint)(perm); BTKit_CheckSolution := function(perm, conlist) local check; diff --git a/gap/canonical.gi b/gap/canonical.gi index 834be65..6b49230 100644 --- a/gap/canonical.gi +++ b/gap/canonical.gi @@ -21,7 +21,7 @@ BTKit_GetCandidateCanonicalSolution := function(state, group) Assert(2, group = false or perm in group); Info(InfoBTKit, 2, "Considering mapping: ", preimage, postimage, perm); - return rec(perm := perm, image := List(state!.conlist, {x} -> x!.image(perm))); + return rec(perm := perm, image := List(state!.conlist, {x} -> ImageFunc(x!.constraint)(perm))); # TODO: Huh? I don't get why we are taking the image w.r.t. the GROUP! end; diff --git a/gap/constraints/tree/tree.g b/gap/constraints/tree/tree.g index fb064a8..7a7fb5c 100644 --- a/gap/constraints/tree/tree.g +++ b/gap/constraints/tree/tree.g @@ -8,7 +8,7 @@ # name := Concatenation("List(", List(conlist, {c} -> c.name), ")"); # r := rec( # name := name, -# check := {p} -> ForAll(conlist, {c} -> c!.check(p)), +# check := {p} -> ForAll(conlist, {c} -> Check(c!.constraint)(p)), # refine := rec( # initialise := function(ps, rbase) # local refines, gather; @@ -33,7 +33,7 @@ # name := Concatenation("Set(", List(conlist, {c} -> c.name), ")"); # r := rec( # name := name, -# check := {p} -> ForAll(conlist, {c} -> c!.check(p)), +# check := {p} -> ForAll(conlist, {c} -> Check(c!.constraint)(p)), # refine := rec( # initialise := function(ps, rbase) # local refines, gather;