def wikenheiser2015_lookahead(goal_no, start, alpha, tau, goal_weight=20., goal_absorb=True, backmove=False, opt_policy_weight=0.9, sigma=0.5, n_samp=n_samp, n_step=n_step): ENVlh = CircularTrack(n_state=n_state_circ, start=start, goal_no=goal_no, goal_weight=goal_weight, goal_absorb=goal_absorb, backmove=backmove, opt_policy_weight=opt_policy_weight) GENlh = Generator(ENV=ENVlh, symmetrize=symmetrize, jump_rate=jump_rate) PROPlh = Propagator(GEN=GENlh, sigma=sigma, tau=tau, alpha=alpha) EXPlh = Explorer(PROP=PROPlh, rho_init=start, no_dwell=no_dwell) EXPlh.sample_sequences(n_samp=n_samp, n_step=n_step) EXPlh.traj_width = 0 EXPlh.start_pos = True EXPlh.state_msize = state_msize return EXPlh, PROPlh, GENlh, ENVlh
def circulartrack_lookahead(start, alpha, tau, sigma=1, n_samp=n_samp, n_step=n_step): ENVlh = CircularTrack(n_state=n_state_circ, start=start, goal_no=None) GENlh = Generator(ENV=ENVlh, symmetrize=symmetrize, jump_rate=jump_rate) PROPlh = Propagator(GEN=GENlh, sigma=sigma, tau=tau, alpha=alpha) EXPlh = Explorer(PROP=PROPlh, rho_init=start, no_dwell=no_dwell) EXPlh.sample_sequences(n_samp=n_samp, n_step=n_step) EXPlh.traj_width = 0 EXPlh.start_pos = True EXPlh.state_msize = state_msize return EXPlh, PROPlh, GENlh, ENVlh
ENV.start = start GEN = Generator(ENV=ENV, symmetrize=symmetrize, jump_rate=jump_rate) # generate trajectories under diffusion (alpha) and turbulence (+ spectral noise) PROPt = Propagator(GEN=GEN, sigma=sigma, tau=tau, alpha=alpha_turb, spec_noise=spec_noise) PROPd = Propagator(GEN=GEN, sigma=sigma, tau=tau, alpha=alpha_diff, spec_noise=0.) PROPd.plot_prop_kernels(n=6) EXPt = Explorer(PROP=PROPt, rho_init=ENV.start, mass=mass, no_dwell=no_dwell) EXPd = Explorer(PROP=PROPd, rho_init=ENV.start, mass=mass, no_dwell=no_dwell) EXPt.set_viz_scheme(**kwargs) EXPd.set_viz_scheme(**kwargs) EXPt.sample_sequences(n_samp=n_samp, n_step=n_step) EXPd.sample_sequences(n_samp=n_samp, n_step=n_step) EXPt.plot_trajectory() EXPd.plot_trajectory() EXPt.crosscorr_rho(smooth_sigma=0.) EXPd.crosscorr_rho(smooth_sigma=0.5) # SAMPLE TRAJECTORIES ENV_OB = OpenBox(scale=scale_OB) GEN_OB = Generator(ENV=ENV_OB, symmetrize=symmetrize, jump_rate=jump_rate) PROPt_OB = Propagator(GEN=GEN_OB, sigma=sigma,
exp_eff_s = [] exp_eff_d = [] exp_eff_o = [] cov_visits_s = [] cov_visits_d = [] cov_visits_o = [] traj_cost_sum_s = [] traj_cost_sum_d = [] traj_cost_sum_o = [] n_visits_s = [] n_visits_d = [] n_visits_o = [] for worker in range(n_workers_exp): EXPd = Explorer(PROP=PROPd, rho_init=rho_init_exp, no_dwell=no_dwell_exp, label='DIFF_w%i_%i_%i' % (worker, n_step_exp, n_samp_exp), target_dir=simdir) EXPs = Explorer(PROP=PROPs, rho_init=rho_init_exp, no_dwell=no_dwell_exp, label='SUPERDIFF_w%i_%i_%i' % (worker, n_step_exp, n_samp_exp), target_dir=simdir) EXPo = Explorer(PROP=PROPo, rho_init=rho_init_exp, no_dwell=no_dwell_exp, label='ACMIN_w%i_%i_%i' % (worker, n_step_exp, n_samp_exp), target_dir=simdir) EXPd.sample_sequences(n_samp=n_samp_exp, n_step=n_step_exp)
GEN = Generator(ENV=ENV, symmetrize=symmetrize, jump_rate=jump_rate) GENh = Generator(ENV=ENV, symmetrize=symmetrize, jump_rate=jump_rate) GENh.highlight_states(states=states_home, weight=goal_weight) PROPd = Propagator(GEN=GENh, tau=tau_diff, alpha=alpha_diff) PROPs = Propagator(GEN=GENh, tau=tau_sdiff, alpha=alpha_sdiff) # multi-start away explorers EXPds = [] EXPss = [] PROPds = [] PROPss = [] for start in states_away: EXPd = Explorer(PROP=PROPd, rho_init=start, no_dwell=no_dwell, label='diff-start%i' % start) EXPs = Explorer(PROP=PROPs, rho_init=start, no_dwell=no_dwell, label='sdiff-start%i' % start) PROPds.append(PROPd.etO[start, :]) PROPss.append(PROPs.etO[start, :]) EXPd.sample_sequences(n_samp=n_samp_away, n_step=n_step_away) EXPs.sample_sequences(n_samp=n_samp_away, n_step=n_step_away) EXPds.append(EXPd) EXPss.append(EXPs) # single-start away explorers EXPda = Explorer(PROP=PROPd, rho_init=state_away_default,
alpha=alpha_diff) PROP_sdiff_base = Propagator(GEN=GEN, sigma=sigma, tau=tau_sdiff, alpha=alpha_sdiff) PROP_diff_taus = [ Propagator(GEN=GEN, sigma=sigma, tau=tau, alpha=alpha_diff) for tau in taus ] PROP_sdiff_taus = [ Propagator(GEN=GEN, sigma=sigma, tau=tau, alpha=alpha_sdiff) for tau in taus ] # parallel explorer EXP_diff_base = Explorer(PROP=PROP_diff_base, rho_init=start_prop, no_dwell=no_dwell, label='diffusion') EXP_sdiff_base = Explorer(PROP=PROP_sdiff_base, rho_init=start_prop, no_dwell=no_dwell, label='superdiffusion') EXP_diff_base.sample_sequences(n_samp=n_samp, n_step=n_step) EXP_sdiff_base.sample_sequences(n_samp=n_samp, n_step=n_step) EXP_diff_base.compute_diagnostics(target_coverage=target_coverage, flight_vision=flight_vision) EXP_sdiff_base.compute_diagnostics(target_coverage=target_coverage, flight_vision=flight_vision) # serial explorer EXP_diff_oneshot = Explorer(PROP=PROP_diff_base, rho_init=start_prop,
autoprop_off=False, cbar=False) PROP_sdiff.plot_prop_kernels(n=5, first_state=start, wrap_col=5, autoprop_off=False, cbar=False) PROP_sdiff_sr.plot_prop_kernels(n=5, first_state=start, wrap_col=5, autoprop_off=False, cbar=False) # %% explorers - sample trajectories EXP_diff = Explorer(PROP=PROP_diff, rho_init=start, no_dwell=no_dwell, label='diffusion [complete]') EXP_diff_sr = Explorer(PROP=PROP_diff_sr, rho_init=start, no_dwell=no_dwell, label='diffusion [scale ratio]') EXP_sdiff = Explorer(PROP=PROP_sdiff, rho_init=start, no_dwell=no_dwell, label='superdiffusion [complete]') EXP_sdiff_sr = Explorer(PROP=PROP_sdiff_sr, rho_init=start, no_dwell=no_dwell, label='superdiffusion [scale ratio]') EXP_diff.sample_sequences(n_samp=n_samp, n_step=n_step_diff)