def experiment(k): # Agent initialization np.random.seed() agent = AgentFactored(budgetTot=1000, deadline=deadline, nCampaigns=nCampaigns, nBudget=nIntervals, nBids=nBids, maxBudget=100.0) agent.initGPs() print "Experiment : ", k print "A" # Set the GPs hyperparameters for c in range(0, nCampaigns): agent.setGPKernel(c, oracle.gpsClicks[c].kernel_, oracle.gpsCosts[c].kernel_) # Init the Core and execute the experiment env = Environment(copy.copy(campaigns)) core = Core(agent, copy.copy(env), deadline) core.runEpisode() np.save(path + "policy_" + str(k), [agent.prevBids, agent.prevBudgets]) np.save(path + "experiment_" + str(k), np.sum(agent.prevConversions, axis=1)) return np.sum(agent.prevConversions, axis=1), agent
def experiment(k): np.random.seed() print "Esperimento: ", k agentGPUCB = AgentFactored(1000, deadline, ncampaigns, nIntervals, nBids, maxBudget, 1.0, "GPUCB") agentGPUCB.initGPs() envGPUCB = Environment(copy.copy(campaigns)) coreGPUCB = Core(agentGPUCB, envGPUCB, deadline) meanConvGPUCB = np.zeros(deadline) # in questo ciclo mi salvo le conversioni medie in ogni istante for t in range(deadline): print "Day: ", t + 1 coreGPUCB.step() meanConvGPUCB[t] = lastMeanConv(agentGPUCB) # ora invece mi salvo le conversioni istantanee instConvGPUCB = np.sum(agentGPUCB.prevConversions, axis=1) positionGPUCB1 = path_dati + "inst_conv_3camp_" + str(k) positionGPUCB2 = path_dati + "mean_conv_3camp_" + str(k) np.save(positionGPUCB1, instConvGPUCB) np.save(positionGPUCB2, meanConvGPUCB) return
Campaign(a5, nMeanResearch=1450.0, nStdResearch=50.0, probClick=probClick[4], convParams=convparams)) ncampaigns = len(campaigns) nBids = 10 nIntervals = 10 deadline = 250 maxBudget = 100 agent = AgentFactored(1000, deadline, ncampaigns, nIntervals, nBids, maxBudget, 1.0) agent.initGPs() env = Environment(campaigns) plotter = PlotterFinal(agent=agent, env=env) # mi creo una lista con tutte le matrici dell'oracolo di ogni campagna listMeans = list() listVar = list() for i in range(0, ncampaigns): [trueMeans, trueVar] = plotter.oracleMatrix(indexCamp=i, nsimul=20) listMeans.append(trueMeans) listVar.append(trueVar) if i == 0: optMatrix = np.array([trueMeans.max(axis=1)]) else: maxrow = np.array([trueMeans.max(axis=1)]) optMatrix = np.concatenate((optMatrix, maxrow))