Intelligent capacitor compensation method