Real m_unNumPoints=1000; /*If you want to compute the loop function at the end of the experiment put it in ComputePerformanceInExperiment */ Real CalculateObjectiveFunction() { int i; CVector2 point; Real dA=0; Real dP=0; for(i = 0; i < m_unNumPoints; i++){ Real d = 1.69; //DIAGONAL *2 point = RandomPointOnSquareArea(spot1,side); for (CSpace::TAnyEntityMap::iterator itEPuckEntity = m_tEPuckEntityMap.begin(); itEPuckEntity != m_tEPuckEntityMap.end(); itEPuckEntity++) { CEPuckEntity* cEPuckEntity = any_cast ((*itEPuckEntity).second); CVector2 cps = cEPuckEntity->GetEmbodiedEntity().GetPosition().ProjectOntoXY(); if(IsOnSquareArea(cps,spot1,side)){ if((point - cps).Length() < d){ d = (point - cps).Length(); } } } dA += d; } dA /= m_unNumPoints; for(i = 0; i < m_unNumPoints; i++){ Real d = 3.77; point = RandomPointOnCirclePerimeter(spot2,Sqrt(squareRatius)); for (CSpace::TAnyEntityMap::iterator itEPuckEntity = m_tEPuckEntityMap.begin(); itEPuckEntity != m_tEPuckEntityMap.end(); itEPuckEntity++) { CEPuckEntity* cEPuckEntity = any_cast ((*itEPuckEntity).second); CVector2 cps = cEPuckEntity->GetEmbodiedEntity().GetPosition().ProjectOntoXY(); if(IsOnCirclePerimeter(cps,0.04f,spot2,Sqrt(squareRatius))){ if((point - cps).Length() < d){ d = (point - cps).Length(); } } } dP += d; } dP /= m_unNumPoints; Real performance = (dA/m_fDoptA) + (dP/m_fDoptP); return performance; }