Skip to content

Commit

Permalink
merge branch origin/master into evolog-actions-new
Browse files Browse the repository at this point in the history
  • Loading branch information
madmike200590 committed May 26, 2024
2 parents 01c7038 + 2b1dddb commit fac7e67
Show file tree
Hide file tree
Showing 252 changed files with 5,928 additions and 2,497 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
strategy:
matrix:
# We test against Java releases:
# - greater than 7
# - greater than or equal to 11
# AND
# - with LTS and in "Premier Support" phase
# OR
Expand All @@ -15,12 +15,12 @@ jobs:
# https://blogs.oracle.com/java-platform-group/oracle-jdk-releases-for-java-11-and-later
# https://www.oracle.com/technetwork/java/java-se-support-roadmap.html
java:
# LTS and in "Premier Support" as of 2019-03 (until 2022-03)
- 8
# LTS and in "Premier Support" as of 2019-03 (until 2023-09)
- 11
# LTS as of 2021-11 (until 2029)
- 17
# Not succeeded as of 2022-12
- 19
os: [ubuntu, windows]
env:
# We only post coverage data for exactly one build to coveralls.
Expand All @@ -40,7 +40,7 @@ jobs:
# See https://github.com/marketplace/actions/gradle-wrapper-validation
- uses: gradle/wrapper-validation-action@v1
# See https://github.com/marketplace/actions/setup-java-jdk
- uses: actions/setup-java@v2
- uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java }}
distribution: 'temurin'
Expand All @@ -52,7 +52,7 @@ jobs:
if: matrix.os == env.MAIN_OS && matrix.java == env.MAIN_JAVA
continue-on-error: true
with:
arguments: jacocoTestReport coveralls
arguments: jacocoAggregatedTestReport coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
- uses: codecov/codecov-action@v1
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ possibilities to interface with the ecosystem built around the Java Virtual Mach

## Getting Started

Download a current version of `alpha.jar` from [Releases](https://github.com/alpha-asp/Alpha/releases).
Download a current version of the distribution jar (`alpha-cli-app-${version}-bundled.jar`) from [Releases](https://github.com/alpha-asp/Alpha/releases) and save it as `alpha.jar` for convenience.

Running Alpha is as simple as running any other JAR:

Expand Down Expand Up @@ -52,19 +52,19 @@ Alpha uses the [Gradle build automation system](https://gradle.org). Executing
$ ./gradlew build
```

will automatically fetch all dependencies (declared in [`build.gradle`](build.gradle)) and compile the project.
will automatically fetch all dependencies (declared in [`build.gradle.kts`](build.gradle.kts)) and compile the project.

Artifacts generated will be placed in `build/`. Most notably you'll find files ready for distribution at
`build/distributions/`. They contain archives which in turn contain a `bin/` directory with scripts to run Alpha on Linux
Artifacts generated will be placed in the `build/` subfolder of the respective module. Most notably you'll find files ready for distribution at
`alpha-cli-app/build/distributions/`. They contain archives which in turn contain a `bin/` directory with scripts to run Alpha on Linux
and Windows.

If you want to generate a JAR file to be run standalone, execute

```bash
$ ./gradlew bundledJar
$ ./gradlew alpha-cli-app:bundledJar
```

and pick up `build/libs/alpha-bundled.jar`.
and pick up `alpha-cli-app/build/libs/alpha-cli-app-${version}-bundled.jar`.

### A Note on IDEs

Expand Down
70 changes: 38 additions & 32 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,64 +2,70 @@

This document explains how to build and release Alpha.

First, decide which revision (= Git commit) of Alpha you want to release. This revision should be on `master`
and ideally ahead of any previously released revisions. We denote the Git commit hash of the revision to be
released as `$rev` (it is a reference to a commit, so it could be the name of a branch, say, `master` or just
a hash like `cafebabe`).

You probably have already checked out this version, but if you haven't, do so now:
The regular release workflow for Alpha assumes that a release will always be based on the latest commit in the `master` branch. In order to release Alpha, first checkout the `master` branch and make sure you're up to date:

```bash
$ git checkout $rev
$ git checkout master
$ git pull
```

Now is the time to make sure the revision you are about to release actually works fine. Run tests, try it out
manually, maybe go paranoid and `./gradlew clean` everything and try again. Only continue if you are happy with
the revision you are about to release, and avoid list minute fixes.
Now is the time to make sure the revision you are about to release actually works. Build it using `./gradlew clean build`, potentially do some manual tests, play around a bit, maybe go paranoid and `./gradlew clean build` everything once more. Only continue if you are happy with the state you are about to release, and avoid last minute fixes.

Next, give `$rev` a name, by tagging it. The naming convention for tags is
[Semantic Versioning 2](http://semver.org/spec/v2.0.0.html). **Read through the specification of Semantic
Versioning carefully, before releasing anything. If in doubt, read it again and seek advice.**
The actual release process consists of following steps:
- Create a release tag using gradle release plugin.
- From the tag created by gradle release plugin, create a release on github.

Make sure the version you want to release does not collide and fits with any
[tags already present on GitHub](https://github.com/alpha-asp/Alpha/tags). We denote the version to be released
as `$version` (it looks like "v0.1.0", "v1.0.0-beta", note it starts with the letter "v").
#### Creating a release tag using Gradle Release Plugin

```bash
$ git tag $version
```
Before running the release plugin, decide on a release version identifier and the next development version. Version identifiers must confirm to [Semantic Versioning 2](http://semver.org/spec/v2.0.0.html). **Read through the specification of Semantic Versioning carefully, before releasing anything. If in doubt, read it again and seek advice.** Also, make sure the version you want to release does not collide with any [tag already present on GitHub](https://github.com/alpha-asp/Alpha/tags). We denote the version to be released as `$version` (it looks like "0.1.0", "1.0.0-beta").

Now you push this tag to GitHub:
The next development version (denoted `$nextVersion`) is the version you expect to be the next release version. Note that it isn't set in stone since actual release versions are set during the release process. For example, if your release version is `0.9.0`, your next version could be `0.10.0` or `1.0.0`.

To create a release tag and set the correct versions in the `gradle.properties` file, call the gradle release plugin:

```bash
$ git push --tags
$ ./gradlew release -Prelease.useAutomaticVersion=true -Prelease.releaseVersion=$version -Prelease.newVersion=$nextVersion-SNAPSHOT
```
**Make sure you add the `-SNAPSHOT` qualifier to the next version!** This is the version that will be put into `gradle.properties` in the `master` branch after creating the release tag, i.e. subsequent builds of `master` (e.g. nightly builds from CI workflows) will have this version.

The release plugin automatically pushes all changes it makes in the repository. After running it, make sure:
- `gradle.properties` in `master` has the new `SNAPSHOT` version.
- On github, you can see a new tag with the same name as your release version.
- When you check out the tag, `gradle.properties` contains the correct version, i.e. the tag name.

Navigate to (Releases)[https://github.com/alpha-asp/Alpha/releases] and press "Draft a new release"). Fill in `$version`
as the name of your tag, and change the Release Title to `$version`. Feel free to write a release note (we currently
have no policy in place for release notes). If `$version` is below 1 or you are releasing a preview version, check the
box.

Now, let's generate two distribution packages of Alpha for convenience. You will attach two files to the release on
GitHub. `alpha.jar`, a self-contained and executbale JAR and `alpha.zip` which contains Alpha as JAR file, dependencies
as JAR files and two scripts to run Alpha on Unix-like and Windows respectively.
Now, let's generate some distribution packages of Alpha for convenience. You will attach the following files to the release on GitHub:
- `alpha-cli-app-$version-bundled.jar: A "fat-jar" containingthe Alpha CLI applications along with all dependencies in one jar file.
- Distribution zip- and tar-archives for the CLI application: Zip- and tar-versions of an archive with Alpha, all dependencies, and launcher scripts for windows and UNIX-like systems.
- A zip- and tar-archive of the source code for Alpha.

To generate `alpha.jar`:
To generate these artifacts, check out your release tag:

```bash
$ git checkout $version
```

To generate the "fat-jar":

```bash
$ ./gradlew alpha-cli-app:bundledJar
$ cp alpha-cli-app/build/libs/alpha-cli*-bundled.jar alpha.jar
```

To generate `alpha.zip`:
The jar file can be found in `./alpha-cli-app/build/libs/alpha-cli-app-$version-bundled.jar`

To generate distribution archives:

```bash
$ ./gradlew alpha-cli-app:distZip
$ cp alpha-cli-app/build/distributions/*.zip alpha.zip
$ ./gradlew alpha-cli-app:distZip && ./gradlew alpha-cli-app:distTar
```

Attach the two files to the release on GitHub, then publish the release. Lastly, check that everything is fine,
e.g. that the tag/version really points at the revision you wanted to rlease and that `alpha.zip` and `alpha.jar
downloaded from GitHub do what they are supposed to do.
The finished archives are located in `./alpha-cli-app/build/distributions/`.
Last `./gradlew clean` the project to get rid of all build artifacts, then create a `sources.zip` (using e.g. `zip -r sources.zip .`) and a `sources.tar.gz` (using e.g. `tar -czf /tmp/sources.tar.gz .`)

Attach the generated files to the release on GitHub, then publish the release. Last but not least, check that everything is fine, i.e. the files - when downloaded from the github release - do what they're supposed to.

Optionally, archive the release on Zenodo. If you do so, add the new identifier to `CITATION.cff`.
16 changes: 16 additions & 0 deletions alpha-api/src/main/java/at/ac/tuwien/kr/alpha/api/Alpha.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Stream;

import at.ac.tuwien.kr.alpha.api.common.fixedinterpretations.PredicateInterpretation;
import at.ac.tuwien.kr.alpha.api.config.InputConfig;
import at.ac.tuwien.kr.alpha.api.programs.InputProgram;
import at.ac.tuwien.kr.alpha.api.programs.NormalProgram;
import at.ac.tuwien.kr.alpha.api.programs.Predicate;
import at.ac.tuwien.kr.alpha.api.programs.atoms.BasicAtom;
import at.ac.tuwien.kr.alpha.api.programs.tests.TestResult;

/**
* Main API entry point for the Alpha ASP system. Provides facilities for parsing, normalizing and solving ASP programs.
Expand Down Expand Up @@ -165,4 +168,17 @@ public interface Alpha {
*/
Solver prepareSolverFor(NormalProgram program, java.util.function.Predicate<Predicate> filter);

/**
* Reifies, i.e. re-expresses as a set of ASP facts, the given input program.
*
* @param program an ASP program to reify
* @return a set of {@link BasicAtom}s encoding the given program
*/
Set<BasicAtom> reify(ASPCore2Program program);

/**
* Runs all test cases of the given program.
*/
TestResult test(ASPCore2Program program);

}
21 changes: 17 additions & 4 deletions alpha-api/src/main/java/at/ac/tuwien/kr/alpha/api/AnswerSet.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package at.ac.tuwien.kr.alpha.api;

import java.util.List;
import java.util.SortedSet;

import at.ac.tuwien.kr.alpha.api.programs.Predicate;
import at.ac.tuwien.kr.alpha.api.programs.atoms.Atom;
import at.ac.tuwien.kr.alpha.api.programs.atoms.AtomQuery;

import java.util.List;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;

/**
* API representation of an answer set, i.e. a set of atoms that is a model of an ASP program.
Expand All @@ -31,5 +34,15 @@ public interface AnswerSet extends Comparable<AnswerSet> {
/**
* List {@link Atom}s in this answer set satisfying the given {@link AnswerSetQuery}.
*/
List<Atom> query(AnswerSetQuery query);
List<Atom> query(AtomQuery query);

default Set<Atom> asFacts() {
return getPredicates().stream()
.map(this::getPredicateInstances)
.reduce(new TreeSet<Atom>(), (left, right) -> {
left.addAll(right);
return left;
});
}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import at.ac.tuwien.kr.alpha.api.programs.InputProgram;
import at.ac.tuwien.kr.alpha.api.programs.Predicate;
import at.ac.tuwien.kr.alpha.api.terms.Term;
import at.ac.tuwien.kr.alpha.api.programs.terms.Term;

/**
* A comparison operator that can be used in {@link InputProgram}s.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
import java.util.List;
import java.util.Set;

import at.ac.tuwien.kr.alpha.api.terms.ConstantTerm;
import at.ac.tuwien.kr.alpha.api.terms.Term;
import at.ac.tuwien.kr.alpha.api.programs.terms.ConstantTerm;
import at.ac.tuwien.kr.alpha.api.programs.terms.Term;

import static java.util.Collections.*;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class InputConfig {
public static final String DEFAULT_PREPROC_TARGET_FILE = "input.preproc.asp";
public static final boolean DEFAULT_WRITE_XLSX = false;
public static final String DEFAULT_XLSX_OUTFILE_PATH = "alphaAnswerSet"; // current directory, files named "alphaAnswerSet.{num}.{ext}"
public static final boolean DEFAULT_REIFY_INPUT = false;
public static final boolean DEFAULT_RUN_TESTS = false;

private List<String> aspStrings = new ArrayList<>();
private List<String> files = new ArrayList<>();
Expand All @@ -37,11 +39,13 @@ public class InputConfig {
private String compgraphPath = InputConfig.DEFAULT_COMPGRAPH_TARGET_FILE;
private String normalizedPath = InputConfig.DEFAULT_NORMALIZED_TARGET_FILE;
private String preprocessedPath = InputConfig.DEFAULT_PREPROC_TARGET_FILE;

private Map<String, PredicateInterpretation> predicateMethods = new HashMap<>();
private boolean writeAnswerSetsAsXlsx = InputConfig.DEFAULT_WRITE_XLSX;
private String answerSetFileOutputPath;
private boolean reifyInput = InputConfig.DEFAULT_REIFY_INPUT;
private boolean runTests = InputConfig.DEFAULT_RUN_TESTS;

private Map<String, PredicateInterpretation> predicateMethods = new HashMap<>();

public static InputConfig forString(String str) {
InputConfig retVal = new InputConfig();
retVal.aspStrings.add(str);
Expand Down Expand Up @@ -209,4 +213,20 @@ public void setDebugPreprocessing(boolean debugPreprocessing) {
this.debugPreprocessing = debugPreprocessing;
}

public boolean isReifyInput() {
return reifyInput;
}

public void setReifyInput(boolean reifyInput) {
this.reifyInput = reifyInput;
}

public boolean isRunTests() {
return runTests;
}

public void setRunTests(boolean runTests) {
this.runTests = runTests;
}

}
Loading

0 comments on commit fac7e67

Please sign in to comment.