//! KAN (Kolmogorov-Arnold Network) configuration.
//!
//! Defines hyperparameters for KAN models including B-spline grid size,
//! spline order, layer widths, and training parameters.

use serde::{Deserialize, Serialize};

/// Configuration for a Kolmogorov-Arnold Network.
///
/// KAN replaces fixed activation functions (`ReLU`) with learnable B-spline
/// activations on each edge, enabling the network to discover arbitrary
/// non-linear relationships.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct KANConfig {
    /// Number of B-spline grid points per activation function.
    /// More points = finer approximation but more parameters.
    pub grid_size: usize,
    /// B-spline order (degree + 1). 4 = cubic splines.
    pub spline_order: usize,
    /// Layer widths including input and output dimensions.
    /// Example: `[51, 32, 16, 1]` means input=51, two hidden layers, output=1.
    pub layer_widths: Vec<usize>,
    /// Learning rate for `AdamW` optimizer.
    pub learning_rate: f64,
    /// L2 weight decay for regularization.
    pub weight_decay: f64,
    /// Maximum gradient norm for clipping.
    pub grad_clip: f64,
}

impl Default for KANConfig {
    fn default() -> Self {
        Self {
            grid_size: 5,
            spline_order: 4,
            layer_widths: vec![51, 32, 16, 1],
            learning_rate: 1e-3,
            weight_decay: 1e-4,
            grad_clip: 1.0,
        }
    }
}
