예제 #1
0
파일: msbid.py 프로젝트: brandonmayer/ssapy
def msbid(ss, ppfile, vfile, lfile, agentArgs=None):
    vmat = numpy.loadtxt(vfile)
    lmat = numpy.loadtxt(lfile)
    
    ppfile = os.path.realpath(ppfile)
    
    with open(ppfile,'rb') as f:
        pricePrediction = pickle.load(f)
    
    agent = agentFactory(agentType = ss,m=vmat.shape[1])
    agent.pricePrediction = pricePrediction
    
    if agentArgs != None:
        agentArgsDict = {}
        for s in agentArgs.split(' '):
            k=s.split('=')[0]
            v=s.split('=')[1]
            agentArgsDict[k]=v
            
    for v, l in zip(vmat,lmat):
        agent.v = v
        agent.l = l
        
        if agentArgs == None:
            bid = agent.bid()
            numpy.savetxt(sys.stdout, bid.reshape(1,bid.shape[0]))
        else:
            print agent.bid(**agentArgsDict)
예제 #2
0
 def test_straightMV(self):
     agentType = "msStraightMV"
     pp = numpy.asarray([5.,5.])
     v = [20.,10.]
     l = 1
     
     agent = agentFactory(agentType = agentType, v = v, l = l, pricePrediction = pp )
     
     numpy.testing.assert_equal(agent.bid(), numpy.asarray([15.,0.],dtype='float'), "test_agentFactory.test_straightMV failed.", True)
예제 #3
0
 def test_collectBids(self):
     agentType = "msStraightMUa"
     pricePrediction = jointGMM(n_components=2)
     pricePrediction.means_  = numpy.asarray([[10,5], [0,5]],dtype='float')
     pricePrediction.weights_ = numpy.asarray([0.5,0.5],dtype = 'float')
     nAgents = 5
     v = [20.,10.]
     l = 1
     agentList = [agentFactory(agentType = agentType, pricePrediction = pricePrediction, v = v, l = l) for i in xrange(nAgents)]
     
     bids = collectBids(agentList)
     
     true_bids = numpy.asarray([[15.,0.],[15.,0.],[15.,0.],[15.,0.],[15.,0.]])
     
     numpy.testing.assert_equal(bids,true_bids)