Exemple #1
0
	def testRatingsNoFeedback(self):
		#Step 1 - generate simulated data
		good_agent = {"range": [1,8], "values": [100,1000], "transactions": 10, "suppliers": 1, "consumers": 1}
		bad_agent = {"range": [9,10], "values": [1,10], "transactions": 100, "suppliers": 1, "consumers": 1}
		reputation_simulate(good_agent,bad_agent, datetime.date(2018, 1, 1), 10, True, None, False)
		#Step 2 - process simulated with reputaion engine in batch mode, grab results and check them
		cmd = 'python reputation_simulate.py ../../bin testsim ./ transactions10_r_100_0.1.tsv users10.tsv 2018-01-01 2018-01-10 logarithm=False weighting=True norm=True default=0.5'
		r = subprocess.check_output(cmd,shell=True)
		lines = r.decode().splitlines()
		self.assertEqual(lines[len(lines)-4],'0.9866744712267205') 
		self.assertEqual(lines[len(lines)-2],'0.9944481144111824') 
	def testRatingsNoFeedback(self):
		print('Testing '+type(self.rs).__name__+' testRatingsNoFeedback')
		#Step 1 - generate simulated data
		good_agent = {"range": [1,8], "values": [100,1000], "transactions": 10, "suppliers": 1, "consumers": 1}
		bad_agent = {"range": [9,10], "values": [1,10], "transactions": 100, "suppliers": 1, "consumers": 1}
		reputation_simulate(good_agent,bad_agent, date(2018, 1, 1), 10, True, None, False, silent=True)
		#Step 2 - process simulated with reputaion engine in batch mode, grab results and check them
		cmd = 'python reputation_simulate.py ./bin testsim ./ transactions10_r_100_0.1.tsv users10.tsv 2018-01-01 2018-01-10 logratings=False weighting=True fullnorm=True default=0.5'
		r = subprocess.check_output(cmd,shell=True)
		lines = r.decode().splitlines()
		#print(lines)
		self.assertEqual(str(round(float(lines[len(lines)-4]),3)),'0.995') 
		self.assertEqual(str(round(float(lines[len(lines)-2]),3)),'0.984') 
	def testRatingsWithFeedback(self):
		print('Testing '+type(self.rs).__name__+' testRatingsWithFeedback')
		#Step 1 - generate simulated data with reputation feedback
		good_agent = {"range": [1,8], "values": [100,1000], "transactions": 10, "suppliers": 1, "consumers": 1}
		bad_agent = {"range": [9,10], "values": [1,10], "transactions": 100, "suppliers": 1, "consumers": 1}
		reputation_simulate(good_agent,bad_agent, date(2018, 1, 1), 3, True, self.rs, False, silent=True)
		#Step 2 - check reputations
		r1 = self.rs.get_ranks_dict({'date':date(2018, 1, 1)})
		r2 = self.rs.get_ranks_dict({'date':date(2018, 1, 2)})
		#print(r1)
		#print(r2)
		#Checking good agents
		assert r1['1'] > 60
		assert r1['2'] > 60
		assert r2['1'] > 60
		assert r2['2'] > 60
		#Checking bad agents
		assert r1['9'] < 40
		assert r1['10'] < 40
		assert r2['9'] < 40
		assert r2['10'] < 40
#Semi-healthy agent environment set
good_agent = {
    "range": [1, 800],
    "values": [100, 1000],
    "transactions": 10,
    "suppliers": suppliers,
    "consumers": consumers
}
bad_agent = {
    "range": [801, 1000],
    "values": [5, 50],
    "transactions": 100,
    "suppliers": suppliers,
    "consumers": consumers
}
"""
start = time.time()
rs = AigentsAPIReputationService('http://localtest.com:1288/', '*****@*****.**', 'q', 'a', False, 'test', True)
if rs is not None:
    rs.set_parameters({'fullnorm':True,'weighting':True,'logratings':False})
reputation_simulate(good_agent,bad_agent, datetime.date(2018, 1, 1), days, True, rs, verbose)
print("Time spent Aigents:",time.time()-start)
del rs

start = time.time()
rs = PythonReputationService()
if rs is not None:
    rs.set_parameters({'fullnorm':True,'weighting':True,'logratings':False})
reputation_simulate(good_agent,bad_agent, datetime.date(2018, 1, 1), days, True, rs, verbose)
print("Time spent Python:",time.time()-start)
del rs
    "suppliers": suppliers,
    "consumers": consumers
}
print('Good Agent:', str(good_agent))
print('Bad Agent :', str(bad_agent))
for sp in [364, 182, 92, 30]:
    #for sp in [182,92,30,10]:
    #for sp in [10,6,4,2]:
    print('Scam period:', str(sp))
    sip = sp / 2

    print('No RS:', end=" ")
    reputation_simulate(good_agent,
                        bad_agent,
                        datetime.date(2018, 1, 1),
                        days,
                        True,
                        None,
                        campaign=[sp, sip],
                        verbose=verbose)

    print('Regular RS:', end=" ")
    rs.set_parameters({
        'fullnorm': True,
        'weighting': False,
        'logratings': False,
        'denomination': False,
        'unrated': False,
        'default': 0.5,
        'decayed': 0.5,
        'ratings': 1.0,
        'spendings': 0.0
Exemple #6
0
good_agent = {
    "range": [1, 8],
    "values": [100, 1000],
    "transactions": 10,
    "suppliers": 1,
    "consumers": 1
}
bad_agent = {
    "range": [9, 10],
    "values": [10, 100],
    "transactions": 100,
    "suppliers": 1,
    "consumers": 1
}

reputation_simulate(good_agent, bad_agent, datetime.date(2018, 1, 1), 10, True,
                    rs)
#reputation_simulate(good_agent,bad_agent, datetime.date(2018, 1, 1), 10, False, rs)

#Semi-healthy agent environment set
good_agent = {
    "range": [1, 8],
    "values": [100, 1000],
    "transactions": 10,
    "suppliers": 1,
    "consumers": 1
}
bad_agent = {
    "range": [9, 10],
    "values": [5, 50],
    "transactions": 100,
    "suppliers": 1,