Permalink
Browse files

Move grant constraint definition back into let

  • Loading branch information...
1 parent d24693f commit fd27884ee53664f8d3a597b896c6fff7d5795a53 @lvh committed Mar 6, 2014
Showing with 1 addition and 7 deletions.
  1. +1 −7 src/hood/constraint.clj
View
@@ -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)))

0 comments on commit fd27884

Please sign in to comment.