From 809f6344ffc0a0b12b2e08bef1a44cbb98369f1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Zieli=C5=84ski?= Date: Mon, 10 Apr 2023 17:59:59 +0200 Subject: [PATCH] Simplified target function comparison. --- lib/rmg/CZonePlacer.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/rmg/CZonePlacer.cpp b/lib/rmg/CZonePlacer.cpp index 87284f5e0..64481142d 100644 --- a/lib/rmg/CZonePlacer.cpp +++ b/lib/rmg/CZonePlacer.cpp @@ -445,15 +445,10 @@ void CZonePlacer::placeZones(CRandomGenerator * rand) //check fitness function bool improvement = false; - if (bestTotalDistance > 0 && bestTotalOverlap > 0) + if ((totalDistance + 1) * (totalOverlap + 1) < (bestTotalDistance + 1) * (bestTotalOverlap + 1)) { - if (totalDistance * totalOverlap < bestTotalDistance * bestTotalOverlap) //multiplication is better for auto-scaling, but stops working if one factor is 0 - improvement = true; - } - else - { - if (totalDistance + totalOverlap < bestTotalDistance + bestTotalOverlap) - improvement = true; + //multiplication is better for auto-scaling, but stops working if one factor is 0 + improvement = true; } logGlobal->trace("Total distance between zones after this iteration: %2.4f, Total overlap: %2.4f, Improved: %s", totalDistance, totalOverlap , improvement);