Package: jaggpy
JAGGPYjaggpyis a Python package for computing outcomes ofjudgment aggregation(JA) scenarios. The package allows for JA scenarios in the most general form, where issues in the agenda, constraints on judgment sets and constraints on the outcome may be arbitrary formulas. For more information on the formal framework used see, e.g.,Endriss, U., de Haan, R., Lang, J., & Slavkovik, M. (2020).The Complexity Landscape of Outcome Determination in Judgment Aggregation.Journal of Artificial Intelligence Research,69, 687-731.in which it is referred to asframework (6).The package offers two ways in which to generate outcomes for a scenario given a JA rule. The first (and slowest) is a brute force solver, and the second makes use of Answer Set Programming (ASP) for the efficient computation of outcomes, building on the encodings presented by de Haan and Slavkovik inde Haan, R., & Slavkovik, M. (2019).Answer set programming for judgment aggregation. InProceedings of the 28th International Joint Conference on Artificial Intelligence (IJCAI 2019). AAAI Press.Table of contentsGetting startedPrerequisitesInstallationTestsUsageScenario objectsFormulas.jagg fileCreating a Scenario ObjectScenario methods and propertiesUsing the solverCreating a solver objectSolver methodsLicenseAcknowledgementsContactReferencesGetting StartedPrerequisitesAt least Python 3.4 is required.InstallationTo install the package run the following commandpip install jaggpyThis will automatically install (if not yet available)
the following dependencies:nnfpyparsingPart of the functionality ofjaggpydepends
onclingo,
which is most conveniently installed usingAnaconda,
e.g., with:conda install -c potassco clingoTestsTo check whether the package and all dependencies are installed and working properly, run the following command:python -m unittest jaggpy.testsUsageTo use this package you need to create a scenario object for the scenario that you want to apply judgment aggregation to. Futhermore, a solver object needs to be made to apply one of the aggregation rules to the scenario. These objects and their methods will be discussed in the following.Scenario objectsFormulasThis package can handle arbitrary formulas in the agenda, input-, and output constraints. The available operators are conjunction (&), disjunction (|), negation (~) and implication (->). Parentheses can usually be omitted where clear from context. A few example formulas are:(~x1 | ~x2 | ~x3) & (~x1 | ~x3 | ~x4)

 (x1 -> ~(x2 & x3)) & (x1 -> ~(x3 & x4)))

 ( ~x1 & x2 ) -> x3.jaggfileAn object from the scenario class is read from a.jaggfile. A.jaggfile should be formatted as follows:var_1,...,var_n: A list of all the variables occuring in the scenario.m: The number of issues in the pre-agenda. (Note that only a pre-agenda needs to be specified. The agenda will be automatically generated. A pre-agenda contains all the issues in their unnegated form. The agenda additionally includes their negations.)X, Formula: For each of themformulas in the pre-agenda, the numberXas a label followed by the formula.In, Formula: The input constraint labeled by the string "In". (Note that it is possible to have be multiple input constraints.)Out, Formula: The output constraint labeled by the string "Out". (Note that it is possible to have be multiple output constraints.)v, j: The number of votersvfollowed by the number of distinct judgment setsj.J, Label_1;...;Label_n: The number of times this judgment set occurs followed by the labels of the accepted formulas. The formulas should be separated by a semicolon. Issues that are not accepted are rejected.By starting a line with a "#" the line will be ignored in the reading of the file. Blank lines will also be ignored. Using these comments and blank lines the.jaggfile can be made more readable.An example of the format of a.jaggfile is:x1, x2, x3
4

# The issues
1, x1
2, x2
3, x3
4, ( ~x1 & x2 ) -> x3

# The constraints are the same
In, ( x1 | ~x1 )
Out, ( x1 | ~x1 )

# We have 8 voters and 3 different judgment sets
8, 3
3, 2;3;4
2, 1;2;4
3, 4In this scenario we have the variablesx1,x2andx3. There are4different issues in the agenda. These issues arex1,x2,x3and( ~x1 & x2 ) -> x3, and are labeled by the numbers1-4respectively. The input and output constraints are( x1 | ~x1 ). There are8voters and3different judgment sets. Of the voters three have accepted the issues labeled by2,3and4(and thus have rejected the issue labeled by1). Two have accepted the issues labeled by1,2and4(and thus have rejected the issue labeled by3). And three have accepted the issue labeled by4(and thus have rejected the issues labeled by1,2and3).Creating a Scenario ObjectA scenario object should first be created, and then can be loaded from a.jaggfile given its path. The path should be given as a string, i.e., of the form"path/to/file/". It can then be loaded using theload_from_filemethod of the scenario class. For example:fromjaggpyimportScenarioscenario1=Scenario()scenario1.load_from_file("path/to/file")If there are any inconsistencies in the scenario defined in the.jaggfile, a warning indicating the inconsistency will occur. It is not possible to successfully load an inconsistent scenario.Scenario methods and propertiesA scenario object has several useful methods and properties.pretty_repr(): A method that returns a string that represents the scenario in a readable format.agenda: This property is a dictionary with the the labels of issues as keys and the issues as values.input_constraints: This property is a list of the input constraints.output_constraints: This property is a list of the output constraints.profile: This property is a list of the judgment sets. Each element is a list of which the first element is the number of times the judgment set occurs. The second element of these lists is a list with the issues that are accepted.number_voters: This property is an integer specifying the number of voters.Using the solverCreating a solver objectIn order to call a solver, we first need to create a solver object. We can create a brute force solver object and an ASP solver object as follows:fromjaggpyimportBFSolver,ASPSolverbfs=BFSolver()asp=ASPSolver()Solver methodsThere are a number of different aggregation rules that are supported. For the brute force solver these are:kemenymaxhammingslaterFor the ASP solver these are:kemenyslaterleximaxyoungmajorityThere are three solver methods corresponding to different ways in which the output is given. For each of these the first argument is the the scenario object and the second argument a lowercase string specifying the rule to be executed. Also, each method has a named argumentverbosethat, if turned on, prints the used rule and solver. This property isFalseby default.The methods are the following:all_outcomes()This method needs no additional arguments. The output of this method is a generator with all the outcomes.outcomes()This method takes one additional argumentnum, which specifies the number of outcomes that are yielded.For example, we can compute and enumerate outcomes generated by the Kemeny rule, given the scenario objectscenario1as follows:foroutcomeinasp.all_outcomes(scenario1,"kemeny",verbose=True):print(outcome)foroutcomeinbfs.outcomes(scenario1,"slater",num=2):print(outcome)LicenseDistributed under the MIT License. SeeLICENSEfor more information.AcknowledgementsThe encodings in this package are created byBo Flachs,Philemon HuisingandRonald de HaanContactRonald de Haan -me@ronalddehaan.euGithub Link:https://github.com/rdehaan/jaggpyReferencesEndriss, U., de Haan, R., Lang, J., & Slavkovik, M. (2020).The Complexity Landscape of Outcome Determination in Judgment Aggregation.Journal of Artificial Intelligence Research,69, 687-731.de Haan, R., & Slavkovik, M. (2019).Answer set programming for judgment aggregation. InProceedings of the 28th International Joint Conference on Artificial Intelligence (IJCAI 2019). AAAI Press.