This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # babashka (37)
- # beginners (27)
- # biff (1)
- # calva (18)
- # cider (45)
- # clj-on-windows (5)
- # cljsrn (1)
- # clojure (90)
- # clojure-art (3)
- # clojure-uk (1)
- # clojurescript (7)
- # core-logic (4)
- # datomic (4)
- # events (2)
- # fulcro (3)
- # hyperfiddle (23)
- # leiningen (66)
- # malli (1)
- # meander (7)
- # nrepl (1)
- # off-topic (9)
- # pathom (1)
- # re-frame (15)
- # reitit (19)
- # remote-jobs (1)
- # shadow-cljs (103)
Hey. Is there a way to do a square root when using a finite domain lvar? It can be lossful but it's fine.
I think that finding data for a specific standard deviation is not the best problem for the solver. But maybe I'm just mistaken.
I get this as one of my errors and it doesn't get more understandable from here...
Error printing return value (StackOverflowError) at clojure.lang.Numbers/hasheq (Numbers.java:1129).
Probably the search space is too deep...
👋 I’m new to logic programming and am looking solve a constraint problem that is think is best modeled as a finite domain.
• Given a set of mentors and mentees
• Each mentee can have a list of mentor preferences
• I want to find all solutions to matching mentees with their mentor preferences.
• Each mentor can only be a mentor for one mentee
My thinking was to look at this as a finite domain (translating names to numbers) and using a
lvarfor each mentor.
(fd/distinct (vec lmentors)) I was hoping to solve for “each mentor only gets to have a single mentee”.
Problem: As the number of lvars becomes large (say ~40) then running
(fd/distinct (vec lmentors)) is very slow. If I remove this constraint the program finds solutions immediately.
Are there ways to optimize this or just program this smarter?
Full sample (seems to work at small scale) https://gist.github.com/krukow/9ab5a708458e4d3d758032b081a5707a
(let [lmentors (repeatedly (count mentees) lvar) ;; one lvar for each mentee to match solutions (pldb/with-db db ;; db pre populated with mentee, mentor and preferences relations (run 1 [q] (== q (vec ;; q is [[mentee1 lvar-mentor2] [mentee2 lvar-mentor2] ... ] (map vector (keys mentees) lmentors))) (everyg #(fd/in % mentor-domain) lmentors) (fd/distinct (vec lmentors)) (and* (map (fn [tee tor] (fresh [tors] (mentee tee) (mentor tor) (preferences tee tors) (membero tor tors))) (keys mentees) lmentors))))] (map keyword-solution solutions))