population_file = pd.read_csv(path, names=['generation', 'index', 'fitness', 'candidate'], header=None) # estimate error landscape with open('./results/params.json') as f: params = json.load(f) p1_range = np.arange(params['lower_bound'], params['upper_bound']+0.0001, 0.01) p2_range = np.arange(params['lower_bound'], params['upper_bound']+0.0001, 0.01) if os.path.isfile('./results/error_landscape.npy'): error = np.load('./results/error_landscape.npy') else: candidates = list() for i, p1 in enumerate(p1_range): for j, p2 in enumerate(p2_range): candidates.append([p1, p2]) problem = CellFitProblem(params) error = problem.evaluator(candidates, []) error = np.reshape(error, (len(p1_range), len(p2_range))) with open('./results/error_landscape.npy', 'w') as f: np.save(f, error) fig = plt.figure() ax = p3.Axes3D(fig) ax.set_xlim3d([0.0, 1.0]) ax.set_xlabel('X') ax.set_ylim3d([0.0, 1.0]) ax.set_ylabel('Y') ax.set_zlabel('Z') ax.view_init(elev=20, azim=50) X, Y = np.meshgrid(p1_range, p2_range) surf = ax.plot_surface(X, Y, error.T, rstride=1, cstride=1, cmap=cm.coolwarm, alpha=0.6, linewidth=0, antialiased=False)
] params = { 'maximize': False, 'normalize': False, 'model_dir': '../../model/cells/toymodel1.json', 'mechanism_dir': '../../model/channels/schmidthieber', 'variables': variables, 'data_dir': '../../data/toymodels/toymodel1/ramp.csv', 'get_var_to_fit': 'get_v', 'fitnessweights': [1.0], 'errfun': 'rms', 'insert_mechanisms': True } problem = CellFitProblem(**params) dt = problem.simulation_params['dt'] time_cut = 20 problem.simulation_params['tstop'] = time_cut # TODO problem.simulation_params['i_amp'] = problem.simulation_params['i_amp'][:time_cut/dt+1] subsample = 5 # initialize pseudo random number generator seed = time() prng = Random() prng.seed(seed) # initialize data t = np.arange(0, problem.simulation_params['tstop']+dt, dt) i_inj = problem.simulation_params['i_amp'] data = np.zeros((n_data, len(t)/subsample, 2)) # inputs are the trace of v and i_inj