diff --git a/src/main/java/nl/uu/cs/ape/APE.java b/src/main/java/nl/uu/cs/ape/APE.java
index 29a5ecb5..35b51647 100644
--- a/src/main/java/nl/uu/cs/ape/APE.java
+++ b/src/main/java/nl/uu/cs/ape/APE.java
@@ -25,19 +25,19 @@
import nl.uu.cs.ape.configuration.APERunConfig;
import nl.uu.cs.ape.configuration.tags.validation.ValidationResults;
import nl.uu.cs.ape.constraints.ConstraintTemplate;
-import nl.uu.cs.ape.domain.APEDimensionsException;
-import nl.uu.cs.ape.domain.APEDomainSetup;
-import nl.uu.cs.ape.domain.OWLReader;
import nl.uu.cs.ape.models.MappingsException;
import nl.uu.cs.ape.models.enums.SynthesisFlag;
import nl.uu.cs.ape.models.logic.constructs.TaxonomyPredicate;
import nl.uu.cs.ape.solver.SynthesisEngine;
+import nl.uu.cs.ape.solver.domainconfiguration.APEDimensionsException;
+import nl.uu.cs.ape.solver.domainconfiguration.Domain;
import nl.uu.cs.ape.solver.minisat.SATSynthesisEngine;
import nl.uu.cs.ape.solver.solutionStructure.SolutionWorkflow;
import nl.uu.cs.ape.solver.solutionStructure.SolutionsList;
import nl.uu.cs.ape.solver.solutionStructure.cwl.DefaultCWLCreator;
import nl.uu.cs.ape.utils.APEFiles;
import nl.uu.cs.ape.utils.APEUtils;
+import nl.uu.cs.ape.utils.OWLReader;
/**
* The {@code APE} class is the main class of the library and is supposed to be
@@ -52,7 +52,7 @@ public class APE implements APEInterface {
private final APECoreConfig config;
/** Object containing general APE encoding. */
- private APEDomainSetup apeDomainSetup;
+ private Domain apeDomainSetup;
/**
* Create instance of the APE solver.
@@ -125,7 +125,7 @@ private boolean setupDomain() throws APEDimensionsException, IOException, OWLOnt
* Encode the taxonomies as objects - generate the list of all types / modules
* occurring in the taxonomies defining their submodules/subtypes
*/
- apeDomainSetup = new APEDomainSetup(config);
+ apeDomainSetup = new Domain(config);
OWLReader owlReader = new OWLReader(apeDomainSetup, config.getOntologyFile());
boolean ontologyRead = owlReader.readOntology();
@@ -185,7 +185,7 @@ public APECoreConfig getConfig() {
* @return The object that contains all crucial information about the domain
* (e.g. list of tools, data types, constraint factory, etc.)
*/
- public APEDomainSetup getDomainSetup() {
+ public Domain getDomainSetup() {
return apeDomainSetup;
}
@@ -284,7 +284,7 @@ public SolutionsList runSynthesis(APERunConfig runConfig) throws IOException, JS
* file.
* @throws JSONException Error in configuration object.
*/
- private SolutionsList runSynthesis(JSONObject runConfigJson, APEDomainSetup apeDomainSetup)
+ private SolutionsList runSynthesis(JSONObject runConfigJson, Domain apeDomainSetup)
throws IOException, JSONException, APEConfigException {
apeDomainSetup.clearConstraints();
APERunConfig runConfig = new APERunConfig(runConfigJson, apeDomainSetup);
diff --git a/src/main/java/nl/uu/cs/ape/APEInterface.java b/src/main/java/nl/uu/cs/ape/APEInterface.java
index 4cc9a999..5abc84f9 100644
--- a/src/main/java/nl/uu/cs/ape/APEInterface.java
+++ b/src/main/java/nl/uu/cs/ape/APEInterface.java
@@ -11,8 +11,8 @@
import nl.uu.cs.ape.configuration.APECoreConfig;
import nl.uu.cs.ape.configuration.APERunConfig;
import nl.uu.cs.ape.constraints.ConstraintTemplate;
-import nl.uu.cs.ape.domain.APEDomainSetup;
import nl.uu.cs.ape.models.logic.constructs.TaxonomyPredicate;
+import nl.uu.cs.ape.solver.domainconfiguration.Domain;
import nl.uu.cs.ape.solver.solutionStructure.SolutionsList;
/**
@@ -45,7 +45,7 @@ public interface APEInterface {
* @return The object that contains all crucial information about the domain
* (e.g. list of tools, data types, constraint factory, etc.)
*/
- public APEDomainSetup getDomainSetup();
+ public Domain getDomainSetup();
/**
* Returns all the taxonomy elements that are subclasses of the given element.
diff --git a/src/main/java/nl/uu/cs/ape/Main.java b/src/main/java/nl/uu/cs/ape/Main.java
index e0b07f7e..80819cad 100644
--- a/src/main/java/nl/uu/cs/ape/Main.java
+++ b/src/main/java/nl/uu/cs/ape/Main.java
@@ -27,8 +27,15 @@ public class Main {
* The entry point of application when the library is used in a Command Line
* Interface (CLI).
*
- * @param args APE expects at most one (1) argument: The absolute or relative
- * path to the configuration file.
+ * @param args APE expects at most two (2) arguments:
+ *
+ * (1) the absolute or relative path to the configuration file.
+ *
+ * (2) the maximum number of solutions to be returned.
+ *
+ * Note: If no arguments are provided, the default configuration
+ * file on location ./config.json is used.
+ *
*/
public static void main(String[] args) {
String path;
diff --git a/src/main/java/nl/uu/cs/ape/automaton/Block.java b/src/main/java/nl/uu/cs/ape/automaton/Block.java
index fbcf6719..5864f230 100644
--- a/src/main/java/nl/uu/cs/ape/automaton/Block.java
+++ b/src/main/java/nl/uu/cs/ape/automaton/Block.java
@@ -14,7 +14,7 @@ public class Block {
* States that comprise this block. Number of stater correspond to the max
* number of inputs or outputs.
*/
- private List typeStates;
+ private final List typeStates;
/**
* Order number of the block in the solution.
@@ -27,7 +27,7 @@ public class Block {
* @param blockNumber The block number.
*/
public Block(int blockNumber) {
- typeStates = new ArrayList();
+ typeStates = new ArrayList<>();
this.blockNumber = blockNumber;
}
diff --git a/src/main/java/nl/uu/cs/ape/automaton/ModuleAutomaton.java b/src/main/java/nl/uu/cs/ape/automaton/ModuleAutomaton.java
index e5ab3b47..21ffe1e1 100644
--- a/src/main/java/nl/uu/cs/ape/automaton/ModuleAutomaton.java
+++ b/src/main/java/nl/uu/cs/ape/automaton/ModuleAutomaton.java
@@ -19,7 +19,7 @@
*/
public class ModuleAutomaton implements Automaton {
- private List moduleStates;
+ private final List moduleStates = new ArrayList<>();
/**
* Generate the Module State automatons based on the defined length.
@@ -31,7 +31,6 @@ public class ModuleAutomaton implements Automaton {
* modules).
*/
public ModuleAutomaton(int automataBound, int inputBranching, int outputBranching) {
- moduleStates = new ArrayList();
automataBound = Math.max(automataBound, 1);
for (int i = 1; i <= automataBound; i++) {
diff --git a/src/main/java/nl/uu/cs/ape/automaton/State.java b/src/main/java/nl/uu/cs/ape/automaton/State.java
index fc048acb..3eda2229 100644
--- a/src/main/java/nl/uu/cs/ape/automaton/State.java
+++ b/src/main/java/nl/uu/cs/ape/automaton/State.java
@@ -1,7 +1,7 @@
package nl.uu.cs.ape.automaton;
import nl.uu.cs.ape.models.enums.AtomType;
-import nl.uu.cs.ape.models.logic.constructs.PredicateLabel;
+import nl.uu.cs.ape.models.logic.constructs.Predicate;
/***
* The {@code State} class is used to represent the states in module and type
@@ -15,7 +15,7 @@
*
* @author Vedran Kasalica
*/
-public class State implements PredicateLabel, StateInterface {
+public class State implements Predicate, StateInterface {
/** Unique name of the state */
private final String stateName;
@@ -98,7 +98,7 @@ public boolean equals(Object obj) {
* before than, equal to, or after than the specified State.
*/
@Override
- public int compareTo(PredicateLabel other) {
+ public int compareTo(Predicate other) {
if (!(other instanceof State)) {
return this.getPredicateID().compareTo(other.getPredicateID());
}
diff --git a/src/main/java/nl/uu/cs/ape/automaton/TypeAutomaton.java b/src/main/java/nl/uu/cs/ape/automaton/TypeAutomaton.java
index 68fe0806..2037cac1 100644
--- a/src/main/java/nl/uu/cs/ape/automaton/TypeAutomaton.java
+++ b/src/main/java/nl/uu/cs/ape/automaton/TypeAutomaton.java
@@ -27,13 +27,13 @@ public class TypeAutomaton implements Automaton {
* Blocks of data types that are being added to the memory (usually outputs from
* the tools, apart from the initial workflow input).
*/
- private List memoryTypesAutomaton;
+ private final List memoryTypesAutomaton = new ArrayList<>();
/**
* Blocks of data types that are being used by tools from the memory (inputs to
* the tools).
*/
- private List usedTypesAutomaton;
+ private final List usedTypesAutomaton = new ArrayList<>();
/**
* State is used in order to represent no state.
@@ -54,8 +54,6 @@ public class TypeAutomaton implements Automaton {
* modules)
*/
public TypeAutomaton(int automataBound, int inputBranching, int outputBranching) {
- memoryTypesAutomaton = new ArrayList();
- usedTypesAutomaton = new ArrayList();
nullState = new State(null, null, -1, inputBranching, outputBranching);
automataBound = automataBound < 1 ? 1 : automataBound;
@@ -224,7 +222,7 @@ public Block getMemoryTypesBlock(int i) {
* @return List of memory States.
*/
public List getMemoryStatesUntilBlockNo(int maxBlockNo) {
- List untilStates = new ArrayList();
+ List untilStates = new ArrayList<>();
for (int i = 0; i <= maxBlockNo && i < this.usedTypesAutomaton.size(); i++) {
Block currBlock = this.getMemoryTypesBlock(i);
for (State currState : currBlock.getStates()) {
@@ -244,7 +242,7 @@ public List getMemoryStatesUntilBlockNo(int maxBlockNo) {
* @return List of Type States.
*/
public List getAllStatesUntilBlockNo(int maxBlockNo) {
- List untilStates = new ArrayList();
+ List untilStates = new ArrayList<>();
for (int i = 0; i <= maxBlockNo && i < this.usedTypesAutomaton.size(); i++) {
Block currBlock = this.usedTypesAutomaton.get(i);
for (State currState : currBlock.getStates()) {
@@ -268,7 +266,7 @@ public List getAllStatesUntilBlockNo(int maxBlockNo) {
* @return List of Memory Type States.
*/
public List getAllMemoryStatesUntilBlockNo(int maxBlockNo) {
- List untilStates = new ArrayList();
+ List untilStates = new ArrayList<>();
for (int i = 0; i <= maxBlockNo && i < this.usedTypesAutomaton.size(); i++) {
Block currBlock = this.memoryTypesAutomaton.get(i);
for (State currState : currBlock.getStates()) {
@@ -287,7 +285,7 @@ public List getAllMemoryStatesUntilBlockNo(int maxBlockNo) {
* @return List of memory States.
*/
public List getMemoryStatesAfterBlockNo(int minBlockNo) {
- List afterStates = new ArrayList();
+ List afterStates = new ArrayList<>();
for (int i = minBlockNo + 1; i < this.memoryTypesAutomaton.size(); i++) {
Block currBlock = this.getMemoryTypesBlock(i);
for (State currState : currBlock.getStates()) {
@@ -307,7 +305,7 @@ public List getMemoryStatesAfterBlockNo(int minBlockNo) {
* @return List of Used States.
*/
public List getUsedStatesAfterBlockNo(int minBlockNo) {
- List afterStates = new ArrayList();
+ List afterStates = new ArrayList<>();
for (int i = minBlockNo + 1; i < this.usedTypesAutomaton.size(); i++) {
Block currBlock = this.usedTypesAutomaton.get(i);
for (State currState : currBlock.getStates()) {
@@ -324,7 +322,7 @@ public List getUsedStatesAfterBlockNo(int minBlockNo) {
*/
@Override
public List getAllStates() {
- List allStates = new ArrayList();
+ List allStates = new ArrayList<>();
for (Block currBlock : getAllBlocks()) {
for (State currState : currBlock.getStates()) {
allStates.add(currState);
@@ -339,7 +337,7 @@ public List getAllStates() {
* @return List of memory type states.
*/
public List getAllMemoryTypesStates() {
- List allMemoryStates = new ArrayList();
+ List allMemoryStates = new ArrayList<>();
for (Block currBlock : getMemoryTypesBlocks()) {
for (State currState : currBlock.getStates()) {
allMemoryStates.add(currState);
@@ -354,7 +352,7 @@ public List getAllMemoryTypesStates() {
* @return List of used type states.
*/
public List getAllUsedTypesStates() {
- List allUsedStates = new ArrayList();
+ List allUsedStates = new ArrayList<>();
for (Block currBlock : getUsedTypesBlocks()) {
for (State currState : currBlock.getStates()) {
allUsedStates.add(currState);
diff --git a/src/main/java/nl/uu/cs/ape/configuration/APECoreConfig.java b/src/main/java/nl/uu/cs/ape/configuration/APECoreConfig.java
index 14357fb4..1d490c04 100644
--- a/src/main/java/nl/uu/cs/ape/configuration/APECoreConfig.java
+++ b/src/main/java/nl/uu/cs/ape/configuration/APECoreConfig.java
@@ -11,10 +11,10 @@
import nl.uu.cs.ape.configuration.tags.APEConfigTags;
import nl.uu.cs.ape.configuration.tags.APEConfigTagFactory.TAGS.*;
import nl.uu.cs.ape.configuration.tags.validation.ValidationResults;
-import nl.uu.cs.ape.domain.APEDimensionsException;
+import nl.uu.cs.ape.solver.domainconfiguration.APEDimensionsException;
import nl.uu.cs.ape.utils.APEFiles;
import nl.uu.cs.ape.utils.APEUtils;
-import nl.uu.cs.ape.domain.OWLReader;
+import nl.uu.cs.ape.utils.OWLReader;
import java.io.File;
import java.io.IOException;
diff --git a/src/main/java/nl/uu/cs/ape/configuration/APERunConfig.java b/src/main/java/nl/uu/cs/ape/configuration/APERunConfig.java
index bfc2cd5a..ba1e1bba 100644
--- a/src/main/java/nl/uu/cs/ape/configuration/APERunConfig.java
+++ b/src/main/java/nl/uu/cs/ape/configuration/APERunConfig.java
@@ -11,11 +11,11 @@
import nl.uu.cs.ape.configuration.tags.APEConfigTags;
import nl.uu.cs.ape.configuration.tags.APEConfigTagFactory.TAGS.*;
import nl.uu.cs.ape.configuration.tags.validation.ValidationResults;
-import nl.uu.cs.ape.domain.APEDomainSetup;
import nl.uu.cs.ape.models.Range;
import nl.uu.cs.ape.models.Type;
import nl.uu.cs.ape.models.enums.ConfigEnum;
import nl.uu.cs.ape.models.enums.SolverType;
+import nl.uu.cs.ape.solver.domainconfiguration.Domain;
import java.io.IOException;
import java.nio.file.Path;
@@ -99,12 +99,12 @@ public class APERunConfig {
/**
* Input types of the workflow.
*/
- private final APEConfigDependentTag.One, APEDomainSetup> PROGRAM_INPUTS = new APEConfigTagFactory.TAGS.PROGRAM_INPUTS(
+ private final APEConfigDependentTag.One, Domain> PROGRAM_INPUTS = new APEConfigTagFactory.TAGS.PROGRAM_INPUTS(
this::getApeDomainSetup);
/**
* Output types of the workflow.
*/
- private final APEConfigDependentTag.One, APEDomainSetup> PROGRAM_OUTPUTS = new APEConfigTagFactory.TAGS.PROGRAM_OUTPUTS(
+ private final APEConfigDependentTag.One, Domain> PROGRAM_OUTPUTS = new APEConfigTagFactory.TAGS.PROGRAM_OUTPUTS(
this::getApeDomainSetup);
/**
* All the Tags specified in this class. Should be in correct order of
@@ -153,10 +153,7 @@ public class APERunConfig {
* Object containing domain information needed for the execution.
*/
@Getter
- private APEDomainSetup apeDomainSetup;
-
- /** Solver type that should be used (SAT). */
- private SolverType solverType = SolverType.SAT;
+ private Domain apeDomainSetup;
/**
* Constructor used to implement the Builder Pattern.
@@ -189,10 +186,10 @@ private APERunConfig(Builder builder) {
/**
* Private constructor used by
- * {@link APERunConfig#validate(JSONObject config, APEDomainSetup setup)}
+ * {@link APERunConfig#validate(JSONObject config, Domain setup)}
* to create an empty instance.
*/
- private APERunConfig(APEDomainSetup setup) {
+ private APERunConfig(Domain setup) {
this.apeDomainSetup = setup;
}
@@ -206,7 +203,7 @@ private APERunConfig(APEDomainSetup setup) {
* @param setup the domain setup
* @return the validation results
*/
- public static ValidationResults validate(JSONObject json, APEDomainSetup setup) {
+ public static ValidationResults validate(JSONObject json, Domain setup) {
APERunConfig dummy = new APERunConfig(setup);
ValidationResults results = new ValidationResults();
for (APEConfigTag> tag : dummy.all_tags) {
@@ -229,7 +226,7 @@ public static ValidationResults validate(JSONObject json, APEDomainSetup setup)
* @throws JSONException Error in parsing the configuration file.
* @throws APEConfigException Error in setting up the the configuration.
*/
- public APERunConfig(JSONObject runConfiguration, APEDomainSetup apeDomainSetup)
+ public APERunConfig(JSONObject runConfiguration, Domain apeDomainSetup)
throws IOException, JSONException, APEConfigException {
/* JSONObject must have been parsed correctly. */
@@ -577,22 +574,6 @@ public void setSolutionLength(int solutionMinLength, int solutionMaxLength) {
this.SOLUTION_LENGTH_RANGE.setValue(Range.of(solutionMinLength, solutionMaxLength));
}
- /**
- * Gets the Solver type that should be used for solving.
- *
- * @return {@link SolverType} that corresponds to the solver type
- */
- public SolverType getSolverType() {
- return this.solverType;
- }
-
- /**
- * @param solverType the solverType to set
- */
- public void setSolverType(SolverType solverType) {
- this.solverType = solverType;
- }
-
/**
* Creates interface for the min length of {@link APERunConfig}.
*/
@@ -624,7 +605,7 @@ public interface IMaxNoSolutionsStage {
* Creates interface to setup the domain of {@link APERunConfig}.
*/
public interface IApeDomainSetupStage {
- IBuildStage withApeDomainSetup(APEDomainSetup apeDomainSetup);
+ IBuildStage withApeDomainSetup(Domain apeDomainSetup);
}
/**
@@ -671,7 +652,7 @@ public static final class Builder implements ISolutionMinLengthStage, ISolutionM
private int solutionMinLength;
private int solutionMaxLength;
private int maxNoSolutions;
- private APEDomainSetup apeDomainSetup;
+ private Domain apeDomainSetup;
private JSONArray constraintsJSON;
private boolean toolSeqRepeat;
private String solutionDirPath;
@@ -708,7 +689,7 @@ public IApeDomainSetupStage withMaxNoSolutions(int maxNoSolutions) {
}
@Override
- public IBuildStage withApeDomainSetup(APEDomainSetup apeDomainSetup) {
+ public IBuildStage withApeDomainSetup(Domain apeDomainSetup) {
this.apeDomainSetup = apeDomainSetup;
return this;
}
diff --git a/src/main/java/nl/uu/cs/ape/configuration/tags/APEConfigTagFactory.java b/src/main/java/nl/uu/cs/ape/configuration/tags/APEConfigTagFactory.java
index 02f49c4a..3f9c6b8d 100644
--- a/src/main/java/nl/uu/cs/ape/configuration/tags/APEConfigTagFactory.java
+++ b/src/main/java/nl/uu/cs/ape/configuration/tags/APEConfigTagFactory.java
@@ -6,17 +6,15 @@
import nl.uu.cs.ape.configuration.APEConfigException;
import nl.uu.cs.ape.configuration.tags.validation.ValidationResults;
-import nl.uu.cs.ape.domain.APEDomainSetup;
import nl.uu.cs.ape.utils.APEFiles;
import nl.uu.cs.ape.utils.APEUtils;
import nl.uu.cs.ape.models.Range;
import nl.uu.cs.ape.models.Type;
import nl.uu.cs.ape.models.enums.ConfigEnum;
+import nl.uu.cs.ape.solver.domainconfiguration.Domain;
import javax.inject.Provider;
-import static nl.uu.cs.ape.configuration.tags.APEConfigTag.TagType.*;
-
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
@@ -119,9 +117,9 @@ public TagType getType() {
/**
* Abstract field type.
*/
- public abstract static class DataInstances extends APEConfigDependentTag.One, APEDomainSetup> {
+ public abstract static class DataInstances extends APEConfigDependentTag.One, Domain> {
- protected DataInstances(Provider provider) {
+ protected DataInstances(Provider provider) {
super(provider);
}
@@ -131,7 +129,7 @@ public TagType getType() {
}
@Override
- protected ValidationResults validate(List value, APEDomainSetup apeDomainSetup,
+ protected ValidationResults validate(List value, Domain apeDomainSetup,
ValidationResults results) {
// TODO: check data instances
return results;
@@ -485,7 +483,7 @@ public APEConfigDefaultValue> getDefault() {
*/
public static class PROGRAM_INPUTS extends TYPES.DataInstances {
- public PROGRAM_INPUTS(Provider provider) {
+ public PROGRAM_INPUTS(Provider provider) {
super(provider);
}
@@ -505,7 +503,7 @@ public String getDescription() {
}
@Override
- protected List constructFromJSON(JSONObject obj, APEDomainSetup apeDomainSetup) {
+ protected List constructFromJSON(JSONObject obj, Domain apeDomainSetup) {
final ArrayList instances = new ArrayList<>();
if (apeDomainSetup == null) {
@@ -535,7 +533,7 @@ protected List constructFromJSON(JSONObject obj, APEDomainSetup apeDomainS
*/
public static class PROGRAM_OUTPUTS extends TYPES.DataInstances {
- public PROGRAM_OUTPUTS(Provider provider) {
+ public PROGRAM_OUTPUTS(Provider provider) {
super(provider);
}
@@ -555,7 +553,7 @@ public String getDescription() {
}
@Override
- protected List constructFromJSON(JSONObject obj, APEDomainSetup apeDomainSetup) {
+ protected List constructFromJSON(JSONObject obj, Domain apeDomainSetup) {
final ArrayList instances = new ArrayList<>();
if (apeDomainSetup == null) {
diff --git a/src/main/java/nl/uu/cs/ape/constraints/ConstraintFactory.java b/src/main/java/nl/uu/cs/ape/constraints/ConstraintFactory.java
index c54391a4..ef5952a0 100644
--- a/src/main/java/nl/uu/cs/ape/constraints/ConstraintFactory.java
+++ b/src/main/java/nl/uu/cs/ape/constraints/ConstraintFactory.java
@@ -2,12 +2,12 @@
import java.util.*;
+import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import nl.uu.cs.ape.automaton.ModuleAutomaton;
import nl.uu.cs.ape.automaton.TypeAutomaton;
-import nl.uu.cs.ape.domain.APEDomainSetup;
-import nl.uu.cs.ape.models.AllModules;
-import nl.uu.cs.ape.models.AllTypes;
+import nl.uu.cs.ape.models.DomainModules;
+import nl.uu.cs.ape.models.DomainTypes;
import nl.uu.cs.ape.models.ConstraintTemplateData;
import nl.uu.cs.ape.models.SATAtomMappings;
import nl.uu.cs.ape.models.enums.AtomType;
@@ -15,6 +15,7 @@
import nl.uu.cs.ape.models.templateFormulas.SLTLxTemplateFormula;
import nl.uu.cs.ape.models.templateFormulas.SLTLxTemplateFinally;
import nl.uu.cs.ape.models.templateFormulas.SLTLxTemplateGlobally;
+import nl.uu.cs.ape.solver.domainconfiguration.Domain;
/**
* The {@code ConstraintFactory} class represents the Factory Method Pattern for
@@ -24,16 +25,10 @@
* @author Vedran Kasalica
*/
@Slf4j
+@NoArgsConstructor
public class ConstraintFactory {
- private Map constraintTemplates;
-
- /**
- * Instantiates a new Constraint factory.
- */
- public ConstraintFactory() {
- this.constraintTemplates = new HashMap<>();
- }
+ private final Map constraintTemplates = new HashMap<>();
/**
* Retrieves a list of the constraint templates.
@@ -95,7 +90,7 @@ public String printConstraintsCodes() {
* @return String description of all the formats (ID, description and number of
* parameters for each).
*/
- public boolean initializeConstraints(AllModules allModules, AllTypes allTypes) {
+ public boolean initializeConstraints(DomainModules allModules, DomainTypes allTypes) {
TaxonomyPredicate rootModule = allModules.getRootModule();
List rootTypes = allTypes.getDataTaxonomyDimensions();
@@ -331,7 +326,7 @@ protected ConstraintDependModule(String id, List pa
}
@Override
- public String getConstraint(List parameters, APEDomainSetup domainSetup,
+ public String getConstraint(List parameters, Domain domainSetup,
ModuleAutomaton moduleAutomaton, TypeAutomaton typeAutomaton, SATAtomMappings mappings) {
if (parameters.size() != this.getNoOfParameters()) {
super.throwParametersError(parameters.size());
@@ -359,7 +354,7 @@ protected ConstraintGenType(String id, List paramet
}
@Override
- public String getConstraint(List parameters, APEDomainSetup domainSetup,
+ public String getConstraint(List parameters, Domain domainSetup,
ModuleAutomaton moduleAutomaton, TypeAutomaton typeAutomaton, SATAtomMappings mappings) {
if (parameters.size() != this.getNoOfParameters()) {
super.throwParametersError(parameters.size());
@@ -392,7 +387,7 @@ protected ConstraintIf_genThenNotType(String id, List parameters, APEDomainSetup domainSetup,
+ public String getConstraint(List parameters, Domain domainSetup,
ModuleAutomaton moduleAutomaton, TypeAutomaton typeAutomaton, SATAtomMappings mappings) {
if (parameters.size() != this.getNoOfParameters()) {
super.throwParametersError(parameters.size());
@@ -422,7 +417,7 @@ protected ConstraintIf_genThenType(String id, List
}
@Override
- public String getConstraint(List parameters, APEDomainSetup domainSetup,
+ public String getConstraint(List parameters, Domain domainSetup,
ModuleAutomaton moduleAutomaton, TypeAutomaton typeAutomaton, SATAtomMappings mappings) {
if (parameters.size() != this.getNoOfParameters()) {
super.throwParametersError(parameters.size());
@@ -452,7 +447,7 @@ protected ConstraintIfThenModule(String id, List pa
}
@Override
- public String getConstraint(List parameters, APEDomainSetup domainSetup,
+ public String getConstraint(List parameters, Domain domainSetup,
ModuleAutomaton moduleAutomaton, TypeAutomaton typeAutomaton, SATAtomMappings mappings) {
if (parameters.size() != this.getNoOfParameters()) {
super.throwParametersError(parameters.size());
@@ -481,7 +476,7 @@ protected ConstraintIfThenNotModule(String id, List
}
@Override
- public String getConstraint(List parameters, APEDomainSetup domainSetup,
+ public String getConstraint(List parameters, Domain domainSetup,
ModuleAutomaton moduleAutomaton, TypeAutomaton typeAutomaton, SATAtomMappings mappings) {
if (parameters.size() != this.getNoOfParameters()) {
super.throwParametersError(parameters.size());
@@ -510,7 +505,7 @@ protected ConstraintIfUseThenNotType(String id, List parameters, APEDomainSetup domainSetup,
+ public String getConstraint(List parameters, Domain domainSetup,
ModuleAutomaton moduleAutomaton, TypeAutomaton typeAutomaton, SATAtomMappings mappings) {
if (parameters.size() != this.getNoOfParameters()) {
super.throwParametersError(parameters.size());
@@ -540,7 +535,7 @@ protected ConstraintIfUseThenType(String id, List p
}
@Override
- public String getConstraint(List parameters, APEDomainSetup domainSetup,
+ public String getConstraint(List parameters, Domain domainSetup,
ModuleAutomaton moduleAutomaton, TypeAutomaton typeAutomaton, SATAtomMappings mappings) {
if (parameters.size() != this.getNoOfParameters()) {
super.throwParametersError(parameters.size());
@@ -570,7 +565,7 @@ protected Constraint_lastModule(String id, List par
}
@Override
- public String getConstraint(List parameters, APEDomainSetup domainSetup,
+ public String getConstraint(List parameters, Domain domainSetup,
ModuleAutomaton moduleAutomaton, TypeAutomaton typeAutomaton, SATAtomMappings mappings) {
if (parameters.size() != this.getNoOfParameters()) {
super.throwParametersError(parameters.size());
@@ -599,7 +594,7 @@ protected Constraint_nextModule(String id, List par
}
@Override
- public String getConstraint(List parameters, APEDomainSetup domainSetup,
+ public String getConstraint(List parameters, Domain domainSetup,
ModuleAutomaton moduleAutomaton, TypeAutomaton typeAutomaton, SATAtomMappings mappings) {
if (parameters.size() != this.getNoOfParameters()) {
super.throwParametersError(parameters.size());
@@ -628,7 +623,7 @@ protected ConstraintNotGenType(String id, List para
}
@Override
- public String getConstraint(List parameters, APEDomainSetup domainSetup,
+ public String getConstraint(List parameters, Domain domainSetup,
ModuleAutomaton moduleAutomaton, TypeAutomaton typeAutomaton, SATAtomMappings mappings) {
if (parameters.size() != this.getNoOfParameters()) {
super.throwParametersError(parameters.size());
@@ -660,7 +655,7 @@ protected ConstraintNotUseModule(String id, List pa
}
@Override
- public String getConstraint(List parameters, APEDomainSetup domainSetup,
+ public String getConstraint(List parameters, Domain domainSetup,
ModuleAutomaton moduleAutomaton, TypeAutomaton typeAutomaton, SATAtomMappings mappings) {
if (parameters.size() != this.getNoOfParameters()) {
super.throwParametersError(parameters.size());
@@ -691,7 +686,7 @@ protected ConstraintNotUseType(String id, List para
}
@Override
- public String getConstraint(List parameters, APEDomainSetup domainSetup,
+ public String getConstraint(List parameters, Domain domainSetup,
ModuleAutomaton moduleAutomaton, TypeAutomaton typeAutomaton, SATAtomMappings mappings) {
if (parameters.size() != this.getNoOfParameters()) {
super.throwParametersError(parameters.size());
@@ -723,7 +718,7 @@ protected Constraint_prevModule(String id, List par
}
@Override
- public String getConstraint(List parameters, APEDomainSetup domainSetup,
+ public String getConstraint(List parameters, Domain domainSetup,
ModuleAutomaton moduleAutomaton, TypeAutomaton typeAutomaton, SATAtomMappings mappings) {
if (parameters.size() != this.getNoOfParameters()) {
super.throwParametersError(parameters.size());
@@ -751,7 +746,7 @@ protected ConstraintUseModule(String id, List param
}
@Override
- public String getConstraint(List parameters, APEDomainSetup domainSetup,
+ public String getConstraint(List parameters, Domain domainSetup,
ModuleAutomaton moduleAutomaton, TypeAutomaton typeAutomaton, SATAtomMappings mappings) {
if (parameters.size() != this.getNoOfParameters()) {
super.throwParametersError(parameters.size());
@@ -781,7 +776,7 @@ protected ConstraintUseType(String id, List paramet
}
@Override
- public String getConstraint(List parameters, APEDomainSetup domainSetup,
+ public String getConstraint(List parameters, Domain domainSetup,
ModuleAutomaton moduleAutomaton, TypeAutomaton typeAutomaton, SATAtomMappings mappings) {
if (parameters.size() != this.getNoOfParameters()) {
super.throwParametersError(parameters.size());
@@ -812,7 +807,7 @@ protected ConstraintUseModuleWithInput(String id, List parameters, APEDomainSetup domainSetup,
+ public String getConstraint(List parameters, Domain domainSetup,
ModuleAutomaton moduleAutomaton, TypeAutomaton typeAutomaton, SATAtomMappings mappings) {
if (parameters.size() != this.getNoOfParameters()) {
super.throwParametersError(parameters.size());
@@ -843,7 +838,7 @@ protected ConstraintUseModuleWithOutput(String id, List parameters, APEDomainSetup domainSetup,
+ public String getConstraint(List parameters, Domain domainSetup,
ModuleAutomaton moduleAutomaton, TypeAutomaton typeAutomaton, SATAtomMappings mappings) {
if (parameters.size() != this.getNoOfParameters()) {
super.throwParametersError(parameters.size());
@@ -874,7 +869,7 @@ protected Constraint_connectedModules(String id, List parameters, APEDomainSetup domainSetup,
+ public String getConstraint(List parameters, Domain domainSetup,
ModuleAutomaton moduleAutomaton, TypeAutomaton typeAutomaton, SATAtomMappings mappings) {
if (parameters.size() != this.getNoOfParameters()) {
super.throwParametersError(parameters.size());
@@ -904,7 +899,7 @@ protected ConstraintNot_connectedModules(String id, List parameters, APEDomainSetup domainSetup,
+ public String getConstraint(List parameters, Domain domainSetup,
ModuleAutomaton moduleAutomaton, TypeAutomaton typeAutomaton, SATAtomMappings mappings) {
if (parameters.size() != this.getNoOfParameters()) {
super.throwParametersError(parameters.size());
@@ -934,7 +929,7 @@ protected ConstraintNot_repeatModules(String id, List parameters, APEDomainSetup domainSetup,
+ public String getConstraint(List parameters, Domain domainSetup,
ModuleAutomaton moduleAutomaton, TypeAutomaton typeAutomaton, SATAtomMappings mappings) {
if (parameters.size() != this.getNoOfParameters()) {
super.throwParametersError(parameters.size());
diff --git a/src/main/java/nl/uu/cs/ape/constraints/ConstraintTemplate.java b/src/main/java/nl/uu/cs/ape/constraints/ConstraintTemplate.java
index 4e963603..d04a0c18 100644
--- a/src/main/java/nl/uu/cs/ape/constraints/ConstraintTemplate.java
+++ b/src/main/java/nl/uu/cs/ape/constraints/ConstraintTemplate.java
@@ -6,9 +6,9 @@
import lombok.extern.slf4j.Slf4j;
import nl.uu.cs.ape.automaton.ModuleAutomaton;
import nl.uu.cs.ape.automaton.TypeAutomaton;
-import nl.uu.cs.ape.domain.APEDomainSetup;
import nl.uu.cs.ape.models.SATAtomMappings;
import nl.uu.cs.ape.models.logic.constructs.TaxonomyPredicate;
+import nl.uu.cs.ape.solver.domainconfiguration.Domain;
import java.util.List;
@@ -118,7 +118,7 @@ public ConstraintTemplateParameter getParameter(int index) {
* @return The String CNF representation of the constraint. null in case of
* incorrect number of constraint parameters.
*/
- public abstract String getConstraint(List list, APEDomainSetup domainSetup,
+ public abstract String getConstraint(List list, Domain domainSetup,
ModuleAutomaton moduleAutomaton,
TypeAutomaton typeAutomaton, SATAtomMappings mappings);
diff --git a/src/main/java/nl/uu/cs/ape/constraints/ConstraintTemplateParameter.java b/src/main/java/nl/uu/cs/ape/constraints/ConstraintTemplateParameter.java
index 604d039d..733d821d 100644
--- a/src/main/java/nl/uu/cs/ape/constraints/ConstraintTemplateParameter.java
+++ b/src/main/java/nl/uu/cs/ape/constraints/ConstraintTemplateParameter.java
@@ -7,18 +7,17 @@
import org.json.JSONObject;
import lombok.extern.slf4j.Slf4j;
-import nl.uu.cs.ape.domain.APEDimensionsException;
-import nl.uu.cs.ape.domain.APEDomainSetup;
import nl.uu.cs.ape.utils.APEUtils;
import nl.uu.cs.ape.models.AbstractModule;
import nl.uu.cs.ape.models.Module;
import nl.uu.cs.ape.models.Type;
import nl.uu.cs.ape.models.logic.constructs.TaxonomyPredicate;
+import nl.uu.cs.ape.solver.domainconfiguration.APEDimensionsException;
+import nl.uu.cs.ape.solver.domainconfiguration.Domain;
/**
* The {@code ConstraintTemplateParameter} class is used to represent a
- * parameter of a
- * constraint.
+ * parameter of a constraint.
*
* @author Vedran Kasalica
*/
@@ -40,7 +39,7 @@ public ConstraintTemplateParameter(List parameterTypes) {
if (parameterTypes != null) {
this.parameterTypes = parameterTypes;
} else {
- this.parameterTypes = new ArrayList();
+ this.parameterTypes = new ArrayList<>();
}
}
@@ -48,7 +47,7 @@ public ConstraintTemplateParameter(List parameterTypes) {
* Instantiates a new Constraint parameter.
*/
public ConstraintTemplateParameter() {
- this.parameterTypes = new ArrayList();
+ this.parameterTypes = new ArrayList<>();
}
/**
@@ -108,7 +107,7 @@ public JSONObject toJSON() {
* @throws APEDimensionsException if the referenced types/modules are not well
* defined
*/
- public TaxonomyPredicate readConstraintParameterFromJson(JSONObject jsonParam, APEDomainSetup domainSetup)
+ public TaxonomyPredicate readConstraintParameterFromJson(JSONObject jsonParam, Domain domainSetup)
throws JSONException, APEDimensionsException {
if (parameterTypes.get(0) instanceof Type) {
return Type.taxonomyInstanceFromJson(jsonParam, domainSetup, false);
diff --git a/src/main/java/nl/uu/cs/ape/models/AuxModulePredicate.java b/src/main/java/nl/uu/cs/ape/models/AuxModulePredicate.java
index 29d404a0..d0f0a7c0 100644
--- a/src/main/java/nl/uu/cs/ape/models/AuxModulePredicate.java
+++ b/src/main/java/nl/uu/cs/ape/models/AuxModulePredicate.java
@@ -4,11 +4,11 @@
import java.util.SortedSet;
import java.util.TreeSet;
-import nl.uu.cs.ape.domain.APEDomainSetup;
import nl.uu.cs.ape.utils.APEUtils;
import nl.uu.cs.ape.models.enums.LogicOperation;
import nl.uu.cs.ape.models.enums.NodeType;
import nl.uu.cs.ape.models.logic.constructs.TaxonomyPredicate;
+import nl.uu.cs.ape.solver.domainconfiguration.Domain;
/**
* The {@code AuxModulePredicate} class represents an abstract class used
@@ -74,7 +74,7 @@ private AuxModulePredicate(String moduleName, String moduleID, String rootNode,
* disjunction/conjunction of the labels.
*/
public static AbstractModule generateAuxiliaryPredicate(SortedSet relatedPredicates,
- LogicOperation logicOp, APEDomainSetup domainSetup) {
+ LogicOperation logicOp, Domain domainSetup) {
if (relatedPredicates.isEmpty()) {
return null;
}
diff --git a/src/main/java/nl/uu/cs/ape/models/AuxTypePredicate.java b/src/main/java/nl/uu/cs/ape/models/AuxTypePredicate.java
index ee2758a5..dabbc775 100644
--- a/src/main/java/nl/uu/cs/ape/models/AuxTypePredicate.java
+++ b/src/main/java/nl/uu/cs/ape/models/AuxTypePredicate.java
@@ -4,11 +4,11 @@
import java.util.SortedSet;
import java.util.TreeSet;
-import nl.uu.cs.ape.domain.APEDomainSetup;
import nl.uu.cs.ape.utils.APEUtils;
import nl.uu.cs.ape.models.enums.LogicOperation;
import nl.uu.cs.ape.models.enums.NodeType;
import nl.uu.cs.ape.models.logic.constructs.TaxonomyPredicate;
+import nl.uu.cs.ape.solver.domainconfiguration.Domain;
/**
* The {@code AuxTypePredicate} class represents an abstract class used
@@ -67,7 +67,7 @@ private AuxTypePredicate(String typeName, String typeID, String rootNode, NodeTy
* disjunction/conjunction of the labels.
*/
public static Type generateAuxiliaryPredicate(SortedSet relatedPredicates,
- LogicOperation logicOp, APEDomainSetup domainSetup) {
+ LogicOperation logicOp, Domain domainSetup) {
if (relatedPredicates.isEmpty()) {
return null;
}
diff --git a/src/main/java/nl/uu/cs/ape/models/AuxiliaryPredicate.java b/src/main/java/nl/uu/cs/ape/models/AuxiliaryPredicate.java
index 60f29179..6edb8e39 100644
--- a/src/main/java/nl/uu/cs/ape/models/AuxiliaryPredicate.java
+++ b/src/main/java/nl/uu/cs/ape/models/AuxiliaryPredicate.java
@@ -3,7 +3,7 @@
import java.util.SortedSet;
import nl.uu.cs.ape.models.enums.LogicOperation;
-import nl.uu.cs.ape.models.logic.constructs.PredicateLabel;
+import nl.uu.cs.ape.models.logic.constructs.Predicate;
import nl.uu.cs.ape.models.logic.constructs.TaxonomyPredicate;
/**
@@ -13,7 +13,7 @@
* @author Vedran Kasalica
*
*/
-public interface AuxiliaryPredicate extends PredicateLabel {
+public interface AuxiliaryPredicate extends Predicate {
/**
* Gets logic operator used to group the abstracted predicates.
diff --git a/src/main/java/nl/uu/cs/ape/models/AllModules.java b/src/main/java/nl/uu/cs/ape/models/DomainModules.java
similarity index 89%
rename from src/main/java/nl/uu/cs/ape/models/AllModules.java
rename to src/main/java/nl/uu/cs/ape/models/DomainModules.java
index 46fb1741..15a8dd2f 100644
--- a/src/main/java/nl/uu/cs/ape/models/AllModules.java
+++ b/src/main/java/nl/uu/cs/ape/models/DomainModules.java
@@ -7,25 +7,25 @@
import nl.uu.cs.ape.configuration.APECoreConfig;
import nl.uu.cs.ape.utils.APEUtils;
-import nl.uu.cs.ape.models.logic.constructs.PredicateLabel;
+import nl.uu.cs.ape.models.logic.constructs.Predicate;
import nl.uu.cs.ape.models.logic.constructs.TaxonomyPredicate;
/**
- * The {@code AllModules} class represent the set of all modules/tools that can
- * be
- * part of our program. Each of them is either {@link Module} or
+ * The {@code DomainModules} class represent the set of all modules/tools that
+ * are part of the configured domain. They can
+ * be steps in generated workflows. Each of them is either {@link Module} or
* {@link AbstractModule}.
*
* @author Vedran Kasalica
*/
-public class AllModules extends AllPredicates {
+public class DomainModules extends DomainPredicates {
/**
* Instantiates a new All modules.
*
* @param config the config
*/
- public AllModules(APECoreConfig config) {
+ public DomainModules(APECoreConfig config) {
super(Arrays.asList(config.getToolTaxonomyRoot()));
}
@@ -34,7 +34,7 @@ public AllModules(APECoreConfig config) {
*
* @param moduleTaxonomyRoot root module
*/
- public AllModules(String moduleTaxonomyRoot) {
+ public DomainModules(String moduleTaxonomyRoot) {
super(Arrays.asList(moduleTaxonomyRoot));
}
@@ -125,9 +125,9 @@ public AbstractModule get(String moduleID) {
*
* @return List of pairs of modules.
*/
- public Set> getSimplePairs() {
+ public Set> getSimplePairs() {
- Set iterator = new HashSet();
+ Set iterator = new HashSet();
for (TaxonomyPredicate module : getMappedPredicates().values()) {
if (module.isSimplePredicate()) {
iterator.add(module);
diff --git a/src/main/java/nl/uu/cs/ape/models/AllPredicates.java b/src/main/java/nl/uu/cs/ape/models/DomainPredicates.java
similarity index 94%
rename from src/main/java/nl/uu/cs/ape/models/AllPredicates.java
rename to src/main/java/nl/uu/cs/ape/models/DomainPredicates.java
index 0a00e6c6..d11c07d5 100644
--- a/src/main/java/nl/uu/cs/ape/models/AllPredicates.java
+++ b/src/main/java/nl/uu/cs/ape/models/DomainPredicates.java
@@ -6,17 +6,18 @@
import nl.uu.cs.ape.models.logic.constructs.TaxonomyPredicate;
/**
- * The {@code AllPredicates} class is used to group all mappedPredicates of the
- * same type (such as module, data) into one collection.
+ * The {@code DomainPredicates} abstract class represents a collection of
+ * predicates of the
+ * same type (e.g., module, data) within the configured domain.
*
* @author Vedran Kasalica
*/
-public abstract class AllPredicates {
+public abstract class DomainPredicates {
/**
* Map of all predicated mapped to their predicateID.
*/
- private Map mappedPredicates;
+ private final Map mappedPredicates = new HashMap<>();
/**
* Root of the taxonomy.
@@ -28,9 +29,8 @@ public abstract class AllPredicates {
*
* @param taxonomyRoots the taxonomy roots
*/
- protected AllPredicates(List taxonomyRoots) {
+ protected DomainPredicates(List taxonomyRoots) {
this.dimensionRoots = taxonomyRoots;
- this.mappedPredicates = new HashMap<>();
}
/**
diff --git a/src/main/java/nl/uu/cs/ape/models/AllTypes.java b/src/main/java/nl/uu/cs/ape/models/DomainTypes.java
similarity index 87%
rename from src/main/java/nl/uu/cs/ape/models/AllTypes.java
rename to src/main/java/nl/uu/cs/ape/models/DomainTypes.java
index 07ef4d71..623e909a 100644
--- a/src/main/java/nl/uu/cs/ape/models/AllTypes.java
+++ b/src/main/java/nl/uu/cs/ape/models/DomainTypes.java
@@ -6,53 +6,51 @@
import lombok.extern.slf4j.Slf4j;
import nl.uu.cs.ape.configuration.APECoreConfig;
-import nl.uu.cs.ape.domain.APEDimensionsException;
import nl.uu.cs.ape.utils.APEUtils;
import nl.uu.cs.ape.models.enums.NodeType;
-import nl.uu.cs.ape.models.logic.constructs.PredicateLabel;
+import nl.uu.cs.ape.models.logic.constructs.Predicate;
import nl.uu.cs.ape.models.logic.constructs.TaxonomyPredicate;
+import nl.uu.cs.ape.solver.domainconfiguration.APEDimensionsException;
/**
- * The {@code AllTypes} class represent the set of all the data dimensions that
- * can be used in our program. The data
- * can be grouped in multiple data dimensions (e.g. types,formats, etc.) and
+ * The {@code DomainTypes} class represent the collection of all the data types
+ * within the configured domain.
+ * The data types are grouped in one or more data dimensions (e.g.
+ * types,formats, etc.) and
* each {@link Type} will belong to one of those dimensions.
*
* @author Vedran Kasalica
*/
@Slf4j
-public class AllTypes extends AllPredicates {
+public class DomainTypes extends DomainPredicates {
- private static String empty = "empty";
- private static String apeLabel = "APE_label";
- private static String emptyLabel = "emptyLabel";
+ private static final String empty = "empty";
+ private static final String apeLabel = "APE_label";
+ private static final String emptyLabel = "emptyLabel";
/**
* {@link Type} object representing the "empty type".
*/
- private Type emptyType;
+ private final Type emptyType = new Type(empty, empty, empty, NodeType.EMPTY);
/**
* {@link Type} object representing the "empty label root".
*/
- private Type apeLabelRoot;
+ private final Type apeLabelRoot = new Type(apeLabel, apeLabel, apeLabel, NodeType.ROOT);
/**
* {@link Type} object representing the "empty label type".
*/
- private Type emptyLabelType;
+ private final Type emptyLabelType = new Type(emptyLabel, emptyLabel, apeLabel, NodeType.EMPTY_LABEL);
/**
* Instantiates a new AllTypes object.
*
* @param config the config
*/
- public AllTypes(APECoreConfig config) {
+ public DomainTypes(APECoreConfig config) {
super(Stream.concat(config.getDataDimensionRoots().stream(), Stream.of(apeLabel))
.collect(Collectors.toList()));
- emptyType = new Type(empty, empty, empty, NodeType.EMPTY);
- apeLabelRoot = new Type(apeLabel, apeLabel, apeLabel, NodeType.ROOT);
- emptyLabelType = new Type(emptyLabel, emptyLabel, apeLabel, NodeType.EMPTY_LABEL);
setRelevant(emptyType);
setRelevant(apeLabelRoot);
setRelevant(emptyLabelType);
@@ -65,12 +63,9 @@ public AllTypes(APECoreConfig config) {
*
* @param typeTaxonomyRoots the list of data dimension roots
*/
- public AllTypes(List typeTaxonomyRoots) {
+ public DomainTypes(List typeTaxonomyRoots) {
super(Stream.concat(typeTaxonomyRoots.stream(), Stream.of(apeLabel))
.collect(Collectors.toList()));
- emptyType = new Type(empty, empty, empty, NodeType.EMPTY);
- apeLabelRoot = new Type(apeLabel, apeLabel, apeLabel, NodeType.ROOT);
- emptyLabelType = new Type(emptyLabel, emptyLabel, apeLabel, NodeType.EMPTY_LABEL);
setRelevant(emptyType);
setRelevant(apeLabelRoot);
setRelevant(emptyLabelType);
@@ -233,8 +228,8 @@ public Class> getPredicateClass() {
*
* @return List of pairs of types.
*/
- public List> getTypePairsForEachSubTaxonomy() {
- List> pairs = new ArrayList>();
+ public List> getTypePairsForEachSubTaxonomy() {
+ List> pairs = new ArrayList>();
/*
* Create a list for each subtree of the Data Taxonomy (e.g. TypeSubTaxonomy,
@@ -272,7 +267,7 @@ public List> getTypePairsForEachSubTaxonomy() {
for (List iterator : subTreesMap.values()) {
for (int i = 0; i < iterator.size() - 1; i++) {
for (int j = i + 1; j < iterator.size(); j++) {
- pairs.add(new Pair(iterator.get(i), iterator.get(j)));
+ pairs.add(new Pair(iterator.get(i), iterator.get(j)));
}
}
}
diff --git a/src/main/java/nl/uu/cs/ape/models/Module.java b/src/main/java/nl/uu/cs/ape/models/Module.java
index 4cae6dfd..e94951b7 100644
--- a/src/main/java/nl/uu/cs/ape/models/Module.java
+++ b/src/main/java/nl/uu/cs/ape/models/Module.java
@@ -3,12 +3,12 @@
import org.json.JSONException;
import org.json.JSONObject;
-import nl.uu.cs.ape.domain.APEDimensionsException;
-import nl.uu.cs.ape.domain.APEDomainSetup;
import nl.uu.cs.ape.utils.APEUtils;
import nl.uu.cs.ape.models.enums.LogicOperation;
import nl.uu.cs.ape.models.enums.NodeType;
import nl.uu.cs.ape.models.logic.constructs.TaxonomyPredicate;
+import nl.uu.cs.ape.solver.domainconfiguration.APEDimensionsException;
+import nl.uu.cs.ape.solver.domainconfiguration.Domain;
import java.util.*;
@@ -24,12 +24,12 @@ public class Module extends AbstractModule {
/**
* List of input types required by the tool.
*/
- private List moduleInput;
+ private final List moduleInput;
/**
* List of output types generated by the tool.
*/
- private List moduleOutput;
+ private final List moduleOutput;
/**
* Tool execution command.
@@ -62,8 +62,8 @@ public class Module extends AbstractModule {
public Module(String moduleName, String moduleID, String rootNode, List moduleInput,
List moduleOutput, String moduleExecution) {
super(moduleName, moduleID, rootNode, NodeType.LEAF);
- this.moduleInput = new ArrayList(moduleInput);
- this.moduleOutput = new ArrayList(moduleOutput);
+ this.moduleInput = new ArrayList<>(moduleInput);
+ this.moduleOutput = new ArrayList<>(moduleOutput);
this.executionCommand = moduleExecution;
}
@@ -79,8 +79,8 @@ public Module(String moduleName, String moduleID, String rootNode, List mo
*/
public Module(String moduleName, String moduleID, String rootNode, String moduleExecution) {
super(moduleName, moduleID, rootNode, NodeType.LEAF);
- this.moduleInput = new ArrayList();
- this.moduleOutput = new ArrayList();
+ this.moduleInput = new ArrayList<>();
+ this.moduleOutput = new ArrayList<>();
this.executionCommand = moduleExecution;
}
@@ -112,12 +112,15 @@ public List getModuleInput() {
}
/**
- * Sets module input.
+ * Sets module input to the given list of types.
*
* @param moduleInputs the module inputs
*/
public void setModuleInput(List moduleInputs) {
- this.moduleInput = moduleInputs;
+ moduleInput.clear();
+ for (Type currModuleInput : moduleInputs) {
+ addModuleInput(currModuleInput);
+ }
}
/**
@@ -149,7 +152,10 @@ public List getModuleOutput() {
* @param moduleOutput the module output
*/
public void setModuleOutput(List moduleOutput) {
- this.moduleOutput = moduleOutput;
+ moduleOutput.clear();
+ for (Type currModuleOutput : moduleOutput) {
+ addModuleOutput(currModuleOutput);
+ }
}
/**
@@ -222,11 +228,11 @@ public void setCwlImplementation(Map cwlImplementation) {
* @throws JSONException if the given JSON is not well formatted
* @throws APEDimensionsException if the referenced modules are not well defined
*/
- public static AbstractModule taxonomyInstanceFromJson(JSONObject jsonParam, APEDomainSetup domainSetup)
+ public static AbstractModule taxonomyInstanceFromJson(JSONObject jsonParam, Domain domainSetup)
throws JSONException {
/* Set of predicates where each describes a type dimension */
SortedSet parameterDimensions = new TreeSet();
- AllModules allModules = domainSetup.getAllModules();
+ DomainModules allModules = domainSetup.getAllModules();
/* Iterate through each of the dimensions */
for (String currRootLabel : jsonParam.keySet()) {
String curRootIRI = currRootLabel;
diff --git a/src/main/java/nl/uu/cs/ape/models/SATAtomMappings.java b/src/main/java/nl/uu/cs/ape/models/SATAtomMappings.java
index 7a70b041..9365383c 100644
--- a/src/main/java/nl/uu/cs/ape/models/SATAtomMappings.java
+++ b/src/main/java/nl/uu/cs/ape/models/SATAtomMappings.java
@@ -1,11 +1,13 @@
package nl.uu.cs.ape.models;
+import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
+import lombok.NoArgsConstructor;
import nl.uu.cs.ape.automaton.State;
import nl.uu.cs.ape.models.enums.AtomType;
-import nl.uu.cs.ape.models.logic.constructs.PredicateLabel;
+import nl.uu.cs.ape.models.logic.constructs.Predicate;
import nl.uu.cs.ape.models.logic.constructs.TaxonomyPredicate;
import nl.uu.cs.ape.models.sltlxStruc.SLTLxAtom;
import nl.uu.cs.ape.models.sltlxStruc.SLTLxAtomVar;
@@ -20,7 +22,8 @@
*
* @author Vedran Kasalica
*/
-public class SATAtomMappings {
+@NoArgsConstructor
+public class SATAtomMappings implements Serializable {
/**
* First variable that can be used for auxiliary variables.
@@ -28,57 +31,37 @@ public class SATAtomMappings {
* {@code false}.
*/
private static final int auxDefaultInit = 3;
+ /**
+ * Last number used to represent auxiliary introduced variables.
+ * Numbers 1 and 2 are special symbols. 1 is {@code true} and 2 is
+ * {@code false}.
+ */
+ private int auxiliary = auxDefaultInit;
/** Max number of all auxiliary variables. */
private static final int auxMax = 100000;
+
/** Max number of all expected atoms containing variables. */
private static final int atomVarMaxNo = 100000;
+
+ /** Number of mapped atoms. */
+ private int atomNo = auxMax + atomVarMaxNo + 1;
+
+ /** Number of mapped atoms containing variables. */
+ private int atomVarNo = auxMax + 1;
+
/** Mapping of the atoms to integers. */
- private Map mappings;
+ private final Map mappings = new HashMap<>();
/** Inverse mapping from integers to atoms. */
- private Map reverseMapping;
+ private final Map reverseMapping = new HashMap<>();
/** Map of all the IDs that were mapped to atoms. */
- private Map mapped;
+ private final Map mapped = new HashMap<>();
/** Mapping of the atoms over variables to integers. */
- private Map vMappings;
+ private final Map vMappings = new HashMap<>();
/** Inverse mapping from integers to atoms containing variables. */
- private Map vReverseMapping;
+ private final Map vReverseMapping = new HashMap<>();
/** Map of all the IDs that were mapped to atoms containing variables. */
- private Map vMapped;
-
- /**
- * Number of mapped atoms.
- */
- private int atomNo;
-
- /**
- * Number of mapped atoms containing variables.
- */
- private int atomVarNo;
-
- /**
- * Last number used to represent auxiliary introduced variables.
- * Numbers 1 and 2 are special symbols. 1 is {@code true} and 2 is
- * {@code false}.
- */
- private int auxiliary;
-
- /**
- * Instantiates a new SLTLxAtom mappings.
- */
- public SATAtomMappings() {
- mappings = new HashMap();
- reverseMapping = new HashMap();
- mapped = new HashMap();
- vMappings = new HashMap();
- vReverseMapping = new HashMap();
- vMapped = new HashMap();
-
- /* First auxMax variables are reserved for auxiliary variables */
- auxiliary = auxDefaultInit;
- atomVarNo = auxMax + 1;
- atomNo = auxMax + atomVarMaxNo + 1;
- }
+ private final Map vMapped = new HashMap<>();
/**
* Function is returning the mapping number of the
@@ -93,7 +76,7 @@ public SATAtomMappings() {
* (such as {@link AtomType#MODULE}.
* @return Mapping number of the atom (number is always > 0).
*/
- public synchronized Integer add(PredicateLabel predicate, State usedInState, AtomType elementType)
+ public synchronized Integer add(Predicate predicate, State usedInState, AtomType elementType)
throws MappingsException {
SLTLxAtom atom = new SLTLxAtom(elementType, predicate, usedInState);
@@ -211,7 +194,7 @@ public int getSize() {
}
/**
- * Get the next auxiliary number and increase the counterErrors by 1.
+ * Get the next auxiliary number and increase the counter by 1.
*
* @return Mapping number that can be used for auxiliary variables.
*/
diff --git a/src/main/java/nl/uu/cs/ape/models/Type.java b/src/main/java/nl/uu/cs/ape/models/Type.java
index 71eb621f..5cde4756 100644
--- a/src/main/java/nl/uu/cs/ape/models/Type.java
+++ b/src/main/java/nl/uu/cs/ape/models/Type.java
@@ -6,12 +6,12 @@
import org.json.JSONException;
import org.json.JSONObject;
-import nl.uu.cs.ape.domain.APEDimensionsException;
-import nl.uu.cs.ape.domain.APEDomainSetup;
import nl.uu.cs.ape.utils.APEUtils;
import nl.uu.cs.ape.models.enums.LogicOperation;
import nl.uu.cs.ape.models.enums.NodeType;
import nl.uu.cs.ape.models.logic.constructs.TaxonomyPredicate;
+import nl.uu.cs.ape.solver.domainconfiguration.APEDimensionsException;
+import nl.uu.cs.ape.solver.domainconfiguration.Domain;
/**
* The {@code Type} class represents data dimension (e.g. data type, data
@@ -97,12 +97,12 @@ public Type getPlainType() {
* @throws JSONException if the given JSON is not well formatted
* @throws APEDimensionsException if the referenced types are not well defined
*/
- public static Type taxonomyInstanceFromJson(JSONObject jsonParam, APEDomainSetup domainSetup, boolean isOutputData)
+ public static Type taxonomyInstanceFromJson(JSONObject jsonParam, Domain domainSetup, boolean isOutputData)
throws JSONException, APEDimensionsException {
/* Set of predicates where each describes a type dimension */
SortedSet parameterDimensions = new TreeSet<>();
boolean labelDefined = false;
- AllTypes allTypes = domainSetup.getAllTypes();
+ DomainTypes allTypes = domainSetup.getAllTypes();
/* Iterate through each of the dimensions */
for (String currRootLabel : jsonParam.keySet()) {
String curRootIRI = currRootLabel;
diff --git a/src/main/java/nl/uu/cs/ape/models/logic/constructs/APEPredicate.java b/src/main/java/nl/uu/cs/ape/models/logic/constructs/APEPredicate.java
deleted file mode 100644
index e9771a75..00000000
--- a/src/main/java/nl/uu/cs/ape/models/logic/constructs/APEPredicate.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package nl.uu.cs.ape.models.logic.constructs;
-
-/**
- * Class provides interface for all APE related predicated used in the encoding.
- *
- * @author Vedran Kasalica
- *
- */
-public interface APEPredicate {
-
-}
diff --git a/src/main/java/nl/uu/cs/ape/models/logic/constructs/CustomLabel.java b/src/main/java/nl/uu/cs/ape/models/logic/constructs/CustomPredicate.java
similarity index 78%
rename from src/main/java/nl/uu/cs/ape/models/logic/constructs/CustomLabel.java
rename to src/main/java/nl/uu/cs/ape/models/logic/constructs/CustomPredicate.java
index a77ceecb..a4d6df68 100644
--- a/src/main/java/nl/uu/cs/ape/models/logic/constructs/CustomLabel.java
+++ b/src/main/java/nl/uu/cs/ape/models/logic/constructs/CustomPredicate.java
@@ -1,22 +1,23 @@
package nl.uu.cs.ape.models.logic.constructs;
/**
- * The {@code CustomLabel} used to represent custom labels (dimension) of the
- * data.
+ * The {@code CustomPredicate} used to represent custom predicates describing
+ * the data,
+ * e.g., new data dimensions.
*
* @author Vedran Kasalica
*
*/
-public class CustomLabel implements PredicateLabel {
+public class CustomPredicate implements Predicate {
private String label;
- public CustomLabel(String label) {
+ public CustomPredicate(String label) {
this.label = label;
}
@Override
- public int compareTo(PredicateLabel arg0) {
+ public int compareTo(Predicate arg0) {
return this.getPredicateID().compareTo(arg0.getPredicateID());
}
@@ -61,7 +62,7 @@ public boolean equals(Object obj) {
return false;
if (getClass() != obj.getClass())
return false;
- CustomLabel other = (CustomLabel) obj;
+ CustomPredicate other = (CustomPredicate) obj;
if (label == null) {
if (other.label != null)
return false;
diff --git a/src/main/java/nl/uu/cs/ape/models/logic/constructs/PredicateLabel.java b/src/main/java/nl/uu/cs/ape/models/logic/constructs/Predicate.java
similarity index 87%
rename from src/main/java/nl/uu/cs/ape/models/logic/constructs/PredicateLabel.java
rename to src/main/java/nl/uu/cs/ape/models/logic/constructs/Predicate.java
index eaf00573..7548eb80 100644
--- a/src/main/java/nl/uu/cs/ape/models/logic/constructs/PredicateLabel.java
+++ b/src/main/java/nl/uu/cs/ape/models/logic/constructs/Predicate.java
@@ -1,12 +1,12 @@
package nl.uu.cs.ape.models.logic.constructs;
/**
- * The {@code PredicateLabel} class is used to represent a label that describes
+ * The {@code Predicate} class is used to represent a label that describes
* predicates, such as data types, operations or states in the system.
*
* @author Vedran Kasalica
*/
-public interface PredicateLabel extends Comparable, APEPredicate {
+public interface Predicate extends Comparable {
/**
* Get the unique predicate identifier defined as String.
diff --git a/src/main/java/nl/uu/cs/ape/models/logic/constructs/TaxonomyPredicate.java b/src/main/java/nl/uu/cs/ape/models/logic/constructs/TaxonomyPredicate.java
index 63f3fae6..ffc401f0 100644
--- a/src/main/java/nl/uu/cs/ape/models/logic/constructs/TaxonomyPredicate.java
+++ b/src/main/java/nl/uu/cs/ape/models/logic/constructs/TaxonomyPredicate.java
@@ -5,7 +5,7 @@
import lombok.extern.slf4j.Slf4j;
import nl.uu.cs.ape.automaton.State;
import nl.uu.cs.ape.utils.APEUtils;
-import nl.uu.cs.ape.models.AllPredicates;
+import nl.uu.cs.ape.models.DomainPredicates;
import nl.uu.cs.ape.models.enums.NodeType;
import nl.uu.cs.ape.models.sltlxStruc.SLTLxAtom;
@@ -19,7 +19,7 @@
* @author Vedran Kasalica
*/
@Slf4j
-public abstract class TaxonomyPredicate implements PredicateLabel {
+public abstract class TaxonomyPredicate implements Predicate {
/**
* Describes the node in from the taxonomy hierarchy. The type can represent a
@@ -131,7 +131,7 @@ public boolean equals(Object obj) {
return true;
}
- public int compareTo(PredicateLabel other) {
+ public int compareTo(Predicate other) {
if (!(other instanceof TaxonomyPredicate)) {
return this.getPredicateID().compareTo(other.getPredicateID());
}
@@ -211,7 +211,7 @@ public Map toMap() {
* @param allPredicates Map of all the predicates of the given type.
* @return true if the predicates were successfully set to be relevant.
*/
- public boolean setAsRelevantTaxonomyTerm(AllPredicates allPredicates) {
+ public boolean setAsRelevantTaxonomyTerm(DomainPredicates allPredicates) {
if (this.isRelevant) {
return true;
}
@@ -236,7 +236,7 @@ public boolean setAsRelevantTaxonomyTerm(AllPredicates allPredicates) {
* @param allPredicates Map of all the predicates of the given type.
* @return true if the predicates were successfully set to be relevant.
*/
- private boolean setAsRelevantTaxonomyTermTopDown(AllPredicates allPredicates) {
+ private boolean setAsRelevantTaxonomyTermTopDown(DomainPredicates allPredicates) {
if (this.isRelevant) {
return true;
}
@@ -258,7 +258,7 @@ private boolean setAsRelevantTaxonomyTermTopDown(AllPredicates allPredicates) {
* @param allPredicates Map of all the predicates of the given type.
* @return true if the predicates were successfully set to be relevant.
*/
- private boolean setAsRelevantTaxonomyTermBottomUp(AllPredicates allPredicates) {
+ private boolean setAsRelevantTaxonomyTermBottomUp(DomainPredicates allPredicates) {
if (this.isRelevant) {
return true;
}
@@ -307,7 +307,7 @@ public String toShortString() {
* distinguish between the tree levels.
* @param allPredicates Set of all the predicates.
*/
- public void printTree(String str, AllPredicates allPredicates) {
+ public void printTree(String str, DomainPredicates allPredicates) {
log.debug(str + toShortString() + "[" + getNodeType() + "]");
for (TaxonomyPredicate predicate : APEUtils.safe(this.subPredicates)) {
predicate.printTree(str + ". ", allPredicates);
diff --git a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/CNFClause.java b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/CNFClause.java
index a76aaecc..00864fd4 100644
--- a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/CNFClause.java
+++ b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/CNFClause.java
@@ -16,7 +16,7 @@
*/
public class CNFClause {
- List atoms;
+ private final List atoms = new ArrayList<>();
/**
* Create clause based on the list of elements (integers, bigger that 0)
@@ -25,7 +25,6 @@ public class CNFClause {
*/
public CNFClause(List atoms) {
super();
- this.atoms = new ArrayList<>();
atoms.forEach(atom -> this.atoms.add(atom));
}
@@ -36,7 +35,6 @@ public CNFClause(List atoms) {
*/
public CNFClause(Integer atom) {
super();
- this.atoms = new ArrayList<>();
this.atoms.add(atom);
}
@@ -51,7 +49,7 @@ public CNFClause(Integer atom) {
*/
public static Set conjunctClausesCollection(Set> facts) {
Set allClauses = new HashSet<>();
- facts.forEach(col -> allClauses.addAll(col));
+ facts.forEach(allClauses::addAll);
return allClauses;
}
diff --git a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxAtom.java b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxAtom.java
index 4fa7b87f..ae9ea4da 100644
--- a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxAtom.java
+++ b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxAtom.java
@@ -4,7 +4,7 @@
import nl.uu.cs.ape.automaton.State;
import nl.uu.cs.ape.models.enums.AtomType;
-import nl.uu.cs.ape.models.logic.constructs.PredicateLabel;
+import nl.uu.cs.ape.models.logic.constructs.Predicate;
import nl.uu.cs.ape.solver.minisat.SATSynthesisEngine;
/**
@@ -17,7 +17,7 @@ public class SLTLxAtom extends SLTLxFormula implements Comparable {
/**
* StateInterface that is referred (tool or type).
*/
- private final PredicateLabel predicate;
+ private final Predicate predicate;
/**
* State in which the type/operation was used.
@@ -46,7 +46,7 @@ public class SLTLxAtom extends SLTLxFormula implements Comparable {
* @param predicate Predicate used.
* @param usedInState State in the automaton it was used/created in.
*/
- public SLTLxAtom(AtomType elementType, PredicateLabel predicate, State usedInState) {
+ public SLTLxAtom(AtomType elementType, Predicate predicate, State usedInState) {
super();
this.predicate = predicate;
this.argumentState = usedInState;
@@ -71,7 +71,7 @@ private SLTLxAtom(int mapping) {
*
* @return Field {@link #predicate}.
*/
- public PredicateLabel getPredicate() {
+ public Predicate getPredicate() {
return predicate;
}
diff --git a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxAtomVar.java b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxAtomVar.java
index 03531485..3b5a0175 100644
--- a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxAtomVar.java
+++ b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxAtomVar.java
@@ -6,7 +6,7 @@
import nl.uu.cs.ape.models.Pair;
import nl.uu.cs.ape.models.enums.AtomType;
import nl.uu.cs.ape.models.enums.AtomVarType;
-import nl.uu.cs.ape.models.logic.constructs.PredicateLabel;
+import nl.uu.cs.ape.models.logic.constructs.Predicate;
import nl.uu.cs.ape.solver.minisat.SATSynthesisEngine;
/**
@@ -21,7 +21,7 @@ public class SLTLxAtomVar extends SLTLxFormula {
* First argument is usually predicate that is referred (tool or type), or a
* variable representing a type state.
*/
- private PredicateLabel firstArg;
+ private Predicate firstArg;
/**
* Second argument is a variable representing a typeState.
@@ -50,7 +50,7 @@ public class SLTLxAtomVar extends SLTLxFormula {
* @param secondArg - Variable representing state in the automaton it was
* used/created in.
*/
- public SLTLxAtomVar(AtomVarType elementType, PredicateLabel firstArg, SLTLxVariable secondArg) {
+ public SLTLxAtomVar(AtomVarType elementType, Predicate firstArg, SLTLxVariable secondArg) {
super();
this.firstArg = firstArg;
this.secondArg = secondArg;
@@ -62,7 +62,7 @@ public SLTLxAtomVar(AtomVarType elementType, PredicateLabel firstArg, SLTLxVaria
*
* @return Field {@link #firstArg}.
*/
- public PredicateLabel getFirstArg() {
+ public Predicate getFirstArg() {
return firstArg;
}
diff --git a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxConjunction.java b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxConjunction.java
index d21632be..06ad3049 100644
--- a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxConjunction.java
+++ b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxConjunction.java
@@ -14,11 +14,11 @@
*/
public class SLTLxConjunction extends SLTLxFormula {
- private Set conjunctedFacts;
+ /** Set of conjuncted facts. */
+ private final Set conjunctedFacts = new HashSet<>();
public SLTLxConjunction(SLTLxFormula arg1, SLTLxFormula arg2) {
super();
- this.conjunctedFacts = new HashSet<>();
if (arg1 != null)
this.conjunctedFacts.add(arg1);
if (arg2 != null)
@@ -27,7 +27,6 @@ public SLTLxConjunction(SLTLxFormula arg1, SLTLxFormula arg2) {
public SLTLxConjunction(SLTLxFormula arg1, SLTLxFormula arg2, SLTLxFormula arg3) {
super();
- this.conjunctedFacts = new HashSet<>();
if (arg1 != null)
this.conjunctedFacts.add(arg1);
if (arg2 != null)
@@ -38,7 +37,6 @@ public SLTLxConjunction(SLTLxFormula arg1, SLTLxFormula arg2, SLTLxFormula arg3)
public SLTLxConjunction(Collection extends SLTLxFormula> conjunctedFacts) {
super();
- this.conjunctedFacts = new HashSet<>();
conjunctedFacts.forEach(fact -> {
if (fact != null)
this.conjunctedFacts.add(fact);
diff --git a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxDisjunction.java b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxDisjunction.java
index a32de782..ccf41688 100644
--- a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxDisjunction.java
+++ b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxDisjunction.java
@@ -14,11 +14,11 @@
*/
public class SLTLxDisjunction extends SLTLxFormula {
- private Set disjointFacts;
+ /** Set of disjoint facts. */
+ private final Set disjointFacts = new HashSet<>();
public SLTLxDisjunction(SLTLxFormula arg1, SLTLxFormula arg2) {
super();
- this.disjointFacts = new HashSet<>();
if (arg1 != null)
this.disjointFacts.add(arg1);
if (arg2 != null)
@@ -27,7 +27,6 @@ public SLTLxDisjunction(SLTLxFormula arg1, SLTLxFormula arg2) {
public SLTLxDisjunction(Collection extends SLTLxFormula> conjunctedFacts) {
super();
- this.disjointFacts = new HashSet<>();
conjunctedFacts.forEach(fact -> {
if (fact != null)
this.disjointFacts.add(fact);
diff --git a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxExists.java b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxExists.java
index 4e522909..d26306df 100644
--- a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxExists.java
+++ b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxExists.java
@@ -22,15 +22,15 @@ public SLTLxExists(SLTLxVariable boundVariable, SLTLxFormula formula) {
public Set getCNFEncoding(int stateNo, SLTLxVariableSubstitutionCollection curVarMapping,
SATSynthesisEngine synthesisEngine) {
Set clauses = new HashSet<>();
- SLTLxVariableSubstitutionCollection newVarMappping = new SLTLxVariableSubstitutionCollection(curVarMapping);
- SLTLxVariable flatBindedVariable = newVarMappping.addNewVariable(boundVariable,
+ SLTLxVariableSubstitutionCollection newVarMapping = new SLTLxVariableSubstitutionCollection(curVarMapping);
+ SLTLxVariable flatBindedVariable = newVarMapping.addNewVariable(boundVariable,
SLTLxVariable.getVariableDomain(stateNo, synthesisEngine));
/** Encode the possible substitutions for the given variable. */
- clauses.addAll(flatBindedVariable.getExistentialCNFEncoding(stateNo, newVarMappping, synthesisEngine));
+ clauses.addAll(flatBindedVariable.getExistentialCNFEncoding(stateNo, newVarMapping, synthesisEngine));
/** Encode the variable substitution and the underlying formula. */
- clauses.addAll(super.getCNFEncoding(stateNo, newVarMappping, synthesisEngine));
+ clauses.addAll(super.getCNFEncoding(stateNo, newVarMapping, synthesisEngine));
return clauses;
}
@@ -42,17 +42,17 @@ public Set getNegatedCNFEncoding(int stateNo, SLTLxVariableSubstitutionC
/** Encode the possible substitutions for the given variable. */
SLTLxVariable.getVariableDomain(stateNo, synthesisEngine).forEach(
state -> {
- SLTLxVariableSubstitutionCollection newVarMappping = new SLTLxVariableSubstitutionCollection(
+ SLTLxVariableSubstitutionCollection newVarMapping = new SLTLxVariableSubstitutionCollection(
curVarMapping);
Set domainState = new HashSet<>();
domainState.add(state);
- SLTLxVariable flatBindedVariable = newVarMappping.addNewVariable(boundVariable, domainState);
+ SLTLxVariable flatBindedVariable = newVarMapping.addNewVariable(boundVariable, domainState);
/* Encode the substitution. */
clauses.addAll(
- flatBindedVariable.getUniversalCNFEncoding(stateNo, newVarMappping, synthesisEngine));
+ flatBindedVariable.getUniversalCNFEncoding(stateNo, newVarMapping, synthesisEngine));
/** Encode the variable substitution and the underlying formula. */
- clauses.addAll(super.getNegatedCNFEncoding(stateNo, newVarMappping, synthesisEngine));
+ clauses.addAll(super.getNegatedCNFEncoding(stateNo, newVarMapping, synthesisEngine));
});
return clauses;
diff --git a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxForall.java b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxForall.java
index 4d74c6a6..686811f2 100644
--- a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxForall.java
+++ b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxForall.java
@@ -26,17 +26,17 @@ public Set getCNFEncoding(int stateNo, SLTLxVariableSubstitutionCollecti
/** Encode the possible substitutions for the given variable. */
SLTLxVariable.getVariableDomain(stateNo, synthesisEngine).forEach(
state -> {
- SLTLxVariableSubstitutionCollection newVarMappping = new SLTLxVariableSubstitutionCollection(
+ SLTLxVariableSubstitutionCollection newVarMapping = new SLTLxVariableSubstitutionCollection(
curVarMapping);
Set domainState = new HashSet<>();
domainState.add(state);
- SLTLxVariable flatBindedVariable = newVarMappping.addNewVariable(boundVariable, domainState);
+ SLTLxVariable flatBindedVariable = newVarMapping.addNewVariable(boundVariable, domainState);
/* Encode the substitution. */
clauses.addAll(
- flatBindedVariable.getUniversalCNFEncoding(stateNo, newVarMappping, synthesisEngine));
+ flatBindedVariable.getUniversalCNFEncoding(stateNo, newVarMapping, synthesisEngine));
/** Encode the variable substitution and the underlying formula. */
- clauses.addAll(super.getCNFEncoding(stateNo, newVarMappping, synthesisEngine));
+ clauses.addAll(super.getCNFEncoding(stateNo, newVarMapping, synthesisEngine));
});
return clauses;
@@ -45,16 +45,16 @@ public Set getCNFEncoding(int stateNo, SLTLxVariableSubstitutionCollecti
@Override
public Set getNegatedCNFEncoding(int stateNo, SLTLxVariableSubstitutionCollection curVarMapping,
SATSynthesisEngine synthesisEngine) {
- Set clauses = new HashSet();
- SLTLxVariableSubstitutionCollection newVarMappping = new SLTLxVariableSubstitutionCollection(curVarMapping);
- SLTLxVariable flatBindedVariable = newVarMappping.addNewVariable(boundVariable,
+ Set clauses = new HashSet<>();
+ SLTLxVariableSubstitutionCollection newVarMapping = new SLTLxVariableSubstitutionCollection(curVarMapping);
+ SLTLxVariable flatBindedVariable = newVarMapping.addNewVariable(boundVariable,
SLTLxVariable.getVariableDomain(stateNo, synthesisEngine));
/** Encode the possible substitutions for the given variable. */
- clauses.addAll(flatBindedVariable.getExistentialCNFEncoding(stateNo, newVarMappping, synthesisEngine));
+ clauses.addAll(flatBindedVariable.getExistentialCNFEncoding(stateNo, newVarMapping, synthesisEngine));
/** Encode the variable substitution and the underlying formula. */
- clauses.addAll(super.getNegatedCNFEncoding(stateNo, newVarMappping, synthesisEngine));
+ clauses.addAll(super.getNegatedCNFEncoding(stateNo, newVarMapping, synthesisEngine));
return clauses;
}
diff --git a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxLiteral.java b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxLiteral.java
index 8fab0086..8ec64e9d 100644
--- a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxLiteral.java
+++ b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxLiteral.java
@@ -3,7 +3,7 @@
import nl.uu.cs.ape.automaton.State;
import nl.uu.cs.ape.models.SATAtomMappings;
import nl.uu.cs.ape.models.enums.AtomType;
-import nl.uu.cs.ape.models.logic.constructs.PredicateLabel;
+import nl.uu.cs.ape.models.logic.constructs.Predicate;
/**
* The {@code SLTLxLiteral} class represents literals (atoms that can be
@@ -160,7 +160,7 @@ public SLTLxAtom getAtom() {
*
* @return StateInterface object that is referred by the literal.
*/
- public PredicateLabel getPredicate() {
+ public Predicate getPredicate() {
return atom.getPredicate();
}
diff --git a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxVarQuantification.java b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxVarQuantification.java
index aee5382f..3aabefcd 100644
--- a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxVarQuantification.java
+++ b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxVarQuantification.java
@@ -25,7 +25,7 @@ protected SLTLxVarQuantification(SLTLxVariable boundVariable, SLTLxFormula formu
@Override
public Set getCNFEncoding(int stateNo, SLTLxVariableSubstitutionCollection newVarMapping,
SATSynthesisEngine synthesisEngine) {
- Set clauses = new HashSet();
+ Set clauses = new HashSet<>();
SLTLxVariable flatBoundVariable = newVarMapping.getVarSabstitute(boundVariable);
/** Encode the underlying formula. */
clauses.addAll(formula.getCNFEncoding(stateNo, newVarMapping, synthesisEngine));
diff --git a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxVariable.java b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxVariable.java
index e1a78e1e..c13c62ff 100644
--- a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxVariable.java
+++ b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxVariable.java
@@ -9,7 +9,7 @@
import nl.uu.cs.ape.models.Pair;
import nl.uu.cs.ape.models.enums.AtomType;
import nl.uu.cs.ape.models.enums.AtomVarType;
-import nl.uu.cs.ape.models.logic.constructs.PredicateLabel;
+import nl.uu.cs.ape.models.logic.constructs.Predicate;
import nl.uu.cs.ape.solver.minisat.SATSynthesisEngine;
/***
@@ -23,7 +23,7 @@
*
* @author Vedran Kasalica
*/
-public class SLTLxVariable implements StateInterface, PredicateLabel {
+public class SLTLxVariable implements StateInterface, Predicate {
/** Unique name of the type state variable */
private final String variableID;
@@ -75,7 +75,7 @@ public String getPredicateID() {
return variableID;
}
- public int compareTo(PredicateLabel other) {
+ public int compareTo(Predicate other) {
return this.getPredicateID().compareTo(other.getPredicateID());
}
@@ -207,7 +207,7 @@ private static Set generateDataPropertySubstitutionRules(SLTLxVari
*/
for (State varState : variableSubstitutions.getVariableDomain(variable)) {
- for (PredicateLabel usedPred : varOccurrences.getDataTypes(variable)) {
+ for (Predicate usedPred : varOccurrences.getDataTypes(variable)) {
/* (VAL(?x,a) => (P(?x) <=> P(a)) */
allFacts.add(new SLTLxImplication(
new SLTLxAtomVar(
@@ -357,7 +357,7 @@ public Set getVariableMutualExclusion(int stateNo, SLTLxVariableSubstitu
* and thus we use the next state to get the domain of the variable.
*/
int nextStateNo = stateNo + 1;
- Set> statePairs = APEUtils
+ Set> statePairs = APEUtils
.getUniquePairs(synthesisEngine.getTypeAutomaton().getAllMemoryStatesUntilBlockNo(nextStateNo));
statePairs.forEach(statePair -> {
diff --git a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxVariableOccurrenceCollection.java b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxVariableOccurrenceCollection.java
index d2fe26e4..eff7a9a6 100644
--- a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxVariableOccurrenceCollection.java
+++ b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxVariableOccurrenceCollection.java
@@ -5,11 +5,12 @@
import java.util.Map;
import java.util.Set;
+import lombok.NoArgsConstructor;
import nl.uu.cs.ape.automaton.State;
import nl.uu.cs.ape.utils.APEUtils;
import nl.uu.cs.ape.models.Pair;
import nl.uu.cs.ape.models.enums.AtomVarType;
-import nl.uu.cs.ape.models.logic.constructs.PredicateLabel;
+import nl.uu.cs.ape.models.logic.constructs.Predicate;
/**
* Class used to list all usages of the given variables within the formulas.
@@ -17,30 +18,20 @@
* @author Vedran Kasalica
*
*/
+@NoArgsConstructor
public class SLTLxVariableOccurrenceCollection {
/** Mapping variables to their predicate properties. */
- private Map> variableDataTypes;
+ private final Map> variableDataTypes = new HashMap<>();
/**
* Mapping variables (depicting memory states) to tool inputs that reference
* them.
*/
- private Map> variableMemoryReferences;
+ private final Map> variableMemoryReferences = new HashMap<>();
/** Mapping pairs variables to their usages under binary predicates. */
- private Map, Set> binaryPredicates;
+ private final Map, Set> binaryPredicates = new HashMap<>();
/** Variable mapping to variables it is combined with under a pair. */
- private Map>> variablePairs;
-
- /**
- * Create the variable usage class.
- */
- public SLTLxVariableOccurrenceCollection() {
- super();
- this.variableDataTypes = new HashMap<>();
- this.variableMemoryReferences = new HashMap<>();
- this.binaryPredicates = new HashMap<>();
- this.variablePairs = new HashMap<>();
- }
+ private final Map>> variablePairs = new HashMap<>();
/**
* Associate the data type to the corresponding variable.
@@ -50,9 +41,9 @@ public SLTLxVariableOccurrenceCollection() {
* @return {@code true} if the property was associated with the variable,
* {@code false} otherwise.
*/
- public boolean addDataType(PredicateLabel dataType, SLTLxVariable variableState) {
+ public boolean addDataType(Predicate dataType, SLTLxVariable variableState) {
if (this.variableDataTypes.get(variableState) == null) {
- Set preds = new HashSet<>();
+ Set preds = new HashSet<>();
boolean tmp = preds.add(dataType);
this.variableDataTypes.put(variableState, preds);
return tmp;
@@ -136,9 +127,9 @@ public void addBinaryPred(Pair varPair, AtomVarType relType) {
* @return Set (possibly empty) of memory references that are mentioned in
* combination with the given variable.
*/
- public Set getDataTypes(SLTLxVariable satVariable) {
- Set unaryPreds = this.variableDataTypes.get(satVariable);
- return ((unaryPreds == null) ? new HashSet() : unaryPreds);
+ public Set getDataTypes(SLTLxVariable satVariable) {
+ Set unaryPreds = this.variableDataTypes.get(satVariable);
+ return ((unaryPreds == null) ? new HashSet() : unaryPreds);
}
/**
diff --git a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxVariableSubstitutionCollection.java b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxVariableSubstitutionCollection.java
index 581e09ff..bd7696ba 100644
--- a/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxVariableSubstitutionCollection.java
+++ b/src/main/java/nl/uu/cs/ape/models/sltlxStruc/SLTLxVariableSubstitutionCollection.java
@@ -4,6 +4,7 @@
import java.util.Map;
import java.util.Set;
+import lombok.NoArgsConstructor;
import nl.uu.cs.ape.automaton.State;
/**
@@ -13,24 +14,16 @@
* @author Vedran Kasalica
*
*/
+@NoArgsConstructor
public class SLTLxVariableSubstitutionCollection {
/** Variable mapping to unique IDs. */
- private Map mappedVariables;
+ private final Map