Skip to content
Snippets Groups Projects
Commit 364f9a80 authored by Gabrielle Van De Vijver's avatar Gabrielle Van De Vijver Committed by Balthazar Wilson
Browse files

SCFFactory sans gestion d'erreur

parent 6e1efc56
No related branches found
No related tags found
No related merge requests found
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment