예제 #1
0
 def test_utility_delta(self):
     agent = edge.create_cagent('Cheese holders', 0)
     test_case = edge.DEF_NUM_CHEESE
     agent["goods"]["cheese"][AMT_AVAILABLE] = test_case
     change = utility_delta(agent, "cheese", 1)
     check = (DEF_MAX_UTIL - test_case + DEF_MAX_UTIL - (test_case + 1)) / 2
     self.assertEqual(change, check)
예제 #2
0
 def test_trade(self):
     agent1 = edge.create_wagent('Wine holders', 0)
     agent2 = edge.create_cagent('Cheese holders', 0)
     trade(agent1, "wine", edge.DEF_NUM_WINE, agent2, "cheese",
           edge.DEF_NUM_CHEESE)
     self.assertEqual(agent1["goods"]["wine"][AMT_AVAILABLE], 0)
     self.assertEqual(agent2["goods"]["cheese"][AMT_AVAILABLE], 0)
예제 #3
0
 def test_create_cagent(self):
     agent = edge.create_cagent('Cheese holders', 0)
     name = agent.name
     camt = agent["goods"]["cheese"][AMT_AVAILABLE]
     wamt = agent["goods"]["wine"][AMT_AVAILABLE]
     self.assertEqual(name, "Cheese holders0")
     self.assertEqual(camt, edge.DEF_NUM_CHEESE)
     self.assertEqual(wamt, 0)
예제 #4
0
 def test_adj_add_good(self):
     agent = edge.create_cagent('Cheese holders', 0)
     adj_add_good(agent, "cheese", -edge.DEF_NUM_CHEESE)
     self.assertEqual(agent["goods"]["cheese"][AMT_AVAILABLE], 0)
예제 #5
0
 def test_rec_offer(self):
     agent1 = edge.create_wagent('Wine holders', 0)
     agent2 = edge.create_cagent('Cheese holders', 0)
     ans = rec_offer(agent1, "cheese", 1, agent2)
     self.assertEqual(agent1["goods"]["cheese"][AMT_AVAILABLE], 1)
     self.assertEqual(agent2["goods"]["wine"][AMT_AVAILABLE], 1)
예제 #6
0
 def test_utility_delta(self):
     agent = edge.create_cagent('Cheese holders', 0)
     agent["goods"]["cheese"][AMT_AVAIL] = edge.DEF_NUM_CHEESE
     delta = utility_delta(agent, "cheese", 1)
     self.assertGreaterEqual(delta, 0.0)
     self.assertLessEqual(delta, DEF_MAX_UTIL)