I have the same app optimization problem after the update to 5.1.1.
Every reboot, the phone optimizes apps. It doesn't matter if the phone is plug into the charger or not (usually is).
But I just did a test now and I could reboot without apps optimization :)
My guess is because I reboot...