Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* src/main/clojure/clojure/core/logic.clj: notes on optimizing distin…

…ctfd
  • Loading branch information...
commit cf92d03f2e8e55ba0204466dacb723d653125bf0 1 parent 5852f31
David Nolen authored
View
5 src/main/clojure/clojure/core/logic.clj
@@ -3338,6 +3338,11 @@
(let [ncs (update-proc (.cs a) (id proc) proc)]
(make-s (.s a) (.l a) ncs))))
+;; NOTE: this implementation attempts to optimize by sharing across all variables.
+;; however this not optimal since this is run when a particular var becomes a singleton.
+;; then we could just remove that single value from all the other domains instead of
+;; having to run set/difference and looping over all the vars
+
(defn -distinctfdc
([y* n*] (-distinctfdc y* n* nil))
([y* n* id]
View
4 src/main/clojure/clojure/core/logic/bench.clj
@@ -465,6 +465,8 @@
(time
(dotimes [_ 1e3]
(sudokufd))))
+
+ (sudokufd)
)
(defn big-sudokufd []
@@ -539,11 +541,13 @@
(big-sudokufd)
;; 27869 calls to run-constraint
+ ;; 13181 calls to run-constraints? because something is no longer refinable
;; 27875 calls to distinctfd
;; 137249 calls to process-dom
;; 141053 calls to FD difference
;; 6002 calls to -force-ans
;; yet only 26 constraints in the store
+ ;; max running constraints - #{4 5 14 16 23}
;; these numbers seem high
Please sign in to comment.
Something went wrong with that request. Please try again.