Identifying when animals are in pain is good for moral reasons, of course, but also for maximizing their productivity.