#############################
# 训练：
# CUDA_VISIBLE_DEVICES=7 python src/main.py --mode train --config src/config.yaml
# 测试：
# python src/main.py --mode test --checkpoint checkpoints/model_final.pt --k-test 6.0
# python src/main.py --mode test --checkpoint checkpoints/model_final.pt --k-test 6.0 --center 0.3,0.6 --radius 0.15

# 可视化：
# python src/main.py --mode viz --checkpoint checkpoints/model_iter0400.pt
# python src/main.py --mode viz --checkpoint checkpoints/model_iter0100.pt --k-test 8.0 --center 0.6,0.5 --radius 0.1
#
#
# sbatch方式：
# 训练
# sbatch sbatch_train.sh
#
###########################

algorithm:
    batch_size: 32
    discount_factor: 1.0
    ppo:
        clip_range: 0.2
        entropy_coefficient: 0.005
        epochs_per_iteration: 3 # 每轮迭代对同一批 rollout 数据重复训练几个 epoch
        gae_lambda: 0.95
        initial_log_std: -2.0 # 初始动作 log 标准差，exp(-2)≈0.135
        max_grad_norm: 0.5
        num_rollout_steps: 256
        value_function_coefficient: 0.5
    use_gpu: true
environment:
    mesh_refinement:
        edge_features:
            euclidean_distance: true
        element_features:
            element_penalty: true
            is_sbc_boundary: true
            k_local_sqrt_vol: true
            solution_std: true
            timestep: true
            volume: true
            wave_number: false
            x_position: false
            y_position: false
            dist_to_interface: true
        element_limit_penalty: 10000
        element_penalty:
            sample_penalty: false
            value: 0.06
        fem:
            domain:
                boundary:
                    - 0
                    - 0
                    - 1
                    - 1
                initial_num_elements: 65
            helmholtz:
                k_ref: 6.0
                k_exponent: 2.0
                scatterer:
                    cx: 0.5
                    cx_max: 0.8
                    cx_min: 0.2
                    cy: 0.5
                    cy_max: 0.8
                    cy_min: 0.2
                    eps_r: 10.0
                    eps_r_max: 8.0
                    eps_r_min: 2.0
                    mode: random_uniform
                    radius: 0.1
                    radius_max: 0.2
                    radius_min: 0.05
                wave_number: 30.0
                wave_number_max: 15.0
                wave_number_min: 3.0
                wave_number_mode: random_uniform
            num_pdes: 100
            pde_type: helmholtz
            pre_asymptotic_N: 2.0
        maximum_elements: 50000
        num_timesteps: 4
        refinement_strategy: continuous_sizing_field
        reward_type: spatial
        global_reward_alpha: 0.5 # 全局奖励权重
        # rho_weights:
        #     w_int: 0.0 # ρ_int 权重 (代码自动除以 k²)
        #     w_jump: 1.0 # ρ_jump 权重 (代码自动除以 k)
        #     w_sbc: 20.0 # ρ_sbc 权重 (代码自动除以 k)
iterations: 401
network:
    actor:
        mlp:
            activation_function: tanh
            num_layers: 2
    base:
        edge_dropout: 0.1
        scatter_reduce: mean
        stack:
            mlp:
                activation_function: leakyrelu
                num_layers: 2
            num_steps: 2
    critic:
        mlp:
            activation_function: tanh
            num_layers: 2
    latent_dimension: 64
    training:
        learning_rate: 0.0003
        lr_decay: 1
        optimizer: adam
