Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
IA04binôme2A
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Gabrielle Van De Vijver
IA04binôme2A
Commits
6bf36c9e
Commit
6bf36c9e
authored
1 year ago
by
Gabrielle Van De Vijver
Browse files
Options
Downloads
Patches
Plain Diff
SWFFactory sans gestion d'erreurs
parent
f6c978f2
No related branches found
Branches containing commit
No related tags found
1 merge request
!1
Gabrielle
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
comsoc/TieBreak.go
+51
-7
51 additions, 7 deletions
comsoc/TieBreak.go
with
51 additions
and
7 deletions
comsoc/TieBreak.go
+
51
−
7
View file @
6bf36c9e
...
...
@@ -19,16 +19,60 @@ func Test_tieBreakFactory(){
fmt
.
Println
(
"Ordre strict :"
,
orderedAlts
)
lambda
:=
TieBreakFactory
(
orderedAlts
)
bestAlts
:=
[]
Alternative
{
3
,
6
}
fmt
.
Println
(
"Premières alternatives à départager :"
,
bestAlts
)
fmt
.
Println
(
"Premières alternatives
,
à départager :"
,
bestAlts
)
bestAlt
,
_
:=
lambda
(
bestAlts
)
fmt
.
Println
(
"Première alternative :"
,
bestAlt
)
}
//
func SWFFactory(func
swf(p
Profile) (Count, error), func
([]Alternative) (Alternative, error)) (func(Profile) ([]Alternative, error)){
func
SWFFactory
(
swf
func
(
Profile
)
(
Count
,
error
),
tb
func
([]
Alternative
)
(
Alternative
,
error
))
(
func
(
Profile
)
([]
Alternative
,
error
)){
// return func ([]Alternative) (Alternative, error) {
// return orderedAlts[0],nil
// }
// }
return
func
(
p
Profile
)
([]
Alternative
,
error
){
//récupération du décompte
count
,
_
:=
swf
(
p
)
//préparation de la sortie
var
sorted_alts
[]
Alternative
//PARCOURS DU DECOMPTE
for
len
(
count
)
>
0
{
//On prend les meilleures alternatives (avant tie break)
bestAlts
:=
maxCount
(
count
)
//On supprime les meilleures alternatives du décompte
for
alt
:=
range
bestAlts
{
delete
(
count
,
Alternative
(
alt
))
}
//Départage
for
len
(
bestAlts
)
>
0
{
bestAlt
,
_
:=
tb
(
bestAlts
)
//ajout de la meilleure alternative post-tie break
sorted_alts
=
append
(
sorted_alts
,
bestAlt
)
//suppression de l'alternative dans bestAlts
indice
:=
rank
(
bestAlt
,
bestAlts
)
bestAlts
=
append
(
bestAlts
[
:
indice
],
bestAlts
[
indice
+
1
:
]
...
)
//suppression de l'alternativ dans le compte
delete
(
count
,
Alternative
(
bestAlt
))
}
}
return
sorted_alts
,
nil
}
}
func
Test_sWFFactory
(){
//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
)
//Construction de la Social Welfare Factory à partir de la fonction swf + la fonction de TieBreak
mu
:=
SWFFactory
(
BordaSWF
,
lambda
)
//Construction d'une fonction
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))
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment