Move anomaly score function out of OPF.