Mentions légales du service

Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • rules/integraal
  • ulliana/integraal
2 results
Show changes
Commits on Source (237)
Showing
with 1685044 additions and 169 deletions
......@@ -88,3 +88,4 @@ tatooinetmp.conf
# ctags file
tags
build.xml
/integraal/integraal-explanation/gsat.gcnf
This diff is collapsed.
......@@ -94,36 +94,6 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven-shade-plugin-version}</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>jar-with-dependencies</shadedClassifierName>
<finalName>integraal-with-dependencies</finalName>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>**/module-info.*</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/**/*.class</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
......
......@@ -118,79 +118,6 @@
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>${maven-shade-plugin-version}</version>
<executions>
<execution>
<id>build-integraal-commander</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>
fr.boreal.api.integraal_commander.InteGraalCommander</mainClass>
</transformer>
</transformers>
<finalName>integraal-commander</finalName>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>jar-with-dependencies</shadedClassifierName>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>**/module-info.*</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/**/*.class</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
<execution>
<id>build-integraal-cli</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>
fr.boreal.api.integraal_repl.IGRepl</mainClass>
</transformer>
</transformers>
<finalName>integraal-cli</finalName>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>jar-with-dependencies</shadedClassifierName>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>**/module-info.*</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/**/*.class</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
......
......@@ -86,7 +86,7 @@ public class IGCommands {
* Prints the substitutions from the iterator.
*
* @param subIt The iterator of substitutions containing the query results.
* @param vars The variables to print; this provides the order of the variables
* @param varsOrder The variables to print; this provides the order of the variables
* @param writer The DlgpWriter object used to write the results.break;
* @param max The maximum number of substitutions to print.
*/
......
package test.factbase_loader;
import fr.boreal.component_builder.AlgorithmParameters;
import fr.boreal.component_builder.InputDataScenario;
import fr.boreal.component_builder.components.FactBaseLoaderFromFile;
import fr.boreal.configuration.keywords.InteGraalKeywords;
import fr.boreal.model.kb.api.FactBase;
import fr.boreal.model.kb.api.RuleBase;
import fr.boreal.model.kb.impl.RuleBaseImpl;
import fr.boreal.model.query.api.Query;
import fr.boreal.storage.builder.StorageBuilder;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import java.net.URISyntaxException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Optional;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
*
*/
public class FactbaseLoadingWithComponentTest {
/**
* Helper method to retrieve the absolute path of a resource in the test/resources folder.
*
* @param relativePath The relative path to the resource.
* @return The absolute Path object of the resource.
* @throws URISyntaxException If the path syntax is incorrect.
*/
private Path getAbsoluteResourcePath(String relativePath) throws URISyntaxException {
return Paths.get(ClassLoader.getSystemResource(relativePath).toURI());
}
/**
* @throws URISyntaxException
*/
@Test
public void testSetFactbasePaths() throws URISyntaxException {
InputDataScenario scenario = new InputDataScenario("TestScenario");
// Get absolute paths using the helper method
String[] paths = {
getAbsoluteResourcePath("factbase/test_factbase.rls").toString()
};
scenario.setFactbasePaths(paths);
var param = new AlgorithmParameters("test in memory storage", InteGraalKeywords.Algorithms.KB_CHASE);
var fb = FactBaseLoaderFromFile.getFactbaseFor(scenario, param);
System.out.println(fb);
Assertions.assertTrue(fb.size()==2);
}
}
package test;
package test.input_data_scenario_object;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
......@@ -11,6 +11,9 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Optional;
import fr.boreal.component_builder.AlgorithmParameters;
import fr.boreal.component_builder.components.FactBaseLoaderFromFile;
import fr.boreal.configuration.keywords.InteGraalKeywords;
import org.junit.Test;
import fr.boreal.component_builder.InputDataScenario;
......
@source p[2]: load-csv("./test_factbase2.csv") .
@source q[2]: load-csv("./test_factbase3.csv") .
a, b
\ No newline at end of file
c, d
\ No newline at end of file
......@@ -350,7 +350,8 @@ public enum InteGraalKeywords {
/**
* GRD Scheduler
*/
GRD
GRD,
BY_PREDICATE
}
/**
......
This diff is collapsed.
# Use an official Python image with Debian-based OS
FROM python:3.9-slim
# Set working directory
WORKDIR /usr/local/bin
# Install system dependencies
RUN apt-get update -y && apt-get install -y \
git \
build-essential \
zlib1g-dev \
&& rm -rf /var/lib/apt/lists/*
# Clone and build MARCO
RUN git clone https://github.com/liffiton/MARCO && \
cd MARCO/src/pyminisolvers && make && \
cd /usr/local/bin && mv ./MARCO/* .
# Ensure MARCO-MUS directory exists and move MARCO files
RUN mkdir -p /usr/local/bin/MARCO-MUS && \
mv /usr/local/bin/marco.py /usr/local/bin/MARCO-MUS/ && \
chmod +x /usr/local/bin/MARCO-MUS/marco.py
# Set environment variables for MARCO
ENV PATH="/usr/local/bin/MARCO-MUS:${PATH}"
ENV PYTHONPATH="/usr/local/bin/src:${PYTHONPATH}"
# Debugging step: Verify MARCO installation
RUN echo "===== Checking MARCO Installation =====" && \
ls -l /usr/local/bin/MARCO-MUS/ && \
echo "===== Checking Python Installation =====" && \
which python3 && python3 --version
# Test MARCO Execution inside Docker
RUN /usr/local/bin/MARCO-MUS/marco.py --help || echo "MARCO execution failed"
# Set MARCO as the default command
ENTRYPOINT ["python", "/usr/local/bin/MARCO-MUS/marco.py"]
......@@ -17,9 +17,15 @@
<description>Facilities for explaining answers to queries</description>
<dependencies>
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>5.7.1</version> <!-- or the latest version -->
</dependency>
<dependency>
<groupId>${groupId}</groupId>
<artifactId>integraal-model</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>${groupId}</groupId>
......@@ -49,6 +55,19 @@
<groupId>${groupId}</groupId>
<artifactId>integraal-component</artifactId>
</dependency>
<dependency>
<groupId>org.ow2.sat4j</groupId>
<artifactId>org.ow2.sat4j.pb</artifactId>
<version>2.3.6</version>
</dependency>
<dependency>
<groupId>org.ow2.sat4j</groupId>
<artifactId>org.ow2.sat4j.pom</artifactId>
<version>2.3.6</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
......@@ -64,11 +83,35 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ow2.sat4j</groupId>
<artifactId>org.ow2.sat4j.sat</artifactId>
<version>2.3.6</version>
</dependency>
<dependency>
<groupId>org.ow2.sat4j</groupId>
<artifactId>org.ow2.sat4j.core</artifactId>
<version>2.3.6</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
<groupId>fr.lirmm.graphik</groupId>
<artifactId>integraal-model</artifactId>
</dependency>
</dependencies>
</dependencies>
<build>
<testResources>
<testResource>
<directory>src/test/resources</directory>
<excludes>
<exclude>**/*</exclude>
</excludes>
</testResource>
</testResources>
</build>
</project>
\ No newline at end of file
package fr.boreal.explanation;
import fr.boreal.explanation.kb_gri.explainers.static_gri.FactSupportExplainer_KBGRI;
import fr.boreal.explanation.kb_gri.explainers.static_gri.KBSupportExplainer_KBGRI;
import fr.boreal.io.api.ParseException;
import fr.boreal.io.dlgp.DlgpParser;
import fr.boreal.model.kb.api.FactBase;
import fr.boreal.model.kb.api.KnowledgeBase;
import fr.boreal.model.kb.api.RuleBase;
import fr.boreal.model.kb.impl.KnowledgeBaseImpl;
import fr.boreal.model.kb.impl.RuleBaseImpl;
import fr.boreal.model.logicalElements.api.Atom;
import fr.boreal.model.logicalElements.factory.api.PredicateFactory;
import fr.boreal.model.logicalElements.factory.api.TermFactory;
import fr.boreal.model.logicalElements.factory.impl.SameObjectPredicateFactory;
import fr.boreal.model.logicalElements.factory.impl.SameObjectTermFactory;
import fr.boreal.model.rule.api.FORule;
import fr.boreal.storage.natives.SimpleInMemoryGraphStore;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Set;
public class InternalDLGPParser {
public InternalDLGPParser(File datalogProgrammeFile, File factsFile, File query_file) throws FileNotFoundException {
PredicateFactory predicateFactory = SameObjectPredicateFactory.instance();
TermFactory termFactory = SameObjectTermFactory.instance();
RuleBase rb = ParserForDLGP.parseRB(datalogProgrammeFile);
FactBase fb = ParserForDLGP.parseFB(datalogProgrammeFile);
KnowledgeBase kb = new KnowledgeBaseImpl(fb,rb);
Collection<Atom> queryAtoms = ParserForDLGP.parseQueries(query_file);
FactSupportExplainer_KBGRI explainer;
explainer = new FactSupportExplainer_KBGRI(kb);
for (Atom queryAtom : queryAtoms) {
Set<FactBase> explanations = explainer.getAllExplanations(queryAtom);
if (explanations.isEmpty()) {
throw new RuntimeException("No explanations found for " + queryAtom);
}
}
}
public static class ParserForDLGP {
public static KnowledgeBase parseKB(File dlgpFile) throws FileNotFoundException {
FactBase fb = new SimpleInMemoryGraphStore();
Collection<FORule> rules = new ArrayList<FORule>();
int ruleLabelNb = 0;
try (DlgpParser dlgp_parseur = new DlgpParser(dlgpFile)) {
while (dlgp_parseur.hasNext()) {
try {
Object result = dlgp_parseur.next();
if (result instanceof Atom) {
fb.add((Atom)result);
} else if (result instanceof FORule) {
((FORule) result).setLabel("r"+ruleLabelNb++);
rules.add((FORule)result);
}
} catch (ParseException e) {
throw new RuntimeException(
String.format("Error with the file %s ", dlgpFile),
e);
}
}
}
RuleBase rb = new RuleBaseImpl(rules);
KnowledgeBase kb = new KnowledgeBaseImpl(fb, rb);
return kb;
}
public static FactBase parseFB(File dlgpFile) throws FileNotFoundException {
FactBase fb = new SimpleInMemoryGraphStore();
try (DlgpParser dlgp_parseur = new DlgpParser(dlgpFile)) {
while (dlgp_parseur.hasNext()) {
try {
Object result = dlgp_parseur.next();
if (result instanceof Atom) {
fb.add((Atom)result);
}
} catch (ParseException e) {
throw new RuntimeException(
String.format("Error with the file %s ", dlgpFile),
e);
}
}
}
return fb;
}
public static RuleBase parseRB(File dlgpFile) throws FileNotFoundException {
Collection<FORule> rules = new ArrayList<FORule>();
try (DlgpParser dlgp_parseur = new DlgpParser(dlgpFile)) {
while (dlgp_parseur.hasNext()) {
try {
Object result = dlgp_parseur.next();if (result instanceof FORule) {
rules.add((FORule)result);
}
} catch (ParseException e) {
throw new RuntimeException(
String.format("Error with the file %s ", dlgpFile),
e);
}
}
}
RuleBase rb = new RuleBaseImpl(rules);
return rb;
}
public static Collection<Atom> parseQueries(File dlgpFile) throws FileNotFoundException {
try (DlgpParser dlgp_parseur = new DlgpParser(dlgpFile)) {
Collection<Atom> queryAtoms = new ArrayList<Atom>();
while (dlgp_parseur.hasNext()) {
try {
Object result = dlgp_parseur.next();
if (result instanceof Atom) {
queryAtoms.add((Atom)result);
}
} catch (ParseException e) {
throw new RuntimeException(
String.format("Error with the file %s ", dlgpFile),
e);
}
}
return queryAtoms;
}
}
}
}
\ No newline at end of file
package fr.boreal.explanation.api;
import fr.boreal.model.formula.api.FOFormulaConjunction;
import fr.boreal.model.kb.api.KnowledgeBase;
import fr.boreal.model.logicalElements.api.Atom;
import fr.boreal.model.query.api.Query;
import java.util.Arrays;
import java.util.Set;
/**
* Interface for an explainer which supports only ground atomic queries (expressed as atoms).
*
* @param <ExplanationType> the type of the (set of) explanations which is returned by the enumerator
*/
public interface AtomicQueryExplanationEnumerator<ExplanationType extends Object> {
/**
* Checks if an atom can be explained
*
* @param query
* @return true iff the query contains only constants and literals
*/
default boolean canExplain(KnowledgeBase kb, Atom query) {
var queryOK = Arrays.stream(query.getTerms()).allMatch(term -> term.isConstant() || term.isLiteral());
// check that all rules body and head are conjunctions
// TODO : check more in depth that the FOFormulaConjunction contains only atoms
// TODO : check that in the the data (be careful of federations) there are only constants and literals
// TODO : check that in the rules there are no functional terms
var rulesOK = true;
for (var r : kb.getRuleBase().getRules()) {
// rules must have a label
if (r.getLabel() == null || r.getLabel().isBlank()) {
throw new RuntimeException("rule label is empty: " + r);
}
if (!(r.getBody() instanceof FOFormulaConjunction || r.getBody() instanceof Atom)) {
rulesOK = false;
break;
}
if (!(r.getHead() instanceof FOFormulaConjunction || r.getHead() instanceof Atom)) {
rulesOK = false;
break;
}
}
return queryOK && rulesOK;
}
/**
*
* @param query
* @return the set of explanations for the query on the current KB
*/
Set<ExplanationType> explain(Atom query);
}
package fr.boreal.explanation.api.encoders;
import fr.boreal.model.logicalElements.api.Atom;
import java.util.Set;
import java.util.function.Predicate;
/**
* Computes at GSAT encoding of the GRI and the Query for GMUS enumeration
* @param <DataStructureType> the data structure holding the GRI
* @param <QueryType> the query type
*/
public interface GSATEncoder_GRI<DataStructureType, QueryType> {
/**
*
* @param filteredGRI
* @param query
* @param belongsToInitialFactbase
* @return at GSAT encoding of the filteredGRI and the Query for GMUS enumeration
*/
GSATEncodingResult_GRI encode(DataStructureType filteredGRI, QueryType query, Predicate<Atom> belongsToInitialFactbase);
}