forked from rpitrust/agentsimulation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tester.py
82 lines (74 loc) · 3.02 KB
/
tester.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
"""
Tester file for the agent code
"""
import simulation as sim
import simplejson as sj
import random
import sys
import simulation as sim
def print_results(results):
print "Trust: %r, Filter: %r, Inbox: %r" \
%(results['setup']['trust_used'], \
results['setup']['trust_filter_on'], \
results['setup']['inbox_trust_sorted'])
print "AVG results"
for val in results['summary_results']['sa_at_value']:
print "\tSteps: %d\t Comm:%.1f\t @sa %.1f" \
%(val['steps'],val['comm'],val['sa'])
print "\tSteps: %d\t Comm:%.1f\t @sa %.2f" \
%( results['summary_results']['steps'],\
results['summary_results']['comm'], \
results['summary_results']['sa'] )
print "Agent 0 results"
for val in results['summary_results']['sa0_at_value']:
print "\tSteps: %d\t Comm:%.1f\t @sa %.1f" \
%(val['steps'],val['comm'],val['sa'])
print "\tSteps: %d\t Comm:%.1f\t @sa %.2f" \
%( results['summary_results']['steps0'],\
results['summary_results']['comm0'], \
results['summary_results']['sa0'] )
print "Total filtered", results['total_filtered']
if __name__ == '__main__':
num_steps = 10000
num_trial = 20
num_facts = 50
num_noise = 5000
num_agents = 20
agent_per_fact = 1
#connection_probability = 1
connection_probability = 0.5
willingness = 1
competence = 1
#graph_type = 'collaborative'
graph_type = 'spatial_random'
#graph_type = 'hierarchy'
spamminess = 0.2
selfishness = 0
#agent_setup = [{"selfish":0.8, "ratio":0.6}]
agent_setup = []
trust_used = False
inbox_trust_sorted = False
trust_filter_on = False
# for (trust_used, trust_filter_on, inbox_trust_sorted) in \
# [(False,False,False), (True, True, False), (True, True, True)]:
#for (trust_used, trust_filter_on, inbox_trust_sorted) in \
# [(False,False,False)]:
for spamminess in [0]:
results = sim.run_simulation(NUM_FACTS=num_facts, \
NUM_NOISE=num_noise, \
NUM_AGENTS=num_agents, \
AGENT_PER_FACT=agent_per_fact, \
CONNECTION_PROBABILITY=connection_probability, \
NUM_STEPS=num_steps, \
WILLINGNESS=willingness, \
COMPETENCE=competence, \
NUM_TRIAL=num_trial,\
GRAPH_TYPE=graph_type, \
AGENT_SETUP=agent_setup, \
SPAMMINESS=spamminess, \
SELFISHNESS=selfishness, \
TRUST_USED=trust_used, \
INBOX_TRUST_SORTED=inbox_trust_sorted,\
TRUST_FILTER_ON=trust_filter_on)
print results
print_results(results)