def test_endow(self): """ See capital.trade_utils for description of what a `trader` and `goods` must look like. """ endow(self.trader, self.goods) self.assertFalse(is_depleted(self.trader["goods"]))
def nature_to_traders(traders, nature): """ A func to do the initial endowment from nature to all traders """ for trader in traders: endow(traders[trader], nature) for good in traders[trader]["goods"]: if traders[trader]["goods"][good][AMT_AVAIL] != 0: nature[good]["is_allocated"] = True print(repr(traders[trader]))
def nature_to_traders(traders, nature): """ A func to do the initial endowment from nature to all traders """ # before endowment from nature to trader, # first adjust the good amt by divisibility amt_adjust(nature) for trader in traders: endow(traders[trader], nature) for good in traders[trader][GOODS]: if traders[trader][GOODS][good][AMT_AVAIL] != 0: nature[good][IS_ALLOC] = True print(repr(traders[trader]))
def nature_to_traders(traders, nature): """ A func to do the initial endowment from nature to all traders """ for trader in traders: endow(traders[trader], nature) for good in nature: if good not in traders[trader]["goods"]: traders[trader]["goods"][good] = nature[good].copy() traders[trader]["goods"][good][AMT_AVAILABLE] = 0 else: # put attributes other than AMT_AVAILABLE into trader dict temp_amt = traders[trader]["goods"][good][AMT_AVAILABLE] traders[trader]["goods"][good] = nature[good].copy() traders[trader]["goods"][good][AMT_AVAILABLE] = temp_amt # each trader is given goods and knows all goods in nature print(repr(traders[trader]))
def allocate_resources(trader, avail_goods): tu.endow(trader, avail_goods, comp=True, rand=True)
def allocate_resources(trader, avail_goods, equal=False, rand=False): tu.endow(trader, avail_goods, equal=equal, rand=rand, comp=True)