golf
This commit is contained in:
parent
e51b3296d6
commit
db1a89199b
@ -53,19 +53,16 @@
|
|||||||
range
|
range
|
||||||
(map #(.mkIntConst ctx (str "j" %))))]
|
(map #(.mkIntConst ctx (str "j" %))))]
|
||||||
(add-expressions opt (for [idx (range (count joltages))]
|
(add-expressions opt (for [idx (range (count joltages))]
|
||||||
(let [jn (nth js idx)
|
(.mkEq ctx (nth js idx) (->> buttons
|
||||||
summation-args (->> buttons
|
(map set)
|
||||||
(map set)
|
(map-indexed vector)
|
||||||
(map-indexed vector)
|
(filter #(contains? (second %) idx))
|
||||||
(filter #(contains? (second %) idx))
|
(map first)
|
||||||
(map first)
|
(map #(nth bs %))
|
||||||
(map #(nth bs %))
|
(into-array Expr)
|
||||||
(into-array Expr)
|
(.mkAdd ctx)))))
|
||||||
(.mkAdd ctx))]
|
|
||||||
(.mkEq ctx jn summation-args))))
|
|
||||||
(add-expressions opt (for [[idx joltage] (map-indexed vector joltages)]
|
(add-expressions opt (for [[idx joltage] (map-indexed vector joltages)]
|
||||||
(let [jn (nth js idx)]
|
(.mkEq ctx (nth js idx) (.mkInt ctx (long joltage)))))
|
||||||
(.mkEq ctx jn (.mkInt ctx (long joltage))))))
|
|
||||||
(add-expressions opt (for [b bs]
|
(add-expressions opt (for [b bs]
|
||||||
(.mkGe ctx b (.mkInt ctx (long 0)))))
|
(.mkGe ctx b (.mkInt ctx (long 0)))))
|
||||||
(let [^Optimize$Handle mx (.MkMinimize opt (.mkAdd ctx (into-array Expr bs)))]
|
(let [^Optimize$Handle mx (.MkMinimize opt (.mkAdd ctx (into-array Expr bs)))]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user