<jupyter_start><jupyter_text>Set up the model<jupyter_code>seed = 1
seed_p = 2
n_xcorr = 0
n_mom = 4
n_summary = 7
summary_stats = 1
prior_uniform = True
prior_log = False
prior_extent = True
cython=True

true_params, labels_params = utils.obs_params(reduced_model=False)
I, t_on, t_off, dt = utils.syn_current()

obs = utils.syn_obs_data(I, dt, true_params, seed=seed, cython=cython)
obs_stats = utils.syn_obs_stats(data=obs, I=I, t_on=t_on, t_off=t_off, dt=dt, params=true_params,
                                seed=seed, n_xcorr=n_xcorr, n_mom=n_mom, cython=cython,
                                summary_stats=summary_stats,n_summary=n_summary)

LABELS_HH_SUMSTATS = [r'$sp$',r'$rpot$',r'$\sigma_{rpot}$','$m_1$','$m_2$','$m_3$','$m_4$']

# define model, prior, summary statistics and generator
n_processes = 10

seeds_model = np.arange(1,n_processes+1,1)
m = []
for i in range(n_processes):
    m.append(HodgkinHuxley(I, dt, V0=obs['data'][0], reduced_model=False, seed=seeds_model[i],
                           cython=cython,prior_log=prior_log))
p = utils.prior(true_params=true_params,prior_uniform=prior_uniform,
                prior_extent=prior_extent,prior_log=prior_log, seed=seed_p)
s = HodgkinHuxleyStatsMoments(t_on=t_on, t_off=t_off, n_xcorr=n_xcorr, n_mom=n_mom, n_summary=n_summary)
g = dg.MPGenerator(models=m, prior=p, summary=s)
    
bounds = np.asarray([p.lower,p.upper]).T<jupyter_output><empty_output><jupyter_text>pilot run<jupyter_code>seed_inf = 1

pilot_samples = 1000

# network setup
n_hiddens = [50,50]

# convenience
prior_norm = True

# MAF parameters
density = 'maf'
n_mades = 5         # number of MADES

# inference object
res = infer.SNPEC(g,
                obs=obs_stats,
                n_hiddens=n_hiddens,
                seed=seed_inf,
                pilot_samples=pilot_samples,
                n_mades=n_mades,
                prior_norm=prior_norm,
                density=density,
                verbose=True)<jupyter_output><empty_output><jupyter_text>Run genetic algorithm<jupyter_code>algo = 'ibea'
offspring_size = 1000
max_ngen = 100
seed_ibea = 5 # 5,6,7,8,9
final_pop, halloffame, log, hist = run_deap(model=m[0], bounds=bounds, labels_params=labels_params,
                                            summary=s, obs_stats=obs_stats, labels_sum_stats=LABELS_HH_SUMSTATS,
                                            stats_std=res.stats_std,algo=algo, offspring_size=offspring_size,
                                            max_ngen=max_ngen, seed=seed_ibea)
io.save_pkl((final_pop,halloffame,log,hist),'./results/'+\
            'sim_run_2_offspr'+str(offspring_size)+'_max_gen'+str(max_ngen)+ '_param8_7stats_' + algo + '.pkl')
final_pop, halloffame, log, hist = io.load_pkl('./results/'+\
                                               'sim_run_2_offspr'+str(offspring_size)+\
                                               '_max_gen'+str(max_ngen)+ '_param8_7stats_' + algo + '.pkl')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1197986577181208, 'fraction_numerical': 0.015771812080536914, 'mean_word_length': 3.0668485675306956, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '386357', 'license': 'MIT', 'n_tokens_mistral': 1156, 'n_tokens_neox': 1092, 'n_words': 159, 'path': '5_hh/03_fitting_genetic_algo.ipynb', 'repo_name': 'mackelab/IdentifyMechanisticModels_2020', 'size': '2980'}