added optimality calculation to agents