def update_inventory(self, time, item):
        item = dict(item)
        category = item["category"]
        amount = item["size"]
        sim = self.item_sims[category]
        sim.record_purchase(time, amount)

    def get_inventory_amounts(self, time):
        amounts = {}
        for category, sim in self.item_sims.iteritems():
            remaining_amount = sim.get_remaining_amount(time)
            amounts[category] = remaining_amount
        return amounts

    def __repr__(self):
        return "(%s, %s dogs, %s cats)" % (self.customer.name,
                                           self.customer.pets["dog"],
                                           self.customer.pets["cat"])


if __name__ == "__main__":
    from products import load_products_json
    from customers import CustomerGenerator

    item_categories = load_products_json()

    customer = CustomerGenerator().generate(1)[0]

    customer_sim = CustomerState(item_categories=item_categories,
                                 customer=customer)
 def load_data(self):
     self.item_categories = products.load_products_json()
     self.zipcode_objs = load_zipcode_data()
     self.first_names, self.last_names = load_names()
        
    def propose_transaction_time(self):
        lambd = 1.0 / self.average_transaction_trigger_time
        time_until_transaction = random.expovariate(lambd)
        transaction_time = max(self.exhaustion_time() - time_until_transaction, 0.0)
        return transaction_time

    def choose_item_for_purchase(self):
        return self.purchase_model.progress_state()


if __name__ == "__main__":
    sim = ItemCategoryUsageSimulation(initial_amount=30.0, initial_time=0.0, daily_usage_rate=1.0,
        amount_used_average=0.5, amount_used_variance=0.2)
    sim.simulate()

    for time, amount in sim.trajectory:
        print time, amount

    from products import load_products_json
    from customers import CustomerGenerator

    item_categories = load_products_json()

    customer = CustomerGenerator().generate(1)[0]
    print 
    for item_category in item_categories.itervalues():
        sim = ExhaustibleItemCategorySimulation(item_category=item_category, customer=customer)
        for i in xrange(10):
            print sim.choose_item_for_purchase()