Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
IA04 TP3
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
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
Mohamed Fall
IA04 TP3
Compare revisions
fe8599ec899add77965926b4152cf8fce1ad426c to 70ca1397d7736cb007a9b53c7d9df1314f4c7faa
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
fallmoha/IA04_TP3
Select target project
No results found
70ca1397d7736cb007a9b53c7d9df1314f4c7faa
Select Git revision
Branches
main
Swap
Target
fallmoha/IA04_TP3
Select target project
fallmoha/IA04_TP3
1 result
fe8599ec899add77965926b4152cf8fce1ad426c
Select Git revision
Branches
main
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (4)
add approval SCF call, and some logs
· 1b7658b8
Antoine Kryus
authored
2 years ago
1b7658b8
Merge branch 'main' of gitlab.utc.fr:fallmoha/IA04_TP3 into main
· 623c1c96
Antoine Kryus
authored
2 years ago
623c1c96
merge
· 5f143eb6
Antoine Kryus
authored
2 years ago
5f143eb6
merge adding pipeline for STV and scoring
· 70ca1397
Antoine Kryus
authored
2 years ago
70ca1397
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ia04_kryus_fall/agt/ballotagent/ballotAgent.go
+6
-1
6 additions, 1 deletion
ia04_kryus_fall/agt/ballotagent/ballotAgent.go
ia04_kryus_fall/cmd/launch_automatic_voting.go
+12
-7
12 additions, 7 deletions
ia04_kryus_fall/cmd/launch_automatic_voting.go
with
18 additions
and
8 deletions
ia04_kryus_fall/agt/ballotagent/ballotAgent.go
View file @
70ca1397
...
...
@@ -112,7 +112,7 @@ func (rba *RestBallotAgent) doNewBallot(w http.ResponseWriter, r *http.Request)
}
log
.
Println
(
"NEW BALLOT: Number of alternatives: "
,
req
.
Alts
)
if
rba
.
rule
!=
"majority"
&&
rba
.
rule
!=
"borda"
&&
rba
.
rule
!=
"copeland"
&&
rba
.
rule
!=
"condorcet"
&&
rba
.
rule
!=
"approval"
&&
rba
.
rule
!=
"scoring"
{
if
rba
.
rule
!=
"majority"
&&
rba
.
rule
!=
"borda"
&&
rba
.
rule
!=
"copeland"
&&
rba
.
rule
!=
"condorcet"
&&
rba
.
rule
!=
"approval"
&&
rba
.
rule
!=
"single transferable vote"
&&
rba
.
rule
!=
"scoring"
{
w
.
WriteHeader
(
http
.
StatusNotImplemented
)
msg
:=
fmt
.
Sprintf
(
"501: vote rule
\"
'%s'
\"
is not impemented in the system"
,
req
.
Rule
)
w
.
Write
([]
byte
(
msg
))
...
...
@@ -145,6 +145,10 @@ func (rba *RestBallotAgent) doNewBallot(w http.ResponseWriter, r *http.Request)
bestAlts
,
err
=
comsoc
.
MajoritySCF
(
rba
.
pfl
)
case
"approval"
:
rba
.
count
,
err
=
comsoc
.
ApprovalSWF
(
rba
.
pfl
,
rba
.
options
)
bestAlts
,
err
=
comsoc
.
ApprovalSCF
(
rba
.
pfl
,
rba
.
options
)
case
"single transferable vote"
:
rba
.
count
,
err
=
comsoc
.
SingleTransferableVoteSWF
(
rba
.
pfl
)
bestAlts
,
err
=
comsoc
.
SingleTransferableVoteSCF
(
rba
.
pfl
)
case
"scoring"
:
rba
.
count
,
err
=
comsoc
.
ScoringSWF
(
rba
.
pfl
,
rba
.
options
)
bestAlts
,
err
=
comsoc
.
ScoringSCF
(
rba
.
pfl
,
rba
.
options
)
...
...
@@ -154,6 +158,7 @@ func (rba *RestBallotAgent) doNewBallot(w http.ResponseWriter, r *http.Request)
rba
.
bestAlt
,
err
=
tb
(
bestAlts
)
if
err
!=
nil
{
log
.
Println
(
"Internal server error in results calculation."
,
err
)
w
.
WriteHeader
(
http
.
StatusInternalServerError
)
msg
:=
fmt
.
Sprintf
(
"500: internal server error."
)
w
.
Write
([]
byte
(
msg
))
...
...
This diff is collapsed.
Click to expand it.
ia04_kryus_fall/cmd/launch_automatic_voting.go
View file @
70ca1397
...
...
@@ -11,7 +11,7 @@ import (
)
func
shuffle
(
n
int
,
pref
[]
comsoc
.
Alternative
)
[]
comsoc
.
Alternative
{
rand
.
Seed
(
time
.
Now
()
.
UnixNano
()
%
100
)
rand
.
Seed
(
time
.
Now
()
.
UnixNano
())
// source := rand.NewSource(time.Now().UnixNano())
// r := rand.New(source
rand
.
Shuffle
(
n
,
func
(
i
,
j
int
)
{
...
...
@@ -38,15 +38,16 @@ func main() {
choice
=
-
1
ts
=
-
1
for
choice
<
0
||
choice
>
4
{
for
choice
<
0
||
choice
>
6
{
fmt
.
Println
(
"Choose the voting rule amonst"
)
fmt
.
Println
(
"0: Borda"
)
fmt
.
Println
(
"1: Majority"
)
fmt
.
Println
(
"2: Copeland"
)
fmt
.
Println
(
"3: Approval"
)
fmt
.
Println
(
"4: Scoring (default vector is <20,21,22,23,...>)"
)
fmt
.
Println
(
"5: Randomly choose between all the latters"
)
fmt
.
Println
(
"4: Single Transferable Vote"
)
fmt
.
Println
(
"5: Scoring (default vector is <20,21,22,23,...>)"
)
fmt
.
Println
(
"6: Randomly choose between all the latters"
)
fmt
.
Println
(
"Enter a number: "
)
fmt
.
Scanln
(
&
choice
)
...
...
@@ -62,10 +63,14 @@ func main() {
fmt
.
Println
(
"Enter an integer number for the threshold : "
)
fmt
.
Scanln
(
&
ts
)
case
4
:
rule
=
"s
cor
ing"
rule
=
"sing
le transferable vote
"
case
5
:
rules
:=
[]
string
{
"borda"
,
"approval"
,
"copeland"
,
"majority"
,
"scoring"
}
rule
=
"scoring"
case
6
:
rules
:=
[]
string
{
"borda"
,
"approval"
,
"copeland"
,
"majority"
}
rand
.
Seed
(
time
.
Now
()
.
UnixNano
())
rule
=
rules
[
rand
.
Intn
(
4
)]
log
.
Println
(
"MAIN:"
,
rule
,
"has been taken randomly as the voting rule."
)
default
:
fmt
.
Println
(
"Incorrect choice..."
)
}
...
...
@@ -109,7 +114,7 @@ func main() {
go
server
.
Start
()
voterAgents
:=
make
([]
agt2
.
RestVoterAgent
,
0
,
m
)
for
i
:=
0
;
i
<
n
;
i
++
{
for
i
:=
0
;
i
<
m
;
i
++
{
id
:=
i
ballotID
:=
1
regle
:=
rule
...
...
This diff is collapsed.
Click to expand it.