예제 #1
0
def regret_vs_m(algorithms, m_vals, N, T, epsilon, simulations=10):
    models = []
    regret = np.zeros((len(algorithms), len(m_vals), simulations))
    for m_indx, m in enumerate(m_vals):
        model = Parallel.create(N, m, epsilon)
        models.append(model)
        print "built model {0}".format(m)
        for s in xrange(simulations):
            for a_indx, algorithm in enumerate(algorithms):
                regret[a_indx, m_indx, s] = algorithm.run(T, model)

    return regret, models
예제 #2
0
    for T_indx, T in enumerate(T_vals):
        for a_indx, algorithm in enumerate(algorithms):
            for s in xrange(simulations):
                regret[a_indx, T_indx, s] = algorithm.run(T, model)
        print T

    return regret


experiment = Experiment(3)
experiment.log_code()

simulations = 10000
N = 50
m = 2
epsilon = .3
model = Parallel.create(N, m, epsilon)
T_vals = range(10, 6 * model.K, 25)
algorithms = [
    GeneralCausal(truncate='None'),
    ParallelCausal(),
    SuccessiveRejects(),
    AlphaUCB(2),
    ThompsonSampling()
]

regret = regret_vs_T(model, algorithms, T_vals, simulations=simulations)
finished = now_string()

experiment.plot_regret(regret, T_vals, "T", algorithms, legend_loc=None)
예제 #3
0
        model.set_epsilon(epsilon)
        for s in xrange(simulations):
            for a_indx, algorithm in enumerate(algorithms):
                regret[a_indx, T_indx, s] = algorithm.run(T, model)

    return regret


experiment = Experiment(2)
experiment.log_code()

N = 50
simulations = 10000
a = 9.0
m = 2
model = Parallel.create(N, m, .1)

Tmin = int(ceil(4 * model.K / a))
Tmax = 10 * model.K
T_vals = range(Tmin, Tmax, 100)

algorithms = [
    GeneralCausal(truncate='None'),
    ParallelCausal(),
    SuccessiveRejects(),
    AlphaUCB(2),
    ThompsonSampling()
]

regret = regret_vs_T_vary_epsilon(model,
                                  algorithms,