This work presents a practical C++ implementation of a physics-informed neural network (PINN) for a fractional-order damped oscillator. A fully connected network outputs displacement and velocity, so the governing dynamics are enforced through a compact state-space residual involving first and second time derivatives. Integer-order derivatives are obtained via automatic differentiation, which removes finite-difference noise and preserves smooth, consistent gradients during training. The history-dependent fractional damping term is incorporated using the classical L1 discretization on a uniform time grid, which makes each residual evaluation depend on the entire predicted solution history and naturally captures memory effects. The training objective combines the squared residual norms at collocation points with a strongly weighted initial-condition penalty to control drift and stabilize early iterations. Gradients of the complete objective with respect to all network parameters are computed using reverse-mode automatic differentiation in CppAD by constructing a scalar loss function of a flat parameter vector, enabling efficient gradient-based optimization. Parameters are updated with the Adam algorithm using bias correction and double-precision moment accumulation for numerical robustness. This implementation includes deterministic parameter packing, explicit size checks, and lightweight diagnostics of boundary values during training, improving reproducibility and debuggability. Overall, the code provides an end-to-end baseline for PINN-based simulation of fractional-order oscillatory systems and can be readily extended to include external forcing, alternative loss weight schedules, and parameter identification from measurement data.
Previous Article in event
Next Article in event
Practical PINN Implementation for a Fractional-Order Damped Oscillator with CppAD-Computed Gradients
Published:
08 April 2026
by MDPI
in The 1st International Online Conference on Fractal and Fractional
session Fractional Calculus in Machine Learning: Applications and Challenges
Abstract:
Keywords: PINN; Fractional differential; Equations; Optimization
