diff --git a/comsoc/TieBreak.go b/comsoc/TieBreak.go index 6e1d47db164f30e888ec5e59502ad2631f3d74fe..872f249ace73e0f3fd8feaeaa47ee8d650901a0e 100644 --- a/comsoc/TieBreak.go +++ b/comsoc/TieBreak.go @@ -75,4 +75,31 @@ func Test_sWFFactory(){ sorted_alts,_ := mu(profil) fmt.Println("Alternatives strictement ordonnées selon la méthode de Borda :", sorted_alts) } -//func SCFFactory(func scf(p Profile) ([]Alternative, error), func ([]Alternative) (Alternative, error)) (func(Profile) (Alternative, error)) + +func SCFFactory(scf func (p Profile) ([]Alternative, error),tb func ([]Alternative) (Alternative, error)) (func(Profile) (Alternative, error)){ + return func(p Profile) (Alternative, error){ + //récupération des meilleures alternatives + bestAlts,_ := scf(p) + //récupération de la meilleure alternative + bestAlt,_ := tb(bestAlts) + return bestAlt,nil + } +} +func Test_sCFFactory(){ + //Définition de l'Ordre strict + orderedAlts := []Alternative{8,9,6,1,3,2} + fmt.Println("Ordre strict :", orderedAlts) + + //Construction d'un profil avec alternatives ex aequo + profil := make([][]Alternative, 2) + profil[0] = []Alternative{1, 2, 3,4,5,6} + profil[1] = []Alternative{3, 2, 1,4,5,6} + fmt.Println("Profil :", profil) + + //Construction de la fonction Tie Break + lambda:=TieBreakFactory(orderedAlts) + mu := SCFFactory(BordaSCF,lambda) + //Construction d'une fonction + best_Alt,_ := mu(profil) + fmt.Println("Meilleure alternative selon la méthode de Borda :", best_Alt) +} \ No newline at end of file