Skip to content
Snippets Groups Projects
Commit 04562524 authored by Clément CONTET's avatar Clément CONTET
Browse files

Initial commit

parent 85085703
No related branches found
No related tags found
No related merge requests found
Showing
with 12529 additions and 87 deletions
File added
# AXp and CXp for Scoring Rules # 'Abductive and Contrastive Explanations for Scoring Rules in Voting' from ECAI-24
This repository contains python implementation of algorithms as well as data used in the experimental part and some additionnal material associate to the paper 'Abductive and Contrastive Explanations for Scoring Rules in Voting' by Clément Contet, Umberto Grandi and Jérôme Mengin from ECAI-24.
## Appendix
`Appendix.pdf` is a two-page appendix giving more detailed proofs of some results presented in the paper.
## Implementation
`scoring_rule_Xp.py` contains an implemetation of algorithms presented in the paper. The code was developped and tested under Python 3.11.
## Getting started For the Minimal Hitting Set and SAT solvers we used solvers provided by the library `PySAT` more information on them can be find here https://pysathq.github.io/.
To make it easy for you to get started with GitLab, here's a list of recommended next steps. ## Experiment
The experiment part uses tools developped for the paper 'Diversity, agreement, and polarization in elections' by Piotr Faliszewski, Andrzej Kaczmarczyk, Krzysztof Sornat, Stanisław Szufa, and Tomasz Wąs from IJCAI-23 available at https://github.com/Project-PRAGMA/diversity-agreement-polarization-IJCAI23.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! The `experiments` directory already contains all the data that we used in our experiment. The data is there for convenience. The elections can be generated from scratch.
## Add your files To run the experiment yourself, install the `dap` tool and simply add the directory `SAXp_size_4_12` and the script `SAXp_size_4_12.py`, uncomment parts of the script and run it.
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
```
cd existing_repo
git remote add origin https://gitlab.irit.fr/ccontet1/axp-and-cxp-for-scoring-rules.git
git branch -M main
git push -uf origin main
```
## Integrate with your tools
- [ ] [Set up project integrations](https://gitlab.irit.fr/ccontet1/axp-and-cxp-for-scoring-rules/-/settings/integrations)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy
Use the built-in continuous integration in GitLab.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
import numpy as np
import math
# USE LOCAL MAPEL
import sys
sys.path.append("..")
import mapel
import printing_plus as pp
import kKemenyDistances as kkd
from scoring_rule_Xp import *
name = 'SAXp_size_4_12'
experiment_id = f'{name}'
instance_type = 'ordinal'
distance_id = 'swap'
embedding_id = 'mds'
## Compute the (normalized) size of the SAXp for the Borda score
def SAXp_size(P):
P2 = P.votes.tolist()
n, m = np.shape(P2)
borda_weights = [m - i - 1 for i in range(m)]
elec = election(P2,borda_weights)
w = np.argmax(elec.get_scores())
elec.set_winner(w)
axp = elec.find_smallest_AXp()
return float(len(axp)/(n*m))
## Compute the margin of victory for the Borda score
def margin(P):
P2 = P.votes.tolist()
n, m = np.shape(P2)
borda_weights = [m - i - 1 for i in range(m)]
elec = election(P2, borda_weights)
scores = elec.get_scores()
m1 = -1
m2 = -1
for score in scores:
if score>m1:
m2=m1
m1=score
elif score>m2:
m2=score
return float(m1 - m2)
experiment = mapel.prepare_experiment(experiment_id=experiment_id,
instance_type=instance_type,
distance_id=distance_id,
embedding_id=embedding_id)
# # EXPERIMENT INITIALIZATION
experiment.prepare_elections(printing=True)
print("Elections prepared")
# experiment.compute_distances(distance_id = distance_id)
# print("Distances computed")
# experiment.embed(algorithm='mds')
# print("Coordinates computed")
#
# experiment.compute_feature(feature_id="Agreement")
# print("Agreement computed")
#
# experiment.add_feature("SAXp_size", SAXp_size)
# experiment.compute_feature(feature_id='SAXp_size')
# print("SAXp_size computed")
## experiment.print_map_2d_colored_by_feature(feature_id='SAXp_size')
#
# experiment.add_feature("Margin", margin)
# experiment.compute_feature(feature_id='margin')
# print("Margin computed")
# # MAP ORIENTATION
# Will probably have to be manually tweak for different data
experiment = pp.upside_down_map(experiment)
experiment = pp.rotate_map(experiment, - math.pi *1.2, 'ID')
experiment.print_map(feature_id="SAXp_size",
# legend=True,
shading=True,
# title="SAXp_size",
# textual=['ID', 'UN', 'AN', 'ST'],
saveas="diversity_map_" + "SAXp_size")
# # TRIANGLE MAPS
pp.print_map_by_features(experiment, "Agreement", "SAXp_size", saveas='default')
pp.print_map_by_features(experiment, "Margin", "SAXp_size", saveas='default')
# # CORRELATIONS TO DISTANCES
pp.correlation_feature_feature(experiment, "SAXp_size", "Margin")
pp.correlation_feature_feature(experiment, "SAXp_size", "Agreement")
instance_id;x;y
Impartial Culture_0;3.81201;-6.97759
Impartial Culture_1;8.20354;-7.1031
Impartial Culture_2;7.35385;-7.48845
Impartial Culture_3;3.56218;-7.66295
Impartial Culture_4;-1.6096;-7.89661
Impartial Culture_5;5.14199;-8.74876
Impartial Culture_6;-5.81752;-5.5573
Impartial Culture_7;0.77473;-1.26342
Impartial Culture_8;9.47726;-5.4039
Impartial Culture_9;-3.60359;-8.86441
IAC_0;9.40656;-7.31159
IAC_1;6.90383;-5.65869
IAC_2;5.17949;-10.27487
IAC_3;1.88942;-8.74598
IAC_4;2.25887;-7.3067
IAC_5;4.56108;0.58784
IAC_6;-0.73504;-9.23258
IAC_7;-4.9663;-8.19236
IAC_8;-2.70936;-4.00617
IAC_9;-1.79228;-0.01424
SP by Conitzer_0;-4.64231;3.19712
SP by Conitzer_1;-9.88518;6.62888
SP by Conitzer_2;6.20589;3.72064
SP by Conitzer_3;-1.52127;5.0868
SP by Conitzer_4;6.41124;5.43735
SP by Conitzer_5;9.16475;7.23782
SP by Conitzer_6;5.33898;3.76924
SP by Conitzer_7;5.71883;3.63227
SP by Conitzer_8;9.41772;7.65811
SP by Conitzer_9;5.57555;9.81756
SP by Walsh_0;-7.5383;1.37666
SP by Walsh_1;-5.91081;4.22024
SP by Walsh_2;-7.61162;2.21354
SP by Walsh_3;-1.87261;2.93341
SP by Walsh_4;-9.91014;2.16243
SP by Walsh_5;-4.88092;2.86009
SP by Walsh_6;-4.29156;2.3841
SP by Walsh_7;-1.52387;2.80058
SP by Walsh_8;-6.75923;0.89234
SP by Walsh_9;-8.11148;0.24969
SPOC_0;-1.38979;-0.55253
SPOC_1;4.81091;-5.44573
SPOC_2;3.62848;-1.17817
SPOC_3;3.1393;-4.50301
SPOC_4;5.56935;-3.44068
SPOC_5;8.07035;-3.78701
SPOC_6;2.81722;-2.40792
SPOC_7;-2.32879;-5.86449
SPOC_8;10.13106;-4.73779
SPOC_9;7.95045;-1.82792
Group-Separable_0;11.55349;2.70805
Group-Separable_1;2.59183;8.91338
Group-Separable_2;9.67362;5.57584
Group-Separable_3;10.31759;6.35264
Group-Separable_4;6.47037;11.51803
Group-Separable_5;11.97682;-2.01583
Group-Separable_6;10.26272;-1.21877
Group-Separable_7;2.27551;-9.70953
Group-Separable_8;6.4642;11.52148
Group-Separable_9;11.29537;1.02729
Single-Crossing_0;-10.64567;-4.13905
Single-Crossing_1;-4.23319;8.9148
Single-Crossing_2;0.46352;8.86585
Single-Crossing_3;9.7635;1.98271
Single-Crossing_4;-5.71966;0.55999
Single-Crossing_5;-10.60891;-0.54603
Single-Crossing_6;-9.54934;4.76681
Single-Crossing_7;-9.57658;-3.79423
Single-Crossing_8;-8.77067;-5.80812
Single-Crossing_9;-9.54477;4.25962
1D Interval_0;-0.67896;7.42182
1D Interval_1;4.37435;11.24257
1D Interval_2;6.78744;7.16828
1D Interval_3;-5.75306;1.84972
1D Interval_4;-10.87209;12.84587
1D Interval_5;3.82554;6.04571
1D Interval_6;-4.14798;13.71724
1D Interval_7;2.23528;12.22835
1D Interval_8;-7.72003;12.11236
1D Interval_9;3.72506;8.75083
2D Disc_0;-5.65317;-4.15771
2D Disc_1;7.44084;1.08148
2D Disc_2;-1.47968;8.54835
2D Disc_3;-8.84572;6.31107
2D Disc_4;-6.95862;10.28784
2D Disc_5;-4.34447;4.40604
2D Disc_6;2.25846;2.17373
2D Disc_7;0.50651;3.65532
2D Disc_8;5.80061;-4.45317
2D Disc_9;2.59955;7.06233
3D Cube_0;4.28574;2.59612
3D Cube_1;6.98961;-2.2862
3D Cube_2;-11.47904;-1.80911
3D Cube_3;-3.56388;9.65853
3D Cube_4;1.25906;6.33528
3D Cube_5;1.80842;5.95427
3D Cube_6;-7.11845;-2.79122
3D Cube_7;-0.14222;-3.2392
3D Cube_8;0.04131;-4.95604
3D Cube_9;5.32557;-2.3973
2D Sphere_0;-7.27116;-7.41017
2D Sphere_1;-4.61951;-3.54248
2D Sphere_2;5.18331;7.16363
2D Sphere_3;-10.60904;0.83343
2D Sphere_4;5.80548;-0.68524
2D Sphere_5;-3.94287;-4.35335
2D Sphere_6;-7.34337;-1.85883
2D Sphere_7;8.32112;2.56108
2D Sphere_8;3.35035;2.81849
2D Sphere_9;-7.53728;3.10987
3D Sphere_0;-7.02773;6.20417
3D Sphere_1;1.21059;-8.01028
3D Sphere_2;-1.13002;-5.07414
3D Sphere_3;-0.79333;4.53504
3D Sphere_4;-3.18522;0.25987
3D Sphere_5;-8.84585;-2.48503
3D Sphere_6;8.38836;-2.9414
3D Sphere_7;2.88719;-0.01918
3D Sphere_8;8.35613;-1.04424
3D Sphere_9;-4.61838;-6.60657
Urn culture_id 0.1_0;0.68438;-9.1768
Urn culture_id 0.1_1;1.19825;-2.76581
Urn culture_id 0.1_2;-4.83605;11.29628
Urn culture_id 0.1_3;0.14308;0.60259
Urn culture_id 0.1_4;-16.20625;8.89946
Urn culture_id 0.1_5;-9.0833;-7.22667
Urn culture_id 0.1_6;0.6023;-6.79988
Urn culture_id 0.1_7;-3.83193;-7.27303
Urn culture_id 0.1_8;10.46417;-3.50739
Urn culture_id 0.1_9;-3.89159;6.97528
Norm-Mallows 0.5_0;-12.85428;-0.49966
Norm-Mallows 0.5_1;-7.41777;4.75253
Norm-Mallows 0.5_2;-2.23056;-6.77463
Norm-Mallows 0.5_3;-6.69753;7.39104
Norm-Mallows 0.5_4;-8.11006;-1.58457
Norm-Mallows 0.5_5;-9.99002;-0.00976
Norm-Mallows 0.5_6;-11.3633;3.09655
Norm-Mallows 0.5_7;-1.9254;8.75562
Norm-Mallows 0.5_8;0.04998;1.88796
Norm-Mallows 0.5_9;-4.84377;-1.73235
Urn culture_id (gamma)_0;-3.8693;-8.52618
Urn culture_id (gamma)_1;3.58615;-9.48601
Urn culture_id (gamma)_2;3.01508;-6.1135
Urn culture_id (gamma)_3;-0.87038;1.4411
Urn culture_id (gamma)_4;2.10568;-6.50214
Urn culture_id (gamma)_5;8.54529;-8.02813
Urn culture_id (gamma)_6;-2.37268;-9.69627
Urn culture_id (gamma)_7;7.0914;-9.38715
Urn culture_id (gamma)_8;-0.64477;-6.4151
Urn culture_id (gamma)_9;6.22061;-6.65103
ID;-20.4251;10.22303
UN_0;6.9415;-10.16099
UN_1;8.15385;-9.09877
UN_2;8.04044;-10.18628
UN_3;6.49208;-11.34119
AN;13.52198;7.65725
This diff is collapsed.
# 1D_Interval {'dim': 1, 'alpha': 1, 'space': 'uniform'}
4
0, c0
1, c1
2, c2
3, c3
12, 12, 5
4, 0, 3, 2, 1
3, 2, 0, 3, 1
3, 1, 2, 0, 3
1, 3, 0, 2, 1
1, 2, 1, 0, 3
# 1D_Interval {'dim': 1, 'alpha': 1, 'space': 'uniform'}
4
0, c0
1, c1
2, c2
3, c3
12, 12, 4
4, 3, 0, 2, 1
3, 2, 1, 0, 3
3, 1, 2, 0, 3
2, 0, 3, 2, 1
# 1D_Interval {'dim': 1, 'alpha': 1, 'space': 'uniform'}
4
0, c0
1, c1
2, c2
3, c3
12, 12, 5
4, 0, 1, 2, 3
3, 1, 0, 2, 3
2, 3, 2, 1, 0
2, 2, 3, 1, 0
1, 1, 2, 3, 0
# 1D_Interval {'dim': 1, 'alpha': 1, 'space': 'uniform'}
4
0, c0
1, c1
2, c2
3, c3
12, 12, 3
5, 0, 2, 1, 3
4, 3, 1, 2, 0
3, 1, 2, 0, 3
# 1D_Interval {'dim': 1, 'alpha': 1, 'space': 'uniform'}
4
0, c0
1, c1
2, c2
3, c3
12, 12, 5
5, 3, 2, 1, 0
3, 0, 1, 2, 3
2, 2, 1, 0, 3
1, 2, 3, 1, 0
1, 1, 0, 2, 3
# 1D_Interval {'dim': 1, 'alpha': 1, 'space': 'uniform'}
4
0, c0
1, c1
2, c2
3, c3
12, 12, 3
6, 2, 1, 0, 3
4, 3, 0, 1, 2
2, 1, 0, 3, 2
# 1D_Interval {'dim': 1, 'alpha': 1, 'space': 'uniform'}
4
0, c0
1, c1
2, c2
3, c3
12, 12, 4
5, 2, 3, 1, 0
3, 3, 2, 1, 0
2, 3, 1, 0, 2
2, 1, 0, 3, 2
# 1D_Interval {'dim': 1, 'alpha': 1, 'space': 'uniform'}
4
0, c0
1, c1
2, c2
3, c3
12, 12, 4
4, 1, 0, 2, 3
3, 3, 2, 1, 0
3, 0, 1, 2, 3
2, 2, 3, 1, 0
# 1D_Interval {'dim': 1, 'alpha': 1, 'space': 'uniform'}
4
0, c0
1, c1
2, c2
3, c3
12, 12, 5
4, 2, 1, 0, 3
3, 1, 2, 0, 3
2, 0, 3, 1, 2
2, 0, 1, 2, 3
1, 0, 1, 3, 2
# 1D_Interval {'dim': 1, 'alpha': 1, 'space': 'uniform'}
4
0, c0
1, c1
2, c2
3, c3
12, 12, 5
7, 3, 0, 2, 1
2, 2, 1, 0, 3
1, 2, 0, 1, 3
1, 1, 2, 0, 3
1, 0, 3, 2, 1
# 2D_Disc {'dim': 2, 'alpha': 1, 'space': 'uniform'}
4
0, c0
1, c1
2, c2
3, c3
12, 12, 5
4, 1, 0, 3, 2
3, 1, 3, 2, 0
3, 0, 1, 2, 3
1, 3, 2, 1, 0
1, 0, 1, 3, 2
# 2D_Disc {'dim': 2, 'alpha': 1, 'space': 'uniform'}
4
0, c0
1, c1
2, c2
3, c3
12, 12, 3
5, 1, 3, 0, 2
5, 0, 3, 1, 2
2, 3, 0, 1, 2
# 2D_Disc {'dim': 2, 'alpha': 1, 'space': 'uniform'}
4
0, c0
1, c1
2, c2
3, c3
12, 12, 6
4, 0, 3, 1, 2
3, 3, 2, 0, 1
2, 0, 1, 3, 2
1, 3, 0, 2, 1
1, 3, 0, 1, 2
1, 2, 3, 1, 0
# 2D_Disc {'dim': 2, 'alpha': 1, 'space': 'uniform'}
4
0, c0
1, c1
2, c2
3, c3
12, 12, 7
3, 3, 1, 2, 0
2, 2, 1, 0, 3
2, 1, 3, 2, 0
2, 0, 2, 1, 3
1, 2, 1, 3, 0
1, 2, 0, 1, 3
1, 1, 2, 3, 0
# 2D_Disc {'dim': 2, 'alpha': 1, 'space': 'uniform'}
4
0, c0
1, c1
2, c2
3, c3
12, 12, 7
3, 0, 3, 1, 2
2, 3, 0, 2, 1
2, 2, 3, 1, 0
2, 1, 3, 0, 2
1, 3, 2, 0, 1
1, 3, 1, 0, 2
1, 0, 3, 2, 1
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment