From 6bb385b21719caeebead6fddeee70c1f998c8fb7 Mon Sep 17 00:00:00 2001 From: Miller Cy Chan Date: Thu, 27 Jul 2023 22:07:54 +0800 Subject: [PATCH] Add files via upload --- nQuantCpp/APNsgaIII.cpp | 6 +++--- nQuantCpp/PnnLABGAQuantizer.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/nQuantCpp/APNsgaIII.cpp b/nQuantCpp/APNsgaIII.cpp index 2e671e7..f69c6d9 100644 --- a/nQuantCpp/APNsgaIII.cpp +++ b/nQuantCpp/APNsgaIII.cpp @@ -121,10 +121,10 @@ namespace nQuantGA int cur = 0, next = 1; while(_currentGeneration < _max_iterations) - { - auto best = this->getResult(); + { if(_currentGeneration > 0) { - double difference = abs(best->getFitness() - lastBestFit); + auto best = this->getResult(); + auto difference = abs(best->getFitness() - lastBestFit); if (difference <= 1e-6) ++bestNotEnhance; else { diff --git a/nQuantCpp/PnnLABGAQuantizer.cpp b/nQuantCpp/PnnLABGAQuantizer.cpp index f44cb2f..c5ae3d6 100644 --- a/nQuantCpp/PnnLABGAQuantizer.cpp +++ b/nQuantCpp/PnnLABGAQuantizer.cpp @@ -197,7 +197,7 @@ namespace PnnLABQuant } static double rotateLeft(double u, double v, double delta) { - auto theta = M_PI * randrange(minRatio, maxRatio); + auto theta = M_PI * randrange(minRatio, maxRatio) / exp(delta); auto result = u * sin(theta) + v * cos(theta); if (result <= minRatio || result >= maxRatio) result = rotateLeft(u, v, delta + .5); @@ -205,7 +205,7 @@ namespace PnnLABQuant } static double rotateRight(double u, double v, double delta) { - auto theta = M_PI * randrange(minRatio, maxRatio); + auto theta = M_PI * randrange(minRatio, maxRatio) / exp(delta); auto result = u * cos(theta) - v * sin(theta); if (result <= minRatio || result >= maxRatio) result = rotateRight(u, v, delta + .5);