Advanced intelligent control and optimization for cardiac pacemaker systems