         allocs (map first allocs-agents)
         agents (map second allocs-agents)]
     [(into {} allocs) (into {} agents)]))
+
+(defn allocate-full
+  "Allocates as many units of skill as possible and needed to site with site-k,
+  returning the new distribution."
+  [{:keys allocation reservoir :as distribution} site-k skill static-data]
+  (loop [available (good-agents (count (:agents static-data)) site-k skill
+                                reservoir static-data)
+         cur-distr distribution]
+    (if (and (seq available)
+             (pos? (demand allocation [site-k skill] static-data)))
+      (recur (rest available)
+             (allocate-max-bundle cur-distr [site-k skill] (first available)
+                                  static-data))
+      cur-distr)))
+
+(defn find-single-distribution
+  "For each skill needed by site site-k, allocates as many units of that skill
+  as possible and needed to it. Returns the new distribution."
+  [{:keys allocation reservoir :as distribution} site-k static-data]
+  (let [allocator (fn [prev-distr skill] (allocate-full prev-distr site-k
+                                                        skill static-data))]
+    (reduce allocator distribution
+            (keys (get-in static-data [:sites site-k :skills])))))
+
+(defn find-initial-distribution [reservoir static-data]
+  (let [allocator (fn [prev-distr site-k])])
+  (reduce find-single-distribution {:allocation {} :reservoir reservoir}
+          (keys (:sites static-data))))
 
 ;;; Credits: http://stackoverflow.com/questions/14488150/how-to-write-a-dissoc-in-command-for-clojure
 (defn dissoc-in

                   agents)))

(defn allocation-for-skill
  [location [skill n-needed] agents]
  (let [sorted-agents (sorted-map-by-distance location
                                              (filter-skill skill agents))]
    (loop [n-remaining n-needed

  heuristically good allocation for this site. Returns the coalition and and the
  agent datastructure with capacities reduced according to the allocation."
  [site agents]
  (let [allocs-agents (map (fn [demand]
                             (allocation-for-skill (:location site)
                                                   demand
