Exemplo n.º 1
0
class TestTrialResponse(unittest.TestCase):
	@data(('0.pkl',
		[50,11,3.3,1.83,0.92,0.31],
		12,
		36,
		4.0,
		0.0,
		0.7,
		0.0,
		8,
		Visualization.Visualize(circleSize=10, screenColor=[255,255,255], screen = pg.display.set_mode([800,800]), 
			saveImage=False, saveImageFile='image'),
		0.95,
		{50:5,11:30,3.3:60,1.83:90,0.92:120,0.31:150}))
	@unpack
	def testResponseForSimpleChasing(self,filename,subtletyHypothesis,updateFrequency,attentionSwitchFrequency,precisionPerSlot,precisionForUntracked,memoryratePerSlot,memoryrateForUntracked,attentionLimitation,visualize,responseRule,precisionToSubtletyDict):
		loadTrajectory=LoadTrajectory.loadTrajectory
		initialPrior=targetCode.initialPrior(attentionLimitation)
		computePosterior=calPosterior.calPosteriorLog
		attention=Attention.AttentionToPrecisionAndDecay(precisionPerSlot, precisionForUntracked, memoryratePerSlot, memoryrateForUntracked)
		attentionSwitch=Attention.AttentionSwitch(attentionLimitation)
		perception=Perception.Perception(attention, computePosterior, attentionSwitch, attentionSwitchFrequency)
		response=Response.RuleBasedResponse(responseRule, precisionToSubtletyDict)
		trial=targetCode.Trial(subtletyHypothesis, updateFrequency, loadTrajectory, visualize, initialPrior, response, perception)
		trialResponse=trial(filename)
		# self.assertTrue(trialResponse['action'])
		self.assertLessEqual(trialResponse['RT'],8000)
		self.assertEqual(trialResponse['wolfIdentity'],0)
		self.assertEqual(trialResponse['sheepIdentity'],1)
Exemplo n.º 2
0
	screenHeight=800
	filename='0.pkl'
	subtletyHypothesis=[50,11,3.3,1.83,0.92,0.31]
	precisionToSubtletyDict={50:5,11:30,3.3:60,1.83:90,0.92:120,0.31:150}
	updateFrequency=12
	attentionSwitchFrequency = 24
	responseRule=1.01
	precisionPerSlot=8.0
	precisionForUntracked=2.5
	memoryratePerSlot=0.7
	memoryrateForUntracked=0.45
	attentionLimitation=2
	outputpath=os.path.abspath(os.path.join(os.getcwd(), os.pardir))+'/data/'
	saveImage=False
	saveImageFile='image'

	initialPrior=initialPrior(attentionLimitation)
	screen = pg.display.set_mode([screenWide,screenHeight])
	loadTrajectory=LoadTrajectory.loadTrajectory
	visualize=Visualization.Visualize(circleSize, screenColor, screen, saveImage, outputpath+saveImageFile)
	computePosterior=calPosterior.calPosteriorLog
	attentionSwitch=Attention.AttentionSwitch(attentionLimitation)
	attention = Attention.AttentionToPrecisionAndDecay(precisionPerSlot, precisionForUntracked, memoryratePerSlot, memoryrateForUntracked)
	perception=Perception.Perception(attention, computePosterior, attentionSwitch, attentionSwitchFrequency)
	response=Response.RuleBasedResponse(responseRule, precisionToSubtletyDict)
	runOneTrial=Trial(subtletyHypothesis, updateFrequency, loadTrajectory, visualize, initialPrior, response, perception)

	response=runOneTrial(filename)
	pg.quit()
	print(response)
Exemplo n.º 3
0
    updateFrequency=12
    attentionSwitchFrequency = 24
    responseRule=1
    precisionPerSlot=8.0
    precisionForUntracked=2.5
    memoryratePerSlot=0.7
    memoryrateForUntracked=0.45
    attentionLimitation=2
    outputpath=os.path.abspath(os.path.join(os.getcwd(), os.pardir))+'/data/'
    saveImage=True
    saveImageFile='image'
    saveResultFile='Hybird.csv'

    screen = pg.display.set_mode([screenWide,screenHeight])
    loadTrajectory = LoadTrajectory.loadTrajectory
    initialPrior=Trial.initialPrior(attentionLimitation)
    response=Response.RuleBasedResponse(responseRule, precisionToSubtletyDict)
    # response=Response.Response(precisionToSubtletyDict)
    writer=Writer.writeToCSV(outputpath+'results/'+saveResultFile)
    plotResult=ResultPlot.plotResult
    computePosterior = calPosterior.calPosteriorLog
    attentionSwitch=Attention.AttentionSwitch(attentionLimitation)
    attention = Attention.AttentionToPrecisionAndDecay(precisionPerSlot, precisionForUntracked, memoryratePerSlot, memoryrateForUntracked)
    perception=Perception.Perception(attention,computePosterior,attentionSwitch,attentionSwitchFrequency)
    visualize = Visualization.Visualize(baseLineWidth, circleSize, screenColor, screen, saveImage, saveImageFile)
    Trial=Trial.Trial(subtletyHypothesis, updateFrequency, loadTrajectory, visualize, initialPrior, response, perception)
    runExperiment = Experiment(trialListFilename, Trial, writer)
    
    runExperiment()
    plotResult(saveResultFile)