コード例 #1
0
ファイル: test_trade_utils.py プロジェクト: gcallah/IndraABM
 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"]))
コード例 #2
0
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]))
コード例 #3
0
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]))
コード例 #4
0
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]))
コード例 #5
0
def allocate_resources(trader, avail_goods):
    tu.endow(trader, avail_goods, comp=True, rand=True)
コード例 #6
0
def allocate_resources(trader, avail_goods, equal=False, rand=False):
    tu.endow(trader, avail_goods, equal=equal, rand=rand, comp=True)