Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Polling server IA04
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
Balthazar Wilson
Polling server IA04
Commits
01e78215
Commit
01e78215
authored
1 year ago
by
Gabrielle Van De Vijver
Committed by
Balthazar Wilson
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
fonction pour générer automatiquement des profils
parent
be7b14e5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
comsoc/GenerateProfile.go
+39
-0
39 additions, 0 deletions
comsoc/GenerateProfile.go
with
39 additions
and
0 deletions
comsoc/GenerateProfile.go
0 → 100644
+
39
−
0
View file @
01e78215
package
comsoc
import
(
"fmt"
"math/rand"
"time"
)
func
GenerateProfile
(
nVoters
int
,
nAlts
int
)
{
// Initialisation du profil
profil
:=
make
([][]
Alternative
,
nVoters
)
for
i
:=
range
profil
{
profil
[
i
]
=
make
([]
Alternative
,
nAlts
)
}
// Définition des alternatives
values
:=
make
([]
Alternative
,
nAlts
)
for
i
:=
range
values
{
values
[
i
]
=
Alternative
(
i
+
1
)
}
// Remplissage du profil avec des permutations différentes à chaque rang
rand
.
Seed
(
time
.
Now
()
.
UnixNano
())
for
i
:=
range
profil
{
// Mélange les valeurs pour chaque ligne
permutation
:=
make
([]
Alternative
,
len
(
values
))
copy
(
permutation
,
values
)
rand
.
Shuffle
(
len
(
permutation
),
func
(
i
,
j
int
)
{
permutation
[
i
],
permutation
[
j
]
=
permutation
[
j
],
permutation
[
i
]
})
// Remplit la ligne avec la permutation
copy
(
profil
[
i
],
permutation
)
}
for
_
,
row
:=
range
profil
{
fmt
.
Println
(
row
)
}
}
\ No newline at end of file
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