Optimizing control systems