"""
SAC state-space: 2M * 8envs (orig 12) * 5seeds * 4 methods (ours vs mlp vs diag fourier vs l2 regul.)
SAC images: 2M * 4envs * 5seeds * 2methods
SAC ablation Value vs Policy vs Both vs Baseline: 2M * 4envs * 5seeds * 2NewMethods
SAC ablation: 1M * 4envs * 3seeds * 3methods (can leave it as is)
SAC no critic: 1M * 4envs * 3seeds * 2methods ---> change to 5seeds and 5M (lower priority)
"""
import math

envs = [
    'dm.cheetah.run',
    'dm.quadruped.walk',
    'dm.hopper.hop'
]

lff_configs = [
    (64, 0.003),
    (1024, 0.001),
    (1024, 0.001),
]

env_dims = [
    (17, 6),
    (78, 12),
    (15, 4),
]

times = (1000000, 1000000, 1000000)
noise_scales = [0.003, 0.01, 0.03]
samples = [5, 20]

# LFF: (obs+action) x fourier_dim / 2 + (fourier_dim + obs+action) x hidden_dim
# MLP: (obs + action+1) x first dim + first_dim x hidden_dim
# = first_dim x (hidden_dim + obs + action + 1)
first_dims = []
for i in range(len(env_dims)):
    input_dim = env_dims[i][0] + env_dims[i][1]
    fourier_dim = lff_configs[i][0]
    lff_params = input_dim * (fourier_dim // 2) + (fourier_dim + input_dim) * 1024
    first_dims.append(math.ceil(lff_params / (1024 + 1 + input_dim)))

lr = '1e-4'
count = 0
for i, env in enumerate(envs):
    commands = []
    base_str = f"python main.py --policy PytorchSAC --env {env} --start_timesteps 5000 --hidden_dim 1024 --batch_size 1024 --n_hidden 2 --lr {lr}"
    max_timesteps = str(times[i])

    # MLP
    for noise_scale in noise_scales:
        for n_critic_samples in samples:
            for seed in [10]:
                commands.append(f"python main.py --policy SmoothedPytorchSAC --env {env} --start_timesteps 5000 --hidden_dim 1024"
                                f" --network_class MLP --batch_size 1024 --n_hidden 3 --first_dim {first_dims[i]} --lr {lr}"
                                f" --seed {seed} --noise_scale {noise_scale} --n_critic_samples {n_critic_samples}")

    for command in commands:
        count += 1
        print(f'CUDA_VISIBLE_DEVICES=0 taskset -c a-b {command} --max_timesteps {max_timesteps} &')
        if count % 10 == 0:
            print(count)
print(count)
# ablation_envs = []

"""
SAC state-space: 2M * 8envs (orig 12) * 5seeds * 4 methods (ours vs mlp vs diag fourier vs l2 regul.)
SAC images: 2M * 4envs * 5seeds * 2methods
SAC ablation Value vs Policy vs Both vs Baseline: 2M * 4envs * 5seeds * 2NewMethods
SAC ablation: 1M * 4envs * 3seeds * 3methods (can leave it as is)
SAC no critic: 1M * 4envs * 3seeds * 2methods ---> change to 5seeds and 5M (lower priority)
"""
import math

envs = [
    'dm.cheetah.run',
    'dm.quadruped.walk',
    'dm.hopper.hop'
]

lff_configs = [
    (64, 0.003),
    (1024, 0.001),
    (1024, 0.001),
]

env_dims = [
    (17, 6),
    (78, 12),
    (15, 4),
]

times = (1000000, 1000000, 1000000)
noise_scales = [0.003, 0.01, 0.03]
samples = [5, 20]

# LFF: (obs+action) x fourier_dim / 2 + (fourier_dim + obs+action) x hidden_dim
# MLP: (obs + action+1) x first dim + first_dim x hidden_dim
# = first_dim x (hidden_dim + obs + action + 1)
first_dims = []
for i in range(len(env_dims)):
    input_dim = env_dims[i][0] + env_dims[i][1]
    fourier_dim = lff_configs[i][0]
    lff_params = input_dim * (fourier_dim // 2) + (fourier_dim + input_dim) * 1024
    first_dims.append(math.ceil(lff_params / (1024 + 1 + input_dim)))

lr = '1e-4'
count = 0
for i, env in enumerate(envs):
    commands = []
    base_str = f"python main.py --policy PytorchSAC --env {env} --start_timesteps 5000 --hidden_dim 1024 --batch_size 1024 --n_hidden 2 --lr {lr}"
    max_timesteps = str(times[i])

    # MLP
    for noise_scale in noise_scales:
        for n_critic_samples in samples:
            for seed in [10]:
                commands.append(f"python main.py --policy SmoothedPytorchSAC --env {env} --start_timesteps 5000 --hidden_dim 1024"
                                f" --network_class MLP --batch_size 1024 --n_hidden 3 --first_dim {first_dims[i]} --lr {lr}"
                                f" --seed {seed} --noise_scale {noise_scale} --n_critic_samples {n_critic_samples}")

    for command in commands:
        count += 1
        print(f'CUDA_VISIBLE_DEVICES=0 taskset -c a-b {command} --max_timesteps {max_timesteps} &')
        if count % 10 == 0:
            print(count)
print(count)
# ablation_envs = []

SAC state-space: 2M * 8envs (orig 12) * 5seeds * 4 methods (ours vs mlp vs diag fourier vs l2 regul.) SAC images: 2M * 4envs * 5seeds * 2methods SAC ablation Value vs Policy vs Both vs Baseline: 2M * 4envs * 5seeds * 2NewMethods SAC ablation: 1M * 4envs * 3seeds * 3methods (can leave it as is) SAC no critic: 1M * 4envs * 3seeds * 2methods ---> change to 5seeds and 5M (lower priority) # LFF: (obs+action) x fourier_dim / 2 + (fourier_dim + obs+action) x hidden_dim # MLP: (obs + action+1) x first dim + first_dim x hidden_dim # = first_dim x (hidden_dim + obs + action + 1) # MLP # ablation_envs = []