// Concept.h // Définition de la classe Concept #include "Methodes.cpp" #include using namespace std; #ifndef CONCEPT_H #define CONCEPT_H typedef Matrice MatInt; typedef Matrice MatVecInt; class Concept { protected: VecInt pte; // Propriétés du concept VecInt obj; // Objets du concept MatInt R; // Relation R réduite MatVecInt N; // Liste des N+ dans la relation MatVecInt M; // Liste des maxmods MatVecInt ND; // Liste des maxmods non dominants MatVecInt DOM; // Tableau des dominations VecInt Marked; // Liste des proprietes deja traitees public: Concept(); Concept(VecInt _pte,VecInt _obj); Concept(VecInt _pte,VecInt _obj,VecInt _Marked); Concept(const Concept& _concept); int nbPte()const; int nbObj()const; void CONCEPTS(const MatInt& _R,MatInt& T,MatInt& D,int nbp,int nbo,MatVecInt& CONCEPTS,MatVecInt& REGLES); void ajouterConcept(MatVecInt& CONCEPTS)const; void initialisation(const MatInt& _R,int nbo,int nbp); MatInt construireR(const MatInt& _R,int nbo,int nbp)const; MatVecInt construireN()const; MatVecInt construireM()const; void majMarked(); void calculND_DOM(int nbp,MatInt& T,MatInt& D); void REGLES_ASSOCIATION(MatVecInt& REGLES); void generationConcepts(MatInt& T,MatInt& D,int nbp,int nbo,MatVecInt& CONCEPTS,MatVecInt& REGLES); void UPDATE(bool V,MatInt& T,MatInt& D,int elem,int nbp,int nbo); ~Concept(); }; Concept::Concept(){ } Concept::Concept(VecInt _pte,VecInt _obj){ pte=_pte; obj=_obj; } Concept::Concept(VecInt _pte,VecInt _obj,VecInt _Marked){ pte=_pte; obj=_obj; Marked=_Marked; } Concept::Concept(const Concept& _concept){ pte=_concept.pte; obj=_concept.obj; R=_concept.R; N=_concept.N; M=_concept.M; ND=_concept.ND; Marked=_concept.Marked; } int Concept::nbPte()const{ return pte.size(); } int Concept::nbObj()const{ return obj.size(); } // Algorithme CONCEPTS void Concept::CONCEPTS(const MatInt& _R,MatInt& T,MatInt& D,int nbp,int nbo,MatVecInt& CONCEPTS,MatVecInt& REGLES){ ajouterConcept(CONCEPTS); initialisation(_R,nbo,nbp); calculND_DOM(nbp,T,D); REGLES_ASSOCIATION(REGLES); generationConcepts(T,D,nbp,nbo,CONCEPTS,REGLES); } // Méthode insérant le nouveau concept dans la matrice CONCEPTS void Concept::ajouterConcept(MatVecInt& CONCEPTS)const{ if (pte.size()!=0){ MatVecInt M(1,2); M.setElement(0,0,pte); M.setElement(0,1,obj); CONCEPTS.ajoutLigne(M); } } // Méthode d'initialisation d'un concept ie construisant R, N, M et mettant à jour Marked void Concept::initialisation(const MatInt& _R,int nbo,int nbp){ R=construireR(_R,nbo,nbp); N=construireN(); M=construireM(); majMarked(); } // Méthode construisant la relation réduite R MatInt Concept::construireR(const MatInt& _R,int nbo,int nbp)const{ MatInt R_temp(obj.size()+1,nbp-pte.size()); int k1=-1; for(int i=0;i<_R.getNbCol();i++) if (appartient(pte,_R.getElement(0,i))==0){ k1++; R_temp.setElement(0,k1,_R.getElement(0,i)); } int k2; k1=-1; for(int i=0;i<_R.getNbCol();i++) if (appartient(pte,_R.getElement(0,i))==0){ k1++; k2=0; for (int j=1;j<_R.getNbLigne();j++) if (appartient(obj,_R.getElement(j,0))==1){ k2++; R_temp.setElement(k2,k1,_R.getElement(j,i)); } } return R_temp; } // Méthode construisant la liste des N+ dans la relation MatVecInt Concept::construireN()const{ int nbl=R.getNbLigne(); int nbc=R.getNbCol(); MatVecInt _N(nbl-1,2); for (int i=0;i(int)Vinit1.size()) taille=Vinit1.size(); Mtemp.setTaille(1,taille); int l=0; for(int i=0;i<_M.getNbCol();i++){ VecInt V1,V2; for (int j=0;j<(int)_M.getElement(0,i).size();j++){ if (appartient(N.getElement(k,1),_M.getElement(0,i)[j])==1) V1.push_back(_M.getElement(0,i)[j]); else V2.push_back(_M.getElement(0,i)[j]); } if (V1.size()!=0){ Mtemp.setElement(0,l,V1); l++; } if (V2.size()!=0){ Mtemp.setElement(0,l,V2); l++; } } _M.setTaille(1,l); for (int j=0;j1) for (int j=0;j<(int)M.getElement(0,i).size();j++) if (appartient(Marked,M.getElement(0,i)[j])==1){ Marked=sommeVecInt(Marked,M.getElement(0,i)); break; } } // Méthode construisant la liste des maxmods non dominants et le tableau des dominations void Concept::calculND_DOM(int nbp,MatInt& T,MatInt& D){ int taille=M.getNbCol(); int l=-1; int c=-1; int t=0; MatVecInt _ND(1,taille); MatVecInt _DOM(nbp-pte.size()-1,2); for (int i=0;i1){ for (int j=0;j<(int)M.getElement(0,i).size();j++){ c++; VecInt V1; V1.push_back(M.getElement(0,i)[j]); _DOM.setElement(c,0,V1); } } } else{ for (int j=0;j<(int)M.getElement(0,i).size();j++){ c++; VecInt V1; V1.push_back(M.getElement(0,i)[j]); _DOM.setElement(c,0,V1); } } } ND.setTaille(1,l+1); for (int i=0;i pile; int test; for (int i=0;iUPDATE(0,T,D,i,nbp,nbo); //pre c1.CONCEPTS(R,T,D,nbp,nbo,CONCEPTS,REGLES); this->UPDATE(1,T,D,i,nbp,nbo); //post Marked=sommeVecInt(Marked,ND.getElement(0,i)); } } } } // Méthode de mise à jour des tables T et D void Concept::UPDATE(bool V,MatInt& T,MatInt& D,int elem,int nbp,int nbo){ int x=*ND.getElement(0,elem).begin(); for (int y=1;y