Skip to content

Commit 5a0648b

Browse files
Merge branch 'main' into epistemicConstraintFramework
2 parents 728fa49 + 0578204 commit 5a0648b

File tree

26 files changed

+12812
-97
lines changed

26 files changed

+12812
-97
lines changed

.github/workflows/package.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Package
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
pull_request:
7+
branches: [ "main" ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Set up JDK 21
17+
uses: actions/setup-java@v4
18+
with:
19+
# Compile source and target are still specified in pom.xml
20+
java-version: '21'
21+
distribution: 'temurin'
22+
cache: maven
23+
- name: Build with Maven
24+
run: mvn --batch-mode package
25+
26+
# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
27+
- name: Update dependency graph
28+
uses: advanced-security/maven-dependency-submission-action@v4

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ testBuild
3636

3737
gurobi-9.1.0.jar
3838
isula-1.1.1.jar
39+
logs/server.log.lck

org-tweetyproject-arg-deductive/src/main/java/org/tweetyproject/arg/deductive/util/RandomDeductiveKnowledgeBaseGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public DeductiveKnowledgeBase next() {
8989
return kb;
9090
}
9191

92-
92+
9393
/**
9494
* Description missing
9595
* @param <C> Description missing
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* This file is part of "TweetyProject", a collection of Java libraries for
3+
* logical aspects of artificial intelligence and knowledge representation.
4+
*
5+
* TweetyProject is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Lesser General Public License version 3 as
7+
* published by the Free Software Foundation.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*
17+
* Copyright 2025 The TweetyProject Team <http://tweetyproject.org/contact/>
18+
*/
19+
package org.tweetyproject.arg.dung.examples;
20+
21+
import org.tweetyproject.arg.dung.semantics.Semantics;
22+
import org.tweetyproject.arg.dung.serialisability.util.AigSerialisationPlotter;
23+
import org.tweetyproject.arg.dung.syntax.Argument;
24+
import org.tweetyproject.arg.dung.syntax.DungTheory;
25+
import org.tweetyproject.arg.dung.util.DefaultDungTheoryGenerator;
26+
import org.tweetyproject.graphs.util.AigGraphPlotter;
27+
28+
import java.io.IOException;
29+
import java.net.URISyntaxException;
30+
31+
/**
32+
* Example Usage of the {@link AigGraphPlotter} which renders a given graph via html in the webbrowser
33+
*
34+
* @author Lars Bengel
35+
*/
36+
public class GraphPlotterExample {
37+
public static void main(String[] args) throws URISyntaxException, IOException {
38+
DungTheory theory = new DefaultDungTheoryGenerator(9, 0.2).next();
39+
40+
// Initialize plotter for argumentation framework
41+
AigGraphPlotter<DungTheory,Argument> plotter = new AigGraphPlotter<>(theory);
42+
43+
// Set options for rendering of the graph, eg
44+
plotter.setLinkDeletable(false);
45+
46+
// Render graph
47+
plotter.show();
48+
49+
// Plot an argumentation framework and its serialisation wrt. complete semantics
50+
//AigSerialisationPlotter.showSerialisation(theory, Semantics.CO);
51+
52+
53+
}
54+
}

org-tweetyproject-arg-dung/src/main/java/org/tweetyproject/arg/dung/serialisability/semantics/SerialisationGraph.java

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
*/
1919
package org.tweetyproject.arg.dung.serialisability.semantics;
2020

21-
import org.tweetyproject.arg.dung.reasoner.AbstractExtensionReasoner;
2221
import org.tweetyproject.arg.dung.reasoner.SerialisedExtensionReasoner;
2322
import org.tweetyproject.arg.dung.semantics.Extension;
2423
import org.tweetyproject.arg.dung.semantics.Semantics;
@@ -46,6 +45,8 @@ public class SerialisationGraph implements Graph<SerialisationState> {
4645
/** explicit storage of children for each node */
4746
private Map<SerialisationState, Set<SerialisationState>> children = new HashMap<>();
4847

48+
private Collection<GeneralEdge<SerialisationState>> edges = new HashSet<>();
49+
4950

5051
/**
5152
* Construct a serialisation graph for the given argumentation framework and serialisation reasoner
@@ -65,7 +66,7 @@ public SerialisationGraph(DungTheory theory, SerialisedExtensionReasoner reasone
6566
DungTheory reduct = theory.getReduct(ext);
6667
SerialisationState node = new SerialisationState(reduct, new Extension<>(ext), reasoner.isTerminal(reduct, ext));
6768
this.add(node);
68-
this.add(new DirectedEdge<>(predecessor, node));
69+
this.add(new DirectedEdge<>(predecessor, node, set.toString()));
6970
predecessor = node;
7071
}
7172
predecessor = root;
@@ -84,7 +85,7 @@ public SerialisationGraph(DungTheory theory, Semantics semantics) {
8485
/** Pretty print of the graph.
8586
* @return the pretty print of the graph.
8687
*/
87-
public String prettyPrint(){
88+
public String prettyPrint() {
8889
StringBuilder output = new StringBuilder();
8990
for (SerialisationState serialisationNode : this)
9091
output.append("node(").append(serialisationNode.toString()).append(").\n");
@@ -162,6 +163,7 @@ public boolean add(GeneralEdge<SerialisationState> edge) {
162163
result |= this.add(e.getNodeB());
163164
result |= children.get(e.getNodeA()).add(e.getNodeB());
164165
result |= parents.get(e.getNodeB()).add(e.getNodeA());
166+
result |= edges.add(e);
165167
return result;
166168
}
167169

@@ -190,19 +192,18 @@ public boolean areAdjacent(SerialisationState a, SerialisationState b) {
190192

191193
@Override
192194
public GeneralEdge<SerialisationState> getEdge(SerialisationState a, SerialisationState b) {
193-
return new DirectedEdge<>(a, b);
195+
for (GeneralEdge<SerialisationState> edge : edges) {
196+
DirectedEdge<SerialisationState> e = (DirectedEdge<SerialisationState>) edge;
197+
if (e.getNodeA().equals(a) && e.getNodeB().equals(b)) {
198+
return new DirectedEdge<>(e.getNodeA(), e.getNodeB(), e.getLabel());
199+
}
200+
}
201+
return null;
194202
}
195203

196204
@Override
197205
public Collection<? extends GeneralEdge<? extends SerialisationState>> getEdges() {
198-
Collection<DirectedEdge<SerialisationState>> edges = new HashSet<>();
199-
for (SerialisationState node: this) {
200-
for (SerialisationState succ: this.children.get(node)) {
201-
DirectedEdge<SerialisationState> edge = new DirectedEdge<>(node, succ);
202-
edges.add(edge);
203-
}
204-
}
205-
return edges;
206+
return new HashSet<>(this.edges);
206207
}
207208

208209
@Override
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package org.tweetyproject.arg.dung.serialisability.util;
2+
3+
import org.tweetyproject.arg.dung.reasoner.SerialisedExtensionReasoner;
4+
import org.tweetyproject.arg.dung.semantics.Extension;
5+
import org.tweetyproject.arg.dung.semantics.Semantics;
6+
import org.tweetyproject.arg.dung.serialisability.semantics.SerialisationGraph;
7+
import org.tweetyproject.arg.dung.serialisability.semantics.SerialisationState;
8+
import org.tweetyproject.arg.dung.syntax.Argument;
9+
import org.tweetyproject.arg.dung.syntax.DungTheory;
10+
import org.tweetyproject.graphs.util.AigGraphPlotter;
11+
12+
import java.awt.*;
13+
import java.io.File;
14+
import java.io.IOException;
15+
import java.nio.file.Files;
16+
import java.nio.file.Path;
17+
import java.nio.file.Paths;
18+
19+
20+
public abstract class AigSerialisationPlotter extends AigGraphPlotter<DungTheory,Argument> {
21+
22+
public AigSerialisationPlotter(DungTheory graph) {
23+
super(graph);
24+
}
25+
26+
public static void showSerialisation(DungTheory theory, Semantics semantics) {
27+
SerialisedExtensionReasoner reasoner = new SerialisedExtensionReasoner(semantics);
28+
29+
SerialisationGraph serialisation = reasoner.getSerialisationGraph(theory);
30+
SerialisationState root = new SerialisationState(theory, new Extension<>(), reasoner.isTerminal(theory, new Extension<>()));
31+
32+
AigGraphPlotter<DungTheory,Argument> plotter1 = new AigGraphPlotter<>(theory);
33+
AigGraphPlotter<SerialisationGraph,SerialisationState> plotter2 = new AigGraphPlotter<>(serialisation);
34+
plotter2.makeLeveled(root);
35+
36+
Path outputPath = Paths.get("index.html");
37+
try {
38+
String template = Files.readString(Paths.get(getResource("aiggraph/serialisation.template")));
39+
String output = String.format(template,
40+
plotter1.write(), plotter2.write(),
41+
getResource("aiggraph/favicon.ico"), getResource("aiggraph/style.css"),
42+
getResource("aiggraph/load-mathjax.js"), getResource("aiggraph/graph-component.js")
43+
);
44+
45+
Files.writeString(outputPath, output);
46+
47+
// show graph in web browser
48+
File htmlFile = new File("index.html");
49+
Desktop.getDesktop().browse(htmlFile.toURI());
50+
} catch (IOException e) {
51+
throw new RuntimeException(e);
52+
}
53+
}
54+
}

org-tweetyproject-arg-rankings/src/main/java/org/tweetyproject/arg/rankings/reasoner/StrategyBasedRankingReasoner.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ public double computeStrengthOfArgument(Argument a, DungTheory kb, Set<Set<Argum
122122
/*
123123
* Solve problem with simplex algorithm
124124
*/
125-
ApacheCommonsSimplex solver = new ApacheCommonsSimplex();
126-
solver.onlyPositive = true;
125+
ApacheCommonsSimplex solver = new ApacheCommonsSimplex(true);
127126
try {
128127
Map<Variable, Term> solution = solver.solve(problem);
129128
return solution.get(targetVar).doubleValue();

org-tweetyproject-arg-rankings/src/main/java/org/tweetyproject/arg/rankings/util/LexicographicIntTupleComparator.java

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* This comparator compares tuples of integers according to the lexicographic ordering as described in
2525
* [Cayrol, Lagasquie-Schiex. Graduality in argumentation. 2005].
2626
*
27-
* @author Anna Gessler
27+
* @author Anna Gessler, Matthias Thimm
2828
*
2929
*/
3030
public class LexicographicIntTupleComparator implements Comparator<int[]> {
@@ -35,18 +35,28 @@ public class LexicographicIntTupleComparator implements Comparator<int[]> {
3535
public static final double PRECISION = 0.001;
3636
@Override
3737
public int compare(int[] o1, int[] o2) {
38-
String s1 = "";
39-
String s2 = "";
40-
for (int i : o1)
41-
s1 += i;
42-
for (int j : o2)
43-
s2 += j;
44-
return s1.compareTo(s2);
38+
int idx = 0;
39+
while(true) {
40+
if(o1.length == idx && o2.length == idx)
41+
return 0;
42+
if(o1.length == idx)
43+
return -1;
44+
if(o2.length == idx)
45+
return 1;
46+
47+
if(o1[idx] > o2[idx])
48+
return 1;
49+
if(o1[idx] < o2[idx])
50+
return -1;
51+
idx++;
52+
}
53+
4554
}
4655

4756

4857
/** Default Constructor */
49-
public LexicographicIntTupleComparator(){}
58+
public LexicographicIntTupleComparator(){}
59+
5060
}
5161

5262

org-tweetyproject-arg-setaf/src/test/java/SetAfTheoryTest.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717
* Copyright 2021 The TweetyProject Team <http://tweetyproject.org/contact/>
1818
*/
1919

20-
21-
22-
23-
import static org.junit.jupiter.api.Assertions.assertTrue;
20+
import static org.junit.jupiter.api.Assertions.assertEquals;
2421

2522
import java.util.HashSet;
2623
import java.util.Set;
@@ -36,6 +33,7 @@
3633
* Examples of SetAf Theorys and their semantics
3734
*
3835
* @author Sebastian Franke
36+
* @author Oleksandr Dzhychko
3937
*
4038
*/
4139
public class SetAfTheoryTest {
@@ -69,12 +67,10 @@ public void extensionTest() {
6967
String grS = gr.getModel(s).toString();
7068
String adS = ad.getModels(s).toString();
7169
String prS = pr.getModels(s).toString();
72-
73-
assertTrue(grS.equals("{b,d}"));
74-
assertTrue(adS.equals("[{b}, {d}, {b,d}, {}]"));
75-
assertTrue(prS.equals("[{b,d}]"));
76-
7770

71+
assertEquals("{b,c,d}", grS);
72+
assertEquals("[{b}, {d}, {b,d}, {b,c,d}, {}]", adS);
73+
assertEquals("[{b,c,d}]", prS);
7874
}
7975

8076
}

0 commit comments

Comments
 (0)