Optimal allocation of inspection effort