Ejemplo n.º 1
0
import pathos

import dotdot
from neuromodel import Offers, Model, ReplicatedModel, run_model

# configuring offers
ΔA, ΔB, n = (0, 20), (0, 20), 4000
offers = Offers(ΔA=ΔA, ΔB=ΔB, n=n, random_seed=0)


def compute_fig5_data(model_class=Model,
                      δ_J_stim=(1, 1),
                      δ_J_nmda=(1, 1),
                      δ_J_gaba=(1, 1, 1),
                      desc=''):
    """Compute the data for Figure 5."""
    model = model_class(n=n,
                        ΔA=ΔA,
                        ΔB=ΔB,
                        random_seed=1,
                        δ_J_stim=δ_J_stim,
                        δ_J_gaba=δ_J_gaba,
                        δ_J_nmda=δ_J_nmda)

    filename = 'data/fig5_{}[{}]{}.pickle'.format(desc, n, model.desc)
    run_model(model, offers, history_keys=(), filename=filename)


if __name__ == '__main__':

    def aux(args):
Ejemplo n.º 2
0
import dotdot
from neuromodel import Model, History, DataAnalysis, Offers

ΔA, ΔB, n = (0, 20), (0, 20), 500
offers = Offers(ΔA=ΔA, ΔB=ΔB, n=n)

w_p = 1.55
model = Model(n=n, ΔA=ΔA, ΔB=ΔB, w_p=w_p, random_seed=1)


def run_model(model,
              offers,
              data_keys=('r_1', 'r_2', 'r_3', 'r_I', 'r_ova', 'r_ovb')):
    """Run a model against a set of offers

    :param opportunistic:  if it finds a file named `filename`, it will load it rather
                           than running the model.
    """
    model.history = History(model, keys=data_keys)

    for i, (x_A, x_B) in enumerate(offers.offers[:25]):
        model.one_trial(x_a=x_A, x_b=x_B)

    analysis = DataAnalysis(model)

    return analysis


if __name__ == '__main__':
    run_model(model, offers, data_keys=('r_2', 'r_I'))