diff --git a/src/Learning/DTForest/DTDiscretizerMODL.cpp b/src/Learning/DTForest/DTDiscretizerMODL.cpp index 53ef284c5..c4093ebdf 100644 --- a/src/Learning/DTForest/DTDiscretizerMODL.cpp +++ b/src/Learning/DTForest/DTDiscretizerMODL.cpp @@ -290,7 +290,7 @@ void DTDiscretizerMODL::DiscretizeNEW(KWFrequencyTable* kwftSource, KWFrequencyT // delete kwftMergedTable; // kwftMergedTable = NULL; - if (dCost < dBestCost) + if (dCost < dBestCost - dEpsilon) { dBestCost = dCost; // Destruction de l'optimum precedent @@ -469,7 +469,7 @@ void DTDiscretizerMODL::DiscretizeOLD(KWFrequencyTable* kwftSource, KWFrequencyT delete kwftMergedTable; kwftMergedTable = NULL; - if (dCost < dBestCost) + if (dCost < dBestCost - dEpsilon) { dBestCost = dCost; // Destruction de l'optimum precedent @@ -630,7 +630,7 @@ void DTDiscretizerMODL::DiscretizeGranularizedFrequencyTableNEW(KWFrequencyTable kwdfvSourceFrequencyVectortarget1->CopyFrom(kwdfvSourceFrequencyVector1); nvfmax = nfv; } - if (dCost < dBestCost) + if (dCost < dBestCost - dEpsilon) { // cout << "cout best " << nfv + 1 << " : " << dCost << endl; dBestCost = dCost; @@ -643,7 +643,7 @@ void DTDiscretizerMODL::DiscretizeGranularizedFrequencyTableNEW(KWFrequencyTable // cout << "nvfmax / nsourcesize : " << nvfmax << " / " << nsourcesize << endl; - if (dCostnull < dBestCost) + if (dCostnull < dBestCost + dEpsilon) { // cout << "NULL Cost" << endl; // cout << "cout best " << nfv + 1 << " : " << dCost << endl; diff --git a/src/Learning/DTForest/DTGrouperMODL.cpp b/src/Learning/DTForest/DTGrouperMODL.cpp index 654c2b974..d0ae9453e 100644 --- a/src/Learning/DTForest/DTGrouperMODL.cpp +++ b/src/Learning/DTForest/DTGrouperMODL.cpp @@ -501,7 +501,7 @@ void DTGrouperMODL::GroupPreprocessedTable(KWFrequencyTable* kwftSource, KWFrequ dCost = ComputeGroupingCost(kwftOptimizedGranularizedTable, nCurrentPartileNumber); // Cas de l'amelioration du cout - if (dCost < dBestCost) + if (dCost < dBestCost - dEpsilon) { // Memorisation du cout optimal dBestCost = dCost; @@ -715,7 +715,7 @@ void DTGrouperMODL::SmallSourceNumberGroup(KWFrequencyTable* kwftSource, KWFrequ MergeFrequencyVectors(workingFrequencyVector, kwftSource->GetFrequencyVectorAt(1), kwftSource->GetFrequencyVectorAt(2)); dCost = ComputeGroupCost(workingFrequencyVector) + dCostGroup0; - if (dCost < dBestCost) + if (dCost < dBestCost - dEpsilon) { dBestCost = dCost; nBestTwoGroupsIndex = 0; @@ -724,7 +724,7 @@ void DTGrouperMODL::SmallSourceNumberGroup(KWFrequencyTable* kwftSource, KWFrequ MergeFrequencyVectors(workingFrequencyVector, kwftSource->GetFrequencyVectorAt(0), kwftSource->GetFrequencyVectorAt(2)); dCost = ComputeGroupCost(workingFrequencyVector) + dCostGroup1; - if (dCost < dBestCost) + if (dCost < dBestCost - dEpsilon) { dBestCost = dCost; nBestTwoGroupsIndex = 1; @@ -733,7 +733,7 @@ void DTGrouperMODL::SmallSourceNumberGroup(KWFrequencyTable* kwftSource, KWFrequ MergeFrequencyVectors(workingFrequencyVector, kwftSource->GetFrequencyVectorAt(0), kwftSource->GetFrequencyVectorAt(1)); dCost = ComputeGroupCost(workingFrequencyVector) + dCostGroup2; - if (dCost < dBestCost) + if (dCost < dBestCost - dEpsilon) { dBestCost = dCost; nBestTwoGroupsIndex = 2; diff --git a/src/Learning/KWDataPreparation/KWDiscretizerMODL.cpp b/src/Learning/KWDataPreparation/KWDiscretizerMODL.cpp index b0361c3c2..d7004c161 100644 --- a/src/Learning/KWDataPreparation/KWDiscretizerMODL.cpp +++ b/src/Learning/KWDataPreparation/KWDiscretizerMODL.cpp @@ -194,7 +194,7 @@ void KWDiscretizerMODL::Discretize(KWFrequencyTable* kwftSource, KWFrequencyTabl delete kwftMergedTable; kwftMergedTable = NULL; - if (dCost < dBestCost) + if (dCost < dBestCost - dEpsilon) { dBestCost = dCost; // Destruction de l'optimum precedent diff --git a/src/Learning/KWDataPreparation/KWGrouperMODL.cpp b/src/Learning/KWDataPreparation/KWGrouperMODL.cpp index 7a11413f6..da4b1c98f 100644 --- a/src/Learning/KWDataPreparation/KWGrouperMODL.cpp +++ b/src/Learning/KWDataPreparation/KWGrouperMODL.cpp @@ -594,7 +594,7 @@ void KWGrouperMODL::GroupPreprocessedTable(KWFrequencyTable* kwftSource, KWFrequ dCost = ComputeGroupingCost(kwftOptimizedGranularizedTable, nCurrentPartileNumber); // Cas de l'amelioration du cout - if (dCost < dBestCost) + if (dCost < dBestCost - dEpsilon) { // Memorisation du cout optimal dBestCost = dCost; @@ -813,7 +813,7 @@ void KWGrouperMODL::SmallSourceNumberGroup(KWFrequencyTable* kwftSource, KWFrequ MergeFrequencyVectors(workingFrequencyVector, kwftSource->GetFrequencyVectorAt(1), kwftSource->GetFrequencyVectorAt(2)); dCost = ComputeGroupCost(workingFrequencyVector) + dCostGroup0; - if (dCost < dBestCost) + if (dCost < dBestCost - dEpsilon) { dBestCost = dCost; nBestTwoGroupsIndex = 0; @@ -822,7 +822,7 @@ void KWGrouperMODL::SmallSourceNumberGroup(KWFrequencyTable* kwftSource, KWFrequ MergeFrequencyVectors(workingFrequencyVector, kwftSource->GetFrequencyVectorAt(0), kwftSource->GetFrequencyVectorAt(2)); dCost = ComputeGroupCost(workingFrequencyVector) + dCostGroup1; - if (dCost < dBestCost) + if (dCost < dBestCost - dEpsilon) { dBestCost = dCost; nBestTwoGroupsIndex = 1; @@ -831,7 +831,7 @@ void KWGrouperMODL::SmallSourceNumberGroup(KWFrequencyTable* kwftSource, KWFrequ MergeFrequencyVectors(workingFrequencyVector, kwftSource->GetFrequencyVectorAt(0), kwftSource->GetFrequencyVectorAt(1)); dCost = ComputeGroupCost(workingFrequencyVector) + dCostGroup2; - if (dCost < dBestCost) + if (dCost < dBestCost - dEpsilon) { dBestCost = dCost; nBestTwoGroupsIndex = 2; diff --git a/src/Learning/KWTest/KWDensityEstimationTest.cpp b/src/Learning/KWTest/KWDensityEstimationTest.cpp index e125da8aa..32900b729 100644 --- a/src/Learning/KWTest/KWDensityEstimationTest.cpp +++ b/src/Learning/KWTest/KWDensityEstimationTest.cpp @@ -183,7 +183,7 @@ int KWDensityEstimationTest::SearchBestInstanceGridSize(ContinuousVector* cvXVal cout << nAxisCellNumber << "\t" << dCost << endl; // Test si amelioration - if (dCost < dBestCost) + if (dCost < dBestCost - dEpsilon) { dBestCost = dCost; nBestAxisCellNumber = nAxisCellNumber; diff --git a/src/Learning/MHHistograms/MHDiscretizerHistogramMODL.cpp b/src/Learning/MHHistograms/MHDiscretizerHistogramMODL.cpp index 51403cbf2..d2ce5fce7 100644 --- a/src/Learning/MHHistograms/MHDiscretizerHistogramMODL.cpp +++ b/src/Learning/MHHistograms/MHDiscretizerHistogramMODL.cpp @@ -647,7 +647,7 @@ void MHDiscretizerHistogramMODL::GranularizedDiscretizeValues(const ContinuousVe << KWContinuous::ContinuousToString(dCost) << endl; // Memorisation si amelioration du cout - if (dCost < dBestCost) + if (dCost < dBestCost - dEpsilon) { dBestCost = dCost; if (optimizedHistogramFrequencyTable != NULL) diff --git a/src/Learning/MHHistograms/MHDiscretizerHistogramMODL_fp.cpp b/src/Learning/MHHistograms/MHDiscretizerHistogramMODL_fp.cpp index 6a36ebac6..eeac16ae9 100644 --- a/src/Learning/MHHistograms/MHDiscretizerHistogramMODL_fp.cpp +++ b/src/Learning/MHHistograms/MHDiscretizerHistogramMODL_fp.cpp @@ -743,7 +743,7 @@ void MHDiscretizerHistogramMODL_fp::OptimizeGranularity(MHHistogram*& optimizedH delete optimizedHistogramFrequencyTable; // Memorisation si amelioration du cout - if (dCost < dBestCost) + if (dCost < dBestCost - dEpsilon) { dBestCost = dCost; diff --git a/src/Learning/MHHistograms/MHFloatingPointFrequencyTableBuilder.cpp b/src/Learning/MHHistograms/MHFloatingPointFrequencyTableBuilder.cpp index 02b9ad97e..607ec1554 100644 --- a/src/Learning/MHHistograms/MHFloatingPointFrequencyTableBuilder.cpp +++ b/src/Learning/MHHistograms/MHFloatingPointFrequencyTableBuilder.cpp @@ -2127,6 +2127,7 @@ int MHFloatingPointFrequencyTableBuilder::SearchBinIndex(int nSearchedCumulative void MHFloatingPointFrequencyTableBuilder::InitializeDomainBounds() { boolean bDisplay = false; + const double dEpsilon = 1e-7; int nTotalFrequency; int i; double dBestCost; @@ -2172,13 +2173,13 @@ void MHFloatingPointFrequencyTableBuilder::InitializeDomainBounds() cout << KWContinuous::ContinuousToString(cUpperBound - GetMaxValue()) << "\t"; cout << dCost << "\t"; cout << dBestCost << "\t"; - if (dCost < dBestCost) + if (dCost < dBestCost - dEpsilon) cout << "Best"; cout << "\n"; } // Memorisation si amelioration - if (dCost < dBestCost) + if (dCost < dBestCost - dEpsilon) { dBestCost = dCost;