Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Move grant constraint definition back into let

  • Loading branch information...
commit fd27884ee53664f8d3a597b896c6fff7d5795a53 1 parent d24693f
@lvh authored
Showing with 1 addition and 7 deletions.
  1. +1 −7 src/hood/constraint.clj
View
8 src/hood/constraint.clj
@@ -9,17 +9,11 @@
[apps]
(for [a apps] [:allocation a]))
-(defn grant-constraint
- "An application will get between zero and the requested amount of
- dollars."
- [app]
- ($in [:allocation app] 0 (:requested app)))
-
(defn ^:private solve
"Throw the constraint problem into loco."
[apps budget target]
(let [allocs (alloc-vars apps)
- grant-constraints (map grant-constraint apps)
+ grant-constraints (map #($in [:allocation %] 0 (:requested %)) apps)
within-budget ($<= (apply $+ allocs) budget)
constraints (conj grant-constraints within-budget)]
(solution constraints :maximize target)))
Please sign in to comment.
Something went wrong with that request. Please try again.