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
a4c270c6
Commit
a4c270c6
authored
1 year ago
by
Balthazar Wilson
Browse files
Options
Downloads
Plain Diff
Merge branch 'fix/options_handling' of gitlab.utc.fr:gvandevi/ia04binome2a into baltha_server
parents
8857b68f
5c276e50
No related branches found
Branches containing commit
No related tags found
1 merge request
!7
Partie serveur
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
comsoc/TieBreak.go
+58
-0
58 additions, 0 deletions
comsoc/TieBreak.go
with
58 additions
and
0 deletions
comsoc/TieBreak.go
+
58
−
0
View file @
a4c270c6
...
...
@@ -62,6 +62,47 @@ func SWFFactory(swf func(Profile) (Count, error), tb func([]Alternative) (Altern
}
}
func
SWFFactoryWithOptions
(
swf
func
(
Profile
,
[]
int
)
(
Count
,
error
),
tb
func
([]
Alternative
)
(
Alternative
,
error
),
)
func
(
Profile
,
[]
int
)
([]
Alternative
,
error
)
{
return
func
(
p
Profile
,
o
[]
int
)
([]
Alternative
,
error
)
{
//récupération du décompte
count
,
errSWF
:=
swf
(
p
,
o
)
if
errSWF
!=
nil
{
return
nil
,
errSWF
}
//préparation de la sortie
var
sortedAlts
[]
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
,
errTB
:=
tb
(
bestAlts
)
if
errTB
!=
nil
{
return
nil
,
errTB
}
//ajout de la meilleure alternative post-tie break
sortedAlts
=
append
(
sortedAlts
,
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
sortedAlts
,
nil
}
}
func
Test_sWFFactory
()
{
//Définition de l'Ordre strict
orderedAlts
:=
[]
Alternative
{
8
,
9
,
6
,
1
,
3
,
2
}
...
...
@@ -94,6 +135,23 @@ func SCFFactory(scf func(p Profile) ([]Alternative, error), tb func([]Alternativ
return
bestAlt
,
errTB
}
}
func
SCFFactoryWithOptions
(
scf
func
(
Profile
,
[]
int
)
([]
Alternative
,
error
),
tb
func
([]
Alternative
)
(
Alternative
,
error
),
)
func
(
Profile
,
[]
int
)
(
Alternative
,
error
)
{
return
func
(
p
Profile
,
o
[]
int
)
(
Alternative
,
error
)
{
//récupération des meilleures alternatives
bestAlts
,
errSCF
:=
scf
(
p
,
o
)
if
errSCF
!=
nil
{
return
Alternative
(
0
),
errSCF
}
//récupération de la meilleure alternative
bestAlt
,
errTB
:=
tb
(
bestAlts
)
return
bestAlt
,
errTB
}
}
func
Test_sCFFactory
()
{
//Définition de l'Ordre strict
orderedAlts
:=
[]
Alternative
{
8
,
9
,
6
,
1
,
3
,
2
}
...
...
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