diff --git a/experiments_vrep.py b/experiments_vrep.py index 89356b8..8b126b5 100644 --- a/experiments_vrep.py +++ b/experiments_vrep.py @@ -45,28 +45,28 @@ def log_callback(state): def experiment_filename(_source, _setup, _tag): return "{}_{}_{}".format(_source, _setup, _tag) - +# TODO folder creation if __name__ == '__main__': extra_tag = "_bd10" mode = [EXP_HEXAPOD_GOAL_REACHING] if EXP_HEXAPOD_GOAL_REACHING in mode: - extra_tag = "_300522_c" + extra_tag = "_030722_d" target_experiment_tag = EXP_HEXAPOD_GOAL_REACHING + extra_tag num_state_centers = 8 sensor_dim = 4 ## - total_iteration_n = 300000 - continue_to =0 + total_iteration_n = 200000 + continue_to = 1 # start_at = 1440 start_at = -1 record_jump = 100 record_capacity = 40 sens_window = 40 - # command_override_start = 1000 + # command_override_start = 1500 command_override_start = 0 diff --git a/experiments_vrep_vis.py b/experiments_vrep_vis.py index 821a9e8..e2725bd 100644 --- a/experiments_vrep_vis.py +++ b/experiments_vrep_vis.py @@ -31,11 +31,17 @@ def __call__(self, *args, **kwargs): # file_name = "hexapod_goal_reaching_ab_cpg_sync_frq400_str10.hdf5" # file_name = "hexapod_goal_reaching_ab_cpg_sync_frq420_str10.hdf5" # file_name = "hexapod_goal_reaching_ab_cpg_sync_frq533_str10.hdf5" -file_name = "hexapod_goal_reaching_ab_cpg_sync_frq666_str10.hdf5" -# file_name = "learning_hexapod_a_0.hdf5" - -# mode = [1] -mode = [2] +# file_name = "hexapod_goal_reaching_ab_cpg_sync_frq666_str10.hdf5" +# file_name = "hexapod_goal_reaching_300522_c_1.hdf5" +# file_name = "hexapod_goal_reaching_010722_c_1.hdf5" +# file_name = "hexapod_goal_reaching_020722_a_0.hdf5" +# file_name = "hexapod_goal_reaching_020722_b_0.hdf5" +# file_name = "hexapod_goal_reaching_020722_c_0.hdf5" +# file_name = "hexapod_goal_reaching_020722_d_0.hdf5" +file_name = "hexapod_goal_reaching_030722_d_0.hdf5" + +mode = [1] +# mode = [2] # mode = [3] # mode += [11] @@ -65,22 +71,22 @@ def __call__(self, *args, **kwargs): ctr = Counter() # limit_cycle_controller.state_evolution(record, plt.figure(ctr())) - limit_cycle_controller.epicycle_evolution(record, plt.figure(ctr())) + # limit_cycle_controller.epicycle_evolution(record, plt.figure(ctr())) limit_cycle_controller_contextual.context_control_evol(record, plt.figure(ctr())) - limit_cycle_controller_contextual.context_quality_evol(record, plt.figure(ctr()), log=False) - limit_cycle_controller_contextual.motor_context_convergence(record, plt.figure(ctr()), squared_norm=True) - limit_cycle_controller_contextual.multi_control_outputs(record, plt.figure(ctr())) + # limit_cycle_controller_contextual.context_quality_evol(record, plt.figure(ctr()), log=False) + # limit_cycle_controller_contextual.motor_context_convergence(record, plt.figure(ctr()), squared_norm=True) + # limit_cycle_controller_contextual.multi_control_outputs(record, plt.figure(ctr())) # - limit_cycle_controller.y_mem_evolution(record, plt.figure(ctr()), sensor_m=0, size=2) - limit_cycle_controller.y_mem_evolution(record, plt.figure(ctr()), sensor_m=1, size=2) + # limit_cycle_controller.y_mem_evolution(record, plt.figure(ctr()), sensor_m=0, size=2) + # limit_cycle_controller.y_mem_evolution(record, plt.figure(ctr()), sensor_m=1, size=2) # limit_cycle_controller.y_mem_evolution(record, plt.figure(ctr()), sensor_m=2, size=2) # limit_cycle_controller.y_mem_evolution(record, plt.figure(ctr()), sensor_m=3, size=2) # limit_cycle_controller.y_mem_evolution(record, plt.figure(ctr()), sensor_m=1, size=4) # limit_cycle_controller.y_mem_evolution(record, plt.figure(ctr()), sensor_m=2, size=4) # # - limit_cycle_controller.u_mem_evolution(record, plt.figure(ctr()), motor_n=0, size=2) + # limit_cycle_controller.u_mem_evolution(record, plt.figure(ctr()), motor_n=0, size=2) # limit_cycle_controller.u_mem_evolution(record, plt.figure(ctr()), motor_n=1, size=4) # limit_cycle_controller.u_mem_evolution(record, plt.figure(ctr()), motor_n=2, size=4) # robot_position_control.position_command_evolution(record, plt.figure(ctr())) @@ -107,7 +113,7 @@ def __call__(self, *args, **kwargs): # # robot_goal_differential_control.diff_control_evol(record, plt.figure(ctr())) # robot_goal_differential_control.pid_evol(record, plt.figure(ctr())) - for i in [1, 2]: + for i in [0, 1]: limit_cycle_controller_contextual.model_context_parameter_convergence(record, plt.figure(ctr()), context=i) limit_cycle_controller_contextual.multi_io_matricies(record, plt.figure(ctr()), ctx=i, sensor_modewise_norming=True) @@ -125,14 +131,14 @@ def __call__(self, *args, **kwargs): # limit_cycle_controller_contextual.bias_evolution(record, plt.figure(ctr()), ctx=i) # limit_cycle_controller_contextual.weight_matrix_evolution(record, plt.figure(ctr()), size=10,ctx=i) - limit_cycle_controller_contextual.phase_combined_sensory_evolution(record, plt.figure(ctr()), ctx=i) + # limit_cycle_controller_contextual.phase_combined_sensory_evolution(record, plt.figure(ctr()), ctx=i) # robot_position_control.u_leg_position(record, plt.figure(ctr()), ctx=i) # limit_cycle_controller_contextual.sensory_posterior_variance(record, plt.figure(ctr()), ctx=i) # robot_position_control.regularization_leg_budget(record, plt.figure(ctr()), ctx=i) # limit_cycle_controller_contextual.u_dif_evolution(record, plt.figure(ctr()), ctx=i) # - lrn_durs, ctr_durs, _ = limit_cycle_controller_contextual.get_context_management_durations(record, ctx=i) + # lrn_durs, ctr_durs, _ = limit_cycle_controller_contextual.get_context_management_durations(record, ctx=i) # for m in [0, 1, 3]: # for lrn_dur in lrn_durs: # limit_cycle_controller_contextual.posterior_sensory_variance_detail(record, plt.figure(ctr()), t=lrn_dur[1][0], diff --git a/models/limit_cycle_controller_contextual.py b/models/limit_cycle_controller_contextual.py index aff7bfe..31b5e7b 100644 --- a/models/limit_cycle_controller_contextual.py +++ b/models/limit_cycle_controller_contextual.py @@ -1,5 +1,6 @@ from dynsys_framework.execution_helpers.model_executor_parameters import ModelExecutorParameters import numpy as np +import models.temporary_constants as TS xp = np import time @@ -507,8 +508,8 @@ def _weights_dyn(w, model_err, motor_diff, state_phase_activator, motor_phase_ac def d_motor_expected(motor_err, weights, motor_lr, ctx_ctr_sel, regularization, decay=0.): active = xp.einsum("imjd,nmcdx,ix->injcx", motor_err, weights, ctx_ctr_sel, optimize=True) * motor_lr if np.sum(ctx_ctr_sel) > 0: - return active * 0.0000001 - regularization * 0.01 #- decay * 0.00001 - # return active * 0.000001 - regularization * 0.01 - decay * 0.00001 #FIXME + # return active * 0.0000001 - regularization * 0.01 #- decay * 0.00001 + return active * TS.U_EXP_ACT_LR - regularization * 0.01 - decay * 0.00001 #FIXME else: return np.zeros(active.shape) @@ -635,7 +636,7 @@ def model_quality_mean(quality_mean, quality): goes_down = quality < quality_mean goes_up = quality >= quality_mean # return (quality - quality_mean) * (goes_down * 0.02 + goes_up * 0.0005) #FIXME - return (quality - quality_mean) * (goes_down * 0.08 + goes_up * 0.001) + return (quality - quality_mean) * (goes_down * TS.QUALITY_MEAN_DOWN_LR + goes_up * TS.QUALITY_MEAN_UP_LR) def model_qiality_variance(quality_variance, quality_mean, quality): diff --git a/models/temporary_constants.py b/models/temporary_constants.py index e69de29..d90f209 100644 --- a/models/temporary_constants.py +++ b/models/temporary_constants.py @@ -0,0 +1,12 @@ + +# U_EXP_ACT_LR = 0.0001 +U_EXP_ACT_LR = 1e-6 + +# QUALITY_MEAN_UP_LR = 0.001 +QUALITY_MEAN_UP_LR = 0.0005 +# QUALITY_MEAN_UP_LR = 0.005 +# QUALITY_MEAN_UP_LR = 0.0001 + + +# QUALITY_MEAN_DOWN_LR = 0.08 +QUALITY_MEAN_DOWN_LR = 0.02 \ No newline at end of file diff --git a/scenes/plane.ttt b/scenes/plane.ttt index ee105b3..b9a7edc 100644 Binary files a/scenes/plane.ttt and b/scenes/plane.ttt differ