Skip to content

Commit

Permalink
WIP Step 10
Browse files Browse the repository at this point in the history
Nettoyage du code
- supression des balises DDD ayant servi au debug
- restoration du yaml de lancement des tests
  • Loading branch information
marcboulle committed Jan 17, 2024
1 parent 520a4fb commit 0fc7633
Show file tree
Hide file tree
Showing 41 changed files with 4,672 additions and 5,170 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/run-standard-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ jobs:
strategy:
matrix:
build-setup:
- {os: windows-2022, cmake-preset: windows-msvc}
- {os: ubuntu-latest, cmake-preset: linux-gcc}
- {os: macos-latest, cmake-preset: macos-clang}
config: [debug, release]
runs-on: ${{ matrix.build-setup.os }}
env:
Expand Down
15 changes: 0 additions & 15 deletions src/Learning/KWDRRuleLibrary/KWDRStringEncrypt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,6 @@ const ALString KWDREncrypt::EncryptString(ALString& sStringToEncrypt, const Symb
int nBlockCode;
char cLastChar;

// DDD
static boolean bTraceOnce = false;
if (bTraceOnce)
{
cout << "Index\tChar\tisdigit\tisalnum\tiscntrl\tisprint\t(isprint and not iscntrl)\n";
for (i = 0; i < 256; i++)
{
cout << i << "\t";
if (isprint(i))
cout << (char)i;
cout << "\t" << (isdigit(i) != 0) << "\t" << (isalnum(i) != 0) << "\t" << (iscntrl(i) != 0)
<< "\t" << (isprint(i) != 0) << "\t" << (isprint(i) != 0 and not iscntrl(i) != 0) << endl;
}
}

// Memorisation de la graine aleatoire initiale
nRandomSeed = GetRandomSeed();

Expand Down
14 changes: 0 additions & 14 deletions src/Learning/KWDataPreparation/KWAttributeSubsetStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,20 +221,6 @@ boolean KWAttributeSubsetStats::ComputeStats(const KWTupleTable* tupleTable)
if (dPreparedLevel < 1e-10)
dPreparedLevel = 0;

// DDD
if (optimizedDataGrid->GetAttributeNumber() == 2 and
optimizedDataGrid->GetAttributeAt(0)->GetAttributeName() == "SPetalLength" and
optimizedDataGrid->GetAttributeAt(1)->GetAttributeName() == "SepalWidth")
{
SetGlobalTraceOn(true);
dataGridCosts->ComputeAttributeCost(optimizedDataGrid->GetAttributeAt(0),
optimizedDataGrid->GetAttributeAt(0)->GetPartNumber());
dataGridCosts->ComputeAttributeCost(optimizedDataGrid->GetAttributeAt(1),
optimizedDataGrid->GetAttributeAt(1)->GetPartNumber());
SetGlobalTraceOn(false);
cout << "All costs" << endl;
dataGridCosts->WriteDataGridAllCosts(optimizedDataGrid, cout);
}
// Calcul des donnes de preparation si necessaire
// Dans le cas supervise, on garde quand meme la grille, qui permet le recodage
// de tous els attributs, y compris non informatifs
Expand Down
25 changes: 2 additions & 23 deletions src/Learning/KWDataPreparation/KWDataGrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3558,7 +3558,7 @@ KWDGValue* KWDGValueSet::AddValue(const Symbol& sValue)
{
KWDGValue* value;

require(not bIsDefaultPart or sValue != Symbol::GetStarValue()); // DDD
require(not bIsDefaultPart or sValue != Symbol::GetStarValue());

// Creation de la valeur
value = NewValue(sValue);
Expand All @@ -3578,14 +3578,6 @@ KWDGValue* KWDGValueSet::AddValue(const Symbol& sValue)
if (sValue == Symbol::GetStarValue())
bIsDefaultPart = true;

// DDD
static int nCount = 0;
nCount++;
if (1720 <= nCount and nCount <= 1723)
cout << flush;
cout << "\tKWDGValueSet::AddValue\t" << nCount << "\t" << GetValueNumber() << "\t(" << sValue << ")\t"
<< BooleanToString(sValue == Symbol::GetStarValue()) << "\t" << BooleanToString(bIsDefaultPart) << endl;

// On retourne la valeur cree
return value;
}
Expand All @@ -3594,7 +3586,7 @@ void KWDGValueSet::DeleteValue(KWDGValue* value)
{
require(value != NULL);

require(not bIsDefaultPart or value->GetValue() != Symbol::GetStarValue()); // DDD
require(not bIsDefaultPart or value->GetValue() != Symbol::GetStarValue());

// Supression de la liste des valuees
nValueNumber--;
Expand All @@ -3611,13 +3603,6 @@ void KWDGValueSet::DeleteValue(KWDGValue* value)
if (value->GetValue() == Symbol::GetStarValue())
bIsDefaultPart = false;

// DDD
static int nCount = 0;
nCount++;
cout << "\tKWDGValueSet::DeleteValue\t" << nCount << "\t" << GetValueNumber() << "\t(" << value->GetValue()
<< ")\t" << BooleanToString(value->GetValue() == Symbol::GetStarValue()) << "\t"
<< BooleanToString(bIsDefaultPart) << endl;

// Destruction de la valeur
delete value;
}
Expand Down Expand Up @@ -3835,10 +3820,6 @@ void KWDGValueSet::CopyFrom(const KWDGValueSet* sourceValueSet)

require(sourceValueSet != NULL);

static int nCount = 0;
nCount++;
cout << "KWDGValueSet::CopyFrom Begin " << nCount << endl;

// Nettoyage des valeurs actuelles
DeleteAllValues();

Expand All @@ -3853,8 +3834,6 @@ void KWDGValueSet::CopyFrom(const KWDGValueSet* sourceValueSet)
bIsDefaultPart = sourceValueSet->IsDefaultPart();
// Pour garantir la valeur correcte de nValueNumber si le sourceValueSet a ete compresse avant la copie
nValueNumber = sourceValueSet->nValueNumber;

cout << "KWDGValueSet::CopyFrom End " << nCount << endl;
}

void KWDGValueSet::UpgradeFrom(const KWDGValueSet* sourceValueSet)
Expand Down
13 changes: 0 additions & 13 deletions src/Learning/KWDataPreparation/KWDataGrid.h
Original file line number Diff line number Diff line change
Expand Up @@ -1262,19 +1262,6 @@ inline KWDGPart* KWDGAttribute::GetGarbagePart() const
inline void KWDGAttribute::SetGarbagePart(KWDGPart* part)
{
require(nAttributeType == KWType::Symbol);
// DDD
static int nCount = 0;
if (GetAttributeName() == "SPetalLength")
{
nCount++;
if (nCount == 291)
cout << flush;
if (part != NULL)
cout << "KWDGAttribute::SetGarbagePart\t" << nCount << "\t"
<< BooleanToString(part->GetValueSet()->IsDefaultPart()) << "\t"
<< part->GetValueSet()->GetTrueValueNumber() << "\t"
<< part->GetValueSet()->GetValueNumber() << "\t" << endl;
}
garbagePart = part;
}

Expand Down
74 changes: 0 additions & 74 deletions src/Learning/KWDataPreparation/KWDataGridCosts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,6 @@

#include "KWDataGridCosts.h"

// DDD
static boolean bGlobalTraceOn = false;

boolean GetGlobalTraceOn()
{
return bGlobalTraceOn;
}

void SetGlobalTraceOn(boolean bValue)
{
bGlobalTraceOn = bValue;
}

////////////////////////////////////////////////////////////////////////////////////////
// Classe KWDataGridCosts

Expand Down Expand Up @@ -1411,15 +1398,6 @@ double KWDataGridClusteringCosts::ComputeAttributeCost(const KWDGAttribute* attr
// Une partition avec poubelle contient au moins 2 parties informatives + 1 groupe poubelle
require(attribute->GetGarbageModalityNumber() == 0 or nPartitionSize >= 3);

// DDD
if (GetGlobalTraceOn())
{
cout << "KWDataGridClusteringCosts::ComputeAttributeCost\t" << attribute->GetAttributeName() << endl;
cout << "\tnPartileNumber\t" << nPartileNumber << endl;
cout << "\tKWFrequencyTable::GetMinimumNumberOfModalitiesForGarbage()\t"
<< KWFrequencyTable::GetMinimumNumberOfModalitiesForGarbage() << endl;
}

// Cout nul si partition nulle
if (nPartitionSize == 1)
dAttributeCost = 0;
Expand Down Expand Up @@ -1447,90 +1425,38 @@ double KWDataGridClusteringCosts::ComputeAttributeCost(const KWDGAttribute* attr
if (nPartileNumber > KWFrequencyTable::GetMinimumNumberOfModalitiesForGarbage())
dAttributeCost += log(2.0);

if (GetGlobalTraceOn()) // DDD
{
cout << "\tattribute->GetCost()\t" << attribute->GetCost() << endl;
cout << "\tnGarbageModalityNumber\t" << nGarbageModalityNumber << endl;
cout << "\tdAttributeCost1\t" << dAttributeCost << endl;
}

// Cout de codage du choix des modalites informatives (hors poubelle)
if (nGarbageModalityNumber > 0)
{
// Cout de codage de la taille de la non-poubelle
dAttributeCost += KWStat::BoundedNaturalNumbersUniversalCodeLength(
nPartileNumber - nGarbageModalityNumber - 1, nPartileNumber - 2);
if (GetGlobalTraceOn()) // DDD
{
cout << "\tdAttributeCost2\t" << dAttributeCost << "\t"
<< KWStat::BoundedNaturalNumbersUniversalCodeLength(
nPartileNumber - nGarbageModalityNumber - 1, nPartileNumber - 2)
<< endl;
}

// Choix des modalites hors poubelle selon un tirage multinomial avec un tirage par
// variable
dAttributeCost +=
(nPartileNumber - nGarbageModalityNumber) * log(nPartileNumber * 1.0) -
KWStat::LnFactorial(nPartileNumber - nGarbageModalityNumber);
if (GetGlobalTraceOn()) // DDD
{
cout << "\tdAttributeCost3\t" << dAttributeCost << "\t"
<< (nPartileNumber - nGarbageModalityNumber) * log(nPartileNumber * 1.0) -
KWStat::LnFactorial(nPartileNumber - nGarbageModalityNumber)
<< endl;
}

// Cout de codage du nombre de parties informatives (nPartitionSize-1)
dAttributeCost += KWStat::BoundedNaturalNumbersUniversalCodeLength(
nPartitionSize - 2, nPartileNumber - nGarbageModalityNumber - 1);
if (GetGlobalTraceOn()) // DDD
{
cout << "\tdAttributeCost4\t" << dAttributeCost << "\t"
<< KWStat::BoundedNaturalNumbersUniversalCodeLength(
nPartitionSize - 2, nPartileNumber - nGarbageModalityNumber - 1)
<< endl;
}

// Cout de codage du choix des parties informatives (nPartitionSize - 1)
dAttributeCost +=
KWStat::LnBell(nPartileNumber - nGarbageModalityNumber, nPartitionSize - 1);
if (GetGlobalTraceOn()) // DDD
{
cout << "\tdAttributeCost5\t" << dAttributeCost << "\t"
<< KWStat::LnBell(nPartileNumber - nGarbageModalityNumber,
nPartitionSize - 1)
<< endl;
}
}
else
{
// Cout de codage du nombre de parties
dAttributeCost += KWStat::BoundedNaturalNumbersUniversalCodeLength(nPartitionSize - 1,
nPartileNumber - 1);
if (GetGlobalTraceOn()) // DDD
{
cout << "\tdAttributeCostBis2\t" << dAttributeCost << "\t"
<< KWStat::BoundedNaturalNumbersUniversalCodeLength(nPartitionSize - 1,
nPartileNumber - 1)
<< endl;
}

// Cout de codage du choix des parties
dAttributeCost += KWStat::LnBell(nPartileNumber, nPartitionSize);
if (GetGlobalTraceOn()) // DDD
{
cout << "\tdAttributeCostBis3\t" << dAttributeCost << "\t"
<< KWStat::LnBell(nPartileNumber, nPartitionSize) << endl;
}
}
}
}
if (GetGlobalTraceOn()) // DDD
{
cout << "\tdAttributeCostFinal\t" << dAttributeCost << endl;
}

return dAttributeCost;
}

Expand Down
6 changes: 0 additions & 6 deletions src/Learning/KWDataPreparation/KWDataGridCosts.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ class KWDataGridGeneralizedClassificationCosts;
#include "KWDataGridMerger.h"
#include "KWStat.h"

// DDD
// Indicateur de trace globale
// A positionner et utiliser temporairement le temps d'un debugage
boolean GetGlobalTraceOn();
void SetGlobalTraceOn(boolean bValue);

////////////////////////////////////////////////////////////////////////////
// Definition de la structure des couts d'une grille de donnees
// Les couts par entite, nuls par defaut, sont redefinissable dans des sous-classes
Expand Down
7 changes: 0 additions & 7 deletions src/Learning/KWDataPreparation/KWDataGridManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2972,9 +2972,6 @@ void KWDataGridManager::SortAttributeParts(KWDGAttribute* sourceAttribute, KWDGA
oaAssociations.SetCompareFunction(KWSortableSymbolCompareValue);
oaAssociations.Sort();

// DDD
cout << "KWDataGridManager::SortAttributeParts" << endl;

// On range dans le tableau en sortie les parties sources, triees par groupe
// (en fait, par leur premiere valeur, ce qui est equivalent), et leur groupe associe
oaSortedSourceParts->SetSize(oaSourceParts.GetSize());
Expand All @@ -2993,10 +2990,6 @@ void KWDataGridManager::SortAttributeParts(KWDGAttribute* sourceAttribute, KWDGA
// Rangement dans les tableaux en sortie
oaSortedSourceParts->SetAt(n, sourcePart);
oaSortedGroupedParts->SetAt(n, groupedPart);

// DDD
cout << "\t" << sourcePart->GetValueSet()->GetObjectLabel() << "\t"
<< groupedPart->GetValueSet()->GetObjectLabel() << endl;
}

// Nettoyage du tableau d'indexation
Expand Down

This file was deleted.

Loading

0 comments on commit 0fc7633

Please sign in to comment.