diff --git a/csp/csp/hacs-demo-triples.rkt b/csp/csp/hacs-demo-triples.rkt new file mode 100644 index 00000000..8b357e61 --- /dev/null +++ b/csp/csp/hacs-demo-triples.rkt @@ -0,0 +1,29 @@ +#lang br +(require csp sugar) + +(define triples (make-csp)) + +(add-var! triples 'a (range 10 50)) +(add-var! triples 'b (range 10 50)) +(add-var! triples 'c (range 10 50)) + +(define (valid-triple? x y z) + (= (expt z 2) (+ (expt x 2) (expt y 2)))) +(add-constraint! triples valid-triple? '(a b c)) + +(require math/number-theory) +(add-constraint! triples coprime? '(a b c)) + +(add-constraint! triples <= '(a b)) + +(time-avg 10 (solve* triples)) + +(define (f) + (for*/list ([a (in-range 10 50)] + [b (in-range 10 50)] + #:when (<= a b) + [c (in-range 10 50)] + #:when (and (coprime? a b c) (valid-triple? a b c))) + `((a . ,a) (b . ,b) (c . ,c)))) + +(time-avg 10 (f)) \ No newline at end of file diff --git a/csp/csp/hacs.rkt b/csp/csp/hacs.rkt index 268301c3..c09405a5 100644 --- a/csp/csp/hacs.rkt +++ b/csp/csp/hacs.rkt @@ -489,7 +489,7 @@ #:select-variable [select-unassigned-variable (or (current-select-variable) first-unassigned-variable)] #:order-values [order-domain-values (or (current-order-values) first-domain-value)] - #:inference [inference (or (current-inference) no-inference)]) + #:inference [inference (or (current-inference) forward-check)]) ((csp?) (#:select-variable procedure? #:order-values procedure? #:inference procedure?) . ->* . generator?) (generator () (define reduce-arity-proc (if (current-arity-reduction) reduce-constraint-arity values))