diff --git a/csp/aima-smm.rkt b/csp/aima-smm.rkt index f0f6cf0e..cdaba300 100644 --- a/csp/aima-smm.rkt +++ b/csp/aima-smm.rkt @@ -21,26 +21,25 @@ (for/list ([pr (in-combinations vs 2)]) ($constraint pr not=))) -(define (smm-func s e n d m o r y) - (= (+ (word-value s e n d) (word-value m o r e)) (word-value m o n e y))) - -(define csp (make-csp vds (append - +(define smm (make-csp vds (append alldiffs (list - ($constraint vs smm-func) ($constraint '(s) positive?) - ($constraint '(m) (λ (x) (= 1 x))) + ($constraint '(m) positive?) ($constraint '(d e y) (λ (d e y) (= (modulo (+ d e) 10) y))) ($constraint '(n d r e y) (λ (n d r e y) (= (modulo (+ (word-value n d) (word-value r e)) 100) (word-value e y)))) ($constraint '(e n d o r y) (λ (e n d o r y) - (= (modulo (+ (word-value e n d) (word-value o r e)) 1000) (word-value n e y)))))))) + (= (modulo (+ (word-value e n d) (word-value o r e)) 1000) (word-value n e y)))) + ($constraint '(s e n d m o r y) (λ (s e n d m o r y) + (= (+ (word-value s e n d) (word-value m o r e)) + (word-value m o n e y)))))))) + (parameterize ([current-select-variable mrv] [current-order-values lcv] [current-inference mac]) - (time (solve csp))) -(nassigns csp) -(nchecks csp) -(reset! csp) \ No newline at end of file + (time (solve smm))) +(nassigns smm) +(nchecks smm) +(reset! smm) \ No newline at end of file diff --git a/csp/hacs-test.rkt b/csp/hacs-test.rkt index b13507b9..db7e4218 100644 --- a/csp/hacs-test.rkt +++ b/csp/hacs-test.rkt @@ -275,7 +275,7 @@ (define (finish x) (apply map list (slice-at x 5))) -(equal? (parameterize ([current-select-variable mrv] +(check-equal? (parameterize ([current-select-variable mrv] [current-shuffle #f]) (finish (time (solve zebra)))) '(((nationality-0 . norwegian) (color-0 . yellow) (drink-0 . water) (smoke-0 . kools) (pet-0 . foxes))