Skip to content

Commit

Permalink
Refactor method KWDataGridVNSOptimizer::VNSOptimizeVarPartDataGrid
Browse files Browse the repository at this point in the history
KWDataGridVNSOptimizer::VNSOptimizeVarPartDataGrid
- utilise maintenant la methode VNSDataGridPostOptimizeVarPart pour la post-optimisation VarPart
- on garde pour l'instant l'ancienne implementation dans DEPRECATED_VNSOptimizeVarPartDataGrid

KWDataGrid
- Set|GetLabel: ajout de ces methodes temporaire permettant d'annoter une grille
  pour aider a la mise au point des algorithmes d'optimisation
  • Loading branch information
marcboulle committed Oct 11, 2023
1 parent 0ba8a7e commit 60538e6
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 33 deletions.
10 changes: 10 additions & 0 deletions src/Learning/KWDataPreparation/KWDataGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5455,6 +5455,16 @@ int KWDGCellCompareDecreasingFrequency(const void* elem1, const void* elem2)
return nCompare;
}

void KWDataGrid::SetLabel(const ALString& sValue)
{
sLabel = sValue;
}

const ALString& KWDataGrid::GetLabel() const
{
return sLabel;
}

void KWDataGrid::SetTargetAttribute(KWDGAttribute* attribute)
{
targetAttribute = attribute;
Expand Down
11 changes: 11 additions & 0 deletions src/Learning/KWDataPreparation/KWDataGrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,13 @@ class KWDataGrid : public Object

///////////////////////////////
//// Implementation

// CH IV Refactoring: parametrage d'un libelle associe, pour aider a la mise au point des grilles
// CH IV Refactoring: a supprimer une fois les nouveaux algorithmes mi au point
// Libelle associe a la grille
void SetLabel(const ALString& sValue);
const ALString& GetLabel() const;

protected:
friend class KWDGAttribute;

Expand Down Expand Up @@ -435,6 +442,10 @@ class KWDataGrid : public Object
// Positionne par l'attribut lors de l'initialsaition de son type s'il est de type VarPart
// Permet egalement de savoir si la grille est de type VarPart
KWDGAttribute* varPartAttribute;

// CH IV Refactoring: a supprimer une fois les nouveaux algorithmes mi au point
// Libelle associe a la grille
ALString sLabel;
};

// Comparaison de deux grilles de donnees, sur la valeur de tri (SortValue),
Expand Down
48 changes: 24 additions & 24 deletions src/Learning/KWDataPreparation/KWDataGridOptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1627,9 +1627,10 @@ double KWDataGridVNSOptimizer::VNSOptimizeDataGrid(const KWDataGrid* initialData
}

// CH IV Begin
double KWDataGridVNSOptimizer::PROTO_VNSDataGridPostOptimizeVarPart(
const KWDataGrid* initialDataGrid, KWDataGridMerger* neighbourDataGrid, double dNeighbourDataGridCost,
KWDataGrid* mergedDataGrid, KWDataGrid* partitionedReferencePostMergedDataGrid) const
double KWDataGridVNSOptimizer::VNSDataGridPostOptimizeVarPart(const KWDataGrid* initialDataGrid,
KWDataGridMerger* neighbourDataGrid,
double dNeighbourDataGridCost, KWDataGrid* mergedDataGrid,
KWDataGrid* partitionedReferencePostMergedDataGrid) const
{
double dCost;
double dMergedCost;
Expand Down Expand Up @@ -1848,11 +1849,10 @@ double KWDataGridVNSOptimizer::PROTO_VNSDataGridPostOptimizeVarPart(
return dMergedCost;
}

double KWDataGridVNSOptimizer::PROTO_VNSOptimizeVarPartDataGrid(const KWDataGrid* initialDataGrid,
double dDecreaseFactor, int nMinIndex, int nMaxIndex,
KWDataGrid* optimizedDataGrid,
double dOptimizedDataGridCost,
double& dBestMergedDataGridCost) const
double KWDataGridVNSOptimizer::VNSOptimizeVarPartDataGrid(const KWDataGrid* initialDataGrid, double dDecreaseFactor,
int nMinIndex, int nMaxIndex, KWDataGrid* optimizedDataGrid,
double dOptimizedDataGridCost,
double& dBestMergedDataGridCost) const
{
double dBestCost;
double dCost;
Expand All @@ -1872,6 +1872,14 @@ double KWDataGridVNSOptimizer::PROTO_VNSOptimizeVarPartDataGrid(const KWDataGrid
require(nMinIndex <= nMaxIndex);
require(fabs(dOptimizedDataGridCost - dataGridCosts->ComputeDataGridTotalCost(optimizedDataGrid)) < dEpsilon);

// CH IV Refactoring : DDDDD
// Test du remplacement de la methode actuelle, par son proto
boolean bDeprecatedVersion = false;
if (bDeprecatedVersion)
return DEPRECATED_VNSOptimizeVarPartDataGrid(initialDataGrid, dDecreaseFactor, nMinIndex, nMaxIndex,
optimizedDataGrid, dOptimizedDataGridCost,
dBestMergedDataGridCost);

// Initialisations
dataGridManager.SetSourceDataGrid(initialDataGrid);
neighbourDataGrid.SetDataGridCosts(dataGridCosts);
Expand Down Expand Up @@ -1908,9 +1916,9 @@ double KWDataGridVNSOptimizer::PROTO_VNSOptimizeVarPartDataGrid(const KWDataGrid
// A terme, a deplacer dans OptimizeSolution
dMergedCost = dCost;
if (initialDataGrid->IsVarPartDataGrid())
dMergedCost = PROTO_VNSDataGridPostOptimizeVarPart(initialDataGrid, &neighbourDataGrid, dCost,
&mergedDataGrid,
&partitionedReferencePostMergedDataGrid);
dMergedCost =
VNSDataGridPostOptimizeVarPart(initialDataGrid, &neighbourDataGrid, dCost, &mergedDataGrid,
&partitionedReferencePostMergedDataGrid);

// Si amelioration: on la memorise
if (dMergedCost < dBestMergedCost - dEpsilon)
Expand Down Expand Up @@ -1981,10 +1989,11 @@ double KWDataGridVNSOptimizer::PROTO_VNSOptimizeVarPartDataGrid(const KWDataGrid
return dBestCost;
}

double KWDataGridVNSOptimizer::VNSOptimizeVarPartDataGrid(const KWDataGrid* initialDataGrid, double dDecreaseFactor,
int nMinIndex, int nMaxIndex, KWDataGrid* optimizedDataGrid,
double dOptimizedDataGridCost,
double& dBestMergedDataGridCost) const
double KWDataGridVNSOptimizer::DEPRECATED_VNSOptimizeVarPartDataGrid(const KWDataGrid* initialDataGrid,
double dDecreaseFactor, int nMinIndex,
int nMaxIndex, KWDataGrid* optimizedDataGrid,
double dOptimizedDataGridCost,
double& dBestMergedDataGridCost) const
{
double dBestCost;
double dCost;
Expand All @@ -2006,15 +2015,6 @@ double KWDataGridVNSOptimizer::VNSOptimizeVarPartDataGrid(const KWDataGrid* init
require(nMinIndex <= nMaxIndex);
require(fabs(dOptimizedDataGridCost - dataGridCosts->ComputeDataGridTotalCost(optimizedDataGrid)) < dEpsilon);

// CH IV Refactoring : DDDDD
// Test du remplacement de la methode actuelle, par son proto
boolean bProto = false;
//DDD bProto = true;
if (bProto)
return PROTO_VNSOptimizeVarPartDataGrid(initialDataGrid, dDecreaseFactor, nMinIndex, nMaxIndex,
optimizedDataGrid, dOptimizedDataGridCost,
dBestMergedDataGridCost);

// Initialisations
dataGridManager.SetSourceDataGrid(initialDataGrid);
neighbourDataGrid.SetDataGridCosts(dataGridCosts);
Expand Down
17 changes: 9 additions & 8 deletions src/Learning/KWDataPreparation/KWDataGridOptimizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,9 @@ class KWDataGridVNSOptimizer : public Object
// - Greedy merge optimization
// - Post-optimization
// - Post-optimization IV
double PROTO_VNSDataGridPostOptimizeVarPart(const KWDataGrid* initialDataGrid,
KWDataGridMerger* neighbourDataGrid, double dNeighbourDataGridCost,
KWDataGrid* mergedDataGrid,
KWDataGrid* partitionedReferencePostMergedDataGrid) const;
double VNSDataGridPostOptimizeVarPart(const KWDataGrid* initialDataGrid, KWDataGridMerger* neighbourDataGrid,
double dNeighbourDataGridCost, KWDataGrid* mergedDataGrid,
KWDataGrid* partitionedReferencePostMergedDataGrid) const;

// CH IV Begin
// Pilotage de la meta heuristique VNS, avec des voisinages successifs de taille décroissante
Expand All @@ -269,13 +268,15 @@ class KWDataGridVNSOptimizer : public Object
// des grilles de meilleur cout apres post-fusion En sortie : optimizedDataGrid contient la grille antecedent
// avant post-fusion de la meilleure grille post-fusionne Le cout renvoye est le cout de cette optimizedDataGrid
// dBestMergedDataGridCost contient le cout de la meilleure grille apres post-fusion (meilleur cout)
// CH IV Refactoring: proto en vue de fusionner la methode avec VNSOptimizeDataGrid (plnate actuellement)
double PROTO_VNSOptimizeVarPartDataGrid(const KWDataGrid* initialDataGrid, double dDecreaseFactor,
int nMinIndex, int nMaxIndex, KWDataGrid* optimizedDataGrid,
double dOptimizedDataGridCost, double& dBestMergedDataGridCost) const;
// CH IV Refactoring: proto en vue de fusionner la methode avec VNSOptimizeDataGrid
double VNSOptimizeVarPartDataGrid(const KWDataGrid* initialDataGrid, double dDecreaseFactor, int nMinIndex,
int nMaxIndex, KWDataGrid* optimizedDataGrid, double dOptimizedDataGridCost,
double& dBestMergedDataGridCost) const;
// CH IV Refactoring: ancienne version avant decoupage en VNSOptimizeVarPartDataGrid et VNSDataGridPostOptimizeVarPart
double DEPRECATED_VNSOptimizeVarPartDataGrid(const KWDataGrid* initialDataGrid, double dDecreaseFactor,
int nMinIndex, int nMaxIndex, KWDataGrid* optimizedDataGrid,
double dOptimizedDataGridCost,
double& dBestMergedDataGridCost) const;
// CH IV End

// Optimisation d'une solution
Expand Down
1 change: 0 additions & 1 deletion src/Learning/MODL/MODL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ int main(int argc, char** argv)

// Choix du repertoire de lancement pour le debugage sous Windows (a commenter apres fin du debug)
// SetWindowsDebugDir("Standard", "IrisLight");
SetWindowsDebugDir("BugsMultiTables", "BugDeployedCoclustering");

// Parametrage des logs memoires depuis les variables d'environnement, pris en compte dans KWLearningProject
// KhiopsMemStatsLogFileName, KhiopsMemStatsLogFrequency, KhiopsMemStatsLogToCollect
Expand Down
1 change: 1 addition & 0 deletions src/Learning/MODL_Coclustering/MODL_Coclustering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ int main(int argc, char** argv)
// Choix du repertoire de lancement pour le debugage sous Windows (a commenter apres fin du debug)
//SetWindowsDebugDir("y_CoclusteringIV_Standard", "IrisLight");
//SetWindowsDebugDir("y_CoclusteringIV_Standard", "Iris");
//SetWindowsDebugDir("Standard", "Iris");

// Point d'arret sur l'allocation d'un bloc memoire
// MemSetAllocIndexExit(77);
Expand Down

0 comments on commit 60538e6

Please sign in to comment.