On-Line Optimization of Switched-Mode