This commit is contained in:
Adam Jeniski 2025-12-22 18:06:10 -05:00
parent e51b3296d6
commit db1a89199b

View File

@ -53,19 +53,16 @@
range
(map #(.mkIntConst ctx (str "j" %))))]
(add-expressions opt (for [idx (range (count joltages))]
(let [jn (nth js idx)
summation-args (->> buttons
(map set)
(map-indexed vector)
(filter #(contains? (second %) idx))
(map first)
(map #(nth bs %))
(into-array Expr)
(.mkAdd ctx))]
(.mkEq ctx jn summation-args))))
(.mkEq ctx (nth js idx) (->> buttons
(map set)
(map-indexed vector)
(filter #(contains? (second %) idx))
(map first)
(map #(nth bs %))
(into-array Expr)
(.mkAdd ctx)))))
(add-expressions opt (for [[idx joltage] (map-indexed vector joltages)]
(let [jn (nth js idx)]
(.mkEq ctx jn (.mkInt ctx (long joltage))))))
(.mkEq ctx (nth js idx) (.mkInt ctx (long joltage)))))
(add-expressions opt (for [b bs]
(.mkGe ctx b (.mkInt ctx (long 0)))))
(let [^Optimize$Handle mx (.MkMinimize opt (.mkAdd ctx (into-array Expr bs)))]