def run_deap(model,
             bounds,
             labels_params,
             summary,
             obs_stats,
             labels_sum_stats,
             stats_std,
             algo='ibea',
             offspring_size=10,
             max_ngen=10,
             seed=None):
    """Runs genetic algorithm

    Parameters
    ----------
    model :
        Model
    bounds :
        Bounds
    labels_params : list of str
        Labels of parameters
    summary :
        Function to compute summary statistics
    obs_stats :
        Observed summary statistics
    labels_sum_stats :
        Labels of summary statistics
    stats_std : array
        Standard deviations of summary statistics on pilot run
    algo: str
        Determines which genetic algorithm is run.
        So far only ibea ('ibea') and deap default ('deap') are implemented
    offspring_size : int
        Offspring size
    max_ngen : int
        Maximum number of generations
    seed : int or None
        If set, randomness in sampling is disabled
    """

    n_params = len(bounds[:, 0])

    params = []
    for i in range(n_params):
        params.append(
            Parameter(labels_params[i], bounds=[bounds[i, 0], bounds[i, 1]]))

    # choose and run genetic algorithm
    evaluator = hh_evaluator(model, summary, obs_stats, labels_sum_stats,
                             stats_std, params)

    if algo == 'ibea':
        opt = bpopt.deapext.optimisations.IBEADEAPOptimisation(
            evaluator, offspring_size=offspring_size, seed=seed)
    else:
        opt = bpopt.deapext.optimisations.DEAPOptimisation(
            evaluator, offspring_size=offspring_size, seed=seed)

    final_pop, halloffame, log, hist = opt.run(max_ngen=max_ngen)

    return final_pop, halloffame, log, hist
Beispiel #2
0
    if feature_name in specific_filter_list:
        #if 'Spikecount_3.0x' == tt.name or 
        if 'Spikecount_1.5x' == tt.name:
            ft = NUFeatureAllenMultiSpike(tt,model,cnt,yes_list,yes_list,spike_obs)
            objective = ephys.objectives.SingletonObjective(
                feature_name,
                ft)
            objectives.append(objective)

       
score_calc = ephys.objectivescalculators.ObjectivesCalculator(objectives) 
      
lop={}

for k,v in MODEL_PARAMS["ADEXP"].items():
    p = Parameter(name=k,bounds=v,frozen=False)
    lop[k] = p

simple_cell.params = lop





sweep_protocols = []
for protocol_name, amplitude in [('step1', 0.05)]:

    protocol = ephys.protocols.SweepProtocol(protocol_name, [None], [None])
    sweep_protocols.append(protocol)
twostep_protocol = ephys.protocols.SequenceProtocol('twostep', protocols=sweep_protocols)