diff --git a/.gitignore b/.gitignore index 097f6d161..333df6657 100644 --- a/.gitignore +++ b/.gitignore @@ -102,3 +102,5 @@ gradle-app.setting *.tokens /.dbeaver /Scripts +/src/main/gen +/buildSrc diff --git a/build.gradle b/build.gradle index 12094d0e8..c74b84af5 100644 --- a/build.gradle +++ b/build.gradle @@ -130,6 +130,6 @@ test { } wrapper { - gradleVersion = '7.3' + gradleVersion = '7.6' distributionType = 'ALL' } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index fbce071a3..f42e62f37 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1b6c78733..c53aefaa5 100755 --- a/gradlew +++ b/gradlew @@ -1,7 +1,7 @@ #!/bin/sh # -# Copyright © 2015-2021 the original authors. +# Copyright © 2015-2021 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -32,10 +32,10 @@ # Busybox and similar reduced shells will NOT work, because this script # requires all of these POSIX shell features: # * functions; -# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», -# «${var#prefix}», «${var%suffix}», and «$( cmd )»; -# * compound commands having a testable exit status, especially «case»; -# * various built-in commands including «command», «set», and «ulimit». +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». # # Important for patching: # diff --git a/src/main/antlr/at/ac/tuwien/kr/alpha/antlr/ASPCore2.g4 b/src/main/antlr/at/ac/tuwien/kr/alpha/antlr/ASPCore2.g4 index aeca5cc2d..296392ca4 100644 --- a/src/main/antlr/at/ac/tuwien/kr/alpha/antlr/ASPCore2.g4 +++ b/src/main/antlr/at/ac/tuwien/kr/alpha/antlr/ASPCore2.g4 @@ -5,7 +5,6 @@ import ASPLexer; /* The ASP-Core-2 grammar in ANTLR v4 based on * https://www.mat.unical.it/aspcomp2013/files/ASP-CORE-2.01c.pdf * (sections 4 and 5, pages 10-12). - * It is extended a bit to parse widespread syntax (e.g. used by gringo/clasp). */ program : statements? query? EOF; @@ -17,8 +16,7 @@ query : classical_literal QUERY_MARK; statement : head DOT # statement_fact | CONS body DOT # statement_constraint | head CONS body DOT # statement_rule - | WCONS body? DOT SQUARE_OPEN weight_at_level SQUARE_CLOSE # statement_weightConstraint - | directive # statement_directive; // NOT Core2 syntax. + | WCONS body? DOT weight_annotation # statement_weightConstraint; head : disjunction | choice; @@ -40,13 +38,19 @@ aggregate_element : basic_terms? (COLON naf_literals?)?; aggregate_function : AGGREGATE_COUNT | AGGREGATE_MAX | AGGREGATE_MIN | AGGREGATE_SUM; +weight_annotation : SQUARE_OPEN weight_at_level SQUARE_CLOSE; + weight_at_level : term (AT term)? (COMMA terms)?; naf_literals : naf_literal (COMMA naf_literals)?; -naf_literal : NAF? (external_atom | classical_literal | builtin_atom); +naf_literal : NAF? atom; + +atom : (classical_literal | builtin_atom); -classical_literal : MINUS? ID (PAREN_OPEN terms PAREN_CLOSE)?; +classical_literal : MINUS? basic_atom; + +basic_atom : ID (PAREN_OPEN terms PAREN_CLOSE)?; builtin_atom : term binop term; @@ -58,10 +62,9 @@ term : ID # term_const | ID (PAREN_OPEN terms? PAREN_CLOSE) # term_func | NUMBER # term_number | QUOTED_STRING # term_string - | VARIABLE # term_variable + | variable # term_variable | ANONYMOUS_VARIABLE # term_anonymousVariable | PAREN_OPEN term PAREN_CLOSE # term_parenthesisedTerm - | interval # term_interval // Syntax extension. | MINUS term # term_minusArithTerm | term POWER term # term_powerArithTerm | term (TIMES | DIV | MODULO) term # term_timesdivmodArithTerm @@ -69,22 +72,16 @@ term : ID # term_const | term BITXOR term # term_bitxorArithTerm ; -interval : lower = (NUMBER | VARIABLE) DOT DOT upper = (NUMBER | VARIABLE); // NOT Core2 syntax, but widespread - -external_atom : MINUS? AMPERSAND ID (SQUARE_OPEN input = terms SQUARE_CLOSE)? (PAREN_OPEN output = terms PAREN_CLOSE)?; // NOT Core2 syntax. - -directive : directive_enumeration; // NOT Core2 syntax, allows solver specific directives. Further directives shall be added here. - -directive_enumeration : SHARP 'enumeration_predicate_is' ID DOT; // NOT Core2 syntax, used for aggregate translation. - basic_terms : basic_term (COMMA basic_terms)? ; basic_term : ground_term | variable_term; ground_term : /*SYMBOLIC_CONSTANT*/ ID | QUOTED_STRING | MINUS? NUMBER; -variable_term : VARIABLE | ANONYMOUS_VARIABLE; +variable_term : variable | ANONYMOUS_VARIABLE; + +variable : VARIABLE; answer_set : CURLY_OPEN classical_literal? (COMMA classical_literal)* CURLY_CLOSE; -answer_sets: answer_set* EOF; \ No newline at end of file +answer_sets: answer_set* EOF; diff --git a/src/main/antlr/at/ac/tuwien/kr/alpha/antlr/ASPLexer.g4 b/src/main/antlr/at/ac/tuwien/kr/alpha/antlr/ASPLexer.g4 index a900ca342..cc5d5251f 100644 --- a/src/main/antlr/at/ac/tuwien/kr/alpha/antlr/ASPLexer.g4 +++ b/src/main/antlr/at/ac/tuwien/kr/alpha/antlr/ASPLexer.g4 @@ -40,6 +40,11 @@ AGGREGATE_MAX : '#max'; AGGREGATE_MIN : '#min'; AGGREGATE_SUM : '#sum'; +HEU_SIGN_T : 'T'; +HEU_SIGN_M : 'M'; +HEU_SIGN_F : 'F'; +HEU_BODY_SIGN : (HEU_SIGN_T | HEU_SIGN_M | HEU_SIGN_F)+; // needed for multi-char heuristic signs + ID : ('a'..'z') ( 'A'..'Z' | 'a'..'z' | '0'..'9' | '_' )*; VARIABLE : ('A'..'Z') ( 'A'..'Z' | 'a'..'z' | '0'..'9' | '_' )*; NUMBER : '0' | ('1'..'9') ('0'..'9')*; @@ -47,4 +52,4 @@ QUOTED_STRING : QUOTE ( '\\"' | . )*? QUOTE; COMMENT : '%' ~[\r\n]* -> channel(HIDDEN); MULTI_LINE_COMMEN : '%*' .*? '*%' -> channel(HIDDEN); -BLANK : [ \t\r\n\f]+ -> channel(HIDDEN); \ No newline at end of file +BLANK : [ \t\r\n\f]+ -> channel(HIDDEN); diff --git a/src/main/antlr/at/ac/tuwien/kr/alpha/antlr/AlphaASP.g4 b/src/main/antlr/at/ac/tuwien/kr/alpha/antlr/AlphaASP.g4 new file mode 100644 index 000000000..b3a299452 --- /dev/null +++ b/src/main/antlr/at/ac/tuwien/kr/alpha/antlr/AlphaASP.g4 @@ -0,0 +1,65 @@ +grammar AlphaASP; + +import ASPLexer, ASPCore2; + +/* The ASP-Core-2 grammar is defined in ASPCore2.g4. + * Here, it is extended a bit to parse widespread syntax (e.g. used by gringo/clasp). + * It is also extended by heuristic directives for Alpha. + */ + +program : statements? query? EOF; + +statements : statement+; + +statement : head DOT # statement_fact + | CONS body DOT # statement_constraint + | head CONS body DOT # statement_rule + | WCONS body? DOT weight_annotation # statement_weightConstraint + | directive # statement_directive; // NOT Core2 syntax. + +naf_literal : NAF? atom; + +atom : (external_atom | classical_literal | builtin_atom); + +external_atom : MINUS? AMPERSAND ID (SQUARE_OPEN input = terms SQUARE_CLOSE)? (PAREN_OPEN output = terms PAREN_CLOSE)?; // NOT Core2 syntax. + +term : ID # term_const + | ID (PAREN_OPEN terms? PAREN_CLOSE) # term_func + | NUMBER # term_number + | QUOTED_STRING # term_string + | variable # term_variable + | ANONYMOUS_VARIABLE # term_anonymousVariable + | PAREN_OPEN term PAREN_CLOSE # term_parenthesisedTerm + | interval # term_interval // Syntax extension. + | MINUS term # term_minusArithTerm + | term POWER term # term_powerArithTerm + | term (TIMES | DIV | MODULO) term # term_timesdivmodArithTerm + | term (PLUS | MINUS) term # term_plusminusArithTerm + | term BITXOR term # term_bitxorArithTerm + ; + +interval : (lowerNum=NUMBER | lowerVar=variable) DOT DOT (upperNum=NUMBER | upperVar=variable); // NOT Core2 syntax, but widespread + +directive : directive_enumeration | directive_heuristic; // NOT Core2 syntax, allows solver specific directives. Further directives shall be added here. + +directive_enumeration : SHARP 'enumeration_predicate_is' ID DOT; // NOT Core2 syntax, used for aggregate translation. + +directive_heuristic : SHARP 'heuristic' heuristic_head_atom (heuristic_body)? DOT heuristic_weight_annotation?; + +heuristic_head_atom : heuristic_head_sign? basic_atom; + +heuristic_head_sign : HEU_SIGN_T | HEU_SIGN_F; + +heuristic_body : COLON heuristic_body_literal (COMMA heuristic_body_literal)*; + +heuristic_body_literal : NAF? heuristic_body_atom | aggregate; + +heuristic_body_atom : (heuristic_body_sign? basic_atom) | builtin_atom | external_atom; + +heuristic_body_sign : (HEU_SIGN_T | HEU_SIGN_M | HEU_SIGN_F | HEU_BODY_SIGN)+; // single-char signs have their own classes in the lexer + +heuristic_weight_annotation : SQUARE_OPEN heuristic_weight_at_level SQUARE_CLOSE; + +heuristic_weight_at_level : term (AT term)?; + +variable : HEU_SIGN_T | HEU_SIGN_M | HEU_SIGN_F | HEU_BODY_SIGN | VARIABLE; // to be able to treat heuristic sign keywords as variable identifiers diff --git a/src/main/java/at/ac/tuwien/kr/alpha/Util.java b/src/main/java/at/ac/tuwien/kr/alpha/Util.java index d4efae105..1148ee142 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/Util.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/Util.java @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2016, the Alpha Team. +/* + * Copyright (c) 2016-2020, the Alpha Team. * All rights reserved. * * Additional changes made by Siemens. @@ -32,14 +32,16 @@ import org.stringtemplate.v4.STGroupFile; import java.io.ByteArrayInputStream; -import java.io.IOException; import java.net.URL; import java.nio.channels.Channels; import java.nio.channels.ReadableByteChannel; import java.nio.charset.StandardCharsets; import java.util.AbstractMap; +import java.util.Arrays; +import java.util.HashSet; import java.util.Iterator; import java.util.Map; +import java.util.Set; import java.util.SortedSet; import java.util.StringJoiner; import java.util.stream.Collector; @@ -74,7 +76,7 @@ public static > int compareSortedSets(Sorte return a.size() - b.size(); } - if (a.isEmpty() && b.isEmpty()) { + if (a.isEmpty()) { return 0; } @@ -114,7 +116,7 @@ public static Stream literate(Stream input) { }); } - public static ReadableByteChannel streamToChannel(Stream lines) throws IOException { + public static ReadableByteChannel streamToChannel(Stream lines) { return Channels.newChannel(new ByteArrayInputStream(lines.collect(Collectors.joining(System.lineSeparator())).getBytes(StandardCharsets.UTF_8))); } @@ -126,7 +128,7 @@ public static int arrayGrowthSize(int oldSize) { /** * Creates a stringtemplate (see {@link ST}) intended for rendering to ASP code from a given string. * The template uses "$" as attribute delimiter. - * + * * @param template the template string * @return an ST that is initialized with the given template string */ @@ -137,7 +139,7 @@ public static ST aspStringTemplate(String template) { /** * Loads a stringtemplate group intended for rendering ASP code from a file. * Templates are assumed to use "$" as attribute delimiter. - * + * * @param classPathUrl * @return */ @@ -145,5 +147,9 @@ public static STGroup loadStringTemplateGroup(URL url) { STGroupFile groupFile = new STGroupFile(url, "UTF-8", '$', '$'); return groupFile; } - + + @SafeVarargs + public static Set asSet(T... elements) { + return new HashSet<>(Arrays.asList(elements)); + } } diff --git a/src/main/java/at/ac/tuwien/kr/alpha/api/Alpha.java b/src/main/java/at/ac/tuwien/kr/alpha/api/Alpha.java index 26770a0e9..7efd51cea 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/api/Alpha.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/api/Alpha.java @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2017-2019, the Alpha Team. +/* + * Copyright (c) 2017-2021, the Alpha Team. * All rights reserved. * * Additional changes made by Siemens. @@ -63,6 +63,8 @@ import at.ac.tuwien.kr.alpha.grounder.transformation.StratifiedEvaluation; import at.ac.tuwien.kr.alpha.solver.Solver; import at.ac.tuwien.kr.alpha.solver.SolverFactory; +import at.ac.tuwien.kr.alpha.solver.heuristics.HeuristicsConfiguration; +import at.ac.tuwien.kr.alpha.solver.heuristics.HeuristicsConfigurationBuilder; public class Alpha { @@ -122,7 +124,7 @@ public InputProgram readProgramString(String aspString) { } public NormalProgram normalizeProgram(InputProgram program) { - return new NormalizeProgramTransformation(config.getAggregateRewritingConfig()).apply(program); + return new NormalizeProgramTransformation(config.getAggregateRewritingConfig(), config.isIgnoreDomspecHeuristics()).apply(program); } public InternalProgram performProgramPreprocessing(InternalProgram program) { @@ -183,7 +185,7 @@ public Stream solve(InternalProgram program) { /** * Solves the given program and filters answer sets based on the passed predicate. - * + * * @param program an {@link InternalProgram} to solve * @param filter {@link Predicate} filtering {@at.ac.tuwien.kr.alpha.common.Predicate}s in the returned answer sets * @return a Stream of answer sets representing stable models of the given program @@ -211,9 +213,20 @@ public Solver prepareSolverFor(InternalProgram program, java.util.function.Predi grounderHeuristicConfiguration.setAccumulatorEnabled(config.isGrounderAccumulatorEnabled()); AtomStore atomStore = new AtomStoreImpl(); - Grounder grounder = GrounderFactory.getInstance(grounderName, program, atomStore, filter, grounderHeuristicConfiguration, doDebugChecks); + HeuristicsConfiguration heuristicsConfiguration = buildHeuristicsConfiguration(program); + Grounder grounder = GrounderFactory.getInstance(grounderName, program, atomStore, heuristicsConfiguration, filter, grounderHeuristicConfiguration, doDebugChecks); + + return SolverFactory.getInstance(config, atomStore, grounder, heuristicsConfiguration); + } - return SolverFactory.getInstance(config, atomStore, grounder); + private HeuristicsConfiguration buildHeuristicsConfiguration(InternalProgram program) { + HeuristicsConfigurationBuilder heuristicsConfigurationBuilder = HeuristicsConfiguration.builder(); + heuristicsConfigurationBuilder.setHeuristic(this.config.getBranchingHeuristic()); + heuristicsConfigurationBuilder.setMomsStrategy(this.config.getMomsStrategy()); + final boolean existsHeuristicRule = program.existsHeuristicRule(); + heuristicsConfigurationBuilder.setRespectDomspecHeuristics(!this.config.isIgnoreDomspecHeuristics() && existsHeuristicRule); + heuristicsConfigurationBuilder.setReplayChoices(this.config.getReplayChoices()); + return heuristicsConfigurationBuilder.build(); } public SystemConfig getConfig() { diff --git a/src/main/java/at/ac/tuwien/kr/alpha/api/mapper/AnswerSetToWorkbookMapper.java b/src/main/java/at/ac/tuwien/kr/alpha/api/mapper/AnswerSetToWorkbookMapper.java index 0f6499728..e400d0433 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/api/mapper/AnswerSetToWorkbookMapper.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/api/mapper/AnswerSetToWorkbookMapper.java @@ -135,3 +135,4 @@ private Sheet createSheetWithHeader(Workbook wb, CellStyle headerStyle, String s } } + diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/Assignment.java b/src/main/java/at/ac/tuwien/kr/alpha/common/Assignment.java index b5aa1c6cf..28fe11eb8 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/common/Assignment.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/Assignment.java @@ -34,6 +34,8 @@ import static at.ac.tuwien.kr.alpha.common.Literals.atomOf; import static at.ac.tuwien.kr.alpha.common.Literals.isNegated; +import static at.ac.tuwien.kr.alpha.solver.ThriceTruth.FALSE; +import static at.ac.tuwien.kr.alpha.solver.ThriceTruth.TRUE; public interface Assignment { Entry get(int atom); @@ -125,6 +127,13 @@ interface Entry { int getDecisionLevel(); + /** + * TODO: rename to isSatisfied? (cf. issue #121) + * @param literal + * @return {@code true} iff {@code literal} is assigned, + * and either it is positive and its value is {@link ThriceTruth#TRUE} or {@link ThriceTruth#MBT} + * or it is negative and its value is {@link ThriceTruth#FALSE}. + */ default boolean isViolated(int literal) { final int atom = atomOf(literal); final ThriceTruth truth = getTruth(atom); @@ -134,6 +143,18 @@ default boolean isViolated(int literal) { } + /** + * Determines whether a given atom is unassigned or MBT. + * + * This method is usually used to determine if an atom is eligible for a choice. + * @param atom + * @return {@code true} iff {@code atom} is neither {@link ThriceTruth#FALSE} nor {@link ThriceTruth#TRUE}. + */ + default boolean isUnassignedOrMBT(int atom) { + final ThriceTruth truth = getTruth(atom); + return truth != FALSE && truth != TRUE; + } + default boolean violates(NoGood noGood) { // Check each NoGood, if it is violated for (Integer noGoodLiteral : noGood) { @@ -168,6 +189,11 @@ default boolean violates(NoGood noGood) { */ int getNumberOfAtomsAssignedSinceLastDecision(); + /** + * @return the number of active choice points + */ + int getNumberOfActiveChoicePoints(); + /** * Obtain a BasicAtom that is currently assigned MBT (but not TRUE). * @return some BasicAtom that is assigned MBT. diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/AtomToFunctionTermConverter.java b/src/main/java/at/ac/tuwien/kr/alpha/common/AtomToFunctionTermConverter.java new file mode 100644 index 000000000..a264eacc1 --- /dev/null +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/AtomToFunctionTermConverter.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2021 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package at.ac.tuwien.kr.alpha.common; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import at.ac.tuwien.kr.alpha.common.atoms.BasicAtom; +import at.ac.tuwien.kr.alpha.common.terms.FunctionTerm; +import at.ac.tuwien.kr.alpha.common.terms.Term; + +/** + * Converts {@link BasicAtom}s to {@link FunctionTerm}s and back + * (which is needed if the atom is to be nested in another term). + */ +public class AtomToFunctionTermConverter { + + /** + * A map of known predicates. + * Keys are predicates with default invisible properties. + * Values are predicates with "real" invisible properties (as first seen). + */ + private static final Map PREDICATES = new HashMap<>(); + + /** + * Converts the given atom to a function term. + * The {@link BasicAtom#getPredicate()} is stored so that, when the atom is converted back by {@link #toAtom(FunctionTerm)}, + * invisible properties such as {@link Predicate#isInternal()} are restored. + * + * @param atom the atom to convert + * @return a representation of the visible properties of the atom as a function term + */ + public static FunctionTerm toFunctionTerm(BasicAtom atom) { + rememberPredicate(atom.getPredicate()); + return FunctionTerm.getInstance(atom.getPredicate().getName(), new ArrayList<>(atom.getTerms())); + } + + /** + * Converts the given function term back to an atom. + * The {@link BasicAtom#getPredicate()} is recovered as it was saved by {@link #toFunctionTerm(BasicAtom)}. + * + * @param functionTerm the function term to convert + * @return the result of translating the function term back to a basic atom + */ + public static BasicAtom toAtom(FunctionTerm functionTerm) { + final String symbol = functionTerm.getSymbol(); + final List terms = functionTerm.getTerms(); + final int arity = terms.size(); + return new BasicAtom(recallPredicate(symbol, arity), terms); + } + + private static void rememberPredicate(Predicate value) { + final Predicate key = Predicate.getInstance(value.getName(), value.getArity()); + final Predicate existingValue = PREDICATES.get(key); + if (existingValue == null) { + PREDICATES.put(key, value); + } else if (!existingValue.equals(value)) { + throw new IllegalArgumentException("Predicate is used with two different sets of invisible properties: " + value); + } + } + + private static Predicate recallPredicate(String symbol, int arity) { + final Predicate key = Predicate.getInstance(symbol, arity); + final Predicate value = PREDICATES.get(key); + if (value == null) { + throw new IllegalArgumentException("Unknown predicate: " + key); + } + return value; + } + +} diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/Directive.java b/src/main/java/at/ac/tuwien/kr/alpha/common/Directive.java new file mode 100644 index 000000000..08b77885f --- /dev/null +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/Directive.java @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2018 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.common; + +/** + * Represents a statement starting with {@code #}, e.g. {@code #heuristic a : b.} + */ +public abstract class Directive { + +} diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/EnumerationDirective.java b/src/main/java/at/ac/tuwien/kr/alpha/common/EnumerationDirective.java new file mode 100644 index 000000000..2098cdef1 --- /dev/null +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/EnumerationDirective.java @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2018 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.common; + +public class EnumerationDirective extends Directive { + + private final String value; + + public EnumerationDirective(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + +} diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/HeuristicDirective.java b/src/main/java/at/ac/tuwien/kr/alpha/common/HeuristicDirective.java new file mode 100644 index 000000000..01440d967 --- /dev/null +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/HeuristicDirective.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2018, 2020, 2022, Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.common; + +import java.util.HashSet; +import java.util.Objects; +import java.util.Set; + +import at.ac.tuwien.kr.alpha.common.heuristics.HeuristicDirectiveAtom; +import at.ac.tuwien.kr.alpha.common.heuristics.HeuristicDirectiveBody; +import at.ac.tuwien.kr.alpha.common.terms.VariableTerm; + +/** + * Represents a heuristic directive, e.g. {@code #heuristic a : b. [2@1]} + */ +public class HeuristicDirective extends Directive { + + private final HeuristicDirectiveAtom head; + private final HeuristicDirectiveBody body; + private final WeightAtLevel weightAtLevel; + + public HeuristicDirective(HeuristicDirectiveAtom head, HeuristicDirectiveBody body, WeightAtLevel weightAtLevel) { + super(); + this.head = head; + this.body = body; + this.weightAtLevel = weightAtLevel; + } + + public HeuristicDirectiveAtom getHead() { + return head; + } + + public HeuristicDirectiveBody getBody() { + return body; + } + + public WeightAtLevel getWeightAtLevel() { + return weightAtLevel; + } + + /** + * Returns the set of all variables occurring in the heuristic directive. + */ + public Set getOccurringVariables() { + final Set variables = new HashSet<>(); + // assumption: all the variables are in the positive body due to safety + for (HeuristicDirectiveAtom atom : body.getBodyAtomsPositive()) { + variables.addAll(atom.getAtom().getOccurringVariables()); + } + return variables; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + HeuristicDirective that = (HeuristicDirective) o; + return head.equals(that.head) && + body.equals(that.body) && + weightAtLevel.equals(that.weightAtLevel); + } + + @Override + public int hashCode() { + return Objects.hash(head, body, weightAtLevel); + } + + @Override + public String toString() { + return "#heuristic " + head + " : " + body + ". [" + weightAtLevel + "]"; + } + +} diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/Literals.java b/src/main/java/at/ac/tuwien/kr/alpha/common/Literals.java index 8c703a54b..7324ff19e 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/common/Literals.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/Literals.java @@ -73,6 +73,10 @@ public static int atomToNegatedLiteral(int atom) { return negateLiteral(atomToLiteral(atom)); } + public static int signedAtomToLiteral(int signedAtom) { + return atomToLiteral(Math.abs(signedAtom), signedAtom > 0); + } + public static int positiveLiteral(int literal) { return literal & ~0x1; } diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/NoGood.java b/src/main/java/at/ac/tuwien/kr/alpha/common/NoGood.java index 84e70cd0e..61b98ed16 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/common/NoGood.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/NoGood.java @@ -31,12 +31,12 @@ import java.util.Arrays; import java.util.Iterator; -import java.util.List; import java.util.stream.IntStream; import static at.ac.tuwien.kr.alpha.Util.oops; -import static at.ac.tuwien.kr.alpha.common.Literals.*; -import static at.ac.tuwien.kr.alpha.common.NoGoodInterface.Type.*; +import static at.ac.tuwien.kr.alpha.common.Literals.isNegated; +import static at.ac.tuwien.kr.alpha.common.Literals.positiveLiteral; +import static at.ac.tuwien.kr.alpha.common.NoGoodInterface.Type.STATIC; public class NoGood implements NoGoodInterface, Comparable { public static final int HEAD = 0; @@ -54,7 +54,7 @@ public NoGood(Type type, int... literals) { this(type, literals, false); } - private NoGood(Type type, int[] literals, boolean head) { + NoGood(Type type, int[] literals, boolean head) { this.type = type; this.head = head; if (head && !isNegated(literals[0])) { @@ -81,59 +81,6 @@ protected NoGood(NoGood noGood) { this.head = noGood.head; this.type = noGood.type; } - - public static NoGood learnt(int... literals) { - return new NoGood(LEARNT, literals); - } - - public static NoGood headFirst(int... literals) { - return headFirst(STATIC, literals); - } - - public static NoGood headFirstInternal(int... literals) { - return headFirst(INTERNAL, literals); - } - - public static NoGood headFirst(Type type, int... literals) { - return new NoGood(type, literals, true); - } - - public static NoGood fact(int literal) { - return headFirst(literal); - } - - public static NoGood support(int headLiteral, int bodyRepresentingLiteral) { - return new NoGood(SUPPORT, headLiteral, negateLiteral(bodyRepresentingLiteral)); - } - - public static NoGood fromConstraint(List posLiterals, List negLiterals) { - return new NoGood(addPosNeg(new int[posLiterals.size() + negLiterals.size()], posLiterals, negLiterals, 0)); - } - - public static NoGood fromBody(List posLiterals, List negLiterals, int bodyRepresentingLiteral) { - return fromBody(STATIC, posLiterals, negLiterals, bodyRepresentingLiteral); - } - - public static NoGood fromBodyInternal(List posLiterals, List negLiterals, int bodyRepresentingLiteral) { - return fromBody(INTERNAL, posLiterals, negLiterals, bodyRepresentingLiteral); - } - - public static NoGood fromBody(Type type, List posLiterals, List negLiterals, int bodyRepresentingLiteral) { - int[] bodyLiterals = new int[posLiterals.size() + negLiterals.size() + 1]; - bodyLiterals[0] = negateLiteral(bodyRepresentingLiteral); - return NoGood.headFirst(type, addPosNeg(bodyLiterals, posLiterals, negLiterals, 1)); - } - - private static int[] addPosNeg(int[] literals, List posLiterals, List negLiterals, int offset) { - int i = offset; - for (Integer literal : posLiterals) { - literals[i++] = literal; - } - for (Integer literal : negLiterals) { - literals[i++] = negateLiteral(literal); - } - return literals; - } @Override public int size() { @@ -275,8 +222,7 @@ public String toString() { sb.append("{ "); for (int literal : literals) { - sb.append(isPositive(literal) ? "+" : "-"); - sb.append(atomOf(literal)); + sb.append(Literals.literalToString(literal)); sb.append(" "); } diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/NoGoodCreator.java b/src/main/java/at/ac/tuwien/kr/alpha/common/NoGoodCreator.java new file mode 100644 index 000000000..50edde687 --- /dev/null +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/NoGoodCreator.java @@ -0,0 +1,99 @@ +/** + * Copyright (c) 2016-2019, the Alpha Team. + * All rights reserved. + * + * Additional changes made by Siemens. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.common; + +import java.util.List; + +import static at.ac.tuwien.kr.alpha.common.Literals.negateLiteral; +import static at.ac.tuwien.kr.alpha.common.NoGoodInterface.Type; +import static at.ac.tuwien.kr.alpha.common.NoGoodInterface.Type.INTERNAL; +import static at.ac.tuwien.kr.alpha.common.NoGoodInterface.Type.LEARNT; +import static at.ac.tuwien.kr.alpha.common.NoGoodInterface.Type.STATIC; +import static at.ac.tuwien.kr.alpha.common.NoGoodInterface.Type.SUPPORT; + +/** + * Offers static methods to create {@link NoGood}s + */ +public class NoGoodCreator { + public static NoGood learnt(int... literals) { + return new NoGood(LEARNT, literals); + } + + public static NoGood internal(int... literals) { + return new NoGood(NoGood.Type.INTERNAL, literals); + } + + public static NoGood headFirst(int... literals) { + return headFirst(STATIC, literals); + } + + public static NoGood headFirstInternal(int... literals) { + return headFirst(INTERNAL, literals); + } + + public static NoGood headFirst(Type type, int... literals) { + return new NoGood(type, literals, true); + } + + public static NoGood fact(int literal) { + return headFirst(literal); + } + + public static NoGood support(int headLiteral, int bodyRepresentingLiteral) { + return new NoGood(SUPPORT, headLiteral, negateLiteral(bodyRepresentingLiteral)); + } + + public static NoGood fromConstraint(List posLiterals, List negLiterals) { + return new NoGood(addPosNeg(new int[posLiterals.size() + negLiterals.size()], posLiterals, negLiterals, 0)); + } + + public static NoGood fromBody(List posLiterals, List negLiterals, int bodyRepresentingLiteral) { + return fromBody(STATIC, posLiterals, negLiterals, bodyRepresentingLiteral); + } + + public static NoGood fromBodyInternal(List posLiterals, List negLiterals, int bodyRepresentingLiteral) { + return fromBody(INTERNAL, posLiterals, negLiterals, bodyRepresentingLiteral); + } + + public static NoGood fromBody(Type type, List posLiterals, List negLiterals, int bodyRepresentingLiteral) { + int[] bodyLiterals = new int[posLiterals.size() + negLiterals.size() + 1]; + bodyLiterals[0] = negateLiteral(bodyRepresentingLiteral); + return headFirst(type, addPosNeg(bodyLiterals, posLiterals, negLiterals, 1)); + } + + private static int[] addPosNeg(int[] literals, List posLiterals, List negLiterals, int offset) { + int i = offset; + for (Integer literal : posLiterals) { + literals[i++] = literal; + } + for (Integer literal : negLiterals) { + literals[i++] = negateLiteral(literal); + } + return literals; + } +} diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/Predicate.java b/src/main/java/at/ac/tuwien/kr/alpha/common/Predicate.java index e181c9200..99caf49b0 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/common/Predicate.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/Predicate.java @@ -1,8 +1,35 @@ +/* + * Copyright (c) 2016-2018, 2021, the Alpha Team. + * All rights reserved. + * + * Additional changes made by Siemens. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + package at.ac.tuwien.kr.alpha.common; -/** - * Copyright (c) 2016, the Alpha Team. - */ +import java.util.Objects; + public class Predicate implements Comparable { private static final Interner INTERNER = new Interner<>(); @@ -58,7 +85,11 @@ public boolean equals(Object o) { return false; } - return name != null ? name.equals(predicate.name) : predicate.name == null; + if (solverInternal != predicate.solverInternal) { + return false; + } + + return Objects.equals(name, predicate.name); } /** diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/Substitutable.java b/src/main/java/at/ac/tuwien/kr/alpha/common/Substitutable.java new file mode 100644 index 000000000..a42ea8ccf --- /dev/null +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/Substitutable.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2018 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.common; + +import at.ac.tuwien.kr.alpha.grounder.Substitution; + +/** + * A common interface for types to which a {@link Substitution} can be applied + * + */ +public interface Substitutable { + + T substitute(Substitution substitution); + +} diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/UniqueVariableNames.java b/src/main/java/at/ac/tuwien/kr/alpha/common/UniqueVariableNames.java new file mode 100644 index 000000000..a0db7a447 --- /dev/null +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/UniqueVariableNames.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2020-2022 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.common; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import at.ac.tuwien.kr.alpha.common.rule.BasicRule; +import at.ac.tuwien.kr.alpha.common.terms.VariableTerm; +import at.ac.tuwien.kr.alpha.grounder.Unifier; + +public class UniqueVariableNames { + + private final Map variablesToOccurrences = new HashMap<>(); + + /** + * This method standardises apart a heuristic directive and a rule. + * Computes a unifier to rename variables in a {@link BasicRule} so that they are different from all variables + * occurring in a given {@link HeuristicDirective}. All variable names in the directive stay the same, and variable + * names in the rule stay the same if possible. + * @param heuristicDirective a heuristic directive + * @param rule a rule + * @return a unifier to be applied to the rule. + */ + public Unifier makeVariableNamesUnique(HeuristicDirective heuristicDirective, BasicRule rule) { + for (VariableTerm variable : heuristicDirective.getOccurringVariables()) { + variablesToOccurrences.put(variable, 0); + } + return renameVariablesIfAlreadyUsed(rule.getOccurringVariables()); + } + + private Unifier renameVariablesIfAlreadyUsed(Set variables) { + final Unifier unifier = new Unifier(); + for (VariableTerm variable : variables) { + if (variablesToOccurrences.containsKey(variable)) { + VariableTerm newVariable; + do { + newVariable = VariableTerm.getInstance(variable.toString() + "_" + (variablesToOccurrences.computeIfPresent(variable, (v, o) -> o + 1))); + } while (variablesToOccurrences.containsKey(newVariable)); + unifier.put(variable, newVariable); + } else { + variablesToOccurrences.put(variable, 0); + } + } + return unifier; + } + +} diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/WeightAtLevel.java b/src/main/java/at/ac/tuwien/kr/alpha/common/WeightAtLevel.java new file mode 100644 index 000000000..b5df8470e --- /dev/null +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/WeightAtLevel.java @@ -0,0 +1,97 @@ +/** + * Copyright (c) 2018-2019 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.common; + +import at.ac.tuwien.kr.alpha.common.terms.ConstantTerm; +import at.ac.tuwien.kr.alpha.common.terms.Term; +import at.ac.tuwien.kr.alpha.grounder.Substitution; + +/** + * Represents a weight-level pair defined within an annotation (either for heuristic values or for a weak constraint) + * + */ +public class WeightAtLevel implements Substitutable { + + public static final int DEFAULT_WEIGHT = 0; + public static final int DEFAULT_LEVEL = 0; + public static final Term DEFAULT_WEIGHT_TERM = ConstantTerm.getInstance(DEFAULT_WEIGHT); + public static final Term DEFAULT_LEVEL_TERM = ConstantTerm.getInstance(DEFAULT_LEVEL); + + private Term weight; + private Term level; + + public WeightAtLevel(Term weight, Term level) { + this.weight = weight != null ? weight : DEFAULT_WEIGHT_TERM; + this.level = level != null ? level : DEFAULT_LEVEL_TERM; + } + + public Term getWeight() { + return weight; + } + + public Term getLevel() { + return level; + } + + @Override + public WeightAtLevel substitute(Substitution substitution) { + return new WeightAtLevel(weight.substitute(substitution), level.substitute(substitution)); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append(weight); + if (level != null) { + sb.append("@"); + sb.append(level); + } + return sb.toString(); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + WeightAtLevel that = (WeightAtLevel) o; + + if (weight != that.weight) { + return false; + } + return level.equals(that.level); + } + + @Override + public int hashCode() { + return 31 * weight.hashCode() + level.hashCode(); + } + +} diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/atoms/AggregateAtom.java b/src/main/java/at/ac/tuwien/kr/alpha/common/atoms/AggregateAtom.java index 46f4aff18..8331deb68 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/common/atoms/AggregateAtom.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/atoms/AggregateAtom.java @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2017-2019, the Alpha Team. +/* + * Copyright (c) 2017-2022, the Alpha Team. * All rights reserved. * * Additional changes made by Siemens. @@ -27,19 +27,20 @@ */ package at.ac.tuwien.kr.alpha.common.atoms; -import static at.ac.tuwien.kr.alpha.Util.join; -import static at.ac.tuwien.kr.alpha.Util.oops; - import java.util.Collections; import java.util.LinkedList; import java.util.List; import at.ac.tuwien.kr.alpha.common.ComparisonOperator; import at.ac.tuwien.kr.alpha.common.Predicate; +import at.ac.tuwien.kr.alpha.common.Substitutable; import at.ac.tuwien.kr.alpha.common.terms.Term; import at.ac.tuwien.kr.alpha.common.terms.VariableTerm; import at.ac.tuwien.kr.alpha.grounder.Substitution; +import static at.ac.tuwien.kr.alpha.Util.join; +import static at.ac.tuwien.kr.alpha.Util.oops; + public class AggregateAtom extends Atom { private final ComparisonOperator lowerBoundOperator; @@ -47,7 +48,7 @@ public class AggregateAtom extends Atom { private final ComparisonOperator upperBoundOperator; private final Term upperBoundTerm; private final AggregateFunctionSymbol aggregatefunction; - private final List aggregateElements; + final List aggregateElements; public AggregateAtom(ComparisonOperator lowerBoundOperator, Term lowerBoundTerm, ComparisonOperator upperBoundOperator, Term upperBoundTerm, AggregateFunctionSymbol aggregatefunction, List aggregateElements) { this.lowerBoundOperator = lowerBoundOperator; @@ -111,7 +112,14 @@ public List getAggregateVariables() { @Override public AggregateAtom substitute(Substitution substitution) { - throw new UnsupportedOperationException("Cannot apply substitution to AggregateAtom!"); + return new AggregateAtom( + lowerBoundOperator, + substitution.substituteIfNotNull(lowerBoundTerm), + upperBoundOperator, + substitution.substituteIfNotNull(upperBoundTerm), + aggregatefunction, + substitution.substituteAll(aggregateElements) + ); } @Override @@ -192,7 +200,7 @@ public enum AggregateFunctionSymbol { SUM } - public static class AggregateElement { + public static class AggregateElement implements Substitutable { final List elementTerms; final List elementLiterals; @@ -237,6 +245,11 @@ public List getOccurringVariables() { return occurringVariables; } + @Override + public AggregateElement substitute(Substitution substitution) { + return new AggregateElement(substitution.substituteAll(elementTerms), substitution.substituteAll(elementLiterals)); + } + @Override public boolean equals(Object o) { if (this == o) { diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/atoms/AggregateLiteral.java b/src/main/java/at/ac/tuwien/kr/alpha/common/atoms/AggregateLiteral.java index 087b191c6..9aed0c66d 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/common/atoms/AggregateLiteral.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/atoms/AggregateLiteral.java @@ -1,16 +1,40 @@ +/* + * Copyright (c) 2018-2020, 2022, the Alpha Team. + * All rights reserved. + * + * Additional changes made by Siemens. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package at.ac.tuwien.kr.alpha.common.atoms; +import java.util.HashSet; +import java.util.Set; + import at.ac.tuwien.kr.alpha.common.ComparisonOperator; import at.ac.tuwien.kr.alpha.common.terms.Term; import at.ac.tuwien.kr.alpha.common.terms.VariableTerm; import at.ac.tuwien.kr.alpha.grounder.Substitution; -import java.util.HashSet; -import java.util.Set; - -/** - * Copyright (c) 2018, the Alpha Team. - */ public class AggregateLiteral extends Literal { public AggregateLiteral(AggregateAtom atom, boolean positive) { super(atom, positive); @@ -53,6 +77,15 @@ public Set getNonBindingVariables() { throw new UnsupportedOperationException(); } + @Override + public Set getOccurringVariables() { + final Set variables = new HashSet<>(); + for (AggregateAtom.AggregateElement aggregateElement : getAtom().aggregateElements) { + variables.addAll(aggregateElement.getOccurringVariables()); + } + return variables; + } + private static VariableTerm boundBindingVariable(ComparisonOperator op, Term bound, boolean positive) { boolean isNormalizedEquality = op == ComparisonOperator.EQ && positive || op == ComparisonOperator.NE && !positive; if (isNormalizedEquality && bound instanceof VariableTerm) { diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/atoms/Atom.java b/src/main/java/at/ac/tuwien/kr/alpha/common/atoms/Atom.java index 7c5b32f5e..d8cb07ede 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/common/atoms/Atom.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/atoms/Atom.java @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2016-2020, the Alpha Team. +/* + * Copyright (c) 2016-2021, the Alpha Team. * All rights reserved. * * Additional changes made by Siemens. @@ -27,19 +27,20 @@ */ package at.ac.tuwien.kr.alpha.common.atoms; +import java.util.List; +import java.util.Set; + import at.ac.tuwien.kr.alpha.common.Predicate; +import at.ac.tuwien.kr.alpha.common.Substitutable; import at.ac.tuwien.kr.alpha.common.terms.Term; import at.ac.tuwien.kr.alpha.common.terms.VariableTerm; import at.ac.tuwien.kr.alpha.grounder.Substitution; import at.ac.tuwien.kr.alpha.grounder.Unifier; -import java.util.List; -import java.util.Set; - /** * An Atom is the common superclass of all representations of ASP atoms used by Alpha. */ -public abstract class Atom implements Comparable { +public abstract class Atom implements Comparable, Substitutable { public abstract Predicate getPredicate(); diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/atoms/BasicAtom.java b/src/main/java/at/ac/tuwien/kr/alpha/common/atoms/BasicAtom.java index 98c7954aa..9ae42ab67 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/common/atoms/BasicAtom.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/atoms/BasicAtom.java @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2016-2020, the Alpha Team. +/* + * Copyright (c) 2016-2021, the Alpha Team. * All rights reserved. * * Additional changes made by Siemens. @@ -27,8 +27,6 @@ */ package at.ac.tuwien.kr.alpha.common.atoms; -import static at.ac.tuwien.kr.alpha.Util.join; - import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -38,12 +36,14 @@ import at.ac.tuwien.kr.alpha.common.terms.Term; import at.ac.tuwien.kr.alpha.grounder.Substitution; +import static at.ac.tuwien.kr.alpha.Util.join; + /** * Represents ordinary ASP atoms. */ public class BasicAtom extends Atom implements VariableNormalizableAtom { - private final Predicate predicate; - private final List terms; + protected final Predicate predicate; + protected final List terms; private final boolean ground; /** diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/atoms/Literal.java b/src/main/java/at/ac/tuwien/kr/alpha/common/atoms/Literal.java index 907a38b04..b8a162e87 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/common/atoms/Literal.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/atoms/Literal.java @@ -8,11 +8,11 @@ * modification, are permitted provided that the following conditions are met: * * 1) Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. + * list of conditions and the following disclaimer. * * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -28,6 +28,7 @@ package at.ac.tuwien.kr.alpha.common.atoms; import at.ac.tuwien.kr.alpha.common.Predicate; +import at.ac.tuwien.kr.alpha.common.Substitutable; import at.ac.tuwien.kr.alpha.common.terms.Term; import at.ac.tuwien.kr.alpha.common.terms.VariableTerm; import at.ac.tuwien.kr.alpha.grounder.Substitution; @@ -41,7 +42,7 @@ * * Copyright (c) 2017-2018, the Alpha Team. */ -public abstract class Literal { +public abstract class Literal implements Substitutable { protected final Atom atom; protected final boolean positive; diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/heuristics/HeuristicDirectiveAtom.java b/src/main/java/at/ac/tuwien/kr/alpha/common/heuristics/HeuristicDirectiveAtom.java new file mode 100644 index 000000000..c0ffaac8b --- /dev/null +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/heuristics/HeuristicDirectiveAtom.java @@ -0,0 +1,153 @@ +/* + * Copyright (c) 2021 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package at.ac.tuwien.kr.alpha.common.heuristics; + +import java.util.Collections; +import java.util.Objects; +import java.util.Set; + +import org.apache.commons.lang3.StringUtils; + +import at.ac.tuwien.kr.alpha.common.Substitutable; +import at.ac.tuwien.kr.alpha.common.atoms.Atom; +import at.ac.tuwien.kr.alpha.common.atoms.BasicAtom; +import at.ac.tuwien.kr.alpha.grounder.Substitution; +import at.ac.tuwien.kr.alpha.solver.ThriceTruth; + +import static at.ac.tuwien.kr.alpha.Util.asSet; +import static at.ac.tuwien.kr.alpha.Util.oops; +import static at.ac.tuwien.kr.alpha.solver.ThriceTruth.MBT; +import static at.ac.tuwien.kr.alpha.solver.ThriceTruth.TRUE; + +public class HeuristicDirectiveAtom implements Comparable, Substitutable { + + public static final ThriceTruth DEFAULT_HEAD_SIGN = TRUE; + public static final Set DEFAULT_BODY_SIGNS = asSet(TRUE, MBT); + public static final Set SIGNS_T = asSet(TRUE); + + private final Set signs; + private final Atom atom; + + private HeuristicDirectiveAtom(Set signs, Atom atom) { + if (atom instanceof BasicAtom) { + this.signs = Collections.unmodifiableSet(signs); + } else { + this.signs = null; + } + this.atom = atom; + } + + public static HeuristicDirectiveAtom head(ThriceTruth sign, BasicAtom atom) { + if (sign == ThriceTruth.MBT) { + throw new IllegalArgumentException("M sign in heuristic head"); + } + if (sign == null) { + sign = DEFAULT_HEAD_SIGN; + } + return new HeuristicDirectiveAtom(Collections.singleton(sign), atom); + } + + public static HeuristicDirectiveAtom head(BasicAtom atom) { + return head(null, atom); + } + + public static HeuristicDirectiveAtom body(Set signs, Atom atom) { + if (signs == null || signs.isEmpty()) { + signs = DEFAULT_BODY_SIGNS; + } else if (!(atom instanceof BasicAtom)) { + throw oops("Non-basic heuristic directive atom with non-empty sign list"); + } + return new HeuristicDirectiveAtom(signs, atom); + } + + public static HeuristicDirectiveAtom body(Atom atom) { + return body(null, atom); + } + + public Set getSigns() { + return signs; + } + + public Atom getAtom() { + return atom; + } + + @Override + public HeuristicDirectiveAtom substitute(Substitution substitution) { + return new HeuristicDirectiveAtom(signs, atom.substitute(substitution)); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + HeuristicDirectiveAtom that = (HeuristicDirectiveAtom) o; + if (this.signs == null || that.signs == null) { + return this.signs == that.signs && this.atom.equals(that.atom); + } + return HeuristicSignSetUtil.toString(this.signs).equals(HeuristicSignSetUtil.toString(that.signs)) && + this.atom.equals(that.atom); + } + + @Override + public int hashCode() { + return Objects.hash(signs, atom); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + if (signs != null) { + for (ThriceTruth truth : ThriceTruth.values()) { + if (signs.contains(truth)) { + sb.append(truth); + } + } + if (!signs.isEmpty()) { + sb.append(" "); + } + } + sb.append(atom); + return sb.toString(); + } + + @Override + public int compareTo(HeuristicDirectiveAtom that) { + final String strSigns1 = this.signs == null ? null : HeuristicSignSetUtil.toString(this.signs); + final String strSigns2 = that.signs == null ? null : HeuristicSignSetUtil.toString(that.signs); + final int diffSignSets = StringUtils.compare(strSigns1, strSigns2); + if (diffSignSets != 0) { + return diffSignSets; + } + // transforming atoms to strings for comparison due to limitations of Term#priority (TODO: why these limitations?) + return StringUtils.compare(this.atom.toString(), that.atom.toString()); + } +} diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/heuristics/HeuristicDirectiveBody.java b/src/main/java/at/ac/tuwien/kr/alpha/common/heuristics/HeuristicDirectiveBody.java new file mode 100644 index 000000000..b3654bac3 --- /dev/null +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/heuristics/HeuristicDirectiveBody.java @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2020-2021 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package at.ac.tuwien.kr.alpha.common.heuristics; + +import at.ac.tuwien.kr.alpha.common.Substitutable; +import at.ac.tuwien.kr.alpha.common.atoms.FixedInterpretationLiteral; +import at.ac.tuwien.kr.alpha.common.atoms.Literal; +import at.ac.tuwien.kr.alpha.grounder.Substitution; +import at.ac.tuwien.kr.alpha.solver.ThriceTruth; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; + +import static at.ac.tuwien.kr.alpha.Util.join; + +public class HeuristicDirectiveBody implements Substitutable { + + private final Set bodyAtomsPositive; + private final Set bodyAtomsNegative; + + public HeuristicDirectiveBody(Collection bodyAtomsPositive, Collection bodyAtomsNegative) { + // transform list to linked set to enable equality check with set semantics: + this.bodyAtomsPositive = Collections.unmodifiableSet(new LinkedHashSet<>(bodyAtomsPositive)); + this.bodyAtomsNegative = Collections.unmodifiableSet(new LinkedHashSet<>(bodyAtomsNegative)); + } + + public HeuristicDirectiveBody(List bodyLiterals) { + this( + bodyLiterals.stream().filter(l -> !l.isNegated()).map(HeuristicDirectiveLiteral::getAtom).collect(Collectors.toList()), + bodyLiterals.stream().filter(l -> l.isNegated()).map(HeuristicDirectiveLiteral::getAtom).collect(Collectors.toList()) + ); + } + + public Collection getBodyAtomsPositive() { + return bodyAtomsPositive; + } + + public Collection getBodyAtomsNegative() { + return bodyAtomsNegative; + } + + /** + * Returns relevant parts of this body as a rule body, which is used to represent heuristic directives as rules. + * @return the basic atoms in the positive part of this body whose heuristic signs do not include F, without heuristic signs; and all non-basic literals in this body + */ + public List toReducedRuleBody() { + final List relevantLiterals = new ArrayList<>(); + for (HeuristicDirectiveAtom heuristicDirectiveAtom : bodyAtomsPositive) { + final Literal literal = heuristicDirectiveAtom.getAtom().toLiteral(); + if (literal instanceof FixedInterpretationLiteral) { + relevantLiterals.add(literal); + } else { + final Set signs = heuristicDirectiveAtom.getSigns(); + if (signs == null || !signs.contains(ThriceTruth.FALSE)) { + relevantLiterals.add(literal); + } + } + } + for (HeuristicDirectiveAtom heuristicDirectiveAtom : bodyAtomsNegative) { + final Literal literal = heuristicDirectiveAtom.getAtom().toLiteral(false); + if (literal instanceof FixedInterpretationLiteral) { + relevantLiterals.add(literal); + } + } + return relevantLiterals; + } + + @Override + public HeuristicDirectiveBody substitute(Substitution substitution) { + return new HeuristicDirectiveBody(substitution.substituteAll(bodyAtomsPositive), substitution.substituteAll(bodyAtomsNegative)); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + HeuristicDirectiveBody that = (HeuristicDirectiveBody) o; + return bodyAtomsPositive.equals(that.bodyAtomsPositive) && + bodyAtomsNegative.equals(that.bodyAtomsNegative); + } + + @Override + public int hashCode() { + return Objects.hash(bodyAtomsPositive, bodyAtomsNegative); + } + + @Override + public String toString() { + return join( + join( + "", + bodyAtomsPositive, + bodyAtomsNegative.size() > 0 ? ", not " : "" + ), + bodyAtomsNegative, + ", not ", + "" + ); + } +} diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/heuristics/HeuristicDirectiveLiteral.java b/src/main/java/at/ac/tuwien/kr/alpha/common/heuristics/HeuristicDirectiveLiteral.java new file mode 100644 index 000000000..f82550875 --- /dev/null +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/heuristics/HeuristicDirectiveLiteral.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2020 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package at.ac.tuwien.kr.alpha.common.heuristics; + +import java.util.Objects; + +public class HeuristicDirectiveLiteral { + + private final HeuristicDirectiveAtom atom; + private final boolean positive; + + public HeuristicDirectiveLiteral(HeuristicDirectiveAtom atom, boolean positive) { + this.atom = atom; + this.positive = positive; + } + + public boolean isNegated() { + return !positive; + } + + public HeuristicDirectiveAtom getAtom() { + return atom; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + HeuristicDirectiveLiteral that = (HeuristicDirectiveLiteral) o; + return atom.equals(that.atom) && + positive == that.positive; + } + + @Override + public int hashCode() { + return Objects.hash(atom, positive); + } + + @Override + public String toString() { + return (positive ? "" : "not ") + atom.toString(); + } +} diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/heuristics/HeuristicDirectiveValues.java b/src/main/java/at/ac/tuwien/kr/alpha/common/heuristics/HeuristicDirectiveValues.java new file mode 100644 index 000000000..bebf4eb57 --- /dev/null +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/heuristics/HeuristicDirectiveValues.java @@ -0,0 +1,138 @@ +/* + * Copyright (c) 2018-2021 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.common.heuristics; + +import java.util.Comparator; +import java.util.Objects; + +import at.ac.tuwien.kr.alpha.common.HeuristicDirective; +import at.ac.tuwien.kr.alpha.common.WeightAtLevel; +import at.ac.tuwien.kr.alpha.common.atoms.BasicAtom; +import at.ac.tuwien.kr.alpha.common.terms.ConstantTerm; +import at.ac.tuwien.kr.alpha.grounder.atoms.HeuristicAtom; +import at.ac.tuwien.kr.alpha.solver.ThriceTruth; + +import static at.ac.tuwien.kr.alpha.common.AtomToFunctionTermConverter.toAtom; + +/** + * Holds values defined by a {@link HeuristicDirective} to steer domain-specific heuristic choice for a single ground heuristic directive. + * + */ +public class HeuristicDirectiveValues { + + private final int headAtomId; + private final BasicAtom groundHeadAtom; + private final int weight; + private final int level; + private final boolean sign; + + public HeuristicDirectiveValues(int headAtomId, BasicAtom groundHeadAtom, int weight, int level, boolean sign) { + this.headAtomId = headAtomId; + this.groundHeadAtom = groundHeadAtom; + this.weight = weight; + this.level = level; + this.sign = sign; + } + + public int getHeadAtomId() { + return headAtomId; + } + + public BasicAtom getGroundHeadAtom() { + return groundHeadAtom; + } + + public int getWeight() { + return weight; + } + + public int getLevel() { + return level; + } + + public boolean getSign() { + return sign; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + HeuristicDirectiveValues that = (HeuristicDirectiveValues) o; + return headAtomId == that.headAtomId && + weight == that.weight && + level == that.level && + groundHeadAtom.equals(that.groundHeadAtom) && + sign == that.sign; + } + + @Override + public int hashCode() { + return Objects.hash(headAtomId, groundHeadAtom, weight, level, sign); + } + + @Override + public String toString() { + return String.format(ThriceTruth.valueOf(sign) + " %d [%d@%d]", headAtomId, weight, level); + } + + /** + * Reads values from a ground {@link HeuristicAtom}. + * @param groundHeuristicAtom a ground heuristic atom + * @param headAtomId the ID of the head atom this heuristic applies to + * @return a new instance of {@link HeuristicDirectiveValues} with the values from {@code groundHeuristicAtom}. + */ + @SuppressWarnings("unchecked") + public static HeuristicDirectiveValues fromHeuristicAtom(HeuristicAtom groundHeuristicAtom, int headAtomId) { + WeightAtLevel weightAtLevel = groundHeuristicAtom.getWeightAtLevel(); + BasicAtom groundHeuristicHead = toAtom(groundHeuristicAtom.getHeadAtom()); + return new HeuristicDirectiveValues(headAtomId, groundHeuristicHead, ((ConstantTerm)weightAtLevel.getWeight()).getObject(), ((ConstantTerm)weightAtLevel.getLevel()).getObject(), groundHeuristicAtom.getHeadSign().toBoolean()); + } + + public static class PriorityComparator implements Comparator { + + @Override + public int compare(HeuristicDirectiveValues v1, HeuristicDirectiveValues v2) { + int difference = v1.level - v2.level; + if (difference == 0) { + difference = v1.weight - v2.weight; + } + if (difference == 0) { + difference = v1.headAtomId - v2.headAtomId; + } + if (difference == 0) { + difference = Boolean.compare(v1.sign, v2.sign); + } + return difference; + } + + } + +} diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/heuristics/HeuristicSignSetUtil.java b/src/main/java/at/ac/tuwien/kr/alpha/common/heuristics/HeuristicSignSetUtil.java new file mode 100644 index 000000000..19a3a41ea --- /dev/null +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/heuristics/HeuristicSignSetUtil.java @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2021 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package at.ac.tuwien.kr.alpha.common.heuristics; + +import at.ac.tuwien.kr.alpha.solver.ThriceTruth; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import static at.ac.tuwien.kr.alpha.Util.asSet; +import static at.ac.tuwien.kr.alpha.solver.ThriceTruth.FALSE; +import static at.ac.tuwien.kr.alpha.solver.ThriceTruth.MBT; +import static at.ac.tuwien.kr.alpha.solver.ThriceTruth.TRUE; + +public class HeuristicSignSetUtil { + + public static final int NUM_SIGN_SETS = 4; + + public static final Set SET_T = asSet(TRUE); + public static final Set SET_TM = asSet(TRUE, MBT); + public static final Set SET_M = asSet(MBT); + public static final Set SET_F = asSet(FALSE); + + private static final String NAME_SIGN_SET_T = "t"; + private static final String NAME_SIGN_SET_TM = "tm"; + private static final String NAME_SIGN_SET_M = "m"; + private static final String NAME_SIGN_SET_F = "f"; + + public static final int IDX_T = 0; + public static final int IDX_TM = 1; + public static final int IDX_M = 2; + public static final int IDX_F = 3; + + private static final Map, String> SIGN_SET_TO_NAME = new HashMap<>(); + private static final Map> NAME_TO_SIGN_SET = new HashMap<>(); + private static final Map, Integer> SIGN_SET_TO_IDX = new HashMap<>(); + private static final Map> IDX_TO_SIGN_SET = new HashMap<>(); + + static { + SIGN_SET_TO_NAME.put(SET_T, NAME_SIGN_SET_T); + SIGN_SET_TO_NAME.put(SET_TM, NAME_SIGN_SET_TM); + SIGN_SET_TO_NAME.put(SET_M, NAME_SIGN_SET_M); + SIGN_SET_TO_NAME.put(SET_F, NAME_SIGN_SET_F); + + NAME_TO_SIGN_SET.put(NAME_SIGN_SET_T, SET_T); + NAME_TO_SIGN_SET.put(NAME_SIGN_SET_TM, SET_TM); + NAME_TO_SIGN_SET.put(NAME_SIGN_SET_M, SET_M); + NAME_TO_SIGN_SET.put(NAME_SIGN_SET_F, SET_F); + + SIGN_SET_TO_IDX.put(SET_T, IDX_T); + SIGN_SET_TO_IDX.put(SET_TM, IDX_TM); + SIGN_SET_TO_IDX.put(SET_M, IDX_M); + SIGN_SET_TO_IDX.put(SET_F, IDX_F); + + IDX_TO_SIGN_SET.put(IDX_T, SET_T); + IDX_TO_SIGN_SET.put(IDX_TM, SET_TM); + IDX_TO_SIGN_SET.put(IDX_M, SET_M); + IDX_TO_SIGN_SET.put(IDX_F, SET_F); + } + + public static String toName(Set signSet) { + return SIGN_SET_TO_NAME.get(signSet); + } + + /** + * Transforms the given sign set to its canonical string representation. + * In contrast to {@link #toName(Set)}, this works for arbitrary sign sets, not only for the standard ones. + */ + public static String toString(Set signSet) { + final StringBuilder string = new StringBuilder(); + if (signSet.contains(FALSE)) { + string.append(NAME_SIGN_SET_F); + } + if (signSet.contains(MBT)) { + string.append(NAME_SIGN_SET_M); + } + if (signSet.contains(TRUE)) { + string.append(NAME_SIGN_SET_T); + } + return string.toString(); + } + + public static Set toSignSet(String name) { + return NAME_TO_SIGN_SET.get(name.toLowerCase()); + } + + public static int getIndex(Set signSet) { + return SIGN_SET_TO_IDX.get(signSet); + } + + public static Set getSignSetByIndex(int idx) { + return IDX_TO_SIGN_SET.get(idx); + } + + /** + * Only the following sign sets are allowed and processable: T, TM, M, F. + * @param signSet the sign set to check + * @return {@code true} iff the given sign set is allowed and processable + */ + public static boolean isProcessable(Set signSet) { + return SIGN_SET_TO_NAME.containsKey(signSet); + } + + public static boolean isF(Set signSet) { + return signSet.size() == 1 && signSet.iterator().next().equals(ThriceTruth.FALSE); + } +} diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/program/AbstractProgram.java b/src/main/java/at/ac/tuwien/kr/alpha/common/program/AbstractProgram.java index 05fb07ea1..39ac732e2 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/common/program/AbstractProgram.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/program/AbstractProgram.java @@ -9,6 +9,8 @@ import java.util.Collections; import java.util.List; +import static at.ac.tuwien.kr.alpha.Util.join; + /** * The parent type for all kinds of programs. Defines a program's basic structure (facts + rules + inlineDirectives) * @@ -42,11 +44,19 @@ public InlineDirectives getInlineDirectives() { @Override public String toString() { final String ls = System.lineSeparator(); - final String result = facts.isEmpty() ? "" : Util.join("", facts, "." + ls, "." + ls); + String result = facts.isEmpty() ? "" : Util.join("", facts, "." + ls, "." + ls); + if (rules.isEmpty()) { return result; } - return Util.join(result, rules, ls, ls); + + result = join(result, rules, ls, ls); + + if (inlineDirectives == null || inlineDirectives.isEmpty()) { + return result; + } + + return join(result, inlineDirectives.getDirectives(), ls, ls); } } diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/program/Facts.java b/src/main/java/at/ac/tuwien/kr/alpha/common/program/Facts.java new file mode 100644 index 000000000..49babbb01 --- /dev/null +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/program/Facts.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2020, the Alpha Team. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.common.program; + +import at.ac.tuwien.kr.alpha.common.Predicate; +import at.ac.tuwien.kr.alpha.common.atoms.Atom; +import at.ac.tuwien.kr.alpha.grounder.FactIntervalEvaluator; +import at.ac.tuwien.kr.alpha.grounder.Instance; + +import java.util.Collections; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +public class Facts { + + private final Map> factsByPredicate = new LinkedHashMap<>(); + + void add(Atom fact) { + List tmpInstances = FactIntervalEvaluator.constructFactInstances(fact); + Predicate tmpPredicate = fact.getPredicate(); + factsByPredicate.putIfAbsent(tmpPredicate, new LinkedHashSet<>()); + factsByPredicate.get(tmpPredicate).addAll(tmpInstances); + } + + public Set>> entrySet() { + return Collections.unmodifiableSet(factsByPredicate.entrySet()); + } + + public Iterable getPredicates() { + return Collections.unmodifiableSet(factsByPredicate.keySet()); + } + + public Set get(Predicate predicate) { + final Set instances = factsByPredicate.get(predicate); + return instances != null ? Collections.unmodifiableSet(instances) : Collections.emptySet(); + } + + public boolean isFact(Atom groundAtom) { + final Set factInstances = factsByPredicate.get(groundAtom.getPredicate()); + return factInstances != null && factInstances.contains(new Instance(groundAtom.getTerms())); + } + + public boolean isEmpty() { + return factsByPredicate.isEmpty(); + } +} diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/program/InternalProgram.java b/src/main/java/at/ac/tuwien/kr/alpha/common/program/InternalProgram.java index 0a710e48b..2da294eff 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/common/program/InternalProgram.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/program/InternalProgram.java @@ -1,15 +1,39 @@ +/* + * Copyright (c) 2017-2021, the Alpha Team. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package at.ac.tuwien.kr.alpha.common.program; import at.ac.tuwien.kr.alpha.common.Predicate; import at.ac.tuwien.kr.alpha.common.atoms.Atom; import at.ac.tuwien.kr.alpha.common.rule.InternalRule; import at.ac.tuwien.kr.alpha.common.rule.NormalRule; -import at.ac.tuwien.kr.alpha.grounder.FactIntervalEvaluator; -import at.ac.tuwien.kr.alpha.grounder.Instance; import org.apache.commons.lang3.tuple.ImmutablePair; import java.util.ArrayList; import java.util.Collections; +import java.util.HashSet; import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; @@ -25,8 +49,9 @@ public class InternalProgram extends AbstractProgram { private final Map> predicateDefiningRules = new LinkedHashMap<>(); - private final Map> factsByPredicate = new LinkedHashMap<>(); + private final Facts facts = new Facts(); private final Map rulesById = new LinkedHashMap<>(); + private boolean existsHeuristicRule; public InternalProgram(List rules, List facts) { super(rules, facts, null); @@ -38,7 +63,7 @@ static ImmutablePair, List> internalizeRulesAndFacts(No List internalRules = new ArrayList<>(); List facts = new ArrayList<>(normalProgram.getFacts()); for (NormalRule r : normalProgram.getRules()) { - if (r.getBody().isEmpty()) { + if (r.getBody().isEmpty() && !r.isHeuristicRule()) { if (!r.getHead().isGround()) { throw new IllegalArgumentException("InternalProgram does not support non-ground rules with empty bodies! (Head = " + r.getHead().toString() + ")"); } @@ -57,18 +82,17 @@ public static InternalProgram fromNormalProgram(NormalProgram normalProgram) { private void recordFacts(List facts) { for (Atom fact : facts) { - List tmpInstances = FactIntervalEvaluator.constructFactInstances(fact); - Predicate tmpPredicate = fact.getPredicate(); - factsByPredicate.putIfAbsent(tmpPredicate, new LinkedHashSet<>()); - factsByPredicate.get(tmpPredicate).addAll(tmpInstances); + this.facts.add(fact); } } private void recordRules(List rules) { for (InternalRule rule : rules) { rulesById.put(rule.getRuleId(), rule); - if (!rule.isConstraint()) { + if (!rule.isConstraint() && !rule.isHeuristicRule()) { recordDefiningRule(rule.getHeadAtom().getPredicate(), rule); + } else if (rule.isHeuristicRule()) { + this.existsHeuristicRule = true; } } } @@ -82,12 +106,21 @@ public Map> getPredicateDefiningRules() { return Collections.unmodifiableMap(predicateDefiningRules); } - public Map> getFactsByPredicate() { - return Collections.unmodifiableMap(factsByPredicate); + public Facts getFactsByPredicate() { + return facts; } public Map getRulesById() { return Collections.unmodifiableMap(rulesById); } + public boolean existsRuleWithPredicateInHead(final Predicate predicate) { + final HashSet definingRules = predicateDefiningRules.get(predicate); + return definingRules != null && !definingRules.isEmpty(); + } + + public boolean existsHeuristicRule() { + return existsHeuristicRule; + } + } diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/rule/AbstractRule.java b/src/main/java/at/ac/tuwien/kr/alpha/common/rule/AbstractRule.java index cb1356d2e..453598e70 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/common/rule/AbstractRule.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/rule/AbstractRule.java @@ -1,16 +1,45 @@ +/* + * Copyright (c) 2019-2022, the Alpha Team. + * All rights reserved. + * + * Additional changes made by Siemens. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package at.ac.tuwien.kr.alpha.common.rule; -import at.ac.tuwien.kr.alpha.Util; -import at.ac.tuwien.kr.alpha.common.atoms.Literal; -import at.ac.tuwien.kr.alpha.common.rule.head.Head; -import org.apache.commons.collections4.SetUtils; - import java.util.Collections; +import java.util.HashSet; import java.util.LinkedHashSet; -import java.util.List; import java.util.Objects; import java.util.Set; +import org.apache.commons.collections4.SetUtils; + +import at.ac.tuwien.kr.alpha.Util; +import at.ac.tuwien.kr.alpha.common.atoms.Literal; +import at.ac.tuwien.kr.alpha.common.rule.head.Head; +import at.ac.tuwien.kr.alpha.common.terms.VariableTerm; + /** * An abstract representation of a rule with a specific type of @{link Head} (type parameter H) * @@ -24,7 +53,7 @@ public abstract class AbstractRule { private final Set bodyLiteralsPositive; private final Set bodyLiteralsNegative; - public AbstractRule(H head, List body) { + public AbstractRule(H head, Iterable body) { this.head = head; Set positiveBody = new LinkedHashSet<>(); Set negativeBody = new LinkedHashSet<>(); @@ -105,6 +134,18 @@ public Set getNegativeBody() { return this.bodyLiteralsNegative; } + /** + * Returns the set of all variables occurring in the rule. + */ + public Set getOccurringVariables() { + final Set variables = new HashSet<>(); + // assumption: all the variables are in the positive body due to safety + for (Literal literal : bodyLiteralsPositive) { + variables.addAll(literal.getOccurringVariables()); + } + return variables; + } + @Override public int hashCode() { return Objects.hash(bodyLiteralsNegative, bodyLiteralsPositive, head); diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/rule/BasicRule.java b/src/main/java/at/ac/tuwien/kr/alpha/common/rule/BasicRule.java index edd2bd381..52554cddc 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/common/rule/BasicRule.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/rule/BasicRule.java @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2019, the Alpha Team. +/* + * Copyright (c) 2019-2022, the Alpha Team. * All rights reserved. * * Additional changes made by Siemens. @@ -28,18 +28,21 @@ package at.ac.tuwien.kr.alpha.common.rule; import java.util.ArrayList; +import java.util.Collections; import java.util.List; +import at.ac.tuwien.kr.alpha.common.Substitutable; import at.ac.tuwien.kr.alpha.common.atoms.Literal; import at.ac.tuwien.kr.alpha.common.rule.head.Head; +import at.ac.tuwien.kr.alpha.grounder.Substitution; /** - * Represents a non-ground rule or a constraint. A @{link BasicRule} has a general {@link Head}, meaning both choice + * Represents a non-ground rule or a constraint. A {@link BasicRule} has a general {@link Head}, meaning both choice * heads and disjunctive heads are permissible. * This implementation represents a rule after being parsed from a given ASP program, but before being transformed into - * a @{link NormalRule}. + * a {@link NormalRule}. */ -public class BasicRule extends AbstractRule { +public class BasicRule extends AbstractRule implements Substitutable { public BasicRule(Head head, List body) { super(head, body); @@ -47,10 +50,12 @@ public BasicRule(Head head, List body) { public static BasicRule getInstance(Head head, Literal... body) { List bodyLst = new ArrayList<>(); - for (Literal lit : body) { - bodyLst.add(lit); - } + Collections.addAll(bodyLst, body); return new BasicRule(head, bodyLst); } + @Override + public BasicRule substitute(Substitution substitution) { + return new BasicRule(getHead().substitute(substitution), substitution.substituteAll(getBody())); + } } diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/rule/InternalRule.java b/src/main/java/at/ac/tuwien/kr/alpha/common/rule/InternalRule.java index a6e21a6d3..c58660a9e 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/common/rule/InternalRule.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/rule/InternalRule.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2016-2020, the Alpha Team. * All rights reserved. * @@ -27,11 +27,6 @@ */ package at.ac.tuwien.kr.alpha.common.rule; -import com.google.common.annotations.VisibleForTesting; - -import java.util.ArrayList; -import java.util.List; - import at.ac.tuwien.kr.alpha.common.Predicate; import at.ac.tuwien.kr.alpha.common.atoms.AggregateLiteral; import at.ac.tuwien.kr.alpha.common.atoms.Atom; @@ -41,12 +36,19 @@ import at.ac.tuwien.kr.alpha.grounder.IntIdGenerator; import at.ac.tuwien.kr.alpha.grounder.RuleGroundingOrders; import at.ac.tuwien.kr.alpha.grounder.Unifier; +import com.google.common.annotations.VisibleForTesting; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.List; /** * Represents a normal rule or a constraint for the semi-naive grounder. * A normal rule has no head atom if it represents a constraint, otherwise it has one atom in its head. */ public class InternalRule extends NormalRule { + private static final Logger LOGGER = LoggerFactory.getLogger(InternalRule.class); private static final IntIdGenerator ID_GENERATOR = new IntIdGenerator(); @@ -58,11 +60,12 @@ public class InternalRule extends NormalRule { public InternalRule(NormalHead head, List body) { super(head, body); - if (body.isEmpty()) { + if (body.isEmpty() && !isHeuristicRule()) { throw new IllegalArgumentException( "Empty bodies are not supported for InternalRule! (Head = " + (head == null ? "NULL" : head.getAtom().toString()) + ")"); } this.ruleId = InternalRule.ID_GENERATOR.getNextId(); + LOGGER.debug("Rule #{}: {}", this.ruleId, this.toString()); this.occurringPredicates = new ArrayList<>(); if (!isConstraint()) { @@ -81,7 +84,10 @@ public InternalRule(NormalHead head, List body) { // this.checkSafety(); this.groundingOrders = new RuleGroundingOrders(this); - this.groundingOrders.computeGroundingOrders(); + if (!(isHeuristicRule() && body.isEmpty())) { + // compute grounding orders only if the body of a rule is non-empty (it can be empty only in rewritten heuristic rules) + groundingOrders.computeGroundingOrders(); + } } @VisibleForTesting diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/rule/NormalRule.java b/src/main/java/at/ac/tuwien/kr/alpha/common/rule/NormalRule.java index 7eac409eb..1ba440023 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/common/rule/NormalRule.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/rule/NormalRule.java @@ -1,12 +1,39 @@ +/* + * Copyright (c) 2016-2021, the Alpha Team. + * All rights reserved. + * + * Additional changes made by Siemens. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package at.ac.tuwien.kr.alpha.common.rule; import at.ac.tuwien.kr.alpha.Util; import at.ac.tuwien.kr.alpha.common.atoms.Atom; import at.ac.tuwien.kr.alpha.common.atoms.Literal; import at.ac.tuwien.kr.alpha.common.rule.head.NormalHead; +import at.ac.tuwien.kr.alpha.grounder.atoms.HeuristicAtom; import java.util.ArrayList; -import java.util.List; /** * A rule that has a normal head, i.e. just one head atom, no disjunction or choice heads allowed. @@ -16,7 +43,7 @@ */ public class NormalRule extends AbstractRule { - public NormalRule(NormalHead head, List body) { + public NormalRule(NormalHead head, Iterable body) { super(head, body); } @@ -47,4 +74,8 @@ public Atom getHeadAtom() { return this.isConstraint() ? null : this.getHead().getAtom(); } + public boolean isHeuristicRule() { + return getHeadAtom() instanceof HeuristicAtom; + } + } diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/rule/head/ChoiceHead.java b/src/main/java/at/ac/tuwien/kr/alpha/common/rule/head/ChoiceHead.java index 46620fce1..d928ac498 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/common/rule/head/ChoiceHead.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/rule/head/ChoiceHead.java @@ -1,18 +1,45 @@ +/* + * Copyright (c) 2017-2020, 2022, the Alpha Team. + * All rights reserved. + * + * Additional changes made by Siemens. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package at.ac.tuwien.kr.alpha.common.rule.head; +import java.util.List; + import at.ac.tuwien.kr.alpha.common.ComparisonOperator; +import at.ac.tuwien.kr.alpha.common.Substitutable; import at.ac.tuwien.kr.alpha.common.atoms.Atom; import at.ac.tuwien.kr.alpha.common.atoms.Literal; import at.ac.tuwien.kr.alpha.common.terms.Term; - -import java.util.List; +import at.ac.tuwien.kr.alpha.grounder.Substitution; import static at.ac.tuwien.kr.alpha.Util.join; /** * Represents the head of a choice rule. - * - * Copyright (c) 2017-2019, the Alpha Team. */ public class ChoiceHead extends Head { private final List choiceElements; @@ -23,7 +50,7 @@ public class ChoiceHead extends Head { private final Term upperBound; private final ComparisonOperator upperOp; - public static class ChoiceElement { + public static class ChoiceElement implements Substitutable { public final Atom choiceAtom; public final List conditionLiterals; @@ -32,6 +59,11 @@ public ChoiceElement(Atom choiceAtom, List conditionLiterals) { this.conditionLiterals = conditionLiterals; } + @Override + public ChoiceElement substitute(Substitution substitution) { + return new ChoiceElement(choiceAtom.substitute(substitution), substitution.substituteAll(conditionLiterals)); + } + @Override public String toString() { String result = choiceAtom.toString(); @@ -72,6 +104,16 @@ public ChoiceHead(List choiceElements, Term lowerBound, Compariso this.upperOp = upperOp; } + @Override + public ChoiceHead substitute(Substitution substitution) { + return new ChoiceHead( + substitution.substituteAll(choiceElements), + lowerBound.substitute(substitution), + lowerOp, + upperBound.substitute(substitution), + upperOp); + } + @Override public String toString() { String result = ""; @@ -137,10 +179,7 @@ public boolean equals(Object obj) { } else if (!this.upperBound.equals(other.upperBound)) { return false; } - if (this.upperOp != other.upperOp) { - return false; - } - return true; + return this.upperOp == other.upperOp; } } diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/rule/head/DisjunctiveHead.java b/src/main/java/at/ac/tuwien/kr/alpha/common/rule/head/DisjunctiveHead.java index 11f0e365d..05d599f2a 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/common/rule/head/DisjunctiveHead.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/rule/head/DisjunctiveHead.java @@ -1,14 +1,39 @@ +/* + * Copyright (c) 2017-2018, 2020, 2022, the Alpha Team. + * All rights reserved. + * + * Additional changes made by Siemens. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package at.ac.tuwien.kr.alpha.common.rule.head; -import at.ac.tuwien.kr.alpha.common.atoms.Atom; - import java.util.List; +import at.ac.tuwien.kr.alpha.common.atoms.Atom; +import at.ac.tuwien.kr.alpha.grounder.Substitution; + import static at.ac.tuwien.kr.alpha.Util.join; -/** - * Copyright (c) 2017, the Alpha Team. - */ public class DisjunctiveHead extends Head { public final List disjunctiveAtoms; @@ -33,6 +58,11 @@ public boolean isGround() { return true; } + @Override + public DisjunctiveHead substitute(Substitution substitution) { + return new DisjunctiveHead(substitution.substituteAll(disjunctiveAtoms)); + } + @Override public int hashCode() { final int prime = 31; @@ -54,13 +84,9 @@ public boolean equals(Object obj) { } DisjunctiveHead other = (DisjunctiveHead) obj; if (this.disjunctiveAtoms == null) { - if (other.disjunctiveAtoms != null) { - return false; - } - } else if (!this.disjunctiveAtoms.equals(other.disjunctiveAtoms)) { - return false; + return other.disjunctiveAtoms == null; + } else { + return this.disjunctiveAtoms.equals(other.disjunctiveAtoms); } - return true; } - } diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/rule/head/Head.java b/src/main/java/at/ac/tuwien/kr/alpha/common/rule/head/Head.java index 535466cb6..d1b80c64e 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/common/rule/head/Head.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/rule/head/Head.java @@ -1,11 +1,38 @@ +/* + * Copyright (c) 2019-2020, 2022, the Alpha Team. + * All rights reserved. + * + * Additional changes made by Siemens. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package at.ac.tuwien.kr.alpha.common.rule.head; +import at.ac.tuwien.kr.alpha.common.Substitutable; + /** * Represents the head of a rule, i.e., either a choice or a disjunction of atoms, but not both. For normal rules the disjunction contains only one atom. - * - * Copyright (c) 2017-2019, the Alpha Team. */ -public abstract class Head { +public abstract class Head implements Substitutable { @Override public abstract String toString(); diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/rule/head/NormalHead.java b/src/main/java/at/ac/tuwien/kr/alpha/common/rule/head/NormalHead.java index cb88e8229..551ccbd4d 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/common/rule/head/NormalHead.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/rule/head/NormalHead.java @@ -1,10 +1,37 @@ +/* + * Copyright (c) 2019-2020, 2022, the Alpha Team. + * All rights reserved. + * + * Additional changes made by Siemens. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package at.ac.tuwien.kr.alpha.common.rule.head; import at.ac.tuwien.kr.alpha.common.atoms.Atom; +import at.ac.tuwien.kr.alpha.grounder.Substitution; /** * Represents a normal head, i.e., a head that is an Atom. - * Copyright (c) 2019, the Alpha Team. */ public class NormalHead extends Head { @@ -23,6 +50,11 @@ public Atom getAtom() { return atom; } + @Override + public NormalHead substitute(Substitution substitution) { + return new NormalHead(atom.substitute(substitution)); + } + @Override public String toString() { return atom.toString(); @@ -49,13 +81,9 @@ public boolean equals(Object obj) { } NormalHead other = (NormalHead) obj; if (this.atom == null) { - if (other.atom != null) { - return false; - } - } else if (!this.atom.equals(other.atom)) { - return false; + return other.atom == null; + } else { + return this.atom.equals(other.atom); } - return true; } - } diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/terms/ConstantTerm.java b/src/main/java/at/ac/tuwien/kr/alpha/common/terms/ConstantTerm.java index 98e035e16..d032b89a3 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/common/terms/ConstantTerm.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/terms/ConstantTerm.java @@ -27,6 +27,15 @@ public static > ConstantTerm getInstance(T symbol) { @SuppressWarnings("unchecked") public static > ConstantTerm getSymbolicInstance(String symbol) { + switch (symbol) { + case "true": return getSymbolicInstance(true); + case "false": return getSymbolicInstance(false); + default: return (ConstantTerm) INTERNER.intern(new ConstantTerm<>(symbol, true)); + } + } + + @SuppressWarnings("unchecked") + public static > ConstantTerm getSymbolicInstance(boolean symbol) { return (ConstantTerm) INTERNER.intern(new ConstantTerm<>(symbol, true)); } diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/terms/FunctionTerm.java b/src/main/java/at/ac/tuwien/kr/alpha/common/terms/FunctionTerm.java index 9e3847ac4..6be877f29 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/common/terms/FunctionTerm.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/terms/FunctionTerm.java @@ -1,14 +1,45 @@ +/* + * Copyright (c) 2016-2018, 2020-2021, the Alpha Team. + * All rights reserved. + * + * Additional changes made by Siemens. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package at.ac.tuwien.kr.alpha.common.terms; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; + import at.ac.tuwien.kr.alpha.common.Interner; import at.ac.tuwien.kr.alpha.grounder.Substitution; -import java.util.*; - import static at.ac.tuwien.kr.alpha.Util.join; /** - * Copyright (c) 2016-2017, the Alpha Team. + * Copyright (c) 2016-2018, the Alpha Team. */ public class FunctionTerm extends Term { private static final Interner INTERNER = new Interner<>(); diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/terms/Term.java b/src/main/java/at/ac/tuwien/kr/alpha/common/terms/Term.java index 490fb46b8..9cfc79e76 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/common/terms/Term.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/terms/Term.java @@ -1,11 +1,39 @@ +/** + * Copyright (c) 2016-2018, the Alpha Team. + * All rights reserved. + * + * Additional changes made by Siemens. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package at.ac.tuwien.kr.alpha.common.terms; +import at.ac.tuwien.kr.alpha.common.Substitutable; +import at.ac.tuwien.kr.alpha.grounder.Substitution; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; -import at.ac.tuwien.kr.alpha.grounder.Substitution; - //@formatter:off /** * Common representation of Terms. Terms are constructed such that each term is represented by a unique object, hence @@ -20,7 +48,7 @@ *
  • {@link ConstantTerm} and symbolic, lexicographically ordered on the symbol
  • *
  • {@link ConstantTerm} lexicographically *
  • {@link ConstantTerm} for all other types, where {@link Comparable#compareTo(Object)} is used as ordering whenever - * possible (i.e. two terms' objects have the same type). For two terms with objects of different type, + * possible (i.e. two terms' objects have the same type). For two terms with objects of different type, * the result is the lexicographic ordering of the type names.
  • * * @@ -31,17 +59,18 @@ * Copyright (c) 2016-2020, the Alpha Team. */ //@formatter:on -public abstract class Term implements Comparable { +public abstract class Term implements Comparable, Substitutable { public abstract boolean isGround(); public abstract List getOccurringVariables(); /** * Applies a substitution, result may be nonground. - * + * * @param substitution the variable substitution to apply. * @return the non-substitute term where all variable substitutions have been applied. */ + @Override public abstract Term substitute(Substitution substitution); private static int priority(Term term) { @@ -63,7 +92,7 @@ public int compareTo(Term o) { /** * Rename all variables occurring in this Term by prefixing their name. - * + * * @param renamePrefix the name to prefix all occurring variables. * @return the term with all variables renamed. */ diff --git a/src/main/java/at/ac/tuwien/kr/alpha/common/terms/VariableTerm.java b/src/main/java/at/ac/tuwien/kr/alpha/common/terms/VariableTerm.java index 8396b4102..f7111f824 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/common/terms/VariableTerm.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/common/terms/VariableTerm.java @@ -1,20 +1,47 @@ +/* + * Copyright (c) 2016-2018, 2021, the Alpha Team. + * All rights reserved. + * + * Additional changes made by Siemens. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package at.ac.tuwien.kr.alpha.common.terms; import at.ac.tuwien.kr.alpha.common.Interner; import at.ac.tuwien.kr.alpha.grounder.IntIdGenerator; import at.ac.tuwien.kr.alpha.grounder.Substitution; +import com.google.common.annotations.VisibleForTesting; import java.util.Collections; import java.util.List; -/** - * Copyright (c) 2016-2017, the Alpha Team. - */ public class VariableTerm extends Term { private static final Interner INTERNER = new Interner<>(); private static final String ANONYMOUS_VARIABLE_PREFIX = "_"; - private static final IntIdGenerator ANONYMOUS_VARIABLE_COUNTER = new IntIdGenerator(); + + @VisibleForTesting + public static final IntIdGenerator ANONYMOUS_VARIABLE_COUNTER = new IntIdGenerator(); private final String variableName; diff --git a/src/main/java/at/ac/tuwien/kr/alpha/config/CommandLineParser.java b/src/main/java/at/ac/tuwien/kr/alpha/config/CommandLineParser.java index 53528ff9c..e706280ef 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/config/CommandLineParser.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/config/CommandLineParser.java @@ -33,8 +33,8 @@ import org.apache.commons.cli.Option; import org.apache.commons.cli.Options; import org.apache.commons.cli.ParseException; +import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringUtils; -import org.apache.commons.text.StringEscapeUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -60,13 +60,13 @@ public class CommandLineParser { //@formatter:off /* - * Whenever a new command line option is added, perform the following steps: - * 1. Add it as a constant option below. + * Whenever a new command line option is added, perform the following steps: + * 1. Add it as a constant option below. * 2. Add the constant option into the Options "CLI_OPTS" in the static initializer. - * 3. Add a handler method for it and add the respective map entry in initializeGlobalOptionHandlers + * 3. Add a handler method for it and add the respective map entry in initializeGlobalOptionHandlers * or initializeInputOptionHandlers with a method reference to the handler. */ - + // "special", i.e. non-configuration options private static final Option OPT_HELP = Option.builder("h").longOpt("help").hasArg(false).desc("shows this help").build(); @@ -131,7 +131,7 @@ public class CommandLineParser { .desc("Disable stratified evaluation") .build(); private static final Option OPT_NO_NOGOOD_DELETION = Option.builder("dnd").longOpt("disableNoGoodDeletion") - .desc("disable the deletion of (learned, little active) nogoods (default: " + .desc("disable the deletion of (learned, little active) nogoods (default: " + SystemConfig.DEFAULT_DISABLE_NOGOOD_DELETION + ")") .build(); private static final Option OPT_GROUNDER_TOLERANCE_CONSTRAINTS = Option.builder("gtc").longOpt("grounderToleranceConstraints") @@ -143,13 +143,16 @@ public class CommandLineParser { .hasArg().argName("tolerance") .build(); private static final Option OPT_GROUNDER_ACCUMULATOR_ENABLED = Option.builder("acc").longOpt("enableAccumulator") - .desc("activates the accumulator grounding strategy by disabling removal of instances from grounder memory in certain cases (default: " + .desc("activates the accumulator grounding strategy by disabling removal of instances from grounder memory in certain cases (default: " + SystemConfig.DEFAULT_GROUNDER_ACCUMULATOR_ENABLED + ")") .build(); private static final Option OPT_OUTPUT_ATOM_SEPARATOR = Option.builder("sep").longOpt("atomSeparator").hasArg(true).argName("separator") .desc("a character (sequence) to use as separator for atoms in printed answer sets (default: " + SystemConfig.DEFAULT_ATOM_SEPARATOR + ")") .build(); + private static final Option OPT_IGNORE_DOMSPEC_HEURISTICS = Option.builder("ids").longOpt("ignoreDomSpecHeuristics") + .desc("ignore domain-specific heuristics defined via heuristic directives (default: " + SystemConfig.DEFAULT_IGNORE_DOMSPEC_HEURISTICS + ")") + .build(); //@formatter:on private static final Options CLI_OPTS = new Options(); @@ -192,6 +195,7 @@ public class CommandLineParser { CommandLineParser.CLI_OPTS.addOption(CommandLineParser.OPT_GROUNDER_TOLERANCE_RULES); CommandLineParser.CLI_OPTS.addOption(CommandLineParser.OPT_GROUNDER_ACCUMULATOR_ENABLED); CommandLineParser.CLI_OPTS.addOption(CommandLineParser.OPT_OUTPUT_ATOM_SEPARATOR); + CommandLineParser.CLI_OPTS.addOption(CommandLineParser.OPT_IGNORE_DOMSPEC_HEURISTICS); } /* @@ -249,6 +253,7 @@ private void initializeGlobalOptionHandlers() { this.globalOptionHandlers.put(CommandLineParser.OPT_GROUNDER_TOLERANCE_RULES.getOpt(), this::handleGrounderToleranceRules); this.globalOptionHandlers.put(CommandLineParser.OPT_GROUNDER_ACCUMULATOR_ENABLED.getOpt(), this::handleGrounderNoInstanceRemoval); this.globalOptionHandlers.put(CommandLineParser.OPT_OUTPUT_ATOM_SEPARATOR.getOpt(), this::handleAtomSeparator); + this.globalOptionHandlers.put(CommandLineParser.OPT_IGNORE_DOMSPEC_HEURISTICS.getOpt(), this::handleIgnoreDomspecHeuristic); } private void initializeInputOptionHandlers() { @@ -489,5 +494,9 @@ private void handleGrounderNoInstanceRemoval(Option opt, SystemConfig cfg) { private void handleAtomSeparator(Option opt, SystemConfig cfg) { cfg.setAtomSeparator(StringEscapeUtils.unescapeJava(opt.getValue(SystemConfig.DEFAULT_ATOM_SEPARATOR))); } - + + private void handleIgnoreDomspecHeuristic(Option opt, SystemConfig cfg) { + cfg.setIgnoreDomspecHeuristics(true); + } + } diff --git a/src/main/java/at/ac/tuwien/kr/alpha/config/SystemConfig.java b/src/main/java/at/ac/tuwien/kr/alpha/config/SystemConfig.java index ae9173f32..f263ef9e2 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/config/SystemConfig.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/config/SystemConfig.java @@ -55,6 +55,7 @@ public class SystemConfig { public static final boolean DEFAULT_DISABLE_JUSTIFICATION_SEARCH = false; public static final boolean DEFAULT_DEBUG_INTERNAL_CHECKS = false; public static final boolean DEFAULT_SORT_ANSWER_SETS = false; + public static final boolean DEFAULT_IGNORE_DOMSPEC_HEURISTICS = false; public static final List DEFAULT_REPLAY_CHOICES = Collections.emptyList(); public static final boolean DEFAULT_STRATIFIED_EVALUATION = true; public static final boolean DEFAULT_DISABLE_NOGOOD_DELETION = false; @@ -76,6 +77,7 @@ public class SystemConfig { private boolean printStats = DEFAULT_PRINT_STATS; private boolean disableJustificationSearch = DEFAULT_DISABLE_JUSTIFICATION_SEARCH; private boolean sortAnswerSets = DEFAULT_SORT_ANSWER_SETS; + private boolean ignoreDomspecHeuristics = DEFAULT_IGNORE_DOMSPEC_HEURISTICS; private List replayChoices = DEFAULT_REPLAY_CHOICES; private boolean evaluateStratifiedPart = DEFAULT_STRATIFIED_EVALUATION; private boolean disableNoGoodDeletion = DEFAULT_DISABLE_NOGOOD_DELETION; @@ -189,6 +191,14 @@ public void setSortAnswerSets(boolean sortAnswerSets) { this.sortAnswerSets = sortAnswerSets; } + public boolean isIgnoreDomspecHeuristics() { + return ignoreDomspecHeuristics; + } + + public void setIgnoreDomspecHeuristics(boolean ignoreDomspecHeuristics) { + this.ignoreDomspecHeuristics = ignoreDomspecHeuristics; + } + public List getReplayChoices() { return replayChoices; } @@ -256,5 +266,5 @@ public AggregateRewritingConfig getAggregateRewritingConfig() { public void setAggregateRewritingConfig(AggregateRewritingConfig aggregateRewritingConfig) { this.aggregateRewritingConfig = aggregateRewritingConfig; } - + } diff --git a/src/main/java/at/ac/tuwien/kr/alpha/grounder/ChoiceRecorder.java b/src/main/java/at/ac/tuwien/kr/alpha/grounder/ChoiceRecorder.java index c807e0bae..2af8b83be 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/grounder/ChoiceRecorder.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/grounder/ChoiceRecorder.java @@ -1,19 +1,19 @@ -/** - * Copyright (c) 2017-2019, the Alpha Team. +/* + * Copyright (c) 2017-2021, the Alpha Team. * All rights reserved. - * + * * Additional changes made by Siemens. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1) Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. - * + * * 2) Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -28,23 +28,53 @@ package at.ac.tuwien.kr.alpha.grounder; import at.ac.tuwien.kr.alpha.common.AtomStore; +import at.ac.tuwien.kr.alpha.common.Literals; import at.ac.tuwien.kr.alpha.common.NoGood; +import at.ac.tuwien.kr.alpha.common.NoGoodCreator; +import at.ac.tuwien.kr.alpha.common.atoms.Atom; +import at.ac.tuwien.kr.alpha.common.heuristics.HeuristicDirectiveAtom; +import at.ac.tuwien.kr.alpha.common.heuristics.HeuristicDirectiveValues; +import at.ac.tuwien.kr.alpha.common.program.InternalProgram; +import at.ac.tuwien.kr.alpha.grounder.atoms.HeuristicAtom; +import at.ac.tuwien.kr.alpha.grounder.atoms.HeuristicInfluencerAtom; import at.ac.tuwien.kr.alpha.grounder.atoms.RuleAtom; +import at.ac.tuwien.kr.alpha.solver.ThriceTruth; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; -import static at.ac.tuwien.kr.alpha.common.Literals.*; +import static at.ac.tuwien.kr.alpha.Util.oops; +import static at.ac.tuwien.kr.alpha.common.Literals.atomToLiteral; +import static at.ac.tuwien.kr.alpha.common.Literals.negateLiteral; +import static at.ac.tuwien.kr.alpha.common.heuristics.HeuristicSignSetUtil.NUM_SIGN_SETS; +import static at.ac.tuwien.kr.alpha.common.heuristics.HeuristicSignSetUtil.getIndex; +import static at.ac.tuwien.kr.alpha.common.heuristics.HeuristicSignSetUtil.getSignSetByIndex; +import static at.ac.tuwien.kr.alpha.common.heuristics.HeuristicSignSetUtil.isF; +import static at.ac.tuwien.kr.alpha.common.heuristics.HeuristicSignSetUtil.isProcessable; import static at.ac.tuwien.kr.alpha.grounder.atoms.ChoiceAtom.off; import static at.ac.tuwien.kr.alpha.grounder.atoms.ChoiceAtom.on; +import static at.ac.tuwien.kr.alpha.grounder.transformation.SignSetTransformation.SET_F; import static java.util.Collections.emptyList; public class ChoiceRecorder { - private static final IntIdGenerator ID_GENERATOR = new IntIdGenerator(); + static final IntIdGenerator ID_GENERATOR = new IntIdGenerator(); + + private static final int IDX_OFF = 1; + private static final int IDX_ON = 0; private final AtomStore atomStore; private Pair, Map> newChoiceAtoms = new ImmutablePair<>(new LinkedHashMap<>(), new LinkedHashMap<>()); + private Pair, Map> newHeuristicAtoms = new ImmutablePair<>(new LinkedHashMap<>(), new LinkedHashMap<>()); + private Map newHeuristicValues = new LinkedHashMap<>(); private Map> newHeadsToBodies = new LinkedHashMap<>(); public ChoiceRecorder(AtomStore atomStore) { @@ -69,11 +99,29 @@ public Map> getAndResetHeadsToBodies() { return currentHeadsToBodies; } - - public List generateChoiceNoGoods(final List posLiterals, final List negLiterals, final int bodyRepresentingLiteral) { + + /** + * @return new heuristic atoms and their enablers and disablers. + */ + public Pair, Map> getAndResetHeuristics() { + Pair, Map> currentHeuristicAtoms = newHeuristicAtoms; + newHeuristicAtoms = new ImmutablePair<>(new LinkedHashMap<>(), new LinkedHashMap<>()); + return currentHeuristicAtoms; + } + + /** + * @return a set of new mappings from heuristic atoms to {@link HeuristicDirectiveValues}. + */ + public Map getAndResetHeuristicValues() { + Map currentHeuristicValues = newHeuristicValues; + newHeuristicValues = new LinkedHashMap<>(); + return currentHeuristicValues; + } + + + public List generateChoiceNoGoods(final List posLiterals, final List negLiterals, final int bodyRepresentingAtom) { // Obtain an ID for this new choice. final int choiceId = ID_GENERATOR.getNextId(); - final int bodyRepresentingAtom = atomOf(bodyRepresentingLiteral); // Create ChoiceOn and ChoiceOff atoms. final int choiceOnAtom = atomStore.putIfAbsent(on(choiceId)); newChoiceAtoms.getLeft().put(bodyRepresentingAtom, choiceOnAtom); @@ -85,11 +133,128 @@ public List generateChoiceNoGoods(final List posLiterals, final return noGoods; } - + + public Collection generateHeuristicNoGoods(HeuristicAtom groundHeuristicAtom, final RuleAtom bodyAtom, final int headId, InternalProgram program) { + // Obtain an ID for this new heuristic. + final int heuristicId = ID_GENERATOR.getNextId(); + final Integer[][] influencers = new Integer[2][4]; // dim 1: [on,off], dim 2: [T,TM,M,F] + + final List noGoods = generateHeuristicNoGoodsForPositiveCondition(groundHeuristicAtom, heuristicId, program, influencers); + if (noGoods == null) { + return null; // heuristic can never be applicable + } + final List noGoodsForNegativeCondition = generateHeuristicNoGoodsForNegativeCondition(groundHeuristicAtom, heuristicId, program, influencers); + if (noGoodsForNegativeCondition == null) { + return null; // heuristic can never be applicable + } + noGoods.addAll(noGoodsForNegativeCondition); + + final int bodyRepresentingAtom = atomStore.putIfAbsent(bodyAtom); + newHeuristicAtoms.getLeft().put(bodyRepresentingAtom, influencers[IDX_ON]); + newHeuristicAtoms.getRight().put(bodyRepresentingAtom, influencers[IDX_OFF]); + + if (newHeuristicValues.put(bodyRepresentingAtom, HeuristicDirectiveValues.fromHeuristicAtom(groundHeuristicAtom, headId)) != null) { + throw oops("Same heuristic body-representing atom used for two heuristic directives"); + } + + return noGoods; + } + + private List generateHeuristicNoGoodsForPositiveCondition(HeuristicAtom groundHeuristicAtom, int heuristicId, InternalProgram program, Integer[][] influencers) { + final List noGoods = new ArrayList<>(); + final Map> positiveAtomsBySignSet = new HashMap<>(NUM_SIGN_SETS); + for (HeuristicDirectiveAtom heuristicDirectiveAtom : groundHeuristicAtom.getOriginalPositiveCondition()) { + final Atom atom = heuristicDirectiveAtom.getAtom(); + final Set signSet = heuristicDirectiveAtom.getSigns(); + + if (program.getFactsByPredicate().isFact(atom)) { + if (signSet.contains(ThriceTruth.TRUE) || signSet.contains(ThriceTruth.MBT)) { + continue; // literal is always satisfied + } + if (signSet.contains(ThriceTruth.FALSE)) { + return null; // heuristic is never applicable + } + } + + if (!program.existsRuleWithPredicateInHead(atom.getPredicate())) { + if (signSet.contains(ThriceTruth.TRUE) || signSet.contains(ThriceTruth.MBT)) { + return null; // heuristic is never applicable + } + if (signSet.contains(ThriceTruth.FALSE)) { + continue; // literal is always satisfied + } + } + + final int idxSignSet = getIndex(signSet); + final Set atomsForSignSet = positiveAtomsBySignSet.computeIfAbsent(idxSignSet, k -> new HashSet<>()); + atomsForSignSet.add(atom); + } + for (int idxSignSet = 0; idxSignSet < NUM_SIGN_SETS; idxSignSet++) { + if (positiveAtomsBySignSet.get(idxSignSet) == null) { + continue; + } + final boolean inNegativeBody = false; + final Set signSet = getSignSetByIndex(idxSignSet); + createHeuristicInfluencer(heuristicId, signSet, inNegativeBody, influencers); + noGoods.add(generateHeuristicPos(positiveAtomsBySignSet.get(idxSignSet), signSet, influencers[IDX_ON][idxSignSet])); + } + return noGoods; + } + + private List generateHeuristicNoGoodsForNegativeCondition(HeuristicAtom groundHeuristicAtom, int heuristicId, InternalProgram program, Integer[][] influencers) { + final List noGoods = new ArrayList<>(); + for (HeuristicDirectiveAtom heuristicDirectiveAtom : groundHeuristicAtom.getOriginalNegativeCondition()) { + final Atom atom = heuristicDirectiveAtom.getAtom(); + final Set signSet = heuristicDirectiveAtom.getSigns(); + + if (program.getFactsByPredicate().isFact(atom)) { + if (signSet.contains(ThriceTruth.TRUE) || signSet.contains(ThriceTruth.MBT)) { + return null; // heuristic is never applicable + } + if (signSet.contains(ThriceTruth.FALSE)) { + continue; // literal is always satisfied + } + } + + if (!program.existsRuleWithPredicateInHead(atom.getPredicate())) { + if (signSet.contains(ThriceTruth.TRUE) || signSet.contains(ThriceTruth.MBT)) { + continue; // literal is always satisfied + } + if (signSet.contains(ThriceTruth.FALSE)) { + return null; // heuristic is never applicable + } + } + + final boolean inNegativeBody = true; + final int idxSignSet = getIndex(signSet); + createHeuristicInfluencer(heuristicId, signSet, inNegativeBody, influencers); + noGoods.add(generateHeuristicNeg(atom, signSet, influencers[IDX_OFF][idxSignSet])); + } + return noGoods; + } + + private void createHeuristicInfluencer(int heuristicId, Set signSet, boolean inNegativeBody, Integer[][] influencers) { + final int idxOnOff = inNegativeBody ? IDX_OFF : IDX_ON; + final int idxSignSet = getIndex(signSet); + if (influencers[idxOnOff][idxSignSet] == null) { + influencers[idxOnOff][idxSignSet] = atomStore.putIfAbsent(HeuristicInfluencerAtom.get(!inNegativeBody, heuristicId, signSet)); + } + } + private NoGood generatePos(final int atomOn, List posLiterals) { final int literalOn = atomToLiteral(atomOn); - return NoGood.fromBodyInternal(posLiterals, emptyList(), literalOn); + return NoGoodCreator.fromBodyInternal(posLiterals, emptyList(), literalOn); + } + + private NoGood generateHeuristicPos(Set atoms, Set signSet, int heuristicInfluencerAtom) { + final int literalOn = atomToLiteral(heuristicInfluencerAtom); + final List literals = atoms.stream().map(atomStore::putIfAbsent).map(Literals::atomToLiteral).collect(Collectors.toList()); + if (SET_F.equals(signSet)) { + return NoGoodCreator.fromBodyInternal(emptyList(), literals, literalOn); + } else { + return NoGoodCreator.fromBodyInternal(literals, emptyList(), literalOn); + } } private List generateNeg(final int atomOff, List negLiterals) { @@ -99,11 +264,19 @@ private List generateNeg(final int atomOff, List negLiterals) for (Integer negLiteral : negLiterals) { // Choice is off if any of the negative atoms is assigned true, // hence we add one nogood for each such atom. - noGoods.add(NoGood.headFirstInternal(negLiteralOff, negLiteral)); + noGoods.add(NoGoodCreator.headFirstInternal(negLiteralOff, negLiteral)); } return noGoods; } + private NoGood generateHeuristicNeg(Atom atom, Set signSet, int heuristicInfluencerAtom) { + if (!isProcessable(signSet)) { + throw oops("Heuristic sign not processable: " + signSet); + } + final int atomID = atomStore.putIfAbsent(atom); + return NoGoodCreator.headFirstInternal(atomToLiteral(heuristicInfluencerAtom, false), atomToLiteral(atomID, !isF(signSet))); + } + public void addHeadToBody(int headId, int bodyId) { Set existingBodies = newHeadsToBodies.get(headId); if (existingBodies == null) { diff --git a/src/main/java/at/ac/tuwien/kr/alpha/grounder/Grounder.java b/src/main/java/at/ac/tuwien/kr/alpha/grounder/Grounder.java index 41849fa53..d728aaea2 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/grounder/Grounder.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/grounder/Grounder.java @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2016-2019, the Alpha Team. +/* + * Copyright (c) 2016-2020, the Alpha Team. * All rights reserved. * * Additional changes made by Siemens. @@ -29,8 +29,10 @@ import at.ac.tuwien.kr.alpha.common.AnswerSet; import at.ac.tuwien.kr.alpha.common.Assignment; +import at.ac.tuwien.kr.alpha.common.AtomStore; import at.ac.tuwien.kr.alpha.common.IntIterator; import at.ac.tuwien.kr.alpha.common.NoGood; +import at.ac.tuwien.kr.alpha.common.heuristics.HeuristicDirectiveValues; import at.ac.tuwien.kr.alpha.grounder.atoms.RuleAtom; import org.apache.commons.lang3.tuple.Pair; @@ -40,6 +42,7 @@ public interface Grounder { /** * Translates an answer-set represented by true atom IDs into its logical representation. + * * @param trueAtoms * @return */ @@ -47,16 +50,18 @@ public interface Grounder { /** * Applies lazy grounding and returns all newly derived (fully ground) NoGoods. + * * @return a mapping of nogood IDs to NoGoods. */ Map getNoGoods(Assignment assignment); /** - * Return choice points and their enablers and disablers. - * Must be preceeded by a call to getNoGoods(). + * Returns new choice points and their enablers and disablers. + * Must be preceded by a call to {@link #getNoGoods(Assignment)}. + * * @return a pair (choiceOn, choiceOff) of two maps from atomIds to atomIds, - * choiceOn maps atoms (choice points) to their enabling atoms - * and choiceOff maps atoms (choice points) to their disabling atoms. + * choiceOn maps atoms (choice points) to their enabling atoms + * and choiceOff maps atoms (choice points) to their disabling atoms. */ Pair, Map> getChoiceAtoms(); @@ -66,17 +71,34 @@ public interface Grounder { */ void updateAssignment(IntIterator it); + /** + * Returns new heuristic atoms and their enablers and disablers. + * Must be preceded by a call to {@link #getNoGoods(Assignment)}. + * @see #getChoiceAtoms() + */ + Pair, Map> getHeuristicAtoms(); + + /** + * Returns a set of new mappings from heuristic atoms to {@link HeuristicDirectiveValues}. + * Must be preceded by a call to {@link #getNoGoods(Assignment)}. + */ + Map getHeuristicValues(); + /** * Returns a set of new mappings from head atoms to {@link RuleAtom}s deriving it. */ Map> getHeadsToBodies(); + void forgetAssignment(int[] atomIds); /** * Registers the given NoGood and returns the identifier of it. + * * @param noGood * @return */ int register(NoGood noGood); + + AtomStore getAtomStore(); } diff --git a/src/main/java/at/ac/tuwien/kr/alpha/grounder/GrounderFactory.java b/src/main/java/at/ac/tuwien/kr/alpha/grounder/GrounderFactory.java index 5c3afda3a..dba1e41d2 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/grounder/GrounderFactory.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/grounder/GrounderFactory.java @@ -33,22 +33,18 @@ import at.ac.tuwien.kr.alpha.config.InputConfig; import at.ac.tuwien.kr.alpha.grounder.bridges.Bridge; import at.ac.tuwien.kr.alpha.grounder.heuristics.GrounderHeuristicsConfiguration; +import at.ac.tuwien.kr.alpha.solver.heuristics.HeuristicsConfiguration; public final class GrounderFactory { - public static Grounder getInstance(String name, InternalProgram program, AtomStore atomStore, java.util.function.Predicate filter, GrounderHeuristicsConfiguration heuristicsConfiguration, boolean debugInternalChecks, Bridge... bridges) { + public static Grounder getInstance(String name, InternalProgram program, AtomStore atomStore, HeuristicsConfiguration heuristicsConfiguration, java.util.function.Predicate filter, GrounderHeuristicsConfiguration grounderHeuristicsConfiguration, boolean debugInternalChecks, Bridge... bridges) { switch (name.toLowerCase()) { case "naive": - return new NaiveGrounder(program, atomStore, filter, heuristicsConfiguration, debugInternalChecks, bridges); + return new NaiveGrounder(program, atomStore, heuristicsConfiguration, filter, grounderHeuristicsConfiguration, debugInternalChecks, bridges); } throw new IllegalArgumentException("Unknown grounder requested."); } - public static Grounder getInstance(String name, InternalProgram program, AtomStore atomStore, java.util.function.Predicate filter, - GrounderHeuristicsConfiguration heuristicsConfiguration, boolean debugInternalChecks) { - return getInstance(name, program, atomStore, filter, heuristicsConfiguration, debugInternalChecks, new Bridge[] {}); - } - - public static Grounder getInstance(String name, InternalProgram program, AtomStore atomStore, boolean debugInternalChecks) { - return getInstance(name, program, atomStore, InputConfig.DEFAULT_FILTER, new GrounderHeuristicsConfiguration(), debugInternalChecks); + public static Grounder getInstance(String name, InternalProgram program, AtomStore atomStore, HeuristicsConfiguration heuristicsConfiguration, boolean debugInternalChecks) { + return getInstance(name, program, atomStore, heuristicsConfiguration, InputConfig.DEFAULT_FILTER, new GrounderHeuristicsConfiguration(), debugInternalChecks); } } diff --git a/src/main/java/at/ac/tuwien/kr/alpha/grounder/NaiveGrounder.java b/src/main/java/at/ac/tuwien/kr/alpha/grounder/NaiveGrounder.java index 8a54946a4..c2bba5a90 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/grounder/NaiveGrounder.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/grounder/NaiveGrounder.java @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2016-2019, the Alpha Team. +/* + * Copyright (c) 2016-2020, the Alpha Team. * All rights reserved. * * Additional changes made by Siemens. @@ -27,27 +27,6 @@ */ package at.ac.tuwien.kr.alpha.grounder; -import static at.ac.tuwien.kr.alpha.Util.oops; -import static at.ac.tuwien.kr.alpha.common.Literals.atomOf; - -import org.apache.commons.lang3.tuple.ImmutablePair; -import org.apache.commons.lang3.tuple.Pair; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeSet; - import at.ac.tuwien.kr.alpha.Util; import at.ac.tuwien.kr.alpha.common.AnswerSet; import at.ac.tuwien.kr.alpha.common.Assignment; @@ -60,10 +39,14 @@ import at.ac.tuwien.kr.alpha.common.atoms.Atom; import at.ac.tuwien.kr.alpha.common.atoms.BasicAtom; import at.ac.tuwien.kr.alpha.common.atoms.Literal; +import at.ac.tuwien.kr.alpha.common.heuristics.HeuristicDirectiveValues; +import at.ac.tuwien.kr.alpha.common.program.Facts; import at.ac.tuwien.kr.alpha.common.program.InternalProgram; import at.ac.tuwien.kr.alpha.common.rule.InternalRule; import at.ac.tuwien.kr.alpha.common.terms.VariableTerm; import at.ac.tuwien.kr.alpha.grounder.atoms.ChoiceAtom; +import at.ac.tuwien.kr.alpha.grounder.atoms.HeuristicAtom; +import at.ac.tuwien.kr.alpha.grounder.atoms.HeuristicInfluencerAtom; import at.ac.tuwien.kr.alpha.grounder.atoms.RuleAtom; import at.ac.tuwien.kr.alpha.grounder.bridges.Bridge; import at.ac.tuwien.kr.alpha.grounder.heuristics.GrounderHeuristicsConfiguration; @@ -73,6 +56,28 @@ import at.ac.tuwien.kr.alpha.grounder.instantiation.LiteralInstantiationResult; import at.ac.tuwien.kr.alpha.grounder.instantiation.LiteralInstantiator; import at.ac.tuwien.kr.alpha.grounder.structure.AnalyzeUnjustified; +import at.ac.tuwien.kr.alpha.solver.heuristics.HeuristicsConfiguration; +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.apache.commons.lang3.tuple.Pair; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; + +import static at.ac.tuwien.kr.alpha.Util.oops; +import static at.ac.tuwien.kr.alpha.common.Literals.atomOf; +import static java.util.Collections.singletonList; /** * A semi-naive grounder. @@ -90,7 +95,7 @@ public class NaiveGrounder extends BridgedGrounder implements ProgramAnalyzingGr private final InternalProgram program; private final AnalyzeUnjustified analyzeUnjustified; - private final Map> factsFromProgram; + private final Facts factsFromProgram; private final Map> rulesUsingPredicateWorkingMemory = new HashMap<>(); private final Map knownNonGroundRules; @@ -98,48 +103,45 @@ public class NaiveGrounder extends BridgedGrounder implements ProgramAnalyzingGr private LinkedHashSet removeAfterObtainingNewNoGoods = new LinkedHashSet<>(); private final boolean debugInternalChecks; - private final GrounderHeuristicsConfiguration heuristicsConfiguration; + private final GrounderHeuristicsConfiguration grounderHeuristicsConfiguration; // Handles instantiation of literals, i.e. supplies ground substitutions for literals of non-ground rules // according to the rules set by the LiteralInstantiationStrategy used by this grounder. private final LiteralInstantiator ruleInstantiator; private final DefaultLazyGroundingInstantiationStrategy instantiationStrategy; - public NaiveGrounder(InternalProgram program, AtomStore atomStore, boolean debugInternalChecks, Bridge... bridges) { - this(program, atomStore, new GrounderHeuristicsConfiguration(), debugInternalChecks, bridges); + public NaiveGrounder(InternalProgram program, AtomStore atomStore, HeuristicsConfiguration heuristicsConfiguration, boolean debugInternalChecks, Bridge... bridges) { + this(program, atomStore, heuristicsConfiguration, new GrounderHeuristicsConfiguration(), debugInternalChecks, bridges); } - private NaiveGrounder(InternalProgram program, AtomStore atomStore, GrounderHeuristicsConfiguration heuristicsConfiguration, boolean debugInternalChecks, + private NaiveGrounder(InternalProgram program, AtomStore atomStore, HeuristicsConfiguration heuristicsConfiguration, GrounderHeuristicsConfiguration grounderHeuristicsConfiguration, boolean debugInternalChecks, Bridge... bridges) { - this(program, atomStore, p -> true, heuristicsConfiguration, debugInternalChecks, bridges); + this(program, atomStore, heuristicsConfiguration, p -> true, grounderHeuristicsConfiguration, debugInternalChecks, bridges); } - NaiveGrounder(InternalProgram program, AtomStore atomStore, java.util.function.Predicate filter, - GrounderHeuristicsConfiguration heuristicsConfiguration, boolean debugInternalChecks, Bridge... bridges) { + NaiveGrounder(InternalProgram program, AtomStore atomStore, HeuristicsConfiguration heuristicsConfiguration, java.util.function.Predicate filter, + GrounderHeuristicsConfiguration grounderHeuristicsConfiguration, boolean debugInternalChecks, Bridge... bridges) { super(filter, bridges); this.atomStore = atomStore; - this.heuristicsConfiguration = heuristicsConfiguration; + this.grounderHeuristicsConfiguration = grounderHeuristicsConfiguration; LOGGER.debug("Grounder configuration: {}", heuristicsConfiguration); this.program = program; - this.factsFromProgram = program.getFactsByPredicate(); this.knownNonGroundRules = program.getRulesById(); - - this.analyzeUnjustified = new AnalyzeUnjustified(this.program, this.atomStore, this.factsFromProgram); + this.analyzeUnjustified = new AnalyzeUnjustified(this.program, this.atomStore); this.initializeFactsAndRules(); final Set uniqueGroundRulePerGroundHead = getRulesWithUniqueHead(); choiceRecorder = new ChoiceRecorder(atomStore); - noGoodGenerator = new NoGoodGenerator(atomStore, choiceRecorder, factsFromProgram, this.program, uniqueGroundRulePerGroundHead); - + noGoodGenerator = new NoGoodGenerator(atomStore, choiceRecorder, this.program, uniqueGroundRulePerGroundHead); this.debugInternalChecks = debugInternalChecks; // Initialize RuleInstantiator and instantiation strategy. Note that the instantiation strategy also // needs the current assignment, which is set with every call of getGroundInstantiations. this.instantiationStrategy = new DefaultLazyGroundingInstantiationStrategy(this.workingMemory, this.atomStore, this.factsFromProgram, - this.heuristicsConfiguration.isAccumulatorEnabled()); + this.grounderHeuristicsConfiguration.isAccumulatorEnabled()); this.instantiationStrategy.setStaleWorkingMemoryEntries(this.removeAfterObtainingNewNoGoods); this.ruleInstantiator = new LiteralInstantiator(this.instantiationStrategy); } @@ -157,6 +159,9 @@ private void initializeFactsAndRules() { workingMemory.initialize(RuleAtom.PREDICATE); workingMemory.initialize(ChoiceAtom.OFF); workingMemory.initialize(ChoiceAtom.ON); + workingMemory.initialize(HeuristicInfluencerAtom.OFF); + workingMemory.initialize(HeuristicInfluencerAtom.ON); + workingMemory.initialize(HeuristicAtom.PREDICATE); // Initialize rules and constraints in working memory. for (InternalRule nonGroundRule : program.getRulesById().values()) { @@ -185,40 +190,59 @@ private Set getRulesWithUniqueHead() { // Record all unique rule heads. final Set uniqueGroundRulePerGroundHead = new HashSet<>(); - for (Map.Entry> headDefiningRules : program.getPredicateDefiningRules().entrySet()) { - if (headDefiningRules.getValue().size() != 1) { + predicates: for (Map.Entry> headDefiningRules : program.getPredicateDefiningRules().entrySet()) { + final LinkedHashSet rules = headDefiningRules.getValue(); + if (rules.size() != 1 && !areAllRulesGroundWithUniqueHeads(rules)) { continue; } - InternalRule nonGroundRule = headDefiningRules.getValue().iterator().next(); - // Check that all variables of the body also occur in the head (otherwise grounding is not unique). - Atom headAtom = nonGroundRule.getHeadAtom(); + rules: for (InternalRule nonGroundRule : rules) { + // Check that all variables of the body also occur in the head (otherwise grounding is not unique). + Atom headAtom = nonGroundRule.getHeadAtom(); - // Rule is not guaranteed unique if there are facts for it. - HashSet potentialFacts = factsFromProgram.get(headAtom.getPredicate()); - if (potentialFacts != null && !potentialFacts.isEmpty()) { - continue; - } + // Rule is not guaranteed unique if there are facts for it. + Set potentialFacts = factsFromProgram.get(headAtom.getPredicate()); + if (!potentialFacts.isEmpty()) { + continue; + } - // Collect head and body variables. - HashSet occurringVariablesHead = new HashSet<>(headAtom.toLiteral().getBindingVariables()); - HashSet occurringVariablesBody = new HashSet<>(); - for (Literal lit : nonGroundRule.getPositiveBody()) { - occurringVariablesBody.addAll(lit.getBindingVariables()); - } - occurringVariablesBody.removeAll(occurringVariablesHead); + // Collect head and body variables. + HashSet occurringVariablesHead = new HashSet<>(headAtom.toLiteral().getBindingVariables()); + HashSet occurringVariablesBody = new HashSet<>(); + for (Literal lit : nonGroundRule.getPositiveBody()) { + occurringVariablesBody.addAll(lit.getBindingVariables()); + } + occurringVariablesBody.removeAll(occurringVariablesHead); - // Check if ever body variables occurs in the head. - if (occurringVariablesBody.isEmpty()) { - uniqueGroundRulePerGroundHead.add(nonGroundRule); + // Check if ever body variables occurs in the head. + if (occurringVariablesBody.isEmpty()) { + uniqueGroundRulePerGroundHead.add(nonGroundRule); + } } } return uniqueGroundRulePerGroundHead; } + private boolean + areAllRulesGroundWithUniqueHeads(Collection rules) { + // FIXME: will be superseded by #283 (cf. #226) + Set headAtoms = new HashSet<>(); + for (InternalRule internalRule : rules) { + if (!internalRule.isGround()) { + return false; + } + final Atom headAtom = internalRule.getHeadAtom(); + if (headAtoms.contains(headAtom)) { + return false; + } + headAtoms.add(headAtom); + } + return true; + } + /** * Registers a starting literal of a NonGroundRule at its corresponding working memory. - * + * * @param nonGroundRule the rule in which the literal occurs. */ private void registerLiteralAtWorkingMemory(Literal literal, InternalRule nonGroundRule) { @@ -257,7 +281,7 @@ public AnswerSet assignmentToAnswerSet(Iterable trueAtoms) { } // Add true atoms from facts. - for (Map.Entry> facts : factsFromProgram.entrySet()) { + for (Map.Entry> facts : factsFromProgram.entrySet()) { Predicate factPredicate = facts.getKey(); // Skip atoms over internal predicates. if (factPredicate.isInternal()) { @@ -288,13 +312,13 @@ public AnswerSet assignmentToAnswerSet(Iterable trueAtoms) { /** * Prepares facts of the input program for joining and derives all NoGoods representing ground rules. May only be called once. - * + * * @return */ protected HashMap bootstrap() { final HashMap groundNogoods = new LinkedHashMap<>(); - for (Predicate predicate : factsFromProgram.keySet()) { + for (Predicate predicate : factsFromProgram.getPredicates()) { // Instead of generating NoGoods, add instance to working memories directly. workingMemory.addInstances(predicate, true, factsFromProgram.get(predicate)); } @@ -302,8 +326,19 @@ protected HashMap bootstrap() { for (InternalRule nonGroundRule : fixedRules) { // Generate NoGoods for all rules that have a fixed grounding. RuleGroundingOrder groundingOrder = nonGroundRule.getGroundingOrders().getFixedGroundingOrder(); - BindingResult bindingResult = getGroundInstantiations(nonGroundRule, groundingOrder, new Substitution(), null); - groundAndRegister(nonGroundRule, bindingResult.getGeneratedSubstitutions(), groundNogoods); + + List substitutions; + if (groundingOrder != null) { + BindingResult bindingResult = getGroundInstantiations(nonGroundRule, groundingOrder, new Substitution(), null); + substitutions = bindingResult.getGeneratedSubstitutions(); + } else { + // groundingOrder may be null only if body of rewritten heuristic rule is empty + if (!nonGroundRule.isHeuristicRule()) { + throw oops("Non-heuristic NonGroundRule without grounding order: " + nonGroundRule); + } + substitutions = singletonList(new Substitution()); + } + groundAndRegister(nonGroundRule, substitutions, groundNogoods); } fixedRules = null; @@ -399,7 +434,7 @@ public Map getNoGoods(Assignment currentAssignment) { */ private void groundAndRegister(final InternalRule nonGroundRule, final List substitutions, final Map newNoGoods) { for (Substitution substitution : substitutions) { - List generatedNoGoods = noGoodGenerator.generateNoGoodsFromGroundSubstitution(nonGroundRule, substitution); + Collection generatedNoGoods = noGoodGenerator.generateNoGoodsFromGroundSubstitution(nonGroundRule, substitution); registry.register(generatedNoGoods, newNoGoods); } } @@ -412,7 +447,7 @@ public int register(NoGood noGood) { // Ideally, this method should be private. It's only visible because NaiveGrounderTest needs to access it. BindingResult getGroundInstantiations(InternalRule rule, RuleGroundingOrder groundingOrder, Substitution partialSubstitution, Assignment currentAssignment) { - int tolerance = heuristicsConfiguration.getTolerance(rule.isConstraint()); + int tolerance = grounderHeuristicsConfiguration.getTolerance(rule.isConstraint()); if (tolerance < 0) { tolerance = Integer.MAX_VALUE; } @@ -436,12 +471,12 @@ BindingResult getGroundInstantiations(InternalRule rule, RuleGroundingOrder grou /** * Helper method used by {@link NaiveGrounder#bindNextAtomInRule(RuleGroundingOrder, int, int, int, Substitution)}. - * + * * Takes an ImmutablePair of a {@link Substitution} and an accompanying {@link AssignmentStatus} and calls * bindNextAtomInRule for the next literal in the grounding order. * If the assignment status for the last bound literal was {@link AssignmentStatus#UNASSIGNED}, the remainingTolerance * parameter is decreased by 1. If the remaining tolerance drops below zero, this method returns an empty {@link BindingResult}. - * + * * @param groundingOrder * @param orderPosition * @param originalTolerance @@ -492,11 +527,11 @@ private BindingResult pushBackAndBindNextAtomInRule(RuleGroundingOrder grounding //@formatter:off /** * Computes ground substitutions for a literal based on a {@link RuleGroundingOrder} and a {@link Substitution}. - * + * * Computes ground substitutions for the literal at position orderPosition of groundingOrder - * Actual substitutions are computed by this grounder's {@link LiteralInstantiator}. - * - * @param groundingOrder a {@link RuleGroundingOrder} representing the body literals of a rule in the + * Actual substitutions are computed by this grounder's {@link LiteralInstantiator}. + * + * @param groundingOrder a {@link RuleGroundingOrder} representing the body literals of a rule in the * sequence in which the should be bound during grounding. * @param orderPosition the current position within groundingOrder, indicates which literal should be bound * @param originalTolerance the original tolerance of the used grounding heuristic @@ -567,6 +602,15 @@ public Pair, Map> getChoiceAtoms() { return choiceRecorder.getAndResetChoices(); } + @Override + public Pair, Map> getHeuristicAtoms() { + return choiceRecorder.getAndResetHeuristics(); + } + + @Override + public Map getHeuristicValues() { + return choiceRecorder.getAndResetHeuristicValues(); + } @Override public Map> getHeadsToBodies() { return choiceRecorder.getAndResetHeadsToBodies(); @@ -584,6 +628,16 @@ public void forgetAssignment(int[] atomIds) { throw new UnsupportedOperationException("Forgetting assignments is not implemented"); } + @Override + public AtomStore getAtomStore() { + return this.atomStore; + } + + static String groundLiteralToString(Literal literal, Substitution substitution, boolean isFirst) { + Literal groundLiteral = literal.substitute(substitution); + return (isFirst ? "" : ", ") + groundLiteral.toString(); + } + @Override public InternalRule getNonGroundRule(Integer ruleId) { return knownNonGroundRules.get(ruleId); @@ -591,11 +645,7 @@ public InternalRule getNonGroundRule(Integer ruleId) { @Override public boolean isFact(Atom atom) { - LinkedHashSet instances = factsFromProgram.get(atom.getPredicate()); - if (instances == null) { - return false; - } - return instances.contains(new Instance(atom.getTerms())); + return program.getFactsByPredicate().isFact(atom); } @Override @@ -607,8 +657,7 @@ public Set justifyAtom(int atomToJustify, Assignment currentAssignment) if (literal.isNegated()) { continue; } - LinkedHashSet factsOverPredicate = factsFromProgram.get(literal.getPredicate()); - if (factsOverPredicate != null && factsOverPredicate.contains(new Instance(literal.getAtom().getTerms()))) { + if (isFact(literal.getAtom())) { iterator.remove(); } } @@ -618,7 +667,7 @@ public Set justifyAtom(int atomToJustify, Assignment currentAssignment) /** * Checks that every nogood not marked as {@link NoGoodInterface.Type#INTERNAL} contains only * atoms which are not {@link Predicate#isSolverInternal()} (except {@link RuleAtom}s, which are allowed). - * + * * @param newNoGoods */ private void checkTypesOfNoGoods(Collection newNoGoods) { diff --git a/src/main/java/at/ac/tuwien/kr/alpha/grounder/NoGoodGenerator.java b/src/main/java/at/ac/tuwien/kr/alpha/grounder/NoGoodGenerator.java index 75a27929d..d4c8fcdd7 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/grounder/NoGoodGenerator.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/grounder/NoGoodGenerator.java @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2017-2018, the Alpha Team. +/* + * Copyright (c) 2017-2021, the Alpha Team. * All rights reserved. * * Additional changes made by Siemens. @@ -27,52 +27,50 @@ */ package at.ac.tuwien.kr.alpha.grounder; -import static at.ac.tuwien.kr.alpha.common.Literals.atomOf; -import static at.ac.tuwien.kr.alpha.common.Literals.atomToLiteral; -import static at.ac.tuwien.kr.alpha.common.Literals.negateLiteral; -import static java.util.Collections.emptyList; -import static java.util.Collections.singletonList; - import java.util.ArrayList; -import java.util.HashSet; -import java.util.LinkedHashSet; +import java.util.Collection; import java.util.List; -import java.util.Map; import java.util.Set; import at.ac.tuwien.kr.alpha.common.AtomStore; import at.ac.tuwien.kr.alpha.common.NoGood; -import at.ac.tuwien.kr.alpha.common.Predicate; +import at.ac.tuwien.kr.alpha.common.NoGoodCreator; import at.ac.tuwien.kr.alpha.common.atoms.Atom; +import at.ac.tuwien.kr.alpha.common.atoms.BasicAtom; import at.ac.tuwien.kr.alpha.common.atoms.FixedInterpretationLiteral; import at.ac.tuwien.kr.alpha.common.atoms.Literal; import at.ac.tuwien.kr.alpha.common.program.InternalProgram; import at.ac.tuwien.kr.alpha.common.rule.InternalRule; import at.ac.tuwien.kr.alpha.grounder.atoms.EnumerationAtom; +import at.ac.tuwien.kr.alpha.grounder.atoms.HeuristicAtom; import at.ac.tuwien.kr.alpha.grounder.atoms.RuleAtom; +import static at.ac.tuwien.kr.alpha.common.AtomToFunctionTermConverter.toAtom; +import static at.ac.tuwien.kr.alpha.common.Literals.atomToLiteral; +import static at.ac.tuwien.kr.alpha.common.Literals.negateLiteral; +import static java.util.Collections.emptyList; +import static java.util.Collections.singletonList; + /** * Class to generate ground NoGoods out of non-ground rules and grounding substitutions. - * Copyright (c) 2017-2018, the Alpha Team. + * Copyright (c) 2017-2020, the Alpha Team. */ public class NoGoodGenerator { private final AtomStore atomStore; private final ChoiceRecorder choiceRecorder; - private final Map> factsFromProgram; - private final InternalProgram programAnalysis; + private final InternalProgram program; private final Set uniqueGroundRulePerGroundHead; - NoGoodGenerator(AtomStore atomStore, ChoiceRecorder recorder, Map> factsFromProgram, InternalProgram programAnalysis, Set uniqueGroundRulePerGroundHead) { + NoGoodGenerator(AtomStore atomStore, ChoiceRecorder recorder, InternalProgram program, Set uniqueGroundRulePerGroundHead) { this.atomStore = atomStore; this.choiceRecorder = recorder; - this.factsFromProgram = factsFromProgram; - this.programAnalysis = programAnalysis; + this.program = program; this.uniqueGroundRulePerGroundHead = uniqueGroundRulePerGroundHead; } /** * Generates all NoGoods resulting from a non-ground rule and a variable substitution. - * + * * @param nonGroundRule * the non-ground rule. * @param substitution @@ -80,7 +78,8 @@ public class NoGoodGenerator { * Assumption: atoms with fixed interpretation evaluate to true under the substitution. * @return a list of the NoGoods corresponding to the ground rule. */ - List generateNoGoodsFromGroundSubstitution(final InternalRule nonGroundRule, final Substitution substitution) { + Collection generateNoGoodsFromGroundSubstitution(final InternalRule nonGroundRule, final Substitution substitution) { + final boolean isHeuristicRule = nonGroundRule.getHeadAtom() instanceof HeuristicAtom; final List posLiterals = collectPosLiterals(nonGroundRule, substitution); final List negLiterals = collectNegLiterals(nonGroundRule, substitution); @@ -90,14 +89,10 @@ List generateNoGoodsFromGroundSubstitution(final InternalRule nonGroundR // A constraint is represented by exactly one nogood. if (nonGroundRule.isConstraint()) { - return singletonList(NoGood.fromConstraint(posLiterals, negLiterals)); + return singletonList(NoGoodCreator.fromConstraint(posLiterals, negLiterals)); } - final List result = new ArrayList<>(); - final Atom groundHeadAtom = nonGroundRule.getHeadAtom().substitute(substitution); - final int headId = atomStore.putIfAbsent(groundHeadAtom); - // Prepare atom representing the rule body. final RuleAtom bodyAtom = new RuleAtom(nonGroundRule, substitution); @@ -109,15 +104,36 @@ List generateNoGoodsFromGroundSubstitution(final InternalRule nonGroundR return emptyList(); } - final int bodyRepresentingLiteral = atomToLiteral(atomStore.putIfAbsent(bodyAtom)); - final int headLiteral = atomToLiteral(atomStore.putIfAbsent(nonGroundRule.getHeadAtom().substitute(substitution))); + if (isHeuristicRule) { + return generateNoGoodsForHeuristicRule((HeuristicAtom) groundHeadAtom, bodyAtom); + } else { + return generateNoGoodsForNonConstraintNonHeuristicRule(nonGroundRule, posLiterals, negLiterals, groundHeadAtom, bodyAtom); + } + } + + private Collection generateNoGoodsForHeuristicRule(HeuristicAtom groundHeadAtom, RuleAtom bodyAtom) { + BasicAtom groundHeuristicHead = toAtom(groundHeadAtom.getHeadAtom()); + final int heuristicHeadId = atomStore.putIfAbsent(groundHeuristicHead); + + final Collection heuristicNoGoods = choiceRecorder.generateHeuristicNoGoods(groundHeadAtom, bodyAtom, heuristicHeadId, program); + if (heuristicNoGoods == null) { + return emptyList(); // heuristic can never be applicable + } + return new ArrayList<>(heuristicNoGoods); + } - choiceRecorder.addHeadToBody(headId, atomOf(bodyRepresentingLiteral)); - + private Collection generateNoGoodsForNonConstraintNonHeuristicRule(InternalRule internalRule, List posLiterals, List negLiterals, Atom groundHeadAtom, RuleAtom bodyAtom) { + final List result = new ArrayList<>(); + final int bodyRepresentingAtom = atomStore.putIfAbsent(bodyAtom); + final int bodyRepresentingLiteral = atomToLiteral(bodyRepresentingAtom); + final int headId = atomStore.putIfAbsent(groundHeadAtom); + final int headLiteral = atomToLiteral(headId); + + choiceRecorder.addHeadToBody(headId, bodyRepresentingAtom); // Create a nogood for the head. - result.add(NoGood.headFirst(negateLiteral(headLiteral), bodyRepresentingLiteral)); + result.add(NoGoodCreator.headFirst(negateLiteral(headLiteral), bodyRepresentingLiteral)); - final NoGood ruleBody = NoGood.fromBody(posLiterals, negLiterals, bodyRepresentingLiteral); + final NoGood ruleBody = NoGoodCreator.fromBody(posLiterals, negLiterals, bodyRepresentingLiteral); result.add(ruleBody); // Nogoods such that the atom representing the body is true iff the body is true. @@ -126,15 +142,14 @@ List generateNoGoodsFromGroundSubstitution(final InternalRule nonGroundR } // If the rule head is unique, add support. - if (uniqueGroundRulePerGroundHead.contains(nonGroundRule)) { - result.add(NoGood.support(headLiteral, bodyRepresentingLiteral)); + if (uniqueGroundRulePerGroundHead.contains(internalRule)) { + result.add(NoGoodCreator.support(headLiteral, bodyRepresentingLiteral)); } // If the body of the rule contains negation, add choices. if (!negLiterals.isEmpty()) { - result.addAll(choiceRecorder.generateChoiceNoGoods(posLiterals, negLiterals, bodyRepresentingLiteral)); + result.addAll(choiceRecorder.generateChoiceNoGoods(posLiterals, negLiterals, bodyRepresentingAtom)); } - return result; } @@ -142,15 +157,13 @@ List collectNegLiterals(final InternalRule nonGroundRule, final Substit final List bodyLiteralsNegative = new ArrayList<>(); for (Literal lit : nonGroundRule.getNegativeBody()) { Atom groundAtom = lit.getAtom().substitute(substitution); - - final Set factInstances = factsFromProgram.get(groundAtom.getPredicate()); - if (factInstances != null && factInstances.contains(new Instance(groundAtom.getTerms()))) { + if (program.getFactsByPredicate().isFact(groundAtom)) { // Negative atom that is always true encountered, skip whole rule as it will never fire. return null; } - if (!existsRuleWithPredicateInHead(groundAtom.getPredicate())) { + if (!program.existsRuleWithPredicateInHead(groundAtom.getPredicate())) { // Negative atom is no fact and no rule defines it, it is always false, skip it. continue; } @@ -180,13 +193,12 @@ private List collectPosLiterals(final InternalRule nonGroundRule, final // Consider facts to eliminate ground atoms from the generated nogoods that are always true // and eliminate nogoods that are always satisfied due to facts. - Set factInstances = factsFromProgram.get(groundAtom.getPredicate()); - if (factInstances != null && factInstances.contains(new Instance(groundAtom.getTerms()))) { + if (program.getFactsByPredicate().isFact(groundAtom)) { // Skip positive atoms that are always true. continue; } - if (!existsRuleWithPredicateInHead(groundAtom.getPredicate())) { + if (!program.existsRuleWithPredicateInHead(groundAtom.getPredicate())) { // Atom is no fact and no rule defines it, it cannot be derived (i.e., is always false), skip whole rule as it will never fire. return null; } @@ -195,9 +207,4 @@ private List collectPosLiterals(final InternalRule nonGroundRule, final } return bodyLiteralsPositive; } - - private boolean existsRuleWithPredicateInHead(final Predicate predicate) { - final HashSet definingRules = programAnalysis.getPredicateDefiningRules().get(predicate); - return definingRules != null && !definingRules.isEmpty(); - } } diff --git a/src/main/java/at/ac/tuwien/kr/alpha/grounder/RuleGroundingOrders.java b/src/main/java/at/ac/tuwien/kr/alpha/grounder/RuleGroundingOrders.java index 6d903d938..463ec7845 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/grounder/RuleGroundingOrders.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/grounder/RuleGroundingOrders.java @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2016-2019, the Alpha Team. +/* + * Copyright (c) 2016-2020, the Alpha Team. * All rights reserved. * * Additional changes made by Siemens. @@ -27,6 +27,11 @@ */ package at.ac.tuwien.kr.alpha.grounder; +import at.ac.tuwien.kr.alpha.common.atoms.BasicAtom; +import at.ac.tuwien.kr.alpha.common.atoms.Literal; +import at.ac.tuwien.kr.alpha.common.rule.InternalRule; +import at.ac.tuwien.kr.alpha.common.terms.VariableTerm; + import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -37,11 +42,6 @@ import java.util.List; import java.util.Set; -import at.ac.tuwien.kr.alpha.common.atoms.BasicAtom; -import at.ac.tuwien.kr.alpha.common.atoms.Literal; -import at.ac.tuwien.kr.alpha.common.rule.InternalRule; -import at.ac.tuwien.kr.alpha.common.terms.VariableTerm; - /** * Provides the grounder with information on the order to ground the literals in the body of a rule. * Grounding starts with some starting literal (i.e., one that does not require any variables to be bound already) and @@ -166,8 +166,7 @@ public void computeGroundingOrders() { private void computeGroundingOrder(Literal startingLiteral) { Set bodyLiterals = internalRule.getBody(); - HashSet boundVariables = new HashSet<>(); - boundVariables.addAll(startingLiteral.getBindingVariables()); + HashSet boundVariables = new HashSet<>(startingLiteral.getBindingVariables()); LinkedHashSet remainingLiterals = new LinkedHashSet<>(bodyLiterals); remainingLiterals.remove(startingLiteral); ArrayList literalsOrder; diff --git a/src/main/java/at/ac/tuwien/kr/alpha/grounder/Substitution.java b/src/main/java/at/ac/tuwien/kr/alpha/grounder/Substitution.java index c90bb4846..dfd8de2dc 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/grounder/Substitution.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/grounder/Substitution.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2020, the Alpha Team. + * Copyright (c) 2016-2021, the Alpha Team. * All rights reserved. * * Additional changes made by Siemens. @@ -27,6 +27,15 @@ */ package at.ac.tuwien.kr.alpha.grounder; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.TreeMap; + +import at.ac.tuwien.kr.alpha.common.Substitutable; import at.ac.tuwien.kr.alpha.common.atoms.Atom; import at.ac.tuwien.kr.alpha.common.atoms.Literal; import at.ac.tuwien.kr.alpha.common.terms.ConstantTerm; @@ -35,12 +44,6 @@ import at.ac.tuwien.kr.alpha.common.terms.VariableTerm; import at.ac.tuwien.kr.alpha.grounder.parser.ProgramPartParser; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import java.util.Set; -import java.util.TreeMap; - import static at.ac.tuwien.kr.alpha.Util.oops; public class Substitution { @@ -193,6 +196,18 @@ public Set getMappedVariables() { return substitution.keySet(); } + public > List substituteAll(Collection substitutables) { + final List substitutes = new ArrayList<>(substitutables.size()); + for (S substitutable : substitutables) { + substitutes.add(substitutable.substitute(this)); + } + return substitutes; + } + + public > S substituteIfNotNull(S substitutable) { + return substitutable == null ? null : substitutable.substitute(this); + } + /** * Prints the variable substitution in a uniform way (sorted by variable names). * diff --git a/src/main/java/at/ac/tuwien/kr/alpha/grounder/Unification.java b/src/main/java/at/ac/tuwien/kr/alpha/grounder/Unification.java index b8548b971..6ca058ba7 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/grounder/Unification.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/grounder/Unification.java @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2017-2018, the Alpha Team. +/* + * Copyright (c) 2017-2018, 2021, the Alpha Team. * All rights reserved. * * Additional changes made by Siemens. @@ -33,10 +33,6 @@ import at.ac.tuwien.kr.alpha.common.terms.Term; import at.ac.tuwien.kr.alpha.common.terms.VariableTerm; -import java.util.Set; - -import static at.ac.tuwien.kr.alpha.Util.oops; - /** * Helper methods for unification and instantiation of two given atoms. * @@ -65,16 +61,6 @@ public static Unifier instantiate(Atom general, Atom specific) { } private static Unifier unifyAtoms(Atom left, Atom right, boolean keepLeftAsIs) { - Set leftOccurringVariables = left.getOccurringVariables(); - Set rightOccurringVaribles = right.getOccurringVariables(); - boolean leftSmaller = leftOccurringVariables.size() < rightOccurringVaribles.size(); - Set smallerSet = leftSmaller ? leftOccurringVariables : rightOccurringVaribles; - Set largerSet = leftSmaller ? rightOccurringVaribles : leftOccurringVariables; - for (VariableTerm variableTerm : smallerSet) { - if (largerSet.contains(variableTerm)) { - throw oops("Left and right atom share variables."); - } - } Unifier mgu = new Unifier(); if (!left.getPredicate().equals(right.getPredicate())) { return null; diff --git a/src/main/java/at/ac/tuwien/kr/alpha/grounder/Unifier.java b/src/main/java/at/ac/tuwien/kr/alpha/grounder/Unifier.java index 7b5bf3e09..fe4276165 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/grounder/Unifier.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/grounder/Unifier.java @@ -1,7 +1,32 @@ +/* + * Copyright (c) 2018, 2020-2022, the Alpha Team. + * All rights reserved. + * + * Additional changes made by Siemens. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package at.ac.tuwien.kr.alpha.grounder; -import static at.ac.tuwien.kr.alpha.Util.oops; - import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -12,6 +37,8 @@ import at.ac.tuwien.kr.alpha.common.terms.Term; import at.ac.tuwien.kr.alpha.common.terms.VariableTerm; +import static at.ac.tuwien.kr.alpha.Util.oops; + /** * A variable substitution allowing variables to occur on the right-hand side. Chains of variable substitutions are * resolved automatically, i.e., adding the substitutions {@literal (X -> A)} and {@literal (A -> d)} results in {@literal (X -> d)}, {@literal (A -> d)}. @@ -66,13 +93,6 @@ public Set getMappedVariables() { @Override public > Term put(VariableTerm variableTerm, Term term) { - // If term is not ground, store it for right-hand side reverse-lookup. - if (!term.isGround()) { - for (VariableTerm rightHandVariable : term.getOccurringVariables()) { - rightHandVariableOccurrences.putIfAbsent(rightHandVariable, new ArrayList<>()); - rightHandVariableOccurrences.get(rightHandVariable).add(variableTerm); - } - } // Note: We're destroying type information here. Term ret = substitution.put(variableTerm, term); @@ -91,6 +111,14 @@ public > Term put(VariableTerm variableTerm, Term term) } } + // If term is not ground, store it for right-hand side reverse-lookup. + if (!term.isGround()) { + for (VariableTerm rightHandVariable : term.getOccurringVariables()) { + rightHandVariableOccurrences.putIfAbsent(rightHandVariable, new ArrayList<>()); + rightHandVariableOccurrences.get(rightHandVariable).add(variableTerm); + } + } + return ret; } diff --git a/src/main/java/at/ac/tuwien/kr/alpha/grounder/atoms/ChoiceAtom.java b/src/main/java/at/ac/tuwien/kr/alpha/grounder/atoms/ChoiceAtom.java index 6584eaa94..5b0bd5f93 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/grounder/atoms/ChoiceAtom.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/grounder/atoms/ChoiceAtom.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016-2018, the Alpha Team. + * Copyright (c) 2016-2019, the Alpha Team. * All rights reserved. * * Additional changes made by Siemens. @@ -27,29 +27,24 @@ */ package at.ac.tuwien.kr.alpha.grounder.atoms; -import static at.ac.tuwien.kr.alpha.Util.join; - -import java.util.Collections; -import java.util.List; - import at.ac.tuwien.kr.alpha.common.Predicate; -import at.ac.tuwien.kr.alpha.common.atoms.Atom; -import at.ac.tuwien.kr.alpha.common.atoms.Literal; +import at.ac.tuwien.kr.alpha.common.atoms.BasicAtom; +import at.ac.tuwien.kr.alpha.common.atoms.BasicLiteral; import at.ac.tuwien.kr.alpha.common.terms.ConstantTerm; import at.ac.tuwien.kr.alpha.common.terms.Term; import at.ac.tuwien.kr.alpha.grounder.Substitution; -public class ChoiceAtom extends Atom { +import java.util.Collections; +import java.util.List; + +import static at.ac.tuwien.kr.alpha.Util.join; +public class ChoiceAtom extends BasicAtom { public static final Predicate ON = Predicate.getInstance("ChoiceOn", 1, true, true); public static final Predicate OFF = Predicate.getInstance("ChoiceOff", 1, true, true); - private final Predicate predicate; - private final List terms; - private ChoiceAtom(Predicate predicate, Term term) { - this.predicate = predicate; - this.terms = Collections.singletonList(term); + super(predicate, Collections.singletonList(term)); } private ChoiceAtom(Predicate predicate, int id) { @@ -64,16 +59,6 @@ public static ChoiceAtom off(int id) { return new ChoiceAtom(OFF, id); } - @Override - public Predicate getPredicate() { - return predicate; - } - - @Override - public List getTerms() { - return terms; - } - @Override public boolean isGround() { // NOTE: Term is a ConstantTerm, which is ground by definition. @@ -81,12 +66,12 @@ public boolean isGround() { } @Override - public Literal toLiteral(boolean negated) { - throw new UnsupportedOperationException("ChoiceAtom cannot be literalized"); + public BasicLiteral toLiteral(boolean negated) { + throw new UnsupportedOperationException(this.getClass().getName() + " cannot be literalized"); } @Override - public Atom substitute(Substitution substitution) { + public ChoiceAtom substitute(Substitution substitution) { return this; } @@ -96,7 +81,7 @@ public String toString() { } @Override - public Atom withTerms(List terms) { + public ChoiceAtom withTerms(List terms) { throw new UnsupportedOperationException("Changing terms is not supported for ChoiceAtoms!"); } diff --git a/src/main/java/at/ac/tuwien/kr/alpha/grounder/atoms/HeuristicAtom.java b/src/main/java/at/ac/tuwien/kr/alpha/grounder/atoms/HeuristicAtom.java new file mode 100644 index 000000000..4c72275fc --- /dev/null +++ b/src/main/java/at/ac/tuwien/kr/alpha/grounder/atoms/HeuristicAtom.java @@ -0,0 +1,235 @@ +/* + * Copyright (c) 2017-2021, the Alpha Team. + * All rights reserved. + * + * Additional changes made by Siemens. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.grounder.atoms; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.Set; + +import at.ac.tuwien.kr.alpha.Util; +import at.ac.tuwien.kr.alpha.common.HeuristicDirective; +import at.ac.tuwien.kr.alpha.common.Predicate; +import at.ac.tuwien.kr.alpha.common.WeightAtLevel; +import at.ac.tuwien.kr.alpha.common.atoms.Atom; +import at.ac.tuwien.kr.alpha.common.atoms.BasicAtom; +import at.ac.tuwien.kr.alpha.common.atoms.Literal; +import at.ac.tuwien.kr.alpha.common.heuristics.HeuristicDirectiveAtom; +import at.ac.tuwien.kr.alpha.common.heuristics.HeuristicDirectiveLiteral; +import at.ac.tuwien.kr.alpha.common.terms.ConstantTerm; +import at.ac.tuwien.kr.alpha.common.terms.FunctionTerm; +import at.ac.tuwien.kr.alpha.common.terms.Term; +import at.ac.tuwien.kr.alpha.grounder.Substitution; +import at.ac.tuwien.kr.alpha.solver.ThriceTruth; + +import static at.ac.tuwien.kr.alpha.common.AtomToFunctionTermConverter.toAtom; +import static at.ac.tuwien.kr.alpha.common.AtomToFunctionTermConverter.toFunctionTerm; +import static at.ac.tuwien.kr.alpha.common.heuristics.HeuristicSignSetUtil.toName; +import static at.ac.tuwien.kr.alpha.common.heuristics.HeuristicSignSetUtil.toSignSet; + +/** + * An internal atom that stores information on domain-specific heuristics. + * + * For example, the information from the heuristic directive: + * #heuristic b(1) : T a(0), MT a(1), F a(2), not T a(3), not MT a(4), not F a(5). [3@2] + * is encoded in a heuristic atom in the following form: + * _h(3, 2, true, b(1), condpos(t(a(0)), tm(a(1)), f(a(2))), condneg(t(a(3)), tm(a(4)), f(a(5)))) + * + */ +public class HeuristicAtom extends Atom { + public static final Predicate PREDICATE = Predicate.getInstance("_h", 6, true); + private static final String FUNCTION_POSITIVE_CONDITION = "condpos"; + private static final String FUNCTION_NEGATIVE_CONDITION = "condneg"; + + private final WeightAtLevel weightAtLevel; + private final ThriceTruth headSign; + private final FunctionTerm headAtom; + private final FunctionTerm positiveCondition; + private final FunctionTerm negativeCondition; + private final boolean ground; + + public HeuristicAtom(WeightAtLevel weightAtLevel, ThriceTruth headSign, FunctionTerm headAtom, FunctionTerm positiveCondition, FunctionTerm negativeCondition) { + this.weightAtLevel = weightAtLevel; + this.headSign = headSign; + this.headAtom = headAtom; + this.positiveCondition = positiveCondition; + this.negativeCondition = negativeCondition; + this.ground = getTerms().stream().allMatch(Term::isGround); + } + + public WeightAtLevel getWeightAtLevel() { + return weightAtLevel; + } + + public ThriceTruth getHeadSign() { + return headSign; + } + + public FunctionTerm getHeadAtom() { + return headAtom; + } + + @Override + public Predicate getPredicate() { + return PREDICATE; + } + + /** + * Returns an unmodifiable list of this atom's terms + * (because changes to the returned list would NOT be reflected in the heuristic atom's terms!) + */ + @Override + public List getTerms() { + return Collections.unmodifiableList(Arrays.asList( + weightAtLevel.getWeight(), + weightAtLevel.getLevel(), + ConstantTerm.getInstance(headSign.toBoolean()), + headAtom, + positiveCondition, + negativeCondition + )); + } + + @SuppressWarnings("unchecked") + @Override + public HeuristicAtom withTerms(List terms) { + if (terms.size() != 6) { + throw new IllegalArgumentException("Length of terms list does not fit " + this.getClass().getSimpleName() + ": " + terms); + } + final WeightAtLevel weightAtLevel = new WeightAtLevel(terms.get(0), terms.get(1)); + final ThriceTruth headSign = ((ConstantTerm) terms.get(2)).getObject() ? ThriceTruth.TRUE : ThriceTruth.FALSE; + final FunctionTerm headAtom = (FunctionTerm) terms.get(3); + final FunctionTerm positiveCondition = (FunctionTerm) terms.get(4); + final FunctionTerm negativeCondition = (FunctionTerm) terms.get(5); + return new HeuristicAtom(weightAtLevel, headSign, headAtom, positiveCondition, negativeCondition); + } + + @Override + public boolean isGround() { + return this.ground; + } + + @Override + public Literal toLiteral(boolean negated) { + return new HeuristicLiteral(this, negated); + } + + @Override + public HeuristicAtom substitute(Substitution substitution) { + return new HeuristicAtom( + weightAtLevel.substitute(substitution), + headSign, + headAtom.substitute(substitution), + positiveCondition.substitute(substitution), + negativeCondition.substitute(substitution) + ); + } + + public List getOriginalCondition() { + final List originalPositiveCondition = getOriginalPositiveCondition(); + final List originalNegativeCondition = getOriginalNegativeCondition(); + final List originalCondition = new ArrayList<>(originalPositiveCondition.size() + originalNegativeCondition.size()); + for (HeuristicDirectiveAtom posAtom : originalPositiveCondition) { + originalCondition.add(new HeuristicDirectiveLiteral(posAtom, true)); + } + for (HeuristicDirectiveAtom negAtom : originalNegativeCondition) { + originalCondition.add(new HeuristicDirectiveLiteral(negAtom, false)); + } + return originalCondition; + } + + public List getOriginalPositiveCondition() { + return functionTermToCondition(positiveCondition); + } + + public List getOriginalNegativeCondition() { + return functionTermToCondition(negativeCondition); + } + + @Override + public String toString() { + return Util.join(PREDICATE.getName() + "(", this.getTerms(), ")"); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + HeuristicAtom that = (HeuristicAtom) o; + return weightAtLevel.equals(that.weightAtLevel) && + headSign == that.headSign && + headAtom.equals(that.headAtom) && + positiveCondition.equals(that.positiveCondition) && + negativeCondition.equals(that.negativeCondition); + } + + @Override + public int hashCode() { + return Objects.hash(weightAtLevel, headSign, headAtom, positiveCondition, negativeCondition); + } + + public static HeuristicAtom fromHeuristicDirective(HeuristicDirective heuristicDirective) { + return new HeuristicAtom( + heuristicDirective.getWeightAtLevel(), + heuristicDirective.getHead().getSigns().iterator().next(), + toFunctionTerm((BasicAtom) heuristicDirective.getHead().getAtom()), + conditionToFunctionTerm(heuristicDirective.getBody().getBodyAtomsPositive(), FUNCTION_POSITIVE_CONDITION), + conditionToFunctionTerm(heuristicDirective.getBody().getBodyAtomsNegative(), FUNCTION_NEGATIVE_CONDITION) + ); + } + + private static FunctionTerm conditionToFunctionTerm(Collection heuristicDirectiveAtoms, String topLevelFunctionName) { + final List terms = new ArrayList<>(heuristicDirectiveAtoms.size()); + for (HeuristicDirectiveAtom heuristicDirectiveAtom : heuristicDirectiveAtoms) { + final Atom atom = heuristicDirectiveAtom.getAtom(); + if (atom instanceof BasicAtom) { + String atomFunctionName = toName(heuristicDirectiveAtom.getSigns()); + terms.add(FunctionTerm.getInstance(atomFunctionName, toFunctionTerm((BasicAtom) atom))); + } + } + return FunctionTerm.getInstance(topLevelFunctionName, terms); + } + + private static List functionTermToCondition(FunctionTerm functionTerm) { + final List terms = functionTerm.getTerms(); + final List condition = new ArrayList<>(terms.size()); + for (Term term : terms) { + final FunctionTerm termHeuristicDirectiveAtom = (FunctionTerm) term; + final Set signSet = toSignSet(termHeuristicDirectiveAtom.getSymbol()); + condition.add(HeuristicDirectiveAtom.body(signSet, toAtom((FunctionTerm)termHeuristicDirectiveAtom.getTerms().get(0)))); + } + return condition; + } +} diff --git a/src/main/java/at/ac/tuwien/kr/alpha/grounder/atoms/HeuristicInfluencerAtom.java b/src/main/java/at/ac/tuwien/kr/alpha/grounder/atoms/HeuristicInfluencerAtom.java new file mode 100644 index 000000000..647e4c6f7 --- /dev/null +++ b/src/main/java/at/ac/tuwien/kr/alpha/grounder/atoms/HeuristicInfluencerAtom.java @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2018-2021, the Alpha Team. + * All rights reserved. + * + * Additional changes made by Siemens. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.grounder.atoms; + +import at.ac.tuwien.kr.alpha.common.Predicate; +import at.ac.tuwien.kr.alpha.common.atoms.BasicAtom; +import at.ac.tuwien.kr.alpha.common.atoms.BasicLiteral; +import at.ac.tuwien.kr.alpha.common.terms.ConstantTerm; +import at.ac.tuwien.kr.alpha.common.terms.Term; +import at.ac.tuwien.kr.alpha.grounder.Substitution; +import at.ac.tuwien.kr.alpha.solver.ThriceTruth; + +import java.util.List; +import java.util.Set; + +import static at.ac.tuwien.kr.alpha.Util.join; +import static at.ac.tuwien.kr.alpha.common.heuristics.HeuristicSignSetUtil.toName; +import static java.util.Arrays.asList; + +public class HeuristicInfluencerAtom extends BasicAtom { + public static final Predicate ON = Predicate.getInstance("HeuOn", 2, true); + public static final Predicate OFF = Predicate.getInstance("HeuOff", 2, true); + + private HeuristicInfluencerAtom(Predicate predicate, Term heuristicID, Term signSetName) { + super(predicate, asList(heuristicID, signSetName)); + } + + private HeuristicInfluencerAtom(Predicate predicate, int id, String signSetName) { + this(predicate, ConstantTerm.getInstance(Integer.toString(id)), ConstantTerm.getInstance(signSetName)); + } + + public static HeuristicInfluencerAtom on(int id, Set signSet) { + return new HeuristicInfluencerAtom(ON, id, toName(signSet)); + } + + public static HeuristicInfluencerAtom off(int id, Set signSet) { + return new HeuristicInfluencerAtom(OFF, id, toName(signSet)); + } + + public static HeuristicInfluencerAtom get(boolean on, int id, Set signSet) { + return new HeuristicInfluencerAtom(on ? ON : OFF, id, toName(signSet)); + } + + @Override + public Predicate getPredicate() { + return predicate; + } + + @Override + public List getTerms() { + return terms; + } + + @Override + public ChoiceAtom withTerms(List terms) { + throw new UnsupportedOperationException("Changing terms is not supported for HeuristicInfluencerAtoms!"); + } + + @Override + public boolean isGround() { + // NOTE: terms are ConstantTerms, which are ground by definition. + return true; + } + + @Override + public BasicLiteral toLiteral(boolean negated) { + throw new UnsupportedOperationException(this.getClass().getName() + " cannot be literalized"); + } + + @Override + public HeuristicInfluencerAtom substitute(Substitution substitution) { + return this; + } + + @Override + public String toString() { + return join(predicate.getName() + "(", terms, ")"); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + + HeuristicInfluencerAtom that = (HeuristicInfluencerAtom) o; + + return predicate.equals(that.predicate) && terms.equals(that.terms); + } + + @Override + public int hashCode() { + return 31 * predicate.hashCode() + terms.hashCode(); + } +} \ No newline at end of file diff --git a/src/main/java/at/ac/tuwien/kr/alpha/grounder/atoms/HeuristicLiteral.java b/src/main/java/at/ac/tuwien/kr/alpha/grounder/atoms/HeuristicLiteral.java new file mode 100644 index 000000000..de97b8555 --- /dev/null +++ b/src/main/java/at/ac/tuwien/kr/alpha/grounder/atoms/HeuristicLiteral.java @@ -0,0 +1,75 @@ +/** + * Copyright (c) 2018 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.grounder.atoms; + +import at.ac.tuwien.kr.alpha.common.atoms.Literal; +import at.ac.tuwien.kr.alpha.common.terms.Term; +import at.ac.tuwien.kr.alpha.common.terms.VariableTerm; +import at.ac.tuwien.kr.alpha.grounder.Substitution; + +import java.util.HashSet; +import java.util.Set; + +public class HeuristicLiteral extends Literal { + + public HeuristicLiteral(HeuristicAtom atom, boolean negated) { + super(atom, negated); + } + + @Override + public HeuristicAtom getAtom() { + return (HeuristicAtom)atom; + } + + @Override + public HeuristicLiteral negate() { + return new HeuristicLiteral(getAtom(), !positive); + } + + @Override + public HeuristicLiteral substitute(Substitution substitution) { + return new HeuristicLiteral(getAtom().substitute(substitution), positive); + } + + @Override + public Set getBindingVariables() { + Set bindingVariables = new HashSet<>(); + for (Term term : getTerms()) { + bindingVariables.addAll(term.getOccurringVariables()); + } + return bindingVariables; + } + + @Override + public Set getNonBindingVariables() { + Set nonbindingVariables = new HashSet<>(); + for (Term term : getTerms()) { + nonbindingVariables.addAll(term.getOccurringVariables()); + } + return nonbindingVariables; + } + +} diff --git a/src/main/java/at/ac/tuwien/kr/alpha/grounder/instantiation/DefaultLazyGroundingInstantiationStrategy.java b/src/main/java/at/ac/tuwien/kr/alpha/grounder/instantiation/DefaultLazyGroundingInstantiationStrategy.java index a57aa1699..90afbfc1b 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/grounder/instantiation/DefaultLazyGroundingInstantiationStrategy.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/grounder/instantiation/DefaultLazyGroundingInstantiationStrategy.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2020, the Alpha Team. * All rights reserved. * @@ -25,15 +25,12 @@ */ package at.ac.tuwien.kr.alpha.grounder.instantiation; -import java.util.LinkedHashSet; -import java.util.Map; - import at.ac.tuwien.kr.alpha.Util; import at.ac.tuwien.kr.alpha.common.Assignment; import at.ac.tuwien.kr.alpha.common.AtomStore; -import at.ac.tuwien.kr.alpha.common.Predicate; import at.ac.tuwien.kr.alpha.common.atoms.Atom; import at.ac.tuwien.kr.alpha.common.atoms.Literal; +import at.ac.tuwien.kr.alpha.common.program.Facts; import at.ac.tuwien.kr.alpha.grounder.IndexedInstanceStorage; import at.ac.tuwien.kr.alpha.grounder.Instance; import at.ac.tuwien.kr.alpha.grounder.NaiveGrounder; @@ -41,6 +38,9 @@ import at.ac.tuwien.kr.alpha.solver.Solver; import at.ac.tuwien.kr.alpha.solver.ThriceTruth; +import java.util.LinkedHashSet; +import java.util.Map; + /** * Implementation of {@link AbstractLiteralInstantiationStrategy} designed for use in {@link NaiveGrounder}. * @@ -68,11 +68,10 @@ public class DefaultLazyGroundingInstantiationStrategy extends AbstractLiteralIn private AtomStore atomStore; private Assignment currentAssignment; private LinkedHashSet staleWorkingMemoryEntries; - private Map> facts; + private Facts facts; private boolean accumulatorEnabled; - public DefaultLazyGroundingInstantiationStrategy(WorkingMemory workingMemory, AtomStore atomStore, - Map> facts, boolean accumulator) { + public DefaultLazyGroundingInstantiationStrategy(WorkingMemory workingMemory, AtomStore atomStore, Facts facts, boolean accumulator) { this.workingMemory = workingMemory; this.atomStore = atomStore; this.facts = facts; @@ -106,7 +105,7 @@ protected Iterable computeCandidateInstances(Atom partiallyGroundAtom) //@formatter:on @Override protected AssignmentStatus getAssignmentStatusForAtom(Atom atom) { - if (this.currentAssignment == null || this.isFact(atom)) { + if (this.currentAssignment == null || facts.isFact(atom)) { // currentAssignment == null is a legitimate case, grounder may be in bootstrap // and will call bindNextAtom with null assignment in that case. // Assumption: since the atom came from working memory and we must be in @@ -141,14 +140,6 @@ protected AssignmentStatus getAssignmentStatusForAtom(Atom atom) { return retVal; } - private boolean isFact(Atom atom) { - if (this.facts.get(atom.getPredicate()) == null) { - return false; - } else { - return this.facts.get(atom.getPredicate()).contains(Instance.fromAtom(atom)); - } - } - @Override protected AssignmentStatus getAssignmentStatusForNegatedGroundLiteral(Literal negatedGroundLiteral) { return AssignmentStatus.TRUE; diff --git a/src/main/java/at/ac/tuwien/kr/alpha/grounder/parser/InlineDirectives.java b/src/main/java/at/ac/tuwien/kr/alpha/grounder/parser/InlineDirectives.java index f6fc42ffb..325bd2e58 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/grounder/parser/InlineDirectives.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/grounder/parser/InlineDirectives.java @@ -1,34 +1,107 @@ +/* + * Copyright (c) 2017-2020, the Alpha Team. + * All rights reserved. + * + * Additional changes made by Siemens. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package at.ac.tuwien.kr.alpha.grounder.parser; +import at.ac.tuwien.kr.alpha.common.Directive; + +import java.util.ArrayList; +import java.util.Collection; import java.util.LinkedHashMap; +import java.util.List; import java.util.Map; /** * Stores directives appearing in the ASP program. Each directive starts with # and ends with . - * Copyright (c) 2017, the Alpha Team. + * Copyright (c) 2017-2020, the Alpha Team. */ public class InlineDirectives { public enum DIRECTIVE { - enum_predicate_is + enum_predicate_is, + heuristic, } - private final LinkedHashMap directives = new LinkedHashMap<>(); + private final LinkedHashMap> directives = new LinkedHashMap<>(); - public String getDirectiveValue(DIRECTIVE directive) { - return directives.get(directive); - } - - public void addDirective(DIRECTIVE directive, String value) { - if (directives.get(directive) != null) { + public Directive getDirectiveValue(DIRECTIVE directive) { + List values = directives.get(directive); + if (values == null) { + return null; + } + if (values.size() > 1) { throw new RuntimeException("Inline directive multiply defined."); } - directives.put(directive, value); + return values.iterator().next(); + } + + public void addDirective(DIRECTIVE directive, Directive value) { + directives.putIfAbsent(directive, new ArrayList<>()); + directives.get(directive).add(value); + } + + public void replaceDirectives(DIRECTIVE directive, List values) { + directives.put(directive, values); } public void accumulate(InlineDirectives other) { - for (Map.Entry directiveEntry : other.directives.entrySet()) { - addDirective(directiveEntry.getKey(), directiveEntry.getValue()); + for (Map.Entry> directiveEntry : other.directives.entrySet()) { + for (Directive directiveValue : directiveEntry.getValue()) { + addDirective(directiveEntry.getKey(), directiveValue); + } } } + + public boolean isEmpty() { + return directives.isEmpty(); + } + + /** + * @return a new collection of all directives, changes to which will not be reflected in the program + */ + public Collection getDirectives() { + List flatList = new ArrayList<>(); + for (List list : directives.values()) { + flatList.addAll(list); + } + return flatList; + } + + /** + * @param type + * @return a collection of directives of the given type, changes to which will be reflected in the program; + * or {@code null} if no directives of the given type exist. + */ + public Collection getDirectives(DIRECTIVE type) { + return directives.get(type); + } + + public boolean hasDirectives(DIRECTIVE type) { + Collection directives = getDirectives(type); + return directives != null && !directives.isEmpty(); + } } diff --git a/src/main/java/at/ac/tuwien/kr/alpha/grounder/parser/ParseTreeVisitor.java b/src/main/java/at/ac/tuwien/kr/alpha/grounder/parser/ParseTreeVisitor.java index 2f12d49c7..b52c1815a 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/grounder/parser/ParseTreeVisitor.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/grounder/parser/ParseTreeVisitor.java @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2016-2018, the Alpha Team. +/* + * Copyright (c) 2016-2021, the Alpha Team. * All rights reserved. * * Additional changes made by Siemens. @@ -27,13 +27,32 @@ */ package at.ac.tuwien.kr.alpha.grounder.parser; -import at.ac.tuwien.kr.alpha.antlr.ASPCore2BaseVisitor; -import at.ac.tuwien.kr.alpha.antlr.ASPCore2Lexer; -import at.ac.tuwien.kr.alpha.antlr.ASPCore2Parser; +import org.antlr.v4.runtime.RuleContext; +import org.antlr.v4.runtime.tree.TerminalNode; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeMap; +import java.util.TreeSet; + +import at.ac.tuwien.kr.alpha.antlr.AlphaASPBaseVisitor; +import at.ac.tuwien.kr.alpha.antlr.AlphaASPParser; +import at.ac.tuwien.kr.alpha.antlr.AlphaASPParser.Directive_heuristicContext; +import at.ac.tuwien.kr.alpha.antlr.AlphaASPParser.Weight_annotationContext; +import at.ac.tuwien.kr.alpha.antlr.AlphaASPParser.Weight_at_levelContext; import at.ac.tuwien.kr.alpha.common.AnswerSet; import at.ac.tuwien.kr.alpha.common.BasicAnswerSet; import at.ac.tuwien.kr.alpha.common.ComparisonOperator; +import at.ac.tuwien.kr.alpha.common.EnumerationDirective; +import at.ac.tuwien.kr.alpha.common.HeuristicDirective; import at.ac.tuwien.kr.alpha.common.Predicate; +import at.ac.tuwien.kr.alpha.common.WeightAtLevel; import at.ac.tuwien.kr.alpha.common.atoms.AggregateAtom; import at.ac.tuwien.kr.alpha.common.atoms.AggregateLiteral; import at.ac.tuwien.kr.alpha.common.atoms.Atom; @@ -45,6 +64,9 @@ import at.ac.tuwien.kr.alpha.common.atoms.ExternalLiteral; import at.ac.tuwien.kr.alpha.common.atoms.Literal; import at.ac.tuwien.kr.alpha.common.fixedinterpretations.PredicateInterpretation; +import at.ac.tuwien.kr.alpha.common.heuristics.HeuristicDirectiveAtom; +import at.ac.tuwien.kr.alpha.common.heuristics.HeuristicDirectiveBody; +import at.ac.tuwien.kr.alpha.common.heuristics.HeuristicDirectiveLiteral; import at.ac.tuwien.kr.alpha.common.program.InputProgram; import at.ac.tuwien.kr.alpha.common.rule.BasicRule; import at.ac.tuwien.kr.alpha.common.rule.head.ChoiceHead; @@ -56,25 +78,13 @@ import at.ac.tuwien.kr.alpha.common.terms.IntervalTerm; import at.ac.tuwien.kr.alpha.common.terms.Term; import at.ac.tuwien.kr.alpha.common.terms.VariableTerm; -import org.antlr.v4.runtime.RuleContext; -import org.antlr.v4.runtime.tree.TerminalNode; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.SortedSet; -import java.util.TreeMap; -import java.util.TreeSet; +import at.ac.tuwien.kr.alpha.grounder.parser.InlineDirectives.DIRECTIVE; +import at.ac.tuwien.kr.alpha.solver.ThriceTruth; +import static at.ac.tuwien.kr.alpha.Util.oops; import static java.util.Collections.emptyList; -/** - * Copyright (c) 2016-2018, the Alpha Team. - */ -public class ParseTreeVisitor extends ASPCore2BaseVisitor { +public class ParseTreeVisitor extends AlphaASPBaseVisitor { private final Map externals; private final boolean acceptVariables; @@ -90,6 +100,11 @@ public ParseTreeVisitor(Map externals, boolean this.acceptVariables = acceptVariables; } + void initialize() { + inlineDirectives = new InlineDirectives(); + programBuilder = InputProgram.builder(); + } + private UnsupportedOperationException notSupported(RuleContext ctx) { return new UnsupportedOperationException("Unsupported syntax encountered: " + ctx.getText()); } @@ -97,22 +112,22 @@ private UnsupportedOperationException notSupported(RuleContext ctx) { /** * Translates a program context (referring to a node in an ATN specific to ANTLR) to the internal representation of Alpha. */ - public InputProgram translate(ASPCore2Parser.ProgramContext input) { + public InputProgram translate(AlphaASPParser.ProgramContext input) { return visitProgram(input); } /** * Translates a context for answer sets (referring to a node in an ATN specific to ANTLR) to the representation that Alpha uses. */ - public Set translate(ASPCore2Parser.Answer_setsContext input) { + public Set translate(AlphaASPParser.Answer_setsContext input) { return visitAnswer_sets(input); } @Override - public Set visitAnswer_sets(ASPCore2Parser.Answer_setsContext ctx) { + public Set visitAnswer_sets(AlphaASPParser.Answer_setsContext ctx) { Set result = new TreeSet<>(); - for (ASPCore2Parser.Answer_setContext answerSetContext : ctx.answer_set()) { + for (AlphaASPParser.Answer_setContext answerSetContext : ctx.answer_set()) { result.add(visitAnswer_set(answerSetContext)); } @@ -120,11 +135,11 @@ public Set visitAnswer_sets(ASPCore2Parser.Answer_setsContext ctx) { } @Override - public AnswerSet visitAnswer_set(ASPCore2Parser.Answer_setContext ctx) { + public AnswerSet visitAnswer_set(AlphaASPParser.Answer_setContext ctx) { SortedSet predicates = new TreeSet<>(); Map> predicateInstances = new TreeMap<>(); - for (ASPCore2Parser.Classical_literalContext classicalLiteralContext : ctx.classical_literal()) { + for (AlphaASPParser.Classical_literalContext classicalLiteralContext : ctx.classical_literal()) { Atom atom = visitClassical_literal(classicalLiteralContext); predicates.add(atom.getPredicate()); @@ -147,7 +162,7 @@ public String visitTerminal(TerminalNode node) { } @Override - public InputProgram visitProgram(ASPCore2Parser.ProgramContext ctx) { + public InputProgram visitProgram(AlphaASPParser.ProgramContext ctx) { // program : statements? query?; if (ctx.query() != null) { throw notSupported(ctx.query()); @@ -156,24 +171,23 @@ public InputProgram visitProgram(ASPCore2Parser.ProgramContext ctx) { if (ctx.statements() == null) { return InputProgram.EMPTY; } - inlineDirectives = new InlineDirectives(); - programBuilder = InputProgram.builder(); + initialize(); visitStatements(ctx.statements()); programBuilder.addInlineDirectives(inlineDirectives); return programBuilder.build(); } @Override - public Object visitStatements(ASPCore2Parser.StatementsContext ctx) { + public Object visitStatements(AlphaASPParser.StatementsContext ctx) { // statements : statement+; - for (ASPCore2Parser.StatementContext statementContext : ctx.statement()) { + for (AlphaASPParser.StatementContext statementContext : ctx.statement()) { visit(statementContext); } return null; } @Override - public Object visitStatement_fact(ASPCore2Parser.Statement_factContext ctx) { + public Object visitStatement_fact(AlphaASPParser.Statement_factContext ctx) { // head DOT Head head = visitHead(ctx.head()); if (head instanceof NormalHead) { @@ -185,28 +199,31 @@ public Object visitStatement_fact(ASPCore2Parser.Statement_factContext ctx) { return null; } + + @Override - public Object visitStatement_constraint(ASPCore2Parser.Statement_constraintContext ctx) { + public Object visitStatement_constraint(AlphaASPParser.Statement_constraintContext ctx) { // CONS body DOT programBuilder.addRule(new BasicRule(null, visitBody(ctx.body()))); return null; } @Override - public Object visitStatement_rule(ASPCore2Parser.Statement_ruleContext ctx) { + public BasicRule visitStatement_rule(AlphaASPParser.Statement_ruleContext ctx) { // head CONS body DOT - programBuilder.addRule(new BasicRule(visitHead(ctx.head()), visitBody(ctx.body()))); - return null; + final BasicRule rule = new BasicRule(visitHead(ctx.head()), visitBody(ctx.body())); + programBuilder.addRule(rule); + return rule; } @Override - public Object visitStatement_weightConstraint(ASPCore2Parser.Statement_weightConstraintContext ctx) { + public Object visitStatement_weightConstraint(AlphaASPParser.Statement_weightConstraintContext ctx) { // WCONS body? DOT SQUARE_OPEN weight_at_level SQUARE_CLOSE throw notSupported(ctx); } @Override - public Object visitStatement_directive(ASPCore2Parser.Statement_directiveContext ctx) { + public Object visitStatement_directive(AlphaASPParser.Statement_directiveContext ctx) { // directive visitDirective(ctx.directive()); // Parsed directives are globally stored, nothing to return here. @@ -214,7 +231,7 @@ public Object visitStatement_directive(ASPCore2Parser.Statement_directiveContext } @Override - public Head visitDisjunction(ASPCore2Parser.DisjunctionContext ctx) { + public Head visitDisjunction(AlphaASPParser.DisjunctionContext ctx) { // disjunction : classical_literal (OR disjunction)?; if (ctx.disjunction() != null) { throw notSupported(ctx); @@ -223,7 +240,7 @@ public Head visitDisjunction(ASPCore2Parser.DisjunctionContext ctx) { } @Override - public Head visitHead(ASPCore2Parser.HeadContext ctx) { + public Head visitHead(AlphaASPParser.HeadContext ctx) { // head : disjunction | choice; if (ctx.choice() != null) { return visitChoice(ctx.choice()); @@ -232,7 +249,7 @@ public Head visitHead(ASPCore2Parser.HeadContext ctx) { } @Override - public Head visitChoice(ASPCore2Parser.ChoiceContext ctx) { + public Head visitChoice(AlphaASPParser.ChoiceContext ctx) { // choice : (lt=term lop=binop)? CURLY_OPEN choice_elements? CURLY_CLOSE (uop=binop ut=term)?; Term lt = null; ComparisonOperator lop = null; @@ -250,7 +267,7 @@ public Head visitChoice(ASPCore2Parser.ChoiceContext ctx) { } @Override - public List visitChoice_elements(ASPCore2Parser.Choice_elementsContext ctx) { + public List visitChoice_elements(AlphaASPParser.Choice_elementsContext ctx) { // choice_elements : choice_element (SEMICOLON choice_elements)?; List choiceElements; if (ctx.choice_elements() != null) { @@ -263,9 +280,9 @@ public List visitChoice_elements(ASPCore2Parser.Choice } @Override - public ChoiceHead.ChoiceElement visitChoice_element(ASPCore2Parser.Choice_elementContext ctx) { + public ChoiceHead.ChoiceElement visitChoice_element(AlphaASPParser.Choice_elementContext ctx) { // choice_element : classical_literal (COLON naf_literals?)?; - BasicAtom atom = (BasicAtom) visitClassical_literal(ctx.classical_literal()); + BasicAtom atom = visitClassical_literal(ctx.classical_literal()); if (ctx.naf_literals() != null) { return new ChoiceHead.ChoiceElement(atom, visitNaf_literals(ctx.naf_literals())); } else { @@ -274,7 +291,7 @@ public ChoiceHead.ChoiceElement visitChoice_element(ASPCore2Parser.Choice_elemen } @Override - public List visitNaf_literals(ASPCore2Parser.Naf_literalsContext ctx) { + public List visitNaf_literals(AlphaASPParser.Naf_literalsContext ctx) { // naf_literals : naf_literal (COMMA naf_literals)?; List literals; if (ctx.naf_literals() != null) { @@ -287,14 +304,14 @@ public List visitNaf_literals(ASPCore2Parser.Naf_literalsContext ctx) { } @Override - public Object visitDirective_enumeration(ASPCore2Parser.Directive_enumerationContext ctx) { + public Object visitDirective_enumeration(AlphaASPParser.Directive_enumerationContext ctx) { // directive_enumeration : SHARP 'enum_predicate_is' ID DOT; - inlineDirectives.addDirective(InlineDirectives.DIRECTIVE.enum_predicate_is, ctx.ID().getText()); + inlineDirectives.addDirective(InlineDirectives.DIRECTIVE.enum_predicate_is, new EnumerationDirective(ctx.ID().getText())); return null; } @Override - public List visitBody(ASPCore2Parser.BodyContext ctx) { + public List visitBody(AlphaASPParser.BodyContext ctx) { // body : ( naf_literal | aggregate ) (COMMA body)?; if (ctx == null) { return emptyList(); @@ -313,8 +330,7 @@ public List visitBody(ASPCore2Parser.BodyContext ctx) { } @Override - public AggregateLiteral visitAggregate(ASPCore2Parser.AggregateContext ctx) { - + public AggregateLiteral visitAggregate(AlphaASPParser.AggregateContext ctx) { // aggregate : NAF? (lt=term lop=binop)? aggregate_function CURLY_OPEN aggregate_elements CURLY_CLOSE (uop=binop ut=term)?; boolean isPositive = ctx.NAF() == null; Term lt = null; @@ -335,7 +351,7 @@ public AggregateLiteral visitAggregate(ASPCore2Parser.AggregateContext ctx) { } @Override - public List visitAggregate_elements(ASPCore2Parser.Aggregate_elementsContext ctx) { + public List visitAggregate_elements(AlphaASPParser.Aggregate_elementsContext ctx) { // aggregate_elements : aggregate_element (SEMICOLON aggregate_elements)?; final List aggregateElements = new ArrayList<>(); do { @@ -346,7 +362,7 @@ public List visitAggregate_elements(ASPCore2Pars } @Override - public AggregateAtom.AggregateElement visitAggregate_element(ASPCore2Parser.Aggregate_elementContext ctx) { + public AggregateAtom.AggregateElement visitAggregate_element(AlphaASPParser.Aggregate_elementContext ctx) { // aggregate_element : basic_terms? (COLON naf_literals?)?; List basicTerms = ctx.basic_terms() != null ? visitBasic_terms(ctx.basic_terms()) : null; if (ctx.naf_literals() != null) { @@ -356,7 +372,7 @@ public AggregateAtom.AggregateElement visitAggregate_element(ASPCore2Parser.Aggr } @Override - public List visitBasic_terms(ASPCore2Parser.Basic_termsContext ctx) { + public List visitBasic_terms(AlphaASPParser.Basic_termsContext ctx) { // basic_terms : basic_term (COMMA basic_terms)? ; List termList = new ArrayList<>(); do { @@ -366,7 +382,7 @@ public List visitBasic_terms(ASPCore2Parser.Basic_termsContext ctx) { } @Override - public Term visitBasic_term(ASPCore2Parser.Basic_termContext ctx) { + public Term visitBasic_term(AlphaASPParser.Basic_termContext ctx) { // basic_term : ground_term | variable_term; if (ctx.ground_term() != null) { return visitGround_term(ctx.ground_term()); @@ -376,7 +392,7 @@ public Term visitBasic_term(ASPCore2Parser.Basic_termContext ctx) { } @Override - public Term visitGround_term(ASPCore2Parser.Ground_termContext ctx) { + public Term visitGround_term(AlphaASPParser.Ground_termContext ctx) { // ground_term : ID | QUOTED_STRING | MINUS? NUMBER; if (ctx.ID() != null) { return ConstantTerm.getSymbolicInstance(ctx.ID().getText()); @@ -393,17 +409,17 @@ public Term visitGround_term(ASPCore2Parser.Ground_termContext ctx) { } @Override - public Term visitVariable_term(ASPCore2Parser.Variable_termContext ctx) { - // variable_term : VARIABLE | ANONYMOUS_VARIABLE; - if (ctx.VARIABLE() != null) { - return VariableTerm.getInstance(ctx.VARIABLE().getText()); + public Term visitVariable_term(AlphaASPParser.Variable_termContext ctx) { + // variable_term : variable | ANONYMOUS_VARIABLE; + if (ctx.variable() != null) { + return VariableTerm.getInstance(ctx.variable().getText()); } else { return VariableTerm.getAnonymousInstance(); } } @Override - public AggregateAtom.AggregateFunctionSymbol visitAggregate_function(ASPCore2Parser.Aggregate_functionContext ctx) { + public AggregateAtom.AggregateFunctionSymbol visitAggregate_function(AlphaASPParser.Aggregate_functionContext ctx) { // aggregate_function : AGGREGATE_COUNT | AGGREGATE_MAX | AGGREGATE_MIN | AGGREGATE_SUM; if (ctx.AGGREGATE_COUNT() != null) { return AggregateAtom.AggregateFunctionSymbol.COUNT; @@ -419,7 +435,7 @@ public AggregateAtom.AggregateFunctionSymbol visitAggregate_function(ASPCore2Par } @Override - public ComparisonOperator visitBinop(ASPCore2Parser.BinopContext ctx) { + public ComparisonOperator visitBinop(AlphaASPParser.BinopContext ctx) { // binop : EQUAL | UNEQUAL | LESS | GREATER | LESS_OR_EQ | GREATER_OR_EQ; if (ctx.EQUAL() != null) { return ComparisonOperator.EQ; @@ -439,42 +455,84 @@ public ComparisonOperator visitBinop(ASPCore2Parser.BinopContext ctx) { } @Override - public ComparisonAtom visitBuiltin_atom(ASPCore2Parser.Builtin_atomContext ctx) { + public ComparisonAtom visitBuiltin_atom(AlphaASPParser.Builtin_atomContext ctx) { // builtin_atom : term binop term; return new ComparisonAtom( - (Term) visit(ctx.term(0)), - (Term) visit(ctx.term(1)), + (Term) visit(ctx.term(0)), + (Term) visit(ctx.term(1)), visitBinop(ctx.binop()) ); } @Override - public Literal visitNaf_literal(ASPCore2Parser.Naf_literalContext ctx) { - // naf_literal : NAF? (external_atom | classical_literal | builtin_atom); + public Literal visitNaf_literal(AlphaASPParser.Naf_literalContext ctx) { + // naf_literal : NAF? atom; boolean isCurrentLiteralNegated = ctx.NAF() != null; + Atom atom = visitAtom(ctx.atom()); + if (atom instanceof ComparisonAtom) { + return new ComparisonLiteral((ComparisonAtom) atom, !isCurrentLiteralNegated); + } else if (atom instanceof BasicAtom) { + return new BasicLiteral((BasicAtom) atom, !isCurrentLiteralNegated); + } else if (atom instanceof ExternalAtom) { + return new ExternalLiteral((ExternalAtom) atom, !isCurrentLiteralNegated); + } + throw notSupported(ctx); + } + + @Override + public Atom visitAtom(AlphaASPParser.AtomContext ctx) { + // atom : (external_atom | classical_literal | builtin_atom); if (ctx.builtin_atom() != null) { - return new ComparisonLiteral(visitBuiltin_atom(ctx.builtin_atom()), !isCurrentLiteralNegated); + return visitBuiltin_atom(ctx.builtin_atom()); } else if (ctx.classical_literal() != null) { - return new BasicLiteral(visitClassical_literal(ctx.classical_literal()), !isCurrentLiteralNegated); + return visitClassical_literal(ctx.classical_literal()); } else if (ctx.external_atom() != null) { - return new ExternalLiteral(visitExternal_atom(ctx.external_atom()), !isCurrentLiteralNegated); + return visitExternal_atom(ctx.external_atom()); } throw notSupported(ctx); } @Override - public BasicAtom visitClassical_literal(ASPCore2Parser.Classical_literalContext ctx) { - // classical_literal : MINUS? ID (PAREN_OPEN terms PAREN_CLOSE)?; + public WeightAtLevel visitWeight_annotation(Weight_annotationContext ctx) { + // SQUARE_OPEN weight_at_level SQUARE_CLOSE + if (ctx == null) { + return new WeightAtLevel(null, null); + } + return visitWeight_at_level(ctx.weight_at_level()); + } + + @Override + public WeightAtLevel visitWeight_at_level(Weight_at_levelContext ctx) { + // term (AT term)? (COMMA terms)? + Term weight; + Term level = null; + weight = (Term) visit(ctx.term(0)); + if (ctx.AT() != null) { + level = (Term) visit(ctx.term(1)); + } + // FIXME: further terms are currently ignored + + return new WeightAtLevel(weight, level); + } + + @Override + public BasicAtom visitClassical_literal(AlphaASPParser.Classical_literalContext ctx) { + // classical_literal : MINUS? basic_atom; if (ctx.MINUS() != null) { throw notSupported(ctx); } + return visitBasic_atom(ctx.basic_atom()); + } + @Override + public BasicAtom visitBasic_atom(AlphaASPParser.Basic_atomContext ctx) { + // basic_atom : ID (PAREN_OPEN terms PAREN_CLOSE)?; final List terms = visitTerms(ctx.terms()); return new BasicAtom(Predicate.getInstance(ctx.ID().getText(), terms.size()), terms); } @Override - public List visitTerms(ASPCore2Parser.TermsContext ctx) { + public List visitTerms(AlphaASPParser.TermsContext ctx) { // terms : term (COMMA terms)?; if (ctx == null) { return emptyList(); @@ -482,7 +540,7 @@ public List visitTerms(ASPCore2Parser.TermsContext ctx) { final List terms = new ArrayList<>(); do { - ASPCore2Parser.TermContext term = ctx.term(); + AlphaASPParser.TermContext term = ctx.term(); terms.add((Term) visit(term)); } while ((ctx = ctx.terms()) != null); @@ -490,28 +548,28 @@ public List visitTerms(ASPCore2Parser.TermsContext ctx) { } @Override - public ConstantTerm visitTerm_number(ASPCore2Parser.Term_numberContext ctx) { + public ConstantTerm visitTerm_number(AlphaASPParser.Term_numberContext ctx) { return ConstantTerm.getInstance(Integer.parseInt(ctx.NUMBER().getText())); } @Override - public ConstantTerm visitTerm_const(ASPCore2Parser.Term_constContext ctx) { + public ConstantTerm visitTerm_const(AlphaASPParser.Term_constContext ctx) { return ConstantTerm.getSymbolicInstance(ctx.ID().getText()); } @Override - public ConstantTerm visitTerm_string(ASPCore2Parser.Term_stringContext ctx) { + public ConstantTerm visitTerm_string(AlphaASPParser.Term_stringContext ctx) { String quotedString = ctx.QUOTED_STRING().getText().replace("\\\"", "\""); return ConstantTerm.getInstance(quotedString.substring(1, quotedString.length() - 1)); } @Override - public FunctionTerm visitTerm_func(ASPCore2Parser.Term_funcContext ctx) { + public FunctionTerm visitTerm_func(AlphaASPParser.Term_funcContext ctx) { return FunctionTerm.getInstance(ctx.ID().getText(), visitTerms(ctx.terms())); } @Override - public VariableTerm visitTerm_anonymousVariable(ASPCore2Parser.Term_anonymousVariableContext ctx) { + public VariableTerm visitTerm_anonymousVariable(AlphaASPParser.Term_anonymousVariableContext ctx) { if (!acceptVariables) { throw notSupported(ctx); } @@ -520,21 +578,21 @@ public VariableTerm visitTerm_anonymousVariable(ASPCore2Parser.Term_anonymousVar } @Override - public VariableTerm visitTerm_variable(ASPCore2Parser.Term_variableContext ctx) { + public VariableTerm visitTerm_variable(AlphaASPParser.Term_variableContext ctx) { if (!acceptVariables) { throw notSupported(ctx); } - return VariableTerm.getInstance(ctx.VARIABLE().getText()); + return VariableTerm.getInstance(ctx.variable().getText()); } @Override - public Term visitTerm_parenthesisedTerm(ASPCore2Parser.Term_parenthesisedTermContext ctx) { + public Term visitTerm_parenthesisedTerm(AlphaASPParser.Term_parenthesisedTermContext ctx) { return (Term) visit(ctx.term()); } @Override - public ExternalAtom visitExternal_atom(ASPCore2Parser.External_atomContext ctx) { + public ExternalAtom visitExternal_atom(AlphaASPParser.External_atomContext ctx) { // external_atom : AMPERSAND ID (SQUARE_OPEN input = terms SQUARE_CLOSE)? (PAREN_OPEN output = terms PAREN_CLOSE)?; if (ctx.MINUS() != null) { @@ -551,32 +609,148 @@ public ExternalAtom visitExternal_atom(ASPCore2Parser.External_atomContext ctx) List outputTerms = visitTerms(ctx.output); return new ExternalAtom( - Predicate.getInstance(predicateName, outputTerms.size()), - interpretation, - visitTerms(ctx.input), + Predicate.getInstance(predicateName, outputTerms.size()), + interpretation, + visitTerms(ctx.input), outputTerms ); } @Override - public IntervalTerm visitTerm_interval(ASPCore2Parser.Term_intervalContext ctx) { - // interval : lower = (NUMBER | VARIABLE) DOT DOT upper = (NUMBER | VARIABLE); - ASPCore2Parser.IntervalContext ictx = ctx.interval(); - String lowerText = ictx.lower.getText(); - String upperText = ictx.upper.getText(); - Term lower = ictx.lower.getType() == ASPCore2Lexer.NUMBER ? ConstantTerm.getInstance(Integer.parseInt(lowerText)) : VariableTerm.getInstance(lowerText); - Term upper = ictx.upper.getType() == ASPCore2Lexer.NUMBER ? ConstantTerm.getInstance(Integer.parseInt(upperText)) : VariableTerm.getInstance(upperText); + public Object visitDirective_heuristic(Directive_heuristicContext ctx) { + // directive_heuristic : SHARP 'heuristic' heuristic_head_atom (heuristic_body)? DOT heuristic_weight_annotation?; + final HeuristicDirectiveAtom head = visitHeuristic_head_atom(ctx.heuristic_head_atom()); + final HeuristicDirectiveBody body = visitHeuristic_body(ctx.heuristic_body()); + final WeightAtLevel weightAtLevel = visitHeuristic_weight_annotation(ctx.heuristic_weight_annotation()); + HeuristicDirective heuristicDirective = new HeuristicDirective(head, body, weightAtLevel); + inlineDirectives.addDirective(DIRECTIVE.heuristic, heuristicDirective); + return heuristicDirective; + } + + @Override + public HeuristicDirectiveAtom visitHeuristic_head_atom(AlphaASPParser.Heuristic_head_atomContext ctx) { + // heuristic_head_atom : (heuristic_head_sign)? basic_atom; + final ThriceTruth sign = visitHeuristic_head_sign(ctx.heuristic_head_sign()); + final BasicAtom atom = visitBasic_atom(ctx.basic_atom()); + return HeuristicDirectiveAtom.head(sign, atom); + } + + @Override + public ThriceTruth visitHeuristic_head_sign(AlphaASPParser.Heuristic_head_signContext ctx) { + // heuristic_head_sign : HEU_SIGN_T | HEU_SIGN_F; + if (ctx != null) { + if (ctx.HEU_SIGN_T() != null) { + return ThriceTruth.TRUE; + } else if (ctx.HEU_SIGN_F() != null) { + return ThriceTruth.FALSE; + } + } + return null; + } + + @Override + public HeuristicDirectiveBody visitHeuristic_body(AlphaASPParser.Heuristic_bodyContext ctx) { + // heuristic_body : COLON heuristic_body_literal (COMMA heuristic_body_literal)*; + final List bodyLiterals = new ArrayList<>(); + if (ctx != null) { + for (AlphaASPParser.Heuristic_body_literalContext literalContext : ctx.heuristic_body_literal()) { + bodyLiterals.add(visitHeuristic_body_literal(literalContext)); + } + } + return new HeuristicDirectiveBody(bodyLiterals); + } + + @Override + public HeuristicDirectiveLiteral visitHeuristic_body_literal(AlphaASPParser.Heuristic_body_literalContext ctx) { + // heuristic_body_literal : NAF? heuristic_body_atom | aggregate; + if (ctx.aggregate() != null) { + final AggregateLiteral aggregateLiteral = visitAggregate(ctx.aggregate()); + return new HeuristicDirectiveLiteral(HeuristicDirectiveAtom.body(aggregateLiteral.getAtom()), !aggregateLiteral.isNegated()); + } else { + return new HeuristicDirectiveLiteral(visitHeuristic_body_atom(ctx.heuristic_body_atom()), ctx.NAF() == null); + } + } + + @Override + public HeuristicDirectiveAtom visitHeuristic_body_atom(AlphaASPParser.Heuristic_body_atomContext ctx) { + // heuristic_body_atom : (heuristic_body_sign? basic_atom) | builtin_atom | external_atom; + final Set heuristicSigns = visitHeuristic_body_sign(ctx.heuristic_body_sign()); + Atom atom; + if (ctx.basic_atom() != null) { + atom = visitBasic_atom(ctx.basic_atom()); + } else if (ctx.builtin_atom() != null) { + atom = visitBuiltin_atom(ctx.builtin_atom()); + } else if (ctx.external_atom() != null) { + atom = visitExternal_atom(ctx.external_atom()); + } else { + throw oops("No known atom found in heuristic body atom"); + } + return HeuristicDirectiveAtom.body(heuristicSigns, atom); + } + + @Override + public Set visitHeuristic_body_sign(AlphaASPParser.Heuristic_body_signContext ctx) { + if (ctx == null) { + return null; + } + final Set heuristicSigns = new HashSet<>(); + if (!ctx.HEU_SIGN_T().isEmpty()) { + heuristicSigns.add(ThriceTruth.TRUE); + } + if (!ctx.HEU_SIGN_F().isEmpty()) { + heuristicSigns.add(ThriceTruth.FALSE); + } + if (!ctx.HEU_SIGN_M().isEmpty()) { + heuristicSigns.add(ThriceTruth.MBT); + } + if (!ctx.HEU_BODY_SIGN().isEmpty()) { + for (TerminalNode compoundBodySign : ctx.HEU_BODY_SIGN()) { + for (char signChar : compoundBodySign.getText().toCharArray()) { + heuristicSigns.add(ThriceTruth.fromChar(signChar)); + } + } + } + return heuristicSigns; + } + + @Override + public WeightAtLevel visitHeuristic_weight_annotation(AlphaASPParser.Heuristic_weight_annotationContext ctx) { + // heuristic_weight_annotation : SQUARE_OPEN heuristic_weight_at_level SQUARE_CLOSE; + if (ctx == null) { + return new WeightAtLevel(null, null); + } + return visitHeuristic_weight_at_level(ctx.heuristic_weight_at_level()); + } + + @Override + public WeightAtLevel visitHeuristic_weight_at_level(AlphaASPParser.Heuristic_weight_at_levelContext ctx) { + // heuristic_weight_at_level : term (AT term)?; + Term weight; + Term level = null; + weight = (Term) visit(ctx.term(0)); + if (ctx.AT() != null) { + level = (Term) visit(ctx.term(1)); + } + + return new WeightAtLevel(weight, level); + } + + public IntervalTerm visitTerm_interval(AlphaASPParser.Term_intervalContext ctx) { + //interval : (lowerNum=NUMBER | lowerVar=variable) DOT DOT (upperNum=NUMBER | upperVar=variable); + AlphaASPParser.IntervalContext ictx = ctx.interval(); + Term lower = ictx.lowerNum != null ? ConstantTerm.getInstance(Integer.parseInt(ictx.lowerNum.getText())) : VariableTerm.getInstance(ictx.lowerVar.getText()); + Term upper = ictx.upperNum != null ? ConstantTerm.getInstance(Integer.parseInt(ictx.upperNum.getText())) : VariableTerm.getInstance(ictx.upperVar.getText()); return IntervalTerm.getInstance(lower, upper); } @Override - public Object visitTerm_minusArithTerm(ASPCore2Parser.Term_minusArithTermContext ctx) { + public Object visitTerm_minusArithTerm(AlphaASPParser.Term_minusArithTermContext ctx) { // | MINUS term return ArithmeticTerm.MinusTerm.getInstance((Term) visit(ctx.term())); } @Override - public Object visitTerm_timesdivmodArithTerm(ASPCore2Parser.Term_timesdivmodArithTermContext ctx) { + public Object visitTerm_timesdivmodArithTerm(AlphaASPParser.Term_timesdivmodArithTermContext ctx) { // | term (TIMES | DIV | MODULO) term ArithmeticTerm.ArithmeticOperator op = ctx.TIMES() != null ? ArithmeticTerm.ArithmeticOperator.TIMES : ctx.DIV() != null ? ArithmeticTerm.ArithmeticOperator.DIV : ArithmeticTerm.ArithmeticOperator.MODULO; @@ -584,21 +758,21 @@ public Object visitTerm_timesdivmodArithTerm(ASPCore2Parser.Term_timesdivmodArit } @Override - public Object visitTerm_plusminusArithTerm(ASPCore2Parser.Term_plusminusArithTermContext ctx) { + public Object visitTerm_plusminusArithTerm(AlphaASPParser.Term_plusminusArithTermContext ctx) { // | term (PLUS | MINUS) term ArithmeticTerm.ArithmeticOperator op = ctx.PLUS() != null ? ArithmeticTerm.ArithmeticOperator.PLUS : ArithmeticTerm.ArithmeticOperator.MINUS; return ArithmeticTerm.getInstance((Term) visit(ctx.term(0)), op, (Term) visit(ctx.term(1))); } @Override - public Object visitTerm_powerArithTerm(ASPCore2Parser.Term_powerArithTermContext ctx) { + public Object visitTerm_powerArithTerm(AlphaASPParser.Term_powerArithTermContext ctx) { // | term POWER term ArithmeticTerm.ArithmeticOperator op = ArithmeticTerm.ArithmeticOperator.POWER; return ArithmeticTerm.getInstance((Term) visit(ctx.term(0)), op, (Term) visit(ctx.term(1))); } @Override - public Object visitTerm_bitxorArithTerm(ASPCore2Parser.Term_bitxorArithTermContext ctx) { + public Object visitTerm_bitxorArithTerm(AlphaASPParser.Term_bitxorArithTermContext ctx) { // | term BITXOR term return ArithmeticTerm.getInstance((Term) visit(ctx.term(0)), ArithmeticTerm.ArithmeticOperator.BITXOR, (Term) visit(ctx.term(1))); } diff --git a/src/main/java/at/ac/tuwien/kr/alpha/grounder/parser/ProgramParser.java b/src/main/java/at/ac/tuwien/kr/alpha/grounder/parser/ProgramParser.java index 7bea8f5a2..8f3b4d5e5 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/grounder/parser/ProgramParser.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/grounder/parser/ProgramParser.java @@ -1,5 +1,37 @@ +/* + * Copyright (c) 2017-2020, the Alpha Team. + * All rights reserved. + * + * Additional changes made by Siemens. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package at.ac.tuwien.kr.alpha.grounder.parser; +import at.ac.tuwien.kr.alpha.CustomErrorListener; +import at.ac.tuwien.kr.alpha.antlr.AlphaASPLexer; +import at.ac.tuwien.kr.alpha.antlr.AlphaASPParser; +import at.ac.tuwien.kr.alpha.common.fixedinterpretations.PredicateInterpretation; +import at.ac.tuwien.kr.alpha.common.program.InputProgram; import org.antlr.v4.runtime.BailErrorStrategy; import org.antlr.v4.runtime.CharStream; import org.antlr.v4.runtime.CharStreams; @@ -13,12 +45,6 @@ import java.util.Collections; import java.util.Map; -import at.ac.tuwien.kr.alpha.CustomErrorListener; -import at.ac.tuwien.kr.alpha.antlr.ASPCore2Lexer; -import at.ac.tuwien.kr.alpha.antlr.ASPCore2Parser; -import at.ac.tuwien.kr.alpha.common.fixedinterpretations.PredicateInterpretation; -import at.ac.tuwien.kr.alpha.common.program.InputProgram; - public class ProgramParser { private final Map externals; @@ -49,15 +75,15 @@ public InputProgram parse(String s) { public InputProgram parse(CharStream stream) throws IOException { //@formatter:off /* - * // In order to require less memory: use unbuffered streams and avoid constructing a full parse tree. - * ASPCore2Lexer lexer = new ASPCore2Lexer(new UnbufferedCharStream(is)); - * lexer.setTokenFactory(new CommonTokenFactory(true)); - * final ASPCore2Parser parser = new ASPCore2Parser(new UnbufferedTokenStream<>(lexer)); + * // In order to require less memory: use unbuffered streams and avoid constructing a full parse tree. + * ASPCore2Lexer lexer = new ASPCore2Lexer(new UnbufferedCharStream(is)); + * lexer.setTokenFactory(new CommonTokenFactory(true)); + * final ASPCore2Parser parser = new ASPCore2Parser(new UnbufferedTokenStream<>(lexer)); * parser.setBuildParseTree(false); */ //@formatter:on - CommonTokenStream tokens = new CommonTokenStream(new ASPCore2Lexer(stream)); - final ASPCore2Parser parser = new ASPCore2Parser(tokens); + CommonTokenStream tokens = new CommonTokenStream(new AlphaASPLexer(stream)); + final AlphaASPParser parser = new AlphaASPParser(tokens); // Try SLL parsing mode (faster but may terminate incorrectly). parser.getInterpreter().setPredictionMode(PredictionMode.SLL); @@ -66,7 +92,7 @@ public InputProgram parse(CharStream stream) throws IOException { final CustomErrorListener errorListener = new CustomErrorListener(stream.getSourceName()); - ASPCore2Parser.ProgramContext programContext; + AlphaASPParser.ProgramContext programContext; try { // Parse program programContext = parser.program(); diff --git a/src/main/java/at/ac/tuwien/kr/alpha/grounder/parser/ProgramPartParser.java b/src/main/java/at/ac/tuwien/kr/alpha/grounder/parser/ProgramPartParser.java index 56593b6a3..8e2827b50 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/grounder/parser/ProgramPartParser.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/grounder/parser/ProgramPartParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2020, the Alpha Team. + * Copyright (c) 2018-2021, the Alpha Team. * All rights reserved. * * Additional changes made by Siemens. @@ -28,10 +28,12 @@ package at.ac.tuwien.kr.alpha.grounder.parser; -import at.ac.tuwien.kr.alpha.antlr.ASPCore2Lexer; -import at.ac.tuwien.kr.alpha.antlr.ASPCore2Parser; +import at.ac.tuwien.kr.alpha.antlr.AlphaASPLexer; +import at.ac.tuwien.kr.alpha.antlr.AlphaASPParser; +import at.ac.tuwien.kr.alpha.common.HeuristicDirective; import at.ac.tuwien.kr.alpha.common.atoms.BasicAtom; import at.ac.tuwien.kr.alpha.common.atoms.Literal; +import at.ac.tuwien.kr.alpha.common.rule.BasicRule; import at.ac.tuwien.kr.alpha.common.terms.Term; import org.antlr.v4.runtime.CharStreams; import org.antlr.v4.runtime.CommonTokenStream; @@ -49,26 +51,37 @@ public class ProgramPartParser { private final ParseTreeVisitor visitor = new ParseTreeVisitor(Collections.emptyMap(), true); public Term parseTerm(String s) { - final ASPCore2Parser parser = getASPCore2Parser(s); + final AlphaASPParser parser = getParser(s); return (Term)parse(parser.term()); } public BasicAtom parseBasicAtom(String s) { - final ASPCore2Parser parser = getASPCore2Parser(s); + final AlphaASPParser parser = getParser(s); return (BasicAtom)parse(parser.classical_literal()); } public Literal parseLiteral(String s) { - final ASPCore2Parser parser = getASPCore2Parser(s); + final AlphaASPParser parser = getParser(s); return (Literal)parse(parser.naf_literal()); } - private ASPCore2Parser getASPCore2Parser(String s) { - return new ASPCore2Parser(new CommonTokenStream(new ASPCore2Lexer(CharStreams.fromString(s)))); + public BasicRule parseBasicRule(String s) { + final AlphaASPParser parser = getParser(s); + return (BasicRule)parse(parser.statement()); + } + + public HeuristicDirective parseHeuristicDirective(String s) { + final AlphaASPParser parser = getParser(s); + return (HeuristicDirective)parse(parser.directive_heuristic()); + } + + private AlphaASPParser getParser(String s) { + return new AlphaASPParser(new CommonTokenStream(new AlphaASPLexer(CharStreams.fromString(s)))); } private Object parse(ParserRuleContext context) { try { + visitor.initialize(); return visitor.visit(context); } catch (RecognitionException | ParseCancellationException e) { // If there were issues parsing the given string, we diff --git a/src/main/java/at/ac/tuwien/kr/alpha/grounder/structure/AnalyzeUnjustified.java b/src/main/java/at/ac/tuwien/kr/alpha/grounder/structure/AnalyzeUnjustified.java index 658429f70..aec7dcfed 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/grounder/structure/AnalyzeUnjustified.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/grounder/structure/AnalyzeUnjustified.java @@ -1,21 +1,32 @@ +/* + * Copyright (c) 2018-2020, the Alpha Team. + * All rights reserved. + * + * Additional changes made by Siemens. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package at.ac.tuwien.kr.alpha.grounder.structure; -import static at.ac.tuwien.kr.alpha.Util.oops; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Set; - import at.ac.tuwien.kr.alpha.common.Assignment; import at.ac.tuwien.kr.alpha.common.AtomStore; import at.ac.tuwien.kr.alpha.common.Predicate; @@ -31,22 +42,35 @@ import at.ac.tuwien.kr.alpha.grounder.Unification; import at.ac.tuwien.kr.alpha.grounder.Unifier; import at.ac.tuwien.kr.alpha.solver.ThriceTruth; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; + +import static at.ac.tuwien.kr.alpha.Util.oops; /** * Copyright (c) 2018-2020, the Alpha Team. */ public class AnalyzeUnjustified { private static final Logger LOGGER = LoggerFactory.getLogger(AnalyzeUnjustified.class); - private final InternalProgram programAnalysis; + private final InternalProgram program; private final AtomStore atomStore; - private final Map> factsFromProgram; private int renamingCounter; private int padDepth; - public AnalyzeUnjustified(InternalProgram programAnalysis, AtomStore atomStore, Map> factsFromProgram) { - this.programAnalysis = programAnalysis; + public AnalyzeUnjustified(InternalProgram program, AtomStore atomStore) { + this.program = program; this.atomStore = atomStore; - this.factsFromProgram = factsFromProgram; padDepth = 0; } @@ -295,7 +319,7 @@ private AssignedAtomsIterator getAssignedAtomsOverPredicate(Predicate predicate) // Find more substitutions, consider currentAssignment. List assignedAtoms = this.assignedAtoms.get(predicate); // Consider instances from facts. - LinkedHashSet factsOverPredicate = factsFromProgram.get(predicate); + Set factsOverPredicate = program.getFactsByPredicate().get(predicate); return new AssignedAtomsIterator(predicate, assignedAtoms, factsOverPredicate); } @@ -304,10 +328,10 @@ private static class AssignedAtomsIterator implements Iterator { private final Iterator assignedAtomsIterator; private final Iterator factsIterator; - public AssignedAtomsIterator(Predicate predicate, List assignedAtoms, Set facts) { + AssignedAtomsIterator(Predicate predicate, List assignedAtoms, Set facts) { this.predicate = predicate; this.assignedAtomsIterator = assignedAtoms == null ? Collections.emptyIterator() : assignedAtoms.iterator(); - this.factsIterator = facts == null ? Collections.emptyIterator() : facts.iterator(); + this.factsIterator = facts.iterator(); } @Override @@ -331,17 +355,15 @@ private List rulesHeadUnifyingWith(Atom p) { List rulesWithUnifier = new ArrayList<>(); Predicate predicate = p.getPredicate(); - + ArrayList definingRulesAndFacts = new ArrayList<>(); // Get facts over the same predicate. - LinkedHashSet factInstances = factsFromProgram.get(predicate); - if (factInstances != null) { - for (Instance factInstance : factInstances) { - definingRulesAndFacts.add(new FactOrNonGroundRule(factInstance)); - } + Set factInstances = program.getFactsByPredicate().get(predicate); + for (Instance factInstance : factInstances) { + definingRulesAndFacts.add(new FactOrNonGroundRule(factInstance)); } - HashSet rulesDefiningPredicate = programAnalysis.getPredicateDefiningRules().get(predicate); + HashSet rulesDefiningPredicate = program.getPredicateDefiningRules().get(predicate); if (rulesDefiningPredicate != null) { for (InternalRule nonGroundRule : rulesDefiningPredicate) { definingRulesAndFacts.add(new FactOrNonGroundRule(nonGroundRule)); @@ -358,6 +380,7 @@ private List rulesHeadUnifyingWith(Atom p) { headAtom = rule.getHeadAtom(); } else { // Create atom and empty rule body out of instance. + assert factOrNonGroundRule.factInstance != null; headAtom = new BasicAtom(p.getPredicate(), factOrNonGroundRule.factInstance.terms); renamedBody = Collections.emptySet(); } diff --git a/src/main/java/at/ac/tuwien/kr/alpha/grounder/transformation/ChoiceHeadToNormal.java b/src/main/java/at/ac/tuwien/kr/alpha/grounder/transformation/ChoiceHeadToNormal.java index a38bcce0c..a7c7a3c3b 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/grounder/transformation/ChoiceHeadToNormal.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/grounder/transformation/ChoiceHeadToNormal.java @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2017-2018, the Alpha Team. +/* + * Copyright (c) 2017-2021, the Alpha Team. * All rights reserved. * * Additional changes made by Siemens. @@ -44,9 +44,6 @@ import java.util.Iterator; import java.util.List; -/** - * Copyright (c) 2017-2020, the Alpha Team. - */ public class ChoiceHeadToNormal extends ProgramTransformation { private final static String PREDICATE_NEGATION_PREFIX = "_n"; @@ -89,13 +86,7 @@ public InputProgram apply(InputProgram inputProgram) { } // Construct head atom for the choice. - Predicate headPredicate = head.getPredicate(); - - Predicate negPredicate = Predicate.getInstance(PREDICATE_NEGATION_PREFIX + headPredicate.getName(), headPredicate.getArity() + 1, true); - List headTerms = new ArrayList<>(head.getTerms()); - headTerms.add(0, ConstantTerm.getInstance("1")); // FIXME: when introducing classical negation, this is 1 for classical positive atoms and 0 for - // classical negative atoms. - Atom negHead = new BasicAtom(negPredicate, headTerms); + Atom negHead = constructNegativeChoiceAtom(head); // Construct two guessing rules. List guessingRuleBodyWithNegHead = new ArrayList<>(ruleBody); @@ -103,7 +94,7 @@ public InputProgram apply(InputProgram inputProgram) { additionalRules.add(new BasicRule(new NormalHead(negHead), guessingRuleBodyWithNegHead)); List guessingRuleBodyWithHead = new ArrayList<>(ruleBody); - guessingRuleBodyWithHead.add(new BasicAtom(negPredicate, headTerms).toLiteral(false)); + guessingRuleBodyWithHead.add(negHead.toLiteral(false)); additionalRules.add(new BasicRule(new NormalHead(head), guessingRuleBodyWithHead)); // TODO: when cardinality constraints are possible, process the boundaries by adding a constraint with a cardinality check. @@ -113,6 +104,14 @@ public InputProgram apply(InputProgram inputProgram) { .addInlineDirectives(inputProgram.getInlineDirectives()).build(); } + public static Atom constructNegativeChoiceAtom(Atom headAtom) { + final Predicate headPredicate = headAtom.getPredicate(); + final Predicate negPredicate = Predicate.getInstance(PREDICATE_NEGATION_PREFIX + headPredicate.getName(), headPredicate.getArity() + 1, true); + final List headTerms = new ArrayList<>(headAtom.getTerms()); + headTerms.add(0, ConstantTerm.getInstance("1")); // FIXME: when introducing classical negation, this is 1 for classical positive atoms and 0 for classical negative atoms. + return new BasicAtom(negPredicate, headTerms); + } + private static boolean containsIntervalTerms(Atom atom) { for (Term term : atom.getTerms()) { if (IntervalTerm.termContainsIntervalTerm(term)) { diff --git a/src/main/java/at/ac/tuwien/kr/alpha/grounder/transformation/EnumerationRewriting.java b/src/main/java/at/ac/tuwien/kr/alpha/grounder/transformation/EnumerationRewriting.java index f080496e7..3f72dce47 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/grounder/transformation/EnumerationRewriting.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/grounder/transformation/EnumerationRewriting.java @@ -1,5 +1,6 @@ package at.ac.tuwien.kr.alpha.grounder.transformation; +import at.ac.tuwien.kr.alpha.common.EnumerationDirective; import at.ac.tuwien.kr.alpha.common.Predicate; import at.ac.tuwien.kr.alpha.common.atoms.Atom; import at.ac.tuwien.kr.alpha.common.atoms.BasicLiteral; @@ -28,12 +29,12 @@ public class EnumerationRewriting extends ProgramTransformation + *
  • creating one copy of each heuristic directive for every rule that can derive its head
  • + *
  • copying the body of the head-deriving rule to the condition of the heuristic directive (unifying variables where necessary).
  • + * + * This ensures that every heuristic directive is only applicable if there is a rule that can derive its head. + */ +public class HeuristicDirectiveConditionEnhancement extends ProgramTransformation { + + private final boolean respectDomspecHeuristics; + + public HeuristicDirectiveConditionEnhancement(HeuristicsConfiguration heuristicsConfiguration) { + this.respectDomspecHeuristics = heuristicsConfiguration.isRespectDomspecHeuristics(); + } + + public HeuristicDirectiveConditionEnhancement(boolean respectDomspecHeuristics) { + this.respectDomspecHeuristics = respectDomspecHeuristics; + } + + @Override + public InputProgram apply(InputProgram inputProgram) { + Collection heuristicDirectives = inputProgram.getInlineDirectives().getDirectives(InlineDirectives.DIRECTIVE.heuristic); + if (heuristicDirectives == null) { + return inputProgram; + } + + final InputProgram.Builder prgBuilder = InputProgram.builder().addFacts(inputProgram.getFacts()).addRules(inputProgram.getRules()); + final InlineDirectives copiedDirectives = new InlineDirectives(); + copiedDirectives.accumulate(inputProgram.getInlineDirectives()); + final List newHeuristicDirectives = new ArrayList<>(); + + if (respectDomspecHeuristics) { + for (Directive directive : copiedDirectives.getDirectives(InlineDirectives.DIRECTIVE.heuristic)) { + transformAndAdd((HeuristicDirective) directive, newHeuristicDirectives, inputProgram); + } + copiedDirectives.replaceDirectives(InlineDirectives.DIRECTIVE.heuristic, newHeuristicDirectives); + } else { + copiedDirectives.getDirectives(InlineDirectives.DIRECTIVE.heuristic).clear(); + } + prgBuilder.addInlineDirectives(copiedDirectives); + + return prgBuilder.build(); + } + + private void transformAndAdd(final HeuristicDirective directive, final Collection newHeuristicDirectives, final InputProgram inputProgram) { + final Atom directiveHeadAtom = directive.getHead().getAtom(); + final Collection headDerivingRules = new ArrayList<>(); + for (BasicRule rule : inputProgram.getRules()) { + if (rule.getHead() == null) { + continue; + } else if (rule.getHead() instanceof NormalHead) { + final NormalHead normalRuleHead = (NormalHead) rule.getHead(); + if (directiveHeadAtom.getPredicate().equals(normalRuleHead.getAtom().getPredicate())) { + headDerivingRules.add(rule); + } + } else if (rule.getHead() instanceof DisjunctiveHead) { + final DisjunctiveHead disjunctiveRuleHead = (DisjunctiveHead) rule.getHead(); + for (Atom ruleHeadAtom : disjunctiveRuleHead.disjunctiveAtoms) { + if (directiveHeadAtom.getPredicate().equals(ruleHeadAtom.getPredicate())) { + headDerivingRules.add(rule); + break; + } + } + } else { + throw oops(this.getClass().getSimpleName() + " only supports rules with normal or disjunctive heads, all other heads should have been normalized already"); + } + } + for (BasicRule headDerivingRule : headDerivingRules) { + final UniqueVariableNames uniqueVariableNames = new UniqueVariableNames(); + final Unifier unifierForStandardisingApart = uniqueVariableNames.makeVariableNamesUnique(directive, headDerivingRule); + headDerivingRule = headDerivingRule.substitute(unifierForStandardisingApart); + final Atom ruleHeadAtom = getMatchingRuleHeadAtom(headDerivingRule.getHead(), directiveHeadAtom); + Unifier unifier = Unification.unifyAtoms(ruleHeadAtom, directiveHeadAtom); + if (unifier == null) { + continue; // do not enhance directive with rule whose head does not unify + } + headDerivingRule = headDerivingRule.substitute(unifier); + final HeuristicDirective unifiedDirective = new HeuristicDirective(directive.getHead().substitute(unifier), directive.getBody().substitute(unifier), directive.getWeightAtLevel().substitute(unifier)); + final HeuristicDirectiveBody newDirectiveBody = new HeuristicDirectiveBody( + joinAtoms(unifiedDirective.getBody().getBodyAtomsPositive(), headDerivingRule.getPositiveBody(), HeuristicDirectiveAtom.SIGNS_T), + joinAtoms(unifiedDirective.getBody().getBodyAtomsNegative(), headDerivingRule.getNegativeBody(), HeuristicDirectiveAtom.DEFAULT_BODY_SIGNS)); + final HeuristicDirective enhancedDirective = new HeuristicDirective(unifiedDirective.getHead(), newDirectiveBody, unifiedDirective.getWeightAtLevel()); + newHeuristicDirectives.add(enhancedDirective); + } + } + + private Collection joinAtoms(Collection existingHeuristicCondition, Collection ruleBodyToAdd, Set defaultSignSet) { + final Set newHeuristicCondition = new HashSet<>(existingHeuristicCondition); + for (Literal literal : ruleBodyToAdd) { + final Atom atom = literal.getAtom(); + if (!(atom instanceof BasicAtom || atom instanceof ComparisonAtom || atom instanceof AggregateAtom)) { + throw new UnsupportedOperationException("Body atom " + atom + " not yet supported by " + this.getClass().getSimpleName()); + } + final Set signSet = atom instanceof BasicAtom ? defaultSignSet : null; + newHeuristicCondition.add(HeuristicDirectiveAtom.body(signSet, atom)); + } + return newHeuristicCondition; + } + + private Atom getMatchingRuleHeadAtom(Head ruleHead, Atom directiveHeadAtom) { + Atom ruleHeadAtom = null; + if (ruleHead instanceof NormalHead) { + final NormalHead normalRuleHead = (NormalHead) ruleHead; + assert directiveHeadAtom.getPredicate().equals(normalRuleHead.getAtom().getPredicate()); + ruleHeadAtom = normalRuleHead.getAtom(); + } else if (ruleHead instanceof DisjunctiveHead) { + final DisjunctiveHead disjunctiveRuleHead = (DisjunctiveHead) ruleHead; + for (Atom disjunctiveAtom : disjunctiveRuleHead.disjunctiveAtoms) { + if (directiveHeadAtom.getPredicate().equals(disjunctiveAtom.getPredicate())) { + if (ruleHeadAtom != null) { + throw new UnsupportedOperationException(this.getClass().getSimpleName() + " does not support disjunctive heads with multiple atoms of the same predicate."); + } + ruleHeadAtom = disjunctiveAtom; + } + } + } else { + throw oops(this.getClass().getSimpleName() + " only supports rules with normal or disjunctive heads, all other heads should have been normalized already"); + } + return ruleHeadAtom; + } +} diff --git a/src/main/java/at/ac/tuwien/kr/alpha/grounder/transformation/HeuristicDirectiveToRule.java b/src/main/java/at/ac/tuwien/kr/alpha/grounder/transformation/HeuristicDirectiveToRule.java new file mode 100644 index 000000000..df83e80a7 --- /dev/null +++ b/src/main/java/at/ac/tuwien/kr/alpha/grounder/transformation/HeuristicDirectiveToRule.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2018-2021 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.grounder.transformation; + +import at.ac.tuwien.kr.alpha.common.Directive; +import at.ac.tuwien.kr.alpha.common.HeuristicDirective; +import at.ac.tuwien.kr.alpha.common.program.InputProgram; +import at.ac.tuwien.kr.alpha.common.rule.BasicRule; +import at.ac.tuwien.kr.alpha.common.rule.head.Head; +import at.ac.tuwien.kr.alpha.common.rule.head.NormalHead; +import at.ac.tuwien.kr.alpha.grounder.atoms.HeuristicAtom; +import at.ac.tuwien.kr.alpha.grounder.parser.InlineDirectives; +import at.ac.tuwien.kr.alpha.solver.heuristics.HeuristicsConfiguration; + +import java.util.Collection; +import java.util.Iterator; + +/** + * Converts all {@link HeuristicDirective}s to {@link BasicRule}s if + * {@link HeuristicsConfiguration#isRespectDomspecHeuristics()} is {@code true}, + * otherwise removes all heuristic directives. + */ +public class HeuristicDirectiveToRule extends ProgramTransformation { + + private final boolean respectDomspecHeuristics; + + public HeuristicDirectiveToRule(HeuristicsConfiguration heuristicsConfiguration) { + this.respectDomspecHeuristics = heuristicsConfiguration.isRespectDomspecHeuristics(); + } + + public HeuristicDirectiveToRule(boolean respectDomspecHeuristics) { + this.respectDomspecHeuristics = respectDomspecHeuristics; + } + + @Override + public InputProgram apply(InputProgram inputProgram) { + Collection heuristicDirectives = inputProgram.getInlineDirectives().getDirectives(InlineDirectives.DIRECTIVE.heuristic); + if (heuristicDirectives == null) { + return inputProgram; + } + + final InputProgram.Builder prgBuilder = InputProgram.builder().addFacts(inputProgram.getFacts()).addRules(inputProgram.getRules()); + final InlineDirectives copiedDirectives = new InlineDirectives(); + copiedDirectives.accumulate(inputProgram.getInlineDirectives()); + + if (respectDomspecHeuristics) { + Iterator directivesIterator = copiedDirectives.getDirectives(InlineDirectives.DIRECTIVE.heuristic).iterator(); + while (directivesIterator.hasNext()) { + Directive directive = directivesIterator.next(); + transformAndAddToProgram((HeuristicDirective) directive, prgBuilder); + directivesIterator.remove(); + } + } else { + copiedDirectives.getDirectives(InlineDirectives.DIRECTIVE.heuristic).clear(); + } + prgBuilder.addInlineDirectives(copiedDirectives); + + return prgBuilder.build(); + } + + private void transformAndAddToProgram(HeuristicDirective heuristicDirective, InputProgram.Builder prgBuilder) { + final Head head = new NormalHead(HeuristicAtom.fromHeuristicDirective(heuristicDirective)); + final BasicRule rule = new BasicRule(head, heuristicDirective.getBody().toReducedRuleBody()); + prgBuilder.addRule(rule); + } +} diff --git a/src/main/java/at/ac/tuwien/kr/alpha/grounder/transformation/IntervalTermToIntervalAtom.java b/src/main/java/at/ac/tuwien/kr/alpha/grounder/transformation/IntervalTermToIntervalAtom.java index c0702d05a..63c40027a 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/grounder/transformation/IntervalTermToIntervalAtom.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/grounder/transformation/IntervalTermToIntervalAtom.java @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2017-2018, the Alpha Team. +/* + * Copyright (c) 2017-2020, the Alpha Team. * All rights reserved. * * Additional changes made by Siemens. @@ -119,8 +119,10 @@ private static Literal rewriteLiteral(Literal lit, Map { private final AggregateRewritingConfig aggregateRewritingCfg; + private final boolean ignoreDomspecHeuristics; - public NormalizeProgramTransformation(AggregateRewritingConfig aggregateCfg) { + public NormalizeProgramTransformation(AggregateRewritingConfig aggregateCfg, boolean ignoreDomspecHeuristics) { this.aggregateRewritingCfg = aggregateCfg; + this.ignoreDomspecHeuristics = ignoreDomspecHeuristics; } @Override @@ -27,6 +56,12 @@ public NormalProgram apply(InputProgram inputProgram) { tmpPrg = new VariableEqualityRemoval().apply(inputProgram); // Transform choice rules. tmpPrg = new ChoiceHeadToNormal().apply(tmpPrg); + // Eliminate any-sign conditions from heuristic directives. + tmpPrg = new SignSetTransformation().apply(tmpPrg); + // Copy bodies of head-deriving rules to conditions of heuristic directives. + tmpPrg = new HeuristicDirectiveConditionEnhancement(!this.ignoreDomspecHeuristics).apply(tmpPrg); + // Translate heuristic directives to rules. + tmpPrg = new HeuristicDirectiveToRule(!this.ignoreDomspecHeuristics).apply(tmpPrg); // Transform cardinality aggregates. tmpPrg = new AggregateRewriting(aggregateRewritingCfg.isUseSortingGridEncoding(), aggregateRewritingCfg.isSupportNegativeValuesInSums()).apply(tmpPrg); // Transform enumeration atoms. diff --git a/src/main/java/at/ac/tuwien/kr/alpha/grounder/transformation/SignSetTransformation.java b/src/main/java/at/ac/tuwien/kr/alpha/grounder/transformation/SignSetTransformation.java new file mode 100644 index 000000000..0d63960b9 --- /dev/null +++ b/src/main/java/at/ac/tuwien/kr/alpha/grounder/transformation/SignSetTransformation.java @@ -0,0 +1,183 @@ +/* + * Copyright (c) 2020-2021 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.grounder.transformation; + +import at.ac.tuwien.kr.alpha.common.Directive; +import at.ac.tuwien.kr.alpha.common.HeuristicDirective; +import at.ac.tuwien.kr.alpha.common.heuristics.HeuristicDirectiveAtom; +import at.ac.tuwien.kr.alpha.common.heuristics.HeuristicDirectiveBody; +import at.ac.tuwien.kr.alpha.common.program.InputProgram; +import at.ac.tuwien.kr.alpha.grounder.parser.InlineDirectives; +import at.ac.tuwien.kr.alpha.solver.ThriceTruth; +import org.apache.commons.collections4.SetUtils; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.LinkedList; +import java.util.List; +import java.util.Queue; +import java.util.Set; + +import static at.ac.tuwien.kr.alpha.Util.asSet; +import static at.ac.tuwien.kr.alpha.solver.ThriceTruth.*; + +/** + * Transforms sign sets as described in Section 5.1 of our paper + * "Domain-Specific Heuristics in Answer Set Programming: A Declarative Non-Monotonic Approach" + */ +public class SignSetTransformation extends ProgramTransformation { + + // sign sets to be replaced: + public static final Set SET_ALL_SIGNS = asSet(ThriceTruth.values()); + public static final Set SET_FM = asSet(FALSE, MBT); + public static final Set SET_FT = asSet(FALSE, TRUE); + public static final Set> SETS_SPLITTABLE = asSet(SET_ALL_SIGNS, SET_FM, SET_FT); + public static final Set SET_M = asSet(MBT); + + // sign sets to be used as replacements: + public static final Set SET_F = asSet(FALSE); + public static final Set SET_MT = asSet(MBT, TRUE); + public static final Set SET_T = asSet(TRUE); + + @Override + public InputProgram apply(InputProgram inputProgram) { + Collection heuristicDirectives = inputProgram.getInlineDirectives().getDirectives(InlineDirectives.DIRECTIVE.heuristic); + if (heuristicDirectives == null) { + return inputProgram; + } + + Queue queue = toQueue(heuristicDirectives); + List transformedDirectives = transformDirectives(queue); + + final InlineDirectives copiedDirectives = new InlineDirectives(); + copiedDirectives.accumulate(inputProgram.getInlineDirectives()); + copiedDirectives.replaceDirectives(InlineDirectives.DIRECTIVE.heuristic, transformedDirectives); + final InputProgram.Builder prgBuilder = InputProgram.builder().addFacts(inputProgram.getFacts()).addRules(inputProgram.getRules()); + prgBuilder.addInlineDirectives(copiedDirectives); + + return prgBuilder.build(); + } + + private static List transformDirectives(Queue queue) { + final List finalDirectives = new ArrayList<>(queue.size()); + HeuristicDirective heuristicDirective; + loopHeuristicDirectives: while ((heuristicDirective = queue.poll()) != null) { + for (HeuristicDirectiveAtom atom : heuristicDirective.getBody().getBodyAtomsPositive()) { + if (SETS_SPLITTABLE.contains(atom.getSigns())) { + queue.addAll(eliminatePositiveSplittable(heuristicDirective, atom)); + continue loopHeuristicDirectives; + } else if (SET_M.equals(atom.getSigns())) { + queue.add(eliminatePositiveM(heuristicDirective, atom)); + continue loopHeuristicDirectives; + } + } + for (HeuristicDirectiveAtom atom : heuristicDirective.getBody().getBodyAtomsNegative()) { + if (SETS_SPLITTABLE.contains(atom.getSigns())) { + queue.add(eliminateNegativeSplittable(heuristicDirective, atom)); + continue loopHeuristicDirectives; + } else if (SET_M.equals(atom.getSigns())) { + queue.addAll(eliminateNegativeM(heuristicDirective, atom)); + continue loopHeuristicDirectives; + } + } + finalDirectives.add(heuristicDirective); + } + return finalDirectives; + } + + private static Queue toQueue(Collection heuristicDirectives) { + Queue queue = new LinkedList<>(); + for (Directive heuristicDirective : heuristicDirectives) { + queue.add((HeuristicDirective)heuristicDirective); + } + return queue; + } + + private static Collection eliminatePositiveSplittable(HeuristicDirective heuristicDirective, HeuristicDirectiveAtom atom) { + final List transformedDirectives = new ArrayList<>(2); + transformedDirectives.add(replaceSignInCondition(heuristicDirective, atom, SetUtils.difference(atom.getSigns(), SET_F), true)); + transformedDirectives.add(replaceSignInCondition(heuristicDirective, atom, SET_F, true)); + return transformedDirectives; + } + + private static HeuristicDirective eliminateNegativeSplittable(HeuristicDirective heuristicDirective, HeuristicDirectiveAtom atom) { + final List transformedNegativeAtoms = new ArrayList<>(heuristicDirective.getBody().getBodyAtomsNegative()); + transformedNegativeAtoms.remove(atom); + transformedNegativeAtoms.add(HeuristicDirectiveAtom.body(SetUtils.difference(atom.getSigns(), SET_F), atom.getAtom())); + transformedNegativeAtoms.add(HeuristicDirectiveAtom.body(SET_F, atom.getAtom())); + final HeuristicDirectiveBody transformedBody = new HeuristicDirectiveBody(heuristicDirective.getBody().getBodyAtomsPositive(), transformedNegativeAtoms); + return replaceBody(heuristicDirective, transformedBody); + } + + private static HeuristicDirective eliminatePositiveM(HeuristicDirective heuristicDirective, HeuristicDirectiveAtom atom) { + final List transformedPositiveAtoms = new ArrayList<>(heuristicDirective.getBody().getBodyAtomsPositive()); + final List transformedNegativeAtoms = new ArrayList<>(heuristicDirective.getBody().getBodyAtomsNegative()); + transformedPositiveAtoms.remove(atom); + transformedPositiveAtoms.add(HeuristicDirectiveAtom.body(SET_MT, atom.getAtom())); + transformedNegativeAtoms.add(HeuristicDirectiveAtom.body(SET_T, atom.getAtom())); + final HeuristicDirectiveBody transformedBody = new HeuristicDirectiveBody(transformedPositiveAtoms, transformedNegativeAtoms); + return replaceBody(heuristicDirective, transformedBody); + } + + private static Collection eliminateNegativeM(HeuristicDirective heuristicDirective, HeuristicDirectiveAtom atom) { + final List transformedDirectives = new ArrayList<>(2); + HeuristicDirective transformedDirective1 = addAtomToPositiveCondition(heuristicDirective, HeuristicDirectiveAtom.body(SET_FT, atom.getAtom())); + transformedDirective1 = removeAtomFromNegativeCondition(transformedDirective1, atom); + HeuristicDirective transformedDirective2 = replaceSignInCondition(heuristicDirective, atom, SET_ALL_SIGNS, false); + transformedDirectives.add(transformedDirective1); + transformedDirectives.add(transformedDirective2); + return transformedDirectives; + } + + private static HeuristicDirective replaceSignInCondition(HeuristicDirective heuristicDirective, HeuristicDirectiveAtom atom, Set signSet, boolean usePositiveCondition) { + final HeuristicDirectiveBody body = heuristicDirective.getBody(); + final List transformedAtoms = new ArrayList<>(usePositiveCondition ? body.getBodyAtomsPositive() : body.getBodyAtomsNegative()); + transformedAtoms.remove(atom); + transformedAtoms.add(HeuristicDirectiveAtom.body(signSet, atom.getAtom())); + final HeuristicDirectiveBody transformedBody = usePositiveCondition ? new HeuristicDirectiveBody(transformedAtoms, body.getBodyAtomsNegative()) : new HeuristicDirectiveBody(body.getBodyAtomsPositive(), transformedAtoms); + return replaceBody(heuristicDirective, transformedBody); + } + + private static HeuristicDirective addAtomToPositiveCondition(HeuristicDirective heuristicDirective, HeuristicDirectiveAtom atom) { + final HeuristicDirectiveBody body = heuristicDirective.getBody(); + final List transformedPositiveAtoms = new ArrayList<>(body.getBodyAtomsPositive()); + transformedPositiveAtoms.add(atom); + final HeuristicDirectiveBody transformedBody = new HeuristicDirectiveBody(transformedPositiveAtoms, body.getBodyAtomsNegative()); + return replaceBody(heuristicDirective, transformedBody); + } + + private static HeuristicDirective removeAtomFromNegativeCondition(HeuristicDirective heuristicDirective, HeuristicDirectiveAtom atom) { + final HeuristicDirectiveBody body = heuristicDirective.getBody(); + final List transformedNegativeAtoms = new ArrayList<>(body.getBodyAtomsNegative()); + transformedNegativeAtoms.remove(atom); + final HeuristicDirectiveBody transformedBody = new HeuristicDirectiveBody(body.getBodyAtomsPositive(), transformedNegativeAtoms); + return replaceBody(heuristicDirective, transformedBody); + } + + private static HeuristicDirective replaceBody(HeuristicDirective heuristicDirective, HeuristicDirectiveBody transformedBody) { + return new HeuristicDirective(heuristicDirective.getHead(), transformedBody, heuristicDirective.getWeightAtLevel()); + } +} diff --git a/src/main/java/at/ac/tuwien/kr/alpha/grounder/transformation/StratifiedEvaluation.java b/src/main/java/at/ac/tuwien/kr/alpha/grounder/transformation/StratifiedEvaluation.java index 36cba1580..aaeb782d9 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/grounder/transformation/StratifiedEvaluation.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/grounder/transformation/StratifiedEvaluation.java @@ -1,3 +1,28 @@ +/* + * Copyright (c) 2019-2020, the Alpha Team. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package at.ac.tuwien.kr.alpha.grounder.transformation; import at.ac.tuwien.kr.alpha.common.Predicate; @@ -9,6 +34,7 @@ import at.ac.tuwien.kr.alpha.common.depgraph.Node; import at.ac.tuwien.kr.alpha.common.depgraph.StratificationAlgorithm; import at.ac.tuwien.kr.alpha.common.program.AnalyzedProgram; +import at.ac.tuwien.kr.alpha.common.program.Facts; import at.ac.tuwien.kr.alpha.common.program.InternalProgram; import at.ac.tuwien.kr.alpha.common.rule.InternalRule; import at.ac.tuwien.kr.alpha.grounder.IndexedInstanceStorage; @@ -30,7 +56,6 @@ import java.util.Collections; import java.util.HashMap; import java.util.HashSet; -import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; @@ -66,8 +91,8 @@ public InternalProgram apply(AnalyzedProgram inputProgram) { predicateDefiningRules = inputProgram.getPredicateDefiningRules(); // Set up list of atoms which are known to be true - these will be expand by the evaluation. - Map> knownFacts = new LinkedHashMap<>(inputProgram.getFactsByPredicate()); - for (Map.Entry> entry : knownFacts.entrySet()) { + final Facts knownFacts = inputProgram.getFactsByPredicate(); + for (Map.Entry> entry : knownFacts.entrySet()) { workingMemory.initialize(entry.getKey()); workingMemory.addInstances(entry.getKey(), true, entry.getValue()); } diff --git a/src/main/java/at/ac/tuwien/kr/alpha/grounder/transformation/VariableEqualityRemoval.java b/src/main/java/at/ac/tuwien/kr/alpha/grounder/transformation/VariableEqualityRemoval.java index 357b6d7cd..8a4573639 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/grounder/transformation/VariableEqualityRemoval.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/grounder/transformation/VariableEqualityRemoval.java @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2017-2018, the Alpha Team. +/* + * Copyright (c) 2017-2021, the Alpha Team. * All rights reserved. * * Additional changes made by Siemens. @@ -27,17 +27,6 @@ */ package at.ac.tuwien.kr.alpha.grounder.transformation; -import at.ac.tuwien.kr.alpha.common.atoms.Atom; -import at.ac.tuwien.kr.alpha.common.atoms.ComparisonLiteral; -import at.ac.tuwien.kr.alpha.common.atoms.Literal; -import at.ac.tuwien.kr.alpha.common.program.InputProgram; -import at.ac.tuwien.kr.alpha.common.rule.BasicRule; -import at.ac.tuwien.kr.alpha.common.rule.head.DisjunctiveHead; -import at.ac.tuwien.kr.alpha.common.rule.head.NormalHead; -import at.ac.tuwien.kr.alpha.common.terms.Term; -import at.ac.tuwien.kr.alpha.common.terms.VariableTerm; -import at.ac.tuwien.kr.alpha.grounder.Unifier; - import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -48,6 +37,16 @@ import java.util.List; import java.util.Map; +import at.ac.tuwien.kr.alpha.common.atoms.ComparisonLiteral; +import at.ac.tuwien.kr.alpha.common.atoms.Literal; +import at.ac.tuwien.kr.alpha.common.program.InputProgram; +import at.ac.tuwien.kr.alpha.common.rule.BasicRule; +import at.ac.tuwien.kr.alpha.common.rule.head.DisjunctiveHead; +import at.ac.tuwien.kr.alpha.common.rule.head.NormalHead; +import at.ac.tuwien.kr.alpha.common.terms.Term; +import at.ac.tuwien.kr.alpha.common.terms.VariableTerm; +import at.ac.tuwien.kr.alpha.grounder.Unifier; + /** * Removes variable equalities from rules by replacing one variable with the other. * @@ -112,7 +111,6 @@ private BasicRule findAndReplaceVariableEquality(BasicRule rule) { if (!rule.isConstraint() && rule.getHead() instanceof DisjunctiveHead) { throw new UnsupportedOperationException("VariableEqualityRemoval cannot be applied to rule with DisjunctiveHead, yet."); } - NormalHead rewrittenHead = rule.isConstraint() ? null : new NormalHead(((NormalHead)rule.getHead()).getAtom()); // Use substitution for actual replacement. Unifier replacementSubstitution = new Unifier(); @@ -131,6 +129,7 @@ private BasicRule findAndReplaceVariableEquality(BasicRule rule) { Literal literal = bodyIterator.next(); if (equalitiesToRemove.contains(literal)) { bodyIterator.remove(); + continue; } for (int i = 0; i < literal.getTerms().size(); i++) { Term replaced = literal.getTerms().get(i).substitute(replacementSubstitution); @@ -138,13 +137,7 @@ private BasicRule findAndReplaceVariableEquality(BasicRule rule) { } } // Replace variables in head. - if (rewrittenHead != null) { - Atom headAtom = rewrittenHead.getAtom(); - for (int i = 0; i < headAtom.getTerms().size(); i++) { - Term replaced = headAtom.getTerms().get(i).substitute(replacementSubstitution); - headAtom.getTerms().set(i, replaced); - } - } + NormalHead rewrittenHead = rule.isConstraint() ? null : new NormalHead(((NormalHead)rule.getHead()).getAtom().substitute(replacementSubstitution)); return new BasicRule(rewrittenHead, rewrittenBody); } } diff --git a/src/main/java/at/ac/tuwien/kr/alpha/grounder/transformation/aggregates/AggregateOperatorNormalization.java b/src/main/java/at/ac/tuwien/kr/alpha/grounder/transformation/aggregates/AggregateOperatorNormalization.java index 26c3f4531..306971d0e 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/grounder/transformation/aggregates/AggregateOperatorNormalization.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/grounder/transformation/aggregates/AggregateOperatorNormalization.java @@ -1,8 +1,5 @@ package at.ac.tuwien.kr.alpha.grounder.transformation.aggregates; -import static at.ac.tuwien.kr.alpha.common.ComparisonOperator.EQ; -import static at.ac.tuwien.kr.alpha.common.ComparisonOperator.LE; - import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -13,7 +10,6 @@ import at.ac.tuwien.kr.alpha.common.atoms.AggregateLiteral; import at.ac.tuwien.kr.alpha.common.atoms.ComparisonAtom; import at.ac.tuwien.kr.alpha.common.atoms.Literal; -import at.ac.tuwien.kr.alpha.common.program.InputProgram; import at.ac.tuwien.kr.alpha.common.rule.BasicRule; import at.ac.tuwien.kr.alpha.common.terms.ArithmeticTerm; import at.ac.tuwien.kr.alpha.common.terms.ArithmeticTerm.ArithmeticOperator; @@ -22,9 +18,9 @@ import at.ac.tuwien.kr.alpha.common.terms.VariableTerm; /** - * Transforms an {@link InputProgram} such that, for all aggregate (body-)literals, only the comparison operators "=" + * Transforms an {@link at.ac.tuwien.kr.alpha.common.program.InputProgram} such that, for all aggregate (body-)literals, only the comparison operators "=" * and "<=" are used. - * + * * Rewriting of "#count" and "#sum" aggregates is done using the following equivalences: *
      *
    • X < #aggr{...} == XP <= #aggr{...}, XP = X + 1
    • @@ -37,11 +33,12 @@ *
    • not X >= #aggr{...} == XP <= #aggr{...}, XP = X + 1
    • *
    * Operators for "#min" and "#max" aggregates are not rewritten. - * - * Note that input programs must only contain aggregate literals of form VAR OP #aggr{...}, i.e. with only - * a left term and operator. When preprocessing programs, apply this transformation AFTER + * + * Note that input programs must only contain aggregate literals of form TERM OP #aggr{...} or #aggr{...} OP TERM, + * i.e. with only + * a left or right term and operator (but not both). When preprocessing programs, apply this transformation AFTER * {@link at.ac.tuwien.kr.alpha.grounder.transformation.aggregates.AggregateLiteralSplitting}. - * + * * Copyright (c) 2020-2021, the Alpha Team. */ public final class AggregateOperatorNormalization { @@ -68,35 +65,34 @@ private static List rewriteLiteral(Literal lit) { private static List rewriteAggregateOperator(AggregateLiteral lit) { AggregateAtom atom = lit.getAtom(); + if (atom.getLowerBoundOperator() == null && atom.getUpperBoundOperator() != null) { + return rewriteAggregateOperator(convertToLeftHandComparison(lit)); + } if (lit.getAtom().getAggregatefunction() == AggregateFunctionSymbol.MIN || lit.getAtom().getAggregatefunction() == AggregateFunctionSymbol.MAX) { // No operator normalization needed for #min/#max aggregates. return Collections.singletonList(lit); } - if (atom.getLowerBoundOperator() == EQ || atom.getLowerBoundOperator() == LE) { + if (atom.getLowerBoundOperator().equals(ComparisonOperator.EQ) || atom.getLowerBoundOperator().equals(ComparisonOperator.LE)) { // Nothing to do for operator "=" or "<=". return Collections.singletonList(lit); } else { List retVal = new ArrayList<>(); VariableTerm decrementedBound; - switch (atom.getLowerBoundOperator()) { - case LT: - decrementedBound = VariableTerm.getAnonymousInstance(); - retVal.add(createLowerBoundedAggregateLiteral(LE, decrementedBound, atom, !lit.isNegated())); - retVal.add(createPlusOneTerm(atom.getLowerBoundTerm(), decrementedBound)); - break; - case NE: - retVal.add(createLowerBoundedAggregateLiteral(EQ, atom.getLowerBoundTerm(), atom, lit.isNegated())); - break; - case GT: - retVal.add(createLowerBoundedAggregateLiteral(LE, atom.getLowerBoundTerm(), atom, lit.isNegated())); - break; - case GE: - decrementedBound = VariableTerm.getAnonymousInstance(); - retVal.add(createLowerBoundedAggregateLiteral(LE, decrementedBound, atom, lit.isNegated())); - retVal.add(createPlusOneTerm(atom.getLowerBoundTerm(), decrementedBound)); - break; - default: - throw new IllegalStateException("No operator rewriting logic available for literal: " + lit); + ComparisonOperator lowerBoundOp = atom.getLowerBoundOperator(); + if (lowerBoundOp.equals(ComparisonOperator.LT)) { + decrementedBound = VariableTerm.getAnonymousInstance(); + retVal.add(createLowerBoundedAggregateLiteral(ComparisonOperator.LE, decrementedBound, atom, !lit.isNegated())); + retVal.add(createPlusOneTerm(atom.getLowerBoundTerm(), decrementedBound)); + } else if (lowerBoundOp.equals(ComparisonOperator.NE)) { + retVal.add(createLowerBoundedAggregateLiteral(ComparisonOperator.EQ, atom.getLowerBoundTerm(), atom, lit.isNegated())); + } else if (lowerBoundOp.equals(ComparisonOperator.GT)) { + retVal.add(createLowerBoundedAggregateLiteral(ComparisonOperator.LE, atom.getLowerBoundTerm(), atom, lit.isNegated())); + } else if (lowerBoundOp.equals(ComparisonOperator.GE)) { + decrementedBound = VariableTerm.getAnonymousInstance(); + retVal.add(createLowerBoundedAggregateLiteral(ComparisonOperator.LE, decrementedBound, atom, lit.isNegated())); + retVal.add(createPlusOneTerm(atom.getLowerBoundTerm(), decrementedBound)); + } else { + throw new IllegalStateException("No operator rewriting logic available for literal: " + lit); } return retVal; } @@ -106,10 +102,10 @@ private static AggregateLiteral createLowerBoundedAggregateLiteral(ComparisonOpe return new AggregateLiteral(new AggregateAtom(op, lowerBoundTerm, aggregateAtom.getAggregatefunction(), aggregateAtom.getAggregateElements()), isNegated); } - + /** * Creates a new {@link Literal} that assigns the given target variable to the given (integer) term plus one. - * + * * @param term * @param targetVariable * @return @@ -120,4 +116,32 @@ private static Literal createPlusOneTerm(Term term, VariableTerm targetVariable) return atom.toLiteral(); } + /** + * Helper function to convert aggregate literals of form #aggr{...} OP TERM to literals of form + * TERM OP #aggr{...}. + * + * @param lit an aggregate literal with only a right-hand term comparison + * @return a semantically equivalent literal with only a left-hand comparison + */ + private static AggregateLiteral convertToLeftHandComparison(AggregateLiteral lit) { + AggregateAtom atom = lit.getAtom(); + ComparisonOperator operator = atom.getUpperBoundOperator(); + ComparisonOperator flippedOperator; + if (operator.equals(ComparisonOperator.EQ) || operator.equals(ComparisonOperator.NE)) { + flippedOperator = operator; + } else if (operator.equals(ComparisonOperator.LE)) { + flippedOperator = ComparisonOperator.GE; + } else if (operator.equals(ComparisonOperator.LT)) { + flippedOperator = ComparisonOperator.GT; + } else if (operator.equals(ComparisonOperator.GE)) { + flippedOperator = ComparisonOperator.LE; + } else if (operator.equals(ComparisonOperator.GT)) { + flippedOperator = ComparisonOperator.LT; + } else { + throw new IllegalArgumentException("Unsupported comparison operator for aggregate atom: " + operator); + } + return new AggregateAtom(flippedOperator, atom.getUpperBoundTerm(), atom.getAggregatefunction(), atom.getAggregateElements()) + .toLiteral(!lit.isNegated()); + } + } diff --git a/src/main/java/at/ac/tuwien/kr/alpha/solver/Choice.java b/src/main/java/at/ac/tuwien/kr/alpha/solver/Choice.java index bdaa9e188..21f4b2850 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/solver/Choice.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/solver/Choice.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2017-2018, the Alpha Team. + * Copyright (c) 2017-2019, the Alpha Team. * All rights reserved. * * Additional changes made by Siemens. @@ -68,6 +68,13 @@ public boolean getTruthValue() { public boolean isBacktracked() { return backtracked; } + + /** + * @return {@link #getAtom()} if {@link #getTruthValue()} is {@code true}, else {@link #getAtom()} {@code * -1}. + */ + public int toSignedInteger() { + return (truthValue ? 1 : -1) * atom; + } @Override public String toString() { diff --git a/src/main/java/at/ac/tuwien/kr/alpha/solver/ChoiceManager.java b/src/main/java/at/ac/tuwien/kr/alpha/solver/ChoiceManager.java index ab9d1e7d0..e5f06aeb5 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/solver/ChoiceManager.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/solver/ChoiceManager.java @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2017-2019, the Alpha Team. +/* + * Copyright (c) 2017-2021, the Alpha Team. * All rights reserved. * * Additional changes made by Siemens. @@ -27,63 +27,78 @@ */ package at.ac.tuwien.kr.alpha.solver; -import at.ac.tuwien.kr.alpha.common.NoGood; -import org.apache.commons.lang3.tuple.Pair; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; +import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.Set; import java.util.Stack; import java.util.stream.Collectors; +import org.apache.commons.lang3.tuple.Pair; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.ac.tuwien.kr.alpha.common.NoGood; +import at.ac.tuwien.kr.alpha.common.heuristics.HeuristicDirectiveValues; +import at.ac.tuwien.kr.alpha.solver.heuristics.domspec.DefaultDomainSpecificHeuristicsStore; +import at.ac.tuwien.kr.alpha.solver.heuristics.domspec.DomainSpecificHeuristicsStore; +import at.ac.tuwien.kr.alpha.solver.heuristics.domspec.EmptyDomainSpecificHeuristicsStore; + import static at.ac.tuwien.kr.alpha.Util.oops; import static at.ac.tuwien.kr.alpha.common.Literals.atomToLiteral; /** * This class provides functionality for choice point management, detection of active choice points, etc. - * Copyright (c) 2017-2019, the Alpha Team. + * Copyright (c) 2017-2020, the Alpha Team. */ public class ChoiceManager implements Checkable { - public static final int DEFAULT_CHOICE_ATOM = 0; + private static final int DEFAULT_CHOICE_ATOM = 0; private static final Logger LOGGER = LoggerFactory.getLogger(ChoiceManager.class); private final WritableAssignment assignment; private final Stack choiceStack; + private final DomainSpecificHeuristicsStore domainSpecificHeuristics; private final Map> headsToBodies = new HashMap<>(); private final Map bodiesToHeads = new HashMap<>(); - // An "influence manager" managing active choice points and heuristics. - private final ChoiceInfluenceManager choicePointInfluenceManager; + // Two "influence managers" managing active choice points and heuristics. + private final ChoicePointInfluenceManager choicePointInfluenceManager; + private final HeuristicInfluenceManager heuristicInfluenceManager; private final NoGoodStore store; private final BinaryNoGoodPropagationEstimation bnpEstimation; + private final ChoiceManagerStatistics choiceManagerStatistics = new ChoiceManagerStatistics(); private boolean checksEnabled; private DebugWatcher debugWatcher; - private int choices; - private int backtracks; - private int backtracksWithinBackjumps; - private int backjumps; - public ChoiceManager(WritableAssignment assignment, NoGoodStore store) { + this(assignment, store, null); + } + + protected ChoiceManager(WritableAssignment assignment, NoGoodStore store, DomainSpecificHeuristicsStore domainSpecificHeuristicsStore) { this.store = store; this.assignment = assignment; - this.choicePointInfluenceManager = new ChoiceInfluenceManager(assignment); + this.choicePointInfluenceManager = new ChoicePointInfluenceManager(assignment); + this.heuristicInfluenceManager = new HeuristicInfluenceManager(assignment); this.choiceStack = new Stack<>(); + if (domainSpecificHeuristicsStore != null) { + this.domainSpecificHeuristics = domainSpecificHeuristicsStore; + } else { + this.domainSpecificHeuristics = new DefaultDomainSpecificHeuristicsStore(); + } + this.domainSpecificHeuristics.setChoiceManager(this); assignment.setCallback(this); this.bnpEstimation = store instanceof BinaryNoGoodPropagationEstimation ? (BinaryNoGoodPropagationEstimation)store : null; } - + public WritableAssignment getAssignment() { return assignment; } @@ -101,7 +116,8 @@ NoGood computeEnumeration() { public void setChecksEnabled(boolean checksEnabled) { this.checksEnabled = checksEnabled; this.choicePointInfluenceManager.setChecksEnabled(checksEnabled); - + this.heuristicInfluenceManager.setChecksEnabled(checksEnabled); + if (checksEnabled) { debugWatcher = new DebugWatcher(); } else { @@ -113,54 +129,32 @@ public boolean isChecksEnabled() { return checksEnabled; } - public void callbackOnChanged(int atom) { + void callbackOnChanged(int atom) { choicePointInfluenceManager.callbackOnChanged(atom); + heuristicInfluenceManager.callbackOnChanged(atom); } - public int getBackjumps() { - return backjumps; - } - - /** - * Returns the total number of backtracks. - * - * The number of backtracks excluding those within backjumps is {@link #getBacktracks()} minus {@link #getBacktracksWithinBackjumps()}. - * - * @return the total number of backtracks - */ - public int getBacktracks() { - return backtracks; + public ChoiceManagerStatistics getStatistics() { + return choiceManagerStatistics; } - /** - * Returns the number of backtracks made within backjumps. - * - * @return the number of backtracks made within backjumps. - */ - public int getBacktracksWithinBackjumps() { - return backtracksWithinBackjumps; - } - - public int getChoices() { - return choices; - } - - public void updateAssignments() { + void updateAssignments() { LOGGER.trace("Updating assignments of ChoiceManager."); if (checksEnabled) { choicePointInfluenceManager.checkActiveChoicePoints(); + heuristicInfluenceManager.checkActiveChoicePoints(); } } public void choose(Choice choice) { if (!choice.isBacktracked()) { - choices++; + choiceManagerStatistics.incrementChoices(); } if (assignment.choose(choice.getAtom(), choice.getTruthValue()) != null) { throw oops("Picked choice is incompatible with current assignment"); } - LOGGER.debug("Choice {} is {}@{}", choices, choice, assignment.getDecisionLevel()); + LOGGER.debug("Choice {} is {}@{}", choiceManagerStatistics.getChoices(), choice, assignment.getDecisionLevel()); if (debugWatcher != null) { debugWatcher.runWatcher(); @@ -169,12 +163,12 @@ public void choose(Choice choice) { choiceStack.push(choice); } - public void backjump(int target) { + void backjump(int target) { if (target < 0) { throw oops("Backjumping to decision level less than 0"); } - backjumps++; + choiceManagerStatistics.incrementBackjumps(); LOGGER.debug("Backjumping to decision level {}.", target); // Remove everything above the target level, but keep the target level unchanged. @@ -182,8 +176,8 @@ public void backjump(int target) { assignment.backjump(target); while (currentDecisionLevel-- > target) { final Choice choice = choiceStack.pop(); - backtracksWithinBackjumps++; - backtracks++; + choiceManagerStatistics.incrementBacktracksWithinBackjumps(); + choiceManagerStatistics.incrementBacktracks(); LOGGER.debug("Backjumping removed choice {}", choice); } } @@ -195,7 +189,7 @@ public void backjump(int target) { */ public Choice backtrack() { store.backtrack(); - backtracks++; + choiceManagerStatistics.incrementBacktracks(); Choice choice = choiceStack.pop(); if (store.propagate() != null) { throw oops("Violated NoGood after backtracking."); @@ -209,8 +203,21 @@ void addChoiceInformation(Pair, Map> cho addHeadsToBodies(headsToBodies); } + void addHeuristicInformation(Pair, Map> heuristicAtoms, Map heuristicValues) { + addInformation(heuristicValues); + heuristicInfluenceManager.addInformation(heuristicAtoms, heuristicValues); + } + + private void addInformation(Map heuristicValues) { + for (Entry entry : heuristicValues.entrySet()) { + domainSpecificHeuristics.addInfo(entry.getKey(), entry.getValue()); + } + } + public void growForMaxAtomId(int maxAtomId) { choicePointInfluenceManager.growForMaxAtomId(maxAtomId); + heuristicInfluenceManager.growForMaxAtomId(maxAtomId); + domainSpecificHeuristics.growForMaxAtomId(maxAtomId); } private void addHeadsToBodies(Map> headsToBodies) { @@ -223,11 +230,7 @@ private void addHeadsToBodies(Map> headsToBodies) { } private void addHeadsToBodies(Integer head, Set bodies) { - Set existingBodies = this.headsToBodies.get(head); - if (existingBodies == null) { - existingBodies = new HashSet<>(); - this.headsToBodies.put(head, existingBodies); - } + Set existingBodies = this.headsToBodies.computeIfAbsent(head, k -> new HashSet<>()); existingBodies.addAll(bodies); } @@ -237,6 +240,10 @@ private void addBodiesToHeads(Integer head, Set bodies) { } } + public DomainSpecificHeuristicsStore getDomainSpecificHeuristics() { + return domainSpecificHeuristics; + } + public boolean isActiveChoiceAtom(int atom) { return choicePointInfluenceManager.isActive(atom); } @@ -245,22 +252,69 @@ public int getNextActiveChoiceAtom() { return choicePointInfluenceManager.getNextActiveAtomOrDefault(DEFAULT_CHOICE_ATOM); } + /** + * @return the number of active choice points + */ + public int getNumberOfActiveChoicePoints() { + return choicePointInfluenceManager.getNumberOfActiveChoicePoints(); + } + public boolean isAtomChoice(int atom) { return choicePointInfluenceManager.isAtomInfluenced(atom); } - - public void setChoicePointActivityListener(ChoiceInfluenceManager.ActivityListener activityListener) { + + public void setChoicePointActivityListener(InfluenceManager.ActivityListener activityListener) { choicePointInfluenceManager.setActivityListener(activityListener); } - + + public void setHeuristicActivityListener(InfluenceManager.ActivityListener activityListener) { + heuristicInfluenceManager.setActivityListener(activityListener); + } + public Integer getHeadDerivedByChoiceAtom(int choiceAtomId) { return bodiesToHeads.get(choiceAtomId); } + /** + * Gets the active choice atoms representing bodies of rules that can derive the given head atom. + * @param headAtomId internal ID of head atom + * @return a subset of all active choice atoms that can derive {@code headAtomId}. + */ + public Set getActiveChoiceAtomsDerivingHead(int headAtomId) { + Set bodies = headsToBodies.get(headAtomId); + if (bodies == null) { + return Collections.emptySet(); + } + Set activeBodies = new HashSet<>(); + for (Integer body : bodies) { + if (isActiveChoiceAtom(body)) { + activeBodies.add(body); + } + } + return activeBodies; + } + + /** + * Returns an unmodifiable view on the current choice stack which does not contain choices that have been removed during backtracking. + * + * @return an unmodifiable view on the current choice stack + */ + List getChoiceStack() { + return Collections.unmodifiableList(choiceStack); + } + public BinaryNoGoodPropagationEstimation getBinaryNoGoodPropagationEstimation() { return bnpEstimation; } + static ChoiceManager withoutDomainSpecificHeuristics(WritableAssignment assignment, NoGoodStore store) { + return new ChoiceManager(assignment, store, new EmptyDomainSpecificHeuristicsStore()); + } + + static ChoiceManager withDomainSpecificHeuristics(WritableAssignment assignment, NoGoodStore store) { + return new ChoiceManager(assignment, store); + } + /** * A helper class for halting the debugger when certain assignments occur on the choice stack. * diff --git a/src/main/java/at/ac/tuwien/kr/alpha/solver/ChoiceManagerStatistics.java b/src/main/java/at/ac/tuwien/kr/alpha/solver/ChoiceManagerStatistics.java new file mode 100644 index 000000000..4f49b646c --- /dev/null +++ b/src/main/java/at/ac/tuwien/kr/alpha/solver/ChoiceManagerStatistics.java @@ -0,0 +1,82 @@ +/** + * Copyright (c) 2017-2019, the Alpha Team. + * All rights reserved. + * + * Additional changes made by Siemens. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.solver; + +public class ChoiceManagerStatistics { + private int choices; + private int backjumps; + private int backtracks; + private int backtracksWithinBackjumps; + + ChoiceManagerStatistics() { + } + + public int getChoices() { + return choices; + } + + int getBackjumps() { + return backjumps; + } + + /** + * Returns the total number of backtracks. + *

    + * The number of backtracks excluding those within backjumps is {@link #getBacktracks()} minus {@link #getBacktracksWithinBackjumps()}. + * + * @return the total number of backtracks + */ + int getBacktracks() { + return backtracks; + } + + /** + * Returns the number of backtracks made within backjumps. + * + * @return the number of backtracks made within backjumps. + */ + int getBacktracksWithinBackjumps() { + return backtracksWithinBackjumps; + } + + void incrementChoices() { + choices++; + } + + void incrementBackjumps() { + backjumps++; + } + + void incrementBacktracks() { + backtracks++; + } + + void incrementBacktracksWithinBackjumps() { + backtracksWithinBackjumps++; + } +} \ No newline at end of file diff --git a/src/main/java/at/ac/tuwien/kr/alpha/solver/ChoiceInfluenceManager.java b/src/main/java/at/ac/tuwien/kr/alpha/solver/ChoicePointInfluenceManager.java similarity index 90% rename from src/main/java/at/ac/tuwien/kr/alpha/solver/ChoiceInfluenceManager.java rename to src/main/java/at/ac/tuwien/kr/alpha/solver/ChoicePointInfluenceManager.java index 62624eecd..0289dc94e 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/solver/ChoiceInfluenceManager.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/solver/ChoicePointInfluenceManager.java @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2017-2019, the Alpha Team. +/* + * Copyright (c) 2017-2021, the Alpha Team. * All rights reserved. * * Additional changes made by Siemens. @@ -27,42 +27,37 @@ */ package at.ac.tuwien.kr.alpha.solver; +import java.util.Arrays; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.Map; +import java.util.Set; + import org.apache.commons.lang3.tuple.Pair; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.*; - import static at.ac.tuwien.kr.alpha.Util.arrayGrowthSize; import static at.ac.tuwien.kr.alpha.Util.oops; import static at.ac.tuwien.kr.alpha.solver.ThriceTruth.MBT; import static at.ac.tuwien.kr.alpha.solver.ThriceTruth.TRUE; /** - * Manages influence of atoms on the activity of certain other atoms. Can be used for either choice points or heuristic atoms. + * Manages influence of atoms on the activity of rule atoms (choice points). * * Copyright (c) 2020, the Alpha Team. */ -public class ChoiceInfluenceManager implements Checkable { +public class ChoicePointInfluenceManager extends InfluenceManager { - private static final Logger LOGGER = LoggerFactory.getLogger(ChoiceInfluenceManager.class); + private static final Logger LOGGER = LoggerFactory.getLogger(ChoicePointInfluenceManager.class); // Active choice points and all atoms that influence a choice point (enabler, disabler, choice atom itself). private final Set activeChoicePoints = new LinkedHashSet<>(); - private final Set activeChoicePointsAtoms = new LinkedHashSet<>(); private ChoicePoint[] influencers = new ChoicePoint[0]; - private ActivityListener activityListener; - - private final WritableAssignment assignment; - - private boolean checksEnabled; + private final Set activeChoicePointsAtoms = new LinkedHashSet<>(); - /** - * @param assignment - * - */ - public ChoiceInfluenceManager(WritableAssignment assignment) { - this.assignment = assignment; + public ChoicePointInfluenceManager(WritableAssignment assignment) { + super(assignment); } void addInformation(Pair, Map> choiceAtoms) { @@ -133,23 +128,11 @@ boolean isActive(int atom) { return choicePoint != null && choicePoint.isActive && choicePoint.atom == atom; } - int getNextActiveAtomOrDefault(int defaultAtom) { - if (checksEnabled) { - checkActiveChoicePoints(); - } - return activeChoicePointsAtoms.size() > 0 ? activeChoicePointsAtoms.iterator().next() : defaultAtom; - } - boolean isAtomInfluenced(int atom) { ChoicePoint choicePoint = influencers[atom]; return choicePoint != null && choicePoint.atom == atom; } - @Override - public void setChecksEnabled(boolean checksEnabled) { - this.checksEnabled = checksEnabled; - } - void callbackOnChanged(int atom) { if (LOGGER.isTraceEnabled()) { LOGGER.trace("Callback received on influencer atom: {}", atom); @@ -160,6 +143,20 @@ void callbackOnChanged(int atom) { } } + /** + * @return the number of active choice points + */ + public int getNumberOfActiveChoicePoints() { + return activeChoicePointsAtoms.size(); + } + + int getNextActiveAtomOrDefault(int defaultAtom) { + if (checksEnabled) { + checkActiveChoicePoints(); + } + return activeChoicePointsAtoms.size() > 0 ? activeChoicePointsAtoms.iterator().next() : defaultAtom; + } + public void growForMaxAtomId(int maxAtomId) { // Grow arrays only if needed. if (influencers.length > maxAtomId) { @@ -172,7 +169,7 @@ public void growForMaxAtomId(int maxAtomId) { } influencers = Arrays.copyOf(influencers, newCapacity); } - + void setActivityListener(ActivityListener listener) { this.activityListener = listener; } @@ -227,9 +224,5 @@ public String toString() { return String.valueOf(atom); } } - - public static interface ActivityListener { - void callbackOnChanged(int atom, boolean active); - } } diff --git a/src/main/java/at/ac/tuwien/kr/alpha/solver/DefaultSolver.java b/src/main/java/at/ac/tuwien/kr/alpha/solver/DefaultSolver.java index ea3e6c1da..81988e742 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/solver/DefaultSolver.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/solver/DefaultSolver.java @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2016-2019, the Alpha Team. +/* + * Copyright (c) 2016-2021, the Alpha Team. * All rights reserved. * * Additional changes made by Siemens. @@ -27,9 +27,27 @@ */ package at.ac.tuwien.kr.alpha.solver; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Random; +import java.util.Set; +import java.util.function.Consumer; +import java.util.stream.Collectors; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import at.ac.tuwien.kr.alpha.common.AnswerSet; import at.ac.tuwien.kr.alpha.common.AtomStore; import at.ac.tuwien.kr.alpha.common.NoGood; +import at.ac.tuwien.kr.alpha.common.NoGoodCreator; import at.ac.tuwien.kr.alpha.common.atoms.Atom; import at.ac.tuwien.kr.alpha.common.atoms.BasicAtom; import at.ac.tuwien.kr.alpha.common.atoms.ComparisonAtom; @@ -47,24 +65,12 @@ import at.ac.tuwien.kr.alpha.solver.heuristics.HeuristicsConfiguration; import at.ac.tuwien.kr.alpha.solver.heuristics.NaiveHeuristic; import at.ac.tuwien.kr.alpha.solver.learning.GroundConflictNoGoodLearner; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.LinkedHashSet; -import java.util.LinkedList; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Random; -import java.util.Set; -import java.util.function.Consumer; import static at.ac.tuwien.kr.alpha.Util.oops; import static at.ac.tuwien.kr.alpha.common.Literals.atomOf; import static at.ac.tuwien.kr.alpha.common.Literals.atomToLiteral; import static at.ac.tuwien.kr.alpha.common.Literals.atomToNegatedLiteral; +import static at.ac.tuwien.kr.alpha.common.Literals.signedAtomToLiteral; import static at.ac.tuwien.kr.alpha.solver.NoGoodStore.LBD_NO_VALUE; import static at.ac.tuwien.kr.alpha.solver.ThriceTruth.FALSE; import static at.ac.tuwien.kr.alpha.solver.ThriceTruth.TRUE; @@ -84,7 +90,7 @@ public class DefaultSolver extends AbstractSolver implements SolverMaintainingSt private final ChoiceManager choiceManager; private final WritableAssignment assignment; private final GroundConflictNoGoodLearner learner; - private final BranchingHeuristic branchingHeuristic; + final BranchingHeuristic branchingHeuristic; private int mbtAtFixpoint; private int conflictsAfterClosing; @@ -102,27 +108,37 @@ private static class SearchState { private final SearchState searchState = new SearchState(); private final PerformanceLog performanceLog; - + public DefaultSolver(AtomStore atomStore, Grounder grounder, NoGoodStore store, WritableAssignment assignment, Random random, SystemConfig config, HeuristicsConfiguration heuristicsConfiguration) { super(atomStore, grounder); this.assignment = assignment; this.store = store; - this.choiceManager = new ChoiceManager(assignment, store); + + if (heuristicsConfiguration.isRespectDomspecHeuristics()) { + this.choiceManager = ChoiceManager.withDomainSpecificHeuristics(assignment, store); + } else { + this.choiceManager = ChoiceManager.withoutDomainSpecificHeuristics(assignment, store); + } this.choiceManager.setChecksEnabled(config.isDebugInternalChecks()); + this.learner = new GroundConflictNoGoodLearner(assignment, atomStore); - this.branchingHeuristic = chainFallbackHeuristic(grounder, assignment, random, heuristicsConfiguration); + this.branchingHeuristic = chainFallbackHeuristic(heuristicsConfiguration, assignment, random); this.disableJustifications = config.isDisableJustificationSearch(); this.disableNoGoodDeletion = config.isDisableNoGoodDeletion(); this.performanceLog = new PerformanceLog(choiceManager, (TrailAssignment) assignment, 1000); } - private BranchingHeuristic chainFallbackHeuristic(Grounder grounder, WritableAssignment assignment, Random random, HeuristicsConfiguration heuristicsConfiguration) { - BranchingHeuristic branchingHeuristic = BranchingHeuristicFactory.getInstance(heuristicsConfiguration, grounder, assignment, choiceManager, random); + private BranchingHeuristic chainFallbackHeuristic(HeuristicsConfiguration heuristicsConfiguration, WritableAssignment assignment, Random random) { + BranchingHeuristic branchingHeuristic = BranchingHeuristicFactory.getInstance(heuristicsConfiguration, assignment, choiceManager, random); if (branchingHeuristic instanceof NaiveHeuristic) { return branchingHeuristic; } - if (branchingHeuristic instanceof ChainedBranchingHeuristics && ((ChainedBranchingHeuristics)branchingHeuristic).getLastElement() instanceof NaiveHeuristic) { + if (branchingHeuristic instanceof ChainedBranchingHeuristics) { + ChainedBranchingHeuristics chainedBranchingHeuristics = (ChainedBranchingHeuristics) branchingHeuristic; + if (!(chainedBranchingHeuristics.getLastElement() instanceof NaiveHeuristic)) { + chainedBranchingHeuristics.add(new NaiveHeuristic(choiceManager)); + } return branchingHeuristic; } return ChainedBranchingHeuristics.chainOf(branchingHeuristic, new NaiveHeuristic(choiceManager)); @@ -141,6 +157,7 @@ protected boolean tryAdvance(Consumer action) { if (searchState.isSearchSpaceCompletelyExplored) { LOGGER.debug("Search space has been fully explored, there are no more answer-sets."); logStats(); + logChoiceStack(); return false; } ConflictCause conflictCause = propagate(); @@ -210,6 +227,10 @@ private void learnFromConflict(ConflictCause conflictCause) { Antecedent conflictAntecedent = conflictCause.getAntecedent(); NoGood violatedNoGood = new NoGood(conflictAntecedent.getReasonLiterals().clone()); // TODO: The violatedNoGood should not be necessary here, but this requires major type changes in heuristics. + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Violated nogood is: {}", atomStore.noGoodToString(violatedNoGood)); + LOGGER.debug("Violating assignment is: {}", assignment); + } branchingHeuristic.violatedNoGood(violatedNoGood); if (searchState.afterAllAtomsAssigned) { LOGGER.debug("Assignment is violated after all unassigned atoms have been assigned false."); @@ -340,7 +361,7 @@ private NoGood noGoodFromJustificationReasons(int atomToJustify, Set re for (Literal literal : reasonsForUnjustified) { reasons[arrpos++] = atomToLiteral(atomStore.get(literal.getAtom()), !literal.isNegated()); } - return NoGood.learnt(reasons); + return NoGoodCreator.learnt(reasons); } private boolean treatConflictAfterClosing(Antecedent violatedNoGood) { @@ -436,8 +457,8 @@ private boolean backtrack() { // Backtrack highest decision level. final int previousDecisionLevel = assignment.getDecisionLevel(); final Choice backtrackedChoice = choiceManager.backtrack(); - if (LOGGER.isTraceEnabled()) { - LOGGER.trace("Backtracked choice atom is {}={}@{}.", backtrackedChoice.getAtom(), + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Backtracked {}={}@{}.", backtrackedChoice.getAtom(), backtrackedChoice.getTruthValue() ? TRUE : FALSE, previousDecisionLevel); } @@ -491,12 +512,15 @@ private boolean ingest(Map obtained) { * False otherwise, i.e., iff the program is UNSAT. */ private boolean fixContradiction(Map.Entry noGoodEntry, ConflictCause conflictCause) { - LOGGER.debug("Attempting to fix violation of {} caused by {}", noGoodEntry.getValue(), conflictCause); + if (LOGGER.isDebugEnabled()) { + LOGGER.debug("Attempting to fix violation of {} caused by {}", atomStore.noGoodToString(noGoodEntry.getValue()), conflictCause); + } GroundConflictNoGoodLearner.ConflictAnalysisResult conflictAnalysisResult = learner.analyzeConflictFromAddingNoGood(conflictCause.getAntecedent()); if (conflictAnalysisResult == UNSAT) { return false; } + LOGGER.debug("Learned NoGood: " + conflictAnalysisResult.learnedNoGood); branchingHeuristic.analyzedConflict(conflictAnalysisResult); if (conflictAnalysisResult.learnedNoGood != null) { throw oops("Unexpectedly learned NoGood after addition of new NoGood caused a conflict."); @@ -512,8 +536,13 @@ private boolean fixContradiction(Map.Entry noGoodEntry, Conflic private boolean choose() { choiceManager.addChoiceInformation(grounder.getChoiceAtoms(), grounder.getHeadsToBodies()); + choiceManager.addHeuristicInformation(grounder.getHeuristicAtoms(), grounder.getHeuristicValues()); choiceManager.updateAssignments(); + if (assignment.getNumberOfActiveChoicePoints() == 0) { + return false; + } + // Hint: for custom heuristics, evaluate them here and pick a value if the heuristics suggests one. int literal; if ((literal = branchingHeuristic.chooseLiteral()) == DEFAULT_CHOICE_LITERAL) { @@ -526,25 +555,36 @@ private boolean choose() { choiceManager.choose(new Choice(literal, false)); return true; } - + @Override public int getNumberOfChoices() { - return choiceManager.getChoices(); + return choiceManager.getStatistics().getChoices(); + } + + @Override + public Map getNumberOfChoicesPerBranchingHeuristic() { + Map mapHeuristicNameToNumberOfDecisions = new LinkedHashMap<>(); + for (Entry entry : ((ChainedBranchingHeuristics) branchingHeuristic).getNumberOfDecisions().entrySet()) { + if (mapHeuristicNameToNumberOfDecisions.put(entry.getKey().toString(), entry.getValue()) != null) { + throw new IllegalStateException("Multiple heuristics with the same name: " + entry.getKey().toString()); + } + } + return Collections.unmodifiableMap(mapHeuristicNameToNumberOfDecisions); } @Override public int getNumberOfBacktracks() { - return choiceManager.getBacktracks(); + return choiceManager.getStatistics().getBacktracks(); } @Override public int getNumberOfBacktracksWithinBackjumps() { - return choiceManager.getBacktracksWithinBackjumps(); + return choiceManager.getStatistics().getBacktracksWithinBackjumps(); } @Override public int getNumberOfBackjumps() { - return choiceManager.getBackjumps(); + return choiceManager.getStatistics().getBackjumps(); } @Override @@ -586,4 +626,27 @@ private void logStats() { LOGGER.debug("Number of atoms by type: {}", atomCounter.getStatsByType()); } } + + private void logChoiceStack() { + final int limitSize = 10000; + List choiceStack = choiceManager.getChoiceStack(); + if (choiceStack.size() > limitSize) { + LOGGER.debug("Logging choice stack (limited to first {} choices) ...", limitSize); + } else { + LOGGER.debug("Logging choice stack ..."); + } + List choicesSignedAtoms = choiceStack.stream().limit(limitSize) + .map(Choice::toSignedInteger).collect(Collectors.toList()); + LOGGER.debug("Choice stack (signed atoms): " + choicesSignedAtoms); + List choicesGroundAtoms = new ArrayList<>(choicesSignedAtoms.size()); + for (int signedAtom : choicesSignedAtoms) { + int literal = signedAtomToLiteral(signedAtom); + choicesGroundAtoms.add(atomStore.literalToString(literal)); + } + LOGGER.debug("Choice stack (ground atoms): " + choicesGroundAtoms); + } + + public void setChecksEnabled(boolean checksEnabled) { + choiceManager.setChecksEnabled(checksEnabled); + } } diff --git a/src/main/java/at/ac/tuwien/kr/alpha/solver/HeuristicInfluenceManager.java b/src/main/java/at/ac/tuwien/kr/alpha/solver/HeuristicInfluenceManager.java new file mode 100644 index 000000000..ce11b7a68 --- /dev/null +++ b/src/main/java/at/ac/tuwien/kr/alpha/solver/HeuristicInfluenceManager.java @@ -0,0 +1,291 @@ +/* + * Copyright (c) 2017-2021, the Alpha Team. + * All rights reserved. + * + * Additional changes made by Siemens. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.solver; + +import java.util.Arrays; +import java.util.Map; + +import org.apache.commons.collections4.MultiValuedMap; +import org.apache.commons.collections4.multimap.HashSetValuedHashMap; +import org.apache.commons.lang3.tuple.Pair; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.ac.tuwien.kr.alpha.common.heuristics.HeuristicDirectiveValues; + +import static at.ac.tuwien.kr.alpha.Util.arrayGrowthSize; +import static at.ac.tuwien.kr.alpha.Util.oops; +import static at.ac.tuwien.kr.alpha.common.heuristics.HeuristicSignSetUtil.IDX_F; +import static at.ac.tuwien.kr.alpha.common.heuristics.HeuristicSignSetUtil.IDX_M; +import static at.ac.tuwien.kr.alpha.common.heuristics.HeuristicSignSetUtil.IDX_T; +import static at.ac.tuwien.kr.alpha.common.heuristics.HeuristicSignSetUtil.IDX_TM; +import static at.ac.tuwien.kr.alpha.solver.ThriceTruth.MBT; +import static at.ac.tuwien.kr.alpha.solver.ThriceTruth.TRUE; + +/** + * Manages influence of atoms on the activity of heuristics. + * + */ +public class HeuristicInfluenceManager extends InfluenceManager { + + private static final Logger LOGGER = LoggerFactory.getLogger(HeuristicInfluenceManager.class); + + /** + * A special HeuristicChoicePoint indicating that several HeuristicChoicePoints exist in a mapping + */ + private final HeuristicChoicePoint multivalueIndicator = new HeuristicChoicePoint(0, 0, null, null); + + /** + * Array of heuristic choice points, indexed by atom IDs, which may be enablers, disablers, heuristic choice atom itself. + */ + private HeuristicChoicePoint[] heuristicChoicePoints = new HeuristicChoicePoint[0]; + + /** + * Maps head atoms of heuristics to heuristic choice points of heuristics with those atoms in the head (there might be several) + */ + private final MultiValuedMap headAtomsToHeuristics = new HashSetValuedHashMap<>(); + + public HeuristicInfluenceManager(WritableAssignment assignment) { + super(assignment); + } + + void addInformation(Pair, Map> heuristicAtoms, Map heuristicValues) { + // Assumption: we get all enabler/disabler pairs in one call. + Map enablers = heuristicAtoms.getLeft(); + Map disablers = heuristicAtoms.getRight(); + for (Map.Entry atomToEnablers : enablers.entrySet()) { + addInformation(atomToEnablers, disablers, heuristicValues); + } + } + + private void addInformation(Map.Entry atomToEnablers, Map atomsToDisablers, + Map heuristicValues) { + // Construct and record ChoicePoint. + Integer choicePointAtom = atomToEnablers.getKey(); + if (choicePointAtom == null) { + throw oops("Incomplete choice point description found (no atom)"); + } + if (heuristicChoicePoints[choicePointAtom] != null) { + throw oops("Received choice information repeatedly"); + } + Integer[] enablers = atomToEnablers.getValue(); + Integer[] disablers = atomsToDisablers.get(choicePointAtom); + if (enablers == null || disablers == null) { + throw oops("Incomplete choice point description found (no enabler or disabler)"); + } + final int headAtom = heuristicValues.get(choicePointAtom).getHeadAtomId(); + registerCallbackOnChange(headAtom); + registerCallbackOnChange(enablers); + registerCallbackOnChange(disablers); + registerCallbackOnChange(choicePointAtom); + HeuristicChoicePoint choicePoint = new HeuristicChoicePoint(choicePointAtom, headAtom, enablers, disablers); + addHeuristicChoicePoint(choicePoint); + addHeuristicChoicePointToHeadAtomId(choicePoint, headAtom); + addHeuristicChoicePointToInfluencers(choicePoint, enablers); + addHeuristicChoicePointToInfluencers(choicePoint, disablers); + choicePoint.recomputeActive(); + } + + private void registerCallbackOnChange(Integer... atoms) { + for (Integer atom : atoms) { + if (atom != null) { + assignment.registerCallbackOnChange(atom); + } + } + } + + private void addHeuristicChoicePoint(HeuristicChoicePoint heuristicChoicePoint) { + heuristicChoicePoints[heuristicChoicePoint.atom] = heuristicChoicePoint; + } + + private void addHeuristicChoicePointToHeadAtomId(HeuristicChoicePoint heuristicChoicePoint, int headAtomId) { + // mapping of head atom IDs is special, because there might be several heuristics for the same head atom! + if (heuristicChoicePoints[headAtomId] == null) { + heuristicChoicePoints[headAtomId] = heuristicChoicePoint; + return; + } + + if (heuristicChoicePoints[headAtomId] != multivalueIndicator) { + headAtomsToHeuristics.put(headAtomId, heuristicChoicePoints[headAtomId]); + } + headAtomsToHeuristics.put(headAtomId, heuristicChoicePoint); + heuristicChoicePoints[headAtomId] = multivalueIndicator; + } + + private void addHeuristicChoicePointToInfluencers(HeuristicChoicePoint heuristicChoicePoint, Integer... atoms) { + for (Integer atom : atoms) { + if (atom != null) { + if (heuristicChoicePoints[atom] != null) { + throw oops("Multiple heuristic choice points mapped to same atom " + atom); + } + heuristicChoicePoints[atom] = heuristicChoicePoint; + } + } + } + + void checkActiveChoicePoints() { + // TODO: re-implement +// HashSet actualActiveChoicePointAtoms = new HashSet<>(); +// for (HeuristicChoicePoint heuristicChoicePoint : heuristicChoicePoints.values()) { +// if (checkActiveChoicePoint(heuristicChoicePoint)) { +// actualActiveChoicePointAtoms.add(heuristicChoicePoint.atom); +// } +// } +// if (!actualActiveChoicePointAtoms.equals(activeChoicePointsAtoms)) { +// throw oops(this.getClass().getSimpleName() + " internal checker detected wrong activeChoicePoints"); +// } +// LOGGER.trace("Checking internal " + this.getClass().getSimpleName() + ": all ok."); + } + + private boolean checkActiveChoicePoint(HeuristicChoicePoint heuristicChoicePoint) { + // TODO: re-implement +// final Integer[] enablers = heuristicChoicePoint.enablers; +// final Integer[] disablers = heuristicChoicePoint.disablers; +// final ThriceTruth truthEnablerTM = getNullsafeTruth(enablers[IDX_TM]); +// boolean isActive = enablers[IDX_TM] == null || truthEnablerTM == TRUE || truthEnablerTM == MBT; +// isActive = isActive && enablers[IDX_T] == null || getNullsafeTruth(enablers[IDX_T]) == TRUE; +// isActive = isActive && enablers[IDX_M] == null || getNullsafeTruth(enablers[IDX_M]) == MBT; +// isActive = isActive && enablers[IDX_F] == null || getNullsafeTruth(enablers[IDX_F]) == TRUE; +// +// final ThriceTruth truthDisablerTM = getNullsafeTruth(disablers[IDX_TM]); +// isActive = isActive && truthDisablerTM != TRUE && truthDisablerTM != MBT; +// isActive = isActive && getNullsafeTruth(disablers[IDX_T]) != TRUE; +// isActive = isActive && getNullsafeTruth(disablers[IDX_M]) != MBT; +// isActive = isActive && getNullsafeTruth(disablers[IDX_F]) != TRUE; +// +// isActive = isActive && assignment.isUnassignedOrMBT(heuristicChoicePoint.headAtom); +// +// ThriceTruth atomTruth = assignment.getTruth(heuristicChoicePoint.atom); +// boolean isNotChosen = atomTruth == null || atomTruth == MBT; +// return isActive && isNotChosen; + return true; + } + + boolean isActive(int atom) { + if (checksEnabled) { + checkActiveChoicePoints(); + } + HeuristicChoicePoint choicePoint = heuristicChoicePoints[atom]; + return choicePoint != null && choicePoint.isActive && choicePoint.atom == atom; + } + + void callbackOnChanged(int atom) { + LOGGER.trace("Callback received on influencer atom: {}", atom); + final HeuristicChoicePoint heuristicChoicePoint = heuristicChoicePoints[atom]; + if (heuristicChoicePoint == multivalueIndicator) { + for (HeuristicChoicePoint heuristicForHead : headAtomsToHeuristics.get(atom)) { + heuristicForHead.recomputeActive(); + } + } else if (heuristicChoicePoint != null) { + heuristicChoicePoint.recomputeActive(); + } + } + + public void growForMaxAtomId(int maxAtomId) { + // Grow arrays only if needed. + if (heuristicChoicePoints.length > maxAtomId) { + return; + } + // Grow to default size, except if bigger array is required due to maxAtomId. + int newCapacity = arrayGrowthSize(heuristicChoicePoints.length); + if (newCapacity < maxAtomId + 1) { + newCapacity = maxAtomId + 1; + } + heuristicChoicePoints = Arrays.copyOf(heuristicChoicePoints, newCapacity); + } + + private ThriceTruth getNullsafeTruth(Integer atom) { + return atom == null ? null : assignment.getTruth(atom); + } + + private class HeuristicChoicePoint { + final int atom; + final int headAtom; + final Integer[] enablers; + final Integer[] disablers; + boolean isActive; + + private HeuristicChoicePoint(int atom, int headAtom, Integer[] enablers, Integer[] disablers) { + this.atom = atom; + this.headAtom = headAtom; + this.enablers = enablers; + this.disablers = disablers; + } + + /** + * A heuristic choice point is active if all of the following conditions hold: + *

      + *
    • enabler[T] is assigned TRUE
    • + *
    • enabler[TM] is assigned TRUE or MBT
    • + *
    • enabler[M] is assigned MBT
    • + *
    • enabler[F] is assigned TRUE
    • + *
    • disabler[T] is not assigned TRUE
    • + *
    • disabler[TM] is assigned neither TRUE nor MBT
    • + *
    • disabler[M] is not assigned MBT
    • + *
    • disabler[F] is not assigned TRUE.
    • + *
    + * @return {@code true} iff all the above conditions hold and the heuristic's head atom is unassigned or assigned MBT. + */ + private boolean isActive() { + final ThriceTruth truthEnablerTM = getNullsafeTruth(enablers[IDX_TM]); + boolean isActive = enablers[IDX_TM] == null || truthEnablerTM == TRUE || truthEnablerTM == MBT; + isActive = isActive && (enablers[IDX_T] == null || getNullsafeTruth(enablers[IDX_T]) == TRUE); + isActive = isActive && (enablers[IDX_M] == null || getNullsafeTruth(enablers[IDX_M]) == MBT); + isActive = isActive && (enablers[IDX_F] == null || getNullsafeTruth(enablers[IDX_F]) == TRUE); + + final ThriceTruth truthDisablerTM = getNullsafeTruth(disablers[IDX_TM]); + isActive = isActive && truthDisablerTM != TRUE && truthDisablerTM != MBT; + isActive = isActive && getNullsafeTruth(disablers[IDX_T]) != TRUE; + isActive = isActive && getNullsafeTruth(disablers[IDX_M]) != MBT; + isActive = isActive && getNullsafeTruth(disablers[IDX_F]) != TRUE; + + isActive = isActive && assignment.isUnassignedOrMBT(headAtom); + return isActive; + } + + private boolean isNotChosen() { + ThriceTruth atomTruth = assignment.getTruth(atom); + return atomTruth == null || atomTruth == MBT; + } + + void recomputeActive() { + final boolean wasActive = isActive; + isActive = isNotChosen() && isActive(); + final boolean changed = isActive != wasActive; + if (changed && activityListener != null) { + activityListener.callbackOnChanged(atom, isActive); + } + } + + @Override + public String toString() { + return String.valueOf(atom); + } + } + +} diff --git a/src/main/java/at/ac/tuwien/kr/alpha/solver/InfluenceManager.java b/src/main/java/at/ac/tuwien/kr/alpha/solver/InfluenceManager.java new file mode 100644 index 000000000..5e0727f9b --- /dev/null +++ b/src/main/java/at/ac/tuwien/kr/alpha/solver/InfluenceManager.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2017-2021, the Alpha Team. + * All rights reserved. + * + * Additional changes made by Siemens. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.solver; + +/** + * Manages influence of atoms on the activity of certain other atoms. Can be used for either choice points or heuristic atoms. + * + * Regarding terminology: "influenced atom" refers to any atom that is influenced by influencers. + * Special types of "influenced atoms" are "choice points" (for rules) and "heuristic choice points" (for heuristics). + */ +public abstract class InfluenceManager implements Checkable { + + protected final WritableAssignment assignment; + + protected ActivityListener activityListener; + protected boolean checksEnabled; + + public InfluenceManager(WritableAssignment assignment) { + this.assignment = assignment; + } + + abstract boolean isActive(int atom); + + @Override + public void setChecksEnabled(boolean checksEnabled) { + this.checksEnabled = checksEnabled; + } + + abstract void checkActiveChoicePoints(); + + abstract void callbackOnChanged(int atom); + + void setActivityListener(ActivityListener listener) { + this.activityListener = listener; + } + + public interface ActivityListener { + void callbackOnChanged(int atom, boolean active); + } + +} diff --git a/src/main/java/at/ac/tuwien/kr/alpha/solver/NaiveNoGoodStore.java b/src/main/java/at/ac/tuwien/kr/alpha/solver/NaiveNoGoodStore.java index 28af2719c..baeeac4ae 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/solver/NaiveNoGoodStore.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/solver/NaiveNoGoodStore.java @@ -229,3 +229,4 @@ private ConflictCause propagateStrongly(NoGood noGood) { return assignment.assign(headAtom, TRUE, noGood.asAntecedent()); } } + diff --git a/src/main/java/at/ac/tuwien/kr/alpha/solver/NoGoodCounter.java b/src/main/java/at/ac/tuwien/kr/alpha/solver/NoGoodCounter.java index 432419ab1..1103671bf 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/solver/NoGoodCounter.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/solver/NoGoodCounter.java @@ -127,3 +127,4 @@ public String getStatsByCardinality() { } } + diff --git a/src/main/java/at/ac/tuwien/kr/alpha/solver/PerformanceLog.java b/src/main/java/at/ac/tuwien/kr/alpha/solver/PerformanceLog.java index a653b8021..4dc4de5b6 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/solver/PerformanceLog.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/solver/PerformanceLog.java @@ -61,7 +61,7 @@ public void initialize() { */ public void writeIfTimeForLogging(Logger logger) { long currentTime = System.currentTimeMillis(); - int currentNumberOfChoices = choiceManager.getChoices(); + int currentNumberOfChoices = choiceManager.getStatistics().getChoices(); if (currentTime >= timeLastPerformanceLog + msBetweenOutputs) { logger.info("Decisions in {}s: {}", (currentTime - timeLastPerformanceLog) / 1000.0f, currentNumberOfChoices - numberOfChoicesLastPerformanceLog); timeLastPerformanceLog = currentTime; diff --git a/src/main/java/at/ac/tuwien/kr/alpha/solver/SolverFactory.java b/src/main/java/at/ac/tuwien/kr/alpha/solver/SolverFactory.java index 414d30c31..ef9039e07 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/solver/SolverFactory.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/solver/SolverFactory.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016-2017, the Alpha Team. + * Copyright (c) 2016-2018, the Alpha Team. * All rights reserved. * * Additional changes made by Siemens. @@ -31,19 +31,18 @@ import at.ac.tuwien.kr.alpha.config.SystemConfig; import at.ac.tuwien.kr.alpha.grounder.Grounder; import at.ac.tuwien.kr.alpha.solver.heuristics.HeuristicsConfiguration; -import at.ac.tuwien.kr.alpha.solver.heuristics.HeuristicsConfigurationBuilder; import java.util.Random; public final class SolverFactory { - - public static Solver getInstance(SystemConfig config, AtomStore atomStore, Grounder grounder) { + + public static Solver getInstance(SystemConfig config, AtomStore atomStore, Grounder grounder, HeuristicsConfiguration heuristicsConfiguration) { final String solverName = config.getSolverName(); final String nogoodStoreName = config.getNogoodStoreName(); final Random random = new Random(config.getSeed()); final boolean debugInternalChecks = config.isDebugInternalChecks(); - final HeuristicsConfiguration heuristicsConfiguration = buildHeuristicsConfiguration(config); - final WritableAssignment assignment = new TrailAssignment(atomStore, debugInternalChecks); + final TrailAssignment assignment = new TrailAssignment(atomStore, debugInternalChecks); + assignment.setChecksEnabled(debugInternalChecks); NoGoodStore store; @@ -62,16 +61,10 @@ public static Solver getInstance(SystemConfig config, AtomStore atomStore, Groun case "naive" : return new NaiveSolver(atomStore, grounder); case "default": - return new DefaultSolver(atomStore, grounder, store, assignment, random, config, heuristicsConfiguration); + DefaultSolver solver = new DefaultSolver(atomStore, grounder, store, assignment, random, config, heuristicsConfiguration); + solver.setChecksEnabled(debugInternalChecks); + return solver; } throw new IllegalArgumentException("Unknown solver requested."); } - - private static HeuristicsConfiguration buildHeuristicsConfiguration(SystemConfig config) { - HeuristicsConfigurationBuilder heuristicsConfigurationBuilder = HeuristicsConfiguration.builder(); - heuristicsConfigurationBuilder.setHeuristic(config.getBranchingHeuristic()); - heuristicsConfigurationBuilder.setMomsStrategy(config.getMomsStrategy()); - heuristicsConfigurationBuilder.setReplayChoices(config.getReplayChoices()); - return heuristicsConfigurationBuilder.build(); - } } diff --git a/src/main/java/at/ac/tuwien/kr/alpha/solver/SolverMaintainingStatistics.java b/src/main/java/at/ac/tuwien/kr/alpha/solver/SolverMaintainingStatistics.java index 0c29abef7..1c336fa48 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/solver/SolverMaintainingStatistics.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/solver/SolverMaintainingStatistics.java @@ -26,11 +26,14 @@ package at.ac.tuwien.kr.alpha.solver; import java.io.PrintStream; +import java.util.Map; public interface SolverMaintainingStatistics { int getNumberOfChoices(); + Map getNumberOfChoicesPerBranchingHeuristic(); + int getNumberOfBacktracks(); int getNumberOfBacktracksWithinBackjumps(); diff --git a/src/main/java/at/ac/tuwien/kr/alpha/solver/ThriceTruth.java b/src/main/java/at/ac/tuwien/kr/alpha/solver/ThriceTruth.java index ade2ccb9c..8e4ce2231 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/solver/ThriceTruth.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/solver/ThriceTruth.java @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2016, the Alpha Team. +/* + * Copyright (c) 2016-2018, 2020, the Alpha Team. * All rights reserved. * * Additional changes made by Siemens. @@ -56,6 +56,15 @@ public static ThriceTruth valueOf(boolean value) { return value ? TRUE : FALSE; } + public static ThriceTruth fromChar(char signChar) { + for (ThriceTruth value : values()) { + if (value.asString.equals(String.valueOf(signChar))) { + return value; + } + } + throw new IllegalArgumentException("Unknown " + ThriceTruth.class.getSimpleName() + ": " + signChar); + } + /** * @return true if this is MBT. */ diff --git a/src/main/java/at/ac/tuwien/kr/alpha/solver/TrailAssignment.java b/src/main/java/at/ac/tuwien/kr/alpha/solver/TrailAssignment.java index 12cb759ae..f9cec9822 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/solver/TrailAssignment.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/solver/TrailAssignment.java @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2016-2019, the Alpha Team. +/* + * Copyright (c) 2016-2021, the Alpha Team. * All rights reserved. * * Additional changes made by Siemens. @@ -27,20 +27,31 @@ */ package at.ac.tuwien.kr.alpha.solver; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import at.ac.tuwien.kr.alpha.common.Assignment; import at.ac.tuwien.kr.alpha.common.AtomStore; import at.ac.tuwien.kr.alpha.common.IntIterator; +import at.ac.tuwien.kr.alpha.common.atoms.Atom; import at.ac.tuwien.kr.alpha.common.atoms.BasicAtom; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.*; +import at.ac.tuwien.kr.alpha.grounder.atoms.HeuristicInfluencerAtom; import static at.ac.tuwien.kr.alpha.Util.arrayGrowthSize; import static at.ac.tuwien.kr.alpha.Util.oops; -import static at.ac.tuwien.kr.alpha.common.Literals.*; +import static at.ac.tuwien.kr.alpha.common.Literals.atomOf; +import static at.ac.tuwien.kr.alpha.common.Literals.atomToLiteral; +import static at.ac.tuwien.kr.alpha.common.Literals.isPositive; import static at.ac.tuwien.kr.alpha.solver.Atoms.isAtom; -import static at.ac.tuwien.kr.alpha.solver.ThriceTruth.*; +import static at.ac.tuwien.kr.alpha.solver.ThriceTruth.FALSE; +import static at.ac.tuwien.kr.alpha.solver.ThriceTruth.MBT; +import static at.ac.tuwien.kr.alpha.solver.ThriceTruth.TRUE; /** * An implementation of Assignment using a trail (of literals) and arrays as underlying structures for storing @@ -69,7 +80,7 @@ public void decreaseActivity() { }; private final AtomStore atomStore; - private ChoiceManager choiceManagerCallback; + private ChoiceManager choiceManager; /** * Contains for each known atom a value whose two least @@ -135,7 +146,7 @@ public void registerCallbackOnChange(int atom) { @Override public void setCallback(ChoiceManager choiceManager) { - choiceManagerCallback = choiceManager; + this.choiceManager = choiceManager; } @Override @@ -145,9 +156,15 @@ public boolean isAssigned(int atom) { @Override public int getBasicAtomAssignedMBT() { - for (int atom = 1; atom <= atomStore.getMaxAtomId(); atom++) { - if (getTruth(atom) == MBT && atomStore.get(atom) instanceof BasicAtom) { - return atom; + for (int atomId = 1; atomId <= atomStore.getMaxAtomId(); atomId++) { + if (getTruth(atomId) == MBT) { + final Atom atom = atomStore.get(atomId); + if (atom instanceof BasicAtom && !(atom instanceof HeuristicInfluencerAtom)) { + // It does not make sense to search for a justification for a HeuristicInfluencerAtom. + // Whenever a HeuristicInfluencerAtom is assigned M, there must also be an ordinary BasicAtom assigned M. + // For these reasons, HeuristicInfluencerAtoms are excluded here. + return atomId; + } } } throw oops("No BasicAtom is assigned MBT."); @@ -199,7 +216,7 @@ int getOutOfOrderStrongDecisionLevel(int atom) { private void informCallback(int atom) { if (callbackUponChange[atom]) { - choiceManagerCallback.callbackOnChanged(atom); + choiceManager.callbackOnChanged(atom); } } @@ -358,7 +375,10 @@ private ConflictCause assignWithTrail(int atom, ThriceTruth value, Antecedent im if (value == TRUE) { strongDecisionLevels[atom] = getDecisionLevel(); } - informCallback(atom); + if (impliedBy != CLOSING_INDICATOR_ANTECEDENT) { + // we assume that callbacks need not be informed during closing + informCallback(atom); + } didChange = true; return null; } @@ -517,7 +537,9 @@ private List getMBTAssignedAtoms() { public boolean closeUnassignedAtoms() { boolean didAssign = false; for (int i = 1; i <= atomStore.getMaxAtomId(); i++) { - if (!isAssigned(i)) { + if (!isAssigned(i) && !(atomStore.get(i) instanceof HeuristicInfluencerAtom)) { + // HeuristicInfluencerAtom may stay unassigned because they are irrelevant in answer sets. + // here they are ignored to avoid conflicts (which can occur when a heuristic becomes applicable due to atoms being assigned false during closing) assign(i, FALSE, CLOSING_INDICATOR_ANTECEDENT); didAssign = true; } @@ -573,6 +595,14 @@ public int getNumberOfAtomsAssignedSinceLastDecision() { return newlyAssignedAtoms.size(); } + @Override + public int getNumberOfActiveChoicePoints() { + if (choiceManager == null) { + throw new UnsupportedOperationException("No ChoiceManager known by TrailAssignment"); + } + return choiceManager.getNumberOfActiveChoicePoints(); + } + @Override public int getDecisionLevel() { return trailIndicesOfDecisionLevels.size() - 1; diff --git a/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/AlphaHeadMustBeTrueHeuristic.java b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/AlphaHeadMustBeTrueHeuristic.java index 52df83cd4..2eeb625fc 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/AlphaHeadMustBeTrueHeuristic.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/AlphaHeadMustBeTrueHeuristic.java @@ -30,7 +30,6 @@ import at.ac.tuwien.kr.alpha.solver.ThriceTruth; import at.ac.tuwien.kr.alpha.solver.heuristics.activity.BodyActivityProviderFactory.BodyActivityType; -import java.util.Comparator; import java.util.Optional; import java.util.Random; import java.util.Set; @@ -54,15 +53,24 @@ public AlphaHeadMustBeTrueHeuristic(Assignment assignment, ChoiceManager choiceM @Override public int chooseLiteral() { - Set heads = headToBodies.keySet(); - Stream bodiesOfMbtHeads = heads.stream().filter(a -> assignment.getTruth(a) == ThriceTruth.MBT).flatMap(h -> headToBodies.get(h).stream()); - Optional mostActiveBody = bodiesOfMbtHeads.filter(this::isUnassigned).filter(choiceManager::isActiveChoiceAtom) - .max(Comparator.comparingDouble(bodyActivity::get)); + return chooseAtom(null); + } + + @Override + public int chooseAtom(Set admissibleChoices) { + Optional mostActiveBody = determineMostActiveBody(admissibleChoices); if (mostActiveBody.isPresent()) { rememberedAtom = mostActiveBody.get(); return rememberedAtom; } - return super.chooseLiteral(); + return super.chooseAtom(admissibleChoices); + } + + private Optional determineMostActiveBody(Set admissibleChoices) { + Set heads = headToBodies.keySet(); + Stream bodiesOfMbtHeads = heads.stream().filter(a -> assignment.getTruth(a) == ThriceTruth.MBT).flatMap(h -> headToBodies.get(h).stream()); + Optional mostActiveBody = getMostActiveBody(bodiesOfMbtHeads, admissibleChoices); + return mostActiveBody; } } diff --git a/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/BerkMin.java b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/BerkMin.java index 48e523932..5f0a1bcc8 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/BerkMin.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/BerkMin.java @@ -1,17 +1,17 @@ /** * Copyright (c) 2016-2019 Siemens AG * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1) Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. - * + * * 2) Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -51,7 +51,7 @@ */ public class BerkMin implements ActivityBasedBranchingHeuristic { private static final Logger LOGGER = LoggerFactory.getLogger(BerkMin.class); - + static final double DEFAULT_ACTIVITY = 0.0; static final int DEFAULT_SIGN_COUNTER = 0; @@ -64,6 +64,15 @@ public class BerkMin implements ActivityBasedBranchingHeuristic { private Map activityCounters = new LinkedHashMap<>(); private Map signCounters = new LinkedHashMap<>(); + + public Map getActivityCounters() { + return activityCounters; + } + + public Deque getStackOfNoGoods() { + return stackOfNoGoods; + } + private Deque stackOfNoGoods = new ArrayDeque<>(); private int decayPeriod; private double decayFactor; @@ -151,7 +160,8 @@ private int numChoicePoints(NoGood noGood) { @Override public double getActivity(int literal) { - return activityCounters.getOrDefault(atomOf(literal), DEFAULT_ACTIVITY); + int key = atomOf(literal); + return activityCounters.getOrDefault(key, DEFAULT_ACTIVITY); } /** @@ -162,16 +172,17 @@ public double getActivity(int literal) { * nogood in the stack, then the one after that and so on. */ @Override - public int chooseLiteral() { - int atom = chooseAtom(); + public int chooseLiteral(Set admissibleChoices) { + int atom = chooseAtom(admissibleChoices); boolean sign = chooseSign(atom); return atomToLiteral(atom, sign); } - - protected int chooseAtom() { + + @Override + public int chooseAtom(Set admissibleChoices) { for (NoGood noGood : stackOfNoGoods) { if (assignment.isUndefined(noGood)) { - int mostActiveAtom = getMostActiveChoosableAtom(noGood); + int mostActiveAtom = getMostActiveChoosableAtom(noGood, admissibleChoices); if (mostActiveAtom != DEFAULT_CHOICE_ATOM) { return mostActiveAtom; } @@ -179,7 +190,7 @@ protected int chooseAtom() { } return DEFAULT_CHOICE_ATOM; } - + private boolean chooseSign(int atom) { if (assignment.getTruth(atom) == ThriceTruth.MBT) { return true; @@ -217,7 +228,7 @@ private void incrementActivityCounter(int literal) { // 2. make check cheaper, e.g. by using dedicated atom IDs (e.g. even // integers for rule bodies, uneven for other atoms) } - + private void incrementSignCounter(Integer literal) { if (choiceManager.isAtomChoice(atomOf(literal))) { signCounters.compute(literal, (k, v) -> (v == null ? DEFAULT_SIGN_COUNTER : v) + 1); @@ -235,6 +246,7 @@ private void decayAllIfTimeHasCome() { /** * Gets the most recent conflict that is still violated. + * * @return the violated nogood closest to the top of the stack of nogoods. */ NoGood getCurrentTopClause() { @@ -245,30 +257,35 @@ NoGood getCurrentTopClause() { } return null; } - + /** * If {@code noGood != null}, returns the most active unassigned literal from {@code noGood}. Else, returns the most active atom of all the known atoms. + * * @param noGood * @return */ - private int getMostActiveChoosableAtom(NoGood noGood) { + protected int getMostActiveChoosableAtom(NoGood noGood, Set admissibleChoices) { + Stream streamOfChoosableAtoms; if (noGood != null) { - return getMostActiveChoosableAtom(noGood.stream().boxed().map(Literals::atomOf)); + streamOfChoosableAtoms = noGood.stream().boxed().map(Literals::atomOf); } else { - return getMostActiveChoosableAtom(activityCounters.keySet().stream()); + streamOfChoosableAtoms = activityCounters.keySet().stream(); + } + if (admissibleChoices != null) { + streamOfChoosableAtoms = streamOfChoosableAtoms.filter(admissibleChoices::contains); } + return getMostActiveChoosableAtom(streamOfChoosableAtoms); } - - protected int getMostActiveChoosableAtom(Stream streamOfLiterals) { - return streamOfLiterals - .map(Literals::atomOf) - .filter(this::isUnassigned) - .filter(choiceManager::isActiveChoiceAtom) - .max(Comparator.comparingDouble(this::getActivity)) + + protected int getMostActiveChoosableAtom(Stream streamOfAtoms) { + return streamOfAtoms + .filter(this::isUnassigned) + .filter(choiceManager::isActiveChoiceAtom) + .max(Comparator.comparingDouble(this::getActivity)) .orElse(DEFAULT_CHOICE_ATOM); } - private boolean isUnassigned(int atom) { + protected boolean isUnassigned(int atom) { ThriceTruth truth = assignment.getTruth(atom); return truth != FALSE && truth != TRUE; // do not use assignment.isAssigned(atom) because we may also choose MBTs } diff --git a/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/BerkMinLiteral.java b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/BerkMinLiteral.java index b916b1b7c..0f39e8c7d 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/BerkMinLiteral.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/BerkMinLiteral.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2017-2018, the Alpha Team. + * Copyright (c) 2017-2019, the Alpha Team. * All rights reserved. * * Additional changes made by Siemens. @@ -28,12 +28,14 @@ package at.ac.tuwien.kr.alpha.solver.heuristics; import at.ac.tuwien.kr.alpha.common.Assignment; +import at.ac.tuwien.kr.alpha.common.Literals; import at.ac.tuwien.kr.alpha.common.NoGood; import at.ac.tuwien.kr.alpha.solver.ChoiceManager; import java.util.Deque; import java.util.LinkedList; import java.util.Random; +import java.util.Set; import static at.ac.tuwien.kr.alpha.common.Literals.atomOf; @@ -57,8 +59,12 @@ public class BerkMinLiteral extends BerkMin { } @Override - public int chooseAtom() { - return getMostActiveChoosableAtom(activeLiterals.stream()); + public int chooseAtom(Set admissibleChoices) { + if (admissibleChoices == null) { + return getMostActiveChoosableAtom(activeLiterals.stream().map(Literals::atomOf)); + } else { + return getMostActiveChoosableAtom(activeLiterals.stream().map(Literals::atomOf).filter(admissibleChoices::contains)); + } } private void pushToStack(Integer literal) { diff --git a/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/BranchingHeuristic.java b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/BranchingHeuristic.java index 78be2e6de..cadd206bf 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/BranchingHeuristic.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/BranchingHeuristic.java @@ -29,6 +29,7 @@ import at.ac.tuwien.kr.alpha.solver.learning.GroundConflictNoGoodLearner; import java.util.Collection; +import java.util.Set; import static at.ac.tuwien.kr.alpha.common.Literals.atomToLiteral; @@ -72,12 +73,35 @@ default void newNoGoods(Collection newNoGoods) { newNoGoods.forEach(this::newNoGood); } + /** + * Determines an atom to choose. + * If only the atom is needed (and the sign is determined by the caller), + * calling this method may avoid some computational overhead invested by {@link #chooseLiteral()} + * to determine the sign. + * @return the atom to choose, or {@link BranchingHeuristic#DEFAULT_CHOICE_LITERAL} if no such atom can be determined. + */ + default int chooseAtom() { + return chooseAtom(null); + } + + /** + * Determines an atom to choose, ignoring all atoms except those in {@code admissibleChoices}. + */ + int chooseAtom(Set admissibleChoices); + /** * Determines a literal (= atom + sign) to choose. * - * @return the literal to choose, or {@link BranchingHeuristic#DEFAULT_CHOICE_LITERAL} if no such atom can be determined. + * @return the literal to choose, or {@link BranchingHeuristic#DEFAULT_CHOICE_LITERAL} if no such literal can be determined. + */ + default int chooseLiteral() { + return chooseLiteral(null); + } + + /** + * Determines a literal to choose, ignoring all atoms (!) except those in {@code admissibleChoices}. */ - int chooseLiteral(); + int chooseLiteral(Set admissibleChoices); default void growForMaxAtomId(int maxAtomId) { } diff --git a/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/BranchingHeuristicFactory.java b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/BranchingHeuristicFactory.java index e84f9b0a1..92905376f 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/BranchingHeuristicFactory.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/BranchingHeuristicFactory.java @@ -25,7 +25,6 @@ */ package at.ac.tuwien.kr.alpha.solver.heuristics; -import at.ac.tuwien.kr.alpha.grounder.Grounder; import at.ac.tuwien.kr.alpha.solver.ChoiceManager; import at.ac.tuwien.kr.alpha.solver.WritableAssignment; import at.ac.tuwien.kr.alpha.solver.heuristics.activity.BodyActivityProviderFactory.BodyActivityType; @@ -72,8 +71,7 @@ public enum Heuristic { GDD_PYRO, @Deprecated ALPHA_ACTIVE_RULE, - @Deprecated - ALPHA_HEAD_MBT, +// ALPHA_HEAD_MBT, // temporarily disabled due to poor performance (TODO: address https://github.com/alpha-asp/Alpha/issues/181) VSIDS, GDD_VSIDS; @@ -85,8 +83,18 @@ public static String listAllowedValues() { } } - public static BranchingHeuristic getInstance(HeuristicsConfiguration heuristicsConfiguration, Grounder grounder, WritableAssignment assignment, ChoiceManager choiceManager, Random random) { - BranchingHeuristic heuristicWithoutReplay = getInstanceWithoutReplay(heuristicsConfiguration, grounder, assignment, choiceManager, random); + public static BranchingHeuristic getInstance(HeuristicsConfiguration heuristicsConfiguration, WritableAssignment assignment, ChoiceManager choiceManager, + Random random) { + BranchingHeuristic fallbackHeuristic = getInstanceWithoutDomspec(heuristicsConfiguration, assignment, choiceManager, random); + if (heuristicsConfiguration.isRespectDomspecHeuristics()) { + return ChainedBranchingHeuristics.chainOf(new DomainSpecific(assignment, choiceManager, fallbackHeuristic), fallbackHeuristic); + } else { + return fallbackHeuristic; + } + } + + public static BranchingHeuristic getInstanceWithoutDomspec(HeuristicsConfiguration heuristicsConfiguration, WritableAssignment assignment, ChoiceManager choiceManager, Random random) { + BranchingHeuristic heuristicWithoutReplay = getInstanceWithoutReplay(heuristicsConfiguration, assignment, choiceManager, random); List replayChoices = heuristicsConfiguration.getReplayChoices(); if (replayChoices != null && !replayChoices.isEmpty()) { return ChainedBranchingHeuristics.chainOf( @@ -95,8 +103,8 @@ public static BranchingHeuristic getInstance(HeuristicsConfiguration heuristicsC } return heuristicWithoutReplay; } - - private static BranchingHeuristic getInstanceWithoutReplay(HeuristicsConfiguration heuristicsConfiguration, Grounder grounder, WritableAssignment assignment, ChoiceManager choiceManager, Random random) { + + private static BranchingHeuristic getInstanceWithoutReplay(HeuristicsConfiguration heuristicsConfiguration, WritableAssignment assignment, ChoiceManager choiceManager, Random random) { switch (heuristicsConfiguration.getHeuristic()) { case NAIVE: return new NaiveHeuristic(choiceManager); @@ -130,8 +138,8 @@ private static BranchingHeuristic getInstanceWithoutReplay(HeuristicsConfigurati return new GeneralizedDependencyDrivenPyroHeuristic(assignment, choiceManager, random, BodyActivityType.DEFAULT); case ALPHA_ACTIVE_RULE: return new AlphaActiveRuleHeuristic(assignment, choiceManager, random); - case ALPHA_HEAD_MBT: - return new AlphaHeadMustBeTrueHeuristic(assignment, choiceManager, random); +// case ALPHA_HEAD_MBT: +// return new AlphaHeadMustBeTrueHeuristic(assignment, choiceManager, random); case VSIDS: return new VSIDS(assignment, choiceManager, heuristicsConfiguration.getMomsStrategy()); case GDD_VSIDS: diff --git a/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/ChainedBranchingHeuristics.java b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/ChainedBranchingHeuristics.java index 6d6eb8761..871eb4a13 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/ChainedBranchingHeuristics.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/ChainedBranchingHeuristics.java @@ -25,8 +25,11 @@ */ package at.ac.tuwien.kr.alpha.solver.heuristics; +import at.ac.tuwien.kr.alpha.common.Literals; import at.ac.tuwien.kr.alpha.common.NoGood; import at.ac.tuwien.kr.alpha.solver.learning.GroundConflictNoGoodLearner.ConflictAnalysisResult; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.util.*; @@ -36,17 +39,19 @@ * A "chained" list of branching heuristics in which the entry at position n+1 is used as a fallback if the entry at position n cannot make a decision. */ public class ChainedBranchingHeuristics implements BranchingHeuristic { - + private static final Logger LOGGER = LoggerFactory.getLogger(ChainedBranchingHeuristics.class); + + private List chain = new LinkedList<>(); private int[] decisionCounters; - + private ChainedBranchingHeuristics(BranchingHeuristic... branchingHeuristics) { for (BranchingHeuristic element : branchingHeuristics) { add(element); } this.decisionCounters = new int[chain.size()]; } - + @Override public void violatedNoGood(NoGood violatedNoGood) { for (BranchingHeuristic element : chain) { @@ -68,12 +73,55 @@ public void newNoGood(NoGood newNoGood) { } } + @Override + public int chooseAtom() { + for (int i = 0; i < chain.size(); i++) { + BranchingHeuristic element = chain.get(i); + int chosenAtom = element.chooseAtom(); + if (chosenAtom != DEFAULT_CHOICE_ATOM) { + logChosenAtom(element, chosenAtom); + decisionCounters[i]++; + return chosenAtom; + } + } + return DEFAULT_CHOICE_ATOM; + } + + @Override + public int chooseAtom(Set admissibleChoices) { + for (int i = 0; i < chain.size(); i++) { + BranchingHeuristic element = chain.get(i); + int chosenAtom = element.chooseAtom(admissibleChoices); + if (chosenAtom != DEFAULT_CHOICE_ATOM) { + logChosenAtom(element, chosenAtom); + decisionCounters[i]++; + return chosenAtom; + } + } + return DEFAULT_CHOICE_ATOM; + } + @Override public int chooseLiteral() { for (int i = 0; i < chain.size(); i++) { BranchingHeuristic element = chain.get(i); int chosenLiteral = element.chooseLiteral(); if (chosenLiteral != DEFAULT_CHOICE_LITERAL) { + logChosenLiteral(element, chosenLiteral); + decisionCounters[i]++; + return chosenLiteral; + } + } + return DEFAULT_CHOICE_LITERAL; + } + + @Override + public int chooseLiteral(Set admissibleChoices) { + for (int i = 0; i < chain.size(); i++) { + BranchingHeuristic element = chain.get(i); + int chosenLiteral = element.chooseLiteral(admissibleChoices); + if (chosenLiteral != DEFAULT_CHOICE_LITERAL) { + logChosenLiteral(element, chosenLiteral); decisionCounters[i]++; return chosenLiteral; } @@ -101,7 +149,7 @@ public void add(BranchingHeuristic element) { public BranchingHeuristic getLastElement() { return chain.get(chain.size() - 1); } - + public static ChainedBranchingHeuristics chainOf(BranchingHeuristic... branchingHeuristics) { return new ChainedBranchingHeuristics(branchingHeuristics); } @@ -110,16 +158,28 @@ public static ChainedBranchingHeuristics chainOf(BranchingHeuristic... branching * Returns a mapping from individual heuristics to number of decisions made by them. */ public Map getNumberOfDecisions() { - Map map = new HashMap<>(); + Map map = new LinkedHashMap<>(); for (int i = 0; i < chain.size(); i++) { map.put(chain.get(i), decisionCounters[i]); } - return map; + return Collections.unmodifiableMap(map); } - + @Override public String toString() { return this.getClass().getSimpleName() + chain; } + private void logChosenAtom(BranchingHeuristic heuristic, int chosenAtom) { + logChoice(heuristic, "atom", String.valueOf(chosenAtom)); + } + + private void logChosenLiteral(BranchingHeuristic heuristic, int chosenLiteral) { + logChoice(heuristic, "literal", Literals.literalToString(chosenLiteral)); + } + + private void logChoice(BranchingHeuristic heuristic, String type, String choice) { + LOGGER.debug("{} chose {} {}", heuristic, type, choice); + } + } diff --git a/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/DependencyDrivenHeuristic.java b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/DependencyDrivenHeuristic.java index e24f29da0..3bf93201e 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/DependencyDrivenHeuristic.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/DependencyDrivenHeuristic.java @@ -85,6 +85,7 @@ public class DependencyDrivenHeuristic implements ActivityBasedBranchingHeuristi /** * Maps rule heads to atoms representing corresponding bodies. + * TODO: somehow use at.ac.tuwien.kr.alpha.solver.ChoiceManager.headsToBodies instead (cf. issue #181) */ protected final MultiValuedMap headToBodies = new HashSetValuedHashMap<>(); @@ -98,6 +99,15 @@ public class DependencyDrivenHeuristic implements ActivityBasedBranchingHeuristi */ protected final MultiValuedMap atomsToBodiesAtoms = new HashSetValuedHashMap<>(); + /** + * + * @param assignment + * @param choiceManager + * @param decayPeriod the number of steps after which all counters are decayed (i.e. multiplied by {@code decayFactor}). + * @param decayFactor + * @param random + * @param bodyActivityType + */ public DependencyDrivenHeuristic(Assignment assignment, ChoiceManager choiceManager, int decayPeriod, double decayFactor, Random random, BodyActivityType bodyActivityType) { this.assignment = assignment; this.choiceManager = choiceManager; @@ -115,34 +125,6 @@ public DependencyDrivenHeuristic(Assignment assignment, ChoiceManager choiceMana this(assignment, choiceManager, random, BodyActivityType.DEFAULT); } - /** - * Gets the number of steps after which all counters are decayed (i.e. multiplied by {@link #getDecayFactor()}. - */ - public int getDecayPeriod() { - return decayPeriod; - } - - /** - * Sets the number of steps after which all counters are decayed (i.e. multiplied by {@link #getDecayFactor()}. - */ - public void setDecayPeriod(int decayPeriod) { - this.decayPeriod = decayPeriod; - } - - /** - * Gets the factor by which all counters are multiplied to decay after {@link #getDecayPeriod()}. - */ - public double getDecayFactor() { - return decayFactor; - } - - /** - * Sets the factor by which all counters are multiplied to decay after {@link #getDecayPeriod()}. - */ - public void setDecayFactor(double decayFactor) { - this.decayFactor = decayFactor; - } - @Override public void violatedNoGood(NoGood violatedNoGood) { pushToStack(violatedNoGood); @@ -192,7 +174,12 @@ public double getActivity(int literal) { */ @Override public int chooseLiteral() { - int atom = chooseAtom(); + return chooseLiteral(null); + } + + @Override + public int chooseLiteral(Set admissibleChoices) { + int atom = chooseAtom(admissibleChoices); if (atom == DEFAULT_CHOICE_ATOM) { return DEFAULT_CHOICE_LITERAL; } @@ -200,16 +187,16 @@ public int chooseLiteral() { return atomToLiteral(atom, sign); } - protected int chooseAtom() { + @Override + public int chooseAtom(Set admissibleChoices) { for (NoGood noGood : stackOfNoGoods) { int mostActiveAtom = getMostActiveAtom(noGood); - if (choiceManager.isActiveChoiceAtom(mostActiveAtom)) { + if (choiceManager.isActiveChoiceAtom(mostActiveAtom) && (admissibleChoices == null || admissibleChoices.contains(mostActiveAtom))) { return mostActiveAtom; } Collection bodies = atomsToBodiesAtoms.get(mostActiveAtom); - Optional mostActiveBody = bodies.stream().filter(this::isUnassigned).filter(choiceManager::isActiveChoiceAtom) - .max(Comparator.comparingDouble(bodyActivity::get)); + Optional mostActiveBody = getMostActiveBody(bodies.stream(), admissibleChoices); if (mostActiveBody.isPresent()) { return mostActiveBody.get(); } @@ -217,6 +204,15 @@ protected int chooseAtom() { return DEFAULT_CHOICE_ATOM; } + protected Optional getMostActiveBody(Stream streamOfBodies, Set admissibleChoices) { + if (admissibleChoices != null) { + streamOfBodies = streamOfBodies.filter(admissibleChoices::contains); + } + Optional mostActiveBody = streamOfBodies.filter(this::isUnassigned).filter(choiceManager::isActiveChoiceAtom) + .max(Comparator.comparingDouble(bodyActivity::get)); + return mostActiveBody; + } + protected boolean chooseSign(int atom) { atom = getAtomForChooseSign(atom); @@ -302,19 +298,6 @@ private void decayAllIfTimeHasCome() { } } - /** - * Gets the most recent conflict that is still violated. - * @return the violated nogood closest to the top of the stack of nogoods. - */ - NoGood getCurrentTopClause() { - for (NoGood noGood : stackOfNoGoods) { - if (assignment.isUndefined(noGood)) { - return noGood; - } - } - return null; - } - protected boolean isUnassigned(int atom) { ThriceTruth truth = assignment.getTruth(atom); return truth != FALSE && truth != TRUE; // do not use assignment.isAssigned(atom) because we may also choose MBTs diff --git a/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/DomainSpecific.java b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/DomainSpecific.java new file mode 100644 index 000000000..285467cf5 --- /dev/null +++ b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/DomainSpecific.java @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2018-2021 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.solver.heuristics; + +import java.util.Collection; +import java.util.Optional; +import java.util.Set; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import at.ac.tuwien.kr.alpha.common.Assignment; +import at.ac.tuwien.kr.alpha.common.HeuristicDirective; +import at.ac.tuwien.kr.alpha.common.Literals; +import at.ac.tuwien.kr.alpha.common.NoGood; +import at.ac.tuwien.kr.alpha.common.heuristics.HeuristicDirectiveValues; +import at.ac.tuwien.kr.alpha.solver.ChoiceManager; +import at.ac.tuwien.kr.alpha.solver.ThriceTruth; +import at.ac.tuwien.kr.alpha.solver.heuristics.domspec.DomainSpecificHeuristicsStore; +import at.ac.tuwien.kr.alpha.solver.learning.GroundConflictNoGoodLearner.ConflictAnalysisResult; + +import static at.ac.tuwien.kr.alpha.Util.oops; +import static at.ac.tuwien.kr.alpha.common.Literals.atomOf; + +/** + * Analyses information obtained from {@link HeuristicDirective}s to follow domain-specific heuristics specified within the input program. + */ +public class DomainSpecific implements BranchingHeuristic { + private static final Logger LOGGER = LoggerFactory.getLogger(DomainSpecific.class); + + private final Assignment assignment; + private final ChoiceManager choiceManager; + private final BranchingHeuristic fallbackHeuristic; + + DomainSpecific(Assignment assignment, ChoiceManager choiceManager, BranchingHeuristic fallbackHeuristic) { + this.assignment = assignment; + this.choiceManager = choiceManager; + this.fallbackHeuristic = fallbackHeuristic; + } + + @Override + public void violatedNoGood(NoGood violatedNoGood) { + fallbackHeuristic.violatedNoGood(violatedNoGood); + } + + @Override + public void analyzedConflict(ConflictAnalysisResult analysisResult) { + fallbackHeuristic.analyzedConflict(analysisResult); + } + + @Override + public void newNoGood(NoGood newNoGood) { + fallbackHeuristic.newNoGood(newNoGood); + } + + @Override + public void newNoGoods(Collection newNoGoods) { + fallbackHeuristic.newNoGoods(newNoGoods); + } + + @Override + public int chooseAtom(Set admissibleChoices) { + return atomOf(chooseLiteral(admissibleChoices)); + } + + @Override + public int chooseLiteral(Set admissibleChoices) { + DomainSpecificHeuristicsStore heuristicsStore = choiceManager.getDomainSpecificHeuristics(); + if (admissibleChoices != null) { + throw new UnsupportedOperationException("DomainSpecific does not support restricting guesses to admissible choices."); + } + + HeuristicDirectiveValues currentValues; + int chosenLiteral = DEFAULT_CHOICE_LITERAL; + while ((currentValues = heuristicsStore.poll()) != null) { + if (assignment.isUnassignedOrMBT(currentValues.getHeadAtomId())) { + Optional body = chooseLiteralForValues(currentValues); + if (body.isPresent()) { + chosenLiteral = body.get(); + LOGGER.debug("Domain-specific choice: sign={}, headId={}, head={}, bodyId={}, priority={}@{}", ThriceTruth.valueOf(currentValues.getSign()), currentValues.getHeadAtomId(), currentValues.getGroundHeadAtom(), atomOf(chosenLiteral), currentValues.getWeight(), currentValues.getLevel()); + break; + } else { + LOGGER.warn("Ground heuristic directive with head {} not applicable because no active rule can derive it.", currentValues.getGroundHeadAtom()); + } + } else { + throw oops("Heuristic chosen whose head is already assigned"); + } + } + + return chosenLiteral; + } + + private Optional chooseLiteralForValues(HeuristicDirectiveValues values) { + Set activeChoiceAtomsDerivingHead = choiceManager.getActiveChoiceAtomsDerivingHead(values.getHeadAtomId()); + int atom; + if (activeChoiceAtomsDerivingHead.isEmpty()) { + return Optional.empty(); + } else if (activeChoiceAtomsDerivingHead.size() == 1) { + atom = activeChoiceAtomsDerivingHead.iterator().next(); + } else { + throw new UnsupportedOperationException("Atom " + values.getGroundHeadAtom() + " chosen by domain-specific heuristic is the head of more than one applicable rule."); + } + return Optional.of(Literals.atomToLiteral(atom, values.getSign())); + } + + @Override + public String toString() { + return this.getClass().getSimpleName(); + } +} diff --git a/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/HeapOfActiveAtoms.java b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/HeapOfActiveAtoms.java index 858b9ec91..f5a7d015d 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/HeapOfActiveAtoms.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/HeapOfActiveAtoms.java @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2018-2019 Siemens AG +/* + * Copyright (c) 2018-2020 Siemens AG * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -28,8 +28,8 @@ import at.ac.tuwien.kr.alpha.common.NoGood; import at.ac.tuwien.kr.alpha.common.NoGoodInterface.Type; import at.ac.tuwien.kr.alpha.solver.BinaryNoGoodPropagationEstimation; -import at.ac.tuwien.kr.alpha.solver.ChoiceInfluenceManager; import at.ac.tuwien.kr.alpha.solver.ChoiceManager; +import at.ac.tuwien.kr.alpha.solver.InfluenceManager; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -160,7 +160,7 @@ protected void initActivity(NoGood newNoGood) { * @param newNoGood a new nogood, the atoms occurring in which will be initialized */ private void initActivityMOMs(NoGood newNoGood) { - LOGGER.debug("Initializing activity scores with MOMs"); + LOGGER.trace("Initializing activity scores with MOMs for nogood: " + newNoGood); for (int literal : newNoGood) { int atom = atomOf(literal); if (!incrementedActivityScores[atom]) { // update initial value as long as not incremented yet by VSIDS @@ -258,7 +258,7 @@ public int compare(Integer a1, Integer a2) { } - private class ChoicePointActivityListener implements ChoiceInfluenceManager.ActivityListener { + private class ChoicePointActivityListener implements InfluenceManager.ActivityListener { @Override public void callbackOnChanged(int atom, boolean active) { diff --git a/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/HeuristicsConfiguration.java b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/HeuristicsConfiguration.java index 160283324..ece7ec36d 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/HeuristicsConfiguration.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/HeuristicsConfiguration.java @@ -1,17 +1,17 @@ /** * Copyright (c) 2018-2019 Siemens AG * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1) Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. - * + * * 2) Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -34,34 +34,32 @@ * Configuration class holding parameters for {@link BranchingHeuristic}s. */ public class HeuristicsConfiguration { - - private Heuristic heuristic; - private Strategy momsStrategy; - private List replayChoices; + + private final Heuristic heuristic; + private final boolean respectDomspecHeuristics; + private final Strategy momsStrategy; + private final List replayChoices; + /** * @param heuristic + * @param respectDomspecHeuristics * @param momsStrategy * @param replayChoices */ - public HeuristicsConfiguration(Heuristic heuristic, Strategy momsStrategy, List replayChoices) { + public HeuristicsConfiguration(Heuristic heuristic, boolean respectDomspecHeuristics, Strategy momsStrategy, List replayChoices) { super(); this.heuristic = heuristic; + this.respectDomspecHeuristics = respectDomspecHeuristics; this.momsStrategy = momsStrategy; this.replayChoices = replayChoices; } - /** - * @return the heuristic - */ public Heuristic getHeuristic() { return heuristic; } - /** - * @param heuristic the heuristic to set - */ - public void setHeuristic(Heuristic heuristic) { - this.heuristic = heuristic; + public boolean isRespectDomspecHeuristics() { + return respectDomspecHeuristics; } /** @@ -70,30 +68,19 @@ public void setHeuristic(Heuristic heuristic) { public Strategy getMomsStrategy() { return momsStrategy; } - - /** - * @param momsStrategy the momsStrategy to set - */ - public void setMomsStrategy(Strategy momsStrategy) { - this.momsStrategy = momsStrategy; - } - - /** +/** * @return the replayChoices */ public List getReplayChoices() { return replayChoices; } - /** - * @param replayChoices the replayChoices to set - */ - public void setReplayChoices(List replayChoices) { - this.replayChoices = replayChoices; - } - public static HeuristicsConfigurationBuilder builder() { return new HeuristicsConfigurationBuilder(); } + @Override + public String toString() { + return heuristic.toString() + ", respectDomspecHeuristics=" + respectDomspecHeuristics + ", momsStrategy=" + momsStrategy; + } } diff --git a/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/HeuristicsConfigurationBuilder.java b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/HeuristicsConfigurationBuilder.java index 8e68582b6..5f9554cad 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/HeuristicsConfigurationBuilder.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/HeuristicsConfigurationBuilder.java @@ -1,17 +1,17 @@ /** * Copyright (c) 2018-2019 Siemens AG * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1) Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. - * + * * 2) Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -34,8 +34,9 @@ * Builder for {@link HeuristicsConfiguration} objects */ public class HeuristicsConfigurationBuilder { - + private Heuristic heuristic; + private boolean respectDomspecHeuristics = true; private BinaryNoGoodPropagationEstimation.Strategy momsStrategy; private List replayChoices; @@ -47,6 +48,11 @@ public HeuristicsConfigurationBuilder setHeuristic(Heuristic heuristic) { return this; } + public HeuristicsConfigurationBuilder setRespectDomspecHeuristics(boolean respectDomspecHeuristics) { + this.respectDomspecHeuristics = respectDomspecHeuristics; + return this; + } + /** * @param momsStrategy the momsStrategy to set */ @@ -64,7 +70,6 @@ public HeuristicsConfigurationBuilder setReplayChoices(List replayChoic } public HeuristicsConfiguration build() { - return new HeuristicsConfiguration(heuristic, momsStrategy, replayChoices); + return new HeuristicsConfiguration(heuristic, respectDomspecHeuristics, momsStrategy, replayChoices); } - } diff --git a/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/NaiveHeuristic.java b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/NaiveHeuristic.java index 506cc345c..1c9c29b35 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/NaiveHeuristic.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/NaiveHeuristic.java @@ -32,6 +32,7 @@ import at.ac.tuwien.kr.alpha.solver.learning.GroundConflictNoGoodLearner.ConflictAnalysisResult; import java.util.Collection; +import java.util.Set; import static at.ac.tuwien.kr.alpha.common.Literals.atomToLiteral; @@ -64,10 +65,34 @@ public void newNoGoods(Collection newNoGoods) { } @Override - public int chooseLiteral() { + public int chooseAtom() { return atomToLiteral(choiceManager.getNextActiveChoiceAtom()); } - + + @Override + public int chooseAtom(Set admissibleChoices) { + if (admissibleChoices == null) { + return chooseLiteral(); + } + + for (int choice : admissibleChoices) { + if (choiceManager.isActiveChoiceAtom(choice)) { + return choice; + } + } + return DEFAULT_CHOICE_ATOM; + } + + @Override + public int chooseLiteral() { + return chooseAtom(); + } + + @Override + public int chooseLiteral(Set admissibleChoices) { + return chooseAtom(admissibleChoices); + } + @Override public String toString() { return this.getClass().getSimpleName(); diff --git a/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/ReplayHeuristic.java b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/ReplayHeuristic.java index cda9f35ac..2d87f99f6 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/ReplayHeuristic.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/ReplayHeuristic.java @@ -32,6 +32,7 @@ import java.util.Iterator; import java.util.List; +import java.util.Set; /** * A heuristic that replays a fixed list of choices. @@ -65,7 +66,12 @@ public void newNoGood(NoGood newNoGood) { } @Override - public int chooseLiteral() { + public int chooseAtom(Set admissibleChoices) { + throw new UnsupportedOperationException(); + } + + @Override + public int chooseLiteral(Set admissibleChoices) { if (!choicesIterator.hasNext()) { return DEFAULT_CHOICE_LITERAL; } @@ -76,12 +82,15 @@ public int chooseLiteral() { } int replayChoiceAtom = Math.abs(replayChoiceSignedAtom); int replayChoiceLiteral = Literals.atomToLiteral(replayChoiceAtom, replayChoiceSignedAtom > 0); + if (admissibleChoices != null && !admissibleChoices.contains(replayChoiceSignedAtom)) { + throw new IllegalStateException("Replay choice is not admissible: " + replayChoiceSignedAtom); + } if (!choiceManager.isActiveChoiceAtom(replayChoiceAtom)) { throw new IllegalStateException("Replay choice is not an active choice point: " + replayChoiceAtom); } return replayChoiceLiteral; } - + @Override public String toString() { return this.getClass().getSimpleName(); diff --git a/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/VSIDS.java b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/VSIDS.java index 16b5f0daa..c423575fa 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/VSIDS.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/VSIDS.java @@ -40,6 +40,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Set; import static at.ac.tuwien.kr.alpha.Util.arrayGrowthSize; import static at.ac.tuwien.kr.alpha.common.Literals.*; @@ -144,8 +145,8 @@ private void ingestBufferedNoGoods() { * When choosing between dependent atoms, a {@link BodyActivityProvider} is employed to define the activity of a choice point. */ @Override - public int chooseLiteral() { - int atom = chooseAtom(); + public int chooseLiteral(Set admissibleChoices) { + int atom = chooseAtom(admissibleChoices); if (atom == DEFAULT_CHOICE_ATOM) { return DEFAULT_CHOICE_LITERAL; } @@ -153,7 +154,12 @@ public int chooseLiteral() { return atomToLiteral(atom, sign); } - protected int chooseAtom() { + @Override + public int chooseAtom(Set admissibleChoices) { + if (admissibleChoices != null) { + throw new UnsupportedOperationException("Choosing from a set of admissible choices is not yet implemented by VSIDS."); + // TODO: idea: build new PriorityQueue, taking comparator from existing HeapOfActiveAtoms, then pick top element (is this the most performant way)? (cf. issue #181) + } ingestBufferedNoGoods(); Integer mostActiveAtom; while ((mostActiveAtom = heapOfActiveAtoms.getMostActiveAtom()) != null) { diff --git a/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/domspec/DefaultDomainSpecificHeuristicsStore.java b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/domspec/DefaultDomainSpecificHeuristicsStore.java new file mode 100644 index 000000000..29ef14ec0 --- /dev/null +++ b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/domspec/DefaultDomainSpecificHeuristicsStore.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2018-2021 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.solver.heuristics.domspec; + +import java.util.Arrays; +import java.util.Comparator; +import java.util.PriorityQueue; + +import at.ac.tuwien.kr.alpha.common.heuristics.HeuristicDirectiveValues; +import at.ac.tuwien.kr.alpha.common.heuristics.HeuristicDirectiveValues.PriorityComparator; +import at.ac.tuwien.kr.alpha.solver.ChoiceManager; +import at.ac.tuwien.kr.alpha.solver.InfluenceManager; + +import static at.ac.tuwien.kr.alpha.Util.arrayGrowthSize; + +/** + * Stores a mapping between heuristic IDs and their corresponding domain-specific heuristic values. + */ +public class DefaultDomainSpecificHeuristicsStore implements DomainSpecificHeuristicsStore { + + private HeuristicDirectiveValues[] heuristicDirectiveValues = new HeuristicDirectiveValues[0]; + private final PriorityQueue prioritisedHeuristics = new PriorityQueue<>(new HeuristicPriorityComparator().reversed()); + + @Override + public void addInfo(int heuristicId, HeuristicDirectiveValues values) { + heuristicDirectiveValues[heuristicId] = values; + } + + @Override + public HeuristicDirectiveValues poll() { + Integer heuristicId = prioritisedHeuristics.poll(); + return heuristicId == null ? null : heuristicDirectiveValues[heuristicId]; + } + + @Override + public void setChoiceManager(ChoiceManager choiceManager) { + if (choiceManager != null) { + choiceManager.setHeuristicActivityListener(new HeuristicActivityListener()); + } + } + + public void growForMaxAtomId(int maxAtomId) { + // Grow arrays only if needed. + if (heuristicDirectiveValues.length > maxAtomId) { + return; + } + // Grow to default size, except if bigger array is required due to maxAtomId. + int newCapacity = arrayGrowthSize(heuristicDirectiveValues.length); + if (newCapacity < maxAtomId + 1) { + newCapacity = maxAtomId + 1; + } + heuristicDirectiveValues = Arrays.copyOf(heuristicDirectiveValues, newCapacity); + } + + private class HeuristicActivityListener implements InfluenceManager.ActivityListener { + + @Override + public void callbackOnChanged(int atom, boolean active) { + if (active) { + prioritisedHeuristics.add(atom); + } else { + prioritisedHeuristics.remove(atom); + } + } + } + + private class HeuristicPriorityComparator implements Comparator { + + private final PriorityComparator priorityComparator = new PriorityComparator(); + + @Override + public int compare(Integer heu1, Integer heu2) { + return priorityComparator.compare(heuristicDirectiveValues[heu1], heuristicDirectiveValues[heu2]); + } + + } + +} diff --git a/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/domspec/DomainSpecificHeuristicsStore.java b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/domspec/DomainSpecificHeuristicsStore.java new file mode 100644 index 000000000..ff8cf869a --- /dev/null +++ b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/domspec/DomainSpecificHeuristicsStore.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2018-2019, 2021 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.solver.heuristics.domspec; + +import at.ac.tuwien.kr.alpha.common.heuristics.HeuristicDirectiveValues; +import at.ac.tuwien.kr.alpha.solver.ChoiceManager; + +/** + * Stores information on heuristic directives obtained from the grounder + */ +public interface DomainSpecificHeuristicsStore { + + void addInfo(int heuristicId, HeuristicDirectiveValues values); + + /** + * Retrieves and removes the element with the highest priority + * @return the element with the highest priority + */ + HeuristicDirectiveValues poll(); + + void setChoiceManager(ChoiceManager choiceManager); + + void growForMaxAtomId(int maxAtomId); +} diff --git a/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/domspec/EmptyDomainSpecificHeuristicsStore.java b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/domspec/EmptyDomainSpecificHeuristicsStore.java new file mode 100644 index 000000000..e9bd9e7da --- /dev/null +++ b/src/main/java/at/ac/tuwien/kr/alpha/solver/heuristics/domspec/EmptyDomainSpecificHeuristicsStore.java @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2018-2019, 2021 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.solver.heuristics.domspec; + +import at.ac.tuwien.kr.alpha.common.heuristics.HeuristicDirectiveValues; +import at.ac.tuwien.kr.alpha.solver.ChoiceManager; + +/** + * Does nothing (to be used instead of {@link DefaultDomainSpecificHeuristicsStore} in case the domain-specific heuristics are not used) + */ +public class EmptyDomainSpecificHeuristicsStore implements DomainSpecificHeuristicsStore { + + @Override + public void addInfo(int heuristicId, HeuristicDirectiveValues values) { + } + + @Override + public HeuristicDirectiveValues poll() { + return null; + } + + @Override + public void setChoiceManager(ChoiceManager choiceManager) { + } + + @Override + public void growForMaxAtomId(int maxAtomId) { + } +} diff --git a/src/main/java/at/ac/tuwien/kr/alpha/solver/learning/GroundConflictNoGoodLearner.java b/src/main/java/at/ac/tuwien/kr/alpha/solver/learning/GroundConflictNoGoodLearner.java index d5b26f9bf..6e536860c 100644 --- a/src/main/java/at/ac/tuwien/kr/alpha/solver/learning/GroundConflictNoGoodLearner.java +++ b/src/main/java/at/ac/tuwien/kr/alpha/solver/learning/GroundConflictNoGoodLearner.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016-2018, the Alpha Team. + * Copyright (c) 2016-2019, the Alpha Team. * All rights reserved. * * Additional changes made by Siemens. @@ -30,6 +30,7 @@ import at.ac.tuwien.kr.alpha.common.Assignment; import at.ac.tuwien.kr.alpha.common.AtomStore; import at.ac.tuwien.kr.alpha.common.NoGood; +import at.ac.tuwien.kr.alpha.common.NoGoodCreator; import at.ac.tuwien.kr.alpha.solver.Antecedent; import at.ac.tuwien.kr.alpha.solver.TrailAssignment; import org.slf4j.Logger; @@ -250,7 +251,7 @@ private ConflictAnalysisResult analyzeTrailBased(Antecedent conflictReason) { int[] learnedLiterals = minimizeLearnedLiterals(resolutionLiterals, seenAtoms); - NoGood learnedNoGood = NoGood.learnt(learnedLiterals); + NoGood learnedNoGood = NoGoodCreator.learnt(learnedLiterals); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Learned NoGood is: {}", atomStore.noGoodToString(learnedNoGood)); } diff --git a/src/test/java/at/ac/tuwien/kr/alpha/AnswerSetToXlsxWriterTest.java b/src/test/java/at/ac/tuwien/kr/alpha/AnswerSetToXlsxWriterTest.java index 4e17c27e7..43447924b 100644 --- a/src/test/java/at/ac/tuwien/kr/alpha/AnswerSetToXlsxWriterTest.java +++ b/src/test/java/at/ac/tuwien/kr/alpha/AnswerSetToXlsxWriterTest.java @@ -64,3 +64,4 @@ public void writeUnsatTest() throws IOException { } } + diff --git a/src/test/java/at/ac/tuwien/kr/alpha/antlr/ParserTest.java b/src/test/java/at/ac/tuwien/kr/alpha/antlr/ParserTest.java index fcd4f9ffd..85bc4fa1e 100644 --- a/src/test/java/at/ac/tuwien/kr/alpha/antlr/ParserTest.java +++ b/src/test/java/at/ac/tuwien/kr/alpha/antlr/ParserTest.java @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2016-2017, the Alpha Team. +/* + * Copyright (c) 2016-2021, the Alpha Team. * All rights reserved. * * Additional changes made by Siemens. @@ -27,10 +27,11 @@ */ package at.ac.tuwien.kr.alpha.antlr; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; +import org.antlr.v4.runtime.CharStream; +import org.antlr.v4.runtime.CharStreams; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.nio.channels.ReadableByteChannel; @@ -40,13 +41,12 @@ import java.util.Optional; import java.util.stream.Stream; -import org.antlr.v4.runtime.CharStream; -import org.antlr.v4.runtime.CharStreams; -import org.junit.jupiter.api.Test; - import at.ac.tuwien.kr.alpha.Util; import at.ac.tuwien.kr.alpha.common.ComparisonOperator; +import at.ac.tuwien.kr.alpha.common.EnumerationDirective; +import at.ac.tuwien.kr.alpha.common.HeuristicDirective; import at.ac.tuwien.kr.alpha.common.Predicate; +import at.ac.tuwien.kr.alpha.common.WeightAtLevel; import at.ac.tuwien.kr.alpha.common.atoms.AggregateAtom; import at.ac.tuwien.kr.alpha.common.atoms.AggregateLiteral; import at.ac.tuwien.kr.alpha.common.atoms.Atom; @@ -61,12 +61,31 @@ import at.ac.tuwien.kr.alpha.common.terms.VariableTerm; import at.ac.tuwien.kr.alpha.grounder.parser.InlineDirectives; import at.ac.tuwien.kr.alpha.grounder.parser.ProgramParser; +import at.ac.tuwien.kr.alpha.grounder.transformation.HeuristicDirectiveToRule; +import at.ac.tuwien.kr.alpha.solver.heuristics.HeuristicsConfiguration; +import at.ac.tuwien.kr.alpha.solver.heuristics.HeuristicsConfigurationBuilder; + +import static at.ac.tuwien.kr.alpha.Util.asSet; +import static at.ac.tuwien.kr.alpha.solver.ThriceTruth.FALSE; +import static at.ac.tuwien.kr.alpha.solver.ThriceTruth.MBT; +import static at.ac.tuwien.kr.alpha.solver.ThriceTruth.TRUE; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; /** - * Copyright (c) 2016, the Alpha Team. + * Copyright (c) 2016-2020, the Alpha Team. */ public class ParserTest { private final ProgramParser parser = new ProgramParser(); + private final HeuristicsConfiguration heuristicsConfiguration = new HeuristicsConfigurationBuilder().setRespectDomspecHeuristics(true).build(); + + @BeforeEach + public void setUp() { + VariableTerm.ANONYMOUS_VARIABLE_COUNTER.resetGenerator(); + } @Test public void parseFact() { @@ -126,9 +145,9 @@ public void parseProgramWithDisjunctionInHead() { public void parseInterval() { InputProgram parsedProgram = parser.parse("fact(2..5). p(X) :- q(a, 3 .. X)."); IntervalTerm factInterval = (IntervalTerm) parsedProgram.getFacts().get(0).getTerms().get(0); - assertTrue(factInterval.equals(IntervalTerm.getInstance(ConstantTerm.getInstance(2), ConstantTerm.getInstance(5)))); - IntervalTerm bodyInterval = (IntervalTerm) ((Literal) parsedProgram.getRules().get(0).getBody().stream().findFirst().get()).getTerms().get(1); - assertTrue(bodyInterval.equals(IntervalTerm.getInstance(ConstantTerm.getInstance(3), VariableTerm.getInstance("X")))); + assertEquals(factInterval, IntervalTerm.getInstance(ConstantTerm.getInstance(2), ConstantTerm.getInstance(5))); + IntervalTerm bodyInterval = (IntervalTerm) parsedProgram.getRules().get(0).getBody().stream().findFirst().get().getTerms().get(1); + assertEquals(bodyInterval, IntervalTerm.getInstance(ConstantTerm.getInstance(3), VariableTerm.getInstance("X"))); } @Test @@ -136,10 +155,10 @@ public void parseChoiceRule() { InputProgram parsedProgram = parser.parse("dom(1). dom(2). { a ; b } :- dom(X)."); ChoiceHead choiceHead = (ChoiceHead) parsedProgram.getRules().get(0).getHead(); assertEquals(2, choiceHead.getChoiceElements().size()); - assertTrue(choiceHead.getChoiceElements().get(0).choiceAtom.toString().equals("a")); - assertTrue(choiceHead.getChoiceElements().get(1).choiceAtom.toString().equals("b")); - assertEquals(null, choiceHead.getLowerBound()); - assertEquals(null, choiceHead.getUpperBound()); + assertEquals("a", choiceHead.getChoiceElements().get(0).choiceAtom.toString()); + assertEquals("b", choiceHead.getChoiceElements().get(1).choiceAtom.toString()); + assertNull(choiceHead.getLowerBound()); + assertNull(choiceHead.getUpperBound()); } @Test @@ -147,8 +166,8 @@ public void parseChoiceRuleBounded() { InputProgram parsedProgram = parser.parse("dom(1). dom(2). 1 < { a: p(v,w), not r; b } <= 13 :- dom(X). foo."); ChoiceHead choiceHead = (ChoiceHead) parsedProgram.getRules().get(0).getHead(); assertEquals(2, choiceHead.getChoiceElements().size()); - assertTrue(choiceHead.getChoiceElements().get(0).choiceAtom.toString().equals("a")); - assertTrue(choiceHead.getChoiceElements().get(1).choiceAtom.toString().equals("b")); + assertEquals("a", choiceHead.getChoiceElements().get(0).choiceAtom.toString()); + assertEquals("b", choiceHead.getChoiceElements().get(1).choiceAtom.toString()); List conditionalLiterals = choiceHead.getChoiceElements().get(0).conditionLiterals; assertEquals(2, conditionalLiterals.size()); assertFalse(conditionalLiterals.get(0).isNegated()); @@ -195,10 +214,10 @@ public void testMissingDotNotIgnored() { @Test public void parseEnumerationDirective() { InputProgram parsedProgram = parser.parse("p(a,1)." + - "# enumeration_predicate_is mune." + - "r(X) :- p(X), mune(X)." + - "p(b,2)."); - String directive = parsedProgram.getInlineDirectives().getDirectiveValue(InlineDirectives.DIRECTIVE.enum_predicate_is); + "# enumeration_predicate_is mune." + + "r(X) :- p(X), mune(X)." + + "p(b,2)."); + String directive = ((EnumerationDirective)parsedProgram.getInlineDirectives().getDirectiveValue(InlineDirectives.DIRECTIVE.enum_predicate_is)).getValue(); assertEquals("mune", directive); } @@ -220,6 +239,167 @@ public void cardinalityAggregate() { assertEquals(expectedAggregate, parsedAggregate.getAtom()); } + @Test + public void parseProgramWithHeuristicDirective_W() { + InputProgram parsedProgram = parser.parse("c(X) :- p(X,a,_), q(Xaa,xaa). " + + "#heuristic c(X) : T p(X,a,_), q(Xaa,xaa). [X]"); + + HeuristicDirective directive = getFirstHeuristicDirective(parsedProgram); + assertEquals("T c(X)", directive.getHead().toString()); + assertEquals("T p(X, a, _1), TM q(Xaa, xaa)", directive.getBody().toString()); + WeightAtLevel weightAtLevel = directive.getWeightAtLevel(); + assertEquals("X", weightAtLevel.getWeight().toString()); + assertEquals("0", weightAtLevel.getLevel().toString()); + } + + @Test + public void parseProgramWithHeuristicDirective_WP() { + InputProgram parsedProgram = parser.parse("c(X) :- p(X,a,_), q(Xaa,xaa). " + + "#heuristic c(X) : p(X,a,_), T q(Xaa,xaa). [X@2]"); + + HeuristicDirective directive = getFirstHeuristicDirective(parsedProgram); + assertEquals("T c(X)", directive.getHead().toString()); + assertEquals("TM p(X, a, _1), T q(Xaa, xaa)", directive.getBody().toString()); + WeightAtLevel weightAtLevel = directive.getWeightAtLevel(); + assertEquals("X", weightAtLevel.getWeight().toString()); + assertEquals("2", weightAtLevel.getLevel().toString()); + } + + @Test + public void parseProgramWithHeuristicDirective_Condition() { + InputProgram parsedProgram = parser.parse("c(X) :- p(X,a,_), q(Xaa,xaa). " + + "#heuristic c(X) : MT p(X,a,_), q(Xaa,xaa), not c(X). [X@2]"); + + HeuristicDirective directive = getFirstHeuristicDirective(parsedProgram); + assertEquals("T c(X)", directive.getHead().toString()); + assertEquals("TM p(X, a, _1), TM q(Xaa, xaa), not TM c(X)", directive.getBody().toString()); + assertEquals("#heuristic T c(X) : TM p(X, a, _1), TM q(Xaa, xaa), not TM c(X). [X@2]", directive.toString()); + WeightAtLevel weightAtLevel = directive.getWeightAtLevel(); + assertEquals("X", weightAtLevel.getWeight().toString()); + assertEquals("2", weightAtLevel.getLevel().toString()); + } + + @Test + public void parseProgramWithHeuristicDirective_ConditionWithArithmetics() { + InputProgram parsedProgram = parser.parse("holds(F,T) :- fluent(F), time(T), T > 0, lasttime(LT), not not_holds(F,T). " + + "#heuristic holds(F,T) : fluent(F), time(T), T > 0, lasttime(LT), not F holds(F,T), holds(F,Tp1), Tp1=T+1, LTp1mT=LT+1-T. [LTp1mT@1]"); + + HeuristicDirective directive = getFirstHeuristicDirective(parsedProgram); + assertEquals("T holds(F, T)", directive.getHead().toString()); + assertEquals("TM fluent(F), TM time(T), T > 0, TM lasttime(LT), TM holds(F, Tp1), Tp1 = T + 1, LTp1mT = LT + 1 - T, not F holds(F, T)", directive.getBody().toString()); + WeightAtLevel weightAtLevel = directive.getWeightAtLevel(); + assertEquals("LTp1mT", weightAtLevel.getWeight().toString()); + assertEquals("1", weightAtLevel.getLevel().toString()); + } + + @Test + public void parseProgramWithHeuristicDirective_ConditionWithHeuristicSignWithBuiltinAtom() { + assertThrows(IllegalArgumentException.class, () -> + parser.parse("holds(F,T) :- fluent(F), time(T), TM T > 0, lasttime(LT), not not_holds(F,T). " + + "#heuristic holds(F,T) : fluent(F), time(T), T > 0, lasttime(LT), not F holds(F,T), holds(F,Tp1), Tp1=T+1, LTp1mT=LT+1-T. [LTp1mT@1]")); + } + + @Test + public void parseProgramWithHeuristicDirective_EmptyCondition() { + InputProgram parsedProgram = parser.parse("a(1)." + + "{ b(N) } :- a(N)." + + "#heuristic b(1). [1@2]"); + HeuristicDirective directive = getFirstHeuristicDirective(parsedProgram); + assertTrue(directive.getBody().getBodyAtomsPositive().isEmpty()); + assertTrue(directive.getBody().getBodyAtomsNegative().isEmpty()); + } + + @Test + public void parseProgramWithHeuristicDirective_HeadDefaultSign() { + InputProgram parsedProgram = parser.parse("c(X) :- p(X,a,_), q(Xaa,xaa). " + + "#heuristic c(X) : p(X,a,_), q(Xaa,xaa), not c(X)."); + + HeuristicDirective directive = getFirstHeuristicDirective(parsedProgram); + assertEquals(asSet(TRUE), directive.getHead().getSigns()); + } + + @Test + public void parseProgramWithHeuristicDirective_HeadTSign() { + InputProgram parsedProgram = parser.parse("c(X) :- p(X,a,_), q(Xaa,xaa). " + + "#heuristic T c(X) : p(X,a,_), q(Xaa,xaa), not c(X)."); + + HeuristicDirective directive = getFirstHeuristicDirective(parsedProgram); + assertEquals(asSet(TRUE), directive.getHead().getSigns()); + } + + @Test + public void parseProgramWithHeuristicDirective_HeadFSign() { + InputProgram parsedProgram = parser.parse("c(X) :- p(X,a,_), q(Xaa,xaa). " + + "#heuristic F c(X) : p(X,a,_), q(Xaa,xaa), not c(X)."); + + HeuristicDirective directive = getFirstHeuristicDirective(parsedProgram); + assertEquals(asSet(FALSE), directive.getHead().getSigns()); + } + + @Test + public void parseProgramWithHeuristicDirective_HeadMSign() { + assertThrows(IllegalArgumentException.class, () -> + parser.parse("c(X) :- p(X,a,_), q(Xaa,xaa). " + + "#heuristic M c(X) : p(X,a,_), q(Xaa,xaa), not c(X).")); + } + + @Test + public void parseProgramWithHeuristicDirective_HeadMultipleSigns() { + assertThrows(IllegalArgumentException.class, () -> + parser.parse("c(X) :- p(X,a,_), q(Xaa,xaa). " + + "#heuristic TF c(X) : p(X,a,_), q(Xaa,xaa), not c(X).")); + } + + @Test + public void parseProgramWithHeuristicDirective_MultipleBodySignsWithSpaces() { + InputProgram parsedProgram = parser.parse("c(X) :- p(X,a,_), q(Xaa,xaa). " + + "#heuristic c(X) : T F p(X,a,_), not c(X)."); + + HeuristicDirective directive = getFirstHeuristicDirective(parsedProgram); + assertEquals(asSet(TRUE, FALSE), directive.getBody().getBodyAtomsPositive().iterator().next().getSigns()); + } + + @Test + public void parseProgramWithHeuristicDirective_MultipleBodySignsWithoutSpaces() { + InputProgram parsedProgram = parser.parse("c(X) :- p(X,a,_), q(Xaa,xaa). " + + "#heuristic c(X) : TM p(X,a,_), not c(X)."); + + HeuristicDirective directive = getFirstHeuristicDirective(parsedProgram); + assertEquals(asSet(TRUE, MBT), directive.getBody().getBodyAtomsPositive().iterator().next().getSigns()); + } + + @Test + @Disabled("Currently, Rule#isSafe does nothing") + public void parseProgramWithHeuristicDirective_GeneratorWithArithmetics_Unsafe1() { + assertThrows(RuntimeException.class, () -> + parseProgramAndTransformHeuristicDirectives("holds(F,T) :- fluent(F), time(T), T > 0, lasttime(LT), not not_holds(F,T). " + + "#heuristic holds(F,T) : fluent(F), time(T), T > 0, lasttime(LT), not not_holds(F,T), holds(F,Tp1), Tp1=T+1, LTp1mT=LT+1-T. [T2@1]")); + } + + @Test + @Disabled("Currently, Rule#isSafe does nothing") + public void parseProgramWithHeuristicDirective_GeneratorWithArithmetics_Unsafe2() { + assertThrows(RuntimeException.class, () -> + parseProgramAndTransformHeuristicDirectives("holds(F,T) :- fluent(F), time(T), T > 0, lasttime(LT), not not_holds(F,T). " + + "#heuristic holds(F,T) : fluent(F), time(T), T > 0, lasttime(LT), not not_holds(F,T), holds(F,T2), Tp1=T+1, LTp1mT=LT+1-T. [LTp1mT@1]")); + } + + @Test + @Disabled("Currently, Rule#isSafe does nothing") + public void parseProgramWithHeuristicDirective_GeneratorWithArithmetics_Unsafe3() { + assertThrows(RuntimeException.class, () -> + parseProgramAndTransformHeuristicDirectives("holds(F,T) :- fluent(F), time(T), T > 0, lasttime(LT), not not_holds(F,T). " + + "#heuristic holds(F,T) : fluent(F), time(T), T > 0, lasttime(LT), not not_holds(F,T), holds(F,Tp1), Tp1=T2+1, LTp1mT=LT+1-T. [LTp1mT@1]")); + } + + private void parseProgramAndTransformHeuristicDirectives(String input) { + InputProgram program = parser.parse(input); + new HeuristicDirectiveToRule(heuristicsConfiguration).apply(program); // without transforming it to a rule, the safety of a heuristic directive is not checked currently + } + + private static HeuristicDirective getFirstHeuristicDirective(InputProgram parsedProgram) { + return (HeuristicDirective) parsedProgram.getInlineDirectives().getDirectives().iterator().next(); + } @Test public void stringWithEscapedQuotes() throws IOException { CharStream stream = CharStreams.fromStream(ParserTest.class.getResourceAsStream("/escaped_quotes.asp")); diff --git a/src/test/java/at/ac/tuwien/kr/alpha/common/NoGoodTest.java b/src/test/java/at/ac/tuwien/kr/alpha/common/NoGoodTest.java index 89247245f..03fabb540 100644 --- a/src/test/java/at/ac/tuwien/kr/alpha/common/NoGoodTest.java +++ b/src/test/java/at/ac/tuwien/kr/alpha/common/NoGoodTest.java @@ -1,3 +1,30 @@ +/** + * Copyright (c) 2016-2019, the Alpha Team. + * All rights reserved. + * + * Additional changes made by Siemens. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package at.ac.tuwien.kr.alpha.common; import static at.ac.tuwien.kr.alpha.common.Literals.atomToLiteral; @@ -74,13 +101,13 @@ public void compareToLexicographicBig() { @Test public void deleteDuplicates() { - NoGood ng = NoGood.headFirst(fromOldLiterals(-3, 1, -2, -2)); + NoGood ng = NoGoodCreator.headFirst(fromOldLiterals(-3, 1, -2, -2)); assertEquals(3, ng.size(), "Duplicate entry must be removed."); assertEquals(fromOldLiterals(-3), ng.getLiteral(0)); assertEquals(fromOldLiterals(1), ng.getLiteral(1)); assertEquals(fromOldLiterals(-2), ng.getLiteral(2)); - NoGood ng2 = NoGood.headFirst(fromOldLiterals(-2, 3, 3, -6, -1, 5, 5, -6, 7)); + NoGood ng2 = NoGoodCreator.headFirst(fromOldLiterals(-2, 3, 3, -6, -1, 5, 5, -6, 7)); assertEquals(6, ng2.size(), "Duplicate entries must be removed."); assertEquals(fromOldLiterals(-2), ng2.getLiteral(0)); assertEquals(fromOldLiterals(-1), ng2.getLiteral(1)); @@ -89,7 +116,7 @@ public void deleteDuplicates() { assertEquals(fromOldLiterals(-6), ng2.getLiteral(4)); assertEquals(fromOldLiterals(7), ng2.getLiteral(5)); - NoGood ng3 = NoGood.headFirst(fromOldLiterals(-1, 2, -3, -4)); + NoGood ng3 = NoGoodCreator.headFirst(fromOldLiterals(-1, 2, -3, -4)); assertEquals(4, ng3.size(), "NoGood contains no duplicates, size must stay the same."); assertEquals(fromOldLiterals(-1), ng3.getLiteral(0)); assertEquals(fromOldLiterals(2), ng3.getLiteral(1)); @@ -100,9 +127,9 @@ public void deleteDuplicates() { @Test public void noGoodsInHashMap() { - NoGood ng1 = NoGood.headFirst(-1, 2, -3, -4); - NoGood ng2 = NoGood.headFirst(-1, 2, -4); - NoGood ng3 = NoGood.headFirst(-1, 2, -3, -4); + NoGood ng1 = NoGoodCreator.headFirst(-1, 2, -3, -4); + NoGood ng2 = NoGoodCreator.headFirst(-1, 2, -4); + NoGood ng3 = NoGoodCreator.headFirst(-1, 2, -3, -4); Map noGoodIdentifiers = new LinkedHashMap<>(); noGoodIdentifiers.put(ng1, 1); noGoodIdentifiers.put(ng1, 2); diff --git a/src/test/java/at/ac/tuwien/kr/alpha/common/ProgramTest.java b/src/test/java/at/ac/tuwien/kr/alpha/common/ProgramTest.java index 37a6fecad..a674822d8 100644 --- a/src/test/java/at/ac/tuwien/kr/alpha/common/ProgramTest.java +++ b/src/test/java/at/ac/tuwien/kr/alpha/common/ProgramTest.java @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2017 Siemens AG +/* + * Copyright (c) 2017-2020 Siemens AG * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -25,25 +25,61 @@ */ package at.ac.tuwien.kr.alpha.common; -import static org.junit.jupiter.api.Assertions.assertEquals; - import org.junit.jupiter.api.Test; import at.ac.tuwien.kr.alpha.common.program.InputProgram; +import at.ac.tuwien.kr.alpha.common.terms.ConstantTerm; import at.ac.tuwien.kr.alpha.grounder.parser.ProgramParser; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class ProgramTest { - + + public static final String LS = System.lineSeparator(); + @Test public void testToString() { InputProgram parsedProgram = new ProgramParser().parse( - "p(a)." + System.lineSeparator() + - "q(X) :- p(X)." + System.lineSeparator() + + "#heuristic q(X) : p(X). [X@2]" + LS + + "p(a)." + LS + + "q(X) :- p(X)." + LS + "p(b)."); assertEquals( - "p(a)." + System.lineSeparator() + - "p(b)." + System.lineSeparator() + - "q(X) :- p(X)." + System.lineSeparator(), + "p(a)." + LS + + "p(b)." + LS + + "q(X) :- p(X)." + LS + + "#heuristic T q(X) : TM p(X). [X@2]" + LS, parsedProgram.toString()); } + + @Test + public void testHeuristicDefaultWeight() { + InputProgram parsedProgram = new ProgramParser().parse( + "#heuristic q(X) : p(X)."); + assertEquals(ConstantTerm.getInstance(0), ((HeuristicDirective)parsedProgram.getInlineDirectives().getDirectives().iterator().next()).getWeightAtLevel().getWeight()); + } + + @Test + public void testHeuristicDefaultLevel() { + InputProgram parsedProgram = new ProgramParser().parse( + "#heuristic q(X) : p(X)."); + assertEquals(ConstantTerm.getInstance(0), ((HeuristicDirective)parsedProgram.getInlineDirectives().getDirectives().iterator().next()).getWeightAtLevel().getLevel()); + } + + @Test + public void testAccumulation() { + InputProgram program1 = new ProgramParser().parse( + "a." + LS + + "b :- a, not c." + LS + + "#heuristic b : not c. [1@2]" + ); + InputProgram program2 = new ProgramParser().parse( + "c :- a, not b." + LS + + "#heuristic c : not b. [2@3]" + ); + program1 = InputProgram.builder(program1).accumulate(program2).build(); + assertEquals(1, program1.getFacts().size()); + assertEquals(2, program1.getRules().size()); + assertEquals(2, program1.getInlineDirectives().getDirectives().size()); + } } \ No newline at end of file diff --git a/src/test/java/at/ac/tuwien/kr/alpha/common/UniqueVariableNamesTest.java b/src/test/java/at/ac/tuwien/kr/alpha/common/UniqueVariableNamesTest.java new file mode 100644 index 000000000..56d0327b1 --- /dev/null +++ b/src/test/java/at/ac/tuwien/kr/alpha/common/UniqueVariableNamesTest.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2022 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.common; + +import org.junit.jupiter.api.Test; + +import at.ac.tuwien.kr.alpha.common.rule.BasicRule; +import at.ac.tuwien.kr.alpha.common.terms.VariableTerm; +import at.ac.tuwien.kr.alpha.grounder.Unifier; +import at.ac.tuwien.kr.alpha.grounder.parser.ProgramPartParser; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * Tests {@link UniqueVariableNames}. + */ +public class UniqueVariableNamesTest { + + private final ProgramPartParser programPartParser = new ProgramPartParser(); + + @Test + public void testHeuristicDirectiveAndRule() { + final HeuristicDirective heuristicDirective = programPartParser.parseHeuristicDirective("#heuristic h(X,Y) : b1(X), b2(Y), b3(Z)."); + final BasicRule rule = programPartParser.parseBasicRule("h(Y,Z) :- b1(Y), b2(Z), b3(X)."); + final UniqueVariableNames uniqueVariableNames = new UniqueVariableNames(); + final Unifier actualUnifier = uniqueVariableNames.makeVariableNamesUnique(heuristicDirective, rule); + final Unifier expectedUnifier = new Unifier(); + expectedUnifier.put(VariableTerm.getInstance("X"), VariableTerm.getInstance("X_1")); + expectedUnifier.put(VariableTerm.getInstance("Y"), VariableTerm.getInstance("Y_1")); + expectedUnifier.put(VariableTerm.getInstance("Z"), VariableTerm.getInstance("Z_1")); + assertEquals(expectedUnifier, actualUnifier); + } + +} diff --git a/src/test/java/at/ac/tuwien/kr/alpha/common/heuristics/ElementsOfHeuristicDirectivesTest.java b/src/test/java/at/ac/tuwien/kr/alpha/common/heuristics/ElementsOfHeuristicDirectivesTest.java new file mode 100644 index 000000000..ce953ecee --- /dev/null +++ b/src/test/java/at/ac/tuwien/kr/alpha/common/heuristics/ElementsOfHeuristicDirectivesTest.java @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2020 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +package at.ac.tuwien.kr.alpha.common.heuristics; + +import org.junit.jupiter.api.Test; + +import java.util.Arrays; +import java.util.Collections; + +import at.ac.tuwien.kr.alpha.common.Predicate; +import at.ac.tuwien.kr.alpha.common.atoms.BasicAtom; + +import static at.ac.tuwien.kr.alpha.Util.asSet; +import static at.ac.tuwien.kr.alpha.solver.ThriceTruth.FALSE; +import static at.ac.tuwien.kr.alpha.solver.ThriceTruth.MBT; +import static at.ac.tuwien.kr.alpha.solver.ThriceTruth.TRUE; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; + +/** + * Tests some properties (e.g., equals(), hashCode(), and toString() implementations) of {@link at.ac.tuwien.kr.alpha.common.HeuristicDirective}, + * {@link HeuristicDirectiveBody}, {@link HeuristicDirectiveLiteral}, and {@link HeuristicDirectiveAtom}. + */ +public class ElementsOfHeuristicDirectivesTest { + + @Test + public void heuristicAtomsWithDifferentSigns() { + final BasicAtom a = new BasicAtom(Predicate.getInstance("a", 0)); + final HeuristicDirectiveAtom atom1 = HeuristicDirectiveAtom.body(asSet(TRUE), a); + final HeuristicDirectiveAtom atom2 = HeuristicDirectiveAtom.body(asSet(TRUE, FALSE), a); + assertNotEquals(atom1, atom2); + assertNotEquals(atom1.hashCode(), atom2.hashCode()); + assertNotEquals(atom1.toString(), atom2.toString()); + assertEquals(2, asSet(atom1, atom2).size()); + } + + @Test + public void heuristicAtomsWithDifferentBasicAtoms() { + final BasicAtom a = new BasicAtom(Predicate.getInstance("a", 0)); + final BasicAtom b = new BasicAtom(Predicate.getInstance("b", 0)); + final HeuristicDirectiveAtom atom1 = HeuristicDirectiveAtom.body(asSet(), a); + final HeuristicDirectiveAtom atom2 = HeuristicDirectiveAtom.body(asSet(), b); + assertNotEquals(atom1, atom2); + assertNotEquals(atom1.hashCode(), atom2.hashCode()); + assertNotEquals(atom1.toString(), atom2.toString()); + assertEquals(2, asSet(atom1, atom2).size()); + } + + @Test + public void equalHeuristicAtoms() { + final BasicAtom a = new BasicAtom(Predicate.getInstance("a", 0)); + final HeuristicDirectiveAtom atom1 = HeuristicDirectiveAtom.body(asSet(MBT, TRUE), a); + final HeuristicDirectiveAtom atom2 = HeuristicDirectiveAtom.body(asSet(MBT, TRUE), a); + assertEquals(atom1, atom2); + assertEquals(atom1.hashCode(), atom2.hashCode()); + assertEquals(atom1.toString(), atom2.toString()); + assertEquals(1, asSet(atom1, atom2).size()); + } + + @Test + public void heuristicLiteralsWithDifferentSigns() { + final BasicAtom a = new BasicAtom(Predicate.getInstance("a", 0)); + final HeuristicDirectiveLiteral literal1 = new HeuristicDirectiveLiteral(HeuristicDirectiveAtom.body(asSet(TRUE), a), true); + final HeuristicDirectiveLiteral literal2 = new HeuristicDirectiveLiteral(HeuristicDirectiveAtom.body(asSet(TRUE, FALSE), a), true); + assertNotEquals(literal1, literal2); + assertNotEquals(literal1.hashCode(), literal2.hashCode()); + assertNotEquals(literal1.toString(), literal2.toString()); + assertEquals(2, asSet(literal1, literal2).size()); + } + + @Test + public void heuristicLiteralsWithDifferentBasicAtoms() { + final BasicAtom a = new BasicAtom(Predicate.getInstance("a", 0)); + final BasicAtom b = new BasicAtom(Predicate.getInstance("b", 0)); + final HeuristicDirectiveLiteral literal1 = new HeuristicDirectiveLiteral(HeuristicDirectiveAtom.body(asSet(), a), false); + final HeuristicDirectiveLiteral literal2 = new HeuristicDirectiveLiteral(HeuristicDirectiveAtom.body(asSet(), b), false); + assertNotEquals(literal1, literal2); + assertNotEquals(literal1.hashCode(), literal2.hashCode()); + assertNotEquals(literal1.toString(), literal2.toString()); + assertEquals(2, asSet(literal1, literal2).size()); + } + + @Test + public void heuristicLiteralsWithDifferentNegatedness() { + final BasicAtom a = new BasicAtom(Predicate.getInstance("a", 0)); + final HeuristicDirectiveLiteral literal1 = new HeuristicDirectiveLiteral(HeuristicDirectiveAtom.body(asSet(MBT, TRUE), a), false); + final HeuristicDirectiveLiteral literal2 = new HeuristicDirectiveLiteral(HeuristicDirectiveAtom.body(asSet(MBT, TRUE), a), true); + assertNotEquals(literal1, literal2); + assertNotEquals(literal1.hashCode(), literal2.hashCode()); + assertNotEquals(literal1.toString(), literal2.toString()); + assertEquals(2, asSet(literal1, literal2).size()); + } + + @Test + public void equalHeuristicLiterals() { + final BasicAtom a = new BasicAtom(Predicate.getInstance("a", 0)); + final HeuristicDirectiveLiteral literal1 = new HeuristicDirectiveLiteral(HeuristicDirectiveAtom.body(asSet(MBT, TRUE), a), false); + final HeuristicDirectiveLiteral literal2 = new HeuristicDirectiveLiteral(HeuristicDirectiveAtom.body(asSet(MBT, TRUE), a), false); + assertEquals(literal1, literal2); + assertEquals(literal1.hashCode(), literal2.hashCode()); + assertEquals(literal1.toString(), literal2.toString()); + assertEquals(1, asSet(literal1, literal2).size()); + } + + @Test + public void heuristicDirectiveBodiesWithDifferentPositiveBodies() { + final BasicAtom a = new BasicAtom(Predicate.getInstance("a", 0)); + final BasicAtom b = new BasicAtom(Predicate.getInstance("b", 0)); + final BasicAtom c = new BasicAtom(Predicate.getInstance("c", 0)); + final HeuristicDirectiveLiteral posLiteral1 = new HeuristicDirectiveLiteral(HeuristicDirectiveAtom.body(asSet(MBT, TRUE), a), true); + final HeuristicDirectiveLiteral posLiteral2 = new HeuristicDirectiveLiteral(HeuristicDirectiveAtom.body(asSet(TRUE), b), true); + final HeuristicDirectiveLiteral negLiteral = new HeuristicDirectiveLiteral(HeuristicDirectiveAtom.body(asSet(FALSE), c), false); + final HeuristicDirectiveBody body1 = new HeuristicDirectiveBody(Arrays.asList(posLiteral1, negLiteral)); + final HeuristicDirectiveBody body2 = new HeuristicDirectiveBody(Arrays.asList(posLiteral1, posLiteral2, negLiteral)); + assertNotEquals(body1, body2); + assertNotEquals(body1.hashCode(), body2.hashCode()); + assertNotEquals(body1.toString(), body2.toString()); + assertEquals(2, asSet(body1, body2).size()); + } + + @Test + public void heuristicDirectiveBodiesWithDifferentNegativeBodies() { + final BasicAtom a = new BasicAtom(Predicate.getInstance("a", 0)); + final BasicAtom b = new BasicAtom(Predicate.getInstance("b", 0)); + final HeuristicDirectiveLiteral posLiteral = new HeuristicDirectiveLiteral(HeuristicDirectiveAtom.body(asSet(MBT, TRUE), a), true); + final HeuristicDirectiveLiteral negLiteral1 = new HeuristicDirectiveLiteral(HeuristicDirectiveAtom.body(asSet(TRUE), b), false); + final HeuristicDirectiveLiteral negLiteral2 = new HeuristicDirectiveLiteral(HeuristicDirectiveAtom.body(asSet(MBT, TRUE), b), false); + final HeuristicDirectiveBody body1 = new HeuristicDirectiveBody(Arrays.asList(posLiteral, negLiteral1)); + final HeuristicDirectiveBody body2 = new HeuristicDirectiveBody(Arrays.asList(posLiteral, negLiteral2)); + assertNotEquals(body1, body2); + assertNotEquals(body1.hashCode(), body2.hashCode()); + assertNotEquals(body1.toString(), body2.toString()); + assertEquals(2, asSet(body1, body2).size()); + } + + @Test + public void equalEmptyHeuristicDirectiveBodies() { + final HeuristicDirectiveBody body1 = new HeuristicDirectiveBody(Collections.emptyList()); + final HeuristicDirectiveBody body2 = new HeuristicDirectiveBody(Collections.emptyList()); + assertEquals(body1, body2); + assertEquals(body1.hashCode(), body2.hashCode()); + assertEquals(body1.toString(), body2.toString()); + assertEquals(1, asSet(body1, body2).size()); + } + + @Test + public void equalNonEmptyHeuristicDirectiveBodies() { + final BasicAtom a = new BasicAtom(Predicate.getInstance("a", 0)); + final HeuristicDirectiveLiteral posLiteral = new HeuristicDirectiveLiteral(HeuristicDirectiveAtom.body(asSet(MBT), a), true); + final HeuristicDirectiveLiteral negLiteral = new HeuristicDirectiveLiteral(HeuristicDirectiveAtom.body(asSet(TRUE), a), false); + final HeuristicDirectiveBody body1 = new HeuristicDirectiveBody(Arrays.asList(posLiteral, negLiteral)); + final HeuristicDirectiveBody body2 = new HeuristicDirectiveBody(Arrays.asList(posLiteral, negLiteral)); + assertEquals(body1, body2); + assertEquals(body1.hashCode(), body2.hashCode()); + assertEquals(body1.toString(), body2.toString()); + assertEquals(1, asSet(body1, body2).size()); + } +} diff --git a/src/test/java/at/ac/tuwien/kr/alpha/common/heuristics/HeuristicDirectiveValuesTest.java b/src/test/java/at/ac/tuwien/kr/alpha/common/heuristics/HeuristicDirectiveValuesTest.java new file mode 100644 index 000000000..14d41a4f3 --- /dev/null +++ b/src/test/java/at/ac/tuwien/kr/alpha/common/heuristics/HeuristicDirectiveValuesTest.java @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2019-2021 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.common.heuristics; + +import org.junit.jupiter.api.Test; + +import at.ac.tuwien.kr.alpha.common.Predicate; +import at.ac.tuwien.kr.alpha.common.atoms.BasicAtom; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; + +/** + * Tests {@link HeuristicDirectiveValues} + */ +public class HeuristicDirectiveValuesTest { + + @Test + public void testToString_positive() { + final int headAtomId = 2; + final int weight = 5; + final int level = 3; + HeuristicDirectiveValues values = new HeuristicDirectiveValues(headAtomId, new BasicAtom(Predicate.getInstance("a", 0)), weight, level, true); + assertEquals(String.format("T %d [%d@%d]", headAtomId, weight, level), values.toString()); + } + + @Test + public void testToString_negative() { + final int headAtomId = 26; + final int weight = 2; + final int level = 4; + HeuristicDirectiveValues values = new HeuristicDirectiveValues(headAtomId, new BasicAtom(Predicate.getInstance("a", 0)), weight, level, false); + assertEquals(String.format("F %d [%d@%d]", headAtomId, weight, level), values.toString()); + } + + @Test + public void testEquals() { + final int headAtomId = 2; + final int weight = 5; + final int level = 3; + HeuristicDirectiveValues values1 = new HeuristicDirectiveValues(headAtomId, new BasicAtom(Predicate.getInstance("a", 0)), weight, level, true); + HeuristicDirectiveValues values2 = new HeuristicDirectiveValues(headAtomId, new BasicAtom(Predicate.getInstance("a", 0)), weight, level, true); + assertEquals(values1, values2); + assertEquals(values1.hashCode(), values2.hashCode()); + } + + @Test + public void testNotEquals_weight() { + final int headAtomId = 2; + final int weight1 = 5; + final int weight2 = 6; + final int level = 3; + HeuristicDirectiveValues values1 = new HeuristicDirectiveValues(headAtomId, new BasicAtom(Predicate.getInstance("a", 0)), weight1, level, true); + HeuristicDirectiveValues values2 = new HeuristicDirectiveValues(headAtomId, new BasicAtom(Predicate.getInstance("a", 0)), weight2, level, true); + assertNotEquals(values1, values2); + assertNotEquals(values1.hashCode(), values2.hashCode()); + } + + @Test + public void testNotEquals_level() { + final int headAtomId = 2; + final int weight = 5; + final int level1 = 3; + final int level2 = 2; + HeuristicDirectiveValues values1 = new HeuristicDirectiveValues(headAtomId, new BasicAtom(Predicate.getInstance("a", 0)), weight, level1, true); + HeuristicDirectiveValues values2 = new HeuristicDirectiveValues(headAtomId, new BasicAtom(Predicate.getInstance("a", 0)), weight, level2, true); + assertNotEquals(values1, values2); + assertNotEquals(values1.hashCode(), values2.hashCode()); + } + + @Test + public void testNotEquals_headAtomId() { + final int headAtomId1 = 2; + final int headAtomId2 = 27; + final int weight = 5; + final int level = 3; + HeuristicDirectiveValues values1 = new HeuristicDirectiveValues(headAtomId1, new BasicAtom(Predicate.getInstance("a", 0)), weight, level, true); + HeuristicDirectiveValues values2 = new HeuristicDirectiveValues(headAtomId2, new BasicAtom(Predicate.getInstance("a", 0)), weight, level, true); + assertNotEquals(values1, values2); + assertNotEquals(values1.hashCode(), values2.hashCode()); + } + + @Test + public void testNotEquals_sign() { + final int headAtomId = 2; + final int weight = 5; + final int level = 3; + HeuristicDirectiveValues values1 = new HeuristicDirectiveValues(headAtomId, new BasicAtom(Predicate.getInstance("a", 0)), weight, level, true); + HeuristicDirectiveValues values2 = new HeuristicDirectiveValues(headAtomId, new BasicAtom(Predicate.getInstance("a", 0)), weight, level, false); + assertNotEquals(values1, values2); + assertNotEquals(values1.hashCode(), values2.hashCode()); + } + + @Test + public void testNotEquals_null() { + final int headAtomId = 2; + final int weight = 5; + final int level = 3; + HeuristicDirectiveValues values1 = new HeuristicDirectiveValues(headAtomId, new BasicAtom(Predicate.getInstance("a", 0)), weight, level, true); + HeuristicDirectiveValues values2 = null; + assertNotEquals(values1, values2); + } +} diff --git a/src/test/java/at/ac/tuwien/kr/alpha/common/heuristics/PriorityComparatorTest.java b/src/test/java/at/ac/tuwien/kr/alpha/common/heuristics/PriorityComparatorTest.java new file mode 100644 index 000000000..7d7d8efe8 --- /dev/null +++ b/src/test/java/at/ac/tuwien/kr/alpha/common/heuristics/PriorityComparatorTest.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2019-2021 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.common.heuristics; + +import org.junit.jupiter.api.Test; + +import at.ac.tuwien.kr.alpha.common.Predicate; +import at.ac.tuwien.kr.alpha.common.atoms.BasicAtom; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * Tests {@link HeuristicDirectiveValues.PriorityComparator}. + */ +public class PriorityComparatorTest { + + private final HeuristicDirectiveValues.PriorityComparator comparator = new HeuristicDirectiveValues.PriorityComparator(); + + @Test + public void testAllEqual() { + final BasicAtom headAtom = new BasicAtom(Predicate.getInstance("a", 0)); + final int headAtomId = 1; + final int weight = 10; + final int level = 5; + final boolean sign = true; + HeuristicDirectiveValues v1 = new HeuristicDirectiveValues(headAtomId, headAtom, weight, level, sign); + HeuristicDirectiveValues v2 = new HeuristicDirectiveValues(headAtomId, headAtom, weight, level, sign); + assertEquals(0, comparator.compare(v1, v2)); + assertEquals(0, comparator.compare(v2, v1)); + } + + @Test + public void testDifferentWeight() { + final BasicAtom headAtom = new BasicAtom(Predicate.getInstance("a", 0)); + final int headAtomId = 1; + final int weight1 = 10; + final int weight2 = 11; + final int level = 5; + final boolean sign = true; + HeuristicDirectiveValues v1 = new HeuristicDirectiveValues(headAtomId, headAtom, weight1, level, sign); + HeuristicDirectiveValues v2 = new HeuristicDirectiveValues(headAtomId, headAtom, weight2, level, sign); + assertTrue(comparator.compare(v1, v2) < 0); + assertTrue(comparator.compare(v2, v1) > 0); + } + + @Test + public void testDifferentLevel() { + final BasicAtom headAtom = new BasicAtom(Predicate.getInstance("a", 0)); + final int headAtomId = 1; + final int weight = 10; + final int level1 = 5; + final int level2 = 10; + final boolean sign = true; + HeuristicDirectiveValues v1 = new HeuristicDirectiveValues(headAtomId, headAtom, weight, level1, sign); + HeuristicDirectiveValues v2 = new HeuristicDirectiveValues(headAtomId, headAtom, weight, level2, sign); + assertTrue(comparator.compare(v1, v2) < 0); + assertTrue(comparator.compare(v2, v1) > 0); + } + + @Test + public void testDifferentSign() { + final BasicAtom headAtom = new BasicAtom(Predicate.getInstance("a", 0)); + final int headAtomId = 1; + final int weight = 10; + final int level = 5; + final boolean sign1 = false; + final boolean sign2 = true; + HeuristicDirectiveValues v1 = new HeuristicDirectiveValues(headAtomId, headAtom, weight, level, sign1); + HeuristicDirectiveValues v2 = new HeuristicDirectiveValues(headAtomId, headAtom, weight, level, sign2); + assertTrue(comparator.compare(v1, v2) < 0); + assertTrue(comparator.compare(v2, v1) > 0); + } + + @Test + public void testDifferentHeadAtomId() { + final BasicAtom headAtom1 = new BasicAtom(Predicate.getInstance("a", 0)); + final BasicAtom headAtom2 = new BasicAtom(Predicate.getInstance("b", 0)); + final int headAtomId1 = 1; + final int headAtomId2 = 2; + final int weight = 10; + final int level = 5; + final boolean sign = true; + HeuristicDirectiveValues v1 = new HeuristicDirectiveValues(headAtomId1, headAtom1, weight, level, sign); + HeuristicDirectiveValues v2 = new HeuristicDirectiveValues(headAtomId2, headAtom2, weight, level, sign); + assertTrue(comparator.compare(v1, v2) < 0); + assertTrue(comparator.compare(v2, v1) > 0); + } + +} diff --git a/src/test/java/at/ac/tuwien/kr/alpha/config/CommandLineParserTest.java b/src/test/java/at/ac/tuwien/kr/alpha/config/CommandLineParserTest.java index 5761660ca..6da1c9758 100644 --- a/src/test/java/at/ac/tuwien/kr/alpha/config/CommandLineParserTest.java +++ b/src/test/java/at/ac/tuwien/kr/alpha/config/CommandLineParserTest.java @@ -53,23 +53,23 @@ public class CommandLineParserTest { @Test public void help() throws ParseException { StringBuilder bld = new StringBuilder(); - CommandLineParser parser = new CommandLineParser(DEFAULT_COMMAND_LINE, (msg) -> bld.append(msg)); + CommandLineParser parser = new CommandLineParser(DEFAULT_COMMAND_LINE, bld::append); parser.parseCommandLine(new String[] {"-h"}); - assertTrue(!(bld.toString().isEmpty())); + assertFalse(bld.toString().isEmpty()); } @Test public void basicUsageWithFile() throws ParseException { CommandLineParser parser = new CommandLineParser(DEFAULT_COMMAND_LINE, DEFAULT_ABORT_ACTION); AlphaConfig ctx = parser.parseCommandLine(new String[] {"-i", "someFile.asp", "-i", "someOtherFile.asp"}); - assertEquals(Arrays.asList(new String[] {"someFile.asp", "someOtherFile.asp"}), ctx.getInputConfig().getFiles()); + assertEquals(Arrays.asList("someFile.asp", "someOtherFile.asp"), ctx.getInputConfig().getFiles()); } @Test public void basicUsageWithString() throws ParseException { CommandLineParser parser = new CommandLineParser(DEFAULT_COMMAND_LINE, DEFAULT_ABORT_ACTION); AlphaConfig ctx = parser.parseCommandLine(new String[] {"-str", "b :- a.", "-str", "c :- a, b."}); - assertEquals(Arrays.asList(new String[] {"b :- a.", "c :- a, b."}), ctx.getInputConfig().getAspStrings()); + assertEquals(Arrays.asList("b :- a.", "c :- a, b."), ctx.getInputConfig().getAspStrings()); } @Test @@ -180,4 +180,11 @@ public void atomSeparator() throws ParseException { assertEquals("some-string", cfg.getSystemConfig().getAtomSeparator()); } + @Test + public void ignoreDomspecHeuristics() throws ParseException { + CommandLineParser parser = new CommandLineParser(DEFAULT_COMMAND_LINE, DEFAULT_ABORT_ACTION); + AlphaConfig alphaConfig = parser.parseCommandLine(new String[]{"-str", "aString.", "-ids"}); + assertTrue(alphaConfig.getSystemConfig().isIgnoreDomspecHeuristics()); + } + } diff --git a/src/test/java/at/ac/tuwien/kr/alpha/grounder/ChoiceGrounder.java b/src/test/java/at/ac/tuwien/kr/alpha/grounder/ChoiceGrounder.java index e090fec20..b7fcb9fd9 100644 --- a/src/test/java/at/ac/tuwien/kr/alpha/grounder/ChoiceGrounder.java +++ b/src/test/java/at/ac/tuwien/kr/alpha/grounder/ChoiceGrounder.java @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2016-2019, the Alpha Team. +/* + * Copyright (c) 2016-2020, the Alpha Team. * All rights reserved. * * Additional changes made by Siemens. @@ -37,6 +37,7 @@ import at.ac.tuwien.kr.alpha.common.Predicate; import at.ac.tuwien.kr.alpha.common.atoms.Atom; import at.ac.tuwien.kr.alpha.common.atoms.BasicAtom; +import at.ac.tuwien.kr.alpha.common.heuristics.HeuristicDirectiveValues; import at.ac.tuwien.kr.alpha.common.rule.BasicRule; import at.ac.tuwien.kr.alpha.common.rule.InternalRule; import at.ac.tuwien.kr.alpha.common.rule.NormalRule; @@ -58,7 +59,7 @@ import static at.ac.tuwien.kr.alpha.Util.entriesToMap; import static at.ac.tuwien.kr.alpha.Util.entry; -import static at.ac.tuwien.kr.alpha.common.NoGood.headFirst; +import static at.ac.tuwien.kr.alpha.common.NoGoodCreator.headFirst; import static at.ac.tuwien.kr.alpha.common.NoGoodTest.fromOldLiterals; import static java.util.Arrays.asList; import static java.util.Collections.singleton; @@ -182,7 +183,17 @@ public Pair, Map> getChoiceAtoms() { return new ImmutablePair<>(new HashMap<>(), new HashMap<>()); } } - + + @Override + public Pair, Map> getHeuristicAtoms() { + return new ImmutablePair<>(Collections.emptyMap(), Collections.emptyMap()); + } + + @Override + public Map getHeuristicValues() { + return Collections.emptyMap(); + } + @Override public Map> getHeadsToBodies() { return Collections.emptyMap(); @@ -207,4 +218,9 @@ public int register(NoGood noGood) { } return solverDerivedNoGoods.get(noGood); } + + @Override + public AtomStore getAtomStore() { + return null; + } } diff --git a/src/test/java/at/ac/tuwien/kr/alpha/grounder/DummyGrounder.java b/src/test/java/at/ac/tuwien/kr/alpha/grounder/DummyGrounder.java index 4ab84e0b2..459648775 100644 --- a/src/test/java/at/ac/tuwien/kr/alpha/grounder/DummyGrounder.java +++ b/src/test/java/at/ac/tuwien/kr/alpha/grounder/DummyGrounder.java @@ -1,19 +1,19 @@ -/** - * Copyright (c) 2016-2019, the Alpha Team. +/* + * Copyright (c) 2016-2020, the Alpha Team. * All rights reserved. - * + * * Additional changes made by Siemens. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1) Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. - * + * * 2) Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -41,6 +41,7 @@ import at.ac.tuwien.kr.alpha.common.rule.InternalRule; import at.ac.tuwien.kr.alpha.common.rule.NormalRule; import at.ac.tuwien.kr.alpha.common.rule.head.NormalHead; +import at.ac.tuwien.kr.alpha.common.heuristics.HeuristicDirectiveValues; import at.ac.tuwien.kr.alpha.grounder.atoms.RuleAtom; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; @@ -57,7 +58,7 @@ import static at.ac.tuwien.kr.alpha.Util.entriesToMap; import static at.ac.tuwien.kr.alpha.Util.entry; -import static at.ac.tuwien.kr.alpha.common.NoGood.headFirst; +import static at.ac.tuwien.kr.alpha.common.NoGoodCreator.headFirst; import static at.ac.tuwien.kr.alpha.common.NoGoodTest.fromOldLiterals; import static java.util.Collections.singleton; import static java.util.Collections.singletonList; @@ -122,6 +123,11 @@ public int register(NoGood noGood) { return solverDerivedNoGoods.get(noGood); } + @Override + public AtomStore getAtomStore() { + return null; + } + @Override public AnswerSet assignmentToAnswerSet(Iterable trueAtoms) { // Note: This grounder only deals with 0-ary predicates, i.e., every atom is a predicate and there is @@ -167,7 +173,17 @@ public Map getNoGoods(Assignment assignment) { public Pair, Map> getChoiceAtoms() { return new ImmutablePair<>(new HashMap<>(), new HashMap<>()); } - + + @Override + public Pair, Map> getHeuristicAtoms() { + return new ImmutablePair<>(Collections.emptyMap(), Collections.emptyMap()); + } + + @Override + public Map getHeuristicValues() { + return Collections.emptyMap(); + } + @Override public Map> getHeadsToBodies() { return Collections.emptyMap(); diff --git a/src/test/java/at/ac/tuwien/kr/alpha/grounder/GroundingOfHeuristicsTest.java b/src/test/java/at/ac/tuwien/kr/alpha/grounder/GroundingOfHeuristicsTest.java new file mode 100644 index 000000000..b1d75a271 --- /dev/null +++ b/src/test/java/at/ac/tuwien/kr/alpha/grounder/GroundingOfHeuristicsTest.java @@ -0,0 +1,282 @@ +/* + * Copyright (c) 2018-2021, the Alpha Team. + * All rights reserved. + * + * Additional changes made by Siemens. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.grounder; + +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import at.ac.tuwien.kr.alpha.api.Alpha; +import at.ac.tuwien.kr.alpha.common.AtomStore; +import at.ac.tuwien.kr.alpha.common.AtomStoreImpl; +import at.ac.tuwien.kr.alpha.common.NoGood; +import at.ac.tuwien.kr.alpha.common.program.InputProgram; +import at.ac.tuwien.kr.alpha.common.program.InternalProgram; +import at.ac.tuwien.kr.alpha.common.program.NormalProgram; +import at.ac.tuwien.kr.alpha.common.rule.InternalRule; +import at.ac.tuwien.kr.alpha.grounder.atoms.HeuristicAtom; +import at.ac.tuwien.kr.alpha.grounder.parser.ProgramParser; +import at.ac.tuwien.kr.alpha.solver.heuristics.HeuristicsConfiguration; +import at.ac.tuwien.kr.alpha.solver.heuristics.HeuristicsConfigurationBuilder; + +import static at.ac.tuwien.kr.alpha.Util.asSet; +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * Tests {@link NaiveGrounder} as it grounds heuristic rules. + */ +public class GroundingOfHeuristicsTest { + private static final ProgramParser PROGRAM_PARSER = new ProgramParser(); + private final HeuristicsConfiguration heuristicsConfiguration = new HeuristicsConfigurationBuilder().setRespectDomspecHeuristics(true).build(); + + @BeforeEach + public void resetIdGenerator() { + ChoiceRecorder.ID_GENERATOR.resetGenerator(); + } + + @BeforeEach + public void resetRuleIdGenerator() { + InternalRule.resetIdGenerator(); + } + + @Test + public void testGenerateHeuristicNoGoods_GeneralCase() { + final InputProgram inputProgram = PROGRAM_PARSER.parse("{ a(0); a(1); a(2); a(3); a(4); a(5) }." + + "{ b(N) } :- a(N)." + + "#heuristic b(1) : T a(0), MT a(1), F a(2), not T a(3), not MT a(4), not F a(5). [3@2]"); + final Set expectedNoGoodsToString = asSet( + "*{-(HeuOn(\"0\", \"t\")), +(a(1)), +(a(0))}", + "*{-(HeuOn(\"0\", \"tm\")), +(a(1))}", + "*{-(HeuOn(\"0\", \"f\")), -(a(2))}", + "*{-(HeuOff(\"0\", \"t\")), +(a(3))}", + "*{-(HeuOff(\"0\", \"tm\")), +(a(4))}", + "*{-(HeuOff(\"0\", \"f\")), -(a(5))}", + "*{-(HeuOff(\"0\", \"tm\")), +(_nb(\"1\", 1))}" + ); + testGenerateHeuristicNoGoods(inputProgram, expectedNoGoodsToString); + } + + @Test + public void testGenerateHeuristicNoGoods_HandlingOfFacts_SkipLiteralPositiveT() { + final InputProgram inputProgram = PROGRAM_PARSER.parse("fact(1). fact(2)." + + "{ guess(N) } :- fact(N)." + + "#heuristic guess(2) : guess(1), T fact(1)."); + final Set expectedNoGoodsToString = asSet( + "*{-(HeuOn(\"0\", \"tm\")), +(guess(1))}", + "*{-(HeuOff(\"0\", \"tm\")), +(_nguess(\"1\", 2))}" + ); + testGenerateHeuristicNoGoods(inputProgram, expectedNoGoodsToString); + } + + @Test + public void testGenerateHeuristicNoGoods_HandlingOfFacts_SkipLiteralPositiveM() { + final InputProgram inputProgram = PROGRAM_PARSER.parse("fact(1). fact(2)." + + "{ guess(N) } :- fact(N)." + + "#heuristic guess(2) : guess(1), T fact(1)."); + final Set expectedNoGoodsToString = asSet( + "*{-(HeuOn(\"0\", \"tm\")), +(guess(1))}", + "*{-(HeuOff(\"0\", \"tm\")), +(_nguess(\"1\", 2))}" + ); + testGenerateHeuristicNoGoods(inputProgram, expectedNoGoodsToString); + } + + @Test + public void testGenerateHeuristicNoGoods_HandlingOfFacts_SkipLiteralPositiveMT() { + final InputProgram inputProgram = PROGRAM_PARSER.parse("fact(1). fact(2)." + + "{ guess(N) } :- fact(N)." + + "#heuristic guess(2) : guess(1), MT fact(1)."); + final Set expectedNoGoodsToString = asSet( + "*{-(HeuOn(\"0\", \"tm\")), +(guess(1))}", + "*{-(HeuOff(\"0\", \"tm\")), +(_nguess(\"1\", 2))}" + ); + testGenerateHeuristicNoGoods(inputProgram, expectedNoGoodsToString); + } + + @Test + public void testGenerateHeuristicNoGoods_HandlingOfFacts_SkipRulePositiveF() { + final InputProgram inputProgram = PROGRAM_PARSER.parse("fact(1). fact(2)." + + "{ guess(N) } :- fact(N)." + + "#heuristic guess(2) : guess(1), F fact(1)."); + final Set expectedNoGoodsToString = Collections.emptySet(); + testGenerateHeuristicNoGoods(inputProgram, expectedNoGoodsToString); + } + + @Test + public void testGenerateHeuristicNoGoods_HandlingOfFacts_SkipRuleNegativeT() { + final InputProgram inputProgram = PROGRAM_PARSER.parse("fact(1). fact(2)." + + "{ guess(N) } :- fact(N)." + + "#heuristic guess(2) : guess(1), not T fact(1)."); + final Set expectedNoGoodsToString = Collections.emptySet(); + testGenerateHeuristicNoGoods(inputProgram, expectedNoGoodsToString); + } + + @Test + public void testGenerateHeuristicNoGoods_HandlingOfFacts_SkipRuleNegativeM() { + final InputProgram inputProgram = PROGRAM_PARSER.parse("fact(1). fact(2)." + + "{ guess(N) } :- fact(N)." + + "#heuristic guess(2) : guess(1), not T fact(1)."); + final Set expectedNoGoodsToString = Collections.emptySet(); + testGenerateHeuristicNoGoods(inputProgram, expectedNoGoodsToString); + } + + @Test + public void testGenerateHeuristicNoGoods_HandlingOfFacts_SkipRuleNegativeTM() { + final InputProgram inputProgram = PROGRAM_PARSER.parse("fact(1). fact(2)." + + "{ guess(N) } :- fact(N)." + + "#heuristic guess(2) : guess(1), not TM fact(1)."); + final Set expectedNoGoodsToString = Collections.emptySet(); + testGenerateHeuristicNoGoods(inputProgram, expectedNoGoodsToString); + } + + @Test + public void testGenerateHeuristicNoGoods_HandlingOfFacts_SkipLiteralNegativeF() { + final InputProgram inputProgram = PROGRAM_PARSER.parse("fact(1). fact(2)." + + "{ guess(N) } :- fact(N)." + + "#heuristic guess(2) : guess(1), not F fact(1)."); + final Set expectedNoGoodsToString = asSet( + "*{-(HeuOn(\"0\", \"tm\")), +(guess(1))}", + "*{-(HeuOff(\"0\", \"tm\")), +(_nguess(\"1\", 2))}" + ); + testGenerateHeuristicNoGoods(inputProgram, expectedNoGoodsToString); + } + + @Test + public void testGenerateHeuristicNoGoods_HandlingOfUnderivableAtoms_SkipRulePositiveT() { + final InputProgram inputProgram = PROGRAM_PARSER.parse("fact(1). fact(2)." + + "{ guess(N) } :- fact(N)." + + "#heuristic guess(2) : guess(1), T fact(0)."); + final Set expectedNoGoodsToString = Collections.emptySet(); + testGenerateHeuristicNoGoods(inputProgram, expectedNoGoodsToString); + } + + @Test + public void testGenerateHeuristicNoGoods_HandlingOfUnderivableAtoms_SkipRulePositiveM() { + final InputProgram inputProgram = PROGRAM_PARSER.parse("fact(1). fact(2)." + + "{ guess(N) } :- fact(N)." + + "#heuristic guess(2) : guess(1), M fact(0)."); + final Set expectedNoGoodsToString = Collections.emptySet(); + testGenerateHeuristicNoGoods(inputProgram, expectedNoGoodsToString); + } + + @Test + public void testGenerateHeuristicNoGoods_HandlingOfUnderivableAtoms_SkipRulePositiveTM() { + final InputProgram inputProgram = PROGRAM_PARSER.parse("fact(1). fact(2)." + + "{ guess(N) } :- fact(N)." + + "#heuristic guess(2) : guess(1), TM fact(0)."); + final Set expectedNoGoodsToString = Collections.emptySet(); + testGenerateHeuristicNoGoods(inputProgram, expectedNoGoodsToString); + } + + @Test + public void testGenerateHeuristicNoGoods_HandlingOfUnderivableAtoms_SkipLiteralPositiveF() { + final InputProgram inputProgram = PROGRAM_PARSER.parse("fact(1). fact(2)." + + "{ guess(N) } :- fact(N)." + + "#heuristic guess(2) : guess(1), F fact(0)."); + final Set expectedNoGoodsToString = asSet( + "*{-(HeuOn(\"0\", \"tm\")), +(guess(1))}", + "*{-(HeuOff(\"0\", \"tm\")), +(_nguess(\"1\", 2))}" + ); + testGenerateHeuristicNoGoods(inputProgram, expectedNoGoodsToString); + } + + @Test + public void testGenerateHeuristicNoGoods_HandlingOfUnderivableAtoms_SkipLiteralNegativeT() { + final InputProgram inputProgram = PROGRAM_PARSER.parse("fact(1). fact(2)." + + "{ guess(N) } :- fact(N)." + + "#heuristic guess(2) : guess(1), not T fact(0)."); + final Set expectedNoGoodsToString = asSet( + "*{-(HeuOn(\"0\", \"tm\")), +(guess(1))}", + "*{-(HeuOff(\"0\", \"tm\")), +(_nguess(\"1\", 2))}" + ); + testGenerateHeuristicNoGoods(inputProgram, expectedNoGoodsToString); + } + + @Test + public void testGenerateHeuristicNoGoods_HandlingOfUnderivableAtoms_SkipLiteralNegativeM() { + final InputProgram inputProgram = PROGRAM_PARSER.parse("fact(1). fact(2)." + + "{ guess(N) } :- fact(N)." + + "#heuristic guess(2) : guess(1), not T fact(0)."); + final Set expectedNoGoodsToString = asSet( + "*{-(HeuOn(\"0\", \"tm\")), +(guess(1))}", + "*{-(HeuOff(\"0\", \"tm\")), +(_nguess(\"1\", 2))}" + ); + testGenerateHeuristicNoGoods(inputProgram, expectedNoGoodsToString); + } + + @Test + public void testGenerateHeuristicNoGoods_HandlingOfUnderivableAtoms_SkipLiteralNegativeTM() { + final InputProgram inputProgram = PROGRAM_PARSER.parse("fact(1). fact(2)." + + "{ guess(N) } :- fact(N)." + + "#heuristic guess(2) : guess(1), not TM fact(0)."); + final Set expectedNoGoodsToString = asSet( + "*{-(HeuOn(\"0\", \"tm\")), +(guess(1))}", + "*{-(HeuOff(\"0\", \"tm\")), +(_nguess(\"1\", 2))}" + ); + testGenerateHeuristicNoGoods(inputProgram, expectedNoGoodsToString); + } + + @Test + public void testGenerateHeuristicNoGoods_HandlingOfUnderivableAtoms_SkipRuleNegativeF() { + final InputProgram inputProgram = PROGRAM_PARSER.parse("fact(1). fact(2)." + + "{ guess(N) } :- fact(N)." + + "#heuristic guess(2) : guess(1), not F fact(0)."); + final Set expectedNoGoodsToString = Collections.emptySet(); + testGenerateHeuristicNoGoods(inputProgram, expectedNoGoodsToString); + } + + private void testGenerateHeuristicNoGoods(InputProgram inputProgram, Set expectedNoGoodsToString) { + final Alpha system = new Alpha(); + final NormalProgram normalProgram = system.normalizeProgram(inputProgram); + final InternalProgram internalProgram = InternalProgram.fromNormalProgram(normalProgram); + + final AtomStore atomStore = new AtomStoreImpl(); + final Grounder grounder = GrounderFactory.getInstance("naive", internalProgram, atomStore, heuristicsConfiguration, true); + final NoGoodGenerator noGoodGenerator = ((NaiveGrounder)grounder).noGoodGenerator; + final InternalRule rule = findHeuristicRule(internalProgram.getRules()); + assert rule != null; + final Set generatedNoGoods = new HashSet<>(noGoodGenerator.generateNoGoodsFromGroundSubstitution(rule, new Substitution())); + assertEquals(expectedNoGoodsToString.size(), generatedNoGoods.size()); + final Set noGoodsToString = generatedNoGoods.stream().map(atomStore::noGoodToString).collect(Collectors.toSet()); + assertEquals(expectedNoGoodsToString, noGoodsToString); + } + + private InternalRule findHeuristicRule(List rules) { + for (InternalRule rule : rules) { + if (rule.getHead().getAtom() instanceof HeuristicAtom) { + return rule; + } + } + return null; + } + +} diff --git a/src/test/java/at/ac/tuwien/kr/alpha/grounder/NaiveGrounderTest.java b/src/test/java/at/ac/tuwien/kr/alpha/grounder/NaiveGrounderTest.java index 07acca9d0..cdbc6c045 100644 --- a/src/test/java/at/ac/tuwien/kr/alpha/grounder/NaiveGrounderTest.java +++ b/src/test/java/at/ac/tuwien/kr/alpha/grounder/NaiveGrounderTest.java @@ -25,12 +25,6 @@ */ package at.ac.tuwien.kr.alpha.grounder; -import static at.ac.tuwien.kr.alpha.solver.ThriceTruth.TRUE; -import static at.ac.tuwien.kr.alpha.test.util.TestUtils.atom; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; @@ -47,22 +41,32 @@ import at.ac.tuwien.kr.alpha.common.AtomStoreImpl; import at.ac.tuwien.kr.alpha.common.Literals; import at.ac.tuwien.kr.alpha.common.NoGood; +import at.ac.tuwien.kr.alpha.common.NoGoodCreator; import at.ac.tuwien.kr.alpha.common.atoms.Literal; import at.ac.tuwien.kr.alpha.common.program.InputProgram; import at.ac.tuwien.kr.alpha.common.program.InternalProgram; import at.ac.tuwien.kr.alpha.common.program.NormalProgram; import at.ac.tuwien.kr.alpha.common.rule.InternalRule; import at.ac.tuwien.kr.alpha.common.terms.ConstantTerm; +import at.ac.tuwien.kr.alpha.common.terms.VariableTerm; import at.ac.tuwien.kr.alpha.grounder.heuristics.GrounderHeuristicsConfiguration; import at.ac.tuwien.kr.alpha.grounder.instantiation.BindingResult; import at.ac.tuwien.kr.alpha.grounder.parser.ProgramParser; import at.ac.tuwien.kr.alpha.grounder.parser.ProgramPartParser; import at.ac.tuwien.kr.alpha.solver.ThriceTruth; import at.ac.tuwien.kr.alpha.solver.TrailAssignment; +import at.ac.tuwien.kr.alpha.solver.heuristics.HeuristicsConfiguration; +import at.ac.tuwien.kr.alpha.solver.heuristics.HeuristicsConfigurationBuilder; + +import static at.ac.tuwien.kr.alpha.solver.ThriceTruth.TRUE; +import static at.ac.tuwien.kr.alpha.test.util.TestUtils.atom; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; /** * Tests {@link NaiveGrounder} - * + * * Some test cases use atoms of the something/1 predicate to trick the grounder * into believing that other atoms might become true. This is fragile because future implementations * of preprocessing techniques might render this trick useless. @@ -71,6 +75,9 @@ public class NaiveGrounderTest { private static final ProgramParser PROGRAM_PARSER = new ProgramParser(); private static final ProgramPartParser PROGRAM_PART_PARSER = new ProgramPartParser(); + private static final VariableTerm N = VariableTerm.getInstance("N"); + private static final ConstantTerm ONE = ConstantTerm.getInstance(1); + private final HeuristicsConfiguration heuristicsConfiguration = new HeuristicsConfigurationBuilder().setRespectDomspecHeuristics(true).build(); final Literal litP1X = PROGRAM_PART_PARSER.parseLiteral("p1(X)"); final Literal litP2X = PROGRAM_PART_PARSER.parseLiteral("p2(X)"); @@ -79,6 +86,11 @@ public class NaiveGrounderTest { final Literal litAX = PROGRAM_PART_PARSER.parseLiteral("a(X)"); final Literal litA1 = PROGRAM_PART_PARSER.parseLiteral("a(1)"); + @BeforeEach + public void resetIdGenerator() { + ChoiceRecorder.ID_GENERATOR.resetGenerator(); + } + @BeforeEach public void resetRuleIdGenerator() { InternalRule.resetIdGenerator(); @@ -96,9 +108,9 @@ public void groundRuleAlreadyGround() { + "c :- b."); NormalProgram normal = system.normalizeProgram(program); InternalProgram prog = system.performProgramPreprocessing(InternalProgram.fromNormalProgram(normal)); - + AtomStore atomStore = new AtomStoreImpl(); - Grounder grounder = GrounderFactory.getInstance("naive", prog, atomStore, true); + Grounder grounder = GrounderFactory.getInstance("naive", prog, atomStore, heuristicsConfiguration, true); Map noGoods = grounder.getNoGoods(new TrailAssignment(atomStore)); int litCNeg = Literals.atomToLiteral(atomStore.get(PROGRAM_PART_PARSER.parseBasicAtom("c")), false); int litB = Literals.atomToLiteral(atomStore.get(PROGRAM_PART_PARSER.parseBasicAtom("b"))); @@ -119,9 +131,9 @@ public void groundRuleWithLongerBodyAlreadyGround() { + "d :- b, c. "); NormalProgram normal = system.normalizeProgram(program); InternalProgram prog = system.performProgramPreprocessing(InternalProgram.fromNormalProgram(normal)); - + AtomStore atomStore = new AtomStoreImpl(); - Grounder grounder = GrounderFactory.getInstance("naive", prog, atomStore, true); + Grounder grounder = GrounderFactory.getInstance("naive", prog, atomStore, heuristicsConfiguration, true); Map noGoods = grounder.getNoGoods(new TrailAssignment(atomStore)); int litANeg = Literals.atomToLiteral(atomStore.get(PROGRAM_PART_PARSER.parseBasicAtom("a")), false); int litBNeg = Literals.atomToLiteral(atomStore.get(PROGRAM_PART_PARSER.parseBasicAtom("b")), false); @@ -145,12 +157,12 @@ public void groundConstraintAlreadyGround() { + ":- b."); NormalProgram normal = system.normalizeProgram(program); InternalProgram prog = system.performProgramPreprocessing(InternalProgram.fromNormalProgram(normal)); - + AtomStore atomStore = new AtomStoreImpl(); - Grounder grounder = GrounderFactory.getInstance("naive", prog, atomStore, true); + Grounder grounder = GrounderFactory.getInstance("naive", prog, atomStore, heuristicsConfiguration, true); Map noGoods = grounder.getNoGoods(new TrailAssignment(atomStore)); int litB = Literals.atomToLiteral(atomStore.get(PROGRAM_PART_PARSER.parseBasicAtom("b"))); - assertTrue(noGoods.containsValue(NoGood.fromConstraint(Collections.singletonList(litB), Collections.emptyList()))); + assertTrue(noGoods.containsValue(NoGoodCreator.fromConstraint(Collections.singletonList(litB), Collections.emptyList()))); } @Test @@ -214,7 +226,7 @@ private void testDeadEnd(String predicateNameOfStartingLiteral, RuleGroundingOrd ); AtomStore atomStore = new AtomStoreImpl(); - NaiveGrounder grounder = (NaiveGrounder) GrounderFactory.getInstance("naive", program, atomStore, p -> true, GrounderHeuristicsConfiguration.permissive(), true); + NaiveGrounder grounder = (NaiveGrounder) GrounderFactory.getInstance("naive", program, atomStore, heuristicsConfiguration, p -> true, GrounderHeuristicsConfiguration.permissive(), true); InternalRule nonGroundRule = grounder.getNonGroundRule(0); String strLiteral = "p1".equals(predicateNameOfStartingLiteral) ? "p1(X)" : "p1(Y)"; @@ -276,7 +288,7 @@ private void testIfGrounderGroundsRule(InputProgram program, int ruleID, Literal InternalProgram internalPrg = InternalProgram.fromNormalProgram(system.normalizeProgram(program)); AtomStore atomStore = new AtomStoreImpl(); TrailAssignment currentAssignment = new TrailAssignment(atomStore); - NaiveGrounder grounder = (NaiveGrounder) GrounderFactory.getInstance("naive", internalPrg, atomStore, p -> true, GrounderHeuristicsConfiguration.permissive(), true); + NaiveGrounder grounder = (NaiveGrounder) GrounderFactory.getInstance("naive", internalPrg, atomStore, heuristicsConfiguration, p -> true, GrounderHeuristicsConfiguration.permissive(), true); int b = atomStore.putIfAbsent(atom("b", 1)); currentAssignment.growForMaxAtomId(); @@ -288,7 +300,7 @@ private void testIfGrounderGroundsRule(InputProgram program, int ruleID, Literal final BindingResult bindingResult = grounder.getGroundInstantiations(nonGroundRule, nonGroundRule.getGroundingOrders().groundingOrders.get(startingLiteral), substStartingLiteral, currentAssignment); assertEquals(expectNoGoods, bindingResult.size() > 0); } - + @Test public void testPermissiveGrounderHeuristicTolerance_0_reject() { InputProgram program = PROGRAM_PARSER.parse("a(1). " @@ -296,7 +308,7 @@ public void testPermissiveGrounderHeuristicTolerance_0_reject() { + "b(X) :- something(X)."); testPermissiveGrounderHeuristicTolerance(program, 0, litAX, 1, 0, false, Arrays.asList(1)); } - + @Test public void testPermissiveGrounderHeuristicTolerance_1_accept() { InputProgram program = PROGRAM_PARSER.parse("a(1). " @@ -304,7 +316,7 @@ public void testPermissiveGrounderHeuristicTolerance_1_accept() { + "b(X) :- something(X)."); testPermissiveGrounderHeuristicTolerance(program, 0, litAX, 1, 1, true, Arrays.asList(1)); } - + @Test public void testPermissiveGrounderHeuristicTolerance_1_reject() { InputProgram program = PROGRAM_PARSER.parse("a(1). " @@ -381,8 +393,8 @@ private void testPermissiveGrounderHeuristicTolerance(InputProgram program, int InternalProgram internalPrg = InternalProgram.fromNormalProgram(system.normalizeProgram(program)); AtomStore atomStore = new AtomStoreImpl(); TrailAssignment currentAssignment = new TrailAssignment(atomStore); - GrounderHeuristicsConfiguration heuristicConfiguration = GrounderHeuristicsConfiguration.getInstance(tolerance, tolerance); - NaiveGrounder grounder = (NaiveGrounder) GrounderFactory.getInstance("naive", internalPrg, atomStore, p -> true, heuristicConfiguration, true); + GrounderHeuristicsConfiguration grounderHeuristicsConfiguration = GrounderHeuristicsConfiguration.getInstance(tolerance, tolerance); + NaiveGrounder grounder = (NaiveGrounder) GrounderFactory.getInstance("naive", internalPrg, atomStore, heuristicsConfiguration, p -> true, grounderHeuristicsConfiguration, true); int[] bAtomIDs = new int[truthsOfB.length]; for (int i = 0; i < truthsOfB.length; i++) { diff --git a/src/test/java/at/ac/tuwien/kr/alpha/grounder/NoGoodGeneratorTest.java b/src/test/java/at/ac/tuwien/kr/alpha/grounder/NoGoodGeneratorTest.java index 0479c42ae..76704b19d 100644 --- a/src/test/java/at/ac/tuwien/kr/alpha/grounder/NoGoodGeneratorTest.java +++ b/src/test/java/at/ac/tuwien/kr/alpha/grounder/NoGoodGeneratorTest.java @@ -1,16 +1,16 @@ /** - * Copyright (c) 2018 Siemens AG + * Copyright (c) 2018-2019 Siemens AG * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * 1) Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. + * list of conditions and the following disclaimer. * * 2) Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -25,13 +25,10 @@ */ package at.ac.tuwien.kr.alpha.grounder; -import static at.ac.tuwien.kr.alpha.common.Literals.atomOf; -import static org.junit.jupiter.api.Assertions.assertEquals; +import org.junit.jupiter.api.Test; import java.util.List; -import org.junit.jupiter.api.Test; - import at.ac.tuwien.kr.alpha.api.Alpha; import at.ac.tuwien.kr.alpha.common.AtomStore; import at.ac.tuwien.kr.alpha.common.AtomStoreImpl; @@ -42,6 +39,11 @@ import at.ac.tuwien.kr.alpha.common.terms.ConstantTerm; import at.ac.tuwien.kr.alpha.common.terms.VariableTerm; import at.ac.tuwien.kr.alpha.grounder.parser.ProgramParser; +import at.ac.tuwien.kr.alpha.solver.heuristics.HeuristicsConfiguration; +import at.ac.tuwien.kr.alpha.solver.heuristics.HeuristicsConfigurationBuilder; + +import static at.ac.tuwien.kr.alpha.common.Literals.atomOf; +import static org.junit.jupiter.api.Assertions.assertEquals; /** * Tests {@link NoGoodGenerator} @@ -56,6 +58,7 @@ public class NoGoodGeneratorTest { private static final VariableTerm X = VariableTerm.getInstance("X"); private static final VariableTerm Y = VariableTerm.getInstance("Y"); + private final HeuristicsConfiguration heuristicsConfiguration = new HeuristicsConfigurationBuilder().build(); /** * Calls {@link NoGoodGenerator#collectNegLiterals(InternalRule, Substitution)}, which puts the atom occurring * negatively in a rule into the atom store. It is then checked whether the atom in the atom store is positive. @@ -63,15 +66,15 @@ public class NoGoodGeneratorTest { @Test public void collectNeg_ContainsOnlyPositiveLiterals() { Alpha system = new Alpha(); - InputProgram input = PARSER.parse("p(a,b). " - + "q(a,b) :- not nq(a,b). " + InputProgram input = PARSER.parse("p(a,b). " + + "q(a,b) :- not nq(a,b). " + "nq(a,b) :- not q(a,b)."); NormalProgram normal = system.normalizeProgram(input); InternalProgram program = InternalProgram.fromNormalProgram(normal); InternalRule rule = program.getRules().get(1); AtomStore atomStore = new AtomStoreImpl(); - Grounder grounder = GrounderFactory.getInstance("naive", program, atomStore, true); + Grounder grounder = GrounderFactory.getInstance("naive", program, atomStore, heuristicsConfiguration, true); NoGoodGenerator noGoodGenerator = ((NaiveGrounder) grounder).noGoodGenerator; Substitution substitution = new Substitution(); substitution.put(X, A); diff --git a/src/test/java/at/ac/tuwien/kr/alpha/grounder/RuleGroundingOrderTest.java b/src/test/java/at/ac/tuwien/kr/alpha/grounder/RuleGroundingOrderTest.java index c512ff0d3..eba04566f 100644 --- a/src/test/java/at/ac/tuwien/kr/alpha/grounder/RuleGroundingOrderTest.java +++ b/src/test/java/at/ac/tuwien/kr/alpha/grounder/RuleGroundingOrderTest.java @@ -1,19 +1,19 @@ /* * Copyright (c) 2017-2020, the Alpha Team. * All rights reserved. - * + * * Additional changes made by Siemens. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: - * + * * 1) Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. - * + * * 2) Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE @@ -29,11 +29,6 @@ -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.junit.jupiter.api.Assertions.fail; - import org.junit.jupiter.api.Test; import at.ac.tuwien.kr.alpha.api.Alpha; @@ -42,6 +37,11 @@ import at.ac.tuwien.kr.alpha.common.rule.InternalRule; import at.ac.tuwien.kr.alpha.grounder.parser.ProgramPartParser; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + /** * Copyright (c) 2017-2019, the Alpha Team. */ @@ -49,7 +49,6 @@ public class RuleGroundingOrderTest { private static final ProgramPartParser PROGRAM_PART_PARSER = new ProgramPartParser(); - @Test public void groundingOrder() { String aspStr = "h(X,C) :- p(X,Y), q(A,B), r(Y,A), s(C)." + @@ -84,7 +83,7 @@ public void groundingOrderUnsafe() { computeGroundingOrdersForRule(internalPrg, 0); }); } - + @Test public void testPositionFromWhichAllVarsAreBound_ground() { String aspStr = "a :- b, not c."; @@ -94,7 +93,7 @@ public void testPositionFromWhichAllVarsAreBound_ground() { RuleGroundingOrders rgo0 = computeGroundingOrdersForRule(internalPrg, 0); assertEquals(0, rgo0.getFixedGroundingOrder().getPositionFromWhichAllVarsAreBound()); } - + @Test public void testPositionFromWhichAllVarsAreBound_simpleNonGround() { String aspStr = "a(X) :- b(X), not c(X)."; diff --git a/src/test/java/at/ac/tuwien/kr/alpha/grounder/RuleToStringTest.java b/src/test/java/at/ac/tuwien/kr/alpha/grounder/RuleToStringTest.java index e6f653a97..80f4b690a 100644 --- a/src/test/java/at/ac/tuwien/kr/alpha/grounder/RuleToStringTest.java +++ b/src/test/java/at/ac/tuwien/kr/alpha/grounder/RuleToStringTest.java @@ -89,8 +89,12 @@ private void parseSingleRuleAndCheckToString(String rule) { } private void constructNonGroundRuleAndCheckToString(String textualRule) { + constructNonGroundRuleAndCheckToString(textualRule, textualRule); + } + + private void constructNonGroundRuleAndCheckToString(String textualRule, String expectedToString) { InternalRule nonGroundRule = InternalRule.fromNormalRule(NormalRule.fromBasicRule(parseSingleRule(textualRule))); - assertEquals(textualRule, nonGroundRule.toString()); + assertEquals(expectedToString, nonGroundRule.toString()); } private BasicRule parseSingleRule(String rule) { diff --git a/src/test/java/at/ac/tuwien/kr/alpha/grounder/instantiation/LiteralInstantiationStrategyTest.java b/src/test/java/at/ac/tuwien/kr/alpha/grounder/instantiation/LiteralInstantiationStrategyTest.java index 9b016a6e2..e3021fb24 100644 --- a/src/test/java/at/ac/tuwien/kr/alpha/grounder/instantiation/LiteralInstantiationStrategyTest.java +++ b/src/test/java/at/ac/tuwien/kr/alpha/grounder/instantiation/LiteralInstantiationStrategyTest.java @@ -1,15 +1,36 @@ +/* + * Copyright (c) 2020, the Alpha Team. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package at.ac.tuwien.kr.alpha.grounder.instantiation; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; +import org.apache.commons.lang3.tuple.ImmutablePair; +import org.junit.jupiter.api.Test; -import java.util.Collections; import java.util.LinkedHashSet; import java.util.List; -import org.apache.commons.lang3.tuple.ImmutablePair; -import org.junit.jupiter.api.Test; - import at.ac.tuwien.kr.alpha.common.AtomStore; import at.ac.tuwien.kr.alpha.common.AtomStoreImpl; import at.ac.tuwien.kr.alpha.common.Predicate; @@ -17,6 +38,7 @@ import at.ac.tuwien.kr.alpha.common.atoms.BasicAtom; import at.ac.tuwien.kr.alpha.common.atoms.BasicLiteral; import at.ac.tuwien.kr.alpha.common.atoms.Literal; +import at.ac.tuwien.kr.alpha.common.program.Facts; import at.ac.tuwien.kr.alpha.common.terms.ConstantTerm; import at.ac.tuwien.kr.alpha.common.terms.VariableTerm; import at.ac.tuwien.kr.alpha.grounder.NaiveGrounder; @@ -26,6 +48,9 @@ import at.ac.tuwien.kr.alpha.solver.TrailAssignment; import at.ac.tuwien.kr.alpha.solver.WritableAssignment; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class LiteralInstantiationStrategyTest { @Test @@ -75,7 +100,7 @@ public void defaultLazyGroundingNoAssignmentGroundLiteral() { WorkingMemory workingMemory = new WorkingMemory(); LinkedHashSet staleSet = new LinkedHashSet<>(); DefaultLazyGroundingInstantiationStrategy strategy = new DefaultLazyGroundingInstantiationStrategy(workingMemory, new AtomStoreImpl(), - Collections.emptyMap(), false); + new Facts(), false); strategy.setStaleWorkingMemoryEntries(staleSet); strategy.setCurrentAssignment(null); @@ -105,7 +130,7 @@ public void defaultLazyGroundingNoAssignmentSubstituteNonGroundLiteral() { workingMemory.addInstance(new BasicAtom(q, ConstantTerm.getSymbolicInstance("a"), ConstantTerm.getSymbolicInstance("b")), true); LinkedHashSet staleSet = new LinkedHashSet<>(); DefaultLazyGroundingInstantiationStrategy strategy = new DefaultLazyGroundingInstantiationStrategy(workingMemory, new AtomStoreImpl(), - Collections.emptyMap(), false); + new Facts(), false); strategy.setStaleWorkingMemoryEntries(staleSet); strategy.setCurrentAssignment(null); @@ -140,7 +165,7 @@ public void defaultLazyGroundingCheckUnassignedGroundLiteral() { WritableAssignment assignment = new TrailAssignment(atomStore); LinkedHashSet staleSet = new LinkedHashSet<>(); DefaultLazyGroundingInstantiationStrategy strategy = new DefaultLazyGroundingInstantiationStrategy(workingMemory, atomStore, - Collections.emptyMap(), false); + new Facts(), false); strategy.setStaleWorkingMemoryEntries(staleSet); strategy.setCurrentAssignment(assignment); @@ -173,7 +198,7 @@ public void defaultLazyGroundingCheckFalseGroundLiteral() { assignment.assign(atomStore.get(pOfA), ThriceTruth.FALSE); LinkedHashSet staleSet = new LinkedHashSet<>(); DefaultLazyGroundingInstantiationStrategy strategy = new DefaultLazyGroundingInstantiationStrategy(workingMemory, atomStore, - Collections.emptyMap(), false); + new Facts(), false); strategy.setStaleWorkingMemoryEntries(staleSet); strategy.setCurrentAssignment(assignment); @@ -206,7 +231,7 @@ public void defaultLazyGroundingCheckTrueGroundLiteral() { assignment.assign(atomStore.get(pOfA), ThriceTruth.TRUE); LinkedHashSet staleSet = new LinkedHashSet<>(); DefaultLazyGroundingInstantiationStrategy strategy = new DefaultLazyGroundingInstantiationStrategy(workingMemory, atomStore, - Collections.emptyMap(), false); + new Facts(), false); strategy.setStaleWorkingMemoryEntries(staleSet); strategy.setCurrentAssignment(assignment); @@ -238,7 +263,7 @@ public void defaultLazyGroundingCheckMustBeTrueGroundLiteral() { assignment.assign(atomStore.get(pOfA), ThriceTruth.MBT); LinkedHashSet staleSet = new LinkedHashSet<>(); DefaultLazyGroundingInstantiationStrategy strategy = new DefaultLazyGroundingInstantiationStrategy(workingMemory, atomStore, - Collections.emptyMap(), false); + new Facts(), false); strategy.setStaleWorkingMemoryEntries(staleSet); strategy.setCurrentAssignment(assignment); @@ -270,7 +295,7 @@ public void defaultLazyGroundingSubstituteNonGroundLiteralWithUnassignedInstance WritableAssignment assignment = new TrailAssignment(atomStore); LinkedHashSet staleSet = new LinkedHashSet<>(); DefaultLazyGroundingInstantiationStrategy strategy = new DefaultLazyGroundingInstantiationStrategy(workingMemory, atomStore, - Collections.emptyMap(), false); + new Facts(), false); strategy.setStaleWorkingMemoryEntries(staleSet); strategy.setCurrentAssignment(assignment); @@ -313,7 +338,7 @@ public void defaultLazyGroundingSubstituteNonGroundLiteralWithTrueInstance() { assignment.assign(atomStore.get(groundAtom), ThriceTruth.TRUE); LinkedHashSet staleSet = new LinkedHashSet<>(); DefaultLazyGroundingInstantiationStrategy strategy = new DefaultLazyGroundingInstantiationStrategy(workingMemory, atomStore, - Collections.emptyMap(), false); + new Facts(), false); strategy.setStaleWorkingMemoryEntries(staleSet); strategy.setCurrentAssignment(assignment); @@ -354,7 +379,7 @@ public void defaultLazyGroundingSubstituteNonGroundLiteralWithFalseInstance() { assignment.assign(atomStore.get(groundAtom), ThriceTruth.FALSE); LinkedHashSet staleSet = new LinkedHashSet<>(); DefaultLazyGroundingInstantiationStrategy strategy = new DefaultLazyGroundingInstantiationStrategy(workingMemory, atomStore, - Collections.emptyMap(), false); + new Facts(), false); strategy.setStaleWorkingMemoryEntries(staleSet); strategy.setCurrentAssignment(assignment); diff --git a/src/test/java/at/ac/tuwien/kr/alpha/grounder/structure/AnalyzeUnjustifiedTest.java b/src/test/java/at/ac/tuwien/kr/alpha/grounder/structure/AnalyzeUnjustifiedTest.java index ebd22ddb7..304d98bee 100644 --- a/src/test/java/at/ac/tuwien/kr/alpha/grounder/structure/AnalyzeUnjustifiedTest.java +++ b/src/test/java/at/ac/tuwien/kr/alpha/grounder/structure/AnalyzeUnjustifiedTest.java @@ -27,15 +27,12 @@ */ package at.ac.tuwien.kr.alpha.grounder.structure; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNotEquals; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Collections; import java.util.Set; -import org.junit.jupiter.api.Test; - import at.ac.tuwien.kr.alpha.api.Alpha; import at.ac.tuwien.kr.alpha.common.AtomStore; import at.ac.tuwien.kr.alpha.common.AtomStoreImpl; @@ -51,6 +48,11 @@ import at.ac.tuwien.kr.alpha.grounder.parser.ProgramParser; import at.ac.tuwien.kr.alpha.solver.ThriceTruth; import at.ac.tuwien.kr.alpha.solver.TrailAssignment; +import at.ac.tuwien.kr.alpha.solver.heuristics.HeuristicsConfiguration; +import at.ac.tuwien.kr.alpha.solver.heuristics.HeuristicsConfigurationBuilder; + +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; /** * Copyright (c) 2018-2020, the Alpha Team. @@ -58,6 +60,7 @@ public class AnalyzeUnjustifiedTest { private final ProgramParser parser = new ProgramParser(); + private final HeuristicsConfiguration heuristicsConfiguration = new HeuristicsConfigurationBuilder().build(); @Test public void justifySimpleRules() { @@ -72,7 +75,7 @@ public void justifySimpleRules() { NormalProgram normal = system.normalizeProgram(parsedProgram); InternalProgram internalProgram = InternalProgram.fromNormalProgram(normal); AtomStore atomStore = new AtomStoreImpl(); - NaiveGrounder grounder = new NaiveGrounder(internalProgram, atomStore, true); + NaiveGrounder grounder = new NaiveGrounder(internalProgram, atomStore, heuristicsConfiguration, true); grounder.getNoGoods(null); TrailAssignment assignment = new TrailAssignment(atomStore); int rId = atomStore.get(new BasicAtom(Predicate.getInstance("r", 0))); @@ -100,7 +103,7 @@ public void justifyLargerRules() { NormalProgram normal = system.normalizeProgram(parsedProgram); InternalProgram internalProgram = InternalProgram.fromNormalProgram(normal); AtomStore atomStore = new AtomStoreImpl(); - NaiveGrounder grounder = new NaiveGrounder(internalProgram, atomStore, true); + NaiveGrounder grounder = new NaiveGrounder(internalProgram, atomStore, heuristicsConfiguration, true); grounder.getNoGoods(null); TrailAssignment assignment = new TrailAssignment(atomStore); Atom p1 = parser.parse("p(1).").getFacts().get(0); @@ -140,7 +143,7 @@ public void justifyMultipleReasons() { NormalProgram normal = system.normalizeProgram(parsedProgram); InternalProgram internalProgram = InternalProgram.fromNormalProgram(normal); AtomStore atomStore = new AtomStoreImpl(); - NaiveGrounder grounder = new NaiveGrounder(internalProgram, atomStore, true); + NaiveGrounder grounder = new NaiveGrounder(internalProgram, atomStore, heuristicsConfiguration, true); grounder.getNoGoods(null); TrailAssignment assignment = new TrailAssignment(atomStore); Atom qa = parser.parse("q(a).").getFacts().get(0); @@ -199,7 +202,7 @@ public void justifyNegatedFactsRemovedFromReasons() { NormalProgram normal = system.normalizeProgram(parsedProgram); InternalProgram internalProgram = InternalProgram.fromNormalProgram(normal); AtomStore atomStore = new AtomStoreImpl(); - NaiveGrounder grounder = new NaiveGrounder(internalProgram, atomStore, true); + NaiveGrounder grounder = new NaiveGrounder(internalProgram, atomStore, heuristicsConfiguration, true); grounder.getNoGoods(null); TrailAssignment assignment = new TrailAssignment(atomStore); int rId = atomStore.get(new BasicAtom(Predicate.getInstance("r", 0))); diff --git a/src/test/java/at/ac/tuwien/kr/alpha/grounder/transformation/ChoiceHeadToNormalTest.java b/src/test/java/at/ac/tuwien/kr/alpha/grounder/transformation/ChoiceHeadToNormalTest.java new file mode 100644 index 000000000..dc836efc9 --- /dev/null +++ b/src/test/java/at/ac/tuwien/kr/alpha/grounder/transformation/ChoiceHeadToNormalTest.java @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2018 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.grounder.transformation; + +import org.junit.jupiter.api.Test; + +import at.ac.tuwien.kr.alpha.common.program.InputProgram; +import at.ac.tuwien.kr.alpha.grounder.parser.ProgramParser; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * Tests {@link ChoiceHeadToNormal}. + */ +public class ChoiceHeadToNormalTest { + private final ProgramParser parser = new ProgramParser(); + + @Test + public void testNumberOfRulesAfterTransformationEqualsTwo() { + InputProgram program = parser.parse("n(1..2). " + + "{ x(N) } :- n(N)."); + program = new ChoiceHeadToNormal().apply(program); + assertEquals(2, program.getRules().size()); + } + +} diff --git a/src/test/java/at/ac/tuwien/kr/alpha/grounder/transformation/HeuristicDirectiveConditionEnhancementTest.java b/src/test/java/at/ac/tuwien/kr/alpha/grounder/transformation/HeuristicDirectiveConditionEnhancementTest.java new file mode 100644 index 000000000..08a6f620d --- /dev/null +++ b/src/test/java/at/ac/tuwien/kr/alpha/grounder/transformation/HeuristicDirectiveConditionEnhancementTest.java @@ -0,0 +1,276 @@ +/* + * Copyright (c) 2021-2022 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.grounder.transformation; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedHashSet; + +import org.junit.jupiter.api.Test; + +import at.ac.tuwien.kr.alpha.common.EnumerationDirective; +import at.ac.tuwien.kr.alpha.common.HeuristicDirective; +import at.ac.tuwien.kr.alpha.common.atoms.Atom; +import at.ac.tuwien.kr.alpha.common.heuristics.HeuristicDirectiveAtom; +import at.ac.tuwien.kr.alpha.common.heuristics.HeuristicDirectiveBody; +import at.ac.tuwien.kr.alpha.common.program.InputProgram; +import at.ac.tuwien.kr.alpha.grounder.parser.ProgramParser; +import at.ac.tuwien.kr.alpha.grounder.parser.ProgramPartParser; +import at.ac.tuwien.kr.alpha.solver.heuristics.HeuristicsConfiguration; +import at.ac.tuwien.kr.alpha.solver.heuristics.HeuristicsConfigurationBuilder; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * Tests {@link HeuristicDirectiveConditionEnhancement}. + */ +public class HeuristicDirectiveConditionEnhancementTest { + private final ProgramParser parser = new ProgramParser(); + private final ProgramPartParser programPartParser = new ProgramPartParser(); + private final HeuristicsConfiguration heuristicsConfiguration = new HeuristicsConfigurationBuilder().setRespectDomspecHeuristics(true).build(); + + @Test + public void testEnhancementOfOneDirectiveWithoutUnification() { + InputProgram program = parser.parse("a(1). c(1). d(1)." + + "{ b(N) } :- c(N)." + + "#heuristic b(N) : a(N). [N@2]"); + final Atom negativeChoiceAtom = ChoiceHeadToNormal.constructNegativeChoiceAtom(programPartParser.parseBasicAtom("b(N)")); + + program = new ChoiceHeadToNormal().apply(program); + program = new HeuristicDirectiveConditionEnhancement(heuristicsConfiguration).apply(program); + Collection expectedHeuristicDirectives = Collections.singletonList( + parseHeuristicDirectiveAndAddNegativeLiteral("#heuristic b(N) : a(N), T c(N). [N@2]", negativeChoiceAtom) + ); + assertEquals(expectedHeuristicDirectives, program.getInlineDirectives().getDirectives()); + } + + @Test + public void testEnhancementOfOneDirectiveWithPartialUnification() { + InputProgram program = parser.parse("a(1). c(1). d(1)." + + "{ b(N,X) } :- c(N), d(X)." + + "#heuristic b(N,M) : a(N), d(M). [N@2]"); + final Atom negativeChoiceAtom = ChoiceHeadToNormal.constructNegativeChoiceAtom(programPartParser.parseBasicAtom("b(N,M)")); + + program = new ChoiceHeadToNormal().apply(program); + program = new HeuristicDirectiveConditionEnhancement(heuristicsConfiguration).apply(program); + Collection expectedHeuristicDirectives = Collections.singletonList( + parseHeuristicDirectiveAndAddNegativeLiteral("#heuristic b(N,M) : a(N), d(M), T c(N), T d(M). [N@2]", negativeChoiceAtom) + ); + assertEquals(expectedHeuristicDirectives, program.getInlineDirectives().getDirectives()); + } + + @Test + public void testEnhancementOfOneDirectiveByTwoNormalRulesWithoutUnification() { + InputProgram program = parser.parse("a(1). c(1). d(1)." + + "b(N) :- c(N), not d(N)." + + "b(N) :- a(N), not d(N)." + + "#heuristic b(N) : a(N). [N@2]"); + + program = new ChoiceHeadToNormal().apply(program); + program = new HeuristicDirectiveConditionEnhancement(heuristicsConfiguration).apply(program); + Collection expectedHeuristicDirectives = Arrays.asList( + programPartParser.parseHeuristicDirective("#heuristic b(N) : a(N), T c(N), not d(N). [N@2]"), + programPartParser.parseHeuristicDirective("#heuristic b(N) : a(N), T a(N), not d(N). [N@2]") + ); + assertEquals(expectedHeuristicDirectives, program.getInlineDirectives().getDirectives()); + } + + @Test + public void testEnhancementOfOneDirectiveByTwoNormalRules() { + InputProgram program = parser.parse("a(1). c(1). d(1)." + + "b(M) :- c(M), not d(M)." + + "b(L) :- a(L), not d(L)." + + "#heuristic b(N) : a(N). [N@2]"); + final Atom negativeChoiceAtom = ChoiceHeadToNormal.constructNegativeChoiceAtom(programPartParser.parseBasicAtom("b(N)")); + + program = new ChoiceHeadToNormal().apply(program); + program = new HeuristicDirectiveConditionEnhancement(heuristicsConfiguration).apply(program); + Collection expectedHeuristicDirectives = Arrays.asList( + programPartParser.parseHeuristicDirective("#heuristic b(N) : a(N), T c(N), not d(N). [N@2]"), + programPartParser.parseHeuristicDirective("#heuristic b(N) : a(N), T a(N), not d(N). [N@2]") + ); + assertEquals(expectedHeuristicDirectives, program.getInlineDirectives().getDirectives()); + } + + @Test + public void testEnhancementOfOneDirectiveByTwoChoiceRulesWithoutUnification() { + InputProgram program = parser.parse("a(1). c(1). d(1)." + + "{ b(N) } :- c(N)." + + "{ b(N) } :- a(N), not d(N)." + + "#heuristic b(N) : a(N). [N@2]"); + final Atom negativeChoiceAtom = ChoiceHeadToNormal.constructNegativeChoiceAtom(programPartParser.parseBasicAtom("b(N)")); + + program = new ChoiceHeadToNormal().apply(program); + program = new HeuristicDirectiveConditionEnhancement(heuristicsConfiguration).apply(program); + Collection expectedHeuristicDirectives = Arrays.asList( + parseHeuristicDirectiveAndAddNegativeLiteral("#heuristic b(N) : a(N), T c(N). [N@2]", negativeChoiceAtom), + parseHeuristicDirectiveAndAddNegativeLiteral("#heuristic b(N) : a(N), T a(N), not d(N). [N@2]", negativeChoiceAtom) + ); + assertEquals(expectedHeuristicDirectives, program.getInlineDirectives().getDirectives()); + } + + @Test + public void testEnhancementOfOneDirectiveByTwoChoiceRules() { + InputProgram program = parser.parse("a(1). c(1). d(1)." + + "{ b(M) } :- c(M)." + + "{ b(L) } :- a(L), not d(L)." + + "#heuristic b(N) : a(N). [N@2]"); + final Atom negativeChoiceAtom = ChoiceHeadToNormal.constructNegativeChoiceAtom(programPartParser.parseBasicAtom("b(N)")); + + program = new ChoiceHeadToNormal().apply(program); + program = new HeuristicDirectiveConditionEnhancement(heuristicsConfiguration).apply(program); + Collection expectedHeuristicDirectives = Arrays.asList( + parseHeuristicDirectiveAndAddNegativeLiteral("#heuristic b(N) : a(N), T c(N). [N@2]", negativeChoiceAtom), + parseHeuristicDirectiveAndAddNegativeLiteral("#heuristic b(N) : a(N), T a(N), not d(N). [N@2]", negativeChoiceAtom) + ); + assertEquals(expectedHeuristicDirectives, program.getInlineDirectives().getDirectives()); + } + + @Test + public void testRuleWithAggregateAtom() { + InputProgram program = parser.parse("a(1). b(1). p(1). q(1,1). q(1,2)." + + "{ b(X) } :- a(X), b(X), X = #sum { Y : p(Y) }, 1 < #count { Z : q(X,Z) }." + + "#heuristic b(N) : a(N). [N@2]"); + final Atom negativeChoiceAtom = ChoiceHeadToNormal.constructNegativeChoiceAtom(programPartParser.parseBasicAtom("b(N)")); + + program = new ChoiceHeadToNormal().apply(program); + program = new HeuristicDirectiveConditionEnhancement(heuristicsConfiguration).apply(program); + Collection expectedHeuristicDirectives = Collections.singletonList( + parseHeuristicDirectiveAndAddNegativeLiteral("#heuristic b(N) : a(N), T a(N), T b(N), N = #sum { Y : p(Y) }, 1 < #count { Z : q(N,Z) }. [N@2]", negativeChoiceAtom) + ); + assertEquals(expectedHeuristicDirectives, program.getInlineDirectives().getDirectives()); + } + + @Test + public void testRuleWithComparisonAtom() { + InputProgram program = parser.parse("a(1). b(1)." + + "{ b(M) } :- a(M), b(X), M <= X." + + "#heuristic b(N) : a(N). [N@2]"); + final Atom negativeChoiceAtom = ChoiceHeadToNormal.constructNegativeChoiceAtom(programPartParser.parseBasicAtom("b(N)")); + + program = new ChoiceHeadToNormal().apply(program); + program = new HeuristicDirectiveConditionEnhancement(heuristicsConfiguration).apply(program); + Collection expectedHeuristicDirectives = Collections.singletonList( + parseHeuristicDirectiveAndAddNegativeLiteral("#heuristic b(N) : a(N), T a(N), T b(X), N <= X. [N@2]", negativeChoiceAtom) + ); + assertEquals(expectedHeuristicDirectives, program.getInlineDirectives().getDirectives()); + } + + @Test + public void testUnificationWithConstantTerm() { + InputProgram program = parser.parse("elem(d,1). comUnit(1)." + + "{ gt(A,X,U) } :- elem(A,X), comUnit(U)." + + "assign(1,d,D) :- elem(d,D), comUnit(1), not gt(d,D,1)." + + "#heuristic assign(U,T,X) : T comUnit(U), T elem(T,X)."); + + program = new ChoiceHeadToNormal().apply(program); + program = new HeuristicDirectiveConditionEnhancement(heuristicsConfiguration).apply(program); + Collection expectedHeuristicDirectives = Collections.singletonList( + programPartParser.parseHeuristicDirective("#heuristic assign(1,d,X) : T comUnit(1), T elem(d,X), not gt(d,X,1).") + ); + assertEquals(expectedHeuristicDirectives, program.getInlineDirectives().getDirectives()); + } + + @Test + public void testUnificationWithArithmeticTerm_SharedVariables() { + InputProgram program = parser.parse("elem(d,1). comUnit(1)." + + "{ gt(A,X,U) } :- elem(A,X), comUnit(U)." + + "assign(U+1,d,D) :- elem(d,D), comUnit(U), not gt(d,D,U+1)." + + "#heuristic assign(U,T,X) : T comUnit(U), T elem(T,X)."); + + program = new ChoiceHeadToNormal().apply(program); + program = new HeuristicDirectiveConditionEnhancement(heuristicsConfiguration).apply(program); + Collection expectedHeuristicDirectives = Collections.singletonList( + programPartParser.parseHeuristicDirective("#heuristic assign(U_1+1,d,X) : T comUnit(U_1), T elem(d,X), T comUnit(U_1+1), not gt(d,X,U_1+1).") + ); + assertEquals(expectedHeuristicDirectives, program.getInlineDirectives().getDirectives()); + } + + @Test + public void testUnificationWithArithmeticTerm() { + InputProgram program = parser.parse("elem(d,1). comUnit(1)." + + "{ gt(A,X,U) } :- elem(A,X), comUnit(U)." + + "assign(U1,d,D) :- elem(d,D), comUnit(U), comUnit(U1), U1=U+1, not gt(d,D,U1)." + + "#heuristic assign(Un,T,X) : T comUnit(Un), T elem(T,X)."); + + program = new ChoiceHeadToNormal().apply(program); + program = new HeuristicDirectiveConditionEnhancement(heuristicsConfiguration).apply(program); + Collection expectedHeuristicDirectives = Collections.singletonList( + programPartParser.parseHeuristicDirective("#heuristic assign(Un,d,X) : T elem(d,X), T comUnit(Un), T comUnit(U), Un=U+1, not gt(d,X,Un).") + ); + assertEquals(expectedHeuristicDirectives, program.getInlineDirectives().getDirectives()); + } + + @Test + public void testUnificationWithFunctionTerm() { + InputProgram program = parser.parse("legacyConfig(cabinetTOthing(1,2)). legacyConfig(roomTOcabinet(3,1))." + + "reuse(cabinetTOthing(X,Y)) :- legacyConfig(cabinetTOthing(X,Y)), not delete(cabinetTOthing(X,Y))." + + "delete(cabinetTOthing(X,Y)) :- legacyConfig(cabinetTOthing(X,Y)), not reuse(cabinetTOthing(X,Y))." + + "reuse(roomTOcabinet(X,Y)) :- legacyConfig(roomTOcabinet(X,Y)), not delete(roomTOcabinet(X,Y))." + + "delete(roomTOcabinet(X,Y)) :- legacyConfig(roomTOcabinet(X,Y)), not reuse(roomTOcabinet(X,Y))." + + "#heuristic reuse(cabinetTOthing(C,T)) : T legacyConfig(cabinetTOthing(C,T)), not thingLong(T)."); + + program = new ChoiceHeadToNormal().apply(program); + program = new HeuristicDirectiveConditionEnhancement(heuristicsConfiguration).apply(program); + Collection expectedHeuristicDirectives = Collections.singletonList( + programPartParser.parseHeuristicDirective("#heuristic reuse(cabinetTOthing(C,T)) : T legacyConfig(cabinetTOthing(C,T)), not TM delete(cabinetTOthing(C,T)), not TM thingLong(T).") + ); + assertEquals(expectedHeuristicDirectives, program.getInlineDirectives().getDirectives()); + } + + @Test + public void testBidirectionalUnificationWithFunctionTerm() { + InputProgram program = parser.parse("b(fn1(1,2),fn2(3,4))." + + "h(Y,fn2(C,D)) :- b(Y,fn2(C,D))." + + "#heuristic h(fn1(A,B),X)."); + + program = new ChoiceHeadToNormal().apply(program); + program = new HeuristicDirectiveConditionEnhancement(heuristicsConfiguration).apply(program); + Collection expectedHeuristicDirectives = Collections.singletonList( + programPartParser.parseHeuristicDirective("#heuristic h(fn1(A,B),fn2(C,D)) : T b(fn1(A,B),fn2(C,D)).") + ); + assertEquals(expectedHeuristicDirectives, program.getInlineDirectives().getDirectives()); + } + + @Test + public void testOtherDirectivesAreUnaffected() { + InputProgram program = parser.parse("#enumeration_predicate_is a."); + program = new ChoiceHeadToNormal().apply(program); + program = new HeuristicDirectiveConditionEnhancement(heuristicsConfiguration).apply(program); + assertEquals(1, program.getInlineDirectives().getDirectives().size()); + assertEquals("a", ((EnumerationDirective)program.getInlineDirectives().getDirectives().iterator().next()).getValue()); + } + + private HeuristicDirective parseHeuristicDirectiveAndAddNegativeLiteral(String strHeuristicDirective, Atom negativeChoiceAtom) { + final HeuristicDirective parsedHeuristicDirective = programPartParser.parseHeuristicDirective(strHeuristicDirective); + final Collection extendedHeuristicDirectiveBodyNegative = new LinkedHashSet<>(parsedHeuristicDirective.getBody().getBodyAtomsNegative()); + extendedHeuristicDirectiveBodyNegative.add(HeuristicDirectiveAtom.body(negativeChoiceAtom)); + final HeuristicDirectiveBody extendedHeuristicDirectiveBody = new HeuristicDirectiveBody(parsedHeuristicDirective.getBody().getBodyAtomsPositive(), extendedHeuristicDirectiveBodyNegative); + return new HeuristicDirective(parsedHeuristicDirective.getHead(), extendedHeuristicDirectiveBody, parsedHeuristicDirective.getWeightAtLevel()); + } + +} diff --git a/src/test/java/at/ac/tuwien/kr/alpha/grounder/transformation/HeuristicDirectiveToRuleTest.java b/src/test/java/at/ac/tuwien/kr/alpha/grounder/transformation/HeuristicDirectiveToRuleTest.java new file mode 100644 index 000000000..59d1b68ed --- /dev/null +++ b/src/test/java/at/ac/tuwien/kr/alpha/grounder/transformation/HeuristicDirectiveToRuleTest.java @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2018-2021 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.grounder.transformation; + +import org.junit.jupiter.api.Test; + +import at.ac.tuwien.kr.alpha.common.program.InputProgram; +import at.ac.tuwien.kr.alpha.grounder.parser.ProgramParser; +import at.ac.tuwien.kr.alpha.solver.heuristics.HeuristicsConfiguration; +import at.ac.tuwien.kr.alpha.solver.heuristics.HeuristicsConfigurationBuilder; + +import static java.util.Collections.emptyList; +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * Tests {@link HeuristicDirectiveToRule}. + */ +public class HeuristicDirectiveToRuleTest { + private final ProgramParser parser = new ProgramParser(); + private final HeuristicsConfiguration heuristicsConfiguration = new HeuristicsConfigurationBuilder().setRespectDomspecHeuristics(true).build(); + + @Test + public void testPositiveDirectiveWithBodyWeightAndLevel() { + InputProgram program = parser.parse("a(1)." + + "{ b(N) } :- a(N)." + + "#heuristic b(N) : a(N). [N@2]"); + + program = new HeuristicDirectiveToRule(heuristicsConfiguration).apply(program); + assertEquals(emptyList(), program.getInlineDirectives().getDirectives()); + assertEquals("_h(N, 2, true, b(N), condpos(tm(a(N))), condneg) :- a(N).", program.getRules().get(program.getRules().size() - 1).toString()); + } + + @Test + public void testNegativeDirectiveWithBodyWeightAndLevel() { + InputProgram program = parser.parse("a(1)." + + "{ b(N) } :- a(N)." + + "#heuristic F b(N) : T a(N), not F b(N). [N@2]"); + + program = new HeuristicDirectiveToRule(heuristicsConfiguration).apply(program); + assertEquals(emptyList(), program.getInlineDirectives().getDirectives()); + assertEquals("_h(N, 2, false, b(N), condpos(t(a(N))), condneg(f(b(N)))) :- a(N).", program.getRules().get(program.getRules().size() - 1).toString()); + } + + @Test + public void testPositiveComparisonAtom() { + InputProgram program = parser.parse("a(1). a(2)." + + "{ b(N) } :- a(N)." + + "#heuristic F b(N) : T a(N), Nm1 = N - 1, not F b(Nm1). [N@2]"); + + program = new HeuristicDirectiveToRule(heuristicsConfiguration).apply(program); + assertEquals(emptyList(), program.getInlineDirectives().getDirectives()); + assertEquals("_h(N, 2, false, b(N), condpos(t(a(N))), condneg(f(b(Nm1)))) :- a(N), Nm1 = N - 1.", program.getRules().get(program.getRules().size() - 1).toString()); + } + + @Test + public void testNegativeComparisonAtom() { + InputProgram program = parser.parse("a(1). a(2)." + + "{ b(N) } :- a(N)." + + "#heuristic F b(N) : T a(N), T b(M), not N < M. [N@2]"); + + program = new HeuristicDirectiveToRule(heuristicsConfiguration).apply(program); + assertEquals(emptyList(), program.getInlineDirectives().getDirectives()); + assertEquals("_h(N, 2, false, b(N), condpos(t(a(N)), t(b(M))), condneg) :- a(N), b(M), not N < M.", program.getRules().get(program.getRules().size() - 1).toString()); + } + +} diff --git a/src/test/java/at/ac/tuwien/kr/alpha/grounder/transformation/SignSetTransformationTest.java b/src/test/java/at/ac/tuwien/kr/alpha/grounder/transformation/SignSetTransformationTest.java new file mode 100644 index 000000000..4054af06b --- /dev/null +++ b/src/test/java/at/ac/tuwien/kr/alpha/grounder/transformation/SignSetTransformationTest.java @@ -0,0 +1,183 @@ +/* + * Copyright (c) 2020-2021 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.grounder.transformation; + +import org.junit.jupiter.api.Test; + +import java.util.Collection; +import java.util.HashSet; +import java.util.Set; + +import at.ac.tuwien.kr.alpha.common.Directive; +import at.ac.tuwien.kr.alpha.common.HeuristicDirective; +import at.ac.tuwien.kr.alpha.common.program.InputProgram; +import at.ac.tuwien.kr.alpha.grounder.parser.InlineDirectives; +import at.ac.tuwien.kr.alpha.grounder.parser.ProgramParser; +import at.ac.tuwien.kr.alpha.grounder.parser.ProgramPartParser; +import at.ac.tuwien.kr.alpha.solver.ThriceTruth; + +import static at.ac.tuwien.kr.alpha.Util.asSet; +import static at.ac.tuwien.kr.alpha.solver.ThriceTruth.FALSE; +import static at.ac.tuwien.kr.alpha.solver.ThriceTruth.MBT; +import static at.ac.tuwien.kr.alpha.solver.ThriceTruth.TRUE; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; + +/** + * Tests {@link SignSetTransformation}. + */ +public class SignSetTransformationTest { + private final ProgramParser parser = new ProgramParser(); + + @Test + public void testPositiveAnySignCondition() { + InputProgram program = parser.parse("a(1)." + + "{ b(N) } :- a(N)." + + "#heuristic b(N) : FMT a(N). [N@2]"); + + final Collection directivesBeforeTransformation = program.getInlineDirectives().getDirectives(InlineDirectives.DIRECTIVE.heuristic); + assertEquals(1, directivesBeforeTransformation.size()); + final HeuristicDirective originalHeuristicDirective = (HeuristicDirective) directivesBeforeTransformation.iterator().next(); + program = new SignSetTransformation().apply(program); + final Collection directivesAfterTransformation = program.getInlineDirectives().getDirectives(InlineDirectives.DIRECTIVE.heuristic); + assertEquals(2, directivesAfterTransformation.size()); + final Set> newSignSets = new HashSet<>(); + for (Directive directive : directivesAfterTransformation) { + final HeuristicDirective heuristicDirective = (HeuristicDirective) directive; + assertEquals(originalHeuristicDirective.getHead(), heuristicDirective.getHead()); + assertEquals(originalHeuristicDirective.getWeightAtLevel(), heuristicDirective.getWeightAtLevel()); + assertNotEquals(originalHeuristicDirective.getBody(), heuristicDirective.getBody()); + newSignSets.add(heuristicDirective.getBody().getBodyAtomsPositive().iterator().next().getSigns()); + } + assertEquals(asSet(asSet(MBT, TRUE), asSet(FALSE)), newSignSets); + } + + @Test + public void testNegativeAnySignCondition() { + InputProgram program = parser.parse("a(1)." + + "{ b(N) } :- a(N)." + + "#heuristic b(N) : a(N), not FTM b(N). [N@2]"); + + final Collection directivesBeforeTransformation = program.getInlineDirectives().getDirectives(InlineDirectives.DIRECTIVE.heuristic); + assertEquals(1, directivesBeforeTransformation.size()); + final HeuristicDirective originalHeuristicDirective = (HeuristicDirective) directivesBeforeTransformation.iterator().next(); + program = new SignSetTransformation().apply(program); + + final Collection directivesAfterTransformation = program.getInlineDirectives().getDirectives(InlineDirectives.DIRECTIVE.heuristic); + assertEquals(1, directivesAfterTransformation.size()); + final HeuristicDirective heuristicDirective = (HeuristicDirective) directivesAfterTransformation.iterator().next(); + assertEquals(originalHeuristicDirective.getHead(), heuristicDirective.getHead()); + assertEquals(originalHeuristicDirective.getWeightAtLevel(), heuristicDirective.getWeightAtLevel()); + assertEquals(originalHeuristicDirective.getBody().getBodyAtomsPositive(), heuristicDirective.getBody().getBodyAtomsPositive()); + assertNotEquals(originalHeuristicDirective.getBody().getBodyAtomsNegative(), heuristicDirective.getBody().getBodyAtomsNegative()); + + assertEquals(2, heuristicDirective.getBody().getBodyAtomsNegative().size()); + assertEquals("TM a(N), not TM b(N), not F b(N)", heuristicDirective.getBody().toString()); + } + + @Test + public void testMultiplePositiveAnySignConditions() { + InputProgram program = parser.parse("a(1). a(2)." + + "{ b(N) } :- a(N)." + + "#heuristic b(N) : FMT a(N), FMT a(Nm1), Nm1=N-1. [N@2]"); + + final Collection directivesBeforeTransformation = program.getInlineDirectives().getDirectives(InlineDirectives.DIRECTIVE.heuristic); + assertEquals(1, directivesBeforeTransformation.size()); + final HeuristicDirective originalHeuristicDirective = (HeuristicDirective) directivesBeforeTransformation.iterator().next(); + program = new SignSetTransformation().apply(program); + final Collection directivesAfterTransformation = program.getInlineDirectives().getDirectives(InlineDirectives.DIRECTIVE.heuristic); + assertEquals(4, directivesAfterTransformation.size()); + + final ProgramPartParser programPartParser = new ProgramPartParser(); + final Collection expected = new HashSet<>(); + expected.add(programPartParser.parseHeuristicDirective("#heuristic b(N) : MT a(N), MT a(Nm1), Nm1=N-1. [N@2]")); + expected.add(programPartParser.parseHeuristicDirective("#heuristic b(N) : MT a(N), F a(Nm1), Nm1=N-1. [N@2]")); + expected.add(programPartParser.parseHeuristicDirective("#heuristic b(N) : F a(N), MT a(Nm1), Nm1=N-1. [N@2]")); + expected.add(programPartParser.parseHeuristicDirective("#heuristic b(N) : F a(N), F a(Nm1), Nm1=N-1. [N@2]")); + assertEquals(expected, new HashSet<>(directivesAfterTransformation)); + } + + @Test + public void testMultipleNegativeAnySignConditions() { + InputProgram program = parser.parse("a(1). a(2)." + + "{ b(N) } :- a(N)." + + "#heuristic b(N) : a(N), not FTM b(N), not FTM b(Nm1), Nm1=N-1. [N@2]"); + + final Collection directivesBeforeTransformation = program.getInlineDirectives().getDirectives(InlineDirectives.DIRECTIVE.heuristic); + assertEquals(1, directivesBeforeTransformation.size()); + program = new SignSetTransformation().apply(program); + + final Collection directivesAfterTransformation = program.getInlineDirectives().getDirectives(InlineDirectives.DIRECTIVE.heuristic); + assertEquals(1, directivesAfterTransformation.size()); + final HeuristicDirective heuristicDirective = (HeuristicDirective) directivesAfterTransformation.iterator().next(); + assertEquals(4, heuristicDirective.getBody().getBodyAtomsNegative().size()); + assertEquals("TM a(N), Nm1 = N - 1, not TM b(N), not F b(N), not TM b(Nm1), not F b(Nm1)", heuristicDirective.getBody().toString()); + } + + /** + * Tests Example 7 from our paper "Domain-Specific Heuristics in Answer Set Programming: A Declarative Non-Monotonic Approach" + */ + @Test + public void testExample7() { + InputProgram program = parser.parse("#heuristic h : FMT a, not FT b."); + + final Collection directivesBeforeTransformation = program.getInlineDirectives().getDirectives(InlineDirectives.DIRECTIVE.heuristic); + assertEquals(1, directivesBeforeTransformation.size()); + program = new SignSetTransformation().apply(program); + + final Collection directivesAfterTransformation = program.getInlineDirectives().getDirectives(InlineDirectives.DIRECTIVE.heuristic); + assertEquals(2, directivesAfterTransformation.size()); + + final ProgramPartParser programPartParser = new ProgramPartParser(); + final Collection expected = new HashSet<>(); + expected.add(programPartParser.parseHeuristicDirective("#heuristic h : F a, not F b, not T b.")); + expected.add(programPartParser.parseHeuristicDirective("#heuristic h : MT a, not F b, not T b.")); + assertEquals(expected, new HashSet<>(directivesAfterTransformation)); + } + + /** + * Tests Example 8 from our paper "Domain-Specific Heuristics in Answer Set Programming: A Declarative Non-Monotonic Approach" + */ + @Test + public void testExample8() { + InputProgram program = parser.parse("#heuristic h : M a, not M b."); + + final Collection directivesBeforeTransformation = program.getInlineDirectives().getDirectives(InlineDirectives.DIRECTIVE.heuristic); + assertEquals(1, directivesBeforeTransformation.size()); + program = new SignSetTransformation().apply(program); + + final Collection directivesAfterTransformation = program.getInlineDirectives().getDirectives(InlineDirectives.DIRECTIVE.heuristic); + assertEquals(3, directivesAfterTransformation.size()); + + final ProgramPartParser programPartParser = new ProgramPartParser(); + final Collection expected = new HashSet<>(); + expected.add(programPartParser.parseHeuristicDirective("#heuristic h : MT a, F b, not T a.")); + expected.add(programPartParser.parseHeuristicDirective("#heuristic h : MT a, T b, not T a.")); + expected.add(programPartParser.parseHeuristicDirective("#heuristic h : MT a, not T a, not F b, not MT b.")); + assertEquals(expected, new HashSet<>(directivesAfterTransformation)); + } + +} diff --git a/src/test/java/at/ac/tuwien/kr/alpha/grounder/transformation/VariableEqualityRemovalTest.java b/src/test/java/at/ac/tuwien/kr/alpha/grounder/transformation/VariableEqualityRemovalTest.java new file mode 100644 index 000000000..f6730bd14 --- /dev/null +++ b/src/test/java/at/ac/tuwien/kr/alpha/grounder/transformation/VariableEqualityRemovalTest.java @@ -0,0 +1,132 @@ +/* + * Copyright (c) 2021 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.grounder.transformation; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.junit.jupiter.api.Test; + +import at.ac.tuwien.kr.alpha.common.WeightAtLevel; +import at.ac.tuwien.kr.alpha.common.atoms.Atom; +import at.ac.tuwien.kr.alpha.common.atoms.BasicAtom; +import at.ac.tuwien.kr.alpha.common.atoms.BasicLiteral; +import at.ac.tuwien.kr.alpha.common.atoms.Literal; +import at.ac.tuwien.kr.alpha.common.program.InputProgram; +import at.ac.tuwien.kr.alpha.common.program.NormalProgram; +import at.ac.tuwien.kr.alpha.common.rule.NormalRule; +import at.ac.tuwien.kr.alpha.common.rule.head.NormalHead; +import at.ac.tuwien.kr.alpha.common.terms.ConstantTerm; +import at.ac.tuwien.kr.alpha.common.terms.FunctionTerm; +import at.ac.tuwien.kr.alpha.common.terms.Term; +import at.ac.tuwien.kr.alpha.grounder.atoms.HeuristicAtom; +import at.ac.tuwien.kr.alpha.grounder.parser.ProgramParser; +import at.ac.tuwien.kr.alpha.grounder.parser.ProgramPartParser; +import at.ac.tuwien.kr.alpha.solver.ThriceTruth; +import at.ac.tuwien.kr.alpha.solver.heuristics.HeuristicsConfiguration; +import at.ac.tuwien.kr.alpha.solver.heuristics.HeuristicsConfigurationBuilder; + +import static at.ac.tuwien.kr.alpha.Util.asSet; +import static at.ac.tuwien.kr.alpha.common.AtomToFunctionTermConverter.toFunctionTerm; +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * Tests {@link VariableEqualityRemoval}. + */ +public class VariableEqualityRemovalTest { + private final ProgramParser parser = new ProgramParser(); + private final ProgramPartParser programPartParser = new ProgramPartParser(); + private final HeuristicsConfiguration heuristicsConfiguration = new HeuristicsConfigurationBuilder().setRespectDomspecHeuristics(true).build(); + + @Test + public void testRemoveEqualityOfVariableInHeuristicRules() { + InputProgram inputProgram = parser.parse("a(1)." + + "b(X) :- a(X), not n_b(X)." + + "n_b(X) :- a(X), not b(X)." + + "#heuristic b(X) : a(X), Y=X. [Y]" + + "#heuristic b(X) : a(X), Y=X+1. [Y]"); + inputProgram = new HeuristicDirectiveToRule(heuristicsConfiguration).apply(inputProgram); + inputProgram = new VariableEqualityRemoval().apply(inputProgram); + NormalProgram program = NormalProgram.fromInputProgram(inputProgram); + + final NormalRule expectedRule1 = changeToHeuristicRule(NormalRule.fromBasicRule(programPartParser.parseBasicRule("h(Y, 0, true, b(Y), condpos(tm(a(Y))), condneg()) :- a(Y)."))); + final NormalRule expectedRule2 = changeToHeuristicRule(NormalRule.fromBasicRule(programPartParser.parseBasicRule("h(Y, 0, true, b(X), condpos(tm(a(X))), condneg()) :- a(X), Y=X+1."))); + final Set expectedHeuristicRules = asSet(expectedRule1, expectedRule2); + + final Set actualHeuristicRules = new HashSet<>(); + for (NormalRule rule : program.getRules()) { + if (rule.isHeuristicRule()) { + actualHeuristicRules.add(rule); + } + } + + assertEquals(expectedHeuristicRules, actualHeuristicRules); + } + + @Test + public void testFunctionTermGeneratedFromAffectedAtom() { + final InputProgram inputProgram = parser.parse("a(1)." + + "h(Y) :- a(X), Y=X."); + + final Set body = inputProgram.getRules().get(0).getBody(); + Atom atomA = null; + for (Literal bodyLiteral : body) { + if (bodyLiteral instanceof BasicLiteral) { + atomA = bodyLiteral.getAtom(); + } + } + + final FunctionTerm functionTerm = toFunctionTerm((BasicAtom) atomA); + final String strFunctionTermBeforeTransformation = functionTerm.toString(); + + new VariableEqualityRemoval().apply(inputProgram); + final String strFunctionTermAfterTransformation = functionTerm.toString(); + + // atom a(X) has changed to a(Y): + assertEquals("a(Y)", atomA.toString()); + // but the function term must not change, because it may be used in an unrelated rule: + assertEquals(strFunctionTermBeforeTransformation, strFunctionTermAfterTransformation); + } + + /** + * Changes the given rule to use {@link HeuristicAtom#PREDICATE} as head predicate, + * because rules with heads of this internal predicate cannot be parsed. + */ + private NormalRule changeToHeuristicRule(NormalRule rule) { + final Atom head = rule.getHeadAtom(); + final List terms = head.getTerms(); + final Term weight = terms.get(0); + final Term level = terms.get(1); + @SuppressWarnings("unchecked") final ConstantTerm sign = (ConstantTerm) terms.get(2); + final FunctionTerm headAtom = (FunctionTerm) terms.get(3); + final FunctionTerm positiveCondition = (FunctionTerm) terms.get(4); + final FunctionTerm negativeCondition = (FunctionTerm) terms.get(5); + final NormalHead modifiedHead = new NormalHead(new HeuristicAtom(new WeightAtLevel(weight, level), ThriceTruth.valueOf(sign.getObject()), headAtom, positiveCondition, negativeCondition)); + return new NormalRule(modifiedHead, rule.getBody()); + } + +} diff --git a/src/test/java/at/ac/tuwien/kr/alpha/grounder/transformation/aggregates/AggregateOperatorNormalizationTest.java b/src/test/java/at/ac/tuwien/kr/alpha/grounder/transformation/aggregates/AggregateOperatorNormalizationTest.java index c76d2f559..adf3a88bc 100644 --- a/src/test/java/at/ac/tuwien/kr/alpha/grounder/transformation/aggregates/AggregateOperatorNormalizationTest.java +++ b/src/test/java/at/ac/tuwien/kr/alpha/grounder/transformation/aggregates/AggregateOperatorNormalizationTest.java @@ -1,9 +1,5 @@ package at.ac.tuwien.kr.alpha.grounder.transformation.aggregates; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - import org.junit.jupiter.api.Test; import at.ac.tuwien.kr.alpha.common.ComparisonOperator; @@ -17,10 +13,14 @@ import at.ac.tuwien.kr.alpha.common.terms.Term; import at.ac.tuwien.kr.alpha.test.util.RuleParser; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class AggregateOperatorNormalizationTest { //@formatter:off - public static final String OPERATOR_NORMALIZATION_GT_POS_ASP = + public static final String OPERATOR_NORMALIZATION_GT_POS_ASP = "bla :- dom(X), X > #count{N : thing(N)}."; public static final String OPERATOR_NORMALIZATION_LT_POS_ASP = "bla :- dom(X), X < #count{N : thing(N)}."; @@ -32,10 +32,17 @@ public class AggregateOperatorNormalizationTest { "bla :- dom(X), not X < #count{N : thing(N)}."; public static final String OPERATOR_NORMALIZATION_NE_NEG_ASP = "bla :- dom(X), not X != #count{N : thing(N)}."; - public static final String OPERATOR_NORMALIZATION_GT_NEG_ASP = + public static final String OPERATOR_NORMALIZATION_GT_NEG_ASP = "bla :- dom(X), not X > #count{N : thing(N)}."; public static final String OPERATOR_NORMALIZATION_GE_NEG_ASP = "bla :- dom(X), not X >= #count{N : thing(N)}."; + /* + * See github issue #311: + * Operator normalization must also make sure that literals with only a right-hand term + * are normalized to left-hand term only (and then operator-normalized if necessary) + */ + public static final String OPERATOR_NORMALIZATION_RIGHT_OP_ONLY = + "bla :- dom(X), #count{N : thing(N)} < X."; //@formatter:on @Test @@ -138,7 +145,10 @@ private static void assertAggregateBoundIncremented(BasicRule sourceRule, BasicR ArithmeticTerm incrementTerm = (ArithmeticTerm) comparisonRightHandTerm; assertEquals(ArithmeticOperator.PLUS, incrementTerm.getArithmeticOperator()); assertEquals(ConstantTerm.getInstance(1), incrementTerm.getRight()); - assertEquals(sourceAggregate.getAtom().getLowerBoundTerm(), incrementTerm.getLeft()); + Term sourceBound = sourceAggregate.getAtom().getLowerBoundTerm() != null ? + sourceAggregate.getAtom().getLowerBoundTerm() + : sourceAggregate.getAtom().getUpperBoundTerm(); + assertEquals(sourceBound, incrementTerm.getLeft()); } } diff --git a/src/test/java/at/ac/tuwien/kr/alpha/solver/AggregatesTest.java b/src/test/java/at/ac/tuwien/kr/alpha/solver/AggregatesTest.java index cd1cc9574..39608f4e2 100644 --- a/src/test/java/at/ac/tuwien/kr/alpha/solver/AggregatesTest.java +++ b/src/test/java/at/ac/tuwien/kr/alpha/solver/AggregatesTest.java @@ -69,19 +69,19 @@ public void aggregateSumEqEmptySetPositive(RegressionTestConfig cfg) { String program = "sum_things(S) :- S = #sum{X : thing(X)}."; assertRegressionTestAnswerSet(cfg, program, "sum_things(0)"); } - + @AggregateRegressionTest public void aggregateSumEqNegativeSum(RegressionTestConfig cfg) { ignoreTestForSimplifiedSumAggregates(cfg); String program = "thing(-1). thing(-2). thing(-3). sum_things(S) :- S = #sum{X : thing(X)}."; assertRegressionTestAnswerSet(cfg, program, "thing(-1), thing(-2), thing(-3), sum_things(-6)"); } - + @AggregateRegressionTest public void aggregateSumEqMixedElementsSum(RegressionTestConfig cfg) { ignoreTestForSimplifiedSumAggregates(cfg); String program = "thing(-1). thing(6). thing(-3). sum_things(S) :- S = #sum{X : thing(X)}."; - assertRegressionTestAnswerSet(cfg, program, "thing(-1), thing(6), thing(-3), sum_things(2)"); + assertRegressionTestAnswerSet(cfg, program, "thing(-1), thing(6), thing(-3), sum_things(2)"); } @AggregateRegressionTest @@ -89,7 +89,7 @@ public void aggregateSumLeEmptySetPositive(RegressionTestConfig cfg) { String program = "zero_leq_sum :- 0 <= #sum{X : thing(X)}."; assertRegressionTestAnswerSet(cfg, program, "zero_leq_sum"); } - + @AggregateRegressionTest public void aggregateSumLeNegativeSum(RegressionTestConfig cfg) { ignoreTestForSimplifiedSumAggregates(cfg); @@ -116,7 +116,7 @@ public void aggregateSumLeNegativeElementsWithChoice(RegressionTestConfig cfg) { "summed_up_thing(-5), summed_up_thing(5)", ""); } - + @AggregateRegressionTest public void aggregateCountLeWithChoicePositive(RegressionTestConfig cfg) { String program = "potential_thing(1..4). " @@ -173,7 +173,7 @@ public void aggregateSumEqWithChoicePositive(RegressionTestConfig cfg) { "thing(2), thing(4), sum_things(6)", "thing(3), thing(4), sum_things(7)"); } - + @AggregateRegressionTest public void aggregateSumEqOverMixedValuesWithChoicePositive(RegressionTestConfig cfg) { ignoreTestForSimplifiedSumAggregates(cfg); diff --git a/src/test/java/at/ac/tuwien/kr/alpha/solver/ChoiceManagerTests.java b/src/test/java/at/ac/tuwien/kr/alpha/solver/ChoiceManagerTests.java index 41094f273..18e8a572e 100644 --- a/src/test/java/at/ac/tuwien/kr/alpha/solver/ChoiceManagerTests.java +++ b/src/test/java/at/ac/tuwien/kr/alpha/solver/ChoiceManagerTests.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2017 Siemens AG + * Copyright (c) 2017-2019 Siemens AG * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -25,14 +25,11 @@ */ package at.ac.tuwien.kr.alpha.solver; -import static at.ac.tuwien.kr.alpha.common.Literals.atomOf; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import java.util.Collection; - import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import java.util.Collection; + import at.ac.tuwien.kr.alpha.api.Alpha; import at.ac.tuwien.kr.alpha.common.AtomStore; import at.ac.tuwien.kr.alpha.common.AtomStoreImpl; @@ -44,8 +41,14 @@ import at.ac.tuwien.kr.alpha.grounder.NaiveGrounder; import at.ac.tuwien.kr.alpha.grounder.atoms.RuleAtom; import at.ac.tuwien.kr.alpha.grounder.parser.ProgramParser; +import at.ac.tuwien.kr.alpha.solver.heuristics.HeuristicsConfiguration; +import at.ac.tuwien.kr.alpha.solver.heuristics.HeuristicsConfigurationBuilder; + +import static at.ac.tuwien.kr.alpha.common.Literals.atomOf; +import static org.junit.jupiter.api.Assertions.assertTrue; public class ChoiceManagerTests { + private final HeuristicsConfiguration heuristicsConfiguration = new HeuristicsConfigurationBuilder().build(); private Grounder grounder; private ChoiceManager choiceManager; private AtomStore atomStore; @@ -58,7 +61,7 @@ public void setUp() { NormalProgram normalProgram = system.normalizeProgram(parsedProgram); InternalProgram internalProgram = InternalProgram.fromNormalProgram(normalProgram); atomStore = new AtomStoreImpl(); - grounder = new NaiveGrounder(internalProgram, atomStore, true); + grounder = new NaiveGrounder(internalProgram, atomStore, heuristicsConfiguration, true); WritableAssignment assignment = new TrailAssignment(atomStore); NoGoodStore store = new NoGoodStoreAlphaRoaming(assignment); choiceManager = new ChoiceManager(assignment, store); diff --git a/src/test/java/at/ac/tuwien/kr/alpha/solver/DefaultSolverChainedBranchingHeuristicsTest.java b/src/test/java/at/ac/tuwien/kr/alpha/solver/DefaultSolverChainedBranchingHeuristicsTest.java new file mode 100644 index 000000000..0cab0850b --- /dev/null +++ b/src/test/java/at/ac/tuwien/kr/alpha/solver/DefaultSolverChainedBranchingHeuristicsTest.java @@ -0,0 +1,106 @@ +/** + * Copyright (c) 2019 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.solver; + +import at.ac.tuwien.kr.alpha.common.Predicate; +import at.ac.tuwien.kr.alpha.common.atoms.BasicAtom; +import at.ac.tuwien.kr.alpha.solver.heuristics.AlphaActiveRuleHeuristic; +import at.ac.tuwien.kr.alpha.solver.heuristics.BerkMin; +import at.ac.tuwien.kr.alpha.solver.heuristics.BerkMinLiteral; +import at.ac.tuwien.kr.alpha.solver.heuristics.ChainedBranchingHeuristics; +import at.ac.tuwien.kr.alpha.solver.heuristics.DependencyDrivenHeuristic; +import at.ac.tuwien.kr.alpha.solver.heuristics.DependencyDrivenPyroHeuristic; +import at.ac.tuwien.kr.alpha.solver.heuristics.DependencyDrivenVSIDS; +import at.ac.tuwien.kr.alpha.solver.heuristics.GeneralizedDependencyDrivenHeuristic; +import at.ac.tuwien.kr.alpha.solver.heuristics.GeneralizedDependencyDrivenPyroHeuristic; +import at.ac.tuwien.kr.alpha.solver.heuristics.NaiveHeuristic; +import at.ac.tuwien.kr.alpha.solver.heuristics.VSIDS; + +import static at.ac.tuwien.kr.alpha.test.util.TestUtils.buildSolverForRegressionTest; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assumptions.assumeTrue; + +/** + * Tests the creation of {@link ChainedBranchingHeuristics} by {@link DefaultSolver}. + */ +public class DefaultSolverChainedBranchingHeuristicsTest { + + private static final String LS = System.lineSeparator(); + private static final BasicAtom ATOM_A = new BasicAtom(Predicate.getInstance("a", 0)); + + @RegressionTest + public void testChainOfBranchingHeuristics(RegressionTestConfig cfg) { + final String testProgram = "a :- not b. " + LS + + "b :- not a. " + LS + + "c :- not d. " + LS + + "d :- not c. " + LS + + "#heuristic a : not b."; + final Solver solver = buildSolverForRegressionTest(testProgram, cfg); + assumeTrue(solver instanceof DefaultSolver); + final DefaultSolver defaultSolver = (DefaultSolver) solver; + assertTrue(defaultSolver.branchingHeuristic instanceof ChainedBranchingHeuristics); + final Class heuristicsClass; + switch (cfg.getBranchingHeuristic()) { + case NAIVE: + heuristicsClass = NaiveHeuristic.class; break; + case BERKMIN: + heuristicsClass = BerkMin.class; break; + case BERKMINLITERAL: + heuristicsClass = BerkMinLiteral.class; break; + case DD: + case DD_SUM: + case DD_AVG: + case DD_MAX: + case DD_MIN: + heuristicsClass = DependencyDrivenHeuristic.class; break; + case DD_PYRO: + heuristicsClass = DependencyDrivenPyroHeuristic.class; break; + case GDD: + case GDD_MAX: + case GDD_SUM: + case GDD_AVG: + case GDD_MIN: + heuristicsClass = GeneralizedDependencyDrivenHeuristic.class; break; + case GDD_PYRO: + heuristicsClass = GeneralizedDependencyDrivenPyroHeuristic.class; break; + case ALPHA_ACTIVE_RULE: + heuristicsClass = AlphaActiveRuleHeuristic.class; break; + case VSIDS: + heuristicsClass = VSIDS.class; break; + case GDD_VSIDS: + heuristicsClass = DependencyDrivenVSIDS.class; break; + default: + throw new IllegalArgumentException("Unknown branching heuristic: " + cfg.getBranchingHeuristic()); + } + if (heuristicsClass == NaiveHeuristic.class) { + assertEquals("ChainedBranchingHeuristics[DomainSpecific, " + heuristicsClass.getSimpleName() + "]", defaultSolver.branchingHeuristic.toString()); + } else { + assertEquals("ChainedBranchingHeuristics[DomainSpecific, " + heuristicsClass.getSimpleName() + ", NaiveHeuristic]", defaultSolver.branchingHeuristic.toString()); + } + } + +} diff --git a/src/test/java/at/ac/tuwien/kr/alpha/solver/DefaultSolverTest.java b/src/test/java/at/ac/tuwien/kr/alpha/solver/DefaultSolverTest.java index 332bc0641..0f2a94c2d 100644 --- a/src/test/java/at/ac/tuwien/kr/alpha/solver/DefaultSolverTest.java +++ b/src/test/java/at/ac/tuwien/kr/alpha/solver/DefaultSolverTest.java @@ -1,15 +1,13 @@ package at.ac.tuwien.kr.alpha.solver; -import static org.junit.jupiter.api.Assertions.assertTrue; +import org.antlr.v4.runtime.CharStreams; +import org.junit.jupiter.api.Test; import java.io.IOException; import java.nio.file.Paths; import java.util.Arrays; import java.util.Optional; -import org.antlr.v4.runtime.CharStreams; -import org.junit.jupiter.api.Test; - import at.ac.tuwien.kr.alpha.api.Alpha; import at.ac.tuwien.kr.alpha.common.AnswerSet; import at.ac.tuwien.kr.alpha.common.program.InputProgram; @@ -17,9 +15,13 @@ import at.ac.tuwien.kr.alpha.grounder.parser.ProgramParser; import at.ac.tuwien.kr.alpha.solver.heuristics.BranchingHeuristicFactory; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class DefaultSolverTest { - - // Detailed reproduction test-case for github issue #239. + + /** + * Detailed reproduction test-case for github issue #239. + */ @Test public void testLearnedUnaryNoGoodCausingOutOfOrderLiteralsConflict() throws IOException { final ProgramParser parser = new ProgramParser(); @@ -27,7 +29,7 @@ public void testLearnedUnaryNoGoodCausingOutOfOrderLiteralsConflict() throws IOE bld.accumulate(parser.parse(CharStreams.fromPath(Paths.get("src", "test", "resources", "HanoiTower_Alpha.asp")))); bld.accumulate(parser.parse(CharStreams.fromPath(Paths.get("src", "test", "resources", "HanoiTower_instances", "simple.asp")))); InputProgram parsedProgram = bld.build(); - + SystemConfig config = new SystemConfig(); config.setSolverName("default"); config.setNogoodStoreName("alpharoaming"); @@ -36,9 +38,45 @@ public void testLearnedUnaryNoGoodCausingOutOfOrderLiteralsConflict() throws IOE config.setDebugInternalChecks(true); config.setDisableJustificationSearch(false); config.setEvaluateStratifiedPart(false); - config.setReplayChoices(Arrays.asList(21, 26, 36, 56, 91, 96, 285, 166, 101, 290, 106, 451, 445, 439, 448, - 433, 427, 442, 421, 415, 436, 409, 430, 397, 391, 424, 385, 379, - 418, 373, 412, 406, 394, 388, 382, 245, 232, 208 + config.setReplayChoices(Arrays.asList(// + 20, //_R_("3","{K->3,N->1,T->0}") + 25, //_R_("3","{K->3,N->1,T->1}") + 35, //_R_("3","{K->3,N->2,T->0}") + 55, //_R_("3","{K->3,N->3,T->1}") + 90, //_R_("3","{K->3,N->5,T->2}") + 95, //_R_("3","{K->3,N->6,T->0}") + 284, //_R_("8","{K->3,N->4,T->0}") + 166, //_R_("4","{K->3,N->2,T->1}") + 100, //_R_("3","{K->3,N->6,T->1}") + 289, //_R_("8","{K->3,N->4,T->1}") + 105, //_R_("3","{K->3,N->6,T->2}") + 451, //_R_("9","{K->3,N->9,T->2}") + 445, //_R_("9","{K->3,N->9,T->0}") + 439, //_R_("9","{K->3,N->8,T->1}") + 448, //_R_("9","{K->3,N->9,T->1}") + 433, //_R_("9","{K->3,N->7,T->2}") + 427, //_R_("9","{K->3,N->7,T->0}") + 442, //_R_("9","{K->3,N->8,T->2}") + 421, //_R_("9","{K->3,N->6,T->1}") + 415, //_R_("9","{K->3,N->5,T->2}") + 436, //_R_("9","{K->3,N->8,T->0}") + 409, //_R_("9","{K->3,N->5,T->0}") + 430, //_R_("9","{K->3,N->7,T->1}") + 397, //_R_("9","{K->3,N->3,T->2}") + 391, //_R_("9","{K->3,N->3,T->0}") + 424, //_R_("9","{K->3,N->6,T->2}") + 385, //_R_("9","{K->3,N->2,T->1}") + 379, //_R_("9","{K->3,N->1,T->2}") + 418, //_R_("9","{K->3,N->6,T->0}") + 373, //_R_("9","{K->3,N->1,T->0}") + 412, //_R_("9","{K->3,N->5,T->1}") + 406, //_R_("9","{K->3,N->4,T->2}") + 394, //_R_("9","{K->3,N->3,T->1}") + 388, //_R_("9","{K->3,N->2,T->2}") + 382, //_R_("9","{K->3,N->2,T->0}") + 244, //_R_("8","{K->3,N->1,T->1}") + 232, //_R_("4","{K->3,N->9,T->2}") + 208 //_R_("4","{K->3,N->7,T->0}") )); Alpha alpha = new Alpha(config); Optional answerSet = alpha.solve(parsedProgram).findFirst(); diff --git a/src/test/java/at/ac/tuwien/kr/alpha/solver/HouseTest.java b/src/test/java/at/ac/tuwien/kr/alpha/solver/HouseTest.java new file mode 100644 index 000000000..b82ea7186 --- /dev/null +++ b/src/test/java/at/ac/tuwien/kr/alpha/solver/HouseTest.java @@ -0,0 +1,278 @@ +/* + * Copyright (c) 2018-2021 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.solver; + +import org.antlr.v4.runtime.CharStreams; +import org.junit.jupiter.api.Disabled; + +import java.io.IOException; +import java.nio.file.Paths; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Optional; +import java.util.Set; +import java.util.SortedSet; +import java.util.stream.Collectors; + +import at.ac.tuwien.kr.alpha.common.AnswerSet; +import at.ac.tuwien.kr.alpha.common.Predicate; +import at.ac.tuwien.kr.alpha.common.atoms.Atom; +import at.ac.tuwien.kr.alpha.common.program.InputProgram; +import at.ac.tuwien.kr.alpha.common.terms.ConstantTerm; +import at.ac.tuwien.kr.alpha.common.terms.FunctionTerm; +import at.ac.tuwien.kr.alpha.grounder.parser.ProgramParser; +import at.ac.tuwien.kr.alpha.test.util.TestUtils; + +import static at.ac.tuwien.kr.alpha.test.util.TestUtils.ignoreTestForNaiveSolver; +import static at.ac.tuwien.kr.alpha.test.util.TestUtils.ignoreTestForNonDefaultDomainIndependentHeuristics; +import static at.ac.tuwien.kr.alpha.test.util.TestUtils.runWithTimeout; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + +/** + * Tests {@link AbstractSolver} using some HRP (House Reconfiguration Problem) test cases. + * + */ +public class HouseTest { + private final ProgramParser parser = new ProgramParser(); + + private static final int DEBUG_TIMEOUT_FACTOR = 5; + + @RegressionTest + public void testHouse_emptyconfig_p05t025(RegressionTestConfig cfg) throws IOException { + long timeout = 60000L; + // test only on one heuristics to save resources during CI + ignoreTestForNaiveSolver(cfg); + ignoreTestForNonDefaultDomainIndependentHeuristics(cfg); + runWithTimeout(cfg, timeout, DEBUG_TIMEOUT_FACTOR, () -> testHouse("emptyconfig_p05t025", cfg)); + } + + @RegressionTest + @Disabled("disabled to save resources during CI") + public void testHouse_emptyconfig_p10t050(RegressionTestConfig cfg) throws IOException { + long timeout = 60000L; + // test only on one heuristics to save resources during CI + ignoreTestForNaiveSolver(cfg); + ignoreTestForNonDefaultDomainIndependentHeuristics(cfg); + runWithTimeout(cfg, timeout, DEBUG_TIMEOUT_FACTOR, () -> testHouse("emptyconfig_p10t050", cfg)); + } + + @RegressionTest + @Disabled("disabled to save resources during CI") + public void testHouse_emptyconfig_p15t075(RegressionTestConfig cfg) throws IOException { + long timeout = 60000L; + // test only on one heuristics to save resources during CI + ignoreTestForNaiveSolver(cfg); + ignoreTestForNonDefaultDomainIndependentHeuristics(cfg); + runWithTimeout(cfg, timeout, DEBUG_TIMEOUT_FACTOR, () -> testHouse("emptyconfig_p15t075", cfg)); + } + + @RegressionTest + @Disabled("disabled to save resources during CI") + public void testHouse_longthings_2_p02t030c3(RegressionTestConfig cfg) throws IOException { + long timeout = 60000L; + // test only on one heuristics to save resources during CI + ignoreTestForNaiveSolver(cfg); + ignoreTestForNonDefaultDomainIndependentHeuristics(cfg); + runWithTimeout(cfg, timeout, DEBUG_TIMEOUT_FACTOR, () -> testHouse("longthings_2_p02t030c3", cfg)); + } + + @RegressionTest + @Disabled("disabled to save resources during CI") + public void testHouse_longthings_newroom_p02t024c3(RegressionTestConfig cfg) throws IOException { + long timeout = 60000L; + // test only on one heuristics to save resources during CI + ignoreTestForNaiveSolver(cfg); + ignoreTestForNonDefaultDomainIndependentHeuristics(cfg); + runWithTimeout(cfg, timeout, DEBUG_TIMEOUT_FACTOR, () -> testHouse("longthings_newroom_p02t024c3", cfg)); + } + + @RegressionTest + @Disabled("disabled to save resources during CI") + public void testHouse_switchthingsize_r02t035(RegressionTestConfig cfg) throws IOException { + long timeout = 60000L; + // test only on one heuristics to save resources during CI + ignoreTestForNaiveSolver(cfg); + ignoreTestForNonDefaultDomainIndependentHeuristics(cfg); + runWithTimeout(cfg, timeout, DEBUG_TIMEOUT_FACTOR, () -> testHouse("switchthingsize_r02t035", cfg)); + } + + private void testHouse(String instanceId, RegressionTestConfig cfg) throws IOException { + + InputProgram parsedProgram = parser + .parse(CharStreams.fromPath(Paths.get("src", "test", "resources", "DomainHeuristics", "House", "house_alpha_2021-02-04.asp"))); + parsedProgram = InputProgram.builder(parsedProgram).accumulate( + parser.parse(CharStreams + .fromPath(Paths.get("src", "test", "resources", "DomainHeuristics", "House", "instances_alpha", instanceId + ".edb")))) + .build(); + + Solver solver = TestUtils.buildSolverForRegressionTest(parsedProgram, cfg); + Optional answerSet = solver.stream().findFirst(); + assertTrue(answerSet.isPresent()); + checkAnswerSet(answerSet.get()); + } + + /** + * Checks the given answer set for the HRP: + *
      + *
    • Each cabinet stores at most 5 things.
    • + *
    • Each room houses at most 4 cabinets.
    • + *
    • Each room houses things of only one persons in its cabinets.
    • + *
    • Long things have to be packed in high cabinets
    • + *
    • At most either 2 high things or 1 high and 2 short or 4 short cabinets are allowed to be in a room
    • + *
    + * + * @param answerSet + */ + private void checkAnswerSet(AnswerSet answerSet) { + Map thingToPersonMapping = getThingToPersonMapping(answerSet); + Map thingToCabinetMapping = getReverseMapping(answerSet, "cabinetTOthing"); + checkEveryThingAssigned(thingToPersonMapping, thingToCabinetMapping); + Map cabinetToRoomMapping = getReverseMapping(answerSet, "roomTOcabinet"); + checkMaxKeysForSameValue(thingToCabinetMapping, 5); + checkMaxKeysForSameValue(cabinetToRoomMapping, 4); + getAndCheckTransitiveMapping(thingToCabinetMapping, cabinetToRoomMapping); + Set longThings = getInstanceTerms(answerSet, "thingLong"); + Set highCabinets = getInstanceTerms(answerSet, "cabinetHigh"); + checkLongThingsInHighCabinets(thingToCabinetMapping, longThings, highCabinets); + checkRoomCapacity(cabinetToRoomMapping, highCabinets); + } + + private void checkEveryThingAssigned(Map thingToPersonMapping, Map thingToCabinetMapping) { + for (Integer thing : thingToPersonMapping.keySet()) { + if (!thingToCabinetMapping.containsKey(thing)) { + fail("Thing " + thing + " not assigned to a cabinet"); + } + } + } + + private Map getThingToPersonMapping(AnswerSet answerSet) { + Map map = new HashMap<>(); + for (Atom lc : answerSet.getPredicateInstances(Predicate.getInstance("legacyConfig", 1))) { + FunctionTerm p2t = (FunctionTerm) lc.getTerms().get(0); + if (p2t.getSymbol().equals("personTOthing")) { + @SuppressWarnings("unchecked") + int person = ((ConstantTerm) p2t.getTerms().get(0)).getObject(); + @SuppressWarnings("unchecked") + int thing = ((ConstantTerm) p2t.getTerms().get(1)).getObject(); + map.put(thing, person); + } + } + return map; + } + + private Map getReverseMapping(AnswerSet answerSet, String predicateName) { + Map map = new HashMap<>(); + for (Atom pair : answerSet.getPredicateInstances(Predicate.getInstance(predicateName, 2))) { + @SuppressWarnings("unchecked") + int o1 = ((ConstantTerm) pair.getTerms().get(0)).getObject(); + @SuppressWarnings("unchecked") + int o2 = ((ConstantTerm) pair.getTerms().get(1)).getObject(); + Integer previousMapping = map.put(o2, o1); + if (previousMapping != null) { + fail("Duplicate mapping: " + predicateName + "(" + o1 + "," + o2 + ")"); + } + } + return map; + } + + private void checkMaxKeysForSameValue(Map mapping, int maxKeys) { + Map> inverseMapping = new HashMap<>(); + for (Entry entry : mapping.entrySet()) { + Integer key = entry.getKey(); + Integer value = entry.getValue(); + Set keys = inverseMapping.get(value); + if (keys == null) { + keys = new HashSet<>(); + inverseMapping.put(value, keys); + } + keys.add(key); + if (keys.size() > maxKeys) { + fail("Too many keys for value " + value); + } + } + } + + private Map getAndCheckTransitiveMapping(Map mapping1, Map mapping2) { + Map result = new HashMap<>(); + for (Entry entry1 : mapping1.entrySet()) { + Integer key1 = entry1.getKey(); + Integer key2 = entry1.getValue(); + Integer value = mapping2.get(key2); + Integer previousMapping = result.put(key1, value); + if (previousMapping != null) { + fail("Duplicate transitive mapping: " + previousMapping); + } + } + return result; + } + + @SuppressWarnings("unchecked") + private Set getInstanceTerms(AnswerSet answerSet, String predicateName) { + SortedSet predicateInstances = answerSet.getPredicateInstances(Predicate.getInstance(predicateName, 1)); + if (predicateInstances == null) { + return Collections.emptySet(); + } + return predicateInstances.stream() + .map(a -> ((ConstantTerm) a.getTerms().get(0)).getObject()).collect(Collectors.toSet()); + } + + private void checkLongThingsInHighCabinets(Map thingToCabinetMapping, Set longThings, Set highCabinets) { + for (Integer longThing : longThings) { + Integer cabinet = thingToCabinetMapping.get(longThing); + if (!highCabinets.contains(cabinet)) { + fail("Long thing " + longThing + " not in high cabinet"); + } + } + } + + private void checkRoomCapacity(Map cabinetToRoomMapping, Set highCabinets) { + final int sizeSmallCabinet = 1; + final int sizeHighCabinet = 2; + final int roomCapacity = 4; + Map roomToUsedCapacity = new HashMap<>(); + for (Entry entry : cabinetToRoomMapping.entrySet()) { + Integer cabinet = entry.getKey(); + Integer room = entry.getValue(); + Integer usedCapacity = roomToUsedCapacity.get(room); + if (usedCapacity == null) { + usedCapacity = 0; + } + if (highCabinets.contains(cabinet)) { + usedCapacity += sizeHighCabinet; + } else { + usedCapacity += sizeSmallCabinet; + } + roomToUsedCapacity.put(room, usedCapacity); + if (usedCapacity > roomCapacity) { + fail("Capacity of room " + room + " exceeded"); + } + } + } +} diff --git a/src/test/java/at/ac/tuwien/kr/alpha/solver/LearnedNoGoodDeletionTest.java b/src/test/java/at/ac/tuwien/kr/alpha/solver/LearnedNoGoodDeletionTest.java index 3a0ffc751..860af7948 100644 --- a/src/test/java/at/ac/tuwien/kr/alpha/solver/LearnedNoGoodDeletionTest.java +++ b/src/test/java/at/ac/tuwien/kr/alpha/solver/LearnedNoGoodDeletionTest.java @@ -27,25 +27,26 @@ */ package at.ac.tuwien.kr.alpha.solver; -import static at.ac.tuwien.kr.alpha.common.NoGoodTest.fromOldLiterals; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertTrue; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Test; - import at.ac.tuwien.kr.alpha.common.AtomStore; import at.ac.tuwien.kr.alpha.common.AtomStoreImpl; import at.ac.tuwien.kr.alpha.common.AtomStoreTest; import at.ac.tuwien.kr.alpha.common.NoGood; +import at.ac.tuwien.kr.alpha.common.NoGoodCreator; import at.ac.tuwien.kr.alpha.common.NoGoodInterface.Type; +import static at.ac.tuwien.kr.alpha.common.NoGoodTest.fromOldLiterals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class LearnedNoGoodDeletionTest { private NoGoodStoreAlphaRoaming store; @@ -91,8 +92,8 @@ public void testDeletionRemovingWatches() { assertFalse(learnedNoGoodDeletion.needToRunNoGoodDeletion()); learnedNoGoodDeletion.increaseConflictCounter(); assertTrue(learnedNoGoodDeletion.needToRunNoGoodDeletion()); - assertNull(store.add(4, NoGood.learnt(fromOldLiterals(10, 11, 12)), 3)); - assertNull(store.add(5, NoGood.learnt(fromOldLiterals(10, -13, -14)), 4)); + assertNull(store.add(4, NoGoodCreator.learnt(fromOldLiterals(10, 11, 12)), 3)); + assertNull(store.add(5, NoGoodCreator.learnt(fromOldLiterals(10, -13, -14)), 4)); List watchedNoGoods = learnedNoGoodDeletion.inspectLearnedNoGoods(); assertTrue(watchedNoGoods.size() >= 2); WatchedNoGood watchedNoGood = watchedNoGoods.get(0); @@ -112,8 +113,8 @@ public void testDeletionIncreasesDeletionCounter() { assertFalse(learnedNoGoodDeletion.needToRunNoGoodDeletion()); learnedNoGoodDeletion.increaseConflictCounter(); assertTrue(learnedNoGoodDeletion.needToRunNoGoodDeletion()); - assertNull(store.add(4, NoGood.learnt(fromOldLiterals(10, 11, 12)), 3)); - assertNull(store.add(5, NoGood.learnt(fromOldLiterals(10, -13, -14)), 4)); + assertNull(store.add(4, NoGoodCreator.learnt(fromOldLiterals(10, 11, 12)), 3)); + assertNull(store.add(5, NoGoodCreator.learnt(fromOldLiterals(10, -13, -14)), 4)); assertEquals(0, learnedNoGoodDeletion.getNumberOfDeletedNoGoods()); learnedNoGoodDeletion.runNoGoodDeletion(); assertTrue(learnedNoGoodDeletion.getNumberOfDeletedNoGoods() > 0); @@ -127,8 +128,8 @@ public void testDeletionReducesNumberOfLearntNoGoods() { assertFalse(learnedNoGoodDeletion.needToRunNoGoodDeletion()); learnedNoGoodDeletion.increaseConflictCounter(); assertTrue(learnedNoGoodDeletion.needToRunNoGoodDeletion()); - assertNull(store.add(4, NoGood.learnt(fromOldLiterals(10, 11, 12)), 3)); - assertNull(store.add(5, NoGood.learnt(fromOldLiterals(10, -13, -14)), 4)); + assertNull(store.add(4, NoGoodCreator.learnt(fromOldLiterals(10, 11, 12)), 3)); + assertNull(store.add(5, NoGoodCreator.learnt(fromOldLiterals(10, -13, -14)), 4)); final Map countersBeforeDeletion = countNoGoodsByType(store); learnedNoGoodDeletion.runNoGoodDeletion(); diff --git a/src/test/java/at/ac/tuwien/kr/alpha/solver/NaiveNoGoodStoreTest.java b/src/test/java/at/ac/tuwien/kr/alpha/solver/NaiveNoGoodStoreTest.java index 6d2ebdbe9..efab66430 100644 --- a/src/test/java/at/ac/tuwien/kr/alpha/solver/NaiveNoGoodStoreTest.java +++ b/src/test/java/at/ac/tuwien/kr/alpha/solver/NaiveNoGoodStoreTest.java @@ -1,7 +1,34 @@ +/** + * Copyright (c) 2017-2019, the Alpha Team. + * All rights reserved. + * + * Additional changes made by Siemens. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package at.ac.tuwien.kr.alpha.solver; -import static at.ac.tuwien.kr.alpha.common.NoGood.fact; -import static at.ac.tuwien.kr.alpha.common.NoGood.headFirst; +import static at.ac.tuwien.kr.alpha.common.NoGoodCreator.fact; +import static at.ac.tuwien.kr.alpha.common.NoGoodCreator.headFirst; import static at.ac.tuwien.kr.alpha.common.NoGoodTest.fromOldLiterals; import static at.ac.tuwien.kr.alpha.solver.AntecedentTest.antecedentsEquals; import static at.ac.tuwien.kr.alpha.solver.ThriceTruth.FALSE; @@ -23,9 +50,6 @@ import at.ac.tuwien.kr.alpha.common.AtomStoreTest; import at.ac.tuwien.kr.alpha.common.NoGood; -/** - * Copyright (c) 2017, the Alpha Team. - */ public class NaiveNoGoodStoreTest { private final AtomStore atomStore; private final TrailAssignment assignment; @@ -37,7 +61,7 @@ public NaiveNoGoodStoreTest() { store = new NaiveNoGoodStore(assignment); } - @BeforeEach + @BeforeEach public void setUp() { store.clear(); AtomStoreTest.fillAtomStore(atomStore, 200); @@ -215,7 +239,7 @@ public void propagateNaryFalse() { assignment.assign(2, FALSE); assignment.assign(3, FALSE); - store.add(1, NoGood.headFirst(fromOldLiterals(-1, -3, -2))); + store.add(1, headFirst(fromOldLiterals(-1, -3, -2))); store.propagate(); assertEquals(TRUE, assignment.getTruth(1)); diff --git a/src/test/java/at/ac/tuwien/kr/alpha/solver/NoGoodStoreAlphaRoamingTest.java b/src/test/java/at/ac/tuwien/kr/alpha/solver/NoGoodStoreAlphaRoamingTest.java index c278f8909..37a239630 100644 --- a/src/test/java/at/ac/tuwien/kr/alpha/solver/NoGoodStoreAlphaRoamingTest.java +++ b/src/test/java/at/ac/tuwien/kr/alpha/solver/NoGoodStoreAlphaRoamingTest.java @@ -1,7 +1,34 @@ +/** + * Copyright (c) 2017-2019, the Alpha Team. + * All rights reserved. + * + * Additional changes made by Siemens. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package at.ac.tuwien.kr.alpha.solver; -import static at.ac.tuwien.kr.alpha.common.NoGood.fact; -import static at.ac.tuwien.kr.alpha.common.NoGood.headFirst; +import static at.ac.tuwien.kr.alpha.common.NoGoodCreator.fact; +import static at.ac.tuwien.kr.alpha.common.NoGoodCreator.headFirst; import static at.ac.tuwien.kr.alpha.common.NoGoodTest.fromOldLiterals; import static at.ac.tuwien.kr.alpha.solver.AntecedentTest.antecedentsEquals; import static at.ac.tuwien.kr.alpha.solver.ThriceTruth.FALSE; @@ -23,9 +50,6 @@ import at.ac.tuwien.kr.alpha.common.AtomStoreTest; import at.ac.tuwien.kr.alpha.common.NoGood; -/** - * Copyright (c) 2017, the Alpha Team. - */ public class NoGoodStoreAlphaRoamingTest { private final AtomStore atomStore; diff --git a/src/test/java/at/ac/tuwien/kr/alpha/solver/PartSubpartConfigurationTest.java b/src/test/java/at/ac/tuwien/kr/alpha/solver/PartSubpartConfigurationTest.java index d421de949..9e5b32bb2 100644 --- a/src/test/java/at/ac/tuwien/kr/alpha/solver/PartSubpartConfigurationTest.java +++ b/src/test/java/at/ac/tuwien/kr/alpha/solver/PartSubpartConfigurationTest.java @@ -32,7 +32,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import java.util.stream.Collectors; import org.junit.jupiter.api.Disabled; @@ -41,9 +40,9 @@ * */ public class PartSubpartConfigurationTest { - + private static final int DEBUG_TIMEOUT_FACTOR = 5; - + @RegressionTest public void testN2(RegressionTestConfig cfg) { long timeout = 1000L; @@ -122,6 +121,6 @@ private void testPartSubpart(int n, RegressionTestConfig cfg) { private String concat(List rules) { String ls = System.lineSeparator(); - return rules.stream().collect(Collectors.joining(ls)); + return String.join(ls, rules); } } diff --git a/src/test/java/at/ac/tuwien/kr/alpha/solver/PartnerUnitsTest.java b/src/test/java/at/ac/tuwien/kr/alpha/solver/PartnerUnitsTest.java new file mode 100644 index 000000000..514a4c211 --- /dev/null +++ b/src/test/java/at/ac/tuwien/kr/alpha/solver/PartnerUnitsTest.java @@ -0,0 +1,226 @@ +/* + * Copyright (c) 2018, 2020 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.solver; + +import org.antlr.v4.runtime.CharStreams; +import org.apache.commons.lang3.tuple.Pair; +import org.junit.jupiter.api.Disabled; + +import java.io.IOException; +import java.nio.file.Paths; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.stream.Collectors; + +import at.ac.tuwien.kr.alpha.common.AnswerSet; +import at.ac.tuwien.kr.alpha.common.Predicate; +import at.ac.tuwien.kr.alpha.common.atoms.Atom; +import at.ac.tuwien.kr.alpha.common.program.InputProgram; +import at.ac.tuwien.kr.alpha.common.terms.ConstantTerm; +import at.ac.tuwien.kr.alpha.grounder.parser.ProgramParser; + +import static at.ac.tuwien.kr.alpha.test.util.TestUtils.buildSolverForRegressionTest; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; + +/** + * Tests {@link AbstractSolver} using some partner units test cases. + * + */ +public class PartnerUnitsTest { + private final ProgramParser parser = new ProgramParser(); + + @RegressionTest + public void testPartnerUnits_generated_003(RegressionTestConfig cfg) throws IOException { + testPartnerUnits_generated("simple003_bf_startZ1.asp", cfg); + } + + @RegressionTest + @Disabled("ignore to save resources during CI") + public void testPartnerUnits_generated_010(RegressionTestConfig cfg) throws IOException { + testPartnerUnits_generated("simple010_bf_startZ1.asp", cfg); + } + + @RegressionTest + @Disabled("ignore to save resources during CI") + public void testPartnerUnits_generated_020(RegressionTestConfig cfg) throws IOException { + testPartnerUnits_generated("simple020_bf_startZ1.asp", cfg); + } + + @RegressionTest + @Disabled("ignore to save resources during CI") + public void testPartnerUnits_generated_030(RegressionTestConfig cfg) throws IOException { + testPartnerUnits_generated("simple030_bf_startZ1.asp", cfg); + } + + private void testPartnerUnits_generated(String instanceId, RegressionTestConfig cfg) throws IOException { + InputProgram parsedProgram = parser + .parse(CharStreams.fromPath(Paths.get("src", "test", "resources", "DomainHeuristics", "PartnerUnits", "pup.alpha_heu_20210205.asp"))); + parsedProgram = InputProgram.builder(parsedProgram) + .accumulate(parser.parse(CharStreams + .fromPath(Paths.get("src", "test", "resources", "DomainHeuristics", "PartnerUnits", "instances", "generated", instanceId)))) + .build(); + + Solver solver = buildSolverForRegressionTest(parsedProgram, cfg); + Optional answerSet = solver.stream().findFirst(); + assertTrue(answerSet.isPresent()); + checkAnswerSet(answerSet.get()); + } + + /** + * Checks the given answer set for the partner units problem: + *
      + *
    • Each zone and sensor is connected to exactly one unit.
    • + *
    • Each unit is connected to at most UCAP zones, UCAP sensors, and IUCAP partner units.
    • + *
    • If any related sensor and zone are connected to different units, then these two units must be partner units.
    • + *
    + * In the present implementation, UCAP = 2 is fixated and maxPU(IUCAP) is given in the answer set. + * + * @param answerSet + */ + private void checkAnswerSet(AnswerSet answerSet) { + final int ucap = 2; + final int iucap = findIUCAP(answerSet); + Set> zone2sensorAssignments = getZone2sensorAssignments(answerSet); + + Map zoneToUnit = new HashMap<>(); + Map sensorToUnit = new HashMap<>(); + Map unitToNZones = new HashMap<>(); + Map unitToNSensors = new HashMap<>(); + + for (Atom assign : answerSet.getPredicateInstances(Predicate.getInstance("assign", 3))) { + if (assignsZone(assign)) { + addAndCheckUnitToElement(assign, zoneToUnit, unitToNZones, ucap); + } else if (assignsSensor(assign)) { + addAndCheckUnitToElement(assign, sensorToUnit, unitToNSensors, ucap); + } else { + fail("Unknown assign: " + assign); + } + } + checkAtLeastOneUnitPerElement(getZones(zone2sensorAssignments), zoneToUnit); + checkAtLeastOneUnitPerElement(getSensors(zone2sensorAssignments), sensorToUnit); + + Map> unitToPartnerUnits = new HashMap<>(); + for (Atom partnerunits : answerSet.getPredicateInstances(Predicate.getInstance("partnerunits", 2))) { + addAndCheckPartnerUnits(partnerunits, unitToPartnerUnits, iucap); + } + + checkPartnerUnits(zone2sensorAssignments, zoneToUnit, sensorToUnit, unitToPartnerUnits); + } + + @SuppressWarnings("unchecked") + private int findIUCAP(AnswerSet answerSet) { + return ((ConstantTerm) answerSet.getPredicateInstances(Predicate.getInstance("maxPU", 1)).first().getTerms().get(0)).getObject(); + } + + private boolean assignsZone(Atom assign) { + return assignsElement(assign, "z"); + } + + private boolean assignsSensor(Atom assign) { + return assignsElement(assign, "s"); + } + + private boolean assignsElement(Atom assign, String elementType) { + return "assign".equals(assign.getPredicate().getName()) && elementType.equals(assign.getTerms().get(1).toString()); + } + + @SuppressWarnings("unchecked") + private void addAndCheckUnitToElement(Atom assign, Map elementToUnit, Map unitToNElements, int ucap) { + int unit = ((ConstantTerm) assign.getTerms().get(0)).getObject(); + int element = ((ConstantTerm) assign.getTerms().get(2)).getObject(); + if (elementToUnit.containsKey(element) && !elementToUnit.get(element).equals(unit)) { + fail("Element assigned to more than one unit: " + element); // TODO: print element type + } else { + elementToUnit.put(element, unit); + } + int nElements = unitToNElements.getOrDefault(unit, 0) + 1; + if (nElements > ucap) { + fail("Unit assigned to more than UCAP elements: " + unit); + } + unitToNElements.put(unit, nElements); + } + + @SuppressWarnings("unchecked") + private void addAndCheckPartnerUnits(Atom partnerunits, Map> unitToPartnerUnits, int iucap) { + int unit1 = ((ConstantTerm) partnerunits.getTerms().get(0)).getObject(); + int unit2 = ((ConstantTerm) partnerunits.getTerms().get(1)).getObject(); + addAndCheckPartnerUnits(unit1, unit2, unitToPartnerUnits, iucap); + addAndCheckPartnerUnits(unit2, unit1, unitToPartnerUnits, iucap); + } + + private void addAndCheckPartnerUnits(int unit1, int unit2, Map> unitToPartnerUnits, int iucap) { + unitToPartnerUnits.putIfAbsent(unit1, new HashSet<>()); + Set partnerUnits = unitToPartnerUnits.get(unit1); + partnerUnits.add(unit2); + if (partnerUnits.size() > iucap) { + fail("Unit has more than IUCAP partner units: " + unit1 + " -> " + partnerUnits); + } + } + + @SuppressWarnings("unchecked") + private Set> getZone2sensorAssignments(AnswerSet answerSet) { + return answerSet.getPredicateInstances(Predicate.getInstance("zone2sensor", 2)).stream() + .map(z2s -> Pair.of( + ((ConstantTerm) z2s.getTerms().get(0)).getObject(), + ((ConstantTerm) z2s.getTerms().get(1)).getObject())) + .collect(Collectors.toSet()); + } + + private void checkPartnerUnits(Set> zone2sensorAssignments, Map zoneToUnit, Map sensorToUnit, + Map> unitToPartnerUnits) { + for (Pair zone2sensor : zone2sensorAssignments) { + int zone = zone2sensor.getLeft(); + int sensor = zone2sensor.getRight(); + int zoneUnit = zoneToUnit.get(zone); + int sensorUnit = sensorToUnit.get(sensor); + if (zoneUnit != sensorUnit) { + if (!unitToPartnerUnits.get(zoneUnit).contains(sensorUnit)) { + fail(String.format("Unit %d of sensor %d is not a partner unit of unit %d of connected zone %d", sensorUnit, sensor, zoneUnit, zone)); + } + } + } + } + + private Set getZones(Set> zone2sensorAssignments) { + return zone2sensorAssignments.stream().map(Pair::getLeft).collect(Collectors.toSet()); + } + + private Set getSensors(Set> zone2sensorAssignments) { + return zone2sensorAssignments.stream().map(Pair::getRight).collect(Collectors.toSet()); + } + + private void checkAtLeastOneUnitPerElement(Set elements, Map elementToUnit) { + for (Integer element : elements) { + if (!elementToUnit.containsKey(element)) { + fail("Element has no unit: " + element); // TODO: print element type + } + } + } +} diff --git a/src/test/java/at/ac/tuwien/kr/alpha/solver/PigeonHoleTest.java b/src/test/java/at/ac/tuwien/kr/alpha/solver/PigeonHoleTest.java index aa2c53f87..21f91779d 100644 --- a/src/test/java/at/ac/tuwien/kr/alpha/solver/PigeonHoleTest.java +++ b/src/test/java/at/ac/tuwien/kr/alpha/solver/PigeonHoleTest.java @@ -43,9 +43,9 @@ * Tests {@link AbstractSolver} using some pigeon-hole test cases (see https://en.wikipedia.org/wiki/Pigeonhole_principle). */ public class PigeonHoleTest { - + private static final long DEBUG_TIMEOUT_FACTOR = 5; - + @RegressionTest public void test2Pigeons2Holes(RegressionTestConfig cfg) { long timeout = 5000L; diff --git a/src/test/java/at/ac/tuwien/kr/alpha/solver/SolverTests.java b/src/test/java/at/ac/tuwien/kr/alpha/solver/SolverTests.java index efc60d417..ec63752bc 100644 --- a/src/test/java/at/ac/tuwien/kr/alpha/solver/SolverTests.java +++ b/src/test/java/at/ac/tuwien/kr/alpha/solver/SolverTests.java @@ -1,5 +1,5 @@ -/** - * Copyright (c) 2016, the Alpha Team. +/* + * Copyright (c) 2016-2018, 2020, the Alpha Team. * All rights reserved. * * Additional changes made by Siemens. @@ -27,15 +27,6 @@ */ package at.ac.tuwien.kr.alpha.solver; -import static at.ac.tuwien.kr.alpha.test.util.TestUtils.assertRegressionTestAnswerSet; -import static at.ac.tuwien.kr.alpha.test.util.TestUtils.assertRegressionTestAnswerSets; -import static at.ac.tuwien.kr.alpha.test.util.TestUtils.assertRegressionTestAnswerSetsWithBase; -import static at.ac.tuwien.kr.alpha.test.util.TestUtils.buildSolverForRegressionTest; -import static at.ac.tuwien.kr.alpha.test.util.TestUtils.collectRegressionTestAnswerSets; -import static java.util.Collections.singleton; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - import java.util.Collections; import java.util.HashSet; import java.util.List; @@ -56,8 +47,17 @@ import at.ac.tuwien.kr.alpha.grounder.parser.InlineDirectives; import at.ac.tuwien.kr.alpha.test.util.AnswerSetsParser; +import static at.ac.tuwien.kr.alpha.test.util.TestUtils.assertRegressionTestAnswerSet; +import static at.ac.tuwien.kr.alpha.test.util.TestUtils.assertRegressionTestAnswerSets; +import static at.ac.tuwien.kr.alpha.test.util.TestUtils.assertRegressionTestAnswerSetsWithBase; +import static at.ac.tuwien.kr.alpha.test.util.TestUtils.buildSolverForRegressionTest; +import static at.ac.tuwien.kr.alpha.test.util.TestUtils.collectRegressionTestAnswerSets; +import static java.util.Collections.singleton; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class SolverTests { - + private static class Thingy implements Comparable { @Override public String toString() { @@ -90,7 +90,7 @@ public void testObjectProgram(RegressionTestConfig cfg) { @RegressionTest public void testFactsOnlyProgram(RegressionTestConfig cfg) { assertRegressionTestAnswerSet( - cfg, + cfg, "p(a). p(b). foo(13). foo(16). q(a). q(c).", "q(a), q(c), p(a), p(b), foo(13), foo(16)" @@ -100,7 +100,7 @@ public void testFactsOnlyProgram(RegressionTestConfig cfg) { @RegressionTest public void testSimpleRule(RegressionTestConfig cfg) { assertRegressionTestAnswerSet( - cfg, + cfg, "p(a). p(b). r(X) :- p(X).", "p(a), p(b), r(a), r(b)" @@ -110,7 +110,7 @@ public void testSimpleRule(RegressionTestConfig cfg) { @RegressionTest public void testSimpleRuleWithGroundPart(RegressionTestConfig cfg) { assertRegressionTestAnswerSet( - cfg, + cfg, "p(1)." + "p(2)." + "q(X) :- p(X), p(1).", @@ -122,7 +122,7 @@ public void testSimpleRuleWithGroundPart(RegressionTestConfig cfg) { @RegressionTest public void testProgramZeroArityPredicates(RegressionTestConfig cfg) { assertRegressionTestAnswerSet( - cfg, + cfg, "a. p(X) :- b, r(X).", "a" @@ -230,7 +230,7 @@ public void builtinAtomsGroundRule(RegressionTestConfig cfg) { @RegressionTest public void choiceProgramConstraintSimple(RegressionTestConfig cfg) { assertRegressionTestAnswerSet( - cfg, + cfg, "fact(a).\n" + "choice(either, X) :- fact(X), not choice(or, X).\n" + "choice(or, X) :- fact(X), not choice(either, X).\n" + @@ -243,7 +243,7 @@ public void choiceProgramConstraintSimple(RegressionTestConfig cfg) { @RegressionTest public void choiceProgramConstraintSimple2(RegressionTestConfig cfg) { assertRegressionTestAnswerSet( - cfg, + cfg, "fact(a).\n" + "desired(either).\n" + "choice(either, X) :- fact(X), not choice(or, X).\n" + @@ -364,7 +364,7 @@ public void testUnsatisfiableProgram(RegressionTestConfig cfg) { @RegressionTest public void testFunctionTermEquality(RegressionTestConfig cfg) { assertRegressionTestAnswerSet( - cfg, + cfg, "r1(f(a,b)). r2(f(a,b)). a :- r1(X), r2(Y), X = Y.", "r1(f(a,b)), r2(f(a,b)), a" @@ -451,7 +451,7 @@ public void choiceConstraintsInequality(RegressionTestConfig cfg) { "nassign(l9,r4)" ); } - + @RegressionTest public void sameVariableTwiceInAtom(RegressionTestConfig cfg) { assertRegressionTestAnswerSets( @@ -497,7 +497,7 @@ public void noPositiveCycleSelfFoundingChoice(RegressionTestConfig cfg) { @RegressionTest public void conflictFromUnaryNoGood(RegressionTestConfig cfg) { assertRegressionTestAnswerSet( - cfg, + cfg, "d(b)." + "sel(X) :- not nsel(X), d(X)." + "nsel(X) :- not sel(X), d(X)." + @@ -605,7 +605,7 @@ public void intervalInFunctionTermsInRules(RegressionTestConfig cfg) { @RegressionTest public void groundAtomInRule(RegressionTestConfig cfg) { assertRegressionTestAnswerSet( - cfg, + cfg, "p :- dom(X), q, q2." + "dom(1)." + "q :- not nq." + @@ -673,7 +673,7 @@ public void doubleChoiceRule(RegressionTestConfig cfg) { @RegressionTest public void simpleArithmetics(RegressionTestConfig cfg) { assertRegressionTestAnswerSet( - cfg, + cfg, "eight(X) :- X = 4 + 5 - 1." + "three(X) :- X = Z, Y = 1..10, Z = Y / 3, Z > 2, Z < 4.", @@ -683,7 +683,7 @@ public void simpleArithmetics(RegressionTestConfig cfg) { @RegressionTest public void arithmeticsMultiplicationBeforeAddition(RegressionTestConfig cfg) { assertRegressionTestAnswerSet( - cfg, + cfg, "seven(X) :- 1+2 * 3 = X.", "seven(7)"); @@ -695,7 +695,7 @@ public void arithmeticsMultiplicationBeforeAddition(RegressionTestConfig cfg) { @RegressionTest public void involvedUnsatisfiableProgram(RegressionTestConfig cfg) { assertRegressionTestAnswerSets( - cfg, + cfg, "x :- c1, c2, not x." + "c1 :- not a1." + "c1 :- not b1." + diff --git a/src/test/java/at/ac/tuwien/kr/alpha/solver/heuristics/AlphaHeuristicTestAssumptions.java b/src/test/java/at/ac/tuwien/kr/alpha/solver/heuristics/AlphaHeuristicTestAssumptions.java index 4b1555253..744d9073f 100644 --- a/src/test/java/at/ac/tuwien/kr/alpha/solver/heuristics/AlphaHeuristicTestAssumptions.java +++ b/src/test/java/at/ac/tuwien/kr/alpha/solver/heuristics/AlphaHeuristicTestAssumptions.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2017-2018 Siemens AG + * Copyright (c) 2017-2019 Siemens AG * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -55,11 +55,10 @@ * Tests assumptions made by {@link DependencyDrivenHeuristic} and other domain-independent heuristics. * Even if these test cases do not test {@link DependencyDrivenHeuristic} directly, * it will break if these test cases break. - * - * Copyright (c) 2017-2018 Siemens AG * */ public class AlphaHeuristicTestAssumptions { + private final HeuristicsConfiguration heuristicsConfiguration = new HeuristicsConfigurationBuilder().build(); private Grounder grounder; private WritableAssignment assignment; private TestableChoiceManager choiceManager; @@ -78,7 +77,7 @@ public void setUp() { NormalProgram normal = system.normalizeProgram(parsedProgram); InternalProgram internalProgram = InternalProgram.fromNormalProgram(normal); atomStore = new AtomStoreImpl(); - grounder = new NaiveGrounder(internalProgram, atomStore, true); + grounder = new NaiveGrounder(internalProgram, atomStore, heuristicsConfiguration, true); assignment = new TrailAssignment(atomStore); choiceManager = new TestableChoiceManager(assignment, new NaiveNoGoodStore(assignment)); } diff --git a/src/test/java/at/ac/tuwien/kr/alpha/solver/heuristics/BerkMinTest.java b/src/test/java/at/ac/tuwien/kr/alpha/solver/heuristics/BerkMinTest.java index d74272b4f..cd5266ca2 100644 --- a/src/test/java/at/ac/tuwien/kr/alpha/solver/heuristics/BerkMinTest.java +++ b/src/test/java/at/ac/tuwien/kr/alpha/solver/heuristics/BerkMinTest.java @@ -1,5 +1,5 @@ /** - * Copyright (c) 2016-2018 Siemens AG + * Copyright (c) 2016-2019 Siemens AG * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -35,10 +35,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import at.ac.tuwien.kr.alpha.common.AtomStore; -import at.ac.tuwien.kr.alpha.common.AtomStoreImpl; -import at.ac.tuwien.kr.alpha.common.AtomStoreTest; -import at.ac.tuwien.kr.alpha.common.NoGood; +import at.ac.tuwien.kr.alpha.common.*; import at.ac.tuwien.kr.alpha.solver.NaiveNoGoodStore; import at.ac.tuwien.kr.alpha.solver.TrailAssignment; import at.ac.tuwien.kr.alpha.solver.WritableAssignment; @@ -179,7 +176,7 @@ public void reachDecayPeriodTwice() { @Test public void learnNoGood() { - NoGood learnedNoGood = NoGood.learnt(fromOldLiterals(1, 2)); + NoGood learnedNoGood = NoGoodCreator.learnt(fromOldLiterals(1, 2)); int backjumpLevel = 1; @SuppressWarnings("unused") boolean clearLastChoiceAfterBackjump = true; diff --git a/src/test/java/at/ac/tuwien/kr/alpha/solver/heuristics/BranchingHeuristicFactoryTest.java b/src/test/java/at/ac/tuwien/kr/alpha/solver/heuristics/BranchingHeuristicFactoryTest.java index 34080fd57..5ae99b002 100644 --- a/src/test/java/at/ac/tuwien/kr/alpha/solver/heuristics/BranchingHeuristicFactoryTest.java +++ b/src/test/java/at/ac/tuwien/kr/alpha/solver/heuristics/BranchingHeuristicFactoryTest.java @@ -59,8 +59,8 @@ public void setUp() { @Test public void testChainedHeuristicWithReplay() { - HeuristicsConfigurationBuilder builder = new HeuristicsConfigurationBuilder().setHeuristic(BranchingHeuristicFactory.Heuristic.VSIDS).setReplayChoices(Arrays.asList(1, 2, 3)); - BranchingHeuristic branchingHeuristic = BranchingHeuristicFactory.getInstance(builder.build(), null, null, choiceManager, null); + HeuristicsConfigurationBuilder builder = new HeuristicsConfigurationBuilder().setRespectDomspecHeuristics(false).setHeuristic(BranchingHeuristicFactory.Heuristic.VSIDS).setReplayChoices(Arrays.asList(1, 2, 3)); + BranchingHeuristic branchingHeuristic = BranchingHeuristicFactory.getInstance(builder.build(), null, choiceManager, null); assertEquals(ChainedBranchingHeuristics.class, branchingHeuristic.getClass()); assertTrue(branchingHeuristic instanceof ChainedBranchingHeuristics, "Unexpected type of branchingHeuristic: " + branchingHeuristic.getClass()); assertEquals(ChainedBranchingHeuristics.class.getSimpleName() + "[" + ReplayHeuristic.class.getSimpleName() + ", " + VSIDS.class.getSimpleName() + "]", branchingHeuristic.toString()); @@ -68,8 +68,8 @@ public void testChainedHeuristicWithReplay() { @Test public void testChainedHeuristicWithoutReplay() { - HeuristicsConfigurationBuilder builder = new HeuristicsConfigurationBuilder().setHeuristic(BranchingHeuristicFactory.Heuristic.VSIDS).setReplayChoices(null); - BranchingHeuristic branchingHeuristic = BranchingHeuristicFactory.getInstance(builder.build(), null, null, choiceManager, null); + HeuristicsConfigurationBuilder builder = new HeuristicsConfigurationBuilder().setRespectDomspecHeuristics(false).setHeuristic(BranchingHeuristicFactory.Heuristic.VSIDS).setReplayChoices(null); + BranchingHeuristic branchingHeuristic = BranchingHeuristicFactory.getInstance(builder.build(), null, choiceManager, null); assertEquals(VSIDS.class, branchingHeuristic.getClass()); } diff --git a/src/test/java/at/ac/tuwien/kr/alpha/solver/heuristics/ChainedBranchingHeuristicsTest.java b/src/test/java/at/ac/tuwien/kr/alpha/solver/heuristics/ChainedBranchingHeuristicsTest.java new file mode 100644 index 000000000..c99772d10 --- /dev/null +++ b/src/test/java/at/ac/tuwien/kr/alpha/solver/heuristics/ChainedBranchingHeuristicsTest.java @@ -0,0 +1,118 @@ +/** + * Copyright (c) 2019 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.solver.heuristics; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import java.util.HashSet; +import java.util.Map; +import java.util.Random; +import java.util.Set; + +import at.ac.tuwien.kr.alpha.common.AtomStore; +import at.ac.tuwien.kr.alpha.common.AtomStoreImpl; +import at.ac.tuwien.kr.alpha.common.AtomStoreTest; +import at.ac.tuwien.kr.alpha.common.Literals; +import at.ac.tuwien.kr.alpha.common.NoGood; +import at.ac.tuwien.kr.alpha.common.Predicate; +import at.ac.tuwien.kr.alpha.common.atoms.Atom; +import at.ac.tuwien.kr.alpha.common.atoms.BasicAtom; +import at.ac.tuwien.kr.alpha.common.terms.ConstantTerm; +import at.ac.tuwien.kr.alpha.solver.NaiveNoGoodStore; +import at.ac.tuwien.kr.alpha.solver.TrailAssignment; +import at.ac.tuwien.kr.alpha.solver.WritableAssignment; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * Tests {@link ChainedBranchingHeuristics}. + */ +public class ChainedBranchingHeuristicsTest { + + private static final Atom ATOM_A0 = new BasicAtom(Predicate.getInstance("a", 1), ConstantTerm.getInstance(0)); + + private ChainedBranchingHeuristics chainedBranchingHeuristics; + private int idOfA0; + + @BeforeEach + public void setUp() { + final AtomStore atomStore = new AtomStoreImpl(); + AtomStoreTest.fillAtomStore(atomStore, 1); + idOfA0 = atomStore.get(ATOM_A0); + final WritableAssignment assignment = new TrailAssignment(atomStore); + assignment.growForMaxAtomId(); + final PseudoChoiceManager choiceManager = new PseudoChoiceManager(assignment, new NaiveNoGoodStore(assignment)); + final BerkMin berkMin = new BerkMin(assignment, choiceManager, new Random(0)); // VSIDS does not support choosing from a set of admissible choices yet + berkMin.newNoGood(new NoGood(Literals.atomToLiteral(idOfA0, false))); + final NaiveHeuristic naive = new NaiveHeuristic(choiceManager); + this.chainedBranchingHeuristics = ChainedBranchingHeuristics.chainOf(berkMin, naive); + } + + @Test + public void testChooseAtom() { + final int chosenAtom = chainedBranchingHeuristics.chooseAtom(); + assertEquals(idOfA0, chosenAtom); + checkNumberOfDecisions(chainedBranchingHeuristics); + } + + @Test + public void testChooseAdmissibleAtom() { + Set admissibleChoices = new HashSet<>(); + admissibleChoices.add(idOfA0); + final int chosenAtom = chainedBranchingHeuristics.chooseAtom(admissibleChoices); + assertEquals(idOfA0, chosenAtom); + checkNumberOfDecisions(chainedBranchingHeuristics); + } + + @Test + public void testChooseLiteral() { + final int chosenAtom = Literals.atomOf(chainedBranchingHeuristics.chooseLiteral()); + assertEquals(idOfA0, chosenAtom); + checkNumberOfDecisions(chainedBranchingHeuristics); + } + + @Test + public void testChooseAdmissibleLiteral() { + Set admissibleChoices = new HashSet<>(); + admissibleChoices.add(idOfA0); + final int chosenAtom = Literals.atomOf(chainedBranchingHeuristics.chooseLiteral(admissibleChoices)); + assertEquals(idOfA0, chosenAtom); + checkNumberOfDecisions(chainedBranchingHeuristics); + } + + private void checkNumberOfDecisions(ChainedBranchingHeuristics chainedBranchingHeuristics) { + for (Map.Entry heuristicToNumberOfDecisions : chainedBranchingHeuristics.getNumberOfDecisions().entrySet()) { + final int numberOfDecisions = heuristicToNumberOfDecisions.getValue(); + if (heuristicToNumberOfDecisions.getKey() instanceof BerkMin) { + assertEquals(1, numberOfDecisions); + } else { + assertEquals(0, numberOfDecisions); + } + } + } + +} diff --git a/src/test/java/at/ac/tuwien/kr/alpha/solver/heuristics/DomainSpecificHeuristicsTest.java b/src/test/java/at/ac/tuwien/kr/alpha/solver/heuristics/DomainSpecificHeuristicsTest.java new file mode 100644 index 000000000..2671f3a61 --- /dev/null +++ b/src/test/java/at/ac/tuwien/kr/alpha/solver/heuristics/DomainSpecificHeuristicsTest.java @@ -0,0 +1,561 @@ +/* + * Copyright (c) 2018-2021 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.solver.heuristics; + +import org.junit.jupiter.api.Test; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import at.ac.tuwien.kr.alpha.api.Alpha; +import at.ac.tuwien.kr.alpha.common.AnswerSet; +import at.ac.tuwien.kr.alpha.common.AtomStore; +import at.ac.tuwien.kr.alpha.common.AtomStoreImpl; +import at.ac.tuwien.kr.alpha.common.atoms.BasicAtom; +import at.ac.tuwien.kr.alpha.common.program.InputProgram; +import at.ac.tuwien.kr.alpha.common.program.InternalProgram; +import at.ac.tuwien.kr.alpha.common.program.NormalProgram; +import at.ac.tuwien.kr.alpha.config.SystemConfig; +import at.ac.tuwien.kr.alpha.grounder.GrounderFactory; +import at.ac.tuwien.kr.alpha.grounder.parser.ProgramParser; +import at.ac.tuwien.kr.alpha.solver.DefaultSolver; +import at.ac.tuwien.kr.alpha.solver.Solver; +import at.ac.tuwien.kr.alpha.solver.SolverFactory; +import at.ac.tuwien.kr.alpha.solver.heuristics.BranchingHeuristicFactory.Heuristic; + +import static at.ac.tuwien.kr.alpha.test.util.TestUtils.atom; +import static at.ac.tuwien.kr.alpha.test.util.TestUtils.checkExpectedAtomsInAnswerSet; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * Tests the {@link DomainSpecific} heuristics. + */ +public class DomainSpecificHeuristicsTest { + + private static final String LS = System.lineSeparator(); + private final AtomStore atomStore; + private final ProgramParser parser = new ProgramParser(); + private final HeuristicsConfiguration heuristicsConfiguration; + private final SystemConfig systemConfig; + + public DomainSpecificHeuristicsTest() { + atomStore = new AtomStoreImpl(); + heuristicsConfiguration = HeuristicsConfiguration.builder().setHeuristic(Heuristic.NAIVE).build(); + systemConfig = buildSystemConfig(); + } + + @Test + public void testSimpleGroundHeuristicProgram_HeuristicDirective_AB_SameLevel() { + InputProgram program = parser.parse( + "a :- not b." + LS + + "b :- not a." + LS + + "#heuristic a : not b. [2@1]" + LS + + "#heuristic b : not a. [1@1]"); + solveAndAssertAnswerSets(program, "{ a }", "{ b }"); + } + + @Test + public void testSimpleGroundHeuristicProgram_HeuristicDirective_AB_SameLevel_HeadsF() { + InputProgram program = parser.parse( + "a :- not b." + LS + + "b :- not a." + LS + + "#heuristic F a : not b. [2@1]" + LS + + "#heuristic F b : not a. [1@1]"); + solveAndAssertAnswerSets(program, "{ b }", "{ a }"); + } + + @Test + public void testSimpleGroundHeuristicProgram_HeuristicDirective_AB_SameLevel_EmptyCondition1() { + InputProgram program = parser.parse( + "a :- not b." + LS + + "b :- not a." + LS + + "#heuristic a. [2@1]" + LS + + "#heuristic b. [1@1]"); + solveAndAssertAnswerSets(program, "{ a }", "{ b }"); + } + + @Test + public void testSimpleGroundHeuristicProgram_HeuristicDirective_AB_SameLevel_EmptyCondition2() { + InputProgram program = parser.parse( + "a :- not b." + LS + + "b :- not a." + LS + + "#heuristic a. [1@1]" + LS + + "#heuristic b. [2@1]"); + solveAndAssertAnswerSets(program, "{ b }", "{ a }"); + } + + @Test + public void testSimpleGroundHeuristicProgram_HeuristicDirective_TwoDirectivesForSameHead() { + InputProgram program = parser.parse( + "a :- not b." + LS + + "b :- not a." + LS + + "#heuristic a : not b. [3@1]" + LS + + "#heuristic b : not a. [1@1]" + LS + + "#heuristic b : not a, not b. [2@1]"); + solveAndAssertAnswerSets(program, "{ a }", "{ b }"); + } + + @Test + public void testSimpleNonGroundHeuristicProgram_HeuristicDirective_AB_SameLevel() { + InputProgram program = parser.parse( + "n(1)." + LS + + "a(N) :- n(N), not b(N)." + LS + + "b(N) :- n(N), not a(N)." + LS + + "#heuristic a(N) : n(N), not b(N). [2@1]" + LS + + "#heuristic b(N) : n(N), not a(N). [1@1]"); + solveAndAssertAnswerSets(program, "{ a(1), n(1) }", "{ b(1), n(1) }"); + } + + @Test + public void testSimpleNonGroundHeuristicProgram_HeuristicDirective_AB_OnlyFactsInCondition() { + InputProgram program = parser.parse( + "n(1)." + LS + + "a(N) :- n(N), not b(N)." + LS + + "b(N) :- n(N), not a(N)." + LS + + "#heuristic a(N) : n(N). [2@1]" + LS + + "#heuristic b(N) : n(N). [1@1]"); + solveAndAssertAnswerSets(program, "{ a(1), n(1) }", "{ b(1), n(1) }"); + } + + @Test + public void testSimpleGroundHeuristicProgram_HeuristicDirective_AB_DominatingLevel() { + InputProgram program = parser.parse( + "a :- not b." + LS + + "b :- not a." + LS + + "#heuristic a : not b. [1@2]" + LS + + "#heuristic b : not a. [2@1]"); + solveAndAssertAnswerSets(program, "{ a }", "{ b }"); + } + + @Test + public void testSimpleNonGroundHeuristicProgram_HeuristicDirective_AB_DominatingLevel() { + InputProgram program = parser.parse( + "n(1)." + LS + + "a(N) :- n(N), not b(N)." + LS + + "b(N) :- n(N), not a(N)." + LS + + "#heuristic a(N) : n(N), not b(N). [1@2]" + LS + + "#heuristic b(N) : n(N), not a(N). [2@1]"); + solveAndAssertAnswerSets(program, "{ a(1), n(1) }", "{ b(1), n(1) }"); + } + + @Test + public void testSimpleGroundHeuristicProgram_HeuristicDirective_BA_SameLevel() { + InputProgram program = parser.parse( + "a :- not b." + LS + + "b :- not a." + LS + + "#heuristic a : not b. [1@1]" + LS + + "#heuristic b : not a. [2@1]"); + solveAndAssertAnswerSets(program, "{ b }", "{ a }"); + } + + @Test + public void testSimpleNonGroundHeuristicProgram_HeuristicDirective_BA_SameLevel() { + InputProgram program = parser.parse( + "n(1)." + LS + + "a(N) :- n(N), not b(N)." + LS + + "b(N) :- n(N), not a(N)." + LS + + "#heuristic a(N) : n(N), not b(N). [1@1]" + LS + + "#heuristic b(N) : n(N), not a(N). [2@1]"); + solveAndAssertAnswerSets(program, "{ b(1), n(1) }", "{ a(1), n(1) }"); + } + + @Test + public void testSimpleGroundHeuristicProgram_HeuristicDirective_BA_DominatingLevel() { + InputProgram program = parser.parse( + "a :- not b." + LS + + "b :- not a." + LS + + "#heuristic a : not b. [2@1]" + LS + + "#heuristic b : not a. [1@2]"); + solveAndAssertAnswerSets(program, "{ b }", "{ a }"); + } + + @Test + public void testSimpleNonGroundHeuristicProgram_HeuristicDirective_BA_DominatingLevel() { + InputProgram program = parser.parse( + "n(1)." + LS + + "a(N) :- n(N), not b(N)." + LS + + "b(N) :- n(N), not a(N)." + LS + + "#heuristic a(N) : n(N), not b(N). [2@1]" + LS + + "#heuristic b(N) : n(N), not a(N). [1@2]"); + solveAndAssertAnswerSets(program, "{ b(1), n(1) }", "{ a(1), n(1) }"); + } + + @Test + public void testSimpleGroundHeuristicProgram_HeuristicDirective_SimpleChoiceGenerator_NegativeLiteral() { + InputProgram program = parser.parse( + "c :- not nc." + LS + + "nc :- not c." + LS + + "a :- not b." + LS + + "b :- not a." + LS + + "#heuristic c : not nc. [10@1]" + LS + + "#heuristic a : not b, c. [2@1]" + LS + + "#heuristic b : not a, not c. [2@1]"); + solveAndAssertAnswerSets(program, "{ a, c }", "{ b, c }", "{ b, nc }", "{ a, nc }"); + } + + @Test + public void testSimpleNonGroundHeuristicProgram_HeuristicDirective_SimpleChoiceGenerator_NegativeLiteral() { + InputProgram program = parser.parse( + "n(1)." + LS + + "c(N) :- n(N), not nc(N)." + LS + + "nc(N) :- n(N), not c(N)." + LS + + "a(N) :- n(N), not b(N)." + LS + + "b(N) :- n(N), not a(N)." + LS + + "#heuristic c(N) : n(N), not nc(N). [10@1]" + LS + + "#heuristic a(N) : n(N), not b(N), c(N). [2@1]" + LS + + "#heuristic b(N) : n(N), not a(N), not c(N). [2@1]"); + solveAndAssertAnswerSets(program, "{ a(1), c(1), n(1) }", "{ b(1), c(1), n(1) }", "{ b(1), n(1), nc(1) }", "{ a(1), n(1), nc(1) }"); + } + + @Test + public void testSimpleGroundHeuristicProgram_HeuristicDirective_SimpleChoiceGenerator_PositiveLiteral() { + InputProgram program = parser.parse( + "c :- not nc." + LS + + "nc :- not c." + LS + + "a :- not b." + LS + + "b :- not a." + LS + + "#heuristic c : not nc. [10@1]" + LS + + "#heuristic a : not b, c. [2@1]" + LS + + "#heuristic b : not a, not c. [2@1]"); + solveAndAssertAnswerSets(program, "{ a, c }", "{ b, c }", "{ b, nc }", "{ a, nc }"); + } + + @Test + public void testSimpleNonGroundHeuristicProgram_HeuristicDirective_SimpleChoiceGenerator_PositiveLiteral() { + InputProgram program = parser.parse( + "n(1)." + LS + + "c(N) :- n(N), not nc(N)." + LS + + "nc(N) :- n(N), not c(N)." + LS + + "a(N) :- n(N), not b(N)." + LS + + "b(N) :- n(N), not a(N)." + LS + + "#heuristic c(N) : n(N), not nc(N). [10@1]" + LS + + "#heuristic a(N) : n(N), not b(N), c(N). [2@1]" + LS + + "#heuristic b(N) : n(N), not a(N), not c(N). [2@1]"); + solveAndAssertAnswerSets(program, "{ a(1), c(1), n(1) }", "{ b(1), c(1), n(1) }", "{ b(1), n(1), nc(1) }", "{ a(1), n(1), nc(1) }"); + } + + @Test + public void testSimpleHeuristicProgram_HeuristicDirective_SimpleNonGroundArithmetics() { + InputProgram program = parser.parse( + "n(2)." + LS + + "a :- n(N), not b." + LS + + "b :- not a." + LS + + "#heuristic a : n(N), not b, Np1=N+1. [Np1@1]" + LS + + "#heuristic b : not a. [1]"); + solveAndAssertAnswerSets(program, "{ a, n(2) }", "{ b, n(2) }"); + } + + @Test + public void testTwoHeuristicsWithSameHeadAndPriority() { + InputProgram program = parser.parse( + "a :- not b." + LS + + "b :- not a." + LS + + "#heuristic a : not b. [2@1]" + LS + + "#heuristic a : not a. [2@1]"); + solveAndAssertAnswerSets(program, "{ a }", "{ b }"); + } + + @Test + public void testTwoHeuristicsOneWithoutRule() { + InputProgram program = parser.parse( + "a :- not b." + LS + + "b :- not a." + LS + + "#heuristic a : not b. [2@1]" + LS + + "#heuristic c : not a. [3@1]"); + solveAndAssertAnswerSets(program, "{ a }", "{ b }"); + } + + /** + * Uses a modified (smaller) PUP encoding and instance to test for an issue with domain-specific heuristics + * that led to heuristics not being applicable after backjumping. + */ + @Test + public void testHeuristicApplicableAfterBackjump() { + final Alpha system = new Alpha(); + InputProgram inputProgram = parser.parse( + "comUnit(1)." + LS + + "comUnit(2)." + LS + + "maxUnit(2)." + LS + + "assign(1, z, 1)." + LS + + "order(4, s, 4)." + LS + + "order(3, s, 4)." + LS + + "order(2, z, 3)." + LS + + "order(2, s, 2)." + LS + + "order(1, s, 2)." + LS + + "order(1, z, 1)." + LS + + "maxElem(6)." + LS + + "maxOrder(4)." + LS + + "elem(z,Z) :- order(Z,z,_)." + LS + + "elem(s,S) :- order(S,s,_)." + LS + + " assign(U,T,X) :- elem(T,X), comUnit(U), not n_assign(U,T,X)." + LS + + "n_assign(U,T,X) :- elem(T,X), comUnit(U), not assign(U,T,X)." + LS + + "h_assign_1(U1,T,X,W) :- order(X,T,O), assign(U,T1,Y), order(Y,T1,Om1), Om1=O-1, maxOrder(M), maxUnit(MU), comUnit(U1), U1<=U, maxElem(ME), W=10*MU*(M-O)+2*(ME-X)+U1." + LS + + "#heuristic assign(U,T,X) : h_assign_1(U,T,X,W). [W]" + LS + + "h_assign_2(Up1,T,X,W) :- order(X,T,O), assign(U,T1,Y), order(Y,T1,Om1), Om1=O-1, maxOrder(M), maxUnit(MU), comUnit(Up1), Up1=U+1, maxElem(ME), W=10*MU*(M-O)+2*(ME-X)." + LS + + "#heuristic assign(U,T,X) : h_assign_2(U,T,X,W). [W]" + LS + + ":- assign(U,T,X1), assign(U,T,X2), assign(U,T,X3), X1 0, "No backjumps done"); + Map numberOfChoicesPerBranchingHeuristic = defaultSolver.getNumberOfChoicesPerBranchingHeuristic(); + assertTrue(!numberOfChoicesPerBranchingHeuristic.isEmpty(), "No numbers of choices per branching heuristic"); + for (Map.Entry entry : numberOfChoicesPerBranchingHeuristic.entrySet()) { + if (entry.getKey().equals("DomainSpecific")) { + assertTrue(entry.getValue() > 0, "No choices done by DomainSpecific"); + } else if (entry.getKey().equals("NaiveHeuristic")) { + // default heuristic has to decide two choice points that are not covered by the domain-specific one + assertEquals(Integer.valueOf(2), entry.getValue(), "Unexpected number of choices done by Naive"); + } else { + assertEquals(Integer.valueOf(0), entry.getValue(), "Choices done by " + entry.getKey()); + } + } + + } + + /** + * Tests Example 5 from our paper "Domain-Specific Heuristics in Answer Set Programming: A Declarative Non-Monotonic Approach". + * Note that the constraint has been removed from the program because it is irrelevant to the behaviour of the domain-specific heuristics. + */ + @Test + public void textExample5() { + final Alpha system = new Alpha(); + final InputProgram inputProgram = parser.parse( + "{ a(2); a(4); a(6); a(8); a(5) }." + + "#heuristic a(5). [1]" + + "#heuristic a(4) : not a(5). [2]" + + "#heuristic F a(5) : a(4). [2]" + + "#heuristic a(6) : F a(5), T a(4). [2]" + ); + + final NormalProgram normalProgram = system.normalizeProgram(inputProgram); + final InternalProgram internalProgram = InternalProgram.fromNormalProgram(normalProgram); + final Solver solver = SolverFactory.getInstance(systemConfig, atomStore, GrounderFactory.getInstance("naive", internalProgram, atomStore, heuristicsConfiguration, true), heuristicsConfiguration); + final AnswerSet answerSet = solver.stream().limit(1).collect(Collectors.toList()).get(0); + final List atomsExpectedInAnswerSet = Arrays.asList(atom("a", 4), atom("a", 6)); + final List atomsNotExpectedInAnswerSet = Collections.singletonList(atom("a", 5)); + checkExpectedAtomsInAnswerSet(answerSet, atomsExpectedInAnswerSet, atomsNotExpectedInAnswerSet); + + final DefaultSolver defaultSolver = (DefaultSolver) solver; + assertEquals(0, defaultSolver.getNumberOfBackjumps()); + final Map numberOfChoicesPerBranchingHeuristic = defaultSolver.getNumberOfChoicesPerBranchingHeuristic(); + assertFalse(numberOfChoicesPerBranchingHeuristic.isEmpty(), "No numbers of choices per branching heuristic"); + for (Map.Entry entry : numberOfChoicesPerBranchingHeuristic.entrySet()) { + if (entry.getKey().equals("DomainSpecific")) { + assertTrue(entry.getValue() > 0, "No choices done by DomainSpecific"); + } else if (entry.getKey().equals("NaiveHeuristic")) { + // default heuristic has to decide two choice points that are not covered by the domain-specific one + assertEquals(Integer.valueOf(2), entry.getValue(), "Unexpected number of choices done by Naive"); + } else { + assertEquals(Integer.valueOf(0), entry.getValue(), "Choices done by " + entry.getKey()); + } + } + } + + @Test + public void testSimpleGroundHeuristicProgram_HeuristicDirective_AB_PositiveAnySignCondition_aF() { + InputProgram program = parser.parse( + "{a}." + LS + + "{b}." + LS + + "#heuristic F a. [2@1]" + LS + + "#heuristic F b : FMT a. [1@1]"); + solveAndAssertAnswerSets(program, "{}", "{ b }", "{ a }", "{ a, b }"); + } + + @Test + public void testSimpleGroundHeuristicProgram_HeuristicDirective_AB_PositiveAnySignCondition_aT() { + InputProgram program = parser.parse( + "{a}." + LS + + "{b}." + LS + + "#heuristic T a. [2@1]" + LS + + "#heuristic F b : FMT a. [1@1]"); + solveAndAssertAnswerSets(program, "{ a }", "{ a, b }", "{}", "{ b }"); + } + + @Test + public void testSimpleGroundHeuristicProgram_HeuristicDirective_AB_NegativeAnySignCondition_HeadF() { + InputProgram program = parser.parse( + "{a}." + LS + + "#heuristic F a : not FMT a."); + solveAndAssertAnswerSets(program, "{}", "{ a }"); + } + + @Test + public void testSimpleGroundHeuristicProgram_HeuristicDirective_AB_NegativeAnySignCondition_HeadT() { + InputProgram program = parser.parse( + "{a}." + LS + + "#heuristic T a : not FMT a."); + solveAndAssertAnswerSets(program, "{ a }", "{}"); + } + + @Test + public void testSimpleGroundHeuristicProgram_MultipleTAtomsInPositiveCondition_NotApplicable() { + InputProgram program = parser.parse( + "{a}." + LS + + "{b}." + LS + + "c :- not d." + LS + + "d :- not c." + LS + + "#heuristic F a. [3@1]" + LS + + "#heuristic T b : F a. [2@1]" + LS + + "#heuristic T c : a, b. [2@1]" + LS + + "#heuristic T d : b, not c. [1@1]"); + solveAndAssertAnswerSets(program, 1, "{ b, d }"); + } + + @Test + public void testSimpleGroundHeuristicProgram_MultipleTAtomsInPositiveCondition_Applicable() { + InputProgram program = parser.parse( + "{a}." + LS + + "{b}." + LS + + "c :- not d." + LS + + "d :- not c." + LS + + "#heuristic T a. [3@1]" + LS + + "#heuristic T b : T a. [2@1]" + LS + + "#heuristic T c : a, b. [2@1]" + LS + + "#heuristic T d : b, not c. [2@1]"); + solveAndAssertAnswerSets(program, 1, "{ a, b, c }"); + } + + @Test + public void testSimpleGroundHeuristicProgram_MultipleFAtomsInPositiveCondition_NotApplicable() { + InputProgram program = parser.parse( + "{a}." + LS + + "{b}." + LS + + "c :- not d." + LS + + "d :- not c." + LS + + "#heuristic F a. [3@1]" + LS + + "#heuristic T b : F a. [2@1]" + LS + + "#heuristic T c : F a, F b. [2@1]" + LS + + "#heuristic T d : b, not c. [1@1]"); + solveAndAssertAnswerSets(program, 1, "{ b, d }"); + } + + @Test + public void testSimpleGroundHeuristicProgram_MultipleFAtomsInPositiveCondition_Applicable() { + InputProgram program = parser.parse( + "{a}." + LS + + "{b}." + LS + + "c :- not d." + LS + + "d :- not c." + LS + + "#heuristic F a. [3@1]" + LS + + "#heuristic F b : F a. [2@1]" + LS + + "#heuristic T c : F a, F b. [2@1]" + LS + + "#heuristic T d : b, not c. [2@1]"); + solveAndAssertAnswerSets(program, 1, "{ c }"); + } + + @Test + public void testNegativeHeuristicWithTwoApplicableRules() { + InputProgram program = parser.parse( + "{a}." + LS + + "{b}." + LS + + "h :- not a." + LS + + "h :- not b." + LS + + "#heuristic F h." + ); + final Solver solver = getSolver(program); + assertThrows(UnsupportedOperationException.class, () -> solver.stream().collect(Collectors.toList())); + } + + @Test + public void testInapplicableHeuristicBecauseHeadAlreadyAssigned() { + InputProgram program = parser.parse( + "{a}." + LS + + "{b}." + LS + + "{c}." + LS + + "c :- a." + LS + + "#heuristic T a. [3]" + LS + + "#heuristic F a. [2]" + LS + + "#heuristic T b. [1]" + LS + + "#heuristic T c. [0]" + ); + solveAndAssertAnswerSets(program, 1, 2, "{ a, b, c }"); + // 2 domain-specific choices are expected because the heuristics for F a and F c are disabled because their heads are assigned before the heuristic could step in + } + + @Test + public void testDiscardingOfFiringHeuristicWithoutApplicableRule() { + InputProgram program = parser.parse( + "{a}." + LS + + "{b} :- a." + LS + + "#heuristic T b. [3]" + LS + // highest priority, but no applicable rule: this heuristic is discarded + "#heuristic T a. [2]" + LS + // after this has fired, the first directive becomes applicable + "#heuristic F b. [1]" // this directive is irrelevant because the heuristic with weight 3 has become applicable + ); + solveAndAssertAnswerSets(program, 1, 2, "{ a, b }"); + } + + private void solveAndAssertAnswerSets(InputProgram program, String... expectedAnswerSets) { + solveAndAssertAnswerSets(program, Integer.MAX_VALUE, expectedAnswerSets); + } + + private void solveAndAssertAnswerSets(InputProgram inputProgram, int limit, String... expectedAnswerSets) { + solveAndAssertAnswerSets(inputProgram, limit, null, expectedAnswerSets); + } + + private void solveAndAssertAnswerSets(InputProgram inputProgram, int limit, Integer expectedNumberOfDomainSpecificChoices, String... expectedAnswerSets) { + final Solver solver = getSolver(inputProgram); + final List computedAnswerSets = solver.stream().limit(limit).map(AnswerSet::toString).collect(Collectors.toList()); + assertEquals(Arrays.asList(expectedAnswerSets), computedAnswerSets); + if (expectedNumberOfDomainSpecificChoices != null) { + assertEquals(expectedNumberOfDomainSpecificChoices, ((DefaultSolver) solver).getNumberOfChoicesPerBranchingHeuristic().get(DomainSpecific.class.getSimpleName())); + } + } + + private Solver getSolver(InputProgram inputProgram) { + final Alpha system = new Alpha(); + final NormalProgram normalProgram = system.normalizeProgram(inputProgram); + final InternalProgram internalProgram = InternalProgram.fromNormalProgram(normalProgram); + final HeuristicsConfiguration heuristicsConfiguration = HeuristicsConfiguration.builder().setHeuristic(Heuristic.NAIVE).build(); + return SolverFactory.getInstance(systemConfig, atomStore, GrounderFactory.getInstance("naive", internalProgram, atomStore, heuristicsConfiguration, true), heuristicsConfiguration); + } + + private SystemConfig buildSystemConfig() { + SystemConfig config = new SystemConfig(); + config.setSolverName("default"); + config.setNogoodStoreName("alpharoaming"); + config.setBranchingHeuristic(heuristicsConfiguration.getHeuristic()); + config.setDebugInternalChecks(true); + config.setDisableJustificationSearch(false); + return config; + } +} diff --git a/src/test/java/at/ac/tuwien/kr/alpha/solver/heuristics/domspec/DefaultDomainSpecificHeuristicsStoreTest.java b/src/test/java/at/ac/tuwien/kr/alpha/solver/heuristics/domspec/DefaultDomainSpecificHeuristicsStoreTest.java new file mode 100644 index 000000000..9ee4d035c --- /dev/null +++ b/src/test/java/at/ac/tuwien/kr/alpha/solver/heuristics/domspec/DefaultDomainSpecificHeuristicsStoreTest.java @@ -0,0 +1,175 @@ +/* + * Copyright (c) 2018-2021 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.solver.heuristics.domspec; + +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.concurrent.atomic.AtomicInteger; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import at.ac.tuwien.kr.alpha.common.AtomStore; +import at.ac.tuwien.kr.alpha.common.AtomStoreImpl; +import at.ac.tuwien.kr.alpha.common.heuristics.HeuristicDirectiveValues; +import at.ac.tuwien.kr.alpha.solver.ChoiceManager; +import at.ac.tuwien.kr.alpha.solver.InfluenceManager.ActivityListener; +import at.ac.tuwien.kr.alpha.solver.NaiveNoGoodStore; +import at.ac.tuwien.kr.alpha.solver.NoGoodStore; +import at.ac.tuwien.kr.alpha.solver.TrailAssignment; +import at.ac.tuwien.kr.alpha.solver.WritableAssignment; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * Test {@link DefaultDomainSpecificHeuristicsStore} + */ +public class DefaultDomainSpecificHeuristicsStoreTest { + private static final int INITIAL_GENERATED_ID = 100; + + private final AtomStore atomStore; + private final WritableAssignment assignment; + private PseudoChoiceManager choiceManager; + private DefaultDomainSpecificHeuristicsStore store; + private AtomicInteger idGenerator = new AtomicInteger(INITIAL_GENERATED_ID); + + public DefaultDomainSpecificHeuristicsStoreTest() { + atomStore = new AtomStoreImpl(); + assignment = new TrailAssignment(atomStore); + } + + @BeforeEach + public void setUp() { + this.store = new DefaultDomainSpecificHeuristicsStore(); + this.choiceManager = new PseudoChoiceManager(assignment, new NaiveNoGoodStore(assignment), store); + } + + @Test + public void testInsert_1_atom() { + int id = idGenerator.getAndIncrement(); + HeuristicDirectiveValues info1 = info(1, 1, 1); + store.growForMaxAtomId(INITIAL_GENERATED_ID + 1); + store.addInfo(id, info1); + choiceManager.makeAtomsActive(id); + List orderedList = listHeuristicsOrderedByDecreasingPriority(); + assertEquals(Arrays.asList(info1), orderedList); + } + + @Test + public void testInsert_2_atoms_sameWeight_sameLevel() { + int id1 = idGenerator.getAndIncrement(); + int id2 = idGenerator.getAndIncrement(); + HeuristicDirectiveValues info1 = info(1, 2, 3); + HeuristicDirectiveValues info2 = info(2, 2, 3); + store.growForMaxAtomId(INITIAL_GENERATED_ID + 2); + store.addInfo(id1, info1); + store.addInfo(id2, info2); + choiceManager.makeAtomsActive(id1, id2); + List orderedList = listHeuristicsOrderedByDecreasingPriority(); + assertEquals(2, orderedList.size()); + assertEquals(new HashSet<>(Arrays.asList(info1, info2)), new HashSet<>(orderedList)); + } + + @Test + public void testInsert_3_atoms_sameWeight_differentLevel() { + int id1 = idGenerator.getAndIncrement(); + int id2 = idGenerator.getAndIncrement(); + int id3 = idGenerator.getAndIncrement(); + HeuristicDirectiveValues info1 = info(1, 2, 3); + HeuristicDirectiveValues info2 = info(2, 2, 1); + HeuristicDirectiveValues info3 = info(3, 2, 2); + store.growForMaxAtomId(INITIAL_GENERATED_ID + 3); + store.addInfo(id1, info1); + store.addInfo(id2, info2); + store.addInfo(id3, info3); + choiceManager.makeAtomsActive(id1, id2, id3); + List orderedList = listHeuristicsOrderedByDecreasingPriority(); + assertEquals(Arrays.asList(info1, info3, info2), orderedList); + } + + @Test + public void testInsert_3_atoms_differentWeight_sameLevel() { + int id1 = idGenerator.getAndIncrement(); + int id2 = idGenerator.getAndIncrement(); + int id3 = idGenerator.getAndIncrement(); + HeuristicDirectiveValues info1 = info(1, 4, 1); + HeuristicDirectiveValues info2 = info(2, 2, 1); + HeuristicDirectiveValues info3 = info(3, 3, 1); + store.growForMaxAtomId(INITIAL_GENERATED_ID + 3); + store.addInfo(id1, info1); + store.addInfo(id2, info2); + store.addInfo(id3, info3); + choiceManager.makeAtomsActive(id1, id2, id3); + List orderedList = listHeuristicsOrderedByDecreasingPriority(); + assertEquals(Arrays.asList(info1, info3, info2), orderedList); + } + + private HeuristicDirectiveValues info(int atom, int weight, int level) { + return new HeuristicDirectiveValues(atom, null, weight, level, true); + } + + private List listHeuristicsOrderedByDecreasingPriority() { + List list = new LinkedList<>(); + HeuristicDirectiveValues currentValues; + while ((currentValues = store.poll()) != null) { + list.add(currentValues); + } + return list; + } + + private class PseudoChoiceManager extends ChoiceManager { + + private Collection activityListeners; + + public PseudoChoiceManager(WritableAssignment assignment, NoGoodStore store, DomainSpecificHeuristicsStore domainSpecificHeuristicsStore) { + super(assignment, store, domainSpecificHeuristicsStore); + } + + @Override + public void setHeuristicActivityListener(ActivityListener activityListener) { + super.setHeuristicActivityListener(activityListener); + if (activityListeners == null) { + activityListeners = new LinkedList<>(); + } + this.activityListeners.add(activityListener); + } + + public void makeAtomsActive(int... atoms) { + for (int atom : atoms) { + activityListeners.forEach(al -> al.callbackOnChanged(atom, true)); + } + } + + @Override + public boolean isActiveChoiceAtom(int atom) { + return true; + } + } + +} diff --git a/src/test/java/at/ac/tuwien/kr/alpha/solver/heuristics/domspec/EmptyDomainSpecificHeuristicsStoreTest.java b/src/test/java/at/ac/tuwien/kr/alpha/solver/heuristics/domspec/EmptyDomainSpecificHeuristicsStoreTest.java new file mode 100644 index 000000000..301e7f397 --- /dev/null +++ b/src/test/java/at/ac/tuwien/kr/alpha/solver/heuristics/domspec/EmptyDomainSpecificHeuristicsStoreTest.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2019-2021 Siemens AG + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package at.ac.tuwien.kr.alpha.solver.heuristics.domspec; + +import java.util.concurrent.atomic.AtomicInteger; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import at.ac.tuwien.kr.alpha.common.heuristics.HeuristicDirectiveValues; + +import static org.junit.jupiter.api.Assertions.assertNull; + + +/** + * Test {@link EmptyDomainSpecificHeuristicsStore} + */ +public class EmptyDomainSpecificHeuristicsStoreTest { + private static final int INITIAL_GENERATED_ID = 100; + + private EmptyDomainSpecificHeuristicsStore store; + private AtomicInteger idGenerator = new AtomicInteger(INITIAL_GENERATED_ID); + + @BeforeEach + public void setUp() { + this.store = new EmptyDomainSpecificHeuristicsStore(); + this.store.setChoiceManager(null); + } + + @Test + public void testInsert_1_atom() { + int id = idGenerator.getAndIncrement(); + HeuristicDirectiveValues info1 = info(1, 1, 1); + store.addInfo(id, info1); + assertNull(store.poll()); + } + + private HeuristicDirectiveValues info(int atom, int weight, int level) { + return new HeuristicDirectiveValues(atom, null, weight, level, true); + } + +} diff --git a/src/test/java/at/ac/tuwien/kr/alpha/test/util/AnswerSetsParser.java b/src/test/java/at/ac/tuwien/kr/alpha/test/util/AnswerSetsParser.java index f20153be7..1ead16c8c 100644 --- a/src/test/java/at/ac/tuwien/kr/alpha/test/util/AnswerSetsParser.java +++ b/src/test/java/at/ac/tuwien/kr/alpha/test/util/AnswerSetsParser.java @@ -1,8 +1,32 @@ +/* + * Copyright (c) 2017-2020, the Alpha Team. + * All rights reserved. + * + * Additional changes made by Siemens. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1) Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * + * 2) Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ package at.ac.tuwien.kr.alpha.test.util; -import java.util.Collections; -import java.util.Set; - import org.antlr.v4.runtime.BailErrorStrategy; import org.antlr.v4.runtime.CharStream; import org.antlr.v4.runtime.CharStreams; @@ -11,8 +35,11 @@ import org.antlr.v4.runtime.atn.PredictionMode; import org.antlr.v4.runtime.misc.ParseCancellationException; -import at.ac.tuwien.kr.alpha.antlr.ASPCore2Lexer; -import at.ac.tuwien.kr.alpha.antlr.ASPCore2Parser; +import java.util.Collections; +import java.util.Set; + +import at.ac.tuwien.kr.alpha.antlr.AlphaASPLexer; +import at.ac.tuwien.kr.alpha.antlr.AlphaASPParser; import at.ac.tuwien.kr.alpha.common.AnswerSet; import at.ac.tuwien.kr.alpha.grounder.parser.ParseTreeVisitor; @@ -31,7 +58,7 @@ public static Set parse(String s) { } public static Set parse(CharStream stream) { - final ASPCore2Parser parser = new ASPCore2Parser(new CommonTokenStream(new ASPCore2Lexer(stream))); + final AlphaASPParser parser = new AlphaASPParser(new CommonTokenStream(new AlphaASPLexer(stream))); // Try SLL parsing mode (faster but may terminate incorrectly). parser.getInterpreter().setPredictionMode(PredictionMode.SLL); diff --git a/src/test/java/at/ac/tuwien/kr/alpha/test/util/TestUtils.java b/src/test/java/at/ac/tuwien/kr/alpha/test/util/TestUtils.java index 9adf681ce..1b41950dd 100644 --- a/src/test/java/at/ac/tuwien/kr/alpha/test/util/TestUtils.java +++ b/src/test/java/at/ac/tuwien/kr/alpha/test/util/TestUtils.java @@ -1,12 +1,5 @@ package at.ac.tuwien.kr.alpha.test.util; -import static java.util.Collections.emptySet; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTimeoutPreemptively; -import static org.junit.jupiter.api.Assertions.assertTrue; - -import com.ibm.icu.impl.Assert; - import org.apache.commons.lang3.StringUtils; import org.junit.jupiter.api.Assumptions; import org.junit.jupiter.api.function.Executable; @@ -47,6 +40,14 @@ import at.ac.tuwien.kr.alpha.solver.Solver; import at.ac.tuwien.kr.alpha.solver.SolverFactory; import at.ac.tuwien.kr.alpha.solver.heuristics.BranchingHeuristicFactory; +import at.ac.tuwien.kr.alpha.solver.heuristics.HeuristicsConfiguration; +import com.ibm.icu.impl.Assert; + +import static java.util.Collections.emptySet; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTimeoutPreemptively; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; public class TestUtils { @@ -100,6 +101,19 @@ public static void assertAnswerSetsEqualWithBase(String base, String[] expectedA TestUtils.assertAnswerSetsEqual(expectedAnswerSets, actual); } + public static void checkExpectedAtomsInAnswerSet(AnswerSet answerSet, List atomsExpectedInAnswerSet, List atomsNotExpectedInAnswerSet) { + for (BasicAtom atom : atomsExpectedInAnswerSet) { + if (!answerSet.getPredicateInstances(atom.getPredicate()).contains(atom)) { + fail("Answer set does not contain " + atom); + } + } + for (BasicAtom atom : atomsNotExpectedInAnswerSet) { + if (answerSet.getPredicateInstances(atom.getPredicate()).contains(atom)) { + fail("Answer set contains " + atom); + } + } + } + public static void assertFactsContainedInProgram(AbstractProgram prog, Atom... facts) { for (Atom fact : facts) { assertTrue(prog.getFacts().contains(fact)); @@ -137,7 +151,7 @@ public static Atom atom(String predicateName, String... termStrings) { return new BasicAtom(Predicate.getInstance(predicateName, terms.length), terms); } - public static Atom atom(String predicateName, int... termInts) { + public static BasicAtom atom(String predicateName, int... termInts) { Term[] terms = new Term[termInts.length]; for (int i = 0; i < termInts.length; i++) { terms[i] = ConstantTerm.getInstance(termInts[i]); @@ -160,11 +174,13 @@ public static void assertProgramContainsRule(InputProgram prog, BasicRule contai private static Solver buildSolverFromSystemConfig(InputProgram prog, SystemConfig cfg) { AtomStore atomStore = new AtomStoreImpl(); - NormalProgram normalProg = new NormalizeProgramTransformation(cfg.getAggregateRewritingConfig()).apply(prog); + NormalProgram normalProg = new NormalizeProgramTransformation(cfg.getAggregateRewritingConfig(), cfg.isIgnoreDomspecHeuristics()).apply(prog); InternalProgram preprocessed = cfg.isEvaluateStratifiedPart() ? new StratifiedEvaluation().apply(AnalyzedProgram.analyzeNormalProgram(normalProg)) : InternalProgram.fromNormalProgram(normalProg); + final HeuristicsConfiguration heuristicsConfiguration = getHeuristicsConfiguration(cfg); return SolverFactory.getInstance(cfg, atomStore, - GrounderFactory.getInstance(cfg.getGrounderName(), preprocessed, atomStore, cfg.isDebugInternalChecks())); + GrounderFactory.getInstance(cfg.getGrounderName(), preprocessed, atomStore, heuristicsConfiguration, cfg.isDebugInternalChecks()), + heuristicsConfiguration); } public static Solver buildSolverForRegressionTest(InputProgram prog, RegressionTestConfig cfg) { @@ -177,7 +193,7 @@ public static Solver buildSolverForRegressionTest(String prog, RegressionTestCon public static Solver buildSolverForRegressionTest(AtomStore atomStore, Grounder grounder, RegressionTestConfig cfg) { SystemConfig systemCfg = cfg.toSystemConfig(); - return SolverFactory.getInstance(systemCfg, atomStore, grounder); + return SolverFactory.getInstance(systemCfg, atomStore, grounder, getHeuristicsConfiguration(systemCfg)); } public static Set collectRegressionTestAnswerSets(InputProgram prog, RegressionTestConfig cfg) { @@ -221,4 +237,14 @@ public static void ignoreTestForSimplifiedSumAggregates(RegressionTestConfig cfg Assumptions.assumeTrue(cfg.isSupportNegativeSumElements()); } + private static HeuristicsConfiguration getHeuristicsConfiguration(SystemConfig cfg) { + final HeuristicsConfiguration heuristicsConfiguration = HeuristicsConfiguration.builder() + .setHeuristic(cfg.getBranchingHeuristic()) + .setRespectDomspecHeuristics(!cfg.isIgnoreDomspecHeuristics()) + .setMomsStrategy(cfg.getMomsStrategy()) + .setReplayChoices(cfg.getReplayChoices()) + .build(); + return heuristicsConfiguration; + } + } diff --git a/src/test/resources/DomainHeuristics/House/house_alpha_2021-02-04.asp b/src/test/resources/DomainHeuristics/House/house_alpha_2021-02-04.asp new file mode 100644 index 000000000..764cfc58b --- /dev/null +++ b/src/test/resources/DomainHeuristics/House/house_alpha_2021-02-04.asp @@ -0,0 +1,144 @@ +% this version contains two minor corrections to house_alpha_2020-02-21.asp + +% INITIAL PROBLEM +cabinetDomain(C) :- cabinetDomainNew(C). +roomDomain(R) :- roomDomainNew(R). + +% guessing of cabinets and rooms in a configuration +{ cabinet(C) } :- cabinetDomain(C). +{ room(R) } :- roomDomain(R). + +% ordering of used cabinets and rooms +room(R1) :- roomDomainNew(R1), roomDomainNew(R2), room(R2), R1 < R2. +cabinet(C1) :- cabinetDomainNew(C1), cabinetDomainNew(C2), cabinet(C2), C1 < C2. + +% association cabinetTOthing +% 1 <= {cabinetTOthing(C,T) : cabinetDomain(C)} <= 1 :- thing(T). +{ cabinetTOthing(C,T) } :- cabinetDomain(C), thing(T). +thingHasCabinet(T) :- cabinetTOthing(C,T). +:- thing(T), not thingHasCabinet(T). +:- thing(T), cabinetDomain(C1), cabinetTOthing(C1,T), cabinetDomain(C2), cabinetTOthing(C2,T), C1 < C2. +:- 6 <= #count { T : cabinetTOthing(C,T), thing(T) }, cabinet(C). + +% association roomTOcabinet +% 1 <= {roomTOcabinet(R,C) : roomDomain(R)} <= 1 :- cabinet(C). +{ roomTOcabinet(R,C) } :- roomDomain(R), cabinet(C). +cabinetHasRoom(C) :- roomTOcabinet(R,C). +:- cabinet(C), not cabinetHasRoom(C). +:- cabinet(C), roomDomain(R1), roomTOcabinet(R1,C), roomDomain(R2), roomTOcabinet(R2,C), R1 < R2. +:- 5 <= #count { C : roomTOcabinet(R,C), cabinetDomain(C) }, room(R). + +% association personTOroom +% a room belongs to a person, who stores things in cabinets in that room +personTOroom(P,R) :- personTOthing(P,T), cabinetTOthing(C,T), roomTOcabinet(R,C). +legacyConfig(personTOroom(P,R)) :- legacyConfig(personTOthing(P,T)), legacyConfig(cabinetTOthing(C,T)), legacyConfig(roomTOcabinet(R,C)). + +% things of one person cannot be placed in a cabinet together with things of another person +:- cabinetTOthing(C,T1), cabinetTOthing(C,T2), + personTOthing(P1,T1), personTOthing(P2,T2), P1 < P2. + +% cabinets of different people cannot be placed in the same room +% i.e. one and the same room cannot belong to 2 different persons +:- personTOroom(P1,R), personTOroom(P2,R), P1 < P2. + +room(R) :- roomTOcabinet(R,C). +room(R) :- personTOroom(P,R). + +cabinet(C) :- cabinetTOthing(C,T). +cabinet(C) :- roomTOcabinet(R,C). + +% MODIFIED PROBLEM +% there are 2 types of things which are disjoint +thing(T) :- thingLong(T). +thing(T) :- thingShort(T). +thingShort(T) :- thing(T), not thingLong(T). +:- thingLong(T), thingShort(T). + +% long things have to be packed in high cabinets +% 1 <= {cabinetHigh(C); cabinetSmall(C)} <= 1 :- cabinet(C). +cabinetHigh(C) :- cabinet(C), not cabinetSmall(C). +cabinetSmall(C) :- cabinet(C), not cabinetHigh(C). +:- cabinet(C), cabinetHigh(C), cabinetSmall(C). +cabinetHigh(C) :- thingLong(T), cabinetTOthing(C,T). + +% at most either 2 high cabinets or 1 high and 2 short or 4 short cabinets +% are allowed to be in a room +% assumption : there are 4 cabinet slots in each room. +% High cabinet requires 2 slots, small - 1 slot +cabinetSize(C,1) :- cabinet(C), cabinetSmall(C). +cabinetSize(C,2) :- cabinet(C), cabinetHigh(C). +roomTOcabinetSize(R,C,S) :- roomTOcabinet(R,C), cabinetSize(C,S). +:- 5 <= #sum { S,C : roomTOcabinetSize(R,C,S), cabinetDomain(C) }, room(R). + +% TRANSFORMATION RULES +person(P) :- legacyConfig(person(P)). +thing(T) :- legacyConfig(thing(T)). +personTOthing(P,T) :- legacyConfig(personTOthing(P,T)). + +% 1 <= {reuse(cabinetTOthing(C,T)); delete(cabinetTOthing(C,T))} <= 1 :- legacyConfig(cabinetTOthing(C,T)). +reuse(cabinetTOthing(C,T)) :- legacyConfig(cabinetTOthing(C,T)), not delete(cabinetTOthing(C,T)). +delete(cabinetTOthing(C,T)) :- legacyConfig(cabinetTOthing(C,T)), not reuse(cabinetTOthing(C,T)). + +% 1 <= {reuse(roomTOcabinet(R,C)); delete(roomTOcabinet(R,C)) } <= 1 :- legacyConfig(roomTOcabinet(R,C)). +reuse(roomTOcabinet(R,C)) :- legacyConfig(roomTOcabinet(R,C)), not delete(roomTOcabinet(R,C)). +delete(roomTOcabinet(R,C)) :- legacyConfig(roomTOcabinet(R,C)), not reuse(roomTOcabinet(R,C)). + +% 1 <= {reuse(personTOroom(P,R)); delete(personTOroom(P,R)) } <= 1 :- legacyConfig(personTOroom(P,R)). +reuse(personTOroom(P,R)) :- legacyConfig(personTOroom(P,R)), not delete(personTOroom(P,R)). +delete(personTOroom(P,R)) :- legacyConfig(personTOroom(P,R)), not reuse(personTOroom(P,R)). + +% all cabinets from the original solution are added to the new domain +cabinetDomain(C) :- legacyConfig(cabinet(C)). +% 1 <= {reuse(cabinet(C)); delete(cabinet(C))} <= 1 :- legacyConfig(cabinet(C)). +reuse(cabinet(C)) :- legacyConfig(cabinet(C)), not delete(cabinet(C)). +delete(cabinet(C)) :- legacyConfig(cabinet(C)), not reuse(cabinet(C)). + +% all rooms from the original solution are added to the new domain +roomDomain(R) :- legacyConfig(room(R)). +% 1 <= {reuse(room(R)); delete(room(R))} <= 1 :- legacyConfig(room(R)). +reuse(room(R)) :- legacyConfig(room(R)), not delete(room(R)). +delete(room(R)) :- legacyConfig(room(R)), not reuse(room(R)). + +% all reused atoms should be a part of a reconfiguration +% i.e. they should be defined as facts +cabinetTOthing(C,T) :- reuse(cabinetTOthing(C,T)). +roomTOcabinet(R,C) :- reuse(roomTOcabinet(R,C)). +personTOroom(P,R) :- reuse(personTOroom(P,R)). +cabinet(C) :- reuse(cabinet(C)). +room(R) :- reuse(room(R)). + +% all deleted atoms cannot be used in a configuration +:- cabinetTOthing(C,T), delete(cabinetTOthing(C,T)). +:- roomTOcabinet(R,C), delete(roomTOcabinet(R,C)). +:- personTOroom(P,R), delete(personTOroom(P,R)). +:- cabinet(C), delete(cabinet(C)). +:- room(R), delete(room(R)). + +% CONSTRUCTIVE HEURISTICS +maxCabinet(C) :- cabinetDomainNew(C), not cabinetDomainNew(C+1). +maxRoom(R) :- roomDomainNew(R), not roomDomainNew(R+1). +fullCabinet(C) :- 5 <= #count { T : cabinetTOthing(C,T), thing(T) }, cabinet(C). +fullRoom(R) :- room(R), 4 <= #sum { S,C : roomTOcabinetSize(R,C,S), cabinetDomain(C) }. +assignedThing(T) :- cabinetTOthing(_,T). +assignedCabinet(C) :- roomTOcabinet(_,C). +personTOcabinet(P,C) :- personTOthing(P,T), cabinetTOthing(C,T). +personTOroom(P,R) :- roomTOcabinet(R,C), personTOcabinet(P,C). +otherPersonTOcabinet(P,C) :- personTOcabinet(P2,C), person(P), P!=P2. +otherPersonTOroom(P,R) :- roomTOcabinet(R,C), personTOcabinet(P2,C), person(P), P!=P2. +% first try to reuse legacy config (assigning long things before short things): +#heuristic reuse(cabinet(C)) : legacyConfig(cabinet(C)). [6@4] +#heuristic reuse(room(R)) : legacyConfig(room(R)). [5@4] +#heuristic reuse(cabinetTOthing(C,T)) : legacyConfig(cabinetTOthing(C,T)), thingLong(T). [4@4] +#heuristic reuse(cabinetTOthing(C,T)) : legacyConfig(cabinetTOthing(C,T)), not thingLong(T). [3@4] +#heuristic reuse(roomTOcabinet(R,C)) : legacyConfig(roomTOcabinet(R,C)). [2@4] +#heuristic reuse(personTOroom(P,R)) : legacyConfig(personTOroom(P,R)). [1@4] +% then fill cabinets with things (assigning long things before short things): +#heuristic cabinetTOthing(C,T) : cabinetDomain(C), not fullCabinet(C), not T assignedThing(T), personTOthing(P,T), not otherPersonTOcabinet(P,C), maxCabinet(MC), W=MC-C, thingLong(T). [W@3] +#heuristic cabinetTOthing(C,T) : cabinetDomain(C), not fullCabinet(C), not T assignedThing(T), personTOthing(P,T), not otherPersonTOcabinet(P,C), maxCabinet(MC), W=MC-C, not thingLong(T). [W@2] +% then fill rooms with cabinets: +#heuristic roomTOcabinet(R,C) : roomDomain(R), not fullRoom(R), cabinet(C), not T assignedCabinet(C), personTOcabinet(P,C), not otherPersonTOroom(P,R), maxRoom(MR), W=MR-R. [W@1] +% when all things and cabinets are assigned, close remaining choices: +#heuristic F cabinet(C) : not cabinet(C), cabinetDomain(C). +#heuristic F room(R) : not room(R), roomDomain(R). +#heuristic F cabinetTOthing(C,T) : not cabinetTOthing(C,T), cabinetDomain(C), thing(T). +#heuristic F roomTOcabinet(R,C) : not roomTOcabinet(R,C), roomDomain(R), cabinet(C). \ No newline at end of file diff --git a/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p05t025.edb b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p05t025.edb new file mode 100644 index 000000000..4d4a6d1c8 --- /dev/null +++ b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p05t025.edb @@ -0,0 +1,104 @@ +legacyConfig(person(1)). +legacyConfig(person(2)). +legacyConfig(person(3)). +legacyConfig(person(4)). +legacyConfig(person(5)). +legacyConfig(thing(12)). +thingShort(12). +legacyConfig(thing(13)). +thingShort(13). +legacyConfig(thing(14)). +thingShort(14). +legacyConfig(thing(15)). +thingShort(15). +legacyConfig(thing(16)). +thingShort(16). +legacyConfig(thing(17)). +thingShort(17). +legacyConfig(thing(18)). +thingShort(18). +legacyConfig(thing(19)). +thingShort(19). +legacyConfig(thing(20)). +thingShort(20). +legacyConfig(thing(21)). +thingShort(21). +legacyConfig(thing(22)). +thingShort(22). +legacyConfig(thing(23)). +thingShort(23). +legacyConfig(thing(24)). +thingShort(24). +legacyConfig(thing(25)). +thingShort(25). +legacyConfig(thing(26)). +thingShort(26). +legacyConfig(thing(27)). +thingShort(27). +legacyConfig(thing(28)). +thingShort(28). +legacyConfig(thing(6)). +thingShort(6). +legacyConfig(thing(29)). +thingShort(29). +legacyConfig(thing(30)). +thingShort(30). +legacyConfig(thing(7)). +thingShort(7). +legacyConfig(thing(8)). +thingShort(8). +legacyConfig(thing(9)). +thingShort(9). +legacyConfig(thing(10)). +thingShort(10). +legacyConfig(thing(11)). +thingShort(11). +legacyConfig(personTOthing(1,6)). +legacyConfig(personTOthing(1,7)). +legacyConfig(personTOthing(1,8)). +legacyConfig(personTOthing(1,9)). +legacyConfig(personTOthing(1,10)). +legacyConfig(personTOthing(2,11)). +legacyConfig(personTOthing(2,12)). +legacyConfig(personTOthing(2,13)). +legacyConfig(personTOthing(2,14)). +legacyConfig(personTOthing(2,15)). +legacyConfig(personTOthing(3,16)). +legacyConfig(personTOthing(3,17)). +legacyConfig(personTOthing(3,18)). +legacyConfig(personTOthing(3,19)). +legacyConfig(personTOthing(3,20)). +legacyConfig(personTOthing(4,21)). +legacyConfig(personTOthing(4,22)). +legacyConfig(personTOthing(4,23)). +legacyConfig(personTOthing(4,24)). +legacyConfig(personTOthing(4,25)). +legacyConfig(personTOthing(5,26)). +legacyConfig(personTOthing(5,27)). +legacyConfig(personTOthing(5,28)). +legacyConfig(personTOthing(5,29)). +legacyConfig(personTOthing(5,30)). +% domains +cabinetDomainNew(500..524). +roomDomainNew(1000..1024). +cabinetUpper(25). +roomUpper(25). +cabinetLower(5). +roomLower(2). +% reuse costs +reuseCabinetTOthingCost(0). +reuseRoomTOcabinetCost(0). +reusePersonTOroomCost(0). +reuseCabinetAsHighCost(3). +reuseCabinetAsSmallCost(0). +reuseRoomCost(0). +% remove costs +removeCabinetTOthingCost(2). +removeRoomTOcabinetCost(2). +removePersonTOroomCost(2). +removeCabinetCost(2). +removeRoomCost(2). +% create costs +cabinetHighCost(100). +cabinetSmallCost(1). +roomCost(5). diff --git a/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p100t500.edb b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p100t500.edb new file mode 100644 index 000000000..057a81a01 --- /dev/null +++ b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p100t500.edb @@ -0,0 +1,1624 @@ +legacyConfig(person(1)). +legacyConfig(person(2)). +legacyConfig(person(3)). +legacyConfig(person(4)). +legacyConfig(person(5)). +legacyConfig(person(6)). +legacyConfig(person(7)). +legacyConfig(person(8)). +legacyConfig(person(9)). +legacyConfig(person(10)). +legacyConfig(person(11)). +legacyConfig(person(12)). +legacyConfig(person(13)). +legacyConfig(person(14)). +legacyConfig(person(15)). +legacyConfig(person(16)). +legacyConfig(person(17)). +legacyConfig(person(18)). +legacyConfig(person(19)). +legacyConfig(person(20)). +legacyConfig(person(21)). +legacyConfig(person(22)). +legacyConfig(person(23)). +legacyConfig(person(24)). +legacyConfig(person(25)). +legacyConfig(person(26)). +legacyConfig(person(27)). +legacyConfig(person(28)). +legacyConfig(person(29)). +legacyConfig(person(30)). +legacyConfig(person(31)). +legacyConfig(person(32)). +legacyConfig(person(33)). +legacyConfig(person(34)). +legacyConfig(person(35)). +legacyConfig(person(36)). +legacyConfig(person(37)). +legacyConfig(person(38)). +legacyConfig(person(39)). +legacyConfig(person(40)). +legacyConfig(person(41)). +legacyConfig(person(42)). +legacyConfig(person(43)). +legacyConfig(person(44)). +legacyConfig(person(45)). +legacyConfig(person(46)). +legacyConfig(person(47)). +legacyConfig(person(48)). +legacyConfig(person(49)). +legacyConfig(person(50)). +legacyConfig(person(51)). +legacyConfig(person(52)). +legacyConfig(person(53)). +legacyConfig(person(54)). +legacyConfig(person(55)). +legacyConfig(person(56)). +legacyConfig(person(57)). +legacyConfig(person(58)). +legacyConfig(person(59)). +legacyConfig(person(60)). +legacyConfig(person(61)). +legacyConfig(person(62)). +legacyConfig(person(63)). +legacyConfig(person(64)). +legacyConfig(person(65)). +legacyConfig(person(66)). +legacyConfig(person(67)). +legacyConfig(person(68)). +legacyConfig(person(69)). +legacyConfig(person(70)). +legacyConfig(person(71)). +legacyConfig(person(72)). +legacyConfig(person(73)). +legacyConfig(person(74)). +legacyConfig(person(75)). +legacyConfig(person(76)). +legacyConfig(person(77)). +legacyConfig(person(78)). +legacyConfig(person(79)). +legacyConfig(person(80)). +legacyConfig(person(81)). +legacyConfig(person(82)). +legacyConfig(person(83)). +legacyConfig(person(84)). +legacyConfig(person(85)). +legacyConfig(person(86)). +legacyConfig(person(87)). +legacyConfig(person(88)). +legacyConfig(person(89)). +legacyConfig(person(90)). +legacyConfig(person(91)). +legacyConfig(person(92)). +legacyConfig(person(93)). +legacyConfig(person(94)). +legacyConfig(person(95)). +legacyConfig(person(96)). +legacyConfig(person(97)). +legacyConfig(person(98)). +legacyConfig(person(99)). +legacyConfig(person(100)). +legacyConfig(thing(101)). +thingShort(101). +legacyConfig(thing(102)). +thingShort(102). +legacyConfig(thing(103)). +thingShort(103). +legacyConfig(thing(104)). +thingShort(104). +legacyConfig(thing(105)). +thingShort(105). +legacyConfig(thing(106)). +thingShort(106). +legacyConfig(thing(107)). +thingShort(107). +legacyConfig(thing(108)). +thingShort(108). +legacyConfig(thing(109)). +thingShort(109). +legacyConfig(thing(110)). +thingShort(110). +legacyConfig(thing(111)). +thingShort(111). +legacyConfig(thing(112)). +thingShort(112). +legacyConfig(thing(113)). +thingShort(113). +legacyConfig(thing(114)). +thingShort(114). +legacyConfig(thing(115)). +thingShort(115). +legacyConfig(thing(116)). +thingShort(116). +legacyConfig(thing(117)). +thingShort(117). +legacyConfig(thing(118)). +thingShort(118). +legacyConfig(thing(119)). +thingShort(119). +legacyConfig(thing(120)). +thingShort(120). +legacyConfig(thing(121)). +thingShort(121). +legacyConfig(thing(122)). +thingShort(122). +legacyConfig(thing(123)). +thingShort(123). +legacyConfig(thing(124)). +thingShort(124). +legacyConfig(thing(125)). +thingShort(125). +legacyConfig(thing(126)). +thingShort(126). +legacyConfig(thing(127)). +thingShort(127). +legacyConfig(thing(128)). +thingShort(128). +legacyConfig(thing(129)). +thingShort(129). +legacyConfig(thing(130)). +thingShort(130). +legacyConfig(thing(131)). +thingShort(131). +legacyConfig(thing(132)). +thingShort(132). +legacyConfig(thing(133)). +thingShort(133). +legacyConfig(thing(134)). +thingShort(134). +legacyConfig(thing(135)). +thingShort(135). +legacyConfig(thing(136)). +thingShort(136). +legacyConfig(thing(137)). +thingShort(137). +legacyConfig(thing(138)). +thingShort(138). +legacyConfig(thing(139)). +thingShort(139). +legacyConfig(thing(140)). +thingShort(140). +legacyConfig(thing(141)). +thingShort(141). +legacyConfig(thing(142)). +thingShort(142). +legacyConfig(thing(143)). +thingShort(143). +legacyConfig(thing(144)). +thingShort(144). +legacyConfig(thing(145)). +thingShort(145). +legacyConfig(thing(146)). +thingShort(146). +legacyConfig(thing(147)). +thingShort(147). +legacyConfig(thing(148)). +thingShort(148). +legacyConfig(thing(149)). +thingShort(149). +legacyConfig(thing(150)). +thingShort(150). +legacyConfig(thing(151)). +thingShort(151). +legacyConfig(thing(152)). +thingShort(152). +legacyConfig(thing(153)). +thingShort(153). +legacyConfig(thing(154)). +thingShort(154). +legacyConfig(thing(155)). +thingShort(155). +legacyConfig(thing(156)). +thingShort(156). +legacyConfig(thing(157)). +thingShort(157). +legacyConfig(thing(158)). +thingShort(158). +legacyConfig(thing(159)). +thingShort(159). +legacyConfig(thing(160)). +thingShort(160). +legacyConfig(thing(161)). +thingShort(161). +legacyConfig(thing(162)). +thingShort(162). +legacyConfig(thing(163)). +thingShort(163). +legacyConfig(thing(164)). +thingShort(164). +legacyConfig(thing(165)). +thingShort(165). +legacyConfig(thing(166)). +thingShort(166). +legacyConfig(thing(167)). +thingShort(167). +legacyConfig(thing(168)). +thingShort(168). +legacyConfig(thing(169)). +thingShort(169). +legacyConfig(thing(170)). +thingShort(170). +legacyConfig(thing(171)). +thingShort(171). +legacyConfig(thing(172)). +thingShort(172). +legacyConfig(thing(173)). +thingShort(173). +legacyConfig(thing(174)). +thingShort(174). +legacyConfig(thing(175)). +thingShort(175). +legacyConfig(thing(176)). +thingShort(176). +legacyConfig(thing(177)). +thingShort(177). +legacyConfig(thing(178)). +thingShort(178). +legacyConfig(thing(179)). +thingShort(179). +legacyConfig(thing(180)). +thingShort(180). +legacyConfig(thing(181)). +thingShort(181). +legacyConfig(thing(182)). +thingShort(182). +legacyConfig(thing(183)). +thingShort(183). +legacyConfig(thing(184)). +thingShort(184). +legacyConfig(thing(185)). +thingShort(185). +legacyConfig(thing(186)). +thingShort(186). +legacyConfig(thing(187)). +thingShort(187). +legacyConfig(thing(188)). +thingShort(188). +legacyConfig(thing(189)). +thingShort(189). +legacyConfig(thing(190)). +thingShort(190). +legacyConfig(thing(191)). +thingShort(191). +legacyConfig(thing(192)). +thingShort(192). +legacyConfig(thing(193)). +thingShort(193). +legacyConfig(thing(194)). +thingShort(194). +legacyConfig(thing(195)). +thingShort(195). +legacyConfig(thing(196)). +thingShort(196). +legacyConfig(thing(197)). +thingShort(197). +legacyConfig(thing(198)). +thingShort(198). +legacyConfig(thing(199)). +thingShort(199). +legacyConfig(thing(200)). +thingShort(200). +legacyConfig(thing(201)). +thingShort(201). +legacyConfig(thing(202)). +thingShort(202). +legacyConfig(thing(203)). +thingShort(203). +legacyConfig(thing(204)). +thingShort(204). +legacyConfig(thing(205)). +thingShort(205). +legacyConfig(thing(206)). +thingShort(206). +legacyConfig(thing(207)). +thingShort(207). +legacyConfig(thing(208)). +thingShort(208). +legacyConfig(thing(209)). +thingShort(209). +legacyConfig(thing(210)). +thingShort(210). +legacyConfig(thing(211)). +thingShort(211). +legacyConfig(thing(212)). +thingShort(212). +legacyConfig(thing(213)). +thingShort(213). +legacyConfig(thing(214)). +thingShort(214). +legacyConfig(thing(215)). +thingShort(215). +legacyConfig(thing(216)). +thingShort(216). +legacyConfig(thing(217)). +thingShort(217). +legacyConfig(thing(218)). +thingShort(218). +legacyConfig(thing(219)). +thingShort(219). +legacyConfig(thing(220)). +thingShort(220). +legacyConfig(thing(221)). +thingShort(221). +legacyConfig(thing(222)). +thingShort(222). +legacyConfig(thing(223)). +thingShort(223). +legacyConfig(thing(224)). +thingShort(224). +legacyConfig(thing(225)). +thingShort(225). +legacyConfig(thing(226)). +thingShort(226). +legacyConfig(thing(227)). +thingShort(227). +legacyConfig(thing(228)). +thingShort(228). +legacyConfig(thing(229)). +thingShort(229). +legacyConfig(thing(230)). +thingShort(230). +legacyConfig(thing(231)). +thingShort(231). +legacyConfig(thing(232)). +thingShort(232). +legacyConfig(thing(233)). +thingShort(233). +legacyConfig(thing(234)). +thingShort(234). +legacyConfig(thing(235)). +thingShort(235). +legacyConfig(thing(236)). +thingShort(236). +legacyConfig(thing(237)). +thingShort(237). +legacyConfig(thing(238)). +thingShort(238). +legacyConfig(thing(239)). +thingShort(239). +legacyConfig(thing(240)). +thingShort(240). +legacyConfig(thing(241)). +thingShort(241). +legacyConfig(thing(242)). +thingShort(242). +legacyConfig(thing(243)). +thingShort(243). +legacyConfig(thing(244)). +thingShort(244). +legacyConfig(thing(245)). +thingShort(245). +legacyConfig(thing(246)). +thingShort(246). +legacyConfig(thing(247)). +thingShort(247). +legacyConfig(thing(248)). +thingShort(248). +legacyConfig(thing(249)). +thingShort(249). +legacyConfig(thing(250)). +thingShort(250). +legacyConfig(thing(251)). +thingShort(251). +legacyConfig(thing(252)). +thingShort(252). +legacyConfig(thing(253)). +thingShort(253). +legacyConfig(thing(254)). +thingShort(254). +legacyConfig(thing(255)). +thingShort(255). +legacyConfig(thing(256)). +thingShort(256). +legacyConfig(thing(257)). +thingShort(257). +legacyConfig(thing(258)). +thingShort(258). +legacyConfig(thing(259)). +thingShort(259). +legacyConfig(thing(260)). +thingShort(260). +legacyConfig(thing(261)). +thingShort(261). +legacyConfig(thing(262)). +thingShort(262). +legacyConfig(thing(263)). +thingShort(263). +legacyConfig(thing(264)). +thingShort(264). +legacyConfig(thing(265)). +thingShort(265). +legacyConfig(thing(266)). +thingShort(266). +legacyConfig(thing(267)). +thingShort(267). +legacyConfig(thing(268)). +thingShort(268). +legacyConfig(thing(269)). +thingShort(269). +legacyConfig(thing(270)). +thingShort(270). +legacyConfig(thing(271)). +thingShort(271). +legacyConfig(thing(272)). +thingShort(272). +legacyConfig(thing(273)). +thingShort(273). +legacyConfig(thing(274)). +thingShort(274). +legacyConfig(thing(275)). +thingShort(275). +legacyConfig(thing(276)). +thingShort(276). +legacyConfig(thing(277)). +thingShort(277). +legacyConfig(thing(278)). +thingShort(278). +legacyConfig(thing(279)). +thingShort(279). +legacyConfig(thing(280)). +thingShort(280). +legacyConfig(thing(281)). +thingShort(281). +legacyConfig(thing(282)). +thingShort(282). +legacyConfig(thing(283)). +thingShort(283). +legacyConfig(thing(284)). +thingShort(284). +legacyConfig(thing(285)). +thingShort(285). +legacyConfig(thing(286)). +thingShort(286). +legacyConfig(thing(287)). +thingShort(287). +legacyConfig(thing(288)). +thingShort(288). +legacyConfig(thing(289)). +thingShort(289). +legacyConfig(thing(290)). +thingShort(290). +legacyConfig(thing(291)). +thingShort(291). +legacyConfig(thing(292)). +thingShort(292). +legacyConfig(thing(293)). +thingShort(293). +legacyConfig(thing(294)). +thingShort(294). +legacyConfig(thing(295)). +thingShort(295). +legacyConfig(thing(296)). +thingShort(296). +legacyConfig(thing(297)). +thingShort(297). +legacyConfig(thing(298)). +thingShort(298). +legacyConfig(thing(299)). +thingShort(299). +legacyConfig(thing(300)). +thingShort(300). +legacyConfig(thing(301)). +thingShort(301). +legacyConfig(thing(302)). +thingShort(302). +legacyConfig(thing(303)). +thingShort(303). +legacyConfig(thing(304)). +thingShort(304). +legacyConfig(thing(305)). +thingShort(305). +legacyConfig(thing(306)). +thingShort(306). +legacyConfig(thing(307)). +thingShort(307). +legacyConfig(thing(308)). +thingShort(308). +legacyConfig(thing(309)). +thingShort(309). +legacyConfig(thing(310)). +thingShort(310). +legacyConfig(thing(311)). +thingShort(311). +legacyConfig(thing(312)). +thingShort(312). +legacyConfig(thing(313)). +thingShort(313). +legacyConfig(thing(314)). +thingShort(314). +legacyConfig(thing(315)). +thingShort(315). +legacyConfig(thing(316)). +thingShort(316). +legacyConfig(thing(317)). +thingShort(317). +legacyConfig(thing(318)). +thingShort(318). +legacyConfig(thing(319)). +thingShort(319). +legacyConfig(thing(320)). +thingShort(320). +legacyConfig(thing(321)). +thingShort(321). +legacyConfig(thing(322)). +thingShort(322). +legacyConfig(thing(323)). +thingShort(323). +legacyConfig(thing(324)). +thingShort(324). +legacyConfig(thing(325)). +thingShort(325). +legacyConfig(thing(326)). +thingShort(326). +legacyConfig(thing(327)). +thingShort(327). +legacyConfig(thing(328)). +thingShort(328). +legacyConfig(thing(329)). +thingShort(329). +legacyConfig(thing(330)). +thingShort(330). +legacyConfig(thing(331)). +thingShort(331). +legacyConfig(thing(332)). +thingShort(332). +legacyConfig(thing(333)). +thingShort(333). +legacyConfig(thing(334)). +thingShort(334). +legacyConfig(thing(335)). +thingShort(335). +legacyConfig(thing(336)). +thingShort(336). +legacyConfig(thing(337)). +thingShort(337). +legacyConfig(thing(338)). +thingShort(338). +legacyConfig(thing(339)). +thingShort(339). +legacyConfig(thing(340)). +thingShort(340). +legacyConfig(thing(341)). +thingShort(341). +legacyConfig(thing(342)). +thingShort(342). +legacyConfig(thing(343)). +thingShort(343). +legacyConfig(thing(344)). +thingShort(344). +legacyConfig(thing(345)). +thingShort(345). +legacyConfig(thing(346)). +thingShort(346). +legacyConfig(thing(347)). +thingShort(347). +legacyConfig(thing(348)). +thingShort(348). +legacyConfig(thing(349)). +thingShort(349). +legacyConfig(thing(350)). +thingShort(350). +legacyConfig(thing(351)). +thingShort(351). +legacyConfig(thing(352)). +thingShort(352). +legacyConfig(thing(353)). +thingShort(353). +legacyConfig(thing(354)). +thingShort(354). +legacyConfig(thing(355)). +thingShort(355). +legacyConfig(thing(356)). +thingShort(356). +legacyConfig(thing(357)). +thingShort(357). +legacyConfig(thing(358)). +thingShort(358). +legacyConfig(thing(359)). +thingShort(359). +legacyConfig(thing(360)). +thingShort(360). +legacyConfig(thing(361)). +thingShort(361). +legacyConfig(thing(362)). +thingShort(362). +legacyConfig(thing(363)). +thingShort(363). +legacyConfig(thing(364)). +thingShort(364). +legacyConfig(thing(365)). +thingShort(365). +legacyConfig(thing(366)). +thingShort(366). +legacyConfig(thing(367)). +thingShort(367). +legacyConfig(thing(368)). +thingShort(368). +legacyConfig(thing(369)). +thingShort(369). +legacyConfig(thing(370)). +thingShort(370). +legacyConfig(thing(371)). +thingShort(371). +legacyConfig(thing(372)). +thingShort(372). +legacyConfig(thing(373)). +thingShort(373). +legacyConfig(thing(374)). +thingShort(374). +legacyConfig(thing(375)). +thingShort(375). +legacyConfig(thing(376)). +thingShort(376). +legacyConfig(thing(377)). +thingShort(377). +legacyConfig(thing(378)). +thingShort(378). +legacyConfig(thing(379)). +thingShort(379). +legacyConfig(thing(380)). +thingShort(380). +legacyConfig(thing(381)). +thingShort(381). +legacyConfig(thing(382)). +thingShort(382). +legacyConfig(thing(383)). +thingShort(383). +legacyConfig(thing(384)). +thingShort(384). +legacyConfig(thing(385)). +thingShort(385). +legacyConfig(thing(386)). +thingShort(386). +legacyConfig(thing(387)). +thingShort(387). +legacyConfig(thing(388)). +thingShort(388). +legacyConfig(thing(389)). +thingShort(389). +legacyConfig(thing(390)). +thingShort(390). +legacyConfig(thing(391)). +thingShort(391). +legacyConfig(thing(392)). +thingShort(392). +legacyConfig(thing(393)). +thingShort(393). +legacyConfig(thing(394)). +thingShort(394). +legacyConfig(thing(395)). +thingShort(395). +legacyConfig(thing(396)). +thingShort(396). +legacyConfig(thing(397)). +thingShort(397). +legacyConfig(thing(398)). +thingShort(398). +legacyConfig(thing(399)). +thingShort(399). +legacyConfig(thing(400)). +thingShort(400). +legacyConfig(thing(401)). +thingShort(401). +legacyConfig(thing(402)). +thingShort(402). +legacyConfig(thing(403)). +thingShort(403). +legacyConfig(thing(404)). +thingShort(404). +legacyConfig(thing(405)). +thingShort(405). +legacyConfig(thing(406)). +thingShort(406). +legacyConfig(thing(407)). +thingShort(407). +legacyConfig(thing(408)). +thingShort(408). +legacyConfig(thing(409)). +thingShort(409). +legacyConfig(thing(410)). +thingShort(410). +legacyConfig(thing(411)). +thingShort(411). +legacyConfig(thing(412)). +thingShort(412). +legacyConfig(thing(413)). +thingShort(413). +legacyConfig(thing(414)). +thingShort(414). +legacyConfig(thing(415)). +thingShort(415). +legacyConfig(thing(416)). +thingShort(416). +legacyConfig(thing(417)). +thingShort(417). +legacyConfig(thing(418)). +thingShort(418). +legacyConfig(thing(419)). +thingShort(419). +legacyConfig(thing(420)). +thingShort(420). +legacyConfig(thing(421)). +thingShort(421). +legacyConfig(thing(422)). +thingShort(422). +legacyConfig(thing(423)). +thingShort(423). +legacyConfig(thing(424)). +thingShort(424). +legacyConfig(thing(425)). +thingShort(425). +legacyConfig(thing(426)). +thingShort(426). +legacyConfig(thing(427)). +thingShort(427). +legacyConfig(thing(428)). +thingShort(428). +legacyConfig(thing(429)). +thingShort(429). +legacyConfig(thing(430)). +thingShort(430). +legacyConfig(thing(431)). +thingShort(431). +legacyConfig(thing(432)). +thingShort(432). +legacyConfig(thing(433)). +thingShort(433). +legacyConfig(thing(434)). +thingShort(434). +legacyConfig(thing(435)). +thingShort(435). +legacyConfig(thing(436)). +thingShort(436). +legacyConfig(thing(437)). +thingShort(437). +legacyConfig(thing(438)). +thingShort(438). +legacyConfig(thing(439)). +thingShort(439). +legacyConfig(thing(440)). +thingShort(440). +legacyConfig(thing(441)). +thingShort(441). +legacyConfig(thing(442)). +thingShort(442). +legacyConfig(thing(443)). +thingShort(443). +legacyConfig(thing(444)). +thingShort(444). +legacyConfig(thing(445)). +thingShort(445). +legacyConfig(thing(446)). +thingShort(446). +legacyConfig(thing(447)). +thingShort(447). +legacyConfig(thing(448)). +thingShort(448). +legacyConfig(thing(449)). +thingShort(449). +legacyConfig(thing(450)). +thingShort(450). +legacyConfig(thing(451)). +thingShort(451). +legacyConfig(thing(452)). +thingShort(452). +legacyConfig(thing(453)). +thingShort(453). +legacyConfig(thing(454)). +thingShort(454). +legacyConfig(thing(455)). +thingShort(455). +legacyConfig(thing(456)). +thingShort(456). +legacyConfig(thing(457)). +thingShort(457). +legacyConfig(thing(458)). +thingShort(458). +legacyConfig(thing(459)). +thingShort(459). +legacyConfig(thing(460)). +thingShort(460). +legacyConfig(thing(461)). +thingShort(461). +legacyConfig(thing(462)). +thingShort(462). +legacyConfig(thing(463)). +thingShort(463). +legacyConfig(thing(464)). +thingShort(464). +legacyConfig(thing(465)). +thingShort(465). +legacyConfig(thing(466)). +thingShort(466). +legacyConfig(thing(467)). +thingShort(467). +legacyConfig(thing(468)). +thingShort(468). +legacyConfig(thing(469)). +thingShort(469). +legacyConfig(thing(470)). +thingShort(470). +legacyConfig(thing(471)). +thingShort(471). +legacyConfig(thing(472)). +thingShort(472). +legacyConfig(thing(473)). +thingShort(473). +legacyConfig(thing(474)). +thingShort(474). +legacyConfig(thing(475)). +thingShort(475). +legacyConfig(thing(476)). +thingShort(476). +legacyConfig(thing(477)). +thingShort(477). +legacyConfig(thing(478)). +thingShort(478). +legacyConfig(thing(479)). +thingShort(479). +legacyConfig(thing(480)). +thingShort(480). +legacyConfig(thing(481)). +thingShort(481). +legacyConfig(thing(482)). +thingShort(482). +legacyConfig(thing(483)). +thingShort(483). +legacyConfig(thing(484)). +thingShort(484). +legacyConfig(thing(485)). +thingShort(485). +legacyConfig(thing(486)). +thingShort(486). +legacyConfig(thing(487)). +thingShort(487). +legacyConfig(thing(488)). +thingShort(488). +legacyConfig(thing(489)). +thingShort(489). +legacyConfig(thing(490)). +thingShort(490). +legacyConfig(thing(491)). +thingShort(491). +legacyConfig(thing(492)). +thingShort(492). +legacyConfig(thing(493)). +thingShort(493). +legacyConfig(thing(494)). +thingShort(494). +legacyConfig(thing(495)). +thingShort(495). +legacyConfig(thing(496)). +thingShort(496). +legacyConfig(thing(497)). +thingShort(497). +legacyConfig(thing(498)). +thingShort(498). +legacyConfig(thing(499)). +thingShort(499). +legacyConfig(thing(500)). +thingShort(500). +legacyConfig(thing(501)). +thingShort(501). +legacyConfig(thing(502)). +thingShort(502). +legacyConfig(thing(503)). +thingShort(503). +legacyConfig(thing(504)). +thingShort(504). +legacyConfig(thing(505)). +thingShort(505). +legacyConfig(thing(506)). +thingShort(506). +legacyConfig(thing(507)). +thingShort(507). +legacyConfig(thing(508)). +thingShort(508). +legacyConfig(thing(509)). +thingShort(509). +legacyConfig(thing(510)). +thingShort(510). +legacyConfig(thing(511)). +thingShort(511). +legacyConfig(thing(512)). +thingShort(512). +legacyConfig(thing(513)). +thingShort(513). +legacyConfig(thing(514)). +thingShort(514). +legacyConfig(thing(515)). +thingShort(515). +legacyConfig(thing(516)). +thingShort(516). +legacyConfig(thing(517)). +thingShort(517). +legacyConfig(thing(518)). +thingShort(518). +legacyConfig(thing(519)). +thingShort(519). +legacyConfig(thing(520)). +thingShort(520). +legacyConfig(thing(521)). +thingShort(521). +legacyConfig(thing(522)). +thingShort(522). +legacyConfig(thing(523)). +thingShort(523). +legacyConfig(thing(524)). +thingShort(524). +legacyConfig(thing(525)). +thingShort(525). +legacyConfig(thing(526)). +thingShort(526). +legacyConfig(thing(527)). +thingShort(527). +legacyConfig(thing(528)). +thingShort(528). +legacyConfig(thing(529)). +thingShort(529). +legacyConfig(thing(530)). +thingShort(530). +legacyConfig(thing(531)). +thingShort(531). +legacyConfig(thing(532)). +thingShort(532). +legacyConfig(thing(533)). +thingShort(533). +legacyConfig(thing(534)). +thingShort(534). +legacyConfig(thing(535)). +thingShort(535). +legacyConfig(thing(536)). +thingShort(536). +legacyConfig(thing(537)). +thingShort(537). +legacyConfig(thing(538)). +thingShort(538). +legacyConfig(thing(539)). +thingShort(539). +legacyConfig(thing(540)). +thingShort(540). +legacyConfig(thing(541)). +thingShort(541). +legacyConfig(thing(542)). +thingShort(542). +legacyConfig(thing(543)). +thingShort(543). +legacyConfig(thing(544)). +thingShort(544). +legacyConfig(thing(545)). +thingShort(545). +legacyConfig(thing(546)). +thingShort(546). +legacyConfig(thing(547)). +thingShort(547). +legacyConfig(thing(548)). +thingShort(548). +legacyConfig(thing(549)). +thingShort(549). +legacyConfig(thing(550)). +thingShort(550). +legacyConfig(thing(551)). +thingShort(551). +legacyConfig(thing(552)). +thingShort(552). +legacyConfig(thing(553)). +thingShort(553). +legacyConfig(thing(554)). +thingShort(554). +legacyConfig(thing(555)). +thingShort(555). +legacyConfig(thing(556)). +thingShort(556). +legacyConfig(thing(557)). +thingShort(557). +legacyConfig(thing(558)). +thingShort(558). +legacyConfig(thing(559)). +thingShort(559). +legacyConfig(thing(560)). +thingShort(560). +legacyConfig(thing(561)). +thingShort(561). +legacyConfig(thing(562)). +thingShort(562). +legacyConfig(thing(563)). +thingShort(563). +legacyConfig(thing(564)). +thingShort(564). +legacyConfig(thing(565)). +thingShort(565). +legacyConfig(thing(566)). +thingShort(566). +legacyConfig(thing(567)). +thingShort(567). +legacyConfig(thing(568)). +thingShort(568). +legacyConfig(thing(569)). +thingShort(569). +legacyConfig(thing(570)). +thingShort(570). +legacyConfig(thing(571)). +thingShort(571). +legacyConfig(thing(572)). +thingShort(572). +legacyConfig(thing(573)). +thingShort(573). +legacyConfig(thing(574)). +thingShort(574). +legacyConfig(thing(575)). +thingShort(575). +legacyConfig(thing(576)). +thingShort(576). +legacyConfig(thing(577)). +thingShort(577). +legacyConfig(thing(578)). +thingShort(578). +legacyConfig(thing(579)). +thingShort(579). +legacyConfig(thing(580)). +thingShort(580). +legacyConfig(thing(581)). +thingShort(581). +legacyConfig(thing(582)). +thingShort(582). +legacyConfig(thing(583)). +thingShort(583). +legacyConfig(thing(584)). +thingShort(584). +legacyConfig(thing(585)). +thingShort(585). +legacyConfig(thing(586)). +thingShort(586). +legacyConfig(thing(587)). +thingShort(587). +legacyConfig(thing(588)). +thingShort(588). +legacyConfig(thing(589)). +thingShort(589). +legacyConfig(thing(590)). +thingShort(590). +legacyConfig(thing(591)). +thingShort(591). +legacyConfig(thing(592)). +thingShort(592). +legacyConfig(thing(593)). +thingShort(593). +legacyConfig(thing(594)). +thingShort(594). +legacyConfig(thing(595)). +thingShort(595). +legacyConfig(thing(596)). +thingShort(596). +legacyConfig(thing(597)). +thingShort(597). +legacyConfig(thing(598)). +thingShort(598). +legacyConfig(thing(599)). +thingShort(599). +legacyConfig(thing(600)). +thingShort(600). +legacyConfig(personTOthing(1,101)). +legacyConfig(personTOthing(1,102)). +legacyConfig(personTOthing(1,103)). +legacyConfig(personTOthing(1,104)). +legacyConfig(personTOthing(1,105)). +legacyConfig(personTOthing(2,106)). +legacyConfig(personTOthing(2,107)). +legacyConfig(personTOthing(2,108)). +legacyConfig(personTOthing(2,109)). +legacyConfig(personTOthing(2,110)). +legacyConfig(personTOthing(3,111)). +legacyConfig(personTOthing(3,112)). +legacyConfig(personTOthing(3,113)). +legacyConfig(personTOthing(3,114)). +legacyConfig(personTOthing(3,115)). +legacyConfig(personTOthing(4,116)). +legacyConfig(personTOthing(4,117)). +legacyConfig(personTOthing(4,118)). +legacyConfig(personTOthing(4,119)). +legacyConfig(personTOthing(4,120)). +legacyConfig(personTOthing(5,121)). +legacyConfig(personTOthing(5,122)). +legacyConfig(personTOthing(5,123)). +legacyConfig(personTOthing(5,124)). +legacyConfig(personTOthing(5,125)). +legacyConfig(personTOthing(6,126)). +legacyConfig(personTOthing(6,127)). +legacyConfig(personTOthing(6,128)). +legacyConfig(personTOthing(6,129)). +legacyConfig(personTOthing(6,130)). +legacyConfig(personTOthing(7,131)). +legacyConfig(personTOthing(7,132)). +legacyConfig(personTOthing(7,133)). +legacyConfig(personTOthing(7,134)). +legacyConfig(personTOthing(7,135)). +legacyConfig(personTOthing(8,136)). +legacyConfig(personTOthing(8,137)). +legacyConfig(personTOthing(8,138)). +legacyConfig(personTOthing(8,139)). +legacyConfig(personTOthing(8,140)). +legacyConfig(personTOthing(9,141)). +legacyConfig(personTOthing(9,142)). +legacyConfig(personTOthing(9,143)). +legacyConfig(personTOthing(9,144)). +legacyConfig(personTOthing(9,145)). +legacyConfig(personTOthing(10,146)). +legacyConfig(personTOthing(10,147)). +legacyConfig(personTOthing(10,148)). +legacyConfig(personTOthing(10,149)). +legacyConfig(personTOthing(10,150)). +legacyConfig(personTOthing(11,151)). +legacyConfig(personTOthing(11,152)). +legacyConfig(personTOthing(11,153)). +legacyConfig(personTOthing(11,154)). +legacyConfig(personTOthing(11,155)). +legacyConfig(personTOthing(12,156)). +legacyConfig(personTOthing(12,157)). +legacyConfig(personTOthing(12,158)). +legacyConfig(personTOthing(12,159)). +legacyConfig(personTOthing(12,160)). +legacyConfig(personTOthing(13,161)). +legacyConfig(personTOthing(13,162)). +legacyConfig(personTOthing(13,163)). +legacyConfig(personTOthing(13,164)). +legacyConfig(personTOthing(13,165)). +legacyConfig(personTOthing(14,166)). +legacyConfig(personTOthing(14,167)). +legacyConfig(personTOthing(14,168)). +legacyConfig(personTOthing(14,169)). +legacyConfig(personTOthing(14,170)). +legacyConfig(personTOthing(15,171)). +legacyConfig(personTOthing(15,172)). +legacyConfig(personTOthing(15,173)). +legacyConfig(personTOthing(15,174)). +legacyConfig(personTOthing(15,175)). +legacyConfig(personTOthing(16,176)). +legacyConfig(personTOthing(16,177)). +legacyConfig(personTOthing(16,178)). +legacyConfig(personTOthing(16,179)). +legacyConfig(personTOthing(16,180)). +legacyConfig(personTOthing(17,181)). +legacyConfig(personTOthing(17,182)). +legacyConfig(personTOthing(17,183)). +legacyConfig(personTOthing(17,184)). +legacyConfig(personTOthing(17,185)). +legacyConfig(personTOthing(18,186)). +legacyConfig(personTOthing(18,187)). +legacyConfig(personTOthing(18,188)). +legacyConfig(personTOthing(18,189)). +legacyConfig(personTOthing(18,190)). +legacyConfig(personTOthing(19,191)). +legacyConfig(personTOthing(19,192)). +legacyConfig(personTOthing(19,193)). +legacyConfig(personTOthing(19,194)). +legacyConfig(personTOthing(19,195)). +legacyConfig(personTOthing(20,196)). +legacyConfig(personTOthing(20,197)). +legacyConfig(personTOthing(20,198)). +legacyConfig(personTOthing(20,199)). +legacyConfig(personTOthing(20,200)). +legacyConfig(personTOthing(21,201)). +legacyConfig(personTOthing(21,202)). +legacyConfig(personTOthing(21,203)). +legacyConfig(personTOthing(21,204)). +legacyConfig(personTOthing(21,205)). +legacyConfig(personTOthing(22,206)). +legacyConfig(personTOthing(22,207)). +legacyConfig(personTOthing(22,208)). +legacyConfig(personTOthing(22,209)). +legacyConfig(personTOthing(22,210)). +legacyConfig(personTOthing(23,211)). +legacyConfig(personTOthing(23,212)). +legacyConfig(personTOthing(23,213)). +legacyConfig(personTOthing(23,214)). +legacyConfig(personTOthing(23,215)). +legacyConfig(personTOthing(24,216)). +legacyConfig(personTOthing(24,217)). +legacyConfig(personTOthing(24,218)). +legacyConfig(personTOthing(24,219)). +legacyConfig(personTOthing(24,220)). +legacyConfig(personTOthing(25,221)). +legacyConfig(personTOthing(25,222)). +legacyConfig(personTOthing(25,223)). +legacyConfig(personTOthing(25,224)). +legacyConfig(personTOthing(25,225)). +legacyConfig(personTOthing(26,226)). +legacyConfig(personTOthing(26,227)). +legacyConfig(personTOthing(26,228)). +legacyConfig(personTOthing(26,229)). +legacyConfig(personTOthing(26,230)). +legacyConfig(personTOthing(27,231)). +legacyConfig(personTOthing(27,232)). +legacyConfig(personTOthing(27,233)). +legacyConfig(personTOthing(27,234)). +legacyConfig(personTOthing(27,235)). +legacyConfig(personTOthing(28,236)). +legacyConfig(personTOthing(28,237)). +legacyConfig(personTOthing(28,238)). +legacyConfig(personTOthing(28,239)). +legacyConfig(personTOthing(28,240)). +legacyConfig(personTOthing(29,241)). +legacyConfig(personTOthing(29,242)). +legacyConfig(personTOthing(29,243)). +legacyConfig(personTOthing(29,244)). +legacyConfig(personTOthing(29,245)). +legacyConfig(personTOthing(30,246)). +legacyConfig(personTOthing(30,247)). +legacyConfig(personTOthing(30,248)). +legacyConfig(personTOthing(30,249)). +legacyConfig(personTOthing(30,250)). +legacyConfig(personTOthing(31,251)). +legacyConfig(personTOthing(31,252)). +legacyConfig(personTOthing(31,253)). +legacyConfig(personTOthing(31,254)). +legacyConfig(personTOthing(31,255)). +legacyConfig(personTOthing(32,256)). +legacyConfig(personTOthing(32,257)). +legacyConfig(personTOthing(32,258)). +legacyConfig(personTOthing(32,259)). +legacyConfig(personTOthing(32,260)). +legacyConfig(personTOthing(33,261)). +legacyConfig(personTOthing(33,262)). +legacyConfig(personTOthing(33,263)). +legacyConfig(personTOthing(33,264)). +legacyConfig(personTOthing(33,265)). +legacyConfig(personTOthing(34,266)). +legacyConfig(personTOthing(34,267)). +legacyConfig(personTOthing(34,268)). +legacyConfig(personTOthing(34,269)). +legacyConfig(personTOthing(34,270)). +legacyConfig(personTOthing(35,271)). +legacyConfig(personTOthing(35,272)). +legacyConfig(personTOthing(35,273)). +legacyConfig(personTOthing(35,274)). +legacyConfig(personTOthing(35,275)). +legacyConfig(personTOthing(36,276)). +legacyConfig(personTOthing(36,277)). +legacyConfig(personTOthing(36,278)). +legacyConfig(personTOthing(36,279)). +legacyConfig(personTOthing(36,280)). +legacyConfig(personTOthing(37,281)). +legacyConfig(personTOthing(37,282)). +legacyConfig(personTOthing(37,283)). +legacyConfig(personTOthing(37,284)). +legacyConfig(personTOthing(37,285)). +legacyConfig(personTOthing(38,286)). +legacyConfig(personTOthing(38,287)). +legacyConfig(personTOthing(38,288)). +legacyConfig(personTOthing(38,289)). +legacyConfig(personTOthing(38,290)). +legacyConfig(personTOthing(39,291)). +legacyConfig(personTOthing(39,292)). +legacyConfig(personTOthing(39,293)). +legacyConfig(personTOthing(39,294)). +legacyConfig(personTOthing(39,295)). +legacyConfig(personTOthing(40,296)). +legacyConfig(personTOthing(40,297)). +legacyConfig(personTOthing(40,298)). +legacyConfig(personTOthing(40,299)). +legacyConfig(personTOthing(40,300)). +legacyConfig(personTOthing(41,301)). +legacyConfig(personTOthing(41,302)). +legacyConfig(personTOthing(41,303)). +legacyConfig(personTOthing(41,304)). +legacyConfig(personTOthing(41,305)). +legacyConfig(personTOthing(42,306)). +legacyConfig(personTOthing(42,307)). +legacyConfig(personTOthing(42,308)). +legacyConfig(personTOthing(42,309)). +legacyConfig(personTOthing(42,310)). +legacyConfig(personTOthing(43,311)). +legacyConfig(personTOthing(43,312)). +legacyConfig(personTOthing(43,313)). +legacyConfig(personTOthing(43,314)). +legacyConfig(personTOthing(43,315)). +legacyConfig(personTOthing(44,316)). +legacyConfig(personTOthing(44,317)). +legacyConfig(personTOthing(44,318)). +legacyConfig(personTOthing(44,319)). +legacyConfig(personTOthing(44,320)). +legacyConfig(personTOthing(45,321)). +legacyConfig(personTOthing(45,322)). +legacyConfig(personTOthing(45,323)). +legacyConfig(personTOthing(45,324)). +legacyConfig(personTOthing(45,325)). +legacyConfig(personTOthing(46,326)). +legacyConfig(personTOthing(46,327)). +legacyConfig(personTOthing(46,328)). +legacyConfig(personTOthing(46,329)). +legacyConfig(personTOthing(46,330)). +legacyConfig(personTOthing(47,331)). +legacyConfig(personTOthing(47,332)). +legacyConfig(personTOthing(47,333)). +legacyConfig(personTOthing(47,334)). +legacyConfig(personTOthing(47,335)). +legacyConfig(personTOthing(48,336)). +legacyConfig(personTOthing(48,337)). +legacyConfig(personTOthing(48,338)). +legacyConfig(personTOthing(48,339)). +legacyConfig(personTOthing(48,340)). +legacyConfig(personTOthing(49,341)). +legacyConfig(personTOthing(49,342)). +legacyConfig(personTOthing(49,343)). +legacyConfig(personTOthing(49,344)). +legacyConfig(personTOthing(49,345)). +legacyConfig(personTOthing(50,346)). +legacyConfig(personTOthing(50,347)). +legacyConfig(personTOthing(50,348)). +legacyConfig(personTOthing(50,349)). +legacyConfig(personTOthing(50,350)). +legacyConfig(personTOthing(51,351)). +legacyConfig(personTOthing(51,352)). +legacyConfig(personTOthing(51,353)). +legacyConfig(personTOthing(51,354)). +legacyConfig(personTOthing(51,355)). +legacyConfig(personTOthing(52,356)). +legacyConfig(personTOthing(52,357)). +legacyConfig(personTOthing(52,358)). +legacyConfig(personTOthing(52,359)). +legacyConfig(personTOthing(52,360)). +legacyConfig(personTOthing(53,361)). +legacyConfig(personTOthing(53,362)). +legacyConfig(personTOthing(53,363)). +legacyConfig(personTOthing(53,364)). +legacyConfig(personTOthing(53,365)). +legacyConfig(personTOthing(54,366)). +legacyConfig(personTOthing(54,367)). +legacyConfig(personTOthing(54,368)). +legacyConfig(personTOthing(54,369)). +legacyConfig(personTOthing(54,370)). +legacyConfig(personTOthing(55,371)). +legacyConfig(personTOthing(55,372)). +legacyConfig(personTOthing(55,373)). +legacyConfig(personTOthing(55,374)). +legacyConfig(personTOthing(55,375)). +legacyConfig(personTOthing(56,376)). +legacyConfig(personTOthing(56,377)). +legacyConfig(personTOthing(56,378)). +legacyConfig(personTOthing(56,379)). +legacyConfig(personTOthing(56,380)). +legacyConfig(personTOthing(57,381)). +legacyConfig(personTOthing(57,382)). +legacyConfig(personTOthing(57,383)). +legacyConfig(personTOthing(57,384)). +legacyConfig(personTOthing(57,385)). +legacyConfig(personTOthing(58,386)). +legacyConfig(personTOthing(58,387)). +legacyConfig(personTOthing(58,388)). +legacyConfig(personTOthing(58,389)). +legacyConfig(personTOthing(58,390)). +legacyConfig(personTOthing(59,391)). +legacyConfig(personTOthing(59,392)). +legacyConfig(personTOthing(59,393)). +legacyConfig(personTOthing(59,394)). +legacyConfig(personTOthing(59,395)). +legacyConfig(personTOthing(60,396)). +legacyConfig(personTOthing(60,397)). +legacyConfig(personTOthing(60,398)). +legacyConfig(personTOthing(60,399)). +legacyConfig(personTOthing(60,400)). +legacyConfig(personTOthing(61,401)). +legacyConfig(personTOthing(61,402)). +legacyConfig(personTOthing(61,403)). +legacyConfig(personTOthing(61,404)). +legacyConfig(personTOthing(61,405)). +legacyConfig(personTOthing(62,406)). +legacyConfig(personTOthing(62,407)). +legacyConfig(personTOthing(62,408)). +legacyConfig(personTOthing(62,409)). +legacyConfig(personTOthing(62,410)). +legacyConfig(personTOthing(63,411)). +legacyConfig(personTOthing(63,412)). +legacyConfig(personTOthing(63,413)). +legacyConfig(personTOthing(63,414)). +legacyConfig(personTOthing(63,415)). +legacyConfig(personTOthing(64,416)). +legacyConfig(personTOthing(64,417)). +legacyConfig(personTOthing(64,418)). +legacyConfig(personTOthing(64,419)). +legacyConfig(personTOthing(64,420)). +legacyConfig(personTOthing(65,421)). +legacyConfig(personTOthing(65,422)). +legacyConfig(personTOthing(65,423)). +legacyConfig(personTOthing(65,424)). +legacyConfig(personTOthing(65,425)). +legacyConfig(personTOthing(66,426)). +legacyConfig(personTOthing(66,427)). +legacyConfig(personTOthing(66,428)). +legacyConfig(personTOthing(66,429)). +legacyConfig(personTOthing(66,430)). +legacyConfig(personTOthing(67,431)). +legacyConfig(personTOthing(67,432)). +legacyConfig(personTOthing(67,433)). +legacyConfig(personTOthing(67,434)). +legacyConfig(personTOthing(67,435)). +legacyConfig(personTOthing(68,436)). +legacyConfig(personTOthing(68,437)). +legacyConfig(personTOthing(68,438)). +legacyConfig(personTOthing(68,439)). +legacyConfig(personTOthing(68,440)). +legacyConfig(personTOthing(69,441)). +legacyConfig(personTOthing(69,442)). +legacyConfig(personTOthing(69,443)). +legacyConfig(personTOthing(69,444)). +legacyConfig(personTOthing(69,445)). +legacyConfig(personTOthing(70,446)). +legacyConfig(personTOthing(70,447)). +legacyConfig(personTOthing(70,448)). +legacyConfig(personTOthing(70,449)). +legacyConfig(personTOthing(70,450)). +legacyConfig(personTOthing(71,451)). +legacyConfig(personTOthing(71,452)). +legacyConfig(personTOthing(71,453)). +legacyConfig(personTOthing(71,454)). +legacyConfig(personTOthing(71,455)). +legacyConfig(personTOthing(72,456)). +legacyConfig(personTOthing(72,457)). +legacyConfig(personTOthing(72,458)). +legacyConfig(personTOthing(72,459)). +legacyConfig(personTOthing(72,460)). +legacyConfig(personTOthing(73,461)). +legacyConfig(personTOthing(73,462)). +legacyConfig(personTOthing(73,463)). +legacyConfig(personTOthing(73,464)). +legacyConfig(personTOthing(73,465)). +legacyConfig(personTOthing(74,466)). +legacyConfig(personTOthing(74,467)). +legacyConfig(personTOthing(74,468)). +legacyConfig(personTOthing(74,469)). +legacyConfig(personTOthing(74,470)). +legacyConfig(personTOthing(75,471)). +legacyConfig(personTOthing(75,472)). +legacyConfig(personTOthing(75,473)). +legacyConfig(personTOthing(75,474)). +legacyConfig(personTOthing(75,475)). +legacyConfig(personTOthing(76,476)). +legacyConfig(personTOthing(76,477)). +legacyConfig(personTOthing(76,478)). +legacyConfig(personTOthing(76,479)). +legacyConfig(personTOthing(76,480)). +legacyConfig(personTOthing(77,481)). +legacyConfig(personTOthing(77,482)). +legacyConfig(personTOthing(77,483)). +legacyConfig(personTOthing(77,484)). +legacyConfig(personTOthing(77,485)). +legacyConfig(personTOthing(78,486)). +legacyConfig(personTOthing(78,487)). +legacyConfig(personTOthing(78,488)). +legacyConfig(personTOthing(78,489)). +legacyConfig(personTOthing(78,490)). +legacyConfig(personTOthing(79,491)). +legacyConfig(personTOthing(79,492)). +legacyConfig(personTOthing(79,493)). +legacyConfig(personTOthing(79,494)). +legacyConfig(personTOthing(79,495)). +legacyConfig(personTOthing(80,496)). +legacyConfig(personTOthing(80,497)). +legacyConfig(personTOthing(80,498)). +legacyConfig(personTOthing(80,499)). +legacyConfig(personTOthing(80,500)). +legacyConfig(personTOthing(81,501)). +legacyConfig(personTOthing(81,502)). +legacyConfig(personTOthing(81,503)). +legacyConfig(personTOthing(81,504)). +legacyConfig(personTOthing(81,505)). +legacyConfig(personTOthing(82,506)). +legacyConfig(personTOthing(82,507)). +legacyConfig(personTOthing(82,508)). +legacyConfig(personTOthing(82,509)). +legacyConfig(personTOthing(82,510)). +legacyConfig(personTOthing(83,511)). +legacyConfig(personTOthing(83,512)). +legacyConfig(personTOthing(83,513)). +legacyConfig(personTOthing(83,514)). +legacyConfig(personTOthing(83,515)). +legacyConfig(personTOthing(84,516)). +legacyConfig(personTOthing(84,517)). +legacyConfig(personTOthing(84,518)). +legacyConfig(personTOthing(84,519)). +legacyConfig(personTOthing(84,520)). +legacyConfig(personTOthing(85,521)). +legacyConfig(personTOthing(85,522)). +legacyConfig(personTOthing(85,523)). +legacyConfig(personTOthing(85,524)). +legacyConfig(personTOthing(85,525)). +legacyConfig(personTOthing(86,526)). +legacyConfig(personTOthing(86,527)). +legacyConfig(personTOthing(86,528)). +legacyConfig(personTOthing(86,529)). +legacyConfig(personTOthing(86,530)). +legacyConfig(personTOthing(87,531)). +legacyConfig(personTOthing(87,532)). +legacyConfig(personTOthing(87,533)). +legacyConfig(personTOthing(87,534)). +legacyConfig(personTOthing(87,535)). +legacyConfig(personTOthing(88,536)). +legacyConfig(personTOthing(88,537)). +legacyConfig(personTOthing(88,538)). +legacyConfig(personTOthing(88,539)). +legacyConfig(personTOthing(88,540)). +legacyConfig(personTOthing(89,541)). +legacyConfig(personTOthing(89,542)). +legacyConfig(personTOthing(89,543)). +legacyConfig(personTOthing(89,544)). +legacyConfig(personTOthing(89,545)). +legacyConfig(personTOthing(90,546)). +legacyConfig(personTOthing(90,547)). +legacyConfig(personTOthing(90,548)). +legacyConfig(personTOthing(90,549)). +legacyConfig(personTOthing(90,550)). +legacyConfig(personTOthing(91,551)). +legacyConfig(personTOthing(91,552)). +legacyConfig(personTOthing(91,553)). +legacyConfig(personTOthing(91,554)). +legacyConfig(personTOthing(91,555)). +legacyConfig(personTOthing(92,556)). +legacyConfig(personTOthing(92,557)). +legacyConfig(personTOthing(92,558)). +legacyConfig(personTOthing(92,559)). +legacyConfig(personTOthing(92,560)). +legacyConfig(personTOthing(93,561)). +legacyConfig(personTOthing(93,562)). +legacyConfig(personTOthing(93,563)). +legacyConfig(personTOthing(93,564)). +legacyConfig(personTOthing(93,565)). +legacyConfig(personTOthing(94,566)). +legacyConfig(personTOthing(94,567)). +legacyConfig(personTOthing(94,568)). +legacyConfig(personTOthing(94,569)). +legacyConfig(personTOthing(94,570)). +legacyConfig(personTOthing(95,571)). +legacyConfig(personTOthing(95,572)). +legacyConfig(personTOthing(95,573)). +legacyConfig(personTOthing(95,574)). +legacyConfig(personTOthing(95,575)). +legacyConfig(personTOthing(96,576)). +legacyConfig(personTOthing(96,577)). +legacyConfig(personTOthing(96,578)). +legacyConfig(personTOthing(96,579)). +legacyConfig(personTOthing(96,580)). +legacyConfig(personTOthing(97,581)). +legacyConfig(personTOthing(97,582)). +legacyConfig(personTOthing(97,583)). +legacyConfig(personTOthing(97,584)). +legacyConfig(personTOthing(97,585)). +legacyConfig(personTOthing(98,586)). +legacyConfig(personTOthing(98,587)). +legacyConfig(personTOthing(98,588)). +legacyConfig(personTOthing(98,589)). +legacyConfig(personTOthing(98,590)). +legacyConfig(personTOthing(99,591)). +legacyConfig(personTOthing(99,592)). +legacyConfig(personTOthing(99,593)). +legacyConfig(personTOthing(99,594)). +legacyConfig(personTOthing(99,595)). +legacyConfig(personTOthing(100,596)). +legacyConfig(personTOthing(100,597)). +legacyConfig(personTOthing(100,598)). +legacyConfig(personTOthing(100,599)). +legacyConfig(personTOthing(100,600)). +% domains +cabinetDomainNew(1000..1499). +roomDomainNew(1500..1999). +cabinetUpper(500). +roomUpper(500). +cabinetLower(100). +roomLower(25). +% reuse costs +reuseCabinetTOthingCost(0). +reuseRoomTOcabinetCost(0). +reusePersonTOroomCost(0). +reuseCabinetAsHighCost(3). +reuseCabinetAsSmallCost(0). +reuseRoomCost(0). +% remove costs +removeCabinetTOthingCost(2). +removeRoomTOcabinetCost(2). +removePersonTOroomCost(2). +removeCabinetCost(2). +removeRoomCost(2). +% create costs +cabinetHighCost(100). +cabinetSmallCost(1). +roomCost(5). diff --git a/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p10t050.edb b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p10t050.edb new file mode 100644 index 000000000..48fc86b7a --- /dev/null +++ b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p10t050.edb @@ -0,0 +1,184 @@ +legacyConfig(person(1)). +legacyConfig(person(2)). +legacyConfig(person(3)). +legacyConfig(person(4)). +legacyConfig(person(5)). +legacyConfig(person(6)). +legacyConfig(person(7)). +legacyConfig(person(8)). +legacyConfig(person(9)). +legacyConfig(person(10)). +legacyConfig(thing(17)). +thingShort(17). +legacyConfig(thing(18)). +thingShort(18). +legacyConfig(thing(19)). +thingShort(19). +legacyConfig(thing(20)). +thingShort(20). +legacyConfig(thing(21)). +thingShort(21). +legacyConfig(thing(22)). +thingShort(22). +legacyConfig(thing(23)). +thingShort(23). +legacyConfig(thing(24)). +thingShort(24). +legacyConfig(thing(25)). +thingShort(25). +legacyConfig(thing(26)). +thingShort(26). +legacyConfig(thing(27)). +thingShort(27). +legacyConfig(thing(28)). +thingShort(28). +legacyConfig(thing(29)). +thingShort(29). +legacyConfig(thing(30)). +thingShort(30). +legacyConfig(thing(31)). +thingShort(31). +legacyConfig(thing(32)). +thingShort(32). +legacyConfig(thing(33)). +thingShort(33). +legacyConfig(thing(11)). +thingShort(11). +legacyConfig(thing(34)). +thingShort(34). +legacyConfig(thing(35)). +thingShort(35). +legacyConfig(thing(36)). +thingShort(36). +legacyConfig(thing(37)). +thingShort(37). +legacyConfig(thing(38)). +thingShort(38). +legacyConfig(thing(39)). +thingShort(39). +legacyConfig(thing(40)). +thingShort(40). +legacyConfig(thing(41)). +thingShort(41). +legacyConfig(thing(12)). +thingShort(12). +legacyConfig(thing(42)). +thingShort(42). +legacyConfig(thing(43)). +thingShort(43). +legacyConfig(thing(44)). +thingShort(44). +legacyConfig(thing(45)). +thingShort(45). +legacyConfig(thing(46)). +thingShort(46). +legacyConfig(thing(47)). +thingShort(47). +legacyConfig(thing(48)). +thingShort(48). +legacyConfig(thing(49)). +thingShort(49). +legacyConfig(thing(50)). +thingShort(50). +legacyConfig(thing(13)). +thingShort(13). +legacyConfig(thing(51)). +thingShort(51). +legacyConfig(thing(52)). +thingShort(52). +legacyConfig(thing(53)). +thingShort(53). +legacyConfig(thing(54)). +thingShort(54). +legacyConfig(thing(55)). +thingShort(55). +legacyConfig(thing(56)). +thingShort(56). +legacyConfig(thing(57)). +thingShort(57). +legacyConfig(thing(58)). +thingShort(58). +legacyConfig(thing(14)). +thingShort(14). +legacyConfig(thing(59)). +thingShort(59). +legacyConfig(thing(60)). +thingShort(60). +legacyConfig(thing(15)). +thingShort(15). +legacyConfig(thing(16)). +thingShort(16). +legacyConfig(personTOthing(1,11)). +legacyConfig(personTOthing(1,12)). +legacyConfig(personTOthing(1,13)). +legacyConfig(personTOthing(1,14)). +legacyConfig(personTOthing(1,15)). +legacyConfig(personTOthing(2,16)). +legacyConfig(personTOthing(2,17)). +legacyConfig(personTOthing(2,18)). +legacyConfig(personTOthing(2,19)). +legacyConfig(personTOthing(2,20)). +legacyConfig(personTOthing(3,21)). +legacyConfig(personTOthing(3,22)). +legacyConfig(personTOthing(3,23)). +legacyConfig(personTOthing(3,24)). +legacyConfig(personTOthing(3,25)). +legacyConfig(personTOthing(4,26)). +legacyConfig(personTOthing(4,27)). +legacyConfig(personTOthing(4,28)). +legacyConfig(personTOthing(4,29)). +legacyConfig(personTOthing(4,30)). +legacyConfig(personTOthing(5,31)). +legacyConfig(personTOthing(5,32)). +legacyConfig(personTOthing(5,33)). +legacyConfig(personTOthing(5,34)). +legacyConfig(personTOthing(5,35)). +legacyConfig(personTOthing(6,36)). +legacyConfig(personTOthing(6,37)). +legacyConfig(personTOthing(6,38)). +legacyConfig(personTOthing(6,39)). +legacyConfig(personTOthing(6,40)). +legacyConfig(personTOthing(7,41)). +legacyConfig(personTOthing(7,42)). +legacyConfig(personTOthing(7,43)). +legacyConfig(personTOthing(7,44)). +legacyConfig(personTOthing(7,45)). +legacyConfig(personTOthing(8,46)). +legacyConfig(personTOthing(8,47)). +legacyConfig(personTOthing(8,48)). +legacyConfig(personTOthing(8,49)). +legacyConfig(personTOthing(8,50)). +legacyConfig(personTOthing(9,51)). +legacyConfig(personTOthing(9,52)). +legacyConfig(personTOthing(9,53)). +legacyConfig(personTOthing(9,54)). +legacyConfig(personTOthing(9,55)). +legacyConfig(personTOthing(10,56)). +legacyConfig(personTOthing(10,57)). +legacyConfig(personTOthing(10,58)). +legacyConfig(personTOthing(10,59)). +legacyConfig(personTOthing(10,60)). +% domains +cabinetDomainNew(500..549). +roomDomainNew(1000..1049). +cabinetUpper(50). +roomUpper(50). +cabinetLower(10). +roomLower(3). +% reuse costs +reuseCabinetTOthingCost(0). +reuseRoomTOcabinetCost(0). +reusePersonTOroomCost(0). +reuseCabinetAsHighCost(3). +reuseCabinetAsSmallCost(0). +reuseRoomCost(0). +% remove costs +removeCabinetTOthingCost(2). +removeRoomTOcabinetCost(2). +removePersonTOroomCost(2). +removeCabinetCost(2). +removeRoomCost(2). +% create costs +cabinetHighCost(100). +cabinetSmallCost(1). +roomCost(5). diff --git a/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p15t075.edb b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p15t075.edb new file mode 100644 index 000000000..616f5e9b6 --- /dev/null +++ b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p15t075.edb @@ -0,0 +1,264 @@ +legacyConfig(person(1)). +legacyConfig(person(2)). +legacyConfig(person(3)). +legacyConfig(person(4)). +legacyConfig(person(5)). +legacyConfig(person(6)). +legacyConfig(person(7)). +legacyConfig(person(8)). +legacyConfig(person(9)). +legacyConfig(person(10)). +legacyConfig(person(11)). +legacyConfig(person(12)). +legacyConfig(person(13)). +legacyConfig(person(14)). +legacyConfig(person(15)). +legacyConfig(thing(22)). +thingShort(22). +legacyConfig(thing(23)). +thingShort(23). +legacyConfig(thing(24)). +thingShort(24). +legacyConfig(thing(25)). +thingShort(25). +legacyConfig(thing(26)). +thingShort(26). +legacyConfig(thing(27)). +thingShort(27). +legacyConfig(thing(28)). +thingShort(28). +legacyConfig(thing(29)). +thingShort(29). +legacyConfig(thing(30)). +thingShort(30). +legacyConfig(thing(31)). +thingShort(31). +legacyConfig(thing(32)). +thingShort(32). +legacyConfig(thing(33)). +thingShort(33). +legacyConfig(thing(34)). +thingShort(34). +legacyConfig(thing(35)). +thingShort(35). +legacyConfig(thing(36)). +thingShort(36). +legacyConfig(thing(37)). +thingShort(37). +legacyConfig(thing(38)). +thingShort(38). +legacyConfig(thing(16)). +thingShort(16). +legacyConfig(thing(39)). +thingShort(39). +legacyConfig(thing(40)). +thingShort(40). +legacyConfig(thing(41)). +thingShort(41). +legacyConfig(thing(42)). +thingShort(42). +legacyConfig(thing(43)). +thingShort(43). +legacyConfig(thing(44)). +thingShort(44). +legacyConfig(thing(45)). +thingShort(45). +legacyConfig(thing(46)). +thingShort(46). +legacyConfig(thing(17)). +thingShort(17). +legacyConfig(thing(47)). +thingShort(47). +legacyConfig(thing(48)). +thingShort(48). +legacyConfig(thing(49)). +thingShort(49). +legacyConfig(thing(50)). +thingShort(50). +legacyConfig(thing(51)). +thingShort(51). +legacyConfig(thing(52)). +thingShort(52). +legacyConfig(thing(53)). +thingShort(53). +legacyConfig(thing(54)). +thingShort(54). +legacyConfig(thing(55)). +thingShort(55). +legacyConfig(thing(18)). +thingShort(18). +legacyConfig(thing(56)). +thingShort(56). +legacyConfig(thing(57)). +thingShort(57). +legacyConfig(thing(58)). +thingShort(58). +legacyConfig(thing(59)). +thingShort(59). +legacyConfig(thing(60)). +thingShort(60). +legacyConfig(thing(61)). +thingShort(61). +legacyConfig(thing(62)). +thingShort(62). +legacyConfig(thing(63)). +thingShort(63). +legacyConfig(thing(19)). +thingShort(19). +legacyConfig(thing(64)). +thingShort(64). +legacyConfig(thing(65)). +thingShort(65). +legacyConfig(thing(66)). +thingShort(66). +legacyConfig(thing(67)). +thingShort(67). +legacyConfig(thing(68)). +thingShort(68). +legacyConfig(thing(69)). +thingShort(69). +legacyConfig(thing(70)). +thingShort(70). +legacyConfig(thing(71)). +thingShort(71). +legacyConfig(thing(20)). +thingShort(20). +legacyConfig(thing(72)). +thingShort(72). +legacyConfig(thing(73)). +thingShort(73). +legacyConfig(thing(74)). +thingShort(74). +legacyConfig(thing(75)). +thingShort(75). +legacyConfig(thing(76)). +thingShort(76). +legacyConfig(thing(77)). +thingShort(77). +legacyConfig(thing(78)). +thingShort(78). +legacyConfig(thing(79)). +thingShort(79). +legacyConfig(thing(80)). +thingShort(80). +legacyConfig(thing(81)). +thingShort(81). +legacyConfig(thing(82)). +thingShort(82). +legacyConfig(thing(83)). +thingShort(83). +legacyConfig(thing(84)). +thingShort(84). +legacyConfig(thing(85)). +thingShort(85). +legacyConfig(thing(86)). +thingShort(86). +legacyConfig(thing(87)). +thingShort(87). +legacyConfig(thing(88)). +thingShort(88). +legacyConfig(thing(21)). +thingShort(21). +legacyConfig(thing(89)). +thingShort(89). +legacyConfig(thing(90)). +thingShort(90). +legacyConfig(personTOthing(1,16)). +legacyConfig(personTOthing(1,17)). +legacyConfig(personTOthing(1,18)). +legacyConfig(personTOthing(1,19)). +legacyConfig(personTOthing(1,20)). +legacyConfig(personTOthing(2,21)). +legacyConfig(personTOthing(2,22)). +legacyConfig(personTOthing(2,23)). +legacyConfig(personTOthing(2,24)). +legacyConfig(personTOthing(2,25)). +legacyConfig(personTOthing(3,26)). +legacyConfig(personTOthing(3,27)). +legacyConfig(personTOthing(3,28)). +legacyConfig(personTOthing(3,29)). +legacyConfig(personTOthing(3,30)). +legacyConfig(personTOthing(4,31)). +legacyConfig(personTOthing(4,32)). +legacyConfig(personTOthing(4,33)). +legacyConfig(personTOthing(4,34)). +legacyConfig(personTOthing(4,35)). +legacyConfig(personTOthing(5,36)). +legacyConfig(personTOthing(5,37)). +legacyConfig(personTOthing(5,38)). +legacyConfig(personTOthing(5,39)). +legacyConfig(personTOthing(5,40)). +legacyConfig(personTOthing(6,41)). +legacyConfig(personTOthing(6,42)). +legacyConfig(personTOthing(6,43)). +legacyConfig(personTOthing(6,44)). +legacyConfig(personTOthing(6,45)). +legacyConfig(personTOthing(7,46)). +legacyConfig(personTOthing(7,47)). +legacyConfig(personTOthing(7,48)). +legacyConfig(personTOthing(7,49)). +legacyConfig(personTOthing(7,50)). +legacyConfig(personTOthing(8,51)). +legacyConfig(personTOthing(8,52)). +legacyConfig(personTOthing(8,53)). +legacyConfig(personTOthing(8,54)). +legacyConfig(personTOthing(8,55)). +legacyConfig(personTOthing(9,56)). +legacyConfig(personTOthing(9,57)). +legacyConfig(personTOthing(9,58)). +legacyConfig(personTOthing(9,59)). +legacyConfig(personTOthing(9,60)). +legacyConfig(personTOthing(10,61)). +legacyConfig(personTOthing(10,62)). +legacyConfig(personTOthing(10,63)). +legacyConfig(personTOthing(10,64)). +legacyConfig(personTOthing(10,65)). +legacyConfig(personTOthing(11,66)). +legacyConfig(personTOthing(11,67)). +legacyConfig(personTOthing(11,68)). +legacyConfig(personTOthing(11,69)). +legacyConfig(personTOthing(11,70)). +legacyConfig(personTOthing(12,71)). +legacyConfig(personTOthing(12,72)). +legacyConfig(personTOthing(12,73)). +legacyConfig(personTOthing(12,74)). +legacyConfig(personTOthing(12,75)). +legacyConfig(personTOthing(13,76)). +legacyConfig(personTOthing(13,77)). +legacyConfig(personTOthing(13,78)). +legacyConfig(personTOthing(13,79)). +legacyConfig(personTOthing(13,80)). +legacyConfig(personTOthing(14,81)). +legacyConfig(personTOthing(14,82)). +legacyConfig(personTOthing(14,83)). +legacyConfig(personTOthing(14,84)). +legacyConfig(personTOthing(14,85)). +legacyConfig(personTOthing(15,86)). +legacyConfig(personTOthing(15,87)). +legacyConfig(personTOthing(15,88)). +legacyConfig(personTOthing(15,89)). +legacyConfig(personTOthing(15,90)). +% domains +cabinetDomainNew(500..574). +roomDomainNew(1000..1074). +cabinetUpper(75). +roomUpper(75). +cabinetLower(15). +roomLower(4). +% reuse costs +reuseCabinetTOthingCost(0). +reuseRoomTOcabinetCost(0). +reusePersonTOroomCost(0). +reuseCabinetAsHighCost(3). +reuseCabinetAsSmallCost(0). +reuseRoomCost(0). +% remove costs +removeCabinetTOthingCost(2). +removeRoomTOcabinetCost(2). +removePersonTOroomCost(2). +removeCabinetCost(2). +removeRoomCost(2). +% create costs +cabinetHighCost(100). +cabinetSmallCost(1). +roomCost(5). diff --git a/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p20t100.edb b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p20t100.edb new file mode 100644 index 000000000..cf777620f --- /dev/null +++ b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p20t100.edb @@ -0,0 +1,344 @@ +legacyConfig(person(1)). +legacyConfig(person(2)). +legacyConfig(person(3)). +legacyConfig(person(4)). +legacyConfig(person(5)). +legacyConfig(person(6)). +legacyConfig(person(7)). +legacyConfig(person(8)). +legacyConfig(person(9)). +legacyConfig(person(10)). +legacyConfig(person(11)). +legacyConfig(person(12)). +legacyConfig(person(13)). +legacyConfig(person(14)). +legacyConfig(person(15)). +legacyConfig(person(16)). +legacyConfig(person(17)). +legacyConfig(person(18)). +legacyConfig(person(19)). +legacyConfig(person(20)). +legacyConfig(thing(27)). +thingShort(27). +legacyConfig(thing(102)). +thingShort(102). +legacyConfig(thing(103)). +thingShort(103). +legacyConfig(thing(104)). +thingShort(104). +legacyConfig(thing(105)). +thingShort(105). +legacyConfig(thing(106)). +thingShort(106). +legacyConfig(thing(107)). +thingShort(107). +legacyConfig(thing(108)). +thingShort(108). +legacyConfig(thing(109)). +thingShort(109). +legacyConfig(thing(110)). +thingShort(110). +legacyConfig(thing(28)). +thingShort(28). +legacyConfig(thing(111)). +thingShort(111). +legacyConfig(thing(112)). +thingShort(112). +legacyConfig(thing(113)). +thingShort(113). +legacyConfig(thing(114)). +thingShort(114). +legacyConfig(thing(115)). +thingShort(115). +legacyConfig(thing(116)). +thingShort(116). +legacyConfig(thing(117)). +thingShort(117). +legacyConfig(thing(118)). +thingShort(118). +legacyConfig(thing(29)). +thingShort(29). +legacyConfig(thing(119)). +thingShort(119). +legacyConfig(thing(120)). +thingShort(120). +legacyConfig(thing(30)). +thingShort(30). +legacyConfig(thing(31)). +thingShort(31). +legacyConfig(thing(32)). +thingShort(32). +legacyConfig(thing(33)). +thingShort(33). +legacyConfig(thing(34)). +thingShort(34). +legacyConfig(thing(35)). +thingShort(35). +legacyConfig(thing(36)). +thingShort(36). +legacyConfig(thing(37)). +thingShort(37). +legacyConfig(thing(38)). +thingShort(38). +legacyConfig(thing(39)). +thingShort(39). +legacyConfig(thing(40)). +thingShort(40). +legacyConfig(thing(41)). +thingShort(41). +legacyConfig(thing(42)). +thingShort(42). +legacyConfig(thing(43)). +thingShort(43). +legacyConfig(thing(21)). +thingShort(21). +legacyConfig(thing(44)). +thingShort(44). +legacyConfig(thing(45)). +thingShort(45). +legacyConfig(thing(46)). +thingShort(46). +legacyConfig(thing(47)). +thingShort(47). +legacyConfig(thing(48)). +thingShort(48). +legacyConfig(thing(49)). +thingShort(49). +legacyConfig(thing(50)). +thingShort(50). +legacyConfig(thing(51)). +thingShort(51). +legacyConfig(thing(22)). +thingShort(22). +legacyConfig(thing(52)). +thingShort(52). +legacyConfig(thing(53)). +thingShort(53). +legacyConfig(thing(54)). +thingShort(54). +legacyConfig(thing(55)). +thingShort(55). +legacyConfig(thing(56)). +thingShort(56). +legacyConfig(thing(57)). +thingShort(57). +legacyConfig(thing(58)). +thingShort(58). +legacyConfig(thing(59)). +thingShort(59). +legacyConfig(thing(60)). +thingShort(60). +legacyConfig(thing(23)). +thingShort(23). +legacyConfig(thing(61)). +thingShort(61). +legacyConfig(thing(62)). +thingShort(62). +legacyConfig(thing(63)). +thingShort(63). +legacyConfig(thing(64)). +thingShort(64). +legacyConfig(thing(65)). +thingShort(65). +legacyConfig(thing(66)). +thingShort(66). +legacyConfig(thing(67)). +thingShort(67). +legacyConfig(thing(68)). +thingShort(68). +legacyConfig(thing(24)). +thingShort(24). +legacyConfig(thing(69)). +thingShort(69). +legacyConfig(thing(70)). +thingShort(70). +legacyConfig(thing(71)). +thingShort(71). +legacyConfig(thing(72)). +thingShort(72). +legacyConfig(thing(73)). +thingShort(73). +legacyConfig(thing(74)). +thingShort(74). +legacyConfig(thing(75)). +thingShort(75). +legacyConfig(thing(76)). +thingShort(76). +legacyConfig(thing(25)). +thingShort(25). +legacyConfig(thing(77)). +thingShort(77). +legacyConfig(thing(78)). +thingShort(78). +legacyConfig(thing(79)). +thingShort(79). +legacyConfig(thing(80)). +thingShort(80). +legacyConfig(thing(81)). +thingShort(81). +legacyConfig(thing(82)). +thingShort(82). +legacyConfig(thing(83)). +thingShort(83). +legacyConfig(thing(84)). +thingShort(84). +legacyConfig(thing(85)). +thingShort(85). +legacyConfig(thing(86)). +thingShort(86). +legacyConfig(thing(87)). +thingShort(87). +legacyConfig(thing(88)). +thingShort(88). +legacyConfig(thing(89)). +thingShort(89). +legacyConfig(thing(90)). +thingShort(90). +legacyConfig(thing(91)). +thingShort(91). +legacyConfig(thing(92)). +thingShort(92). +legacyConfig(thing(93)). +thingShort(93). +legacyConfig(thing(26)). +thingShort(26). +legacyConfig(thing(94)). +thingShort(94). +legacyConfig(thing(95)). +thingShort(95). +legacyConfig(thing(96)). +thingShort(96). +legacyConfig(thing(97)). +thingShort(97). +legacyConfig(thing(98)). +thingShort(98). +legacyConfig(thing(99)). +thingShort(99). +legacyConfig(thing(100)). +thingShort(100). +legacyConfig(thing(101)). +thingShort(101). +legacyConfig(personTOthing(1,21)). +legacyConfig(personTOthing(1,22)). +legacyConfig(personTOthing(1,23)). +legacyConfig(personTOthing(1,24)). +legacyConfig(personTOthing(1,25)). +legacyConfig(personTOthing(2,26)). +legacyConfig(personTOthing(2,27)). +legacyConfig(personTOthing(2,28)). +legacyConfig(personTOthing(2,29)). +legacyConfig(personTOthing(2,30)). +legacyConfig(personTOthing(3,31)). +legacyConfig(personTOthing(3,32)). +legacyConfig(personTOthing(3,33)). +legacyConfig(personTOthing(3,34)). +legacyConfig(personTOthing(3,35)). +legacyConfig(personTOthing(4,36)). +legacyConfig(personTOthing(4,37)). +legacyConfig(personTOthing(4,38)). +legacyConfig(personTOthing(4,39)). +legacyConfig(personTOthing(4,40)). +legacyConfig(personTOthing(5,41)). +legacyConfig(personTOthing(5,42)). +legacyConfig(personTOthing(5,43)). +legacyConfig(personTOthing(5,44)). +legacyConfig(personTOthing(5,45)). +legacyConfig(personTOthing(6,46)). +legacyConfig(personTOthing(6,47)). +legacyConfig(personTOthing(6,48)). +legacyConfig(personTOthing(6,49)). +legacyConfig(personTOthing(6,50)). +legacyConfig(personTOthing(7,51)). +legacyConfig(personTOthing(7,52)). +legacyConfig(personTOthing(7,53)). +legacyConfig(personTOthing(7,54)). +legacyConfig(personTOthing(7,55)). +legacyConfig(personTOthing(8,56)). +legacyConfig(personTOthing(8,57)). +legacyConfig(personTOthing(8,58)). +legacyConfig(personTOthing(8,59)). +legacyConfig(personTOthing(8,60)). +legacyConfig(personTOthing(9,61)). +legacyConfig(personTOthing(9,62)). +legacyConfig(personTOthing(9,63)). +legacyConfig(personTOthing(9,64)). +legacyConfig(personTOthing(9,65)). +legacyConfig(personTOthing(10,66)). +legacyConfig(personTOthing(10,67)). +legacyConfig(personTOthing(10,68)). +legacyConfig(personTOthing(10,69)). +legacyConfig(personTOthing(10,70)). +legacyConfig(personTOthing(11,71)). +legacyConfig(personTOthing(11,72)). +legacyConfig(personTOthing(11,73)). +legacyConfig(personTOthing(11,74)). +legacyConfig(personTOthing(11,75)). +legacyConfig(personTOthing(12,76)). +legacyConfig(personTOthing(12,77)). +legacyConfig(personTOthing(12,78)). +legacyConfig(personTOthing(12,79)). +legacyConfig(personTOthing(12,80)). +legacyConfig(personTOthing(13,81)). +legacyConfig(personTOthing(13,82)). +legacyConfig(personTOthing(13,83)). +legacyConfig(personTOthing(13,84)). +legacyConfig(personTOthing(13,85)). +legacyConfig(personTOthing(14,86)). +legacyConfig(personTOthing(14,87)). +legacyConfig(personTOthing(14,88)). +legacyConfig(personTOthing(14,89)). +legacyConfig(personTOthing(14,90)). +legacyConfig(personTOthing(15,91)). +legacyConfig(personTOthing(15,92)). +legacyConfig(personTOthing(15,93)). +legacyConfig(personTOthing(15,94)). +legacyConfig(personTOthing(15,95)). +legacyConfig(personTOthing(16,96)). +legacyConfig(personTOthing(16,97)). +legacyConfig(personTOthing(16,98)). +legacyConfig(personTOthing(16,99)). +legacyConfig(personTOthing(16,100)). +legacyConfig(personTOthing(17,101)). +legacyConfig(personTOthing(17,102)). +legacyConfig(personTOthing(17,103)). +legacyConfig(personTOthing(17,104)). +legacyConfig(personTOthing(17,105)). +legacyConfig(personTOthing(18,106)). +legacyConfig(personTOthing(18,107)). +legacyConfig(personTOthing(18,108)). +legacyConfig(personTOthing(18,109)). +legacyConfig(personTOthing(18,110)). +legacyConfig(personTOthing(19,111)). +legacyConfig(personTOthing(19,112)). +legacyConfig(personTOthing(19,113)). +legacyConfig(personTOthing(19,114)). +legacyConfig(personTOthing(19,115)). +legacyConfig(personTOthing(20,116)). +legacyConfig(personTOthing(20,117)). +legacyConfig(personTOthing(20,118)). +legacyConfig(personTOthing(20,119)). +legacyConfig(personTOthing(20,120)). +% domains +cabinetDomainNew(500..599). +roomDomainNew(1000..1099). +cabinetUpper(100). +roomUpper(100). +cabinetLower(20). +roomLower(5). +% reuse costs +reuseCabinetTOthingCost(0). +reuseRoomTOcabinetCost(0). +reusePersonTOroomCost(0). +reuseCabinetAsHighCost(3). +reuseCabinetAsSmallCost(0). +reuseRoomCost(0). +% remove costs +removeCabinetTOthingCost(2). +removeRoomTOcabinetCost(2). +removePersonTOroomCost(2). +removeCabinetCost(2). +removeRoomCost(2). +% create costs +cabinetHighCost(100). +cabinetSmallCost(1). +roomCost(5). diff --git a/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p25t125.edb b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p25t125.edb new file mode 100644 index 000000000..f5201453a --- /dev/null +++ b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p25t125.edb @@ -0,0 +1,424 @@ +legacyConfig(person(1)). +legacyConfig(person(2)). +legacyConfig(person(3)). +legacyConfig(person(4)). +legacyConfig(person(5)). +legacyConfig(person(6)). +legacyConfig(person(7)). +legacyConfig(person(8)). +legacyConfig(person(9)). +legacyConfig(person(10)). +legacyConfig(person(11)). +legacyConfig(person(12)). +legacyConfig(person(13)). +legacyConfig(person(14)). +legacyConfig(person(15)). +legacyConfig(person(16)). +legacyConfig(person(17)). +legacyConfig(person(18)). +legacyConfig(person(19)). +legacyConfig(person(20)). +legacyConfig(person(21)). +legacyConfig(person(22)). +legacyConfig(person(23)). +legacyConfig(person(24)). +legacyConfig(person(25)). +legacyConfig(thing(32)). +thingShort(32). +legacyConfig(thing(107)). +thingShort(107). +legacyConfig(thing(108)). +thingShort(108). +legacyConfig(thing(109)). +thingShort(109). +legacyConfig(thing(110)). +thingShort(110). +legacyConfig(thing(111)). +thingShort(111). +legacyConfig(thing(112)). +thingShort(112). +legacyConfig(thing(113)). +thingShort(113). +legacyConfig(thing(114)). +thingShort(114). +legacyConfig(thing(115)). +thingShort(115). +legacyConfig(thing(33)). +thingShort(33). +legacyConfig(thing(116)). +thingShort(116). +legacyConfig(thing(117)). +thingShort(117). +legacyConfig(thing(118)). +thingShort(118). +legacyConfig(thing(119)). +thingShort(119). +legacyConfig(thing(120)). +thingShort(120). +legacyConfig(thing(121)). +thingShort(121). +legacyConfig(thing(122)). +thingShort(122). +legacyConfig(thing(123)). +thingShort(123). +legacyConfig(thing(34)). +thingShort(34). +legacyConfig(thing(124)). +thingShort(124). +legacyConfig(thing(125)). +thingShort(125). +legacyConfig(thing(126)). +thingShort(126). +legacyConfig(thing(127)). +thingShort(127). +legacyConfig(thing(128)). +thingShort(128). +legacyConfig(thing(129)). +thingShort(129). +legacyConfig(thing(130)). +thingShort(130). +legacyConfig(thing(131)). +thingShort(131). +legacyConfig(thing(35)). +thingShort(35). +legacyConfig(thing(132)). +thingShort(132). +legacyConfig(thing(133)). +thingShort(133). +legacyConfig(thing(134)). +thingShort(134). +legacyConfig(thing(135)). +thingShort(135). +legacyConfig(thing(136)). +thingShort(136). +legacyConfig(thing(137)). +thingShort(137). +legacyConfig(thing(138)). +thingShort(138). +legacyConfig(thing(139)). +thingShort(139). +legacyConfig(thing(140)). +thingShort(140). +legacyConfig(thing(141)). +thingShort(141). +legacyConfig(thing(142)). +thingShort(142). +legacyConfig(thing(143)). +thingShort(143). +legacyConfig(thing(144)). +thingShort(144). +legacyConfig(thing(145)). +thingShort(145). +legacyConfig(thing(146)). +thingShort(146). +legacyConfig(thing(147)). +thingShort(147). +legacyConfig(thing(148)). +thingShort(148). +legacyConfig(thing(36)). +thingShort(36). +legacyConfig(thing(149)). +thingShort(149). +legacyConfig(thing(150)). +thingShort(150). +legacyConfig(thing(37)). +thingShort(37). +legacyConfig(thing(38)). +thingShort(38). +legacyConfig(thing(39)). +thingShort(39). +legacyConfig(thing(40)). +thingShort(40). +legacyConfig(thing(41)). +thingShort(41). +legacyConfig(thing(42)). +thingShort(42). +legacyConfig(thing(43)). +thingShort(43). +legacyConfig(thing(44)). +thingShort(44). +legacyConfig(thing(45)). +thingShort(45). +legacyConfig(thing(46)). +thingShort(46). +legacyConfig(thing(47)). +thingShort(47). +legacyConfig(thing(48)). +thingShort(48). +legacyConfig(thing(26)). +thingShort(26). +legacyConfig(thing(49)). +thingShort(49). +legacyConfig(thing(50)). +thingShort(50). +legacyConfig(thing(51)). +thingShort(51). +legacyConfig(thing(52)). +thingShort(52). +legacyConfig(thing(53)). +thingShort(53). +legacyConfig(thing(54)). +thingShort(54). +legacyConfig(thing(55)). +thingShort(55). +legacyConfig(thing(56)). +thingShort(56). +legacyConfig(thing(27)). +thingShort(27). +legacyConfig(thing(57)). +thingShort(57). +legacyConfig(thing(58)). +thingShort(58). +legacyConfig(thing(59)). +thingShort(59). +legacyConfig(thing(60)). +thingShort(60). +legacyConfig(thing(61)). +thingShort(61). +legacyConfig(thing(62)). +thingShort(62). +legacyConfig(thing(63)). +thingShort(63). +legacyConfig(thing(64)). +thingShort(64). +legacyConfig(thing(65)). +thingShort(65). +legacyConfig(thing(28)). +thingShort(28). +legacyConfig(thing(66)). +thingShort(66). +legacyConfig(thing(67)). +thingShort(67). +legacyConfig(thing(68)). +thingShort(68). +legacyConfig(thing(69)). +thingShort(69). +legacyConfig(thing(70)). +thingShort(70). +legacyConfig(thing(71)). +thingShort(71). +legacyConfig(thing(72)). +thingShort(72). +legacyConfig(thing(73)). +thingShort(73). +legacyConfig(thing(29)). +thingShort(29). +legacyConfig(thing(74)). +thingShort(74). +legacyConfig(thing(75)). +thingShort(75). +legacyConfig(thing(76)). +thingShort(76). +legacyConfig(thing(77)). +thingShort(77). +legacyConfig(thing(78)). +thingShort(78). +legacyConfig(thing(79)). +thingShort(79). +legacyConfig(thing(80)). +thingShort(80). +legacyConfig(thing(81)). +thingShort(81). +legacyConfig(thing(30)). +thingShort(30). +legacyConfig(thing(82)). +thingShort(82). +legacyConfig(thing(83)). +thingShort(83). +legacyConfig(thing(84)). +thingShort(84). +legacyConfig(thing(85)). +thingShort(85). +legacyConfig(thing(86)). +thingShort(86). +legacyConfig(thing(87)). +thingShort(87). +legacyConfig(thing(88)). +thingShort(88). +legacyConfig(thing(89)). +thingShort(89). +legacyConfig(thing(90)). +thingShort(90). +legacyConfig(thing(91)). +thingShort(91). +legacyConfig(thing(92)). +thingShort(92). +legacyConfig(thing(93)). +thingShort(93). +legacyConfig(thing(94)). +thingShort(94). +legacyConfig(thing(95)). +thingShort(95). +legacyConfig(thing(96)). +thingShort(96). +legacyConfig(thing(97)). +thingShort(97). +legacyConfig(thing(98)). +thingShort(98). +legacyConfig(thing(31)). +thingShort(31). +legacyConfig(thing(99)). +thingShort(99). +legacyConfig(thing(100)). +thingShort(100). +legacyConfig(thing(101)). +thingShort(101). +legacyConfig(thing(102)). +thingShort(102). +legacyConfig(thing(103)). +thingShort(103). +legacyConfig(thing(104)). +thingShort(104). +legacyConfig(thing(105)). +thingShort(105). +legacyConfig(thing(106)). +thingShort(106). +legacyConfig(personTOthing(1,26)). +legacyConfig(personTOthing(1,27)). +legacyConfig(personTOthing(1,28)). +legacyConfig(personTOthing(1,29)). +legacyConfig(personTOthing(1,30)). +legacyConfig(personTOthing(2,31)). +legacyConfig(personTOthing(2,32)). +legacyConfig(personTOthing(2,33)). +legacyConfig(personTOthing(2,34)). +legacyConfig(personTOthing(2,35)). +legacyConfig(personTOthing(3,36)). +legacyConfig(personTOthing(3,37)). +legacyConfig(personTOthing(3,38)). +legacyConfig(personTOthing(3,39)). +legacyConfig(personTOthing(3,40)). +legacyConfig(personTOthing(4,41)). +legacyConfig(personTOthing(4,42)). +legacyConfig(personTOthing(4,43)). +legacyConfig(personTOthing(4,44)). +legacyConfig(personTOthing(4,45)). +legacyConfig(personTOthing(5,46)). +legacyConfig(personTOthing(5,47)). +legacyConfig(personTOthing(5,48)). +legacyConfig(personTOthing(5,49)). +legacyConfig(personTOthing(5,50)). +legacyConfig(personTOthing(6,51)). +legacyConfig(personTOthing(6,52)). +legacyConfig(personTOthing(6,53)). +legacyConfig(personTOthing(6,54)). +legacyConfig(personTOthing(6,55)). +legacyConfig(personTOthing(7,56)). +legacyConfig(personTOthing(7,57)). +legacyConfig(personTOthing(7,58)). +legacyConfig(personTOthing(7,59)). +legacyConfig(personTOthing(7,60)). +legacyConfig(personTOthing(8,61)). +legacyConfig(personTOthing(8,62)). +legacyConfig(personTOthing(8,63)). +legacyConfig(personTOthing(8,64)). +legacyConfig(personTOthing(8,65)). +legacyConfig(personTOthing(9,66)). +legacyConfig(personTOthing(9,67)). +legacyConfig(personTOthing(9,68)). +legacyConfig(personTOthing(9,69)). +legacyConfig(personTOthing(9,70)). +legacyConfig(personTOthing(10,71)). +legacyConfig(personTOthing(10,72)). +legacyConfig(personTOthing(10,73)). +legacyConfig(personTOthing(10,74)). +legacyConfig(personTOthing(10,75)). +legacyConfig(personTOthing(11,76)). +legacyConfig(personTOthing(11,77)). +legacyConfig(personTOthing(11,78)). +legacyConfig(personTOthing(11,79)). +legacyConfig(personTOthing(11,80)). +legacyConfig(personTOthing(12,81)). +legacyConfig(personTOthing(12,82)). +legacyConfig(personTOthing(12,83)). +legacyConfig(personTOthing(12,84)). +legacyConfig(personTOthing(12,85)). +legacyConfig(personTOthing(13,86)). +legacyConfig(personTOthing(13,87)). +legacyConfig(personTOthing(13,88)). +legacyConfig(personTOthing(13,89)). +legacyConfig(personTOthing(13,90)). +legacyConfig(personTOthing(14,91)). +legacyConfig(personTOthing(14,92)). +legacyConfig(personTOthing(14,93)). +legacyConfig(personTOthing(14,94)). +legacyConfig(personTOthing(14,95)). +legacyConfig(personTOthing(15,96)). +legacyConfig(personTOthing(15,97)). +legacyConfig(personTOthing(15,98)). +legacyConfig(personTOthing(15,99)). +legacyConfig(personTOthing(15,100)). +legacyConfig(personTOthing(16,101)). +legacyConfig(personTOthing(16,102)). +legacyConfig(personTOthing(16,103)). +legacyConfig(personTOthing(16,104)). +legacyConfig(personTOthing(16,105)). +legacyConfig(personTOthing(17,106)). +legacyConfig(personTOthing(17,107)). +legacyConfig(personTOthing(17,108)). +legacyConfig(personTOthing(17,109)). +legacyConfig(personTOthing(17,110)). +legacyConfig(personTOthing(18,111)). +legacyConfig(personTOthing(18,112)). +legacyConfig(personTOthing(18,113)). +legacyConfig(personTOthing(18,114)). +legacyConfig(personTOthing(18,115)). +legacyConfig(personTOthing(19,116)). +legacyConfig(personTOthing(19,117)). +legacyConfig(personTOthing(19,118)). +legacyConfig(personTOthing(19,119)). +legacyConfig(personTOthing(19,120)). +legacyConfig(personTOthing(20,121)). +legacyConfig(personTOthing(20,122)). +legacyConfig(personTOthing(20,123)). +legacyConfig(personTOthing(20,124)). +legacyConfig(personTOthing(20,125)). +legacyConfig(personTOthing(21,126)). +legacyConfig(personTOthing(21,127)). +legacyConfig(personTOthing(21,128)). +legacyConfig(personTOthing(21,129)). +legacyConfig(personTOthing(21,130)). +legacyConfig(personTOthing(22,131)). +legacyConfig(personTOthing(22,132)). +legacyConfig(personTOthing(22,133)). +legacyConfig(personTOthing(22,134)). +legacyConfig(personTOthing(22,135)). +legacyConfig(personTOthing(23,136)). +legacyConfig(personTOthing(23,137)). +legacyConfig(personTOthing(23,138)). +legacyConfig(personTOthing(23,139)). +legacyConfig(personTOthing(23,140)). +legacyConfig(personTOthing(24,141)). +legacyConfig(personTOthing(24,142)). +legacyConfig(personTOthing(24,143)). +legacyConfig(personTOthing(24,144)). +legacyConfig(personTOthing(24,145)). +legacyConfig(personTOthing(25,146)). +legacyConfig(personTOthing(25,147)). +legacyConfig(personTOthing(25,148)). +legacyConfig(personTOthing(25,149)). +legacyConfig(personTOthing(25,150)). +% domains +cabinetDomainNew(500..624). +roomDomainNew(1000..1124). +cabinetUpper(125). +roomUpper(125). +cabinetLower(25). +roomLower(7). +% reuse costs +reuseCabinetTOthingCost(0). +reuseRoomTOcabinetCost(0). +reusePersonTOroomCost(0). +reuseCabinetAsHighCost(3). +reuseCabinetAsSmallCost(0). +reuseRoomCost(0). +% remove costs +removeCabinetTOthingCost(2). +removeRoomTOcabinetCost(2). +removePersonTOroomCost(2). +removeCabinetCost(2). +removeRoomCost(2). +% create costs +cabinetHighCost(100). +cabinetSmallCost(1). +roomCost(5). diff --git a/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p30t150.edb b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p30t150.edb new file mode 100644 index 000000000..963352473 --- /dev/null +++ b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p30t150.edb @@ -0,0 +1,504 @@ +legacyConfig(person(1)). +legacyConfig(person(2)). +legacyConfig(person(3)). +legacyConfig(person(4)). +legacyConfig(person(5)). +legacyConfig(person(6)). +legacyConfig(person(7)). +legacyConfig(person(8)). +legacyConfig(person(9)). +legacyConfig(person(10)). +legacyConfig(person(11)). +legacyConfig(person(12)). +legacyConfig(person(13)). +legacyConfig(person(14)). +legacyConfig(person(15)). +legacyConfig(person(16)). +legacyConfig(person(17)). +legacyConfig(person(18)). +legacyConfig(person(19)). +legacyConfig(person(20)). +legacyConfig(person(21)). +legacyConfig(person(22)). +legacyConfig(person(23)). +legacyConfig(person(24)). +legacyConfig(person(25)). +legacyConfig(person(26)). +legacyConfig(person(27)). +legacyConfig(person(28)). +legacyConfig(person(29)). +legacyConfig(person(30)). +legacyConfig(thing(37)). +thingShort(37). +legacyConfig(thing(112)). +thingShort(112). +legacyConfig(thing(113)). +thingShort(113). +legacyConfig(thing(114)). +thingShort(114). +legacyConfig(thing(115)). +thingShort(115). +legacyConfig(thing(116)). +thingShort(116). +legacyConfig(thing(117)). +thingShort(117). +legacyConfig(thing(118)). +thingShort(118). +legacyConfig(thing(119)). +thingShort(119). +legacyConfig(thing(120)). +thingShort(120). +legacyConfig(thing(38)). +thingShort(38). +legacyConfig(thing(121)). +thingShort(121). +legacyConfig(thing(122)). +thingShort(122). +legacyConfig(thing(123)). +thingShort(123). +legacyConfig(thing(124)). +thingShort(124). +legacyConfig(thing(125)). +thingShort(125). +legacyConfig(thing(126)). +thingShort(126). +legacyConfig(thing(127)). +thingShort(127). +legacyConfig(thing(128)). +thingShort(128). +legacyConfig(thing(39)). +thingShort(39). +legacyConfig(thing(129)). +thingShort(129). +legacyConfig(thing(130)). +thingShort(130). +legacyConfig(thing(131)). +thingShort(131). +legacyConfig(thing(132)). +thingShort(132). +legacyConfig(thing(133)). +thingShort(133). +legacyConfig(thing(134)). +thingShort(134). +legacyConfig(thing(135)). +thingShort(135). +legacyConfig(thing(136)). +thingShort(136). +legacyConfig(thing(40)). +thingShort(40). +legacyConfig(thing(137)). +thingShort(137). +legacyConfig(thing(138)). +thingShort(138). +legacyConfig(thing(139)). +thingShort(139). +legacyConfig(thing(140)). +thingShort(140). +legacyConfig(thing(141)). +thingShort(141). +legacyConfig(thing(142)). +thingShort(142). +legacyConfig(thing(143)). +thingShort(143). +legacyConfig(thing(144)). +thingShort(144). +legacyConfig(thing(145)). +thingShort(145). +legacyConfig(thing(146)). +thingShort(146). +legacyConfig(thing(147)). +thingShort(147). +legacyConfig(thing(148)). +thingShort(148). +legacyConfig(thing(149)). +thingShort(149). +legacyConfig(thing(150)). +thingShort(150). +legacyConfig(thing(151)). +thingShort(151). +legacyConfig(thing(152)). +thingShort(152). +legacyConfig(thing(153)). +thingShort(153). +legacyConfig(thing(41)). +thingShort(41). +legacyConfig(thing(154)). +thingShort(154). +legacyConfig(thing(155)). +thingShort(155). +legacyConfig(thing(156)). +thingShort(156). +legacyConfig(thing(157)). +thingShort(157). +legacyConfig(thing(158)). +thingShort(158). +legacyConfig(thing(159)). +thingShort(159). +legacyConfig(thing(160)). +thingShort(160). +legacyConfig(thing(161)). +thingShort(161). +legacyConfig(thing(42)). +thingShort(42). +legacyConfig(thing(162)). +thingShort(162). +legacyConfig(thing(163)). +thingShort(163). +legacyConfig(thing(164)). +thingShort(164). +legacyConfig(thing(165)). +thingShort(165). +legacyConfig(thing(166)). +thingShort(166). +legacyConfig(thing(167)). +thingShort(167). +legacyConfig(thing(168)). +thingShort(168). +legacyConfig(thing(169)). +thingShort(169). +legacyConfig(thing(170)). +thingShort(170). +legacyConfig(thing(43)). +thingShort(43). +legacyConfig(thing(171)). +thingShort(171). +legacyConfig(thing(172)). +thingShort(172). +legacyConfig(thing(173)). +thingShort(173). +legacyConfig(thing(174)). +thingShort(174). +legacyConfig(thing(175)). +thingShort(175). +legacyConfig(thing(176)). +thingShort(176). +legacyConfig(thing(177)). +thingShort(177). +legacyConfig(thing(178)). +thingShort(178). +legacyConfig(thing(44)). +thingShort(44). +legacyConfig(thing(179)). +thingShort(179). +legacyConfig(thing(180)). +thingShort(180). +legacyConfig(thing(45)). +thingShort(45). +legacyConfig(thing(46)). +thingShort(46). +legacyConfig(thing(47)). +thingShort(47). +legacyConfig(thing(48)). +thingShort(48). +legacyConfig(thing(49)). +thingShort(49). +legacyConfig(thing(50)). +thingShort(50). +legacyConfig(thing(51)). +thingShort(51). +legacyConfig(thing(52)). +thingShort(52). +legacyConfig(thing(53)). +thingShort(53). +legacyConfig(thing(31)). +thingShort(31). +legacyConfig(thing(54)). +thingShort(54). +legacyConfig(thing(55)). +thingShort(55). +legacyConfig(thing(56)). +thingShort(56). +legacyConfig(thing(57)). +thingShort(57). +legacyConfig(thing(58)). +thingShort(58). +legacyConfig(thing(59)). +thingShort(59). +legacyConfig(thing(60)). +thingShort(60). +legacyConfig(thing(61)). +thingShort(61). +legacyConfig(thing(32)). +thingShort(32). +legacyConfig(thing(62)). +thingShort(62). +legacyConfig(thing(63)). +thingShort(63). +legacyConfig(thing(64)). +thingShort(64). +legacyConfig(thing(65)). +thingShort(65). +legacyConfig(thing(66)). +thingShort(66). +legacyConfig(thing(67)). +thingShort(67). +legacyConfig(thing(68)). +thingShort(68). +legacyConfig(thing(69)). +thingShort(69). +legacyConfig(thing(70)). +thingShort(70). +legacyConfig(thing(33)). +thingShort(33). +legacyConfig(thing(71)). +thingShort(71). +legacyConfig(thing(72)). +thingShort(72). +legacyConfig(thing(73)). +thingShort(73). +legacyConfig(thing(74)). +thingShort(74). +legacyConfig(thing(75)). +thingShort(75). +legacyConfig(thing(76)). +thingShort(76). +legacyConfig(thing(77)). +thingShort(77). +legacyConfig(thing(78)). +thingShort(78). +legacyConfig(thing(34)). +thingShort(34). +legacyConfig(thing(79)). +thingShort(79). +legacyConfig(thing(80)). +thingShort(80). +legacyConfig(thing(81)). +thingShort(81). +legacyConfig(thing(82)). +thingShort(82). +legacyConfig(thing(83)). +thingShort(83). +legacyConfig(thing(84)). +thingShort(84). +legacyConfig(thing(85)). +thingShort(85). +legacyConfig(thing(86)). +thingShort(86). +legacyConfig(thing(35)). +thingShort(35). +legacyConfig(thing(87)). +thingShort(87). +legacyConfig(thing(88)). +thingShort(88). +legacyConfig(thing(89)). +thingShort(89). +legacyConfig(thing(90)). +thingShort(90). +legacyConfig(thing(91)). +thingShort(91). +legacyConfig(thing(92)). +thingShort(92). +legacyConfig(thing(93)). +thingShort(93). +legacyConfig(thing(94)). +thingShort(94). +legacyConfig(thing(95)). +thingShort(95). +legacyConfig(thing(96)). +thingShort(96). +legacyConfig(thing(97)). +thingShort(97). +legacyConfig(thing(98)). +thingShort(98). +legacyConfig(thing(99)). +thingShort(99). +legacyConfig(thing(100)). +thingShort(100). +legacyConfig(thing(101)). +thingShort(101). +legacyConfig(thing(102)). +thingShort(102). +legacyConfig(thing(103)). +thingShort(103). +legacyConfig(thing(36)). +thingShort(36). +legacyConfig(thing(104)). +thingShort(104). +legacyConfig(thing(105)). +thingShort(105). +legacyConfig(thing(106)). +thingShort(106). +legacyConfig(thing(107)). +thingShort(107). +legacyConfig(thing(108)). +thingShort(108). +legacyConfig(thing(109)). +thingShort(109). +legacyConfig(thing(110)). +thingShort(110). +legacyConfig(thing(111)). +thingShort(111). +legacyConfig(personTOthing(1,31)). +legacyConfig(personTOthing(1,32)). +legacyConfig(personTOthing(1,33)). +legacyConfig(personTOthing(1,34)). +legacyConfig(personTOthing(1,35)). +legacyConfig(personTOthing(2,36)). +legacyConfig(personTOthing(2,37)). +legacyConfig(personTOthing(2,38)). +legacyConfig(personTOthing(2,39)). +legacyConfig(personTOthing(2,40)). +legacyConfig(personTOthing(3,41)). +legacyConfig(personTOthing(3,42)). +legacyConfig(personTOthing(3,43)). +legacyConfig(personTOthing(3,44)). +legacyConfig(personTOthing(3,45)). +legacyConfig(personTOthing(4,46)). +legacyConfig(personTOthing(4,47)). +legacyConfig(personTOthing(4,48)). +legacyConfig(personTOthing(4,49)). +legacyConfig(personTOthing(4,50)). +legacyConfig(personTOthing(5,51)). +legacyConfig(personTOthing(5,52)). +legacyConfig(personTOthing(5,53)). +legacyConfig(personTOthing(5,54)). +legacyConfig(personTOthing(5,55)). +legacyConfig(personTOthing(6,56)). +legacyConfig(personTOthing(6,57)). +legacyConfig(personTOthing(6,58)). +legacyConfig(personTOthing(6,59)). +legacyConfig(personTOthing(6,60)). +legacyConfig(personTOthing(7,61)). +legacyConfig(personTOthing(7,62)). +legacyConfig(personTOthing(7,63)). +legacyConfig(personTOthing(7,64)). +legacyConfig(personTOthing(7,65)). +legacyConfig(personTOthing(8,66)). +legacyConfig(personTOthing(8,67)). +legacyConfig(personTOthing(8,68)). +legacyConfig(personTOthing(8,69)). +legacyConfig(personTOthing(8,70)). +legacyConfig(personTOthing(9,71)). +legacyConfig(personTOthing(9,72)). +legacyConfig(personTOthing(9,73)). +legacyConfig(personTOthing(9,74)). +legacyConfig(personTOthing(9,75)). +legacyConfig(personTOthing(10,76)). +legacyConfig(personTOthing(10,77)). +legacyConfig(personTOthing(10,78)). +legacyConfig(personTOthing(10,79)). +legacyConfig(personTOthing(10,80)). +legacyConfig(personTOthing(11,81)). +legacyConfig(personTOthing(11,82)). +legacyConfig(personTOthing(11,83)). +legacyConfig(personTOthing(11,84)). +legacyConfig(personTOthing(11,85)). +legacyConfig(personTOthing(12,86)). +legacyConfig(personTOthing(12,87)). +legacyConfig(personTOthing(12,88)). +legacyConfig(personTOthing(12,89)). +legacyConfig(personTOthing(12,90)). +legacyConfig(personTOthing(13,91)). +legacyConfig(personTOthing(13,92)). +legacyConfig(personTOthing(13,93)). +legacyConfig(personTOthing(13,94)). +legacyConfig(personTOthing(13,95)). +legacyConfig(personTOthing(14,96)). +legacyConfig(personTOthing(14,97)). +legacyConfig(personTOthing(14,98)). +legacyConfig(personTOthing(14,99)). +legacyConfig(personTOthing(14,100)). +legacyConfig(personTOthing(15,101)). +legacyConfig(personTOthing(15,102)). +legacyConfig(personTOthing(15,103)). +legacyConfig(personTOthing(15,104)). +legacyConfig(personTOthing(15,105)). +legacyConfig(personTOthing(16,106)). +legacyConfig(personTOthing(16,107)). +legacyConfig(personTOthing(16,108)). +legacyConfig(personTOthing(16,109)). +legacyConfig(personTOthing(16,110)). +legacyConfig(personTOthing(17,111)). +legacyConfig(personTOthing(17,112)). +legacyConfig(personTOthing(17,113)). +legacyConfig(personTOthing(17,114)). +legacyConfig(personTOthing(17,115)). +legacyConfig(personTOthing(18,116)). +legacyConfig(personTOthing(18,117)). +legacyConfig(personTOthing(18,118)). +legacyConfig(personTOthing(18,119)). +legacyConfig(personTOthing(18,120)). +legacyConfig(personTOthing(19,121)). +legacyConfig(personTOthing(19,122)). +legacyConfig(personTOthing(19,123)). +legacyConfig(personTOthing(19,124)). +legacyConfig(personTOthing(19,125)). +legacyConfig(personTOthing(20,126)). +legacyConfig(personTOthing(20,127)). +legacyConfig(personTOthing(20,128)). +legacyConfig(personTOthing(20,129)). +legacyConfig(personTOthing(20,130)). +legacyConfig(personTOthing(21,131)). +legacyConfig(personTOthing(21,132)). +legacyConfig(personTOthing(21,133)). +legacyConfig(personTOthing(21,134)). +legacyConfig(personTOthing(21,135)). +legacyConfig(personTOthing(22,136)). +legacyConfig(personTOthing(22,137)). +legacyConfig(personTOthing(22,138)). +legacyConfig(personTOthing(22,139)). +legacyConfig(personTOthing(22,140)). +legacyConfig(personTOthing(23,141)). +legacyConfig(personTOthing(23,142)). +legacyConfig(personTOthing(23,143)). +legacyConfig(personTOthing(23,144)). +legacyConfig(personTOthing(23,145)). +legacyConfig(personTOthing(24,146)). +legacyConfig(personTOthing(24,147)). +legacyConfig(personTOthing(24,148)). +legacyConfig(personTOthing(24,149)). +legacyConfig(personTOthing(24,150)). +legacyConfig(personTOthing(25,151)). +legacyConfig(personTOthing(25,152)). +legacyConfig(personTOthing(25,153)). +legacyConfig(personTOthing(25,154)). +legacyConfig(personTOthing(25,155)). +legacyConfig(personTOthing(26,156)). +legacyConfig(personTOthing(26,157)). +legacyConfig(personTOthing(26,158)). +legacyConfig(personTOthing(26,159)). +legacyConfig(personTOthing(26,160)). +legacyConfig(personTOthing(27,161)). +legacyConfig(personTOthing(27,162)). +legacyConfig(personTOthing(27,163)). +legacyConfig(personTOthing(27,164)). +legacyConfig(personTOthing(27,165)). +legacyConfig(personTOthing(28,166)). +legacyConfig(personTOthing(28,167)). +legacyConfig(personTOthing(28,168)). +legacyConfig(personTOthing(28,169)). +legacyConfig(personTOthing(28,170)). +legacyConfig(personTOthing(29,171)). +legacyConfig(personTOthing(29,172)). +legacyConfig(personTOthing(29,173)). +legacyConfig(personTOthing(29,174)). +legacyConfig(personTOthing(29,175)). +legacyConfig(personTOthing(30,176)). +legacyConfig(personTOthing(30,177)). +legacyConfig(personTOthing(30,178)). +legacyConfig(personTOthing(30,179)). +legacyConfig(personTOthing(30,180)). +% domains +cabinetDomainNew(500..649). +roomDomainNew(1000..1149). +cabinetUpper(150). +roomUpper(150). +cabinetLower(30). +roomLower(8). +% reuse costs +reuseCabinetTOthingCost(0). +reuseRoomTOcabinetCost(0). +reusePersonTOroomCost(0). +reuseCabinetAsHighCost(3). +reuseCabinetAsSmallCost(0). +reuseRoomCost(0). +% remove costs +removeCabinetTOthingCost(2). +removeRoomTOcabinetCost(2). +removePersonTOroomCost(2). +removeCabinetCost(2). +removeRoomCost(2). +% create costs +cabinetHighCost(100). +cabinetSmallCost(1). +roomCost(5). diff --git a/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p35t175.edb b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p35t175.edb new file mode 100644 index 000000000..3ccd6cfb6 --- /dev/null +++ b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p35t175.edb @@ -0,0 +1,584 @@ +legacyConfig(person(1)). +legacyConfig(person(2)). +legacyConfig(person(3)). +legacyConfig(person(4)). +legacyConfig(person(5)). +legacyConfig(person(6)). +legacyConfig(person(7)). +legacyConfig(person(8)). +legacyConfig(person(9)). +legacyConfig(person(10)). +legacyConfig(person(11)). +legacyConfig(person(12)). +legacyConfig(person(13)). +legacyConfig(person(14)). +legacyConfig(person(15)). +legacyConfig(person(16)). +legacyConfig(person(17)). +legacyConfig(person(18)). +legacyConfig(person(19)). +legacyConfig(person(20)). +legacyConfig(person(21)). +legacyConfig(person(22)). +legacyConfig(person(23)). +legacyConfig(person(24)). +legacyConfig(person(25)). +legacyConfig(person(26)). +legacyConfig(person(27)). +legacyConfig(person(28)). +legacyConfig(person(29)). +legacyConfig(person(30)). +legacyConfig(person(31)). +legacyConfig(person(32)). +legacyConfig(person(33)). +legacyConfig(person(34)). +legacyConfig(person(35)). +legacyConfig(thing(42)). +thingShort(42). +legacyConfig(thing(117)). +thingShort(117). +legacyConfig(thing(118)). +thingShort(118). +legacyConfig(thing(119)). +thingShort(119). +legacyConfig(thing(120)). +thingShort(120). +legacyConfig(thing(121)). +thingShort(121). +legacyConfig(thing(122)). +thingShort(122). +legacyConfig(thing(123)). +thingShort(123). +legacyConfig(thing(124)). +thingShort(124). +legacyConfig(thing(125)). +thingShort(125). +legacyConfig(thing(43)). +thingShort(43). +legacyConfig(thing(126)). +thingShort(126). +legacyConfig(thing(127)). +thingShort(127). +legacyConfig(thing(128)). +thingShort(128). +legacyConfig(thing(129)). +thingShort(129). +legacyConfig(thing(130)). +thingShort(130). +legacyConfig(thing(131)). +thingShort(131). +legacyConfig(thing(132)). +thingShort(132). +legacyConfig(thing(133)). +thingShort(133). +legacyConfig(thing(44)). +thingShort(44). +legacyConfig(thing(134)). +thingShort(134). +legacyConfig(thing(135)). +thingShort(135). +legacyConfig(thing(136)). +thingShort(136). +legacyConfig(thing(137)). +thingShort(137). +legacyConfig(thing(138)). +thingShort(138). +legacyConfig(thing(139)). +thingShort(139). +legacyConfig(thing(140)). +thingShort(140). +legacyConfig(thing(141)). +thingShort(141). +legacyConfig(thing(45)). +thingShort(45). +legacyConfig(thing(142)). +thingShort(142). +legacyConfig(thing(143)). +thingShort(143). +legacyConfig(thing(144)). +thingShort(144). +legacyConfig(thing(145)). +thingShort(145). +legacyConfig(thing(146)). +thingShort(146). +legacyConfig(thing(147)). +thingShort(147). +legacyConfig(thing(148)). +thingShort(148). +legacyConfig(thing(149)). +thingShort(149). +legacyConfig(thing(150)). +thingShort(150). +legacyConfig(thing(151)). +thingShort(151). +legacyConfig(thing(152)). +thingShort(152). +legacyConfig(thing(153)). +thingShort(153). +legacyConfig(thing(154)). +thingShort(154). +legacyConfig(thing(155)). +thingShort(155). +legacyConfig(thing(156)). +thingShort(156). +legacyConfig(thing(157)). +thingShort(157). +legacyConfig(thing(158)). +thingShort(158). +legacyConfig(thing(46)). +thingShort(46). +legacyConfig(thing(159)). +thingShort(159). +legacyConfig(thing(160)). +thingShort(160). +legacyConfig(thing(161)). +thingShort(161). +legacyConfig(thing(162)). +thingShort(162). +legacyConfig(thing(163)). +thingShort(163). +legacyConfig(thing(164)). +thingShort(164). +legacyConfig(thing(165)). +thingShort(165). +legacyConfig(thing(166)). +thingShort(166). +legacyConfig(thing(47)). +thingShort(47). +legacyConfig(thing(167)). +thingShort(167). +legacyConfig(thing(168)). +thingShort(168). +legacyConfig(thing(169)). +thingShort(169). +legacyConfig(thing(170)). +thingShort(170). +legacyConfig(thing(171)). +thingShort(171). +legacyConfig(thing(172)). +thingShort(172). +legacyConfig(thing(173)). +thingShort(173). +legacyConfig(thing(174)). +thingShort(174). +legacyConfig(thing(175)). +thingShort(175). +legacyConfig(thing(48)). +thingShort(48). +legacyConfig(thing(176)). +thingShort(176). +legacyConfig(thing(177)). +thingShort(177). +legacyConfig(thing(178)). +thingShort(178). +legacyConfig(thing(179)). +thingShort(179). +legacyConfig(thing(180)). +thingShort(180). +legacyConfig(thing(181)). +thingShort(181). +legacyConfig(thing(182)). +thingShort(182). +legacyConfig(thing(183)). +thingShort(183). +legacyConfig(thing(49)). +thingShort(49). +legacyConfig(thing(184)). +thingShort(184). +legacyConfig(thing(185)). +thingShort(185). +legacyConfig(thing(186)). +thingShort(186). +legacyConfig(thing(187)). +thingShort(187). +legacyConfig(thing(188)). +thingShort(188). +legacyConfig(thing(189)). +thingShort(189). +legacyConfig(thing(190)). +thingShort(190). +legacyConfig(thing(191)). +thingShort(191). +legacyConfig(thing(50)). +thingShort(50). +legacyConfig(thing(192)). +thingShort(192). +legacyConfig(thing(193)). +thingShort(193). +legacyConfig(thing(194)). +thingShort(194). +legacyConfig(thing(195)). +thingShort(195). +legacyConfig(thing(196)). +thingShort(196). +legacyConfig(thing(197)). +thingShort(197). +legacyConfig(thing(198)). +thingShort(198). +legacyConfig(thing(199)). +thingShort(199). +legacyConfig(thing(200)). +thingShort(200). +legacyConfig(thing(201)). +thingShort(201). +legacyConfig(thing(202)). +thingShort(202). +legacyConfig(thing(203)). +thingShort(203). +legacyConfig(thing(204)). +thingShort(204). +legacyConfig(thing(205)). +thingShort(205). +legacyConfig(thing(206)). +thingShort(206). +legacyConfig(thing(207)). +thingShort(207). +legacyConfig(thing(208)). +thingShort(208). +legacyConfig(thing(51)). +thingShort(51). +legacyConfig(thing(209)). +thingShort(209). +legacyConfig(thing(210)). +thingShort(210). +legacyConfig(thing(52)). +thingShort(52). +legacyConfig(thing(53)). +thingShort(53). +legacyConfig(thing(54)). +thingShort(54). +legacyConfig(thing(55)). +thingShort(55). +legacyConfig(thing(56)). +thingShort(56). +legacyConfig(thing(57)). +thingShort(57). +legacyConfig(thing(58)). +thingShort(58). +legacyConfig(thing(36)). +thingShort(36). +legacyConfig(thing(59)). +thingShort(59). +legacyConfig(thing(60)). +thingShort(60). +legacyConfig(thing(61)). +thingShort(61). +legacyConfig(thing(62)). +thingShort(62). +legacyConfig(thing(63)). +thingShort(63). +legacyConfig(thing(64)). +thingShort(64). +legacyConfig(thing(65)). +thingShort(65). +legacyConfig(thing(66)). +thingShort(66). +legacyConfig(thing(37)). +thingShort(37). +legacyConfig(thing(67)). +thingShort(67). +legacyConfig(thing(68)). +thingShort(68). +legacyConfig(thing(69)). +thingShort(69). +legacyConfig(thing(70)). +thingShort(70). +legacyConfig(thing(71)). +thingShort(71). +legacyConfig(thing(72)). +thingShort(72). +legacyConfig(thing(73)). +thingShort(73). +legacyConfig(thing(74)). +thingShort(74). +legacyConfig(thing(75)). +thingShort(75). +legacyConfig(thing(38)). +thingShort(38). +legacyConfig(thing(76)). +thingShort(76). +legacyConfig(thing(77)). +thingShort(77). +legacyConfig(thing(78)). +thingShort(78). +legacyConfig(thing(79)). +thingShort(79). +legacyConfig(thing(80)). +thingShort(80). +legacyConfig(thing(81)). +thingShort(81). +legacyConfig(thing(82)). +thingShort(82). +legacyConfig(thing(83)). +thingShort(83). +legacyConfig(thing(39)). +thingShort(39). +legacyConfig(thing(84)). +thingShort(84). +legacyConfig(thing(85)). +thingShort(85). +legacyConfig(thing(86)). +thingShort(86). +legacyConfig(thing(87)). +thingShort(87). +legacyConfig(thing(88)). +thingShort(88). +legacyConfig(thing(89)). +thingShort(89). +legacyConfig(thing(90)). +thingShort(90). +legacyConfig(thing(91)). +thingShort(91). +legacyConfig(thing(40)). +thingShort(40). +legacyConfig(thing(92)). +thingShort(92). +legacyConfig(thing(93)). +thingShort(93). +legacyConfig(thing(94)). +thingShort(94). +legacyConfig(thing(95)). +thingShort(95). +legacyConfig(thing(96)). +thingShort(96). +legacyConfig(thing(97)). +thingShort(97). +legacyConfig(thing(98)). +thingShort(98). +legacyConfig(thing(99)). +thingShort(99). +legacyConfig(thing(100)). +thingShort(100). +legacyConfig(thing(101)). +thingShort(101). +legacyConfig(thing(102)). +thingShort(102). +legacyConfig(thing(103)). +thingShort(103). +legacyConfig(thing(104)). +thingShort(104). +legacyConfig(thing(105)). +thingShort(105). +legacyConfig(thing(106)). +thingShort(106). +legacyConfig(thing(107)). +thingShort(107). +legacyConfig(thing(108)). +thingShort(108). +legacyConfig(thing(41)). +thingShort(41). +legacyConfig(thing(109)). +thingShort(109). +legacyConfig(thing(110)). +thingShort(110). +legacyConfig(thing(111)). +thingShort(111). +legacyConfig(thing(112)). +thingShort(112). +legacyConfig(thing(113)). +thingShort(113). +legacyConfig(thing(114)). +thingShort(114). +legacyConfig(thing(115)). +thingShort(115). +legacyConfig(thing(116)). +thingShort(116). +legacyConfig(personTOthing(1,36)). +legacyConfig(personTOthing(1,37)). +legacyConfig(personTOthing(1,38)). +legacyConfig(personTOthing(1,39)). +legacyConfig(personTOthing(1,40)). +legacyConfig(personTOthing(2,41)). +legacyConfig(personTOthing(2,42)). +legacyConfig(personTOthing(2,43)). +legacyConfig(personTOthing(2,44)). +legacyConfig(personTOthing(2,45)). +legacyConfig(personTOthing(3,46)). +legacyConfig(personTOthing(3,47)). +legacyConfig(personTOthing(3,48)). +legacyConfig(personTOthing(3,49)). +legacyConfig(personTOthing(3,50)). +legacyConfig(personTOthing(4,51)). +legacyConfig(personTOthing(4,52)). +legacyConfig(personTOthing(4,53)). +legacyConfig(personTOthing(4,54)). +legacyConfig(personTOthing(4,55)). +legacyConfig(personTOthing(5,56)). +legacyConfig(personTOthing(5,57)). +legacyConfig(personTOthing(5,58)). +legacyConfig(personTOthing(5,59)). +legacyConfig(personTOthing(5,60)). +legacyConfig(personTOthing(6,61)). +legacyConfig(personTOthing(6,62)). +legacyConfig(personTOthing(6,63)). +legacyConfig(personTOthing(6,64)). +legacyConfig(personTOthing(6,65)). +legacyConfig(personTOthing(7,66)). +legacyConfig(personTOthing(7,67)). +legacyConfig(personTOthing(7,68)). +legacyConfig(personTOthing(7,69)). +legacyConfig(personTOthing(7,70)). +legacyConfig(personTOthing(8,71)). +legacyConfig(personTOthing(8,72)). +legacyConfig(personTOthing(8,73)). +legacyConfig(personTOthing(8,74)). +legacyConfig(personTOthing(8,75)). +legacyConfig(personTOthing(9,76)). +legacyConfig(personTOthing(9,77)). +legacyConfig(personTOthing(9,78)). +legacyConfig(personTOthing(9,79)). +legacyConfig(personTOthing(9,80)). +legacyConfig(personTOthing(10,81)). +legacyConfig(personTOthing(10,82)). +legacyConfig(personTOthing(10,83)). +legacyConfig(personTOthing(10,84)). +legacyConfig(personTOthing(10,85)). +legacyConfig(personTOthing(11,86)). +legacyConfig(personTOthing(11,87)). +legacyConfig(personTOthing(11,88)). +legacyConfig(personTOthing(11,89)). +legacyConfig(personTOthing(11,90)). +legacyConfig(personTOthing(12,91)). +legacyConfig(personTOthing(12,92)). +legacyConfig(personTOthing(12,93)). +legacyConfig(personTOthing(12,94)). +legacyConfig(personTOthing(12,95)). +legacyConfig(personTOthing(13,96)). +legacyConfig(personTOthing(13,97)). +legacyConfig(personTOthing(13,98)). +legacyConfig(personTOthing(13,99)). +legacyConfig(personTOthing(13,100)). +legacyConfig(personTOthing(14,101)). +legacyConfig(personTOthing(14,102)). +legacyConfig(personTOthing(14,103)). +legacyConfig(personTOthing(14,104)). +legacyConfig(personTOthing(14,105)). +legacyConfig(personTOthing(15,106)). +legacyConfig(personTOthing(15,107)). +legacyConfig(personTOthing(15,108)). +legacyConfig(personTOthing(15,109)). +legacyConfig(personTOthing(15,110)). +legacyConfig(personTOthing(16,111)). +legacyConfig(personTOthing(16,112)). +legacyConfig(personTOthing(16,113)). +legacyConfig(personTOthing(16,114)). +legacyConfig(personTOthing(16,115)). +legacyConfig(personTOthing(17,116)). +legacyConfig(personTOthing(17,117)). +legacyConfig(personTOthing(17,118)). +legacyConfig(personTOthing(17,119)). +legacyConfig(personTOthing(17,120)). +legacyConfig(personTOthing(18,121)). +legacyConfig(personTOthing(18,122)). +legacyConfig(personTOthing(18,123)). +legacyConfig(personTOthing(18,124)). +legacyConfig(personTOthing(18,125)). +legacyConfig(personTOthing(19,126)). +legacyConfig(personTOthing(19,127)). +legacyConfig(personTOthing(19,128)). +legacyConfig(personTOthing(19,129)). +legacyConfig(personTOthing(19,130)). +legacyConfig(personTOthing(20,131)). +legacyConfig(personTOthing(20,132)). +legacyConfig(personTOthing(20,133)). +legacyConfig(personTOthing(20,134)). +legacyConfig(personTOthing(20,135)). +legacyConfig(personTOthing(21,136)). +legacyConfig(personTOthing(21,137)). +legacyConfig(personTOthing(21,138)). +legacyConfig(personTOthing(21,139)). +legacyConfig(personTOthing(21,140)). +legacyConfig(personTOthing(22,141)). +legacyConfig(personTOthing(22,142)). +legacyConfig(personTOthing(22,143)). +legacyConfig(personTOthing(22,144)). +legacyConfig(personTOthing(22,145)). +legacyConfig(personTOthing(23,146)). +legacyConfig(personTOthing(23,147)). +legacyConfig(personTOthing(23,148)). +legacyConfig(personTOthing(23,149)). +legacyConfig(personTOthing(23,150)). +legacyConfig(personTOthing(24,151)). +legacyConfig(personTOthing(24,152)). +legacyConfig(personTOthing(24,153)). +legacyConfig(personTOthing(24,154)). +legacyConfig(personTOthing(24,155)). +legacyConfig(personTOthing(25,156)). +legacyConfig(personTOthing(25,157)). +legacyConfig(personTOthing(25,158)). +legacyConfig(personTOthing(25,159)). +legacyConfig(personTOthing(25,160)). +legacyConfig(personTOthing(26,161)). +legacyConfig(personTOthing(26,162)). +legacyConfig(personTOthing(26,163)). +legacyConfig(personTOthing(26,164)). +legacyConfig(personTOthing(26,165)). +legacyConfig(personTOthing(27,166)). +legacyConfig(personTOthing(27,167)). +legacyConfig(personTOthing(27,168)). +legacyConfig(personTOthing(27,169)). +legacyConfig(personTOthing(27,170)). +legacyConfig(personTOthing(28,171)). +legacyConfig(personTOthing(28,172)). +legacyConfig(personTOthing(28,173)). +legacyConfig(personTOthing(28,174)). +legacyConfig(personTOthing(28,175)). +legacyConfig(personTOthing(29,176)). +legacyConfig(personTOthing(29,177)). +legacyConfig(personTOthing(29,178)). +legacyConfig(personTOthing(29,179)). +legacyConfig(personTOthing(29,180)). +legacyConfig(personTOthing(30,181)). +legacyConfig(personTOthing(30,182)). +legacyConfig(personTOthing(30,183)). +legacyConfig(personTOthing(30,184)). +legacyConfig(personTOthing(30,185)). +legacyConfig(personTOthing(31,186)). +legacyConfig(personTOthing(31,187)). +legacyConfig(personTOthing(31,188)). +legacyConfig(personTOthing(31,189)). +legacyConfig(personTOthing(31,190)). +legacyConfig(personTOthing(32,191)). +legacyConfig(personTOthing(32,192)). +legacyConfig(personTOthing(32,193)). +legacyConfig(personTOthing(32,194)). +legacyConfig(personTOthing(32,195)). +legacyConfig(personTOthing(33,196)). +legacyConfig(personTOthing(33,197)). +legacyConfig(personTOthing(33,198)). +legacyConfig(personTOthing(33,199)). +legacyConfig(personTOthing(33,200)). +legacyConfig(personTOthing(34,201)). +legacyConfig(personTOthing(34,202)). +legacyConfig(personTOthing(34,203)). +legacyConfig(personTOthing(34,204)). +legacyConfig(personTOthing(34,205)). +legacyConfig(personTOthing(35,206)). +legacyConfig(personTOthing(35,207)). +legacyConfig(personTOthing(35,208)). +legacyConfig(personTOthing(35,209)). +legacyConfig(personTOthing(35,210)). +% domains +cabinetDomainNew(500..674). +roomDomainNew(1000..1174). +cabinetUpper(175). +roomUpper(175). +cabinetLower(35). +roomLower(9). +% reuse costs +reuseCabinetTOthingCost(0). +reuseRoomTOcabinetCost(0). +reusePersonTOroomCost(0). +reuseCabinetAsHighCost(3). +reuseCabinetAsSmallCost(0). +reuseRoomCost(0). +% remove costs +removeCabinetTOthingCost(2). +removeRoomTOcabinetCost(2). +removePersonTOroomCost(2). +removeCabinetCost(2). +removeRoomCost(2). +% create costs +cabinetHighCost(100). +cabinetSmallCost(1). +roomCost(5). diff --git a/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p40t200.edb b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p40t200.edb new file mode 100644 index 000000000..d948b830d --- /dev/null +++ b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p40t200.edb @@ -0,0 +1,664 @@ +legacyConfig(person(1)). +legacyConfig(person(2)). +legacyConfig(person(3)). +legacyConfig(person(4)). +legacyConfig(person(5)). +legacyConfig(person(6)). +legacyConfig(person(7)). +legacyConfig(person(8)). +legacyConfig(person(9)). +legacyConfig(person(10)). +legacyConfig(person(11)). +legacyConfig(person(12)). +legacyConfig(person(13)). +legacyConfig(person(14)). +legacyConfig(person(15)). +legacyConfig(person(16)). +legacyConfig(person(17)). +legacyConfig(person(18)). +legacyConfig(person(19)). +legacyConfig(person(20)). +legacyConfig(person(21)). +legacyConfig(person(22)). +legacyConfig(person(23)). +legacyConfig(person(24)). +legacyConfig(person(25)). +legacyConfig(person(26)). +legacyConfig(person(27)). +legacyConfig(person(28)). +legacyConfig(person(29)). +legacyConfig(person(30)). +legacyConfig(person(31)). +legacyConfig(person(32)). +legacyConfig(person(33)). +legacyConfig(person(34)). +legacyConfig(person(35)). +legacyConfig(person(36)). +legacyConfig(person(37)). +legacyConfig(person(38)). +legacyConfig(person(39)). +legacyConfig(person(40)). +legacyConfig(thing(47)). +thingShort(47). +legacyConfig(thing(122)). +thingShort(122). +legacyConfig(thing(123)). +thingShort(123). +legacyConfig(thing(124)). +thingShort(124). +legacyConfig(thing(125)). +thingShort(125). +legacyConfig(thing(126)). +thingShort(126). +legacyConfig(thing(127)). +thingShort(127). +legacyConfig(thing(128)). +thingShort(128). +legacyConfig(thing(129)). +thingShort(129). +legacyConfig(thing(130)). +thingShort(130). +legacyConfig(thing(48)). +thingShort(48). +legacyConfig(thing(131)). +thingShort(131). +legacyConfig(thing(132)). +thingShort(132). +legacyConfig(thing(133)). +thingShort(133). +legacyConfig(thing(134)). +thingShort(134). +legacyConfig(thing(135)). +thingShort(135). +legacyConfig(thing(136)). +thingShort(136). +legacyConfig(thing(137)). +thingShort(137). +legacyConfig(thing(138)). +thingShort(138). +legacyConfig(thing(49)). +thingShort(49). +legacyConfig(thing(139)). +thingShort(139). +legacyConfig(thing(140)). +thingShort(140). +legacyConfig(thing(141)). +thingShort(141). +legacyConfig(thing(142)). +thingShort(142). +legacyConfig(thing(143)). +thingShort(143). +legacyConfig(thing(144)). +thingShort(144). +legacyConfig(thing(145)). +thingShort(145). +legacyConfig(thing(146)). +thingShort(146). +legacyConfig(thing(50)). +thingShort(50). +legacyConfig(thing(147)). +thingShort(147). +legacyConfig(thing(148)). +thingShort(148). +legacyConfig(thing(149)). +thingShort(149). +legacyConfig(thing(150)). +thingShort(150). +legacyConfig(thing(151)). +thingShort(151). +legacyConfig(thing(152)). +thingShort(152). +legacyConfig(thing(153)). +thingShort(153). +legacyConfig(thing(154)). +thingShort(154). +legacyConfig(thing(155)). +thingShort(155). +legacyConfig(thing(156)). +thingShort(156). +legacyConfig(thing(157)). +thingShort(157). +legacyConfig(thing(158)). +thingShort(158). +legacyConfig(thing(159)). +thingShort(159). +legacyConfig(thing(160)). +thingShort(160). +legacyConfig(thing(161)). +thingShort(161). +legacyConfig(thing(162)). +thingShort(162). +legacyConfig(thing(163)). +thingShort(163). +legacyConfig(thing(51)). +thingShort(51). +legacyConfig(thing(164)). +thingShort(164). +legacyConfig(thing(165)). +thingShort(165). +legacyConfig(thing(166)). +thingShort(166). +legacyConfig(thing(167)). +thingShort(167). +legacyConfig(thing(168)). +thingShort(168). +legacyConfig(thing(169)). +thingShort(169). +legacyConfig(thing(170)). +thingShort(170). +legacyConfig(thing(171)). +thingShort(171). +legacyConfig(thing(52)). +thingShort(52). +legacyConfig(thing(172)). +thingShort(172). +legacyConfig(thing(173)). +thingShort(173). +legacyConfig(thing(174)). +thingShort(174). +legacyConfig(thing(175)). +thingShort(175). +legacyConfig(thing(176)). +thingShort(176). +legacyConfig(thing(177)). +thingShort(177). +legacyConfig(thing(178)). +thingShort(178). +legacyConfig(thing(179)). +thingShort(179). +legacyConfig(thing(180)). +thingShort(180). +legacyConfig(thing(53)). +thingShort(53). +legacyConfig(thing(181)). +thingShort(181). +legacyConfig(thing(182)). +thingShort(182). +legacyConfig(thing(183)). +thingShort(183). +legacyConfig(thing(184)). +thingShort(184). +legacyConfig(thing(185)). +thingShort(185). +legacyConfig(thing(186)). +thingShort(186). +legacyConfig(thing(187)). +thingShort(187). +legacyConfig(thing(188)). +thingShort(188). +legacyConfig(thing(54)). +thingShort(54). +legacyConfig(thing(189)). +thingShort(189). +legacyConfig(thing(190)). +thingShort(190). +legacyConfig(thing(191)). +thingShort(191). +legacyConfig(thing(192)). +thingShort(192). +legacyConfig(thing(193)). +thingShort(193). +legacyConfig(thing(194)). +thingShort(194). +legacyConfig(thing(195)). +thingShort(195). +legacyConfig(thing(196)). +thingShort(196). +legacyConfig(thing(55)). +thingShort(55). +legacyConfig(thing(197)). +thingShort(197). +legacyConfig(thing(198)). +thingShort(198). +legacyConfig(thing(199)). +thingShort(199). +legacyConfig(thing(200)). +thingShort(200). +legacyConfig(thing(201)). +thingShort(201). +legacyConfig(thing(202)). +thingShort(202). +legacyConfig(thing(203)). +thingShort(203). +legacyConfig(thing(204)). +thingShort(204). +legacyConfig(thing(205)). +thingShort(205). +legacyConfig(thing(206)). +thingShort(206). +legacyConfig(thing(207)). +thingShort(207). +legacyConfig(thing(208)). +thingShort(208). +legacyConfig(thing(209)). +thingShort(209). +legacyConfig(thing(210)). +thingShort(210). +legacyConfig(thing(211)). +thingShort(211). +legacyConfig(thing(212)). +thingShort(212). +legacyConfig(thing(213)). +thingShort(213). +legacyConfig(thing(56)). +thingShort(56). +legacyConfig(thing(214)). +thingShort(214). +legacyConfig(thing(215)). +thingShort(215). +legacyConfig(thing(216)). +thingShort(216). +legacyConfig(thing(217)). +thingShort(217). +legacyConfig(thing(218)). +thingShort(218). +legacyConfig(thing(219)). +thingShort(219). +legacyConfig(thing(220)). +thingShort(220). +legacyConfig(thing(221)). +thingShort(221). +legacyConfig(thing(57)). +thingShort(57). +legacyConfig(thing(222)). +thingShort(222). +legacyConfig(thing(223)). +thingShort(223). +legacyConfig(thing(224)). +thingShort(224). +legacyConfig(thing(225)). +thingShort(225). +legacyConfig(thing(226)). +thingShort(226). +legacyConfig(thing(227)). +thingShort(227). +legacyConfig(thing(228)). +thingShort(228). +legacyConfig(thing(229)). +thingShort(229). +legacyConfig(thing(230)). +thingShort(230). +legacyConfig(thing(58)). +thingShort(58). +legacyConfig(thing(231)). +thingShort(231). +legacyConfig(thing(232)). +thingShort(232). +legacyConfig(thing(233)). +thingShort(233). +legacyConfig(thing(234)). +thingShort(234). +legacyConfig(thing(235)). +thingShort(235). +legacyConfig(thing(236)). +thingShort(236). +legacyConfig(thing(237)). +thingShort(237). +legacyConfig(thing(238)). +thingShort(238). +legacyConfig(thing(59)). +thingShort(59). +legacyConfig(thing(239)). +thingShort(239). +legacyConfig(thing(240)). +thingShort(240). +legacyConfig(thing(60)). +thingShort(60). +legacyConfig(thing(61)). +thingShort(61). +legacyConfig(thing(62)). +thingShort(62). +legacyConfig(thing(63)). +thingShort(63). +legacyConfig(thing(41)). +thingShort(41). +legacyConfig(thing(64)). +thingShort(64). +legacyConfig(thing(65)). +thingShort(65). +legacyConfig(thing(66)). +thingShort(66). +legacyConfig(thing(67)). +thingShort(67). +legacyConfig(thing(68)). +thingShort(68). +legacyConfig(thing(69)). +thingShort(69). +legacyConfig(thing(70)). +thingShort(70). +legacyConfig(thing(71)). +thingShort(71). +legacyConfig(thing(42)). +thingShort(42). +legacyConfig(thing(72)). +thingShort(72). +legacyConfig(thing(73)). +thingShort(73). +legacyConfig(thing(74)). +thingShort(74). +legacyConfig(thing(75)). +thingShort(75). +legacyConfig(thing(76)). +thingShort(76). +legacyConfig(thing(77)). +thingShort(77). +legacyConfig(thing(78)). +thingShort(78). +legacyConfig(thing(79)). +thingShort(79). +legacyConfig(thing(80)). +thingShort(80). +legacyConfig(thing(43)). +thingShort(43). +legacyConfig(thing(81)). +thingShort(81). +legacyConfig(thing(82)). +thingShort(82). +legacyConfig(thing(83)). +thingShort(83). +legacyConfig(thing(84)). +thingShort(84). +legacyConfig(thing(85)). +thingShort(85). +legacyConfig(thing(86)). +thingShort(86). +legacyConfig(thing(87)). +thingShort(87). +legacyConfig(thing(88)). +thingShort(88). +legacyConfig(thing(44)). +thingShort(44). +legacyConfig(thing(89)). +thingShort(89). +legacyConfig(thing(90)). +thingShort(90). +legacyConfig(thing(91)). +thingShort(91). +legacyConfig(thing(92)). +thingShort(92). +legacyConfig(thing(93)). +thingShort(93). +legacyConfig(thing(94)). +thingShort(94). +legacyConfig(thing(95)). +thingShort(95). +legacyConfig(thing(96)). +thingShort(96). +legacyConfig(thing(45)). +thingShort(45). +legacyConfig(thing(97)). +thingShort(97). +legacyConfig(thing(98)). +thingShort(98). +legacyConfig(thing(99)). +thingShort(99). +legacyConfig(thing(100)). +thingShort(100). +legacyConfig(thing(101)). +thingShort(101). +legacyConfig(thing(102)). +thingShort(102). +legacyConfig(thing(103)). +thingShort(103). +legacyConfig(thing(104)). +thingShort(104). +legacyConfig(thing(105)). +thingShort(105). +legacyConfig(thing(106)). +thingShort(106). +legacyConfig(thing(107)). +thingShort(107). +legacyConfig(thing(108)). +thingShort(108). +legacyConfig(thing(109)). +thingShort(109). +legacyConfig(thing(110)). +thingShort(110). +legacyConfig(thing(111)). +thingShort(111). +legacyConfig(thing(112)). +thingShort(112). +legacyConfig(thing(113)). +thingShort(113). +legacyConfig(thing(46)). +thingShort(46). +legacyConfig(thing(114)). +thingShort(114). +legacyConfig(thing(115)). +thingShort(115). +legacyConfig(thing(116)). +thingShort(116). +legacyConfig(thing(117)). +thingShort(117). +legacyConfig(thing(118)). +thingShort(118). +legacyConfig(thing(119)). +thingShort(119). +legacyConfig(thing(120)). +thingShort(120). +legacyConfig(thing(121)). +thingShort(121). +legacyConfig(personTOthing(1,41)). +legacyConfig(personTOthing(1,42)). +legacyConfig(personTOthing(1,43)). +legacyConfig(personTOthing(1,44)). +legacyConfig(personTOthing(1,45)). +legacyConfig(personTOthing(2,46)). +legacyConfig(personTOthing(2,47)). +legacyConfig(personTOthing(2,48)). +legacyConfig(personTOthing(2,49)). +legacyConfig(personTOthing(2,50)). +legacyConfig(personTOthing(3,51)). +legacyConfig(personTOthing(3,52)). +legacyConfig(personTOthing(3,53)). +legacyConfig(personTOthing(3,54)). +legacyConfig(personTOthing(3,55)). +legacyConfig(personTOthing(4,56)). +legacyConfig(personTOthing(4,57)). +legacyConfig(personTOthing(4,58)). +legacyConfig(personTOthing(4,59)). +legacyConfig(personTOthing(4,60)). +legacyConfig(personTOthing(5,61)). +legacyConfig(personTOthing(5,62)). +legacyConfig(personTOthing(5,63)). +legacyConfig(personTOthing(5,64)). +legacyConfig(personTOthing(5,65)). +legacyConfig(personTOthing(6,66)). +legacyConfig(personTOthing(6,67)). +legacyConfig(personTOthing(6,68)). +legacyConfig(personTOthing(6,69)). +legacyConfig(personTOthing(6,70)). +legacyConfig(personTOthing(7,71)). +legacyConfig(personTOthing(7,72)). +legacyConfig(personTOthing(7,73)). +legacyConfig(personTOthing(7,74)). +legacyConfig(personTOthing(7,75)). +legacyConfig(personTOthing(8,76)). +legacyConfig(personTOthing(8,77)). +legacyConfig(personTOthing(8,78)). +legacyConfig(personTOthing(8,79)). +legacyConfig(personTOthing(8,80)). +legacyConfig(personTOthing(9,81)). +legacyConfig(personTOthing(9,82)). +legacyConfig(personTOthing(9,83)). +legacyConfig(personTOthing(9,84)). +legacyConfig(personTOthing(9,85)). +legacyConfig(personTOthing(10,86)). +legacyConfig(personTOthing(10,87)). +legacyConfig(personTOthing(10,88)). +legacyConfig(personTOthing(10,89)). +legacyConfig(personTOthing(10,90)). +legacyConfig(personTOthing(11,91)). +legacyConfig(personTOthing(11,92)). +legacyConfig(personTOthing(11,93)). +legacyConfig(personTOthing(11,94)). +legacyConfig(personTOthing(11,95)). +legacyConfig(personTOthing(12,96)). +legacyConfig(personTOthing(12,97)). +legacyConfig(personTOthing(12,98)). +legacyConfig(personTOthing(12,99)). +legacyConfig(personTOthing(12,100)). +legacyConfig(personTOthing(13,101)). +legacyConfig(personTOthing(13,102)). +legacyConfig(personTOthing(13,103)). +legacyConfig(personTOthing(13,104)). +legacyConfig(personTOthing(13,105)). +legacyConfig(personTOthing(14,106)). +legacyConfig(personTOthing(14,107)). +legacyConfig(personTOthing(14,108)). +legacyConfig(personTOthing(14,109)). +legacyConfig(personTOthing(14,110)). +legacyConfig(personTOthing(15,111)). +legacyConfig(personTOthing(15,112)). +legacyConfig(personTOthing(15,113)). +legacyConfig(personTOthing(15,114)). +legacyConfig(personTOthing(15,115)). +legacyConfig(personTOthing(16,116)). +legacyConfig(personTOthing(16,117)). +legacyConfig(personTOthing(16,118)). +legacyConfig(personTOthing(16,119)). +legacyConfig(personTOthing(16,120)). +legacyConfig(personTOthing(17,121)). +legacyConfig(personTOthing(17,122)). +legacyConfig(personTOthing(17,123)). +legacyConfig(personTOthing(17,124)). +legacyConfig(personTOthing(17,125)). +legacyConfig(personTOthing(18,126)). +legacyConfig(personTOthing(18,127)). +legacyConfig(personTOthing(18,128)). +legacyConfig(personTOthing(18,129)). +legacyConfig(personTOthing(18,130)). +legacyConfig(personTOthing(19,131)). +legacyConfig(personTOthing(19,132)). +legacyConfig(personTOthing(19,133)). +legacyConfig(personTOthing(19,134)). +legacyConfig(personTOthing(19,135)). +legacyConfig(personTOthing(20,136)). +legacyConfig(personTOthing(20,137)). +legacyConfig(personTOthing(20,138)). +legacyConfig(personTOthing(20,139)). +legacyConfig(personTOthing(20,140)). +legacyConfig(personTOthing(21,141)). +legacyConfig(personTOthing(21,142)). +legacyConfig(personTOthing(21,143)). +legacyConfig(personTOthing(21,144)). +legacyConfig(personTOthing(21,145)). +legacyConfig(personTOthing(22,146)). +legacyConfig(personTOthing(22,147)). +legacyConfig(personTOthing(22,148)). +legacyConfig(personTOthing(22,149)). +legacyConfig(personTOthing(22,150)). +legacyConfig(personTOthing(23,151)). +legacyConfig(personTOthing(23,152)). +legacyConfig(personTOthing(23,153)). +legacyConfig(personTOthing(23,154)). +legacyConfig(personTOthing(23,155)). +legacyConfig(personTOthing(24,156)). +legacyConfig(personTOthing(24,157)). +legacyConfig(personTOthing(24,158)). +legacyConfig(personTOthing(24,159)). +legacyConfig(personTOthing(24,160)). +legacyConfig(personTOthing(25,161)). +legacyConfig(personTOthing(25,162)). +legacyConfig(personTOthing(25,163)). +legacyConfig(personTOthing(25,164)). +legacyConfig(personTOthing(25,165)). +legacyConfig(personTOthing(26,166)). +legacyConfig(personTOthing(26,167)). +legacyConfig(personTOthing(26,168)). +legacyConfig(personTOthing(26,169)). +legacyConfig(personTOthing(26,170)). +legacyConfig(personTOthing(27,171)). +legacyConfig(personTOthing(27,172)). +legacyConfig(personTOthing(27,173)). +legacyConfig(personTOthing(27,174)). +legacyConfig(personTOthing(27,175)). +legacyConfig(personTOthing(28,176)). +legacyConfig(personTOthing(28,177)). +legacyConfig(personTOthing(28,178)). +legacyConfig(personTOthing(28,179)). +legacyConfig(personTOthing(28,180)). +legacyConfig(personTOthing(29,181)). +legacyConfig(personTOthing(29,182)). +legacyConfig(personTOthing(29,183)). +legacyConfig(personTOthing(29,184)). +legacyConfig(personTOthing(29,185)). +legacyConfig(personTOthing(30,186)). +legacyConfig(personTOthing(30,187)). +legacyConfig(personTOthing(30,188)). +legacyConfig(personTOthing(30,189)). +legacyConfig(personTOthing(30,190)). +legacyConfig(personTOthing(31,191)). +legacyConfig(personTOthing(31,192)). +legacyConfig(personTOthing(31,193)). +legacyConfig(personTOthing(31,194)). +legacyConfig(personTOthing(31,195)). +legacyConfig(personTOthing(32,196)). +legacyConfig(personTOthing(32,197)). +legacyConfig(personTOthing(32,198)). +legacyConfig(personTOthing(32,199)). +legacyConfig(personTOthing(32,200)). +legacyConfig(personTOthing(33,201)). +legacyConfig(personTOthing(33,202)). +legacyConfig(personTOthing(33,203)). +legacyConfig(personTOthing(33,204)). +legacyConfig(personTOthing(33,205)). +legacyConfig(personTOthing(34,206)). +legacyConfig(personTOthing(34,207)). +legacyConfig(personTOthing(34,208)). +legacyConfig(personTOthing(34,209)). +legacyConfig(personTOthing(34,210)). +legacyConfig(personTOthing(35,211)). +legacyConfig(personTOthing(35,212)). +legacyConfig(personTOthing(35,213)). +legacyConfig(personTOthing(35,214)). +legacyConfig(personTOthing(35,215)). +legacyConfig(personTOthing(36,216)). +legacyConfig(personTOthing(36,217)). +legacyConfig(personTOthing(36,218)). +legacyConfig(personTOthing(36,219)). +legacyConfig(personTOthing(36,220)). +legacyConfig(personTOthing(37,221)). +legacyConfig(personTOthing(37,222)). +legacyConfig(personTOthing(37,223)). +legacyConfig(personTOthing(37,224)). +legacyConfig(personTOthing(37,225)). +legacyConfig(personTOthing(38,226)). +legacyConfig(personTOthing(38,227)). +legacyConfig(personTOthing(38,228)). +legacyConfig(personTOthing(38,229)). +legacyConfig(personTOthing(38,230)). +legacyConfig(personTOthing(39,231)). +legacyConfig(personTOthing(39,232)). +legacyConfig(personTOthing(39,233)). +legacyConfig(personTOthing(39,234)). +legacyConfig(personTOthing(39,235)). +legacyConfig(personTOthing(40,236)). +legacyConfig(personTOthing(40,237)). +legacyConfig(personTOthing(40,238)). +legacyConfig(personTOthing(40,239)). +legacyConfig(personTOthing(40,240)). +% domains +cabinetDomainNew(500..699). +roomDomainNew(1000..1199). +cabinetUpper(200). +roomUpper(200). +cabinetLower(40). +roomLower(10). +% reuse costs +reuseCabinetTOthingCost(0). +reuseRoomTOcabinetCost(0). +reusePersonTOroomCost(0). +reuseCabinetAsHighCost(3). +reuseCabinetAsSmallCost(0). +reuseRoomCost(0). +% remove costs +removeCabinetTOthingCost(2). +removeRoomTOcabinetCost(2). +removePersonTOroomCost(2). +removeCabinetCost(2). +removeRoomCost(2). +% create costs +cabinetHighCost(100). +cabinetSmallCost(1). +roomCost(5). diff --git a/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p45t225.edb b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p45t225.edb new file mode 100644 index 000000000..7443b6650 --- /dev/null +++ b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p45t225.edb @@ -0,0 +1,744 @@ +legacyConfig(person(1)). +legacyConfig(person(2)). +legacyConfig(person(3)). +legacyConfig(person(4)). +legacyConfig(person(5)). +legacyConfig(person(6)). +legacyConfig(person(7)). +legacyConfig(person(8)). +legacyConfig(person(9)). +legacyConfig(person(10)). +legacyConfig(person(11)). +legacyConfig(person(12)). +legacyConfig(person(13)). +legacyConfig(person(14)). +legacyConfig(person(15)). +legacyConfig(person(16)). +legacyConfig(person(17)). +legacyConfig(person(18)). +legacyConfig(person(19)). +legacyConfig(person(20)). +legacyConfig(person(21)). +legacyConfig(person(22)). +legacyConfig(person(23)). +legacyConfig(person(24)). +legacyConfig(person(25)). +legacyConfig(person(26)). +legacyConfig(person(27)). +legacyConfig(person(28)). +legacyConfig(person(29)). +legacyConfig(person(30)). +legacyConfig(person(31)). +legacyConfig(person(32)). +legacyConfig(person(33)). +legacyConfig(person(34)). +legacyConfig(person(35)). +legacyConfig(person(36)). +legacyConfig(person(37)). +legacyConfig(person(38)). +legacyConfig(person(39)). +legacyConfig(person(40)). +legacyConfig(person(41)). +legacyConfig(person(42)). +legacyConfig(person(43)). +legacyConfig(person(44)). +legacyConfig(person(45)). +legacyConfig(thing(46)). +thingShort(46). +legacyConfig(thing(47)). +thingShort(47). +legacyConfig(thing(48)). +thingShort(48). +legacyConfig(thing(49)). +thingShort(49). +legacyConfig(thing(50)). +thingShort(50). +legacyConfig(thing(51)). +thingShort(51). +legacyConfig(thing(52)). +thingShort(52). +legacyConfig(thing(53)). +thingShort(53). +legacyConfig(thing(54)). +thingShort(54). +legacyConfig(thing(55)). +thingShort(55). +legacyConfig(thing(56)). +thingShort(56). +legacyConfig(thing(57)). +thingShort(57). +legacyConfig(thing(58)). +thingShort(58). +legacyConfig(thing(59)). +thingShort(59). +legacyConfig(thing(60)). +thingShort(60). +legacyConfig(thing(61)). +thingShort(61). +legacyConfig(thing(62)). +thingShort(62). +legacyConfig(thing(63)). +thingShort(63). +legacyConfig(thing(64)). +thingShort(64). +legacyConfig(thing(65)). +thingShort(65). +legacyConfig(thing(66)). +thingShort(66). +legacyConfig(thing(67)). +thingShort(67). +legacyConfig(thing(68)). +thingShort(68). +legacyConfig(thing(69)). +thingShort(69). +legacyConfig(thing(70)). +thingShort(70). +legacyConfig(thing(71)). +thingShort(71). +legacyConfig(thing(72)). +thingShort(72). +legacyConfig(thing(73)). +thingShort(73). +legacyConfig(thing(74)). +thingShort(74). +legacyConfig(thing(75)). +thingShort(75). +legacyConfig(thing(76)). +thingShort(76). +legacyConfig(thing(77)). +thingShort(77). +legacyConfig(thing(78)). +thingShort(78). +legacyConfig(thing(79)). +thingShort(79). +legacyConfig(thing(80)). +thingShort(80). +legacyConfig(thing(81)). +thingShort(81). +legacyConfig(thing(82)). +thingShort(82). +legacyConfig(thing(83)). +thingShort(83). +legacyConfig(thing(84)). +thingShort(84). +legacyConfig(thing(85)). +thingShort(85). +legacyConfig(thing(86)). +thingShort(86). +legacyConfig(thing(87)). +thingShort(87). +legacyConfig(thing(88)). +thingShort(88). +legacyConfig(thing(89)). +thingShort(89). +legacyConfig(thing(90)). +thingShort(90). +legacyConfig(thing(91)). +thingShort(91). +legacyConfig(thing(92)). +thingShort(92). +legacyConfig(thing(93)). +thingShort(93). +legacyConfig(thing(94)). +thingShort(94). +legacyConfig(thing(95)). +thingShort(95). +legacyConfig(thing(96)). +thingShort(96). +legacyConfig(thing(97)). +thingShort(97). +legacyConfig(thing(98)). +thingShort(98). +legacyConfig(thing(99)). +thingShort(99). +legacyConfig(thing(100)). +thingShort(100). +legacyConfig(thing(101)). +thingShort(101). +legacyConfig(thing(102)). +thingShort(102). +legacyConfig(thing(103)). +thingShort(103). +legacyConfig(thing(104)). +thingShort(104). +legacyConfig(thing(105)). +thingShort(105). +legacyConfig(thing(106)). +thingShort(106). +legacyConfig(thing(107)). +thingShort(107). +legacyConfig(thing(108)). +thingShort(108). +legacyConfig(thing(109)). +thingShort(109). +legacyConfig(thing(110)). +thingShort(110). +legacyConfig(thing(111)). +thingShort(111). +legacyConfig(thing(112)). +thingShort(112). +legacyConfig(thing(113)). +thingShort(113). +legacyConfig(thing(114)). +thingShort(114). +legacyConfig(thing(115)). +thingShort(115). +legacyConfig(thing(116)). +thingShort(116). +legacyConfig(thing(117)). +thingShort(117). +legacyConfig(thing(118)). +thingShort(118). +legacyConfig(thing(119)). +thingShort(119). +legacyConfig(thing(120)). +thingShort(120). +legacyConfig(thing(121)). +thingShort(121). +legacyConfig(thing(122)). +thingShort(122). +legacyConfig(thing(123)). +thingShort(123). +legacyConfig(thing(124)). +thingShort(124). +legacyConfig(thing(125)). +thingShort(125). +legacyConfig(thing(126)). +thingShort(126). +legacyConfig(thing(127)). +thingShort(127). +legacyConfig(thing(128)). +thingShort(128). +legacyConfig(thing(129)). +thingShort(129). +legacyConfig(thing(130)). +thingShort(130). +legacyConfig(thing(131)). +thingShort(131). +legacyConfig(thing(132)). +thingShort(132). +legacyConfig(thing(133)). +thingShort(133). +legacyConfig(thing(134)). +thingShort(134). +legacyConfig(thing(135)). +thingShort(135). +legacyConfig(thing(136)). +thingShort(136). +legacyConfig(thing(137)). +thingShort(137). +legacyConfig(thing(138)). +thingShort(138). +legacyConfig(thing(139)). +thingShort(139). +legacyConfig(thing(140)). +thingShort(140). +legacyConfig(thing(141)). +thingShort(141). +legacyConfig(thing(142)). +thingShort(142). +legacyConfig(thing(143)). +thingShort(143). +legacyConfig(thing(144)). +thingShort(144). +legacyConfig(thing(145)). +thingShort(145). +legacyConfig(thing(146)). +thingShort(146). +legacyConfig(thing(147)). +thingShort(147). +legacyConfig(thing(148)). +thingShort(148). +legacyConfig(thing(149)). +thingShort(149). +legacyConfig(thing(150)). +thingShort(150). +legacyConfig(thing(151)). +thingShort(151). +legacyConfig(thing(152)). +thingShort(152). +legacyConfig(thing(153)). +thingShort(153). +legacyConfig(thing(154)). +thingShort(154). +legacyConfig(thing(155)). +thingShort(155). +legacyConfig(thing(156)). +thingShort(156). +legacyConfig(thing(157)). +thingShort(157). +legacyConfig(thing(158)). +thingShort(158). +legacyConfig(thing(159)). +thingShort(159). +legacyConfig(thing(160)). +thingShort(160). +legacyConfig(thing(161)). +thingShort(161). +legacyConfig(thing(162)). +thingShort(162). +legacyConfig(thing(163)). +thingShort(163). +legacyConfig(thing(164)). +thingShort(164). +legacyConfig(thing(165)). +thingShort(165). +legacyConfig(thing(166)). +thingShort(166). +legacyConfig(thing(167)). +thingShort(167). +legacyConfig(thing(168)). +thingShort(168). +legacyConfig(thing(169)). +thingShort(169). +legacyConfig(thing(170)). +thingShort(170). +legacyConfig(thing(171)). +thingShort(171). +legacyConfig(thing(172)). +thingShort(172). +legacyConfig(thing(173)). +thingShort(173). +legacyConfig(thing(174)). +thingShort(174). +legacyConfig(thing(175)). +thingShort(175). +legacyConfig(thing(176)). +thingShort(176). +legacyConfig(thing(177)). +thingShort(177). +legacyConfig(thing(178)). +thingShort(178). +legacyConfig(thing(179)). +thingShort(179). +legacyConfig(thing(180)). +thingShort(180). +legacyConfig(thing(181)). +thingShort(181). +legacyConfig(thing(182)). +thingShort(182). +legacyConfig(thing(183)). +thingShort(183). +legacyConfig(thing(184)). +thingShort(184). +legacyConfig(thing(185)). +thingShort(185). +legacyConfig(thing(186)). +thingShort(186). +legacyConfig(thing(187)). +thingShort(187). +legacyConfig(thing(188)). +thingShort(188). +legacyConfig(thing(189)). +thingShort(189). +legacyConfig(thing(190)). +thingShort(190). +legacyConfig(thing(191)). +thingShort(191). +legacyConfig(thing(192)). +thingShort(192). +legacyConfig(thing(193)). +thingShort(193). +legacyConfig(thing(194)). +thingShort(194). +legacyConfig(thing(195)). +thingShort(195). +legacyConfig(thing(196)). +thingShort(196). +legacyConfig(thing(197)). +thingShort(197). +legacyConfig(thing(198)). +thingShort(198). +legacyConfig(thing(199)). +thingShort(199). +legacyConfig(thing(200)). +thingShort(200). +legacyConfig(thing(201)). +thingShort(201). +legacyConfig(thing(202)). +thingShort(202). +legacyConfig(thing(203)). +thingShort(203). +legacyConfig(thing(204)). +thingShort(204). +legacyConfig(thing(205)). +thingShort(205). +legacyConfig(thing(206)). +thingShort(206). +legacyConfig(thing(207)). +thingShort(207). +legacyConfig(thing(208)). +thingShort(208). +legacyConfig(thing(209)). +thingShort(209). +legacyConfig(thing(210)). +thingShort(210). +legacyConfig(thing(211)). +thingShort(211). +legacyConfig(thing(212)). +thingShort(212). +legacyConfig(thing(213)). +thingShort(213). +legacyConfig(thing(214)). +thingShort(214). +legacyConfig(thing(215)). +thingShort(215). +legacyConfig(thing(216)). +thingShort(216). +legacyConfig(thing(217)). +thingShort(217). +legacyConfig(thing(218)). +thingShort(218). +legacyConfig(thing(219)). +thingShort(219). +legacyConfig(thing(220)). +thingShort(220). +legacyConfig(thing(221)). +thingShort(221). +legacyConfig(thing(222)). +thingShort(222). +legacyConfig(thing(223)). +thingShort(223). +legacyConfig(thing(224)). +thingShort(224). +legacyConfig(thing(225)). +thingShort(225). +legacyConfig(thing(226)). +thingShort(226). +legacyConfig(thing(227)). +thingShort(227). +legacyConfig(thing(228)). +thingShort(228). +legacyConfig(thing(229)). +thingShort(229). +legacyConfig(thing(230)). +thingShort(230). +legacyConfig(thing(231)). +thingShort(231). +legacyConfig(thing(232)). +thingShort(232). +legacyConfig(thing(233)). +thingShort(233). +legacyConfig(thing(234)). +thingShort(234). +legacyConfig(thing(235)). +thingShort(235). +legacyConfig(thing(236)). +thingShort(236). +legacyConfig(thing(237)). +thingShort(237). +legacyConfig(thing(238)). +thingShort(238). +legacyConfig(thing(239)). +thingShort(239). +legacyConfig(thing(240)). +thingShort(240). +legacyConfig(thing(241)). +thingShort(241). +legacyConfig(thing(242)). +thingShort(242). +legacyConfig(thing(243)). +thingShort(243). +legacyConfig(thing(244)). +thingShort(244). +legacyConfig(thing(245)). +thingShort(245). +legacyConfig(thing(246)). +thingShort(246). +legacyConfig(thing(247)). +thingShort(247). +legacyConfig(thing(248)). +thingShort(248). +legacyConfig(thing(249)). +thingShort(249). +legacyConfig(thing(250)). +thingShort(250). +legacyConfig(thing(251)). +thingShort(251). +legacyConfig(thing(252)). +thingShort(252). +legacyConfig(thing(253)). +thingShort(253). +legacyConfig(thing(254)). +thingShort(254). +legacyConfig(thing(255)). +thingShort(255). +legacyConfig(thing(256)). +thingShort(256). +legacyConfig(thing(257)). +thingShort(257). +legacyConfig(thing(258)). +thingShort(258). +legacyConfig(thing(259)). +thingShort(259). +legacyConfig(thing(260)). +thingShort(260). +legacyConfig(thing(261)). +thingShort(261). +legacyConfig(thing(262)). +thingShort(262). +legacyConfig(thing(263)). +thingShort(263). +legacyConfig(thing(264)). +thingShort(264). +legacyConfig(thing(265)). +thingShort(265). +legacyConfig(thing(266)). +thingShort(266). +legacyConfig(thing(267)). +thingShort(267). +legacyConfig(thing(268)). +thingShort(268). +legacyConfig(thing(269)). +thingShort(269). +legacyConfig(thing(270)). +thingShort(270). +legacyConfig(personTOthing(1,46)). +legacyConfig(personTOthing(1,47)). +legacyConfig(personTOthing(1,48)). +legacyConfig(personTOthing(1,49)). +legacyConfig(personTOthing(1,50)). +legacyConfig(personTOthing(2,51)). +legacyConfig(personTOthing(2,52)). +legacyConfig(personTOthing(2,53)). +legacyConfig(personTOthing(2,54)). +legacyConfig(personTOthing(2,55)). +legacyConfig(personTOthing(3,56)). +legacyConfig(personTOthing(3,57)). +legacyConfig(personTOthing(3,58)). +legacyConfig(personTOthing(3,59)). +legacyConfig(personTOthing(3,60)). +legacyConfig(personTOthing(4,61)). +legacyConfig(personTOthing(4,62)). +legacyConfig(personTOthing(4,63)). +legacyConfig(personTOthing(4,64)). +legacyConfig(personTOthing(4,65)). +legacyConfig(personTOthing(5,66)). +legacyConfig(personTOthing(5,67)). +legacyConfig(personTOthing(5,68)). +legacyConfig(personTOthing(5,69)). +legacyConfig(personTOthing(5,70)). +legacyConfig(personTOthing(6,71)). +legacyConfig(personTOthing(6,72)). +legacyConfig(personTOthing(6,73)). +legacyConfig(personTOthing(6,74)). +legacyConfig(personTOthing(6,75)). +legacyConfig(personTOthing(7,76)). +legacyConfig(personTOthing(7,77)). +legacyConfig(personTOthing(7,78)). +legacyConfig(personTOthing(7,79)). +legacyConfig(personTOthing(7,80)). +legacyConfig(personTOthing(8,81)). +legacyConfig(personTOthing(8,82)). +legacyConfig(personTOthing(8,83)). +legacyConfig(personTOthing(8,84)). +legacyConfig(personTOthing(8,85)). +legacyConfig(personTOthing(9,86)). +legacyConfig(personTOthing(9,87)). +legacyConfig(personTOthing(9,88)). +legacyConfig(personTOthing(9,89)). +legacyConfig(personTOthing(9,90)). +legacyConfig(personTOthing(10,91)). +legacyConfig(personTOthing(10,92)). +legacyConfig(personTOthing(10,93)). +legacyConfig(personTOthing(10,94)). +legacyConfig(personTOthing(10,95)). +legacyConfig(personTOthing(11,96)). +legacyConfig(personTOthing(11,97)). +legacyConfig(personTOthing(11,98)). +legacyConfig(personTOthing(11,99)). +legacyConfig(personTOthing(11,100)). +legacyConfig(personTOthing(12,101)). +legacyConfig(personTOthing(12,102)). +legacyConfig(personTOthing(12,103)). +legacyConfig(personTOthing(12,104)). +legacyConfig(personTOthing(12,105)). +legacyConfig(personTOthing(13,106)). +legacyConfig(personTOthing(13,107)). +legacyConfig(personTOthing(13,108)). +legacyConfig(personTOthing(13,109)). +legacyConfig(personTOthing(13,110)). +legacyConfig(personTOthing(14,111)). +legacyConfig(personTOthing(14,112)). +legacyConfig(personTOthing(14,113)). +legacyConfig(personTOthing(14,114)). +legacyConfig(personTOthing(14,115)). +legacyConfig(personTOthing(15,116)). +legacyConfig(personTOthing(15,117)). +legacyConfig(personTOthing(15,118)). +legacyConfig(personTOthing(15,119)). +legacyConfig(personTOthing(15,120)). +legacyConfig(personTOthing(16,121)). +legacyConfig(personTOthing(16,122)). +legacyConfig(personTOthing(16,123)). +legacyConfig(personTOthing(16,124)). +legacyConfig(personTOthing(16,125)). +legacyConfig(personTOthing(17,126)). +legacyConfig(personTOthing(17,127)). +legacyConfig(personTOthing(17,128)). +legacyConfig(personTOthing(17,129)). +legacyConfig(personTOthing(17,130)). +legacyConfig(personTOthing(18,131)). +legacyConfig(personTOthing(18,132)). +legacyConfig(personTOthing(18,133)). +legacyConfig(personTOthing(18,134)). +legacyConfig(personTOthing(18,135)). +legacyConfig(personTOthing(19,136)). +legacyConfig(personTOthing(19,137)). +legacyConfig(personTOthing(19,138)). +legacyConfig(personTOthing(19,139)). +legacyConfig(personTOthing(19,140)). +legacyConfig(personTOthing(20,141)). +legacyConfig(personTOthing(20,142)). +legacyConfig(personTOthing(20,143)). +legacyConfig(personTOthing(20,144)). +legacyConfig(personTOthing(20,145)). +legacyConfig(personTOthing(21,146)). +legacyConfig(personTOthing(21,147)). +legacyConfig(personTOthing(21,148)). +legacyConfig(personTOthing(21,149)). +legacyConfig(personTOthing(21,150)). +legacyConfig(personTOthing(22,151)). +legacyConfig(personTOthing(22,152)). +legacyConfig(personTOthing(22,153)). +legacyConfig(personTOthing(22,154)). +legacyConfig(personTOthing(22,155)). +legacyConfig(personTOthing(23,156)). +legacyConfig(personTOthing(23,157)). +legacyConfig(personTOthing(23,158)). +legacyConfig(personTOthing(23,159)). +legacyConfig(personTOthing(23,160)). +legacyConfig(personTOthing(24,161)). +legacyConfig(personTOthing(24,162)). +legacyConfig(personTOthing(24,163)). +legacyConfig(personTOthing(24,164)). +legacyConfig(personTOthing(24,165)). +legacyConfig(personTOthing(25,166)). +legacyConfig(personTOthing(25,167)). +legacyConfig(personTOthing(25,168)). +legacyConfig(personTOthing(25,169)). +legacyConfig(personTOthing(25,170)). +legacyConfig(personTOthing(26,171)). +legacyConfig(personTOthing(26,172)). +legacyConfig(personTOthing(26,173)). +legacyConfig(personTOthing(26,174)). +legacyConfig(personTOthing(26,175)). +legacyConfig(personTOthing(27,176)). +legacyConfig(personTOthing(27,177)). +legacyConfig(personTOthing(27,178)). +legacyConfig(personTOthing(27,179)). +legacyConfig(personTOthing(27,180)). +legacyConfig(personTOthing(28,181)). +legacyConfig(personTOthing(28,182)). +legacyConfig(personTOthing(28,183)). +legacyConfig(personTOthing(28,184)). +legacyConfig(personTOthing(28,185)). +legacyConfig(personTOthing(29,186)). +legacyConfig(personTOthing(29,187)). +legacyConfig(personTOthing(29,188)). +legacyConfig(personTOthing(29,189)). +legacyConfig(personTOthing(29,190)). +legacyConfig(personTOthing(30,191)). +legacyConfig(personTOthing(30,192)). +legacyConfig(personTOthing(30,193)). +legacyConfig(personTOthing(30,194)). +legacyConfig(personTOthing(30,195)). +legacyConfig(personTOthing(31,196)). +legacyConfig(personTOthing(31,197)). +legacyConfig(personTOthing(31,198)). +legacyConfig(personTOthing(31,199)). +legacyConfig(personTOthing(31,200)). +legacyConfig(personTOthing(32,201)). +legacyConfig(personTOthing(32,202)). +legacyConfig(personTOthing(32,203)). +legacyConfig(personTOthing(32,204)). +legacyConfig(personTOthing(32,205)). +legacyConfig(personTOthing(33,206)). +legacyConfig(personTOthing(33,207)). +legacyConfig(personTOthing(33,208)). +legacyConfig(personTOthing(33,209)). +legacyConfig(personTOthing(33,210)). +legacyConfig(personTOthing(34,211)). +legacyConfig(personTOthing(34,212)). +legacyConfig(personTOthing(34,213)). +legacyConfig(personTOthing(34,214)). +legacyConfig(personTOthing(34,215)). +legacyConfig(personTOthing(35,216)). +legacyConfig(personTOthing(35,217)). +legacyConfig(personTOthing(35,218)). +legacyConfig(personTOthing(35,219)). +legacyConfig(personTOthing(35,220)). +legacyConfig(personTOthing(36,221)). +legacyConfig(personTOthing(36,222)). +legacyConfig(personTOthing(36,223)). +legacyConfig(personTOthing(36,224)). +legacyConfig(personTOthing(36,225)). +legacyConfig(personTOthing(37,226)). +legacyConfig(personTOthing(37,227)). +legacyConfig(personTOthing(37,228)). +legacyConfig(personTOthing(37,229)). +legacyConfig(personTOthing(37,230)). +legacyConfig(personTOthing(38,231)). +legacyConfig(personTOthing(38,232)). +legacyConfig(personTOthing(38,233)). +legacyConfig(personTOthing(38,234)). +legacyConfig(personTOthing(38,235)). +legacyConfig(personTOthing(39,236)). +legacyConfig(personTOthing(39,237)). +legacyConfig(personTOthing(39,238)). +legacyConfig(personTOthing(39,239)). +legacyConfig(personTOthing(39,240)). +legacyConfig(personTOthing(40,241)). +legacyConfig(personTOthing(40,242)). +legacyConfig(personTOthing(40,243)). +legacyConfig(personTOthing(40,244)). +legacyConfig(personTOthing(40,245)). +legacyConfig(personTOthing(41,246)). +legacyConfig(personTOthing(41,247)). +legacyConfig(personTOthing(41,248)). +legacyConfig(personTOthing(41,249)). +legacyConfig(personTOthing(41,250)). +legacyConfig(personTOthing(42,251)). +legacyConfig(personTOthing(42,252)). +legacyConfig(personTOthing(42,253)). +legacyConfig(personTOthing(42,254)). +legacyConfig(personTOthing(42,255)). +legacyConfig(personTOthing(43,256)). +legacyConfig(personTOthing(43,257)). +legacyConfig(personTOthing(43,258)). +legacyConfig(personTOthing(43,259)). +legacyConfig(personTOthing(43,260)). +legacyConfig(personTOthing(44,261)). +legacyConfig(personTOthing(44,262)). +legacyConfig(personTOthing(44,263)). +legacyConfig(personTOthing(44,264)). +legacyConfig(personTOthing(44,265)). +legacyConfig(personTOthing(45,266)). +legacyConfig(personTOthing(45,267)). +legacyConfig(personTOthing(45,268)). +legacyConfig(personTOthing(45,269)). +legacyConfig(personTOthing(45,270)). +% domains +cabinetDomainNew(500..724). +roomDomainNew(1000..1224). +cabinetUpper(225). +roomUpper(225). +cabinetLower(45). +roomLower(12). +% reuse costs +reuseCabinetTOthingCost(0). +reuseRoomTOcabinetCost(0). +reusePersonTOroomCost(0). +reuseCabinetAsHighCost(3). +reuseCabinetAsSmallCost(0). +reuseRoomCost(0). +% remove costs +removeCabinetTOthingCost(2). +removeRoomTOcabinetCost(2). +removePersonTOroomCost(2). +removeCabinetCost(2). +removeRoomCost(2). +% create costs +cabinetHighCost(100). +cabinetSmallCost(1). +roomCost(5). diff --git a/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p50t250.edb b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p50t250.edb new file mode 100644 index 000000000..94610fd86 --- /dev/null +++ b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p50t250.edb @@ -0,0 +1,824 @@ +legacyConfig(person(1)). +legacyConfig(person(2)). +legacyConfig(person(3)). +legacyConfig(person(4)). +legacyConfig(person(5)). +legacyConfig(person(6)). +legacyConfig(person(7)). +legacyConfig(person(8)). +legacyConfig(person(9)). +legacyConfig(person(10)). +legacyConfig(person(11)). +legacyConfig(person(12)). +legacyConfig(person(13)). +legacyConfig(person(14)). +legacyConfig(person(15)). +legacyConfig(person(16)). +legacyConfig(person(17)). +legacyConfig(person(18)). +legacyConfig(person(19)). +legacyConfig(person(20)). +legacyConfig(person(21)). +legacyConfig(person(22)). +legacyConfig(person(23)). +legacyConfig(person(24)). +legacyConfig(person(25)). +legacyConfig(person(26)). +legacyConfig(person(27)). +legacyConfig(person(28)). +legacyConfig(person(29)). +legacyConfig(person(30)). +legacyConfig(person(31)). +legacyConfig(person(32)). +legacyConfig(person(33)). +legacyConfig(person(34)). +legacyConfig(person(35)). +legacyConfig(person(36)). +legacyConfig(person(37)). +legacyConfig(person(38)). +legacyConfig(person(39)). +legacyConfig(person(40)). +legacyConfig(person(41)). +legacyConfig(person(42)). +legacyConfig(person(43)). +legacyConfig(person(44)). +legacyConfig(person(45)). +legacyConfig(person(46)). +legacyConfig(person(47)). +legacyConfig(person(48)). +legacyConfig(person(49)). +legacyConfig(person(50)). +legacyConfig(thing(51)). +thingShort(51). +legacyConfig(thing(52)). +thingShort(52). +legacyConfig(thing(53)). +thingShort(53). +legacyConfig(thing(54)). +thingShort(54). +legacyConfig(thing(55)). +thingShort(55). +legacyConfig(thing(56)). +thingShort(56). +legacyConfig(thing(57)). +thingShort(57). +legacyConfig(thing(58)). +thingShort(58). +legacyConfig(thing(59)). +thingShort(59). +legacyConfig(thing(60)). +thingShort(60). +legacyConfig(thing(61)). +thingShort(61). +legacyConfig(thing(62)). +thingShort(62). +legacyConfig(thing(63)). +thingShort(63). +legacyConfig(thing(64)). +thingShort(64). +legacyConfig(thing(65)). +thingShort(65). +legacyConfig(thing(66)). +thingShort(66). +legacyConfig(thing(67)). +thingShort(67). +legacyConfig(thing(68)). +thingShort(68). +legacyConfig(thing(69)). +thingShort(69). +legacyConfig(thing(70)). +thingShort(70). +legacyConfig(thing(71)). +thingShort(71). +legacyConfig(thing(72)). +thingShort(72). +legacyConfig(thing(73)). +thingShort(73). +legacyConfig(thing(74)). +thingShort(74). +legacyConfig(thing(75)). +thingShort(75). +legacyConfig(thing(76)). +thingShort(76). +legacyConfig(thing(77)). +thingShort(77). +legacyConfig(thing(78)). +thingShort(78). +legacyConfig(thing(79)). +thingShort(79). +legacyConfig(thing(80)). +thingShort(80). +legacyConfig(thing(81)). +thingShort(81). +legacyConfig(thing(82)). +thingShort(82). +legacyConfig(thing(83)). +thingShort(83). +legacyConfig(thing(84)). +thingShort(84). +legacyConfig(thing(85)). +thingShort(85). +legacyConfig(thing(86)). +thingShort(86). +legacyConfig(thing(87)). +thingShort(87). +legacyConfig(thing(88)). +thingShort(88). +legacyConfig(thing(89)). +thingShort(89). +legacyConfig(thing(90)). +thingShort(90). +legacyConfig(thing(91)). +thingShort(91). +legacyConfig(thing(92)). +thingShort(92). +legacyConfig(thing(93)). +thingShort(93). +legacyConfig(thing(94)). +thingShort(94). +legacyConfig(thing(95)). +thingShort(95). +legacyConfig(thing(96)). +thingShort(96). +legacyConfig(thing(97)). +thingShort(97). +legacyConfig(thing(98)). +thingShort(98). +legacyConfig(thing(99)). +thingShort(99). +legacyConfig(thing(100)). +thingShort(100). +legacyConfig(thing(101)). +thingShort(101). +legacyConfig(thing(102)). +thingShort(102). +legacyConfig(thing(103)). +thingShort(103). +legacyConfig(thing(104)). +thingShort(104). +legacyConfig(thing(105)). +thingShort(105). +legacyConfig(thing(106)). +thingShort(106). +legacyConfig(thing(107)). +thingShort(107). +legacyConfig(thing(108)). +thingShort(108). +legacyConfig(thing(109)). +thingShort(109). +legacyConfig(thing(110)). +thingShort(110). +legacyConfig(thing(111)). +thingShort(111). +legacyConfig(thing(112)). +thingShort(112). +legacyConfig(thing(113)). +thingShort(113). +legacyConfig(thing(114)). +thingShort(114). +legacyConfig(thing(115)). +thingShort(115). +legacyConfig(thing(116)). +thingShort(116). +legacyConfig(thing(117)). +thingShort(117). +legacyConfig(thing(118)). +thingShort(118). +legacyConfig(thing(119)). +thingShort(119). +legacyConfig(thing(120)). +thingShort(120). +legacyConfig(thing(121)). +thingShort(121). +legacyConfig(thing(122)). +thingShort(122). +legacyConfig(thing(123)). +thingShort(123). +legacyConfig(thing(124)). +thingShort(124). +legacyConfig(thing(125)). +thingShort(125). +legacyConfig(thing(126)). +thingShort(126). +legacyConfig(thing(127)). +thingShort(127). +legacyConfig(thing(128)). +thingShort(128). +legacyConfig(thing(129)). +thingShort(129). +legacyConfig(thing(130)). +thingShort(130). +legacyConfig(thing(131)). +thingShort(131). +legacyConfig(thing(132)). +thingShort(132). +legacyConfig(thing(133)). +thingShort(133). +legacyConfig(thing(134)). +thingShort(134). +legacyConfig(thing(135)). +thingShort(135). +legacyConfig(thing(136)). +thingShort(136). +legacyConfig(thing(137)). +thingShort(137). +legacyConfig(thing(138)). +thingShort(138). +legacyConfig(thing(139)). +thingShort(139). +legacyConfig(thing(140)). +thingShort(140). +legacyConfig(thing(141)). +thingShort(141). +legacyConfig(thing(142)). +thingShort(142). +legacyConfig(thing(143)). +thingShort(143). +legacyConfig(thing(144)). +thingShort(144). +legacyConfig(thing(145)). +thingShort(145). +legacyConfig(thing(146)). +thingShort(146). +legacyConfig(thing(147)). +thingShort(147). +legacyConfig(thing(148)). +thingShort(148). +legacyConfig(thing(149)). +thingShort(149). +legacyConfig(thing(150)). +thingShort(150). +legacyConfig(thing(151)). +thingShort(151). +legacyConfig(thing(152)). +thingShort(152). +legacyConfig(thing(153)). +thingShort(153). +legacyConfig(thing(154)). +thingShort(154). +legacyConfig(thing(155)). +thingShort(155). +legacyConfig(thing(156)). +thingShort(156). +legacyConfig(thing(157)). +thingShort(157). +legacyConfig(thing(158)). +thingShort(158). +legacyConfig(thing(159)). +thingShort(159). +legacyConfig(thing(160)). +thingShort(160). +legacyConfig(thing(161)). +thingShort(161). +legacyConfig(thing(162)). +thingShort(162). +legacyConfig(thing(163)). +thingShort(163). +legacyConfig(thing(164)). +thingShort(164). +legacyConfig(thing(165)). +thingShort(165). +legacyConfig(thing(166)). +thingShort(166). +legacyConfig(thing(167)). +thingShort(167). +legacyConfig(thing(168)). +thingShort(168). +legacyConfig(thing(169)). +thingShort(169). +legacyConfig(thing(170)). +thingShort(170). +legacyConfig(thing(171)). +thingShort(171). +legacyConfig(thing(172)). +thingShort(172). +legacyConfig(thing(173)). +thingShort(173). +legacyConfig(thing(174)). +thingShort(174). +legacyConfig(thing(175)). +thingShort(175). +legacyConfig(thing(176)). +thingShort(176). +legacyConfig(thing(177)). +thingShort(177). +legacyConfig(thing(178)). +thingShort(178). +legacyConfig(thing(179)). +thingShort(179). +legacyConfig(thing(180)). +thingShort(180). +legacyConfig(thing(181)). +thingShort(181). +legacyConfig(thing(182)). +thingShort(182). +legacyConfig(thing(183)). +thingShort(183). +legacyConfig(thing(184)). +thingShort(184). +legacyConfig(thing(185)). +thingShort(185). +legacyConfig(thing(186)). +thingShort(186). +legacyConfig(thing(187)). +thingShort(187). +legacyConfig(thing(188)). +thingShort(188). +legacyConfig(thing(189)). +thingShort(189). +legacyConfig(thing(190)). +thingShort(190). +legacyConfig(thing(191)). +thingShort(191). +legacyConfig(thing(192)). +thingShort(192). +legacyConfig(thing(193)). +thingShort(193). +legacyConfig(thing(194)). +thingShort(194). +legacyConfig(thing(195)). +thingShort(195). +legacyConfig(thing(196)). +thingShort(196). +legacyConfig(thing(197)). +thingShort(197). +legacyConfig(thing(198)). +thingShort(198). +legacyConfig(thing(199)). +thingShort(199). +legacyConfig(thing(200)). +thingShort(200). +legacyConfig(thing(201)). +thingShort(201). +legacyConfig(thing(202)). +thingShort(202). +legacyConfig(thing(203)). +thingShort(203). +legacyConfig(thing(204)). +thingShort(204). +legacyConfig(thing(205)). +thingShort(205). +legacyConfig(thing(206)). +thingShort(206). +legacyConfig(thing(207)). +thingShort(207). +legacyConfig(thing(208)). +thingShort(208). +legacyConfig(thing(209)). +thingShort(209). +legacyConfig(thing(210)). +thingShort(210). +legacyConfig(thing(211)). +thingShort(211). +legacyConfig(thing(212)). +thingShort(212). +legacyConfig(thing(213)). +thingShort(213). +legacyConfig(thing(214)). +thingShort(214). +legacyConfig(thing(215)). +thingShort(215). +legacyConfig(thing(216)). +thingShort(216). +legacyConfig(thing(217)). +thingShort(217). +legacyConfig(thing(218)). +thingShort(218). +legacyConfig(thing(219)). +thingShort(219). +legacyConfig(thing(220)). +thingShort(220). +legacyConfig(thing(221)). +thingShort(221). +legacyConfig(thing(222)). +thingShort(222). +legacyConfig(thing(223)). +thingShort(223). +legacyConfig(thing(224)). +thingShort(224). +legacyConfig(thing(225)). +thingShort(225). +legacyConfig(thing(226)). +thingShort(226). +legacyConfig(thing(227)). +thingShort(227). +legacyConfig(thing(228)). +thingShort(228). +legacyConfig(thing(229)). +thingShort(229). +legacyConfig(thing(230)). +thingShort(230). +legacyConfig(thing(231)). +thingShort(231). +legacyConfig(thing(232)). +thingShort(232). +legacyConfig(thing(233)). +thingShort(233). +legacyConfig(thing(234)). +thingShort(234). +legacyConfig(thing(235)). +thingShort(235). +legacyConfig(thing(236)). +thingShort(236). +legacyConfig(thing(237)). +thingShort(237). +legacyConfig(thing(238)). +thingShort(238). +legacyConfig(thing(239)). +thingShort(239). +legacyConfig(thing(240)). +thingShort(240). +legacyConfig(thing(241)). +thingShort(241). +legacyConfig(thing(242)). +thingShort(242). +legacyConfig(thing(243)). +thingShort(243). +legacyConfig(thing(244)). +thingShort(244). +legacyConfig(thing(245)). +thingShort(245). +legacyConfig(thing(246)). +thingShort(246). +legacyConfig(thing(247)). +thingShort(247). +legacyConfig(thing(248)). +thingShort(248). +legacyConfig(thing(249)). +thingShort(249). +legacyConfig(thing(250)). +thingShort(250). +legacyConfig(thing(251)). +thingShort(251). +legacyConfig(thing(252)). +thingShort(252). +legacyConfig(thing(253)). +thingShort(253). +legacyConfig(thing(254)). +thingShort(254). +legacyConfig(thing(255)). +thingShort(255). +legacyConfig(thing(256)). +thingShort(256). +legacyConfig(thing(257)). +thingShort(257). +legacyConfig(thing(258)). +thingShort(258). +legacyConfig(thing(259)). +thingShort(259). +legacyConfig(thing(260)). +thingShort(260). +legacyConfig(thing(261)). +thingShort(261). +legacyConfig(thing(262)). +thingShort(262). +legacyConfig(thing(263)). +thingShort(263). +legacyConfig(thing(264)). +thingShort(264). +legacyConfig(thing(265)). +thingShort(265). +legacyConfig(thing(266)). +thingShort(266). +legacyConfig(thing(267)). +thingShort(267). +legacyConfig(thing(268)). +thingShort(268). +legacyConfig(thing(269)). +thingShort(269). +legacyConfig(thing(270)). +thingShort(270). +legacyConfig(thing(271)). +thingShort(271). +legacyConfig(thing(272)). +thingShort(272). +legacyConfig(thing(273)). +thingShort(273). +legacyConfig(thing(274)). +thingShort(274). +legacyConfig(thing(275)). +thingShort(275). +legacyConfig(thing(276)). +thingShort(276). +legacyConfig(thing(277)). +thingShort(277). +legacyConfig(thing(278)). +thingShort(278). +legacyConfig(thing(279)). +thingShort(279). +legacyConfig(thing(280)). +thingShort(280). +legacyConfig(thing(281)). +thingShort(281). +legacyConfig(thing(282)). +thingShort(282). +legacyConfig(thing(283)). +thingShort(283). +legacyConfig(thing(284)). +thingShort(284). +legacyConfig(thing(285)). +thingShort(285). +legacyConfig(thing(286)). +thingShort(286). +legacyConfig(thing(287)). +thingShort(287). +legacyConfig(thing(288)). +thingShort(288). +legacyConfig(thing(289)). +thingShort(289). +legacyConfig(thing(290)). +thingShort(290). +legacyConfig(thing(291)). +thingShort(291). +legacyConfig(thing(292)). +thingShort(292). +legacyConfig(thing(293)). +thingShort(293). +legacyConfig(thing(294)). +thingShort(294). +legacyConfig(thing(295)). +thingShort(295). +legacyConfig(thing(296)). +thingShort(296). +legacyConfig(thing(297)). +thingShort(297). +legacyConfig(thing(298)). +thingShort(298). +legacyConfig(thing(299)). +thingShort(299). +legacyConfig(thing(300)). +thingShort(300). +legacyConfig(personTOthing(1,51)). +legacyConfig(personTOthing(1,52)). +legacyConfig(personTOthing(1,53)). +legacyConfig(personTOthing(1,54)). +legacyConfig(personTOthing(1,55)). +legacyConfig(personTOthing(2,56)). +legacyConfig(personTOthing(2,57)). +legacyConfig(personTOthing(2,58)). +legacyConfig(personTOthing(2,59)). +legacyConfig(personTOthing(2,60)). +legacyConfig(personTOthing(3,61)). +legacyConfig(personTOthing(3,62)). +legacyConfig(personTOthing(3,63)). +legacyConfig(personTOthing(3,64)). +legacyConfig(personTOthing(3,65)). +legacyConfig(personTOthing(4,66)). +legacyConfig(personTOthing(4,67)). +legacyConfig(personTOthing(4,68)). +legacyConfig(personTOthing(4,69)). +legacyConfig(personTOthing(4,70)). +legacyConfig(personTOthing(5,71)). +legacyConfig(personTOthing(5,72)). +legacyConfig(personTOthing(5,73)). +legacyConfig(personTOthing(5,74)). +legacyConfig(personTOthing(5,75)). +legacyConfig(personTOthing(6,76)). +legacyConfig(personTOthing(6,77)). +legacyConfig(personTOthing(6,78)). +legacyConfig(personTOthing(6,79)). +legacyConfig(personTOthing(6,80)). +legacyConfig(personTOthing(7,81)). +legacyConfig(personTOthing(7,82)). +legacyConfig(personTOthing(7,83)). +legacyConfig(personTOthing(7,84)). +legacyConfig(personTOthing(7,85)). +legacyConfig(personTOthing(8,86)). +legacyConfig(personTOthing(8,87)). +legacyConfig(personTOthing(8,88)). +legacyConfig(personTOthing(8,89)). +legacyConfig(personTOthing(8,90)). +legacyConfig(personTOthing(9,91)). +legacyConfig(personTOthing(9,92)). +legacyConfig(personTOthing(9,93)). +legacyConfig(personTOthing(9,94)). +legacyConfig(personTOthing(9,95)). +legacyConfig(personTOthing(10,96)). +legacyConfig(personTOthing(10,97)). +legacyConfig(personTOthing(10,98)). +legacyConfig(personTOthing(10,99)). +legacyConfig(personTOthing(10,100)). +legacyConfig(personTOthing(11,101)). +legacyConfig(personTOthing(11,102)). +legacyConfig(personTOthing(11,103)). +legacyConfig(personTOthing(11,104)). +legacyConfig(personTOthing(11,105)). +legacyConfig(personTOthing(12,106)). +legacyConfig(personTOthing(12,107)). +legacyConfig(personTOthing(12,108)). +legacyConfig(personTOthing(12,109)). +legacyConfig(personTOthing(12,110)). +legacyConfig(personTOthing(13,111)). +legacyConfig(personTOthing(13,112)). +legacyConfig(personTOthing(13,113)). +legacyConfig(personTOthing(13,114)). +legacyConfig(personTOthing(13,115)). +legacyConfig(personTOthing(14,116)). +legacyConfig(personTOthing(14,117)). +legacyConfig(personTOthing(14,118)). +legacyConfig(personTOthing(14,119)). +legacyConfig(personTOthing(14,120)). +legacyConfig(personTOthing(15,121)). +legacyConfig(personTOthing(15,122)). +legacyConfig(personTOthing(15,123)). +legacyConfig(personTOthing(15,124)). +legacyConfig(personTOthing(15,125)). +legacyConfig(personTOthing(16,126)). +legacyConfig(personTOthing(16,127)). +legacyConfig(personTOthing(16,128)). +legacyConfig(personTOthing(16,129)). +legacyConfig(personTOthing(16,130)). +legacyConfig(personTOthing(17,131)). +legacyConfig(personTOthing(17,132)). +legacyConfig(personTOthing(17,133)). +legacyConfig(personTOthing(17,134)). +legacyConfig(personTOthing(17,135)). +legacyConfig(personTOthing(18,136)). +legacyConfig(personTOthing(18,137)). +legacyConfig(personTOthing(18,138)). +legacyConfig(personTOthing(18,139)). +legacyConfig(personTOthing(18,140)). +legacyConfig(personTOthing(19,141)). +legacyConfig(personTOthing(19,142)). +legacyConfig(personTOthing(19,143)). +legacyConfig(personTOthing(19,144)). +legacyConfig(personTOthing(19,145)). +legacyConfig(personTOthing(20,146)). +legacyConfig(personTOthing(20,147)). +legacyConfig(personTOthing(20,148)). +legacyConfig(personTOthing(20,149)). +legacyConfig(personTOthing(20,150)). +legacyConfig(personTOthing(21,151)). +legacyConfig(personTOthing(21,152)). +legacyConfig(personTOthing(21,153)). +legacyConfig(personTOthing(21,154)). +legacyConfig(personTOthing(21,155)). +legacyConfig(personTOthing(22,156)). +legacyConfig(personTOthing(22,157)). +legacyConfig(personTOthing(22,158)). +legacyConfig(personTOthing(22,159)). +legacyConfig(personTOthing(22,160)). +legacyConfig(personTOthing(23,161)). +legacyConfig(personTOthing(23,162)). +legacyConfig(personTOthing(23,163)). +legacyConfig(personTOthing(23,164)). +legacyConfig(personTOthing(23,165)). +legacyConfig(personTOthing(24,166)). +legacyConfig(personTOthing(24,167)). +legacyConfig(personTOthing(24,168)). +legacyConfig(personTOthing(24,169)). +legacyConfig(personTOthing(24,170)). +legacyConfig(personTOthing(25,171)). +legacyConfig(personTOthing(25,172)). +legacyConfig(personTOthing(25,173)). +legacyConfig(personTOthing(25,174)). +legacyConfig(personTOthing(25,175)). +legacyConfig(personTOthing(26,176)). +legacyConfig(personTOthing(26,177)). +legacyConfig(personTOthing(26,178)). +legacyConfig(personTOthing(26,179)). +legacyConfig(personTOthing(26,180)). +legacyConfig(personTOthing(27,181)). +legacyConfig(personTOthing(27,182)). +legacyConfig(personTOthing(27,183)). +legacyConfig(personTOthing(27,184)). +legacyConfig(personTOthing(27,185)). +legacyConfig(personTOthing(28,186)). +legacyConfig(personTOthing(28,187)). +legacyConfig(personTOthing(28,188)). +legacyConfig(personTOthing(28,189)). +legacyConfig(personTOthing(28,190)). +legacyConfig(personTOthing(29,191)). +legacyConfig(personTOthing(29,192)). +legacyConfig(personTOthing(29,193)). +legacyConfig(personTOthing(29,194)). +legacyConfig(personTOthing(29,195)). +legacyConfig(personTOthing(30,196)). +legacyConfig(personTOthing(30,197)). +legacyConfig(personTOthing(30,198)). +legacyConfig(personTOthing(30,199)). +legacyConfig(personTOthing(30,200)). +legacyConfig(personTOthing(31,201)). +legacyConfig(personTOthing(31,202)). +legacyConfig(personTOthing(31,203)). +legacyConfig(personTOthing(31,204)). +legacyConfig(personTOthing(31,205)). +legacyConfig(personTOthing(32,206)). +legacyConfig(personTOthing(32,207)). +legacyConfig(personTOthing(32,208)). +legacyConfig(personTOthing(32,209)). +legacyConfig(personTOthing(32,210)). +legacyConfig(personTOthing(33,211)). +legacyConfig(personTOthing(33,212)). +legacyConfig(personTOthing(33,213)). +legacyConfig(personTOthing(33,214)). +legacyConfig(personTOthing(33,215)). +legacyConfig(personTOthing(34,216)). +legacyConfig(personTOthing(34,217)). +legacyConfig(personTOthing(34,218)). +legacyConfig(personTOthing(34,219)). +legacyConfig(personTOthing(34,220)). +legacyConfig(personTOthing(35,221)). +legacyConfig(personTOthing(35,222)). +legacyConfig(personTOthing(35,223)). +legacyConfig(personTOthing(35,224)). +legacyConfig(personTOthing(35,225)). +legacyConfig(personTOthing(36,226)). +legacyConfig(personTOthing(36,227)). +legacyConfig(personTOthing(36,228)). +legacyConfig(personTOthing(36,229)). +legacyConfig(personTOthing(36,230)). +legacyConfig(personTOthing(37,231)). +legacyConfig(personTOthing(37,232)). +legacyConfig(personTOthing(37,233)). +legacyConfig(personTOthing(37,234)). +legacyConfig(personTOthing(37,235)). +legacyConfig(personTOthing(38,236)). +legacyConfig(personTOthing(38,237)). +legacyConfig(personTOthing(38,238)). +legacyConfig(personTOthing(38,239)). +legacyConfig(personTOthing(38,240)). +legacyConfig(personTOthing(39,241)). +legacyConfig(personTOthing(39,242)). +legacyConfig(personTOthing(39,243)). +legacyConfig(personTOthing(39,244)). +legacyConfig(personTOthing(39,245)). +legacyConfig(personTOthing(40,246)). +legacyConfig(personTOthing(40,247)). +legacyConfig(personTOthing(40,248)). +legacyConfig(personTOthing(40,249)). +legacyConfig(personTOthing(40,250)). +legacyConfig(personTOthing(41,251)). +legacyConfig(personTOthing(41,252)). +legacyConfig(personTOthing(41,253)). +legacyConfig(personTOthing(41,254)). +legacyConfig(personTOthing(41,255)). +legacyConfig(personTOthing(42,256)). +legacyConfig(personTOthing(42,257)). +legacyConfig(personTOthing(42,258)). +legacyConfig(personTOthing(42,259)). +legacyConfig(personTOthing(42,260)). +legacyConfig(personTOthing(43,261)). +legacyConfig(personTOthing(43,262)). +legacyConfig(personTOthing(43,263)). +legacyConfig(personTOthing(43,264)). +legacyConfig(personTOthing(43,265)). +legacyConfig(personTOthing(44,266)). +legacyConfig(personTOthing(44,267)). +legacyConfig(personTOthing(44,268)). +legacyConfig(personTOthing(44,269)). +legacyConfig(personTOthing(44,270)). +legacyConfig(personTOthing(45,271)). +legacyConfig(personTOthing(45,272)). +legacyConfig(personTOthing(45,273)). +legacyConfig(personTOthing(45,274)). +legacyConfig(personTOthing(45,275)). +legacyConfig(personTOthing(46,276)). +legacyConfig(personTOthing(46,277)). +legacyConfig(personTOthing(46,278)). +legacyConfig(personTOthing(46,279)). +legacyConfig(personTOthing(46,280)). +legacyConfig(personTOthing(47,281)). +legacyConfig(personTOthing(47,282)). +legacyConfig(personTOthing(47,283)). +legacyConfig(personTOthing(47,284)). +legacyConfig(personTOthing(47,285)). +legacyConfig(personTOthing(48,286)). +legacyConfig(personTOthing(48,287)). +legacyConfig(personTOthing(48,288)). +legacyConfig(personTOthing(48,289)). +legacyConfig(personTOthing(48,290)). +legacyConfig(personTOthing(49,291)). +legacyConfig(personTOthing(49,292)). +legacyConfig(personTOthing(49,293)). +legacyConfig(personTOthing(49,294)). +legacyConfig(personTOthing(49,295)). +legacyConfig(personTOthing(50,296)). +legacyConfig(personTOthing(50,297)). +legacyConfig(personTOthing(50,298)). +legacyConfig(personTOthing(50,299)). +legacyConfig(personTOthing(50,300)). +% domains +cabinetDomainNew(500..749). +roomDomainNew(1000..1249). +cabinetUpper(250). +roomUpper(250). +cabinetLower(50). +roomLower(13). +% reuse costs +reuseCabinetTOthingCost(0). +reuseRoomTOcabinetCost(0). +reusePersonTOroomCost(0). +reuseCabinetAsHighCost(3). +reuseCabinetAsSmallCost(0). +reuseRoomCost(0). +% remove costs +removeCabinetTOthingCost(2). +removeRoomTOcabinetCost(2). +removePersonTOroomCost(2). +removeCabinetCost(2). +removeRoomCost(2). +% create costs +cabinetHighCost(100). +cabinetSmallCost(1). +roomCost(5). diff --git a/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p55t275.edb b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p55t275.edb new file mode 100644 index 000000000..3ec0e9448 --- /dev/null +++ b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p55t275.edb @@ -0,0 +1,904 @@ +legacyConfig(person(1)). +legacyConfig(person(2)). +legacyConfig(person(3)). +legacyConfig(person(4)). +legacyConfig(person(5)). +legacyConfig(person(6)). +legacyConfig(person(7)). +legacyConfig(person(8)). +legacyConfig(person(9)). +legacyConfig(person(10)). +legacyConfig(person(11)). +legacyConfig(person(12)). +legacyConfig(person(13)). +legacyConfig(person(14)). +legacyConfig(person(15)). +legacyConfig(person(16)). +legacyConfig(person(17)). +legacyConfig(person(18)). +legacyConfig(person(19)). +legacyConfig(person(20)). +legacyConfig(person(21)). +legacyConfig(person(22)). +legacyConfig(person(23)). +legacyConfig(person(24)). +legacyConfig(person(25)). +legacyConfig(person(26)). +legacyConfig(person(27)). +legacyConfig(person(28)). +legacyConfig(person(29)). +legacyConfig(person(30)). +legacyConfig(person(31)). +legacyConfig(person(32)). +legacyConfig(person(33)). +legacyConfig(person(34)). +legacyConfig(person(35)). +legacyConfig(person(36)). +legacyConfig(person(37)). +legacyConfig(person(38)). +legacyConfig(person(39)). +legacyConfig(person(40)). +legacyConfig(person(41)). +legacyConfig(person(42)). +legacyConfig(person(43)). +legacyConfig(person(44)). +legacyConfig(person(45)). +legacyConfig(person(46)). +legacyConfig(person(47)). +legacyConfig(person(48)). +legacyConfig(person(49)). +legacyConfig(person(50)). +legacyConfig(person(51)). +legacyConfig(person(52)). +legacyConfig(person(53)). +legacyConfig(person(54)). +legacyConfig(person(55)). +legacyConfig(thing(56)). +thingShort(56). +legacyConfig(thing(57)). +thingShort(57). +legacyConfig(thing(58)). +thingShort(58). +legacyConfig(thing(59)). +thingShort(59). +legacyConfig(thing(60)). +thingShort(60). +legacyConfig(thing(61)). +thingShort(61). +legacyConfig(thing(62)). +thingShort(62). +legacyConfig(thing(63)). +thingShort(63). +legacyConfig(thing(64)). +thingShort(64). +legacyConfig(thing(65)). +thingShort(65). +legacyConfig(thing(66)). +thingShort(66). +legacyConfig(thing(67)). +thingShort(67). +legacyConfig(thing(68)). +thingShort(68). +legacyConfig(thing(69)). +thingShort(69). +legacyConfig(thing(70)). +thingShort(70). +legacyConfig(thing(71)). +thingShort(71). +legacyConfig(thing(72)). +thingShort(72). +legacyConfig(thing(73)). +thingShort(73). +legacyConfig(thing(74)). +thingShort(74). +legacyConfig(thing(75)). +thingShort(75). +legacyConfig(thing(76)). +thingShort(76). +legacyConfig(thing(77)). +thingShort(77). +legacyConfig(thing(78)). +thingShort(78). +legacyConfig(thing(79)). +thingShort(79). +legacyConfig(thing(80)). +thingShort(80). +legacyConfig(thing(81)). +thingShort(81). +legacyConfig(thing(82)). +thingShort(82). +legacyConfig(thing(83)). +thingShort(83). +legacyConfig(thing(84)). +thingShort(84). +legacyConfig(thing(85)). +thingShort(85). +legacyConfig(thing(86)). +thingShort(86). +legacyConfig(thing(87)). +thingShort(87). +legacyConfig(thing(88)). +thingShort(88). +legacyConfig(thing(89)). +thingShort(89). +legacyConfig(thing(90)). +thingShort(90). +legacyConfig(thing(91)). +thingShort(91). +legacyConfig(thing(92)). +thingShort(92). +legacyConfig(thing(93)). +thingShort(93). +legacyConfig(thing(94)). +thingShort(94). +legacyConfig(thing(95)). +thingShort(95). +legacyConfig(thing(96)). +thingShort(96). +legacyConfig(thing(97)). +thingShort(97). +legacyConfig(thing(98)). +thingShort(98). +legacyConfig(thing(99)). +thingShort(99). +legacyConfig(thing(100)). +thingShort(100). +legacyConfig(thing(101)). +thingShort(101). +legacyConfig(thing(102)). +thingShort(102). +legacyConfig(thing(103)). +thingShort(103). +legacyConfig(thing(104)). +thingShort(104). +legacyConfig(thing(105)). +thingShort(105). +legacyConfig(thing(106)). +thingShort(106). +legacyConfig(thing(107)). +thingShort(107). +legacyConfig(thing(108)). +thingShort(108). +legacyConfig(thing(109)). +thingShort(109). +legacyConfig(thing(110)). +thingShort(110). +legacyConfig(thing(111)). +thingShort(111). +legacyConfig(thing(112)). +thingShort(112). +legacyConfig(thing(113)). +thingShort(113). +legacyConfig(thing(114)). +thingShort(114). +legacyConfig(thing(115)). +thingShort(115). +legacyConfig(thing(116)). +thingShort(116). +legacyConfig(thing(117)). +thingShort(117). +legacyConfig(thing(118)). +thingShort(118). +legacyConfig(thing(119)). +thingShort(119). +legacyConfig(thing(120)). +thingShort(120). +legacyConfig(thing(121)). +thingShort(121). +legacyConfig(thing(122)). +thingShort(122). +legacyConfig(thing(123)). +thingShort(123). +legacyConfig(thing(124)). +thingShort(124). +legacyConfig(thing(125)). +thingShort(125). +legacyConfig(thing(126)). +thingShort(126). +legacyConfig(thing(127)). +thingShort(127). +legacyConfig(thing(128)). +thingShort(128). +legacyConfig(thing(129)). +thingShort(129). +legacyConfig(thing(130)). +thingShort(130). +legacyConfig(thing(131)). +thingShort(131). +legacyConfig(thing(132)). +thingShort(132). +legacyConfig(thing(133)). +thingShort(133). +legacyConfig(thing(134)). +thingShort(134). +legacyConfig(thing(135)). +thingShort(135). +legacyConfig(thing(136)). +thingShort(136). +legacyConfig(thing(137)). +thingShort(137). +legacyConfig(thing(138)). +thingShort(138). +legacyConfig(thing(139)). +thingShort(139). +legacyConfig(thing(140)). +thingShort(140). +legacyConfig(thing(141)). +thingShort(141). +legacyConfig(thing(142)). +thingShort(142). +legacyConfig(thing(143)). +thingShort(143). +legacyConfig(thing(144)). +thingShort(144). +legacyConfig(thing(145)). +thingShort(145). +legacyConfig(thing(146)). +thingShort(146). +legacyConfig(thing(147)). +thingShort(147). +legacyConfig(thing(148)). +thingShort(148). +legacyConfig(thing(149)). +thingShort(149). +legacyConfig(thing(150)). +thingShort(150). +legacyConfig(thing(151)). +thingShort(151). +legacyConfig(thing(152)). +thingShort(152). +legacyConfig(thing(153)). +thingShort(153). +legacyConfig(thing(154)). +thingShort(154). +legacyConfig(thing(155)). +thingShort(155). +legacyConfig(thing(156)). +thingShort(156). +legacyConfig(thing(157)). +thingShort(157). +legacyConfig(thing(158)). +thingShort(158). +legacyConfig(thing(159)). +thingShort(159). +legacyConfig(thing(160)). +thingShort(160). +legacyConfig(thing(161)). +thingShort(161). +legacyConfig(thing(162)). +thingShort(162). +legacyConfig(thing(163)). +thingShort(163). +legacyConfig(thing(164)). +thingShort(164). +legacyConfig(thing(165)). +thingShort(165). +legacyConfig(thing(166)). +thingShort(166). +legacyConfig(thing(167)). +thingShort(167). +legacyConfig(thing(168)). +thingShort(168). +legacyConfig(thing(169)). +thingShort(169). +legacyConfig(thing(170)). +thingShort(170). +legacyConfig(thing(171)). +thingShort(171). +legacyConfig(thing(172)). +thingShort(172). +legacyConfig(thing(173)). +thingShort(173). +legacyConfig(thing(174)). +thingShort(174). +legacyConfig(thing(175)). +thingShort(175). +legacyConfig(thing(176)). +thingShort(176). +legacyConfig(thing(177)). +thingShort(177). +legacyConfig(thing(178)). +thingShort(178). +legacyConfig(thing(179)). +thingShort(179). +legacyConfig(thing(180)). +thingShort(180). +legacyConfig(thing(181)). +thingShort(181). +legacyConfig(thing(182)). +thingShort(182). +legacyConfig(thing(183)). +thingShort(183). +legacyConfig(thing(184)). +thingShort(184). +legacyConfig(thing(185)). +thingShort(185). +legacyConfig(thing(186)). +thingShort(186). +legacyConfig(thing(187)). +thingShort(187). +legacyConfig(thing(188)). +thingShort(188). +legacyConfig(thing(189)). +thingShort(189). +legacyConfig(thing(190)). +thingShort(190). +legacyConfig(thing(191)). +thingShort(191). +legacyConfig(thing(192)). +thingShort(192). +legacyConfig(thing(193)). +thingShort(193). +legacyConfig(thing(194)). +thingShort(194). +legacyConfig(thing(195)). +thingShort(195). +legacyConfig(thing(196)). +thingShort(196). +legacyConfig(thing(197)). +thingShort(197). +legacyConfig(thing(198)). +thingShort(198). +legacyConfig(thing(199)). +thingShort(199). +legacyConfig(thing(200)). +thingShort(200). +legacyConfig(thing(201)). +thingShort(201). +legacyConfig(thing(202)). +thingShort(202). +legacyConfig(thing(203)). +thingShort(203). +legacyConfig(thing(204)). +thingShort(204). +legacyConfig(thing(205)). +thingShort(205). +legacyConfig(thing(206)). +thingShort(206). +legacyConfig(thing(207)). +thingShort(207). +legacyConfig(thing(208)). +thingShort(208). +legacyConfig(thing(209)). +thingShort(209). +legacyConfig(thing(210)). +thingShort(210). +legacyConfig(thing(211)). +thingShort(211). +legacyConfig(thing(212)). +thingShort(212). +legacyConfig(thing(213)). +thingShort(213). +legacyConfig(thing(214)). +thingShort(214). +legacyConfig(thing(215)). +thingShort(215). +legacyConfig(thing(216)). +thingShort(216). +legacyConfig(thing(217)). +thingShort(217). +legacyConfig(thing(218)). +thingShort(218). +legacyConfig(thing(219)). +thingShort(219). +legacyConfig(thing(220)). +thingShort(220). +legacyConfig(thing(221)). +thingShort(221). +legacyConfig(thing(222)). +thingShort(222). +legacyConfig(thing(223)). +thingShort(223). +legacyConfig(thing(224)). +thingShort(224). +legacyConfig(thing(225)). +thingShort(225). +legacyConfig(thing(226)). +thingShort(226). +legacyConfig(thing(227)). +thingShort(227). +legacyConfig(thing(228)). +thingShort(228). +legacyConfig(thing(229)). +thingShort(229). +legacyConfig(thing(230)). +thingShort(230). +legacyConfig(thing(231)). +thingShort(231). +legacyConfig(thing(232)). +thingShort(232). +legacyConfig(thing(233)). +thingShort(233). +legacyConfig(thing(234)). +thingShort(234). +legacyConfig(thing(235)). +thingShort(235). +legacyConfig(thing(236)). +thingShort(236). +legacyConfig(thing(237)). +thingShort(237). +legacyConfig(thing(238)). +thingShort(238). +legacyConfig(thing(239)). +thingShort(239). +legacyConfig(thing(240)). +thingShort(240). +legacyConfig(thing(241)). +thingShort(241). +legacyConfig(thing(242)). +thingShort(242). +legacyConfig(thing(243)). +thingShort(243). +legacyConfig(thing(244)). +thingShort(244). +legacyConfig(thing(245)). +thingShort(245). +legacyConfig(thing(246)). +thingShort(246). +legacyConfig(thing(247)). +thingShort(247). +legacyConfig(thing(248)). +thingShort(248). +legacyConfig(thing(249)). +thingShort(249). +legacyConfig(thing(250)). +thingShort(250). +legacyConfig(thing(251)). +thingShort(251). +legacyConfig(thing(252)). +thingShort(252). +legacyConfig(thing(253)). +thingShort(253). +legacyConfig(thing(254)). +thingShort(254). +legacyConfig(thing(255)). +thingShort(255). +legacyConfig(thing(256)). +thingShort(256). +legacyConfig(thing(257)). +thingShort(257). +legacyConfig(thing(258)). +thingShort(258). +legacyConfig(thing(259)). +thingShort(259). +legacyConfig(thing(260)). +thingShort(260). +legacyConfig(thing(261)). +thingShort(261). +legacyConfig(thing(262)). +thingShort(262). +legacyConfig(thing(263)). +thingShort(263). +legacyConfig(thing(264)). +thingShort(264). +legacyConfig(thing(265)). +thingShort(265). +legacyConfig(thing(266)). +thingShort(266). +legacyConfig(thing(267)). +thingShort(267). +legacyConfig(thing(268)). +thingShort(268). +legacyConfig(thing(269)). +thingShort(269). +legacyConfig(thing(270)). +thingShort(270). +legacyConfig(thing(271)). +thingShort(271). +legacyConfig(thing(272)). +thingShort(272). +legacyConfig(thing(273)). +thingShort(273). +legacyConfig(thing(274)). +thingShort(274). +legacyConfig(thing(275)). +thingShort(275). +legacyConfig(thing(276)). +thingShort(276). +legacyConfig(thing(277)). +thingShort(277). +legacyConfig(thing(278)). +thingShort(278). +legacyConfig(thing(279)). +thingShort(279). +legacyConfig(thing(280)). +thingShort(280). +legacyConfig(thing(281)). +thingShort(281). +legacyConfig(thing(282)). +thingShort(282). +legacyConfig(thing(283)). +thingShort(283). +legacyConfig(thing(284)). +thingShort(284). +legacyConfig(thing(285)). +thingShort(285). +legacyConfig(thing(286)). +thingShort(286). +legacyConfig(thing(287)). +thingShort(287). +legacyConfig(thing(288)). +thingShort(288). +legacyConfig(thing(289)). +thingShort(289). +legacyConfig(thing(290)). +thingShort(290). +legacyConfig(thing(291)). +thingShort(291). +legacyConfig(thing(292)). +thingShort(292). +legacyConfig(thing(293)). +thingShort(293). +legacyConfig(thing(294)). +thingShort(294). +legacyConfig(thing(295)). +thingShort(295). +legacyConfig(thing(296)). +thingShort(296). +legacyConfig(thing(297)). +thingShort(297). +legacyConfig(thing(298)). +thingShort(298). +legacyConfig(thing(299)). +thingShort(299). +legacyConfig(thing(300)). +thingShort(300). +legacyConfig(thing(301)). +thingShort(301). +legacyConfig(thing(302)). +thingShort(302). +legacyConfig(thing(303)). +thingShort(303). +legacyConfig(thing(304)). +thingShort(304). +legacyConfig(thing(305)). +thingShort(305). +legacyConfig(thing(306)). +thingShort(306). +legacyConfig(thing(307)). +thingShort(307). +legacyConfig(thing(308)). +thingShort(308). +legacyConfig(thing(309)). +thingShort(309). +legacyConfig(thing(310)). +thingShort(310). +legacyConfig(thing(311)). +thingShort(311). +legacyConfig(thing(312)). +thingShort(312). +legacyConfig(thing(313)). +thingShort(313). +legacyConfig(thing(314)). +thingShort(314). +legacyConfig(thing(315)). +thingShort(315). +legacyConfig(thing(316)). +thingShort(316). +legacyConfig(thing(317)). +thingShort(317). +legacyConfig(thing(318)). +thingShort(318). +legacyConfig(thing(319)). +thingShort(319). +legacyConfig(thing(320)). +thingShort(320). +legacyConfig(thing(321)). +thingShort(321). +legacyConfig(thing(322)). +thingShort(322). +legacyConfig(thing(323)). +thingShort(323). +legacyConfig(thing(324)). +thingShort(324). +legacyConfig(thing(325)). +thingShort(325). +legacyConfig(thing(326)). +thingShort(326). +legacyConfig(thing(327)). +thingShort(327). +legacyConfig(thing(328)). +thingShort(328). +legacyConfig(thing(329)). +thingShort(329). +legacyConfig(thing(330)). +thingShort(330). +legacyConfig(personTOthing(1,56)). +legacyConfig(personTOthing(1,57)). +legacyConfig(personTOthing(1,58)). +legacyConfig(personTOthing(1,59)). +legacyConfig(personTOthing(1,60)). +legacyConfig(personTOthing(2,61)). +legacyConfig(personTOthing(2,62)). +legacyConfig(personTOthing(2,63)). +legacyConfig(personTOthing(2,64)). +legacyConfig(personTOthing(2,65)). +legacyConfig(personTOthing(3,66)). +legacyConfig(personTOthing(3,67)). +legacyConfig(personTOthing(3,68)). +legacyConfig(personTOthing(3,69)). +legacyConfig(personTOthing(3,70)). +legacyConfig(personTOthing(4,71)). +legacyConfig(personTOthing(4,72)). +legacyConfig(personTOthing(4,73)). +legacyConfig(personTOthing(4,74)). +legacyConfig(personTOthing(4,75)). +legacyConfig(personTOthing(5,76)). +legacyConfig(personTOthing(5,77)). +legacyConfig(personTOthing(5,78)). +legacyConfig(personTOthing(5,79)). +legacyConfig(personTOthing(5,80)). +legacyConfig(personTOthing(6,81)). +legacyConfig(personTOthing(6,82)). +legacyConfig(personTOthing(6,83)). +legacyConfig(personTOthing(6,84)). +legacyConfig(personTOthing(6,85)). +legacyConfig(personTOthing(7,86)). +legacyConfig(personTOthing(7,87)). +legacyConfig(personTOthing(7,88)). +legacyConfig(personTOthing(7,89)). +legacyConfig(personTOthing(7,90)). +legacyConfig(personTOthing(8,91)). +legacyConfig(personTOthing(8,92)). +legacyConfig(personTOthing(8,93)). +legacyConfig(personTOthing(8,94)). +legacyConfig(personTOthing(8,95)). +legacyConfig(personTOthing(9,96)). +legacyConfig(personTOthing(9,97)). +legacyConfig(personTOthing(9,98)). +legacyConfig(personTOthing(9,99)). +legacyConfig(personTOthing(9,100)). +legacyConfig(personTOthing(10,101)). +legacyConfig(personTOthing(10,102)). +legacyConfig(personTOthing(10,103)). +legacyConfig(personTOthing(10,104)). +legacyConfig(personTOthing(10,105)). +legacyConfig(personTOthing(11,106)). +legacyConfig(personTOthing(11,107)). +legacyConfig(personTOthing(11,108)). +legacyConfig(personTOthing(11,109)). +legacyConfig(personTOthing(11,110)). +legacyConfig(personTOthing(12,111)). +legacyConfig(personTOthing(12,112)). +legacyConfig(personTOthing(12,113)). +legacyConfig(personTOthing(12,114)). +legacyConfig(personTOthing(12,115)). +legacyConfig(personTOthing(13,116)). +legacyConfig(personTOthing(13,117)). +legacyConfig(personTOthing(13,118)). +legacyConfig(personTOthing(13,119)). +legacyConfig(personTOthing(13,120)). +legacyConfig(personTOthing(14,121)). +legacyConfig(personTOthing(14,122)). +legacyConfig(personTOthing(14,123)). +legacyConfig(personTOthing(14,124)). +legacyConfig(personTOthing(14,125)). +legacyConfig(personTOthing(15,126)). +legacyConfig(personTOthing(15,127)). +legacyConfig(personTOthing(15,128)). +legacyConfig(personTOthing(15,129)). +legacyConfig(personTOthing(15,130)). +legacyConfig(personTOthing(16,131)). +legacyConfig(personTOthing(16,132)). +legacyConfig(personTOthing(16,133)). +legacyConfig(personTOthing(16,134)). +legacyConfig(personTOthing(16,135)). +legacyConfig(personTOthing(17,136)). +legacyConfig(personTOthing(17,137)). +legacyConfig(personTOthing(17,138)). +legacyConfig(personTOthing(17,139)). +legacyConfig(personTOthing(17,140)). +legacyConfig(personTOthing(18,141)). +legacyConfig(personTOthing(18,142)). +legacyConfig(personTOthing(18,143)). +legacyConfig(personTOthing(18,144)). +legacyConfig(personTOthing(18,145)). +legacyConfig(personTOthing(19,146)). +legacyConfig(personTOthing(19,147)). +legacyConfig(personTOthing(19,148)). +legacyConfig(personTOthing(19,149)). +legacyConfig(personTOthing(19,150)). +legacyConfig(personTOthing(20,151)). +legacyConfig(personTOthing(20,152)). +legacyConfig(personTOthing(20,153)). +legacyConfig(personTOthing(20,154)). +legacyConfig(personTOthing(20,155)). +legacyConfig(personTOthing(21,156)). +legacyConfig(personTOthing(21,157)). +legacyConfig(personTOthing(21,158)). +legacyConfig(personTOthing(21,159)). +legacyConfig(personTOthing(21,160)). +legacyConfig(personTOthing(22,161)). +legacyConfig(personTOthing(22,162)). +legacyConfig(personTOthing(22,163)). +legacyConfig(personTOthing(22,164)). +legacyConfig(personTOthing(22,165)). +legacyConfig(personTOthing(23,166)). +legacyConfig(personTOthing(23,167)). +legacyConfig(personTOthing(23,168)). +legacyConfig(personTOthing(23,169)). +legacyConfig(personTOthing(23,170)). +legacyConfig(personTOthing(24,171)). +legacyConfig(personTOthing(24,172)). +legacyConfig(personTOthing(24,173)). +legacyConfig(personTOthing(24,174)). +legacyConfig(personTOthing(24,175)). +legacyConfig(personTOthing(25,176)). +legacyConfig(personTOthing(25,177)). +legacyConfig(personTOthing(25,178)). +legacyConfig(personTOthing(25,179)). +legacyConfig(personTOthing(25,180)). +legacyConfig(personTOthing(26,181)). +legacyConfig(personTOthing(26,182)). +legacyConfig(personTOthing(26,183)). +legacyConfig(personTOthing(26,184)). +legacyConfig(personTOthing(26,185)). +legacyConfig(personTOthing(27,186)). +legacyConfig(personTOthing(27,187)). +legacyConfig(personTOthing(27,188)). +legacyConfig(personTOthing(27,189)). +legacyConfig(personTOthing(27,190)). +legacyConfig(personTOthing(28,191)). +legacyConfig(personTOthing(28,192)). +legacyConfig(personTOthing(28,193)). +legacyConfig(personTOthing(28,194)). +legacyConfig(personTOthing(28,195)). +legacyConfig(personTOthing(29,196)). +legacyConfig(personTOthing(29,197)). +legacyConfig(personTOthing(29,198)). +legacyConfig(personTOthing(29,199)). +legacyConfig(personTOthing(29,200)). +legacyConfig(personTOthing(30,201)). +legacyConfig(personTOthing(30,202)). +legacyConfig(personTOthing(30,203)). +legacyConfig(personTOthing(30,204)). +legacyConfig(personTOthing(30,205)). +legacyConfig(personTOthing(31,206)). +legacyConfig(personTOthing(31,207)). +legacyConfig(personTOthing(31,208)). +legacyConfig(personTOthing(31,209)). +legacyConfig(personTOthing(31,210)). +legacyConfig(personTOthing(32,211)). +legacyConfig(personTOthing(32,212)). +legacyConfig(personTOthing(32,213)). +legacyConfig(personTOthing(32,214)). +legacyConfig(personTOthing(32,215)). +legacyConfig(personTOthing(33,216)). +legacyConfig(personTOthing(33,217)). +legacyConfig(personTOthing(33,218)). +legacyConfig(personTOthing(33,219)). +legacyConfig(personTOthing(33,220)). +legacyConfig(personTOthing(34,221)). +legacyConfig(personTOthing(34,222)). +legacyConfig(personTOthing(34,223)). +legacyConfig(personTOthing(34,224)). +legacyConfig(personTOthing(34,225)). +legacyConfig(personTOthing(35,226)). +legacyConfig(personTOthing(35,227)). +legacyConfig(personTOthing(35,228)). +legacyConfig(personTOthing(35,229)). +legacyConfig(personTOthing(35,230)). +legacyConfig(personTOthing(36,231)). +legacyConfig(personTOthing(36,232)). +legacyConfig(personTOthing(36,233)). +legacyConfig(personTOthing(36,234)). +legacyConfig(personTOthing(36,235)). +legacyConfig(personTOthing(37,236)). +legacyConfig(personTOthing(37,237)). +legacyConfig(personTOthing(37,238)). +legacyConfig(personTOthing(37,239)). +legacyConfig(personTOthing(37,240)). +legacyConfig(personTOthing(38,241)). +legacyConfig(personTOthing(38,242)). +legacyConfig(personTOthing(38,243)). +legacyConfig(personTOthing(38,244)). +legacyConfig(personTOthing(38,245)). +legacyConfig(personTOthing(39,246)). +legacyConfig(personTOthing(39,247)). +legacyConfig(personTOthing(39,248)). +legacyConfig(personTOthing(39,249)). +legacyConfig(personTOthing(39,250)). +legacyConfig(personTOthing(40,251)). +legacyConfig(personTOthing(40,252)). +legacyConfig(personTOthing(40,253)). +legacyConfig(personTOthing(40,254)). +legacyConfig(personTOthing(40,255)). +legacyConfig(personTOthing(41,256)). +legacyConfig(personTOthing(41,257)). +legacyConfig(personTOthing(41,258)). +legacyConfig(personTOthing(41,259)). +legacyConfig(personTOthing(41,260)). +legacyConfig(personTOthing(42,261)). +legacyConfig(personTOthing(42,262)). +legacyConfig(personTOthing(42,263)). +legacyConfig(personTOthing(42,264)). +legacyConfig(personTOthing(42,265)). +legacyConfig(personTOthing(43,266)). +legacyConfig(personTOthing(43,267)). +legacyConfig(personTOthing(43,268)). +legacyConfig(personTOthing(43,269)). +legacyConfig(personTOthing(43,270)). +legacyConfig(personTOthing(44,271)). +legacyConfig(personTOthing(44,272)). +legacyConfig(personTOthing(44,273)). +legacyConfig(personTOthing(44,274)). +legacyConfig(personTOthing(44,275)). +legacyConfig(personTOthing(45,276)). +legacyConfig(personTOthing(45,277)). +legacyConfig(personTOthing(45,278)). +legacyConfig(personTOthing(45,279)). +legacyConfig(personTOthing(45,280)). +legacyConfig(personTOthing(46,281)). +legacyConfig(personTOthing(46,282)). +legacyConfig(personTOthing(46,283)). +legacyConfig(personTOthing(46,284)). +legacyConfig(personTOthing(46,285)). +legacyConfig(personTOthing(47,286)). +legacyConfig(personTOthing(47,287)). +legacyConfig(personTOthing(47,288)). +legacyConfig(personTOthing(47,289)). +legacyConfig(personTOthing(47,290)). +legacyConfig(personTOthing(48,291)). +legacyConfig(personTOthing(48,292)). +legacyConfig(personTOthing(48,293)). +legacyConfig(personTOthing(48,294)). +legacyConfig(personTOthing(48,295)). +legacyConfig(personTOthing(49,296)). +legacyConfig(personTOthing(49,297)). +legacyConfig(personTOthing(49,298)). +legacyConfig(personTOthing(49,299)). +legacyConfig(personTOthing(49,300)). +legacyConfig(personTOthing(50,301)). +legacyConfig(personTOthing(50,302)). +legacyConfig(personTOthing(50,303)). +legacyConfig(personTOthing(50,304)). +legacyConfig(personTOthing(50,305)). +legacyConfig(personTOthing(51,306)). +legacyConfig(personTOthing(51,307)). +legacyConfig(personTOthing(51,308)). +legacyConfig(personTOthing(51,309)). +legacyConfig(personTOthing(51,310)). +legacyConfig(personTOthing(52,311)). +legacyConfig(personTOthing(52,312)). +legacyConfig(personTOthing(52,313)). +legacyConfig(personTOthing(52,314)). +legacyConfig(personTOthing(52,315)). +legacyConfig(personTOthing(53,316)). +legacyConfig(personTOthing(53,317)). +legacyConfig(personTOthing(53,318)). +legacyConfig(personTOthing(53,319)). +legacyConfig(personTOthing(53,320)). +legacyConfig(personTOthing(54,321)). +legacyConfig(personTOthing(54,322)). +legacyConfig(personTOthing(54,323)). +legacyConfig(personTOthing(54,324)). +legacyConfig(personTOthing(54,325)). +legacyConfig(personTOthing(55,326)). +legacyConfig(personTOthing(55,327)). +legacyConfig(personTOthing(55,328)). +legacyConfig(personTOthing(55,329)). +legacyConfig(personTOthing(55,330)). +% domains +cabinetDomainNew(500..774). +roomDomainNew(1000..1274). +cabinetUpper(275). +roomUpper(275). +cabinetLower(55). +roomLower(14). +% reuse costs +reuseCabinetTOthingCost(0). +reuseRoomTOcabinetCost(0). +reusePersonTOroomCost(0). +reuseCabinetAsHighCost(3). +reuseCabinetAsSmallCost(0). +reuseRoomCost(0). +% remove costs +removeCabinetTOthingCost(2). +removeRoomTOcabinetCost(2). +removePersonTOroomCost(2). +removeCabinetCost(2). +removeRoomCost(2). +% create costs +cabinetHighCost(100). +cabinetSmallCost(1). +roomCost(5). diff --git a/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p60t300.edb b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p60t300.edb new file mode 100644 index 000000000..f9bf9c03e --- /dev/null +++ b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p60t300.edb @@ -0,0 +1,984 @@ +legacyConfig(person(1)). +legacyConfig(person(2)). +legacyConfig(person(3)). +legacyConfig(person(4)). +legacyConfig(person(5)). +legacyConfig(person(6)). +legacyConfig(person(7)). +legacyConfig(person(8)). +legacyConfig(person(9)). +legacyConfig(person(10)). +legacyConfig(person(11)). +legacyConfig(person(12)). +legacyConfig(person(13)). +legacyConfig(person(14)). +legacyConfig(person(15)). +legacyConfig(person(16)). +legacyConfig(person(17)). +legacyConfig(person(18)). +legacyConfig(person(19)). +legacyConfig(person(20)). +legacyConfig(person(21)). +legacyConfig(person(22)). +legacyConfig(person(23)). +legacyConfig(person(24)). +legacyConfig(person(25)). +legacyConfig(person(26)). +legacyConfig(person(27)). +legacyConfig(person(28)). +legacyConfig(person(29)). +legacyConfig(person(30)). +legacyConfig(person(31)). +legacyConfig(person(32)). +legacyConfig(person(33)). +legacyConfig(person(34)). +legacyConfig(person(35)). +legacyConfig(person(36)). +legacyConfig(person(37)). +legacyConfig(person(38)). +legacyConfig(person(39)). +legacyConfig(person(40)). +legacyConfig(person(41)). +legacyConfig(person(42)). +legacyConfig(person(43)). +legacyConfig(person(44)). +legacyConfig(person(45)). +legacyConfig(person(46)). +legacyConfig(person(47)). +legacyConfig(person(48)). +legacyConfig(person(49)). +legacyConfig(person(50)). +legacyConfig(person(51)). +legacyConfig(person(52)). +legacyConfig(person(53)). +legacyConfig(person(54)). +legacyConfig(person(55)). +legacyConfig(person(56)). +legacyConfig(person(57)). +legacyConfig(person(58)). +legacyConfig(person(59)). +legacyConfig(person(60)). +legacyConfig(thing(61)). +thingShort(61). +legacyConfig(thing(62)). +thingShort(62). +legacyConfig(thing(63)). +thingShort(63). +legacyConfig(thing(64)). +thingShort(64). +legacyConfig(thing(65)). +thingShort(65). +legacyConfig(thing(66)). +thingShort(66). +legacyConfig(thing(67)). +thingShort(67). +legacyConfig(thing(68)). +thingShort(68). +legacyConfig(thing(69)). +thingShort(69). +legacyConfig(thing(70)). +thingShort(70). +legacyConfig(thing(71)). +thingShort(71). +legacyConfig(thing(72)). +thingShort(72). +legacyConfig(thing(73)). +thingShort(73). +legacyConfig(thing(74)). +thingShort(74). +legacyConfig(thing(75)). +thingShort(75). +legacyConfig(thing(76)). +thingShort(76). +legacyConfig(thing(77)). +thingShort(77). +legacyConfig(thing(78)). +thingShort(78). +legacyConfig(thing(79)). +thingShort(79). +legacyConfig(thing(80)). +thingShort(80). +legacyConfig(thing(81)). +thingShort(81). +legacyConfig(thing(82)). +thingShort(82). +legacyConfig(thing(83)). +thingShort(83). +legacyConfig(thing(84)). +thingShort(84). +legacyConfig(thing(85)). +thingShort(85). +legacyConfig(thing(86)). +thingShort(86). +legacyConfig(thing(87)). +thingShort(87). +legacyConfig(thing(88)). +thingShort(88). +legacyConfig(thing(89)). +thingShort(89). +legacyConfig(thing(90)). +thingShort(90). +legacyConfig(thing(91)). +thingShort(91). +legacyConfig(thing(92)). +thingShort(92). +legacyConfig(thing(93)). +thingShort(93). +legacyConfig(thing(94)). +thingShort(94). +legacyConfig(thing(95)). +thingShort(95). +legacyConfig(thing(96)). +thingShort(96). +legacyConfig(thing(97)). +thingShort(97). +legacyConfig(thing(98)). +thingShort(98). +legacyConfig(thing(99)). +thingShort(99). +legacyConfig(thing(100)). +thingShort(100). +legacyConfig(thing(101)). +thingShort(101). +legacyConfig(thing(102)). +thingShort(102). +legacyConfig(thing(103)). +thingShort(103). +legacyConfig(thing(104)). +thingShort(104). +legacyConfig(thing(105)). +thingShort(105). +legacyConfig(thing(106)). +thingShort(106). +legacyConfig(thing(107)). +thingShort(107). +legacyConfig(thing(108)). +thingShort(108). +legacyConfig(thing(109)). +thingShort(109). +legacyConfig(thing(110)). +thingShort(110). +legacyConfig(thing(111)). +thingShort(111). +legacyConfig(thing(112)). +thingShort(112). +legacyConfig(thing(113)). +thingShort(113). +legacyConfig(thing(114)). +thingShort(114). +legacyConfig(thing(115)). +thingShort(115). +legacyConfig(thing(116)). +thingShort(116). +legacyConfig(thing(117)). +thingShort(117). +legacyConfig(thing(118)). +thingShort(118). +legacyConfig(thing(119)). +thingShort(119). +legacyConfig(thing(120)). +thingShort(120). +legacyConfig(thing(121)). +thingShort(121). +legacyConfig(thing(122)). +thingShort(122). +legacyConfig(thing(123)). +thingShort(123). +legacyConfig(thing(124)). +thingShort(124). +legacyConfig(thing(125)). +thingShort(125). +legacyConfig(thing(126)). +thingShort(126). +legacyConfig(thing(127)). +thingShort(127). +legacyConfig(thing(128)). +thingShort(128). +legacyConfig(thing(129)). +thingShort(129). +legacyConfig(thing(130)). +thingShort(130). +legacyConfig(thing(131)). +thingShort(131). +legacyConfig(thing(132)). +thingShort(132). +legacyConfig(thing(133)). +thingShort(133). +legacyConfig(thing(134)). +thingShort(134). +legacyConfig(thing(135)). +thingShort(135). +legacyConfig(thing(136)). +thingShort(136). +legacyConfig(thing(137)). +thingShort(137). +legacyConfig(thing(138)). +thingShort(138). +legacyConfig(thing(139)). +thingShort(139). +legacyConfig(thing(140)). +thingShort(140). +legacyConfig(thing(141)). +thingShort(141). +legacyConfig(thing(142)). +thingShort(142). +legacyConfig(thing(143)). +thingShort(143). +legacyConfig(thing(144)). +thingShort(144). +legacyConfig(thing(145)). +thingShort(145). +legacyConfig(thing(146)). +thingShort(146). +legacyConfig(thing(147)). +thingShort(147). +legacyConfig(thing(148)). +thingShort(148). +legacyConfig(thing(149)). +thingShort(149). +legacyConfig(thing(150)). +thingShort(150). +legacyConfig(thing(151)). +thingShort(151). +legacyConfig(thing(152)). +thingShort(152). +legacyConfig(thing(153)). +thingShort(153). +legacyConfig(thing(154)). +thingShort(154). +legacyConfig(thing(155)). +thingShort(155). +legacyConfig(thing(156)). +thingShort(156). +legacyConfig(thing(157)). +thingShort(157). +legacyConfig(thing(158)). +thingShort(158). +legacyConfig(thing(159)). +thingShort(159). +legacyConfig(thing(160)). +thingShort(160). +legacyConfig(thing(161)). +thingShort(161). +legacyConfig(thing(162)). +thingShort(162). +legacyConfig(thing(163)). +thingShort(163). +legacyConfig(thing(164)). +thingShort(164). +legacyConfig(thing(165)). +thingShort(165). +legacyConfig(thing(166)). +thingShort(166). +legacyConfig(thing(167)). +thingShort(167). +legacyConfig(thing(168)). +thingShort(168). +legacyConfig(thing(169)). +thingShort(169). +legacyConfig(thing(170)). +thingShort(170). +legacyConfig(thing(171)). +thingShort(171). +legacyConfig(thing(172)). +thingShort(172). +legacyConfig(thing(173)). +thingShort(173). +legacyConfig(thing(174)). +thingShort(174). +legacyConfig(thing(175)). +thingShort(175). +legacyConfig(thing(176)). +thingShort(176). +legacyConfig(thing(177)). +thingShort(177). +legacyConfig(thing(178)). +thingShort(178). +legacyConfig(thing(179)). +thingShort(179). +legacyConfig(thing(180)). +thingShort(180). +legacyConfig(thing(181)). +thingShort(181). +legacyConfig(thing(182)). +thingShort(182). +legacyConfig(thing(183)). +thingShort(183). +legacyConfig(thing(184)). +thingShort(184). +legacyConfig(thing(185)). +thingShort(185). +legacyConfig(thing(186)). +thingShort(186). +legacyConfig(thing(187)). +thingShort(187). +legacyConfig(thing(188)). +thingShort(188). +legacyConfig(thing(189)). +thingShort(189). +legacyConfig(thing(190)). +thingShort(190). +legacyConfig(thing(191)). +thingShort(191). +legacyConfig(thing(192)). +thingShort(192). +legacyConfig(thing(193)). +thingShort(193). +legacyConfig(thing(194)). +thingShort(194). +legacyConfig(thing(195)). +thingShort(195). +legacyConfig(thing(196)). +thingShort(196). +legacyConfig(thing(197)). +thingShort(197). +legacyConfig(thing(198)). +thingShort(198). +legacyConfig(thing(199)). +thingShort(199). +legacyConfig(thing(200)). +thingShort(200). +legacyConfig(thing(201)). +thingShort(201). +legacyConfig(thing(202)). +thingShort(202). +legacyConfig(thing(203)). +thingShort(203). +legacyConfig(thing(204)). +thingShort(204). +legacyConfig(thing(205)). +thingShort(205). +legacyConfig(thing(206)). +thingShort(206). +legacyConfig(thing(207)). +thingShort(207). +legacyConfig(thing(208)). +thingShort(208). +legacyConfig(thing(209)). +thingShort(209). +legacyConfig(thing(210)). +thingShort(210). +legacyConfig(thing(211)). +thingShort(211). +legacyConfig(thing(212)). +thingShort(212). +legacyConfig(thing(213)). +thingShort(213). +legacyConfig(thing(214)). +thingShort(214). +legacyConfig(thing(215)). +thingShort(215). +legacyConfig(thing(216)). +thingShort(216). +legacyConfig(thing(217)). +thingShort(217). +legacyConfig(thing(218)). +thingShort(218). +legacyConfig(thing(219)). +thingShort(219). +legacyConfig(thing(220)). +thingShort(220). +legacyConfig(thing(221)). +thingShort(221). +legacyConfig(thing(222)). +thingShort(222). +legacyConfig(thing(223)). +thingShort(223). +legacyConfig(thing(224)). +thingShort(224). +legacyConfig(thing(225)). +thingShort(225). +legacyConfig(thing(226)). +thingShort(226). +legacyConfig(thing(227)). +thingShort(227). +legacyConfig(thing(228)). +thingShort(228). +legacyConfig(thing(229)). +thingShort(229). +legacyConfig(thing(230)). +thingShort(230). +legacyConfig(thing(231)). +thingShort(231). +legacyConfig(thing(232)). +thingShort(232). +legacyConfig(thing(233)). +thingShort(233). +legacyConfig(thing(234)). +thingShort(234). +legacyConfig(thing(235)). +thingShort(235). +legacyConfig(thing(236)). +thingShort(236). +legacyConfig(thing(237)). +thingShort(237). +legacyConfig(thing(238)). +thingShort(238). +legacyConfig(thing(239)). +thingShort(239). +legacyConfig(thing(240)). +thingShort(240). +legacyConfig(thing(241)). +thingShort(241). +legacyConfig(thing(242)). +thingShort(242). +legacyConfig(thing(243)). +thingShort(243). +legacyConfig(thing(244)). +thingShort(244). +legacyConfig(thing(245)). +thingShort(245). +legacyConfig(thing(246)). +thingShort(246). +legacyConfig(thing(247)). +thingShort(247). +legacyConfig(thing(248)). +thingShort(248). +legacyConfig(thing(249)). +thingShort(249). +legacyConfig(thing(250)). +thingShort(250). +legacyConfig(thing(251)). +thingShort(251). +legacyConfig(thing(252)). +thingShort(252). +legacyConfig(thing(253)). +thingShort(253). +legacyConfig(thing(254)). +thingShort(254). +legacyConfig(thing(255)). +thingShort(255). +legacyConfig(thing(256)). +thingShort(256). +legacyConfig(thing(257)). +thingShort(257). +legacyConfig(thing(258)). +thingShort(258). +legacyConfig(thing(259)). +thingShort(259). +legacyConfig(thing(260)). +thingShort(260). +legacyConfig(thing(261)). +thingShort(261). +legacyConfig(thing(262)). +thingShort(262). +legacyConfig(thing(263)). +thingShort(263). +legacyConfig(thing(264)). +thingShort(264). +legacyConfig(thing(265)). +thingShort(265). +legacyConfig(thing(266)). +thingShort(266). +legacyConfig(thing(267)). +thingShort(267). +legacyConfig(thing(268)). +thingShort(268). +legacyConfig(thing(269)). +thingShort(269). +legacyConfig(thing(270)). +thingShort(270). +legacyConfig(thing(271)). +thingShort(271). +legacyConfig(thing(272)). +thingShort(272). +legacyConfig(thing(273)). +thingShort(273). +legacyConfig(thing(274)). +thingShort(274). +legacyConfig(thing(275)). +thingShort(275). +legacyConfig(thing(276)). +thingShort(276). +legacyConfig(thing(277)). +thingShort(277). +legacyConfig(thing(278)). +thingShort(278). +legacyConfig(thing(279)). +thingShort(279). +legacyConfig(thing(280)). +thingShort(280). +legacyConfig(thing(281)). +thingShort(281). +legacyConfig(thing(282)). +thingShort(282). +legacyConfig(thing(283)). +thingShort(283). +legacyConfig(thing(284)). +thingShort(284). +legacyConfig(thing(285)). +thingShort(285). +legacyConfig(thing(286)). +thingShort(286). +legacyConfig(thing(287)). +thingShort(287). +legacyConfig(thing(288)). +thingShort(288). +legacyConfig(thing(289)). +thingShort(289). +legacyConfig(thing(290)). +thingShort(290). +legacyConfig(thing(291)). +thingShort(291). +legacyConfig(thing(292)). +thingShort(292). +legacyConfig(thing(293)). +thingShort(293). +legacyConfig(thing(294)). +thingShort(294). +legacyConfig(thing(295)). +thingShort(295). +legacyConfig(thing(296)). +thingShort(296). +legacyConfig(thing(297)). +thingShort(297). +legacyConfig(thing(298)). +thingShort(298). +legacyConfig(thing(299)). +thingShort(299). +legacyConfig(thing(300)). +thingShort(300). +legacyConfig(thing(301)). +thingShort(301). +legacyConfig(thing(302)). +thingShort(302). +legacyConfig(thing(303)). +thingShort(303). +legacyConfig(thing(304)). +thingShort(304). +legacyConfig(thing(305)). +thingShort(305). +legacyConfig(thing(306)). +thingShort(306). +legacyConfig(thing(307)). +thingShort(307). +legacyConfig(thing(308)). +thingShort(308). +legacyConfig(thing(309)). +thingShort(309). +legacyConfig(thing(310)). +thingShort(310). +legacyConfig(thing(311)). +thingShort(311). +legacyConfig(thing(312)). +thingShort(312). +legacyConfig(thing(313)). +thingShort(313). +legacyConfig(thing(314)). +thingShort(314). +legacyConfig(thing(315)). +thingShort(315). +legacyConfig(thing(316)). +thingShort(316). +legacyConfig(thing(317)). +thingShort(317). +legacyConfig(thing(318)). +thingShort(318). +legacyConfig(thing(319)). +thingShort(319). +legacyConfig(thing(320)). +thingShort(320). +legacyConfig(thing(321)). +thingShort(321). +legacyConfig(thing(322)). +thingShort(322). +legacyConfig(thing(323)). +thingShort(323). +legacyConfig(thing(324)). +thingShort(324). +legacyConfig(thing(325)). +thingShort(325). +legacyConfig(thing(326)). +thingShort(326). +legacyConfig(thing(327)). +thingShort(327). +legacyConfig(thing(328)). +thingShort(328). +legacyConfig(thing(329)). +thingShort(329). +legacyConfig(thing(330)). +thingShort(330). +legacyConfig(thing(331)). +thingShort(331). +legacyConfig(thing(332)). +thingShort(332). +legacyConfig(thing(333)). +thingShort(333). +legacyConfig(thing(334)). +thingShort(334). +legacyConfig(thing(335)). +thingShort(335). +legacyConfig(thing(336)). +thingShort(336). +legacyConfig(thing(337)). +thingShort(337). +legacyConfig(thing(338)). +thingShort(338). +legacyConfig(thing(339)). +thingShort(339). +legacyConfig(thing(340)). +thingShort(340). +legacyConfig(thing(341)). +thingShort(341). +legacyConfig(thing(342)). +thingShort(342). +legacyConfig(thing(343)). +thingShort(343). +legacyConfig(thing(344)). +thingShort(344). +legacyConfig(thing(345)). +thingShort(345). +legacyConfig(thing(346)). +thingShort(346). +legacyConfig(thing(347)). +thingShort(347). +legacyConfig(thing(348)). +thingShort(348). +legacyConfig(thing(349)). +thingShort(349). +legacyConfig(thing(350)). +thingShort(350). +legacyConfig(thing(351)). +thingShort(351). +legacyConfig(thing(352)). +thingShort(352). +legacyConfig(thing(353)). +thingShort(353). +legacyConfig(thing(354)). +thingShort(354). +legacyConfig(thing(355)). +thingShort(355). +legacyConfig(thing(356)). +thingShort(356). +legacyConfig(thing(357)). +thingShort(357). +legacyConfig(thing(358)). +thingShort(358). +legacyConfig(thing(359)). +thingShort(359). +legacyConfig(thing(360)). +thingShort(360). +legacyConfig(personTOthing(1,61)). +legacyConfig(personTOthing(1,62)). +legacyConfig(personTOthing(1,63)). +legacyConfig(personTOthing(1,64)). +legacyConfig(personTOthing(1,65)). +legacyConfig(personTOthing(2,66)). +legacyConfig(personTOthing(2,67)). +legacyConfig(personTOthing(2,68)). +legacyConfig(personTOthing(2,69)). +legacyConfig(personTOthing(2,70)). +legacyConfig(personTOthing(3,71)). +legacyConfig(personTOthing(3,72)). +legacyConfig(personTOthing(3,73)). +legacyConfig(personTOthing(3,74)). +legacyConfig(personTOthing(3,75)). +legacyConfig(personTOthing(4,76)). +legacyConfig(personTOthing(4,77)). +legacyConfig(personTOthing(4,78)). +legacyConfig(personTOthing(4,79)). +legacyConfig(personTOthing(4,80)). +legacyConfig(personTOthing(5,81)). +legacyConfig(personTOthing(5,82)). +legacyConfig(personTOthing(5,83)). +legacyConfig(personTOthing(5,84)). +legacyConfig(personTOthing(5,85)). +legacyConfig(personTOthing(6,86)). +legacyConfig(personTOthing(6,87)). +legacyConfig(personTOthing(6,88)). +legacyConfig(personTOthing(6,89)). +legacyConfig(personTOthing(6,90)). +legacyConfig(personTOthing(7,91)). +legacyConfig(personTOthing(7,92)). +legacyConfig(personTOthing(7,93)). +legacyConfig(personTOthing(7,94)). +legacyConfig(personTOthing(7,95)). +legacyConfig(personTOthing(8,96)). +legacyConfig(personTOthing(8,97)). +legacyConfig(personTOthing(8,98)). +legacyConfig(personTOthing(8,99)). +legacyConfig(personTOthing(8,100)). +legacyConfig(personTOthing(9,101)). +legacyConfig(personTOthing(9,102)). +legacyConfig(personTOthing(9,103)). +legacyConfig(personTOthing(9,104)). +legacyConfig(personTOthing(9,105)). +legacyConfig(personTOthing(10,106)). +legacyConfig(personTOthing(10,107)). +legacyConfig(personTOthing(10,108)). +legacyConfig(personTOthing(10,109)). +legacyConfig(personTOthing(10,110)). +legacyConfig(personTOthing(11,111)). +legacyConfig(personTOthing(11,112)). +legacyConfig(personTOthing(11,113)). +legacyConfig(personTOthing(11,114)). +legacyConfig(personTOthing(11,115)). +legacyConfig(personTOthing(12,116)). +legacyConfig(personTOthing(12,117)). +legacyConfig(personTOthing(12,118)). +legacyConfig(personTOthing(12,119)). +legacyConfig(personTOthing(12,120)). +legacyConfig(personTOthing(13,121)). +legacyConfig(personTOthing(13,122)). +legacyConfig(personTOthing(13,123)). +legacyConfig(personTOthing(13,124)). +legacyConfig(personTOthing(13,125)). +legacyConfig(personTOthing(14,126)). +legacyConfig(personTOthing(14,127)). +legacyConfig(personTOthing(14,128)). +legacyConfig(personTOthing(14,129)). +legacyConfig(personTOthing(14,130)). +legacyConfig(personTOthing(15,131)). +legacyConfig(personTOthing(15,132)). +legacyConfig(personTOthing(15,133)). +legacyConfig(personTOthing(15,134)). +legacyConfig(personTOthing(15,135)). +legacyConfig(personTOthing(16,136)). +legacyConfig(personTOthing(16,137)). +legacyConfig(personTOthing(16,138)). +legacyConfig(personTOthing(16,139)). +legacyConfig(personTOthing(16,140)). +legacyConfig(personTOthing(17,141)). +legacyConfig(personTOthing(17,142)). +legacyConfig(personTOthing(17,143)). +legacyConfig(personTOthing(17,144)). +legacyConfig(personTOthing(17,145)). +legacyConfig(personTOthing(18,146)). +legacyConfig(personTOthing(18,147)). +legacyConfig(personTOthing(18,148)). +legacyConfig(personTOthing(18,149)). +legacyConfig(personTOthing(18,150)). +legacyConfig(personTOthing(19,151)). +legacyConfig(personTOthing(19,152)). +legacyConfig(personTOthing(19,153)). +legacyConfig(personTOthing(19,154)). +legacyConfig(personTOthing(19,155)). +legacyConfig(personTOthing(20,156)). +legacyConfig(personTOthing(20,157)). +legacyConfig(personTOthing(20,158)). +legacyConfig(personTOthing(20,159)). +legacyConfig(personTOthing(20,160)). +legacyConfig(personTOthing(21,161)). +legacyConfig(personTOthing(21,162)). +legacyConfig(personTOthing(21,163)). +legacyConfig(personTOthing(21,164)). +legacyConfig(personTOthing(21,165)). +legacyConfig(personTOthing(22,166)). +legacyConfig(personTOthing(22,167)). +legacyConfig(personTOthing(22,168)). +legacyConfig(personTOthing(22,169)). +legacyConfig(personTOthing(22,170)). +legacyConfig(personTOthing(23,171)). +legacyConfig(personTOthing(23,172)). +legacyConfig(personTOthing(23,173)). +legacyConfig(personTOthing(23,174)). +legacyConfig(personTOthing(23,175)). +legacyConfig(personTOthing(24,176)). +legacyConfig(personTOthing(24,177)). +legacyConfig(personTOthing(24,178)). +legacyConfig(personTOthing(24,179)). +legacyConfig(personTOthing(24,180)). +legacyConfig(personTOthing(25,181)). +legacyConfig(personTOthing(25,182)). +legacyConfig(personTOthing(25,183)). +legacyConfig(personTOthing(25,184)). +legacyConfig(personTOthing(25,185)). +legacyConfig(personTOthing(26,186)). +legacyConfig(personTOthing(26,187)). +legacyConfig(personTOthing(26,188)). +legacyConfig(personTOthing(26,189)). +legacyConfig(personTOthing(26,190)). +legacyConfig(personTOthing(27,191)). +legacyConfig(personTOthing(27,192)). +legacyConfig(personTOthing(27,193)). +legacyConfig(personTOthing(27,194)). +legacyConfig(personTOthing(27,195)). +legacyConfig(personTOthing(28,196)). +legacyConfig(personTOthing(28,197)). +legacyConfig(personTOthing(28,198)). +legacyConfig(personTOthing(28,199)). +legacyConfig(personTOthing(28,200)). +legacyConfig(personTOthing(29,201)). +legacyConfig(personTOthing(29,202)). +legacyConfig(personTOthing(29,203)). +legacyConfig(personTOthing(29,204)). +legacyConfig(personTOthing(29,205)). +legacyConfig(personTOthing(30,206)). +legacyConfig(personTOthing(30,207)). +legacyConfig(personTOthing(30,208)). +legacyConfig(personTOthing(30,209)). +legacyConfig(personTOthing(30,210)). +legacyConfig(personTOthing(31,211)). +legacyConfig(personTOthing(31,212)). +legacyConfig(personTOthing(31,213)). +legacyConfig(personTOthing(31,214)). +legacyConfig(personTOthing(31,215)). +legacyConfig(personTOthing(32,216)). +legacyConfig(personTOthing(32,217)). +legacyConfig(personTOthing(32,218)). +legacyConfig(personTOthing(32,219)). +legacyConfig(personTOthing(32,220)). +legacyConfig(personTOthing(33,221)). +legacyConfig(personTOthing(33,222)). +legacyConfig(personTOthing(33,223)). +legacyConfig(personTOthing(33,224)). +legacyConfig(personTOthing(33,225)). +legacyConfig(personTOthing(34,226)). +legacyConfig(personTOthing(34,227)). +legacyConfig(personTOthing(34,228)). +legacyConfig(personTOthing(34,229)). +legacyConfig(personTOthing(34,230)). +legacyConfig(personTOthing(35,231)). +legacyConfig(personTOthing(35,232)). +legacyConfig(personTOthing(35,233)). +legacyConfig(personTOthing(35,234)). +legacyConfig(personTOthing(35,235)). +legacyConfig(personTOthing(36,236)). +legacyConfig(personTOthing(36,237)). +legacyConfig(personTOthing(36,238)). +legacyConfig(personTOthing(36,239)). +legacyConfig(personTOthing(36,240)). +legacyConfig(personTOthing(37,241)). +legacyConfig(personTOthing(37,242)). +legacyConfig(personTOthing(37,243)). +legacyConfig(personTOthing(37,244)). +legacyConfig(personTOthing(37,245)). +legacyConfig(personTOthing(38,246)). +legacyConfig(personTOthing(38,247)). +legacyConfig(personTOthing(38,248)). +legacyConfig(personTOthing(38,249)). +legacyConfig(personTOthing(38,250)). +legacyConfig(personTOthing(39,251)). +legacyConfig(personTOthing(39,252)). +legacyConfig(personTOthing(39,253)). +legacyConfig(personTOthing(39,254)). +legacyConfig(personTOthing(39,255)). +legacyConfig(personTOthing(40,256)). +legacyConfig(personTOthing(40,257)). +legacyConfig(personTOthing(40,258)). +legacyConfig(personTOthing(40,259)). +legacyConfig(personTOthing(40,260)). +legacyConfig(personTOthing(41,261)). +legacyConfig(personTOthing(41,262)). +legacyConfig(personTOthing(41,263)). +legacyConfig(personTOthing(41,264)). +legacyConfig(personTOthing(41,265)). +legacyConfig(personTOthing(42,266)). +legacyConfig(personTOthing(42,267)). +legacyConfig(personTOthing(42,268)). +legacyConfig(personTOthing(42,269)). +legacyConfig(personTOthing(42,270)). +legacyConfig(personTOthing(43,271)). +legacyConfig(personTOthing(43,272)). +legacyConfig(personTOthing(43,273)). +legacyConfig(personTOthing(43,274)). +legacyConfig(personTOthing(43,275)). +legacyConfig(personTOthing(44,276)). +legacyConfig(personTOthing(44,277)). +legacyConfig(personTOthing(44,278)). +legacyConfig(personTOthing(44,279)). +legacyConfig(personTOthing(44,280)). +legacyConfig(personTOthing(45,281)). +legacyConfig(personTOthing(45,282)). +legacyConfig(personTOthing(45,283)). +legacyConfig(personTOthing(45,284)). +legacyConfig(personTOthing(45,285)). +legacyConfig(personTOthing(46,286)). +legacyConfig(personTOthing(46,287)). +legacyConfig(personTOthing(46,288)). +legacyConfig(personTOthing(46,289)). +legacyConfig(personTOthing(46,290)). +legacyConfig(personTOthing(47,291)). +legacyConfig(personTOthing(47,292)). +legacyConfig(personTOthing(47,293)). +legacyConfig(personTOthing(47,294)). +legacyConfig(personTOthing(47,295)). +legacyConfig(personTOthing(48,296)). +legacyConfig(personTOthing(48,297)). +legacyConfig(personTOthing(48,298)). +legacyConfig(personTOthing(48,299)). +legacyConfig(personTOthing(48,300)). +legacyConfig(personTOthing(49,301)). +legacyConfig(personTOthing(49,302)). +legacyConfig(personTOthing(49,303)). +legacyConfig(personTOthing(49,304)). +legacyConfig(personTOthing(49,305)). +legacyConfig(personTOthing(50,306)). +legacyConfig(personTOthing(50,307)). +legacyConfig(personTOthing(50,308)). +legacyConfig(personTOthing(50,309)). +legacyConfig(personTOthing(50,310)). +legacyConfig(personTOthing(51,311)). +legacyConfig(personTOthing(51,312)). +legacyConfig(personTOthing(51,313)). +legacyConfig(personTOthing(51,314)). +legacyConfig(personTOthing(51,315)). +legacyConfig(personTOthing(52,316)). +legacyConfig(personTOthing(52,317)). +legacyConfig(personTOthing(52,318)). +legacyConfig(personTOthing(52,319)). +legacyConfig(personTOthing(52,320)). +legacyConfig(personTOthing(53,321)). +legacyConfig(personTOthing(53,322)). +legacyConfig(personTOthing(53,323)). +legacyConfig(personTOthing(53,324)). +legacyConfig(personTOthing(53,325)). +legacyConfig(personTOthing(54,326)). +legacyConfig(personTOthing(54,327)). +legacyConfig(personTOthing(54,328)). +legacyConfig(personTOthing(54,329)). +legacyConfig(personTOthing(54,330)). +legacyConfig(personTOthing(55,331)). +legacyConfig(personTOthing(55,332)). +legacyConfig(personTOthing(55,333)). +legacyConfig(personTOthing(55,334)). +legacyConfig(personTOthing(55,335)). +legacyConfig(personTOthing(56,336)). +legacyConfig(personTOthing(56,337)). +legacyConfig(personTOthing(56,338)). +legacyConfig(personTOthing(56,339)). +legacyConfig(personTOthing(56,340)). +legacyConfig(personTOthing(57,341)). +legacyConfig(personTOthing(57,342)). +legacyConfig(personTOthing(57,343)). +legacyConfig(personTOthing(57,344)). +legacyConfig(personTOthing(57,345)). +legacyConfig(personTOthing(58,346)). +legacyConfig(personTOthing(58,347)). +legacyConfig(personTOthing(58,348)). +legacyConfig(personTOthing(58,349)). +legacyConfig(personTOthing(58,350)). +legacyConfig(personTOthing(59,351)). +legacyConfig(personTOthing(59,352)). +legacyConfig(personTOthing(59,353)). +legacyConfig(personTOthing(59,354)). +legacyConfig(personTOthing(59,355)). +legacyConfig(personTOthing(60,356)). +legacyConfig(personTOthing(60,357)). +legacyConfig(personTOthing(60,358)). +legacyConfig(personTOthing(60,359)). +legacyConfig(personTOthing(60,360)). +% domains +cabinetDomainNew(500..799). +roomDomainNew(1000..1299). +cabinetUpper(300). +roomUpper(300). +cabinetLower(60). +roomLower(15). +% reuse costs +reuseCabinetTOthingCost(0). +reuseRoomTOcabinetCost(0). +reusePersonTOroomCost(0). +reuseCabinetAsHighCost(3). +reuseCabinetAsSmallCost(0). +reuseRoomCost(0). +% remove costs +removeCabinetTOthingCost(2). +removeRoomTOcabinetCost(2). +removePersonTOroomCost(2). +removeCabinetCost(2). +removeRoomCost(2). +% create costs +cabinetHighCost(100). +cabinetSmallCost(1). +roomCost(5). diff --git a/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p65t325.edb b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p65t325.edb new file mode 100644 index 000000000..502a989d3 --- /dev/null +++ b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p65t325.edb @@ -0,0 +1,1064 @@ +legacyConfig(person(1)). +legacyConfig(person(2)). +legacyConfig(person(3)). +legacyConfig(person(4)). +legacyConfig(person(5)). +legacyConfig(person(6)). +legacyConfig(person(7)). +legacyConfig(person(8)). +legacyConfig(person(9)). +legacyConfig(person(10)). +legacyConfig(person(11)). +legacyConfig(person(12)). +legacyConfig(person(13)). +legacyConfig(person(14)). +legacyConfig(person(15)). +legacyConfig(person(16)). +legacyConfig(person(17)). +legacyConfig(person(18)). +legacyConfig(person(19)). +legacyConfig(person(20)). +legacyConfig(person(21)). +legacyConfig(person(22)). +legacyConfig(person(23)). +legacyConfig(person(24)). +legacyConfig(person(25)). +legacyConfig(person(26)). +legacyConfig(person(27)). +legacyConfig(person(28)). +legacyConfig(person(29)). +legacyConfig(person(30)). +legacyConfig(person(31)). +legacyConfig(person(32)). +legacyConfig(person(33)). +legacyConfig(person(34)). +legacyConfig(person(35)). +legacyConfig(person(36)). +legacyConfig(person(37)). +legacyConfig(person(38)). +legacyConfig(person(39)). +legacyConfig(person(40)). +legacyConfig(person(41)). +legacyConfig(person(42)). +legacyConfig(person(43)). +legacyConfig(person(44)). +legacyConfig(person(45)). +legacyConfig(person(46)). +legacyConfig(person(47)). +legacyConfig(person(48)). +legacyConfig(person(49)). +legacyConfig(person(50)). +legacyConfig(person(51)). +legacyConfig(person(52)). +legacyConfig(person(53)). +legacyConfig(person(54)). +legacyConfig(person(55)). +legacyConfig(person(56)). +legacyConfig(person(57)). +legacyConfig(person(58)). +legacyConfig(person(59)). +legacyConfig(person(60)). +legacyConfig(person(61)). +legacyConfig(person(62)). +legacyConfig(person(63)). +legacyConfig(person(64)). +legacyConfig(person(65)). +legacyConfig(thing(66)). +thingShort(66). +legacyConfig(thing(67)). +thingShort(67). +legacyConfig(thing(68)). +thingShort(68). +legacyConfig(thing(69)). +thingShort(69). +legacyConfig(thing(70)). +thingShort(70). +legacyConfig(thing(71)). +thingShort(71). +legacyConfig(thing(72)). +thingShort(72). +legacyConfig(thing(73)). +thingShort(73). +legacyConfig(thing(74)). +thingShort(74). +legacyConfig(thing(75)). +thingShort(75). +legacyConfig(thing(76)). +thingShort(76). +legacyConfig(thing(77)). +thingShort(77). +legacyConfig(thing(78)). +thingShort(78). +legacyConfig(thing(79)). +thingShort(79). +legacyConfig(thing(80)). +thingShort(80). +legacyConfig(thing(81)). +thingShort(81). +legacyConfig(thing(82)). +thingShort(82). +legacyConfig(thing(83)). +thingShort(83). +legacyConfig(thing(84)). +thingShort(84). +legacyConfig(thing(85)). +thingShort(85). +legacyConfig(thing(86)). +thingShort(86). +legacyConfig(thing(87)). +thingShort(87). +legacyConfig(thing(88)). +thingShort(88). +legacyConfig(thing(89)). +thingShort(89). +legacyConfig(thing(90)). +thingShort(90). +legacyConfig(thing(91)). +thingShort(91). +legacyConfig(thing(92)). +thingShort(92). +legacyConfig(thing(93)). +thingShort(93). +legacyConfig(thing(94)). +thingShort(94). +legacyConfig(thing(95)). +thingShort(95). +legacyConfig(thing(96)). +thingShort(96). +legacyConfig(thing(97)). +thingShort(97). +legacyConfig(thing(98)). +thingShort(98). +legacyConfig(thing(99)). +thingShort(99). +legacyConfig(thing(100)). +thingShort(100). +legacyConfig(thing(101)). +thingShort(101). +legacyConfig(thing(102)). +thingShort(102). +legacyConfig(thing(103)). +thingShort(103). +legacyConfig(thing(104)). +thingShort(104). +legacyConfig(thing(105)). +thingShort(105). +legacyConfig(thing(106)). +thingShort(106). +legacyConfig(thing(107)). +thingShort(107). +legacyConfig(thing(108)). +thingShort(108). +legacyConfig(thing(109)). +thingShort(109). +legacyConfig(thing(110)). +thingShort(110). +legacyConfig(thing(111)). +thingShort(111). +legacyConfig(thing(112)). +thingShort(112). +legacyConfig(thing(113)). +thingShort(113). +legacyConfig(thing(114)). +thingShort(114). +legacyConfig(thing(115)). +thingShort(115). +legacyConfig(thing(116)). +thingShort(116). +legacyConfig(thing(117)). +thingShort(117). +legacyConfig(thing(118)). +thingShort(118). +legacyConfig(thing(119)). +thingShort(119). +legacyConfig(thing(120)). +thingShort(120). +legacyConfig(thing(121)). +thingShort(121). +legacyConfig(thing(122)). +thingShort(122). +legacyConfig(thing(123)). +thingShort(123). +legacyConfig(thing(124)). +thingShort(124). +legacyConfig(thing(125)). +thingShort(125). +legacyConfig(thing(126)). +thingShort(126). +legacyConfig(thing(127)). +thingShort(127). +legacyConfig(thing(128)). +thingShort(128). +legacyConfig(thing(129)). +thingShort(129). +legacyConfig(thing(130)). +thingShort(130). +legacyConfig(thing(131)). +thingShort(131). +legacyConfig(thing(132)). +thingShort(132). +legacyConfig(thing(133)). +thingShort(133). +legacyConfig(thing(134)). +thingShort(134). +legacyConfig(thing(135)). +thingShort(135). +legacyConfig(thing(136)). +thingShort(136). +legacyConfig(thing(137)). +thingShort(137). +legacyConfig(thing(138)). +thingShort(138). +legacyConfig(thing(139)). +thingShort(139). +legacyConfig(thing(140)). +thingShort(140). +legacyConfig(thing(141)). +thingShort(141). +legacyConfig(thing(142)). +thingShort(142). +legacyConfig(thing(143)). +thingShort(143). +legacyConfig(thing(144)). +thingShort(144). +legacyConfig(thing(145)). +thingShort(145). +legacyConfig(thing(146)). +thingShort(146). +legacyConfig(thing(147)). +thingShort(147). +legacyConfig(thing(148)). +thingShort(148). +legacyConfig(thing(149)). +thingShort(149). +legacyConfig(thing(150)). +thingShort(150). +legacyConfig(thing(151)). +thingShort(151). +legacyConfig(thing(152)). +thingShort(152). +legacyConfig(thing(153)). +thingShort(153). +legacyConfig(thing(154)). +thingShort(154). +legacyConfig(thing(155)). +thingShort(155). +legacyConfig(thing(156)). +thingShort(156). +legacyConfig(thing(157)). +thingShort(157). +legacyConfig(thing(158)). +thingShort(158). +legacyConfig(thing(159)). +thingShort(159). +legacyConfig(thing(160)). +thingShort(160). +legacyConfig(thing(161)). +thingShort(161). +legacyConfig(thing(162)). +thingShort(162). +legacyConfig(thing(163)). +thingShort(163). +legacyConfig(thing(164)). +thingShort(164). +legacyConfig(thing(165)). +thingShort(165). +legacyConfig(thing(166)). +thingShort(166). +legacyConfig(thing(167)). +thingShort(167). +legacyConfig(thing(168)). +thingShort(168). +legacyConfig(thing(169)). +thingShort(169). +legacyConfig(thing(170)). +thingShort(170). +legacyConfig(thing(171)). +thingShort(171). +legacyConfig(thing(172)). +thingShort(172). +legacyConfig(thing(173)). +thingShort(173). +legacyConfig(thing(174)). +thingShort(174). +legacyConfig(thing(175)). +thingShort(175). +legacyConfig(thing(176)). +thingShort(176). +legacyConfig(thing(177)). +thingShort(177). +legacyConfig(thing(178)). +thingShort(178). +legacyConfig(thing(179)). +thingShort(179). +legacyConfig(thing(180)). +thingShort(180). +legacyConfig(thing(181)). +thingShort(181). +legacyConfig(thing(182)). +thingShort(182). +legacyConfig(thing(183)). +thingShort(183). +legacyConfig(thing(184)). +thingShort(184). +legacyConfig(thing(185)). +thingShort(185). +legacyConfig(thing(186)). +thingShort(186). +legacyConfig(thing(187)). +thingShort(187). +legacyConfig(thing(188)). +thingShort(188). +legacyConfig(thing(189)). +thingShort(189). +legacyConfig(thing(190)). +thingShort(190). +legacyConfig(thing(191)). +thingShort(191). +legacyConfig(thing(192)). +thingShort(192). +legacyConfig(thing(193)). +thingShort(193). +legacyConfig(thing(194)). +thingShort(194). +legacyConfig(thing(195)). +thingShort(195). +legacyConfig(thing(196)). +thingShort(196). +legacyConfig(thing(197)). +thingShort(197). +legacyConfig(thing(198)). +thingShort(198). +legacyConfig(thing(199)). +thingShort(199). +legacyConfig(thing(200)). +thingShort(200). +legacyConfig(thing(201)). +thingShort(201). +legacyConfig(thing(202)). +thingShort(202). +legacyConfig(thing(203)). +thingShort(203). +legacyConfig(thing(204)). +thingShort(204). +legacyConfig(thing(205)). +thingShort(205). +legacyConfig(thing(206)). +thingShort(206). +legacyConfig(thing(207)). +thingShort(207). +legacyConfig(thing(208)). +thingShort(208). +legacyConfig(thing(209)). +thingShort(209). +legacyConfig(thing(210)). +thingShort(210). +legacyConfig(thing(211)). +thingShort(211). +legacyConfig(thing(212)). +thingShort(212). +legacyConfig(thing(213)). +thingShort(213). +legacyConfig(thing(214)). +thingShort(214). +legacyConfig(thing(215)). +thingShort(215). +legacyConfig(thing(216)). +thingShort(216). +legacyConfig(thing(217)). +thingShort(217). +legacyConfig(thing(218)). +thingShort(218). +legacyConfig(thing(219)). +thingShort(219). +legacyConfig(thing(220)). +thingShort(220). +legacyConfig(thing(221)). +thingShort(221). +legacyConfig(thing(222)). +thingShort(222). +legacyConfig(thing(223)). +thingShort(223). +legacyConfig(thing(224)). +thingShort(224). +legacyConfig(thing(225)). +thingShort(225). +legacyConfig(thing(226)). +thingShort(226). +legacyConfig(thing(227)). +thingShort(227). +legacyConfig(thing(228)). +thingShort(228). +legacyConfig(thing(229)). +thingShort(229). +legacyConfig(thing(230)). +thingShort(230). +legacyConfig(thing(231)). +thingShort(231). +legacyConfig(thing(232)). +thingShort(232). +legacyConfig(thing(233)). +thingShort(233). +legacyConfig(thing(234)). +thingShort(234). +legacyConfig(thing(235)). +thingShort(235). +legacyConfig(thing(236)). +thingShort(236). +legacyConfig(thing(237)). +thingShort(237). +legacyConfig(thing(238)). +thingShort(238). +legacyConfig(thing(239)). +thingShort(239). +legacyConfig(thing(240)). +thingShort(240). +legacyConfig(thing(241)). +thingShort(241). +legacyConfig(thing(242)). +thingShort(242). +legacyConfig(thing(243)). +thingShort(243). +legacyConfig(thing(244)). +thingShort(244). +legacyConfig(thing(245)). +thingShort(245). +legacyConfig(thing(246)). +thingShort(246). +legacyConfig(thing(247)). +thingShort(247). +legacyConfig(thing(248)). +thingShort(248). +legacyConfig(thing(249)). +thingShort(249). +legacyConfig(thing(250)). +thingShort(250). +legacyConfig(thing(251)). +thingShort(251). +legacyConfig(thing(252)). +thingShort(252). +legacyConfig(thing(253)). +thingShort(253). +legacyConfig(thing(254)). +thingShort(254). +legacyConfig(thing(255)). +thingShort(255). +legacyConfig(thing(256)). +thingShort(256). +legacyConfig(thing(257)). +thingShort(257). +legacyConfig(thing(258)). +thingShort(258). +legacyConfig(thing(259)). +thingShort(259). +legacyConfig(thing(260)). +thingShort(260). +legacyConfig(thing(261)). +thingShort(261). +legacyConfig(thing(262)). +thingShort(262). +legacyConfig(thing(263)). +thingShort(263). +legacyConfig(thing(264)). +thingShort(264). +legacyConfig(thing(265)). +thingShort(265). +legacyConfig(thing(266)). +thingShort(266). +legacyConfig(thing(267)). +thingShort(267). +legacyConfig(thing(268)). +thingShort(268). +legacyConfig(thing(269)). +thingShort(269). +legacyConfig(thing(270)). +thingShort(270). +legacyConfig(thing(271)). +thingShort(271). +legacyConfig(thing(272)). +thingShort(272). +legacyConfig(thing(273)). +thingShort(273). +legacyConfig(thing(274)). +thingShort(274). +legacyConfig(thing(275)). +thingShort(275). +legacyConfig(thing(276)). +thingShort(276). +legacyConfig(thing(277)). +thingShort(277). +legacyConfig(thing(278)). +thingShort(278). +legacyConfig(thing(279)). +thingShort(279). +legacyConfig(thing(280)). +thingShort(280). +legacyConfig(thing(281)). +thingShort(281). +legacyConfig(thing(282)). +thingShort(282). +legacyConfig(thing(283)). +thingShort(283). +legacyConfig(thing(284)). +thingShort(284). +legacyConfig(thing(285)). +thingShort(285). +legacyConfig(thing(286)). +thingShort(286). +legacyConfig(thing(287)). +thingShort(287). +legacyConfig(thing(288)). +thingShort(288). +legacyConfig(thing(289)). +thingShort(289). +legacyConfig(thing(290)). +thingShort(290). +legacyConfig(thing(291)). +thingShort(291). +legacyConfig(thing(292)). +thingShort(292). +legacyConfig(thing(293)). +thingShort(293). +legacyConfig(thing(294)). +thingShort(294). +legacyConfig(thing(295)). +thingShort(295). +legacyConfig(thing(296)). +thingShort(296). +legacyConfig(thing(297)). +thingShort(297). +legacyConfig(thing(298)). +thingShort(298). +legacyConfig(thing(299)). +thingShort(299). +legacyConfig(thing(300)). +thingShort(300). +legacyConfig(thing(301)). +thingShort(301). +legacyConfig(thing(302)). +thingShort(302). +legacyConfig(thing(303)). +thingShort(303). +legacyConfig(thing(304)). +thingShort(304). +legacyConfig(thing(305)). +thingShort(305). +legacyConfig(thing(306)). +thingShort(306). +legacyConfig(thing(307)). +thingShort(307). +legacyConfig(thing(308)). +thingShort(308). +legacyConfig(thing(309)). +thingShort(309). +legacyConfig(thing(310)). +thingShort(310). +legacyConfig(thing(311)). +thingShort(311). +legacyConfig(thing(312)). +thingShort(312). +legacyConfig(thing(313)). +thingShort(313). +legacyConfig(thing(314)). +thingShort(314). +legacyConfig(thing(315)). +thingShort(315). +legacyConfig(thing(316)). +thingShort(316). +legacyConfig(thing(317)). +thingShort(317). +legacyConfig(thing(318)). +thingShort(318). +legacyConfig(thing(319)). +thingShort(319). +legacyConfig(thing(320)). +thingShort(320). +legacyConfig(thing(321)). +thingShort(321). +legacyConfig(thing(322)). +thingShort(322). +legacyConfig(thing(323)). +thingShort(323). +legacyConfig(thing(324)). +thingShort(324). +legacyConfig(thing(325)). +thingShort(325). +legacyConfig(thing(326)). +thingShort(326). +legacyConfig(thing(327)). +thingShort(327). +legacyConfig(thing(328)). +thingShort(328). +legacyConfig(thing(329)). +thingShort(329). +legacyConfig(thing(330)). +thingShort(330). +legacyConfig(thing(331)). +thingShort(331). +legacyConfig(thing(332)). +thingShort(332). +legacyConfig(thing(333)). +thingShort(333). +legacyConfig(thing(334)). +thingShort(334). +legacyConfig(thing(335)). +thingShort(335). +legacyConfig(thing(336)). +thingShort(336). +legacyConfig(thing(337)). +thingShort(337). +legacyConfig(thing(338)). +thingShort(338). +legacyConfig(thing(339)). +thingShort(339). +legacyConfig(thing(340)). +thingShort(340). +legacyConfig(thing(341)). +thingShort(341). +legacyConfig(thing(342)). +thingShort(342). +legacyConfig(thing(343)). +thingShort(343). +legacyConfig(thing(344)). +thingShort(344). +legacyConfig(thing(345)). +thingShort(345). +legacyConfig(thing(346)). +thingShort(346). +legacyConfig(thing(347)). +thingShort(347). +legacyConfig(thing(348)). +thingShort(348). +legacyConfig(thing(349)). +thingShort(349). +legacyConfig(thing(350)). +thingShort(350). +legacyConfig(thing(351)). +thingShort(351). +legacyConfig(thing(352)). +thingShort(352). +legacyConfig(thing(353)). +thingShort(353). +legacyConfig(thing(354)). +thingShort(354). +legacyConfig(thing(355)). +thingShort(355). +legacyConfig(thing(356)). +thingShort(356). +legacyConfig(thing(357)). +thingShort(357). +legacyConfig(thing(358)). +thingShort(358). +legacyConfig(thing(359)). +thingShort(359). +legacyConfig(thing(360)). +thingShort(360). +legacyConfig(thing(361)). +thingShort(361). +legacyConfig(thing(362)). +thingShort(362). +legacyConfig(thing(363)). +thingShort(363). +legacyConfig(thing(364)). +thingShort(364). +legacyConfig(thing(365)). +thingShort(365). +legacyConfig(thing(366)). +thingShort(366). +legacyConfig(thing(367)). +thingShort(367). +legacyConfig(thing(368)). +thingShort(368). +legacyConfig(thing(369)). +thingShort(369). +legacyConfig(thing(370)). +thingShort(370). +legacyConfig(thing(371)). +thingShort(371). +legacyConfig(thing(372)). +thingShort(372). +legacyConfig(thing(373)). +thingShort(373). +legacyConfig(thing(374)). +thingShort(374). +legacyConfig(thing(375)). +thingShort(375). +legacyConfig(thing(376)). +thingShort(376). +legacyConfig(thing(377)). +thingShort(377). +legacyConfig(thing(378)). +thingShort(378). +legacyConfig(thing(379)). +thingShort(379). +legacyConfig(thing(380)). +thingShort(380). +legacyConfig(thing(381)). +thingShort(381). +legacyConfig(thing(382)). +thingShort(382). +legacyConfig(thing(383)). +thingShort(383). +legacyConfig(thing(384)). +thingShort(384). +legacyConfig(thing(385)). +thingShort(385). +legacyConfig(thing(386)). +thingShort(386). +legacyConfig(thing(387)). +thingShort(387). +legacyConfig(thing(388)). +thingShort(388). +legacyConfig(thing(389)). +thingShort(389). +legacyConfig(thing(390)). +thingShort(390). +legacyConfig(personTOthing(1,66)). +legacyConfig(personTOthing(1,67)). +legacyConfig(personTOthing(1,68)). +legacyConfig(personTOthing(1,69)). +legacyConfig(personTOthing(1,70)). +legacyConfig(personTOthing(2,71)). +legacyConfig(personTOthing(2,72)). +legacyConfig(personTOthing(2,73)). +legacyConfig(personTOthing(2,74)). +legacyConfig(personTOthing(2,75)). +legacyConfig(personTOthing(3,76)). +legacyConfig(personTOthing(3,77)). +legacyConfig(personTOthing(3,78)). +legacyConfig(personTOthing(3,79)). +legacyConfig(personTOthing(3,80)). +legacyConfig(personTOthing(4,81)). +legacyConfig(personTOthing(4,82)). +legacyConfig(personTOthing(4,83)). +legacyConfig(personTOthing(4,84)). +legacyConfig(personTOthing(4,85)). +legacyConfig(personTOthing(5,86)). +legacyConfig(personTOthing(5,87)). +legacyConfig(personTOthing(5,88)). +legacyConfig(personTOthing(5,89)). +legacyConfig(personTOthing(5,90)). +legacyConfig(personTOthing(6,91)). +legacyConfig(personTOthing(6,92)). +legacyConfig(personTOthing(6,93)). +legacyConfig(personTOthing(6,94)). +legacyConfig(personTOthing(6,95)). +legacyConfig(personTOthing(7,96)). +legacyConfig(personTOthing(7,97)). +legacyConfig(personTOthing(7,98)). +legacyConfig(personTOthing(7,99)). +legacyConfig(personTOthing(7,100)). +legacyConfig(personTOthing(8,101)). +legacyConfig(personTOthing(8,102)). +legacyConfig(personTOthing(8,103)). +legacyConfig(personTOthing(8,104)). +legacyConfig(personTOthing(8,105)). +legacyConfig(personTOthing(9,106)). +legacyConfig(personTOthing(9,107)). +legacyConfig(personTOthing(9,108)). +legacyConfig(personTOthing(9,109)). +legacyConfig(personTOthing(9,110)). +legacyConfig(personTOthing(10,111)). +legacyConfig(personTOthing(10,112)). +legacyConfig(personTOthing(10,113)). +legacyConfig(personTOthing(10,114)). +legacyConfig(personTOthing(10,115)). +legacyConfig(personTOthing(11,116)). +legacyConfig(personTOthing(11,117)). +legacyConfig(personTOthing(11,118)). +legacyConfig(personTOthing(11,119)). +legacyConfig(personTOthing(11,120)). +legacyConfig(personTOthing(12,121)). +legacyConfig(personTOthing(12,122)). +legacyConfig(personTOthing(12,123)). +legacyConfig(personTOthing(12,124)). +legacyConfig(personTOthing(12,125)). +legacyConfig(personTOthing(13,126)). +legacyConfig(personTOthing(13,127)). +legacyConfig(personTOthing(13,128)). +legacyConfig(personTOthing(13,129)). +legacyConfig(personTOthing(13,130)). +legacyConfig(personTOthing(14,131)). +legacyConfig(personTOthing(14,132)). +legacyConfig(personTOthing(14,133)). +legacyConfig(personTOthing(14,134)). +legacyConfig(personTOthing(14,135)). +legacyConfig(personTOthing(15,136)). +legacyConfig(personTOthing(15,137)). +legacyConfig(personTOthing(15,138)). +legacyConfig(personTOthing(15,139)). +legacyConfig(personTOthing(15,140)). +legacyConfig(personTOthing(16,141)). +legacyConfig(personTOthing(16,142)). +legacyConfig(personTOthing(16,143)). +legacyConfig(personTOthing(16,144)). +legacyConfig(personTOthing(16,145)). +legacyConfig(personTOthing(17,146)). +legacyConfig(personTOthing(17,147)). +legacyConfig(personTOthing(17,148)). +legacyConfig(personTOthing(17,149)). +legacyConfig(personTOthing(17,150)). +legacyConfig(personTOthing(18,151)). +legacyConfig(personTOthing(18,152)). +legacyConfig(personTOthing(18,153)). +legacyConfig(personTOthing(18,154)). +legacyConfig(personTOthing(18,155)). +legacyConfig(personTOthing(19,156)). +legacyConfig(personTOthing(19,157)). +legacyConfig(personTOthing(19,158)). +legacyConfig(personTOthing(19,159)). +legacyConfig(personTOthing(19,160)). +legacyConfig(personTOthing(20,161)). +legacyConfig(personTOthing(20,162)). +legacyConfig(personTOthing(20,163)). +legacyConfig(personTOthing(20,164)). +legacyConfig(personTOthing(20,165)). +legacyConfig(personTOthing(21,166)). +legacyConfig(personTOthing(21,167)). +legacyConfig(personTOthing(21,168)). +legacyConfig(personTOthing(21,169)). +legacyConfig(personTOthing(21,170)). +legacyConfig(personTOthing(22,171)). +legacyConfig(personTOthing(22,172)). +legacyConfig(personTOthing(22,173)). +legacyConfig(personTOthing(22,174)). +legacyConfig(personTOthing(22,175)). +legacyConfig(personTOthing(23,176)). +legacyConfig(personTOthing(23,177)). +legacyConfig(personTOthing(23,178)). +legacyConfig(personTOthing(23,179)). +legacyConfig(personTOthing(23,180)). +legacyConfig(personTOthing(24,181)). +legacyConfig(personTOthing(24,182)). +legacyConfig(personTOthing(24,183)). +legacyConfig(personTOthing(24,184)). +legacyConfig(personTOthing(24,185)). +legacyConfig(personTOthing(25,186)). +legacyConfig(personTOthing(25,187)). +legacyConfig(personTOthing(25,188)). +legacyConfig(personTOthing(25,189)). +legacyConfig(personTOthing(25,190)). +legacyConfig(personTOthing(26,191)). +legacyConfig(personTOthing(26,192)). +legacyConfig(personTOthing(26,193)). +legacyConfig(personTOthing(26,194)). +legacyConfig(personTOthing(26,195)). +legacyConfig(personTOthing(27,196)). +legacyConfig(personTOthing(27,197)). +legacyConfig(personTOthing(27,198)). +legacyConfig(personTOthing(27,199)). +legacyConfig(personTOthing(27,200)). +legacyConfig(personTOthing(28,201)). +legacyConfig(personTOthing(28,202)). +legacyConfig(personTOthing(28,203)). +legacyConfig(personTOthing(28,204)). +legacyConfig(personTOthing(28,205)). +legacyConfig(personTOthing(29,206)). +legacyConfig(personTOthing(29,207)). +legacyConfig(personTOthing(29,208)). +legacyConfig(personTOthing(29,209)). +legacyConfig(personTOthing(29,210)). +legacyConfig(personTOthing(30,211)). +legacyConfig(personTOthing(30,212)). +legacyConfig(personTOthing(30,213)). +legacyConfig(personTOthing(30,214)). +legacyConfig(personTOthing(30,215)). +legacyConfig(personTOthing(31,216)). +legacyConfig(personTOthing(31,217)). +legacyConfig(personTOthing(31,218)). +legacyConfig(personTOthing(31,219)). +legacyConfig(personTOthing(31,220)). +legacyConfig(personTOthing(32,221)). +legacyConfig(personTOthing(32,222)). +legacyConfig(personTOthing(32,223)). +legacyConfig(personTOthing(32,224)). +legacyConfig(personTOthing(32,225)). +legacyConfig(personTOthing(33,226)). +legacyConfig(personTOthing(33,227)). +legacyConfig(personTOthing(33,228)). +legacyConfig(personTOthing(33,229)). +legacyConfig(personTOthing(33,230)). +legacyConfig(personTOthing(34,231)). +legacyConfig(personTOthing(34,232)). +legacyConfig(personTOthing(34,233)). +legacyConfig(personTOthing(34,234)). +legacyConfig(personTOthing(34,235)). +legacyConfig(personTOthing(35,236)). +legacyConfig(personTOthing(35,237)). +legacyConfig(personTOthing(35,238)). +legacyConfig(personTOthing(35,239)). +legacyConfig(personTOthing(35,240)). +legacyConfig(personTOthing(36,241)). +legacyConfig(personTOthing(36,242)). +legacyConfig(personTOthing(36,243)). +legacyConfig(personTOthing(36,244)). +legacyConfig(personTOthing(36,245)). +legacyConfig(personTOthing(37,246)). +legacyConfig(personTOthing(37,247)). +legacyConfig(personTOthing(37,248)). +legacyConfig(personTOthing(37,249)). +legacyConfig(personTOthing(37,250)). +legacyConfig(personTOthing(38,251)). +legacyConfig(personTOthing(38,252)). +legacyConfig(personTOthing(38,253)). +legacyConfig(personTOthing(38,254)). +legacyConfig(personTOthing(38,255)). +legacyConfig(personTOthing(39,256)). +legacyConfig(personTOthing(39,257)). +legacyConfig(personTOthing(39,258)). +legacyConfig(personTOthing(39,259)). +legacyConfig(personTOthing(39,260)). +legacyConfig(personTOthing(40,261)). +legacyConfig(personTOthing(40,262)). +legacyConfig(personTOthing(40,263)). +legacyConfig(personTOthing(40,264)). +legacyConfig(personTOthing(40,265)). +legacyConfig(personTOthing(41,266)). +legacyConfig(personTOthing(41,267)). +legacyConfig(personTOthing(41,268)). +legacyConfig(personTOthing(41,269)). +legacyConfig(personTOthing(41,270)). +legacyConfig(personTOthing(42,271)). +legacyConfig(personTOthing(42,272)). +legacyConfig(personTOthing(42,273)). +legacyConfig(personTOthing(42,274)). +legacyConfig(personTOthing(42,275)). +legacyConfig(personTOthing(43,276)). +legacyConfig(personTOthing(43,277)). +legacyConfig(personTOthing(43,278)). +legacyConfig(personTOthing(43,279)). +legacyConfig(personTOthing(43,280)). +legacyConfig(personTOthing(44,281)). +legacyConfig(personTOthing(44,282)). +legacyConfig(personTOthing(44,283)). +legacyConfig(personTOthing(44,284)). +legacyConfig(personTOthing(44,285)). +legacyConfig(personTOthing(45,286)). +legacyConfig(personTOthing(45,287)). +legacyConfig(personTOthing(45,288)). +legacyConfig(personTOthing(45,289)). +legacyConfig(personTOthing(45,290)). +legacyConfig(personTOthing(46,291)). +legacyConfig(personTOthing(46,292)). +legacyConfig(personTOthing(46,293)). +legacyConfig(personTOthing(46,294)). +legacyConfig(personTOthing(46,295)). +legacyConfig(personTOthing(47,296)). +legacyConfig(personTOthing(47,297)). +legacyConfig(personTOthing(47,298)). +legacyConfig(personTOthing(47,299)). +legacyConfig(personTOthing(47,300)). +legacyConfig(personTOthing(48,301)). +legacyConfig(personTOthing(48,302)). +legacyConfig(personTOthing(48,303)). +legacyConfig(personTOthing(48,304)). +legacyConfig(personTOthing(48,305)). +legacyConfig(personTOthing(49,306)). +legacyConfig(personTOthing(49,307)). +legacyConfig(personTOthing(49,308)). +legacyConfig(personTOthing(49,309)). +legacyConfig(personTOthing(49,310)). +legacyConfig(personTOthing(50,311)). +legacyConfig(personTOthing(50,312)). +legacyConfig(personTOthing(50,313)). +legacyConfig(personTOthing(50,314)). +legacyConfig(personTOthing(50,315)). +legacyConfig(personTOthing(51,316)). +legacyConfig(personTOthing(51,317)). +legacyConfig(personTOthing(51,318)). +legacyConfig(personTOthing(51,319)). +legacyConfig(personTOthing(51,320)). +legacyConfig(personTOthing(52,321)). +legacyConfig(personTOthing(52,322)). +legacyConfig(personTOthing(52,323)). +legacyConfig(personTOthing(52,324)). +legacyConfig(personTOthing(52,325)). +legacyConfig(personTOthing(53,326)). +legacyConfig(personTOthing(53,327)). +legacyConfig(personTOthing(53,328)). +legacyConfig(personTOthing(53,329)). +legacyConfig(personTOthing(53,330)). +legacyConfig(personTOthing(54,331)). +legacyConfig(personTOthing(54,332)). +legacyConfig(personTOthing(54,333)). +legacyConfig(personTOthing(54,334)). +legacyConfig(personTOthing(54,335)). +legacyConfig(personTOthing(55,336)). +legacyConfig(personTOthing(55,337)). +legacyConfig(personTOthing(55,338)). +legacyConfig(personTOthing(55,339)). +legacyConfig(personTOthing(55,340)). +legacyConfig(personTOthing(56,341)). +legacyConfig(personTOthing(56,342)). +legacyConfig(personTOthing(56,343)). +legacyConfig(personTOthing(56,344)). +legacyConfig(personTOthing(56,345)). +legacyConfig(personTOthing(57,346)). +legacyConfig(personTOthing(57,347)). +legacyConfig(personTOthing(57,348)). +legacyConfig(personTOthing(57,349)). +legacyConfig(personTOthing(57,350)). +legacyConfig(personTOthing(58,351)). +legacyConfig(personTOthing(58,352)). +legacyConfig(personTOthing(58,353)). +legacyConfig(personTOthing(58,354)). +legacyConfig(personTOthing(58,355)). +legacyConfig(personTOthing(59,356)). +legacyConfig(personTOthing(59,357)). +legacyConfig(personTOthing(59,358)). +legacyConfig(personTOthing(59,359)). +legacyConfig(personTOthing(59,360)). +legacyConfig(personTOthing(60,361)). +legacyConfig(personTOthing(60,362)). +legacyConfig(personTOthing(60,363)). +legacyConfig(personTOthing(60,364)). +legacyConfig(personTOthing(60,365)). +legacyConfig(personTOthing(61,366)). +legacyConfig(personTOthing(61,367)). +legacyConfig(personTOthing(61,368)). +legacyConfig(personTOthing(61,369)). +legacyConfig(personTOthing(61,370)). +legacyConfig(personTOthing(62,371)). +legacyConfig(personTOthing(62,372)). +legacyConfig(personTOthing(62,373)). +legacyConfig(personTOthing(62,374)). +legacyConfig(personTOthing(62,375)). +legacyConfig(personTOthing(63,376)). +legacyConfig(personTOthing(63,377)). +legacyConfig(personTOthing(63,378)). +legacyConfig(personTOthing(63,379)). +legacyConfig(personTOthing(63,380)). +legacyConfig(personTOthing(64,381)). +legacyConfig(personTOthing(64,382)). +legacyConfig(personTOthing(64,383)). +legacyConfig(personTOthing(64,384)). +legacyConfig(personTOthing(64,385)). +legacyConfig(personTOthing(65,386)). +legacyConfig(personTOthing(65,387)). +legacyConfig(personTOthing(65,388)). +legacyConfig(personTOthing(65,389)). +legacyConfig(personTOthing(65,390)). +% domains +cabinetDomainNew(500..824). +roomDomainNew(1000..1324). +cabinetUpper(325). +roomUpper(325). +cabinetLower(65). +roomLower(17). +% reuse costs +reuseCabinetTOthingCost(0). +reuseRoomTOcabinetCost(0). +reusePersonTOroomCost(0). +reuseCabinetAsHighCost(3). +reuseCabinetAsSmallCost(0). +reuseRoomCost(0). +% remove costs +removeCabinetTOthingCost(2). +removeRoomTOcabinetCost(2). +removePersonTOroomCost(2). +removeCabinetCost(2). +removeRoomCost(2). +% create costs +cabinetHighCost(100). +cabinetSmallCost(1). +roomCost(5). diff --git a/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p70t350.edb b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p70t350.edb new file mode 100644 index 000000000..cbe030d0d --- /dev/null +++ b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p70t350.edb @@ -0,0 +1,1144 @@ +legacyConfig(person(1)). +legacyConfig(person(2)). +legacyConfig(person(3)). +legacyConfig(person(4)). +legacyConfig(person(5)). +legacyConfig(person(6)). +legacyConfig(person(7)). +legacyConfig(person(8)). +legacyConfig(person(9)). +legacyConfig(person(10)). +legacyConfig(person(11)). +legacyConfig(person(12)). +legacyConfig(person(13)). +legacyConfig(person(14)). +legacyConfig(person(15)). +legacyConfig(person(16)). +legacyConfig(person(17)). +legacyConfig(person(18)). +legacyConfig(person(19)). +legacyConfig(person(20)). +legacyConfig(person(21)). +legacyConfig(person(22)). +legacyConfig(person(23)). +legacyConfig(person(24)). +legacyConfig(person(25)). +legacyConfig(person(26)). +legacyConfig(person(27)). +legacyConfig(person(28)). +legacyConfig(person(29)). +legacyConfig(person(30)). +legacyConfig(person(31)). +legacyConfig(person(32)). +legacyConfig(person(33)). +legacyConfig(person(34)). +legacyConfig(person(35)). +legacyConfig(person(36)). +legacyConfig(person(37)). +legacyConfig(person(38)). +legacyConfig(person(39)). +legacyConfig(person(40)). +legacyConfig(person(41)). +legacyConfig(person(42)). +legacyConfig(person(43)). +legacyConfig(person(44)). +legacyConfig(person(45)). +legacyConfig(person(46)). +legacyConfig(person(47)). +legacyConfig(person(48)). +legacyConfig(person(49)). +legacyConfig(person(50)). +legacyConfig(person(51)). +legacyConfig(person(52)). +legacyConfig(person(53)). +legacyConfig(person(54)). +legacyConfig(person(55)). +legacyConfig(person(56)). +legacyConfig(person(57)). +legacyConfig(person(58)). +legacyConfig(person(59)). +legacyConfig(person(60)). +legacyConfig(person(61)). +legacyConfig(person(62)). +legacyConfig(person(63)). +legacyConfig(person(64)). +legacyConfig(person(65)). +legacyConfig(person(66)). +legacyConfig(person(67)). +legacyConfig(person(68)). +legacyConfig(person(69)). +legacyConfig(person(70)). +legacyConfig(thing(71)). +thingShort(71). +legacyConfig(thing(72)). +thingShort(72). +legacyConfig(thing(73)). +thingShort(73). +legacyConfig(thing(74)). +thingShort(74). +legacyConfig(thing(75)). +thingShort(75). +legacyConfig(thing(76)). +thingShort(76). +legacyConfig(thing(77)). +thingShort(77). +legacyConfig(thing(78)). +thingShort(78). +legacyConfig(thing(79)). +thingShort(79). +legacyConfig(thing(80)). +thingShort(80). +legacyConfig(thing(81)). +thingShort(81). +legacyConfig(thing(82)). +thingShort(82). +legacyConfig(thing(83)). +thingShort(83). +legacyConfig(thing(84)). +thingShort(84). +legacyConfig(thing(85)). +thingShort(85). +legacyConfig(thing(86)). +thingShort(86). +legacyConfig(thing(87)). +thingShort(87). +legacyConfig(thing(88)). +thingShort(88). +legacyConfig(thing(89)). +thingShort(89). +legacyConfig(thing(90)). +thingShort(90). +legacyConfig(thing(91)). +thingShort(91). +legacyConfig(thing(92)). +thingShort(92). +legacyConfig(thing(93)). +thingShort(93). +legacyConfig(thing(94)). +thingShort(94). +legacyConfig(thing(95)). +thingShort(95). +legacyConfig(thing(96)). +thingShort(96). +legacyConfig(thing(97)). +thingShort(97). +legacyConfig(thing(98)). +thingShort(98). +legacyConfig(thing(99)). +thingShort(99). +legacyConfig(thing(100)). +thingShort(100). +legacyConfig(thing(101)). +thingShort(101). +legacyConfig(thing(102)). +thingShort(102). +legacyConfig(thing(103)). +thingShort(103). +legacyConfig(thing(104)). +thingShort(104). +legacyConfig(thing(105)). +thingShort(105). +legacyConfig(thing(106)). +thingShort(106). +legacyConfig(thing(107)). +thingShort(107). +legacyConfig(thing(108)). +thingShort(108). +legacyConfig(thing(109)). +thingShort(109). +legacyConfig(thing(110)). +thingShort(110). +legacyConfig(thing(111)). +thingShort(111). +legacyConfig(thing(112)). +thingShort(112). +legacyConfig(thing(113)). +thingShort(113). +legacyConfig(thing(114)). +thingShort(114). +legacyConfig(thing(115)). +thingShort(115). +legacyConfig(thing(116)). +thingShort(116). +legacyConfig(thing(117)). +thingShort(117). +legacyConfig(thing(118)). +thingShort(118). +legacyConfig(thing(119)). +thingShort(119). +legacyConfig(thing(120)). +thingShort(120). +legacyConfig(thing(121)). +thingShort(121). +legacyConfig(thing(122)). +thingShort(122). +legacyConfig(thing(123)). +thingShort(123). +legacyConfig(thing(124)). +thingShort(124). +legacyConfig(thing(125)). +thingShort(125). +legacyConfig(thing(126)). +thingShort(126). +legacyConfig(thing(127)). +thingShort(127). +legacyConfig(thing(128)). +thingShort(128). +legacyConfig(thing(129)). +thingShort(129). +legacyConfig(thing(130)). +thingShort(130). +legacyConfig(thing(131)). +thingShort(131). +legacyConfig(thing(132)). +thingShort(132). +legacyConfig(thing(133)). +thingShort(133). +legacyConfig(thing(134)). +thingShort(134). +legacyConfig(thing(135)). +thingShort(135). +legacyConfig(thing(136)). +thingShort(136). +legacyConfig(thing(137)). +thingShort(137). +legacyConfig(thing(138)). +thingShort(138). +legacyConfig(thing(139)). +thingShort(139). +legacyConfig(thing(140)). +thingShort(140). +legacyConfig(thing(141)). +thingShort(141). +legacyConfig(thing(142)). +thingShort(142). +legacyConfig(thing(143)). +thingShort(143). +legacyConfig(thing(144)). +thingShort(144). +legacyConfig(thing(145)). +thingShort(145). +legacyConfig(thing(146)). +thingShort(146). +legacyConfig(thing(147)). +thingShort(147). +legacyConfig(thing(148)). +thingShort(148). +legacyConfig(thing(149)). +thingShort(149). +legacyConfig(thing(150)). +thingShort(150). +legacyConfig(thing(151)). +thingShort(151). +legacyConfig(thing(152)). +thingShort(152). +legacyConfig(thing(153)). +thingShort(153). +legacyConfig(thing(154)). +thingShort(154). +legacyConfig(thing(155)). +thingShort(155). +legacyConfig(thing(156)). +thingShort(156). +legacyConfig(thing(157)). +thingShort(157). +legacyConfig(thing(158)). +thingShort(158). +legacyConfig(thing(159)). +thingShort(159). +legacyConfig(thing(160)). +thingShort(160). +legacyConfig(thing(161)). +thingShort(161). +legacyConfig(thing(162)). +thingShort(162). +legacyConfig(thing(163)). +thingShort(163). +legacyConfig(thing(164)). +thingShort(164). +legacyConfig(thing(165)). +thingShort(165). +legacyConfig(thing(166)). +thingShort(166). +legacyConfig(thing(167)). +thingShort(167). +legacyConfig(thing(168)). +thingShort(168). +legacyConfig(thing(169)). +thingShort(169). +legacyConfig(thing(170)). +thingShort(170). +legacyConfig(thing(171)). +thingShort(171). +legacyConfig(thing(172)). +thingShort(172). +legacyConfig(thing(173)). +thingShort(173). +legacyConfig(thing(174)). +thingShort(174). +legacyConfig(thing(175)). +thingShort(175). +legacyConfig(thing(176)). +thingShort(176). +legacyConfig(thing(177)). +thingShort(177). +legacyConfig(thing(178)). +thingShort(178). +legacyConfig(thing(179)). +thingShort(179). +legacyConfig(thing(180)). +thingShort(180). +legacyConfig(thing(181)). +thingShort(181). +legacyConfig(thing(182)). +thingShort(182). +legacyConfig(thing(183)). +thingShort(183). +legacyConfig(thing(184)). +thingShort(184). +legacyConfig(thing(185)). +thingShort(185). +legacyConfig(thing(186)). +thingShort(186). +legacyConfig(thing(187)). +thingShort(187). +legacyConfig(thing(188)). +thingShort(188). +legacyConfig(thing(189)). +thingShort(189). +legacyConfig(thing(190)). +thingShort(190). +legacyConfig(thing(191)). +thingShort(191). +legacyConfig(thing(192)). +thingShort(192). +legacyConfig(thing(193)). +thingShort(193). +legacyConfig(thing(194)). +thingShort(194). +legacyConfig(thing(195)). +thingShort(195). +legacyConfig(thing(196)). +thingShort(196). +legacyConfig(thing(197)). +thingShort(197). +legacyConfig(thing(198)). +thingShort(198). +legacyConfig(thing(199)). +thingShort(199). +legacyConfig(thing(200)). +thingShort(200). +legacyConfig(thing(201)). +thingShort(201). +legacyConfig(thing(202)). +thingShort(202). +legacyConfig(thing(203)). +thingShort(203). +legacyConfig(thing(204)). +thingShort(204). +legacyConfig(thing(205)). +thingShort(205). +legacyConfig(thing(206)). +thingShort(206). +legacyConfig(thing(207)). +thingShort(207). +legacyConfig(thing(208)). +thingShort(208). +legacyConfig(thing(209)). +thingShort(209). +legacyConfig(thing(210)). +thingShort(210). +legacyConfig(thing(211)). +thingShort(211). +legacyConfig(thing(212)). +thingShort(212). +legacyConfig(thing(213)). +thingShort(213). +legacyConfig(thing(214)). +thingShort(214). +legacyConfig(thing(215)). +thingShort(215). +legacyConfig(thing(216)). +thingShort(216). +legacyConfig(thing(217)). +thingShort(217). +legacyConfig(thing(218)). +thingShort(218). +legacyConfig(thing(219)). +thingShort(219). +legacyConfig(thing(220)). +thingShort(220). +legacyConfig(thing(221)). +thingShort(221). +legacyConfig(thing(222)). +thingShort(222). +legacyConfig(thing(223)). +thingShort(223). +legacyConfig(thing(224)). +thingShort(224). +legacyConfig(thing(225)). +thingShort(225). +legacyConfig(thing(226)). +thingShort(226). +legacyConfig(thing(227)). +thingShort(227). +legacyConfig(thing(228)). +thingShort(228). +legacyConfig(thing(229)). +thingShort(229). +legacyConfig(thing(230)). +thingShort(230). +legacyConfig(thing(231)). +thingShort(231). +legacyConfig(thing(232)). +thingShort(232). +legacyConfig(thing(233)). +thingShort(233). +legacyConfig(thing(234)). +thingShort(234). +legacyConfig(thing(235)). +thingShort(235). +legacyConfig(thing(236)). +thingShort(236). +legacyConfig(thing(237)). +thingShort(237). +legacyConfig(thing(238)). +thingShort(238). +legacyConfig(thing(239)). +thingShort(239). +legacyConfig(thing(240)). +thingShort(240). +legacyConfig(thing(241)). +thingShort(241). +legacyConfig(thing(242)). +thingShort(242). +legacyConfig(thing(243)). +thingShort(243). +legacyConfig(thing(244)). +thingShort(244). +legacyConfig(thing(245)). +thingShort(245). +legacyConfig(thing(246)). +thingShort(246). +legacyConfig(thing(247)). +thingShort(247). +legacyConfig(thing(248)). +thingShort(248). +legacyConfig(thing(249)). +thingShort(249). +legacyConfig(thing(250)). +thingShort(250). +legacyConfig(thing(251)). +thingShort(251). +legacyConfig(thing(252)). +thingShort(252). +legacyConfig(thing(253)). +thingShort(253). +legacyConfig(thing(254)). +thingShort(254). +legacyConfig(thing(255)). +thingShort(255). +legacyConfig(thing(256)). +thingShort(256). +legacyConfig(thing(257)). +thingShort(257). +legacyConfig(thing(258)). +thingShort(258). +legacyConfig(thing(259)). +thingShort(259). +legacyConfig(thing(260)). +thingShort(260). +legacyConfig(thing(261)). +thingShort(261). +legacyConfig(thing(262)). +thingShort(262). +legacyConfig(thing(263)). +thingShort(263). +legacyConfig(thing(264)). +thingShort(264). +legacyConfig(thing(265)). +thingShort(265). +legacyConfig(thing(266)). +thingShort(266). +legacyConfig(thing(267)). +thingShort(267). +legacyConfig(thing(268)). +thingShort(268). +legacyConfig(thing(269)). +thingShort(269). +legacyConfig(thing(270)). +thingShort(270). +legacyConfig(thing(271)). +thingShort(271). +legacyConfig(thing(272)). +thingShort(272). +legacyConfig(thing(273)). +thingShort(273). +legacyConfig(thing(274)). +thingShort(274). +legacyConfig(thing(275)). +thingShort(275). +legacyConfig(thing(276)). +thingShort(276). +legacyConfig(thing(277)). +thingShort(277). +legacyConfig(thing(278)). +thingShort(278). +legacyConfig(thing(279)). +thingShort(279). +legacyConfig(thing(280)). +thingShort(280). +legacyConfig(thing(281)). +thingShort(281). +legacyConfig(thing(282)). +thingShort(282). +legacyConfig(thing(283)). +thingShort(283). +legacyConfig(thing(284)). +thingShort(284). +legacyConfig(thing(285)). +thingShort(285). +legacyConfig(thing(286)). +thingShort(286). +legacyConfig(thing(287)). +thingShort(287). +legacyConfig(thing(288)). +thingShort(288). +legacyConfig(thing(289)). +thingShort(289). +legacyConfig(thing(290)). +thingShort(290). +legacyConfig(thing(291)). +thingShort(291). +legacyConfig(thing(292)). +thingShort(292). +legacyConfig(thing(293)). +thingShort(293). +legacyConfig(thing(294)). +thingShort(294). +legacyConfig(thing(295)). +thingShort(295). +legacyConfig(thing(296)). +thingShort(296). +legacyConfig(thing(297)). +thingShort(297). +legacyConfig(thing(298)). +thingShort(298). +legacyConfig(thing(299)). +thingShort(299). +legacyConfig(thing(300)). +thingShort(300). +legacyConfig(thing(301)). +thingShort(301). +legacyConfig(thing(302)). +thingShort(302). +legacyConfig(thing(303)). +thingShort(303). +legacyConfig(thing(304)). +thingShort(304). +legacyConfig(thing(305)). +thingShort(305). +legacyConfig(thing(306)). +thingShort(306). +legacyConfig(thing(307)). +thingShort(307). +legacyConfig(thing(308)). +thingShort(308). +legacyConfig(thing(309)). +thingShort(309). +legacyConfig(thing(310)). +thingShort(310). +legacyConfig(thing(311)). +thingShort(311). +legacyConfig(thing(312)). +thingShort(312). +legacyConfig(thing(313)). +thingShort(313). +legacyConfig(thing(314)). +thingShort(314). +legacyConfig(thing(315)). +thingShort(315). +legacyConfig(thing(316)). +thingShort(316). +legacyConfig(thing(317)). +thingShort(317). +legacyConfig(thing(318)). +thingShort(318). +legacyConfig(thing(319)). +thingShort(319). +legacyConfig(thing(320)). +thingShort(320). +legacyConfig(thing(321)). +thingShort(321). +legacyConfig(thing(322)). +thingShort(322). +legacyConfig(thing(323)). +thingShort(323). +legacyConfig(thing(324)). +thingShort(324). +legacyConfig(thing(325)). +thingShort(325). +legacyConfig(thing(326)). +thingShort(326). +legacyConfig(thing(327)). +thingShort(327). +legacyConfig(thing(328)). +thingShort(328). +legacyConfig(thing(329)). +thingShort(329). +legacyConfig(thing(330)). +thingShort(330). +legacyConfig(thing(331)). +thingShort(331). +legacyConfig(thing(332)). +thingShort(332). +legacyConfig(thing(333)). +thingShort(333). +legacyConfig(thing(334)). +thingShort(334). +legacyConfig(thing(335)). +thingShort(335). +legacyConfig(thing(336)). +thingShort(336). +legacyConfig(thing(337)). +thingShort(337). +legacyConfig(thing(338)). +thingShort(338). +legacyConfig(thing(339)). +thingShort(339). +legacyConfig(thing(340)). +thingShort(340). +legacyConfig(thing(341)). +thingShort(341). +legacyConfig(thing(342)). +thingShort(342). +legacyConfig(thing(343)). +thingShort(343). +legacyConfig(thing(344)). +thingShort(344). +legacyConfig(thing(345)). +thingShort(345). +legacyConfig(thing(346)). +thingShort(346). +legacyConfig(thing(347)). +thingShort(347). +legacyConfig(thing(348)). +thingShort(348). +legacyConfig(thing(349)). +thingShort(349). +legacyConfig(thing(350)). +thingShort(350). +legacyConfig(thing(351)). +thingShort(351). +legacyConfig(thing(352)). +thingShort(352). +legacyConfig(thing(353)). +thingShort(353). +legacyConfig(thing(354)). +thingShort(354). +legacyConfig(thing(355)). +thingShort(355). +legacyConfig(thing(356)). +thingShort(356). +legacyConfig(thing(357)). +thingShort(357). +legacyConfig(thing(358)). +thingShort(358). +legacyConfig(thing(359)). +thingShort(359). +legacyConfig(thing(360)). +thingShort(360). +legacyConfig(thing(361)). +thingShort(361). +legacyConfig(thing(362)). +thingShort(362). +legacyConfig(thing(363)). +thingShort(363). +legacyConfig(thing(364)). +thingShort(364). +legacyConfig(thing(365)). +thingShort(365). +legacyConfig(thing(366)). +thingShort(366). +legacyConfig(thing(367)). +thingShort(367). +legacyConfig(thing(368)). +thingShort(368). +legacyConfig(thing(369)). +thingShort(369). +legacyConfig(thing(370)). +thingShort(370). +legacyConfig(thing(371)). +thingShort(371). +legacyConfig(thing(372)). +thingShort(372). +legacyConfig(thing(373)). +thingShort(373). +legacyConfig(thing(374)). +thingShort(374). +legacyConfig(thing(375)). +thingShort(375). +legacyConfig(thing(376)). +thingShort(376). +legacyConfig(thing(377)). +thingShort(377). +legacyConfig(thing(378)). +thingShort(378). +legacyConfig(thing(379)). +thingShort(379). +legacyConfig(thing(380)). +thingShort(380). +legacyConfig(thing(381)). +thingShort(381). +legacyConfig(thing(382)). +thingShort(382). +legacyConfig(thing(383)). +thingShort(383). +legacyConfig(thing(384)). +thingShort(384). +legacyConfig(thing(385)). +thingShort(385). +legacyConfig(thing(386)). +thingShort(386). +legacyConfig(thing(387)). +thingShort(387). +legacyConfig(thing(388)). +thingShort(388). +legacyConfig(thing(389)). +thingShort(389). +legacyConfig(thing(390)). +thingShort(390). +legacyConfig(thing(391)). +thingShort(391). +legacyConfig(thing(392)). +thingShort(392). +legacyConfig(thing(393)). +thingShort(393). +legacyConfig(thing(394)). +thingShort(394). +legacyConfig(thing(395)). +thingShort(395). +legacyConfig(thing(396)). +thingShort(396). +legacyConfig(thing(397)). +thingShort(397). +legacyConfig(thing(398)). +thingShort(398). +legacyConfig(thing(399)). +thingShort(399). +legacyConfig(thing(400)). +thingShort(400). +legacyConfig(thing(401)). +thingShort(401). +legacyConfig(thing(402)). +thingShort(402). +legacyConfig(thing(403)). +thingShort(403). +legacyConfig(thing(404)). +thingShort(404). +legacyConfig(thing(405)). +thingShort(405). +legacyConfig(thing(406)). +thingShort(406). +legacyConfig(thing(407)). +thingShort(407). +legacyConfig(thing(408)). +thingShort(408). +legacyConfig(thing(409)). +thingShort(409). +legacyConfig(thing(410)). +thingShort(410). +legacyConfig(thing(411)). +thingShort(411). +legacyConfig(thing(412)). +thingShort(412). +legacyConfig(thing(413)). +thingShort(413). +legacyConfig(thing(414)). +thingShort(414). +legacyConfig(thing(415)). +thingShort(415). +legacyConfig(thing(416)). +thingShort(416). +legacyConfig(thing(417)). +thingShort(417). +legacyConfig(thing(418)). +thingShort(418). +legacyConfig(thing(419)). +thingShort(419). +legacyConfig(thing(420)). +thingShort(420). +legacyConfig(personTOthing(1,71)). +legacyConfig(personTOthing(1,72)). +legacyConfig(personTOthing(1,73)). +legacyConfig(personTOthing(1,74)). +legacyConfig(personTOthing(1,75)). +legacyConfig(personTOthing(2,76)). +legacyConfig(personTOthing(2,77)). +legacyConfig(personTOthing(2,78)). +legacyConfig(personTOthing(2,79)). +legacyConfig(personTOthing(2,80)). +legacyConfig(personTOthing(3,81)). +legacyConfig(personTOthing(3,82)). +legacyConfig(personTOthing(3,83)). +legacyConfig(personTOthing(3,84)). +legacyConfig(personTOthing(3,85)). +legacyConfig(personTOthing(4,86)). +legacyConfig(personTOthing(4,87)). +legacyConfig(personTOthing(4,88)). +legacyConfig(personTOthing(4,89)). +legacyConfig(personTOthing(4,90)). +legacyConfig(personTOthing(5,91)). +legacyConfig(personTOthing(5,92)). +legacyConfig(personTOthing(5,93)). +legacyConfig(personTOthing(5,94)). +legacyConfig(personTOthing(5,95)). +legacyConfig(personTOthing(6,96)). +legacyConfig(personTOthing(6,97)). +legacyConfig(personTOthing(6,98)). +legacyConfig(personTOthing(6,99)). +legacyConfig(personTOthing(6,100)). +legacyConfig(personTOthing(7,101)). +legacyConfig(personTOthing(7,102)). +legacyConfig(personTOthing(7,103)). +legacyConfig(personTOthing(7,104)). +legacyConfig(personTOthing(7,105)). +legacyConfig(personTOthing(8,106)). +legacyConfig(personTOthing(8,107)). +legacyConfig(personTOthing(8,108)). +legacyConfig(personTOthing(8,109)). +legacyConfig(personTOthing(8,110)). +legacyConfig(personTOthing(9,111)). +legacyConfig(personTOthing(9,112)). +legacyConfig(personTOthing(9,113)). +legacyConfig(personTOthing(9,114)). +legacyConfig(personTOthing(9,115)). +legacyConfig(personTOthing(10,116)). +legacyConfig(personTOthing(10,117)). +legacyConfig(personTOthing(10,118)). +legacyConfig(personTOthing(10,119)). +legacyConfig(personTOthing(10,120)). +legacyConfig(personTOthing(11,121)). +legacyConfig(personTOthing(11,122)). +legacyConfig(personTOthing(11,123)). +legacyConfig(personTOthing(11,124)). +legacyConfig(personTOthing(11,125)). +legacyConfig(personTOthing(12,126)). +legacyConfig(personTOthing(12,127)). +legacyConfig(personTOthing(12,128)). +legacyConfig(personTOthing(12,129)). +legacyConfig(personTOthing(12,130)). +legacyConfig(personTOthing(13,131)). +legacyConfig(personTOthing(13,132)). +legacyConfig(personTOthing(13,133)). +legacyConfig(personTOthing(13,134)). +legacyConfig(personTOthing(13,135)). +legacyConfig(personTOthing(14,136)). +legacyConfig(personTOthing(14,137)). +legacyConfig(personTOthing(14,138)). +legacyConfig(personTOthing(14,139)). +legacyConfig(personTOthing(14,140)). +legacyConfig(personTOthing(15,141)). +legacyConfig(personTOthing(15,142)). +legacyConfig(personTOthing(15,143)). +legacyConfig(personTOthing(15,144)). +legacyConfig(personTOthing(15,145)). +legacyConfig(personTOthing(16,146)). +legacyConfig(personTOthing(16,147)). +legacyConfig(personTOthing(16,148)). +legacyConfig(personTOthing(16,149)). +legacyConfig(personTOthing(16,150)). +legacyConfig(personTOthing(17,151)). +legacyConfig(personTOthing(17,152)). +legacyConfig(personTOthing(17,153)). +legacyConfig(personTOthing(17,154)). +legacyConfig(personTOthing(17,155)). +legacyConfig(personTOthing(18,156)). +legacyConfig(personTOthing(18,157)). +legacyConfig(personTOthing(18,158)). +legacyConfig(personTOthing(18,159)). +legacyConfig(personTOthing(18,160)). +legacyConfig(personTOthing(19,161)). +legacyConfig(personTOthing(19,162)). +legacyConfig(personTOthing(19,163)). +legacyConfig(personTOthing(19,164)). +legacyConfig(personTOthing(19,165)). +legacyConfig(personTOthing(20,166)). +legacyConfig(personTOthing(20,167)). +legacyConfig(personTOthing(20,168)). +legacyConfig(personTOthing(20,169)). +legacyConfig(personTOthing(20,170)). +legacyConfig(personTOthing(21,171)). +legacyConfig(personTOthing(21,172)). +legacyConfig(personTOthing(21,173)). +legacyConfig(personTOthing(21,174)). +legacyConfig(personTOthing(21,175)). +legacyConfig(personTOthing(22,176)). +legacyConfig(personTOthing(22,177)). +legacyConfig(personTOthing(22,178)). +legacyConfig(personTOthing(22,179)). +legacyConfig(personTOthing(22,180)). +legacyConfig(personTOthing(23,181)). +legacyConfig(personTOthing(23,182)). +legacyConfig(personTOthing(23,183)). +legacyConfig(personTOthing(23,184)). +legacyConfig(personTOthing(23,185)). +legacyConfig(personTOthing(24,186)). +legacyConfig(personTOthing(24,187)). +legacyConfig(personTOthing(24,188)). +legacyConfig(personTOthing(24,189)). +legacyConfig(personTOthing(24,190)). +legacyConfig(personTOthing(25,191)). +legacyConfig(personTOthing(25,192)). +legacyConfig(personTOthing(25,193)). +legacyConfig(personTOthing(25,194)). +legacyConfig(personTOthing(25,195)). +legacyConfig(personTOthing(26,196)). +legacyConfig(personTOthing(26,197)). +legacyConfig(personTOthing(26,198)). +legacyConfig(personTOthing(26,199)). +legacyConfig(personTOthing(26,200)). +legacyConfig(personTOthing(27,201)). +legacyConfig(personTOthing(27,202)). +legacyConfig(personTOthing(27,203)). +legacyConfig(personTOthing(27,204)). +legacyConfig(personTOthing(27,205)). +legacyConfig(personTOthing(28,206)). +legacyConfig(personTOthing(28,207)). +legacyConfig(personTOthing(28,208)). +legacyConfig(personTOthing(28,209)). +legacyConfig(personTOthing(28,210)). +legacyConfig(personTOthing(29,211)). +legacyConfig(personTOthing(29,212)). +legacyConfig(personTOthing(29,213)). +legacyConfig(personTOthing(29,214)). +legacyConfig(personTOthing(29,215)). +legacyConfig(personTOthing(30,216)). +legacyConfig(personTOthing(30,217)). +legacyConfig(personTOthing(30,218)). +legacyConfig(personTOthing(30,219)). +legacyConfig(personTOthing(30,220)). +legacyConfig(personTOthing(31,221)). +legacyConfig(personTOthing(31,222)). +legacyConfig(personTOthing(31,223)). +legacyConfig(personTOthing(31,224)). +legacyConfig(personTOthing(31,225)). +legacyConfig(personTOthing(32,226)). +legacyConfig(personTOthing(32,227)). +legacyConfig(personTOthing(32,228)). +legacyConfig(personTOthing(32,229)). +legacyConfig(personTOthing(32,230)). +legacyConfig(personTOthing(33,231)). +legacyConfig(personTOthing(33,232)). +legacyConfig(personTOthing(33,233)). +legacyConfig(personTOthing(33,234)). +legacyConfig(personTOthing(33,235)). +legacyConfig(personTOthing(34,236)). +legacyConfig(personTOthing(34,237)). +legacyConfig(personTOthing(34,238)). +legacyConfig(personTOthing(34,239)). +legacyConfig(personTOthing(34,240)). +legacyConfig(personTOthing(35,241)). +legacyConfig(personTOthing(35,242)). +legacyConfig(personTOthing(35,243)). +legacyConfig(personTOthing(35,244)). +legacyConfig(personTOthing(35,245)). +legacyConfig(personTOthing(36,246)). +legacyConfig(personTOthing(36,247)). +legacyConfig(personTOthing(36,248)). +legacyConfig(personTOthing(36,249)). +legacyConfig(personTOthing(36,250)). +legacyConfig(personTOthing(37,251)). +legacyConfig(personTOthing(37,252)). +legacyConfig(personTOthing(37,253)). +legacyConfig(personTOthing(37,254)). +legacyConfig(personTOthing(37,255)). +legacyConfig(personTOthing(38,256)). +legacyConfig(personTOthing(38,257)). +legacyConfig(personTOthing(38,258)). +legacyConfig(personTOthing(38,259)). +legacyConfig(personTOthing(38,260)). +legacyConfig(personTOthing(39,261)). +legacyConfig(personTOthing(39,262)). +legacyConfig(personTOthing(39,263)). +legacyConfig(personTOthing(39,264)). +legacyConfig(personTOthing(39,265)). +legacyConfig(personTOthing(40,266)). +legacyConfig(personTOthing(40,267)). +legacyConfig(personTOthing(40,268)). +legacyConfig(personTOthing(40,269)). +legacyConfig(personTOthing(40,270)). +legacyConfig(personTOthing(41,271)). +legacyConfig(personTOthing(41,272)). +legacyConfig(personTOthing(41,273)). +legacyConfig(personTOthing(41,274)). +legacyConfig(personTOthing(41,275)). +legacyConfig(personTOthing(42,276)). +legacyConfig(personTOthing(42,277)). +legacyConfig(personTOthing(42,278)). +legacyConfig(personTOthing(42,279)). +legacyConfig(personTOthing(42,280)). +legacyConfig(personTOthing(43,281)). +legacyConfig(personTOthing(43,282)). +legacyConfig(personTOthing(43,283)). +legacyConfig(personTOthing(43,284)). +legacyConfig(personTOthing(43,285)). +legacyConfig(personTOthing(44,286)). +legacyConfig(personTOthing(44,287)). +legacyConfig(personTOthing(44,288)). +legacyConfig(personTOthing(44,289)). +legacyConfig(personTOthing(44,290)). +legacyConfig(personTOthing(45,291)). +legacyConfig(personTOthing(45,292)). +legacyConfig(personTOthing(45,293)). +legacyConfig(personTOthing(45,294)). +legacyConfig(personTOthing(45,295)). +legacyConfig(personTOthing(46,296)). +legacyConfig(personTOthing(46,297)). +legacyConfig(personTOthing(46,298)). +legacyConfig(personTOthing(46,299)). +legacyConfig(personTOthing(46,300)). +legacyConfig(personTOthing(47,301)). +legacyConfig(personTOthing(47,302)). +legacyConfig(personTOthing(47,303)). +legacyConfig(personTOthing(47,304)). +legacyConfig(personTOthing(47,305)). +legacyConfig(personTOthing(48,306)). +legacyConfig(personTOthing(48,307)). +legacyConfig(personTOthing(48,308)). +legacyConfig(personTOthing(48,309)). +legacyConfig(personTOthing(48,310)). +legacyConfig(personTOthing(49,311)). +legacyConfig(personTOthing(49,312)). +legacyConfig(personTOthing(49,313)). +legacyConfig(personTOthing(49,314)). +legacyConfig(personTOthing(49,315)). +legacyConfig(personTOthing(50,316)). +legacyConfig(personTOthing(50,317)). +legacyConfig(personTOthing(50,318)). +legacyConfig(personTOthing(50,319)). +legacyConfig(personTOthing(50,320)). +legacyConfig(personTOthing(51,321)). +legacyConfig(personTOthing(51,322)). +legacyConfig(personTOthing(51,323)). +legacyConfig(personTOthing(51,324)). +legacyConfig(personTOthing(51,325)). +legacyConfig(personTOthing(52,326)). +legacyConfig(personTOthing(52,327)). +legacyConfig(personTOthing(52,328)). +legacyConfig(personTOthing(52,329)). +legacyConfig(personTOthing(52,330)). +legacyConfig(personTOthing(53,331)). +legacyConfig(personTOthing(53,332)). +legacyConfig(personTOthing(53,333)). +legacyConfig(personTOthing(53,334)). +legacyConfig(personTOthing(53,335)). +legacyConfig(personTOthing(54,336)). +legacyConfig(personTOthing(54,337)). +legacyConfig(personTOthing(54,338)). +legacyConfig(personTOthing(54,339)). +legacyConfig(personTOthing(54,340)). +legacyConfig(personTOthing(55,341)). +legacyConfig(personTOthing(55,342)). +legacyConfig(personTOthing(55,343)). +legacyConfig(personTOthing(55,344)). +legacyConfig(personTOthing(55,345)). +legacyConfig(personTOthing(56,346)). +legacyConfig(personTOthing(56,347)). +legacyConfig(personTOthing(56,348)). +legacyConfig(personTOthing(56,349)). +legacyConfig(personTOthing(56,350)). +legacyConfig(personTOthing(57,351)). +legacyConfig(personTOthing(57,352)). +legacyConfig(personTOthing(57,353)). +legacyConfig(personTOthing(57,354)). +legacyConfig(personTOthing(57,355)). +legacyConfig(personTOthing(58,356)). +legacyConfig(personTOthing(58,357)). +legacyConfig(personTOthing(58,358)). +legacyConfig(personTOthing(58,359)). +legacyConfig(personTOthing(58,360)). +legacyConfig(personTOthing(59,361)). +legacyConfig(personTOthing(59,362)). +legacyConfig(personTOthing(59,363)). +legacyConfig(personTOthing(59,364)). +legacyConfig(personTOthing(59,365)). +legacyConfig(personTOthing(60,366)). +legacyConfig(personTOthing(60,367)). +legacyConfig(personTOthing(60,368)). +legacyConfig(personTOthing(60,369)). +legacyConfig(personTOthing(60,370)). +legacyConfig(personTOthing(61,371)). +legacyConfig(personTOthing(61,372)). +legacyConfig(personTOthing(61,373)). +legacyConfig(personTOthing(61,374)). +legacyConfig(personTOthing(61,375)). +legacyConfig(personTOthing(62,376)). +legacyConfig(personTOthing(62,377)). +legacyConfig(personTOthing(62,378)). +legacyConfig(personTOthing(62,379)). +legacyConfig(personTOthing(62,380)). +legacyConfig(personTOthing(63,381)). +legacyConfig(personTOthing(63,382)). +legacyConfig(personTOthing(63,383)). +legacyConfig(personTOthing(63,384)). +legacyConfig(personTOthing(63,385)). +legacyConfig(personTOthing(64,386)). +legacyConfig(personTOthing(64,387)). +legacyConfig(personTOthing(64,388)). +legacyConfig(personTOthing(64,389)). +legacyConfig(personTOthing(64,390)). +legacyConfig(personTOthing(65,391)). +legacyConfig(personTOthing(65,392)). +legacyConfig(personTOthing(65,393)). +legacyConfig(personTOthing(65,394)). +legacyConfig(personTOthing(65,395)). +legacyConfig(personTOthing(66,396)). +legacyConfig(personTOthing(66,397)). +legacyConfig(personTOthing(66,398)). +legacyConfig(personTOthing(66,399)). +legacyConfig(personTOthing(66,400)). +legacyConfig(personTOthing(67,401)). +legacyConfig(personTOthing(67,402)). +legacyConfig(personTOthing(67,403)). +legacyConfig(personTOthing(67,404)). +legacyConfig(personTOthing(67,405)). +legacyConfig(personTOthing(68,406)). +legacyConfig(personTOthing(68,407)). +legacyConfig(personTOthing(68,408)). +legacyConfig(personTOthing(68,409)). +legacyConfig(personTOthing(68,410)). +legacyConfig(personTOthing(69,411)). +legacyConfig(personTOthing(69,412)). +legacyConfig(personTOthing(69,413)). +legacyConfig(personTOthing(69,414)). +legacyConfig(personTOthing(69,415)). +legacyConfig(personTOthing(70,416)). +legacyConfig(personTOthing(70,417)). +legacyConfig(personTOthing(70,418)). +legacyConfig(personTOthing(70,419)). +legacyConfig(personTOthing(70,420)). +% domains +cabinetDomainNew(500..849). +roomDomainNew(1000..1349). +cabinetUpper(350). +roomUpper(350). +cabinetLower(70). +roomLower(18). +% reuse costs +reuseCabinetTOthingCost(0). +reuseRoomTOcabinetCost(0). +reusePersonTOroomCost(0). +reuseCabinetAsHighCost(3). +reuseCabinetAsSmallCost(0). +reuseRoomCost(0). +% remove costs +removeCabinetTOthingCost(2). +removeRoomTOcabinetCost(2). +removePersonTOroomCost(2). +removeCabinetCost(2). +removeRoomCost(2). +% create costs +cabinetHighCost(100). +cabinetSmallCost(1). +roomCost(5). diff --git a/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p75t375.edb b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p75t375.edb new file mode 100644 index 000000000..a1b13d2e5 --- /dev/null +++ b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p75t375.edb @@ -0,0 +1,1224 @@ +legacyConfig(person(1)). +legacyConfig(person(2)). +legacyConfig(person(3)). +legacyConfig(person(4)). +legacyConfig(person(5)). +legacyConfig(person(6)). +legacyConfig(person(7)). +legacyConfig(person(8)). +legacyConfig(person(9)). +legacyConfig(person(10)). +legacyConfig(person(11)). +legacyConfig(person(12)). +legacyConfig(person(13)). +legacyConfig(person(14)). +legacyConfig(person(15)). +legacyConfig(person(16)). +legacyConfig(person(17)). +legacyConfig(person(18)). +legacyConfig(person(19)). +legacyConfig(person(20)). +legacyConfig(person(21)). +legacyConfig(person(22)). +legacyConfig(person(23)). +legacyConfig(person(24)). +legacyConfig(person(25)). +legacyConfig(person(26)). +legacyConfig(person(27)). +legacyConfig(person(28)). +legacyConfig(person(29)). +legacyConfig(person(30)). +legacyConfig(person(31)). +legacyConfig(person(32)). +legacyConfig(person(33)). +legacyConfig(person(34)). +legacyConfig(person(35)). +legacyConfig(person(36)). +legacyConfig(person(37)). +legacyConfig(person(38)). +legacyConfig(person(39)). +legacyConfig(person(40)). +legacyConfig(person(41)). +legacyConfig(person(42)). +legacyConfig(person(43)). +legacyConfig(person(44)). +legacyConfig(person(45)). +legacyConfig(person(46)). +legacyConfig(person(47)). +legacyConfig(person(48)). +legacyConfig(person(49)). +legacyConfig(person(50)). +legacyConfig(person(51)). +legacyConfig(person(52)). +legacyConfig(person(53)). +legacyConfig(person(54)). +legacyConfig(person(55)). +legacyConfig(person(56)). +legacyConfig(person(57)). +legacyConfig(person(58)). +legacyConfig(person(59)). +legacyConfig(person(60)). +legacyConfig(person(61)). +legacyConfig(person(62)). +legacyConfig(person(63)). +legacyConfig(person(64)). +legacyConfig(person(65)). +legacyConfig(person(66)). +legacyConfig(person(67)). +legacyConfig(person(68)). +legacyConfig(person(69)). +legacyConfig(person(70)). +legacyConfig(person(71)). +legacyConfig(person(72)). +legacyConfig(person(73)). +legacyConfig(person(74)). +legacyConfig(person(75)). +legacyConfig(thing(76)). +thingShort(76). +legacyConfig(thing(77)). +thingShort(77). +legacyConfig(thing(78)). +thingShort(78). +legacyConfig(thing(79)). +thingShort(79). +legacyConfig(thing(80)). +thingShort(80). +legacyConfig(thing(81)). +thingShort(81). +legacyConfig(thing(82)). +thingShort(82). +legacyConfig(thing(83)). +thingShort(83). +legacyConfig(thing(84)). +thingShort(84). +legacyConfig(thing(85)). +thingShort(85). +legacyConfig(thing(86)). +thingShort(86). +legacyConfig(thing(87)). +thingShort(87). +legacyConfig(thing(88)). +thingShort(88). +legacyConfig(thing(89)). +thingShort(89). +legacyConfig(thing(90)). +thingShort(90). +legacyConfig(thing(91)). +thingShort(91). +legacyConfig(thing(92)). +thingShort(92). +legacyConfig(thing(93)). +thingShort(93). +legacyConfig(thing(94)). +thingShort(94). +legacyConfig(thing(95)). +thingShort(95). +legacyConfig(thing(96)). +thingShort(96). +legacyConfig(thing(97)). +thingShort(97). +legacyConfig(thing(98)). +thingShort(98). +legacyConfig(thing(99)). +thingShort(99). +legacyConfig(thing(100)). +thingShort(100). +legacyConfig(thing(101)). +thingShort(101). +legacyConfig(thing(102)). +thingShort(102). +legacyConfig(thing(103)). +thingShort(103). +legacyConfig(thing(104)). +thingShort(104). +legacyConfig(thing(105)). +thingShort(105). +legacyConfig(thing(106)). +thingShort(106). +legacyConfig(thing(107)). +thingShort(107). +legacyConfig(thing(108)). +thingShort(108). +legacyConfig(thing(109)). +thingShort(109). +legacyConfig(thing(110)). +thingShort(110). +legacyConfig(thing(111)). +thingShort(111). +legacyConfig(thing(112)). +thingShort(112). +legacyConfig(thing(113)). +thingShort(113). +legacyConfig(thing(114)). +thingShort(114). +legacyConfig(thing(115)). +thingShort(115). +legacyConfig(thing(116)). +thingShort(116). +legacyConfig(thing(117)). +thingShort(117). +legacyConfig(thing(118)). +thingShort(118). +legacyConfig(thing(119)). +thingShort(119). +legacyConfig(thing(120)). +thingShort(120). +legacyConfig(thing(121)). +thingShort(121). +legacyConfig(thing(122)). +thingShort(122). +legacyConfig(thing(123)). +thingShort(123). +legacyConfig(thing(124)). +thingShort(124). +legacyConfig(thing(125)). +thingShort(125). +legacyConfig(thing(126)). +thingShort(126). +legacyConfig(thing(127)). +thingShort(127). +legacyConfig(thing(128)). +thingShort(128). +legacyConfig(thing(129)). +thingShort(129). +legacyConfig(thing(130)). +thingShort(130). +legacyConfig(thing(131)). +thingShort(131). +legacyConfig(thing(132)). +thingShort(132). +legacyConfig(thing(133)). +thingShort(133). +legacyConfig(thing(134)). +thingShort(134). +legacyConfig(thing(135)). +thingShort(135). +legacyConfig(thing(136)). +thingShort(136). +legacyConfig(thing(137)). +thingShort(137). +legacyConfig(thing(138)). +thingShort(138). +legacyConfig(thing(139)). +thingShort(139). +legacyConfig(thing(140)). +thingShort(140). +legacyConfig(thing(141)). +thingShort(141). +legacyConfig(thing(142)). +thingShort(142). +legacyConfig(thing(143)). +thingShort(143). +legacyConfig(thing(144)). +thingShort(144). +legacyConfig(thing(145)). +thingShort(145). +legacyConfig(thing(146)). +thingShort(146). +legacyConfig(thing(147)). +thingShort(147). +legacyConfig(thing(148)). +thingShort(148). +legacyConfig(thing(149)). +thingShort(149). +legacyConfig(thing(150)). +thingShort(150). +legacyConfig(thing(151)). +thingShort(151). +legacyConfig(thing(152)). +thingShort(152). +legacyConfig(thing(153)). +thingShort(153). +legacyConfig(thing(154)). +thingShort(154). +legacyConfig(thing(155)). +thingShort(155). +legacyConfig(thing(156)). +thingShort(156). +legacyConfig(thing(157)). +thingShort(157). +legacyConfig(thing(158)). +thingShort(158). +legacyConfig(thing(159)). +thingShort(159). +legacyConfig(thing(160)). +thingShort(160). +legacyConfig(thing(161)). +thingShort(161). +legacyConfig(thing(162)). +thingShort(162). +legacyConfig(thing(163)). +thingShort(163). +legacyConfig(thing(164)). +thingShort(164). +legacyConfig(thing(165)). +thingShort(165). +legacyConfig(thing(166)). +thingShort(166). +legacyConfig(thing(167)). +thingShort(167). +legacyConfig(thing(168)). +thingShort(168). +legacyConfig(thing(169)). +thingShort(169). +legacyConfig(thing(170)). +thingShort(170). +legacyConfig(thing(171)). +thingShort(171). +legacyConfig(thing(172)). +thingShort(172). +legacyConfig(thing(173)). +thingShort(173). +legacyConfig(thing(174)). +thingShort(174). +legacyConfig(thing(175)). +thingShort(175). +legacyConfig(thing(176)). +thingShort(176). +legacyConfig(thing(177)). +thingShort(177). +legacyConfig(thing(178)). +thingShort(178). +legacyConfig(thing(179)). +thingShort(179). +legacyConfig(thing(180)). +thingShort(180). +legacyConfig(thing(181)). +thingShort(181). +legacyConfig(thing(182)). +thingShort(182). +legacyConfig(thing(183)). +thingShort(183). +legacyConfig(thing(184)). +thingShort(184). +legacyConfig(thing(185)). +thingShort(185). +legacyConfig(thing(186)). +thingShort(186). +legacyConfig(thing(187)). +thingShort(187). +legacyConfig(thing(188)). +thingShort(188). +legacyConfig(thing(189)). +thingShort(189). +legacyConfig(thing(190)). +thingShort(190). +legacyConfig(thing(191)). +thingShort(191). +legacyConfig(thing(192)). +thingShort(192). +legacyConfig(thing(193)). +thingShort(193). +legacyConfig(thing(194)). +thingShort(194). +legacyConfig(thing(195)). +thingShort(195). +legacyConfig(thing(196)). +thingShort(196). +legacyConfig(thing(197)). +thingShort(197). +legacyConfig(thing(198)). +thingShort(198). +legacyConfig(thing(199)). +thingShort(199). +legacyConfig(thing(200)). +thingShort(200). +legacyConfig(thing(201)). +thingShort(201). +legacyConfig(thing(202)). +thingShort(202). +legacyConfig(thing(203)). +thingShort(203). +legacyConfig(thing(204)). +thingShort(204). +legacyConfig(thing(205)). +thingShort(205). +legacyConfig(thing(206)). +thingShort(206). +legacyConfig(thing(207)). +thingShort(207). +legacyConfig(thing(208)). +thingShort(208). +legacyConfig(thing(209)). +thingShort(209). +legacyConfig(thing(210)). +thingShort(210). +legacyConfig(thing(211)). +thingShort(211). +legacyConfig(thing(212)). +thingShort(212). +legacyConfig(thing(213)). +thingShort(213). +legacyConfig(thing(214)). +thingShort(214). +legacyConfig(thing(215)). +thingShort(215). +legacyConfig(thing(216)). +thingShort(216). +legacyConfig(thing(217)). +thingShort(217). +legacyConfig(thing(218)). +thingShort(218). +legacyConfig(thing(219)). +thingShort(219). +legacyConfig(thing(220)). +thingShort(220). +legacyConfig(thing(221)). +thingShort(221). +legacyConfig(thing(222)). +thingShort(222). +legacyConfig(thing(223)). +thingShort(223). +legacyConfig(thing(224)). +thingShort(224). +legacyConfig(thing(225)). +thingShort(225). +legacyConfig(thing(226)). +thingShort(226). +legacyConfig(thing(227)). +thingShort(227). +legacyConfig(thing(228)). +thingShort(228). +legacyConfig(thing(229)). +thingShort(229). +legacyConfig(thing(230)). +thingShort(230). +legacyConfig(thing(231)). +thingShort(231). +legacyConfig(thing(232)). +thingShort(232). +legacyConfig(thing(233)). +thingShort(233). +legacyConfig(thing(234)). +thingShort(234). +legacyConfig(thing(235)). +thingShort(235). +legacyConfig(thing(236)). +thingShort(236). +legacyConfig(thing(237)). +thingShort(237). +legacyConfig(thing(238)). +thingShort(238). +legacyConfig(thing(239)). +thingShort(239). +legacyConfig(thing(240)). +thingShort(240). +legacyConfig(thing(241)). +thingShort(241). +legacyConfig(thing(242)). +thingShort(242). +legacyConfig(thing(243)). +thingShort(243). +legacyConfig(thing(244)). +thingShort(244). +legacyConfig(thing(245)). +thingShort(245). +legacyConfig(thing(246)). +thingShort(246). +legacyConfig(thing(247)). +thingShort(247). +legacyConfig(thing(248)). +thingShort(248). +legacyConfig(thing(249)). +thingShort(249). +legacyConfig(thing(250)). +thingShort(250). +legacyConfig(thing(251)). +thingShort(251). +legacyConfig(thing(252)). +thingShort(252). +legacyConfig(thing(253)). +thingShort(253). +legacyConfig(thing(254)). +thingShort(254). +legacyConfig(thing(255)). +thingShort(255). +legacyConfig(thing(256)). +thingShort(256). +legacyConfig(thing(257)). +thingShort(257). +legacyConfig(thing(258)). +thingShort(258). +legacyConfig(thing(259)). +thingShort(259). +legacyConfig(thing(260)). +thingShort(260). +legacyConfig(thing(261)). +thingShort(261). +legacyConfig(thing(262)). +thingShort(262). +legacyConfig(thing(263)). +thingShort(263). +legacyConfig(thing(264)). +thingShort(264). +legacyConfig(thing(265)). +thingShort(265). +legacyConfig(thing(266)). +thingShort(266). +legacyConfig(thing(267)). +thingShort(267). +legacyConfig(thing(268)). +thingShort(268). +legacyConfig(thing(269)). +thingShort(269). +legacyConfig(thing(270)). +thingShort(270). +legacyConfig(thing(271)). +thingShort(271). +legacyConfig(thing(272)). +thingShort(272). +legacyConfig(thing(273)). +thingShort(273). +legacyConfig(thing(274)). +thingShort(274). +legacyConfig(thing(275)). +thingShort(275). +legacyConfig(thing(276)). +thingShort(276). +legacyConfig(thing(277)). +thingShort(277). +legacyConfig(thing(278)). +thingShort(278). +legacyConfig(thing(279)). +thingShort(279). +legacyConfig(thing(280)). +thingShort(280). +legacyConfig(thing(281)). +thingShort(281). +legacyConfig(thing(282)). +thingShort(282). +legacyConfig(thing(283)). +thingShort(283). +legacyConfig(thing(284)). +thingShort(284). +legacyConfig(thing(285)). +thingShort(285). +legacyConfig(thing(286)). +thingShort(286). +legacyConfig(thing(287)). +thingShort(287). +legacyConfig(thing(288)). +thingShort(288). +legacyConfig(thing(289)). +thingShort(289). +legacyConfig(thing(290)). +thingShort(290). +legacyConfig(thing(291)). +thingShort(291). +legacyConfig(thing(292)). +thingShort(292). +legacyConfig(thing(293)). +thingShort(293). +legacyConfig(thing(294)). +thingShort(294). +legacyConfig(thing(295)). +thingShort(295). +legacyConfig(thing(296)). +thingShort(296). +legacyConfig(thing(297)). +thingShort(297). +legacyConfig(thing(298)). +thingShort(298). +legacyConfig(thing(299)). +thingShort(299). +legacyConfig(thing(300)). +thingShort(300). +legacyConfig(thing(301)). +thingShort(301). +legacyConfig(thing(302)). +thingShort(302). +legacyConfig(thing(303)). +thingShort(303). +legacyConfig(thing(304)). +thingShort(304). +legacyConfig(thing(305)). +thingShort(305). +legacyConfig(thing(306)). +thingShort(306). +legacyConfig(thing(307)). +thingShort(307). +legacyConfig(thing(308)). +thingShort(308). +legacyConfig(thing(309)). +thingShort(309). +legacyConfig(thing(310)). +thingShort(310). +legacyConfig(thing(311)). +thingShort(311). +legacyConfig(thing(312)). +thingShort(312). +legacyConfig(thing(313)). +thingShort(313). +legacyConfig(thing(314)). +thingShort(314). +legacyConfig(thing(315)). +thingShort(315). +legacyConfig(thing(316)). +thingShort(316). +legacyConfig(thing(317)). +thingShort(317). +legacyConfig(thing(318)). +thingShort(318). +legacyConfig(thing(319)). +thingShort(319). +legacyConfig(thing(320)). +thingShort(320). +legacyConfig(thing(321)). +thingShort(321). +legacyConfig(thing(322)). +thingShort(322). +legacyConfig(thing(323)). +thingShort(323). +legacyConfig(thing(324)). +thingShort(324). +legacyConfig(thing(325)). +thingShort(325). +legacyConfig(thing(326)). +thingShort(326). +legacyConfig(thing(327)). +thingShort(327). +legacyConfig(thing(328)). +thingShort(328). +legacyConfig(thing(329)). +thingShort(329). +legacyConfig(thing(330)). +thingShort(330). +legacyConfig(thing(331)). +thingShort(331). +legacyConfig(thing(332)). +thingShort(332). +legacyConfig(thing(333)). +thingShort(333). +legacyConfig(thing(334)). +thingShort(334). +legacyConfig(thing(335)). +thingShort(335). +legacyConfig(thing(336)). +thingShort(336). +legacyConfig(thing(337)). +thingShort(337). +legacyConfig(thing(338)). +thingShort(338). +legacyConfig(thing(339)). +thingShort(339). +legacyConfig(thing(340)). +thingShort(340). +legacyConfig(thing(341)). +thingShort(341). +legacyConfig(thing(342)). +thingShort(342). +legacyConfig(thing(343)). +thingShort(343). +legacyConfig(thing(344)). +thingShort(344). +legacyConfig(thing(345)). +thingShort(345). +legacyConfig(thing(346)). +thingShort(346). +legacyConfig(thing(347)). +thingShort(347). +legacyConfig(thing(348)). +thingShort(348). +legacyConfig(thing(349)). +thingShort(349). +legacyConfig(thing(350)). +thingShort(350). +legacyConfig(thing(351)). +thingShort(351). +legacyConfig(thing(352)). +thingShort(352). +legacyConfig(thing(353)). +thingShort(353). +legacyConfig(thing(354)). +thingShort(354). +legacyConfig(thing(355)). +thingShort(355). +legacyConfig(thing(356)). +thingShort(356). +legacyConfig(thing(357)). +thingShort(357). +legacyConfig(thing(358)). +thingShort(358). +legacyConfig(thing(359)). +thingShort(359). +legacyConfig(thing(360)). +thingShort(360). +legacyConfig(thing(361)). +thingShort(361). +legacyConfig(thing(362)). +thingShort(362). +legacyConfig(thing(363)). +thingShort(363). +legacyConfig(thing(364)). +thingShort(364). +legacyConfig(thing(365)). +thingShort(365). +legacyConfig(thing(366)). +thingShort(366). +legacyConfig(thing(367)). +thingShort(367). +legacyConfig(thing(368)). +thingShort(368). +legacyConfig(thing(369)). +thingShort(369). +legacyConfig(thing(370)). +thingShort(370). +legacyConfig(thing(371)). +thingShort(371). +legacyConfig(thing(372)). +thingShort(372). +legacyConfig(thing(373)). +thingShort(373). +legacyConfig(thing(374)). +thingShort(374). +legacyConfig(thing(375)). +thingShort(375). +legacyConfig(thing(376)). +thingShort(376). +legacyConfig(thing(377)). +thingShort(377). +legacyConfig(thing(378)). +thingShort(378). +legacyConfig(thing(379)). +thingShort(379). +legacyConfig(thing(380)). +thingShort(380). +legacyConfig(thing(381)). +thingShort(381). +legacyConfig(thing(382)). +thingShort(382). +legacyConfig(thing(383)). +thingShort(383). +legacyConfig(thing(384)). +thingShort(384). +legacyConfig(thing(385)). +thingShort(385). +legacyConfig(thing(386)). +thingShort(386). +legacyConfig(thing(387)). +thingShort(387). +legacyConfig(thing(388)). +thingShort(388). +legacyConfig(thing(389)). +thingShort(389). +legacyConfig(thing(390)). +thingShort(390). +legacyConfig(thing(391)). +thingShort(391). +legacyConfig(thing(392)). +thingShort(392). +legacyConfig(thing(393)). +thingShort(393). +legacyConfig(thing(394)). +thingShort(394). +legacyConfig(thing(395)). +thingShort(395). +legacyConfig(thing(396)). +thingShort(396). +legacyConfig(thing(397)). +thingShort(397). +legacyConfig(thing(398)). +thingShort(398). +legacyConfig(thing(399)). +thingShort(399). +legacyConfig(thing(400)). +thingShort(400). +legacyConfig(thing(401)). +thingShort(401). +legacyConfig(thing(402)). +thingShort(402). +legacyConfig(thing(403)). +thingShort(403). +legacyConfig(thing(404)). +thingShort(404). +legacyConfig(thing(405)). +thingShort(405). +legacyConfig(thing(406)). +thingShort(406). +legacyConfig(thing(407)). +thingShort(407). +legacyConfig(thing(408)). +thingShort(408). +legacyConfig(thing(409)). +thingShort(409). +legacyConfig(thing(410)). +thingShort(410). +legacyConfig(thing(411)). +thingShort(411). +legacyConfig(thing(412)). +thingShort(412). +legacyConfig(thing(413)). +thingShort(413). +legacyConfig(thing(414)). +thingShort(414). +legacyConfig(thing(415)). +thingShort(415). +legacyConfig(thing(416)). +thingShort(416). +legacyConfig(thing(417)). +thingShort(417). +legacyConfig(thing(418)). +thingShort(418). +legacyConfig(thing(419)). +thingShort(419). +legacyConfig(thing(420)). +thingShort(420). +legacyConfig(thing(421)). +thingShort(421). +legacyConfig(thing(422)). +thingShort(422). +legacyConfig(thing(423)). +thingShort(423). +legacyConfig(thing(424)). +thingShort(424). +legacyConfig(thing(425)). +thingShort(425). +legacyConfig(thing(426)). +thingShort(426). +legacyConfig(thing(427)). +thingShort(427). +legacyConfig(thing(428)). +thingShort(428). +legacyConfig(thing(429)). +thingShort(429). +legacyConfig(thing(430)). +thingShort(430). +legacyConfig(thing(431)). +thingShort(431). +legacyConfig(thing(432)). +thingShort(432). +legacyConfig(thing(433)). +thingShort(433). +legacyConfig(thing(434)). +thingShort(434). +legacyConfig(thing(435)). +thingShort(435). +legacyConfig(thing(436)). +thingShort(436). +legacyConfig(thing(437)). +thingShort(437). +legacyConfig(thing(438)). +thingShort(438). +legacyConfig(thing(439)). +thingShort(439). +legacyConfig(thing(440)). +thingShort(440). +legacyConfig(thing(441)). +thingShort(441). +legacyConfig(thing(442)). +thingShort(442). +legacyConfig(thing(443)). +thingShort(443). +legacyConfig(thing(444)). +thingShort(444). +legacyConfig(thing(445)). +thingShort(445). +legacyConfig(thing(446)). +thingShort(446). +legacyConfig(thing(447)). +thingShort(447). +legacyConfig(thing(448)). +thingShort(448). +legacyConfig(thing(449)). +thingShort(449). +legacyConfig(thing(450)). +thingShort(450). +legacyConfig(personTOthing(1,76)). +legacyConfig(personTOthing(1,77)). +legacyConfig(personTOthing(1,78)). +legacyConfig(personTOthing(1,79)). +legacyConfig(personTOthing(1,80)). +legacyConfig(personTOthing(2,81)). +legacyConfig(personTOthing(2,82)). +legacyConfig(personTOthing(2,83)). +legacyConfig(personTOthing(2,84)). +legacyConfig(personTOthing(2,85)). +legacyConfig(personTOthing(3,86)). +legacyConfig(personTOthing(3,87)). +legacyConfig(personTOthing(3,88)). +legacyConfig(personTOthing(3,89)). +legacyConfig(personTOthing(3,90)). +legacyConfig(personTOthing(4,91)). +legacyConfig(personTOthing(4,92)). +legacyConfig(personTOthing(4,93)). +legacyConfig(personTOthing(4,94)). +legacyConfig(personTOthing(4,95)). +legacyConfig(personTOthing(5,96)). +legacyConfig(personTOthing(5,97)). +legacyConfig(personTOthing(5,98)). +legacyConfig(personTOthing(5,99)). +legacyConfig(personTOthing(5,100)). +legacyConfig(personTOthing(6,101)). +legacyConfig(personTOthing(6,102)). +legacyConfig(personTOthing(6,103)). +legacyConfig(personTOthing(6,104)). +legacyConfig(personTOthing(6,105)). +legacyConfig(personTOthing(7,106)). +legacyConfig(personTOthing(7,107)). +legacyConfig(personTOthing(7,108)). +legacyConfig(personTOthing(7,109)). +legacyConfig(personTOthing(7,110)). +legacyConfig(personTOthing(8,111)). +legacyConfig(personTOthing(8,112)). +legacyConfig(personTOthing(8,113)). +legacyConfig(personTOthing(8,114)). +legacyConfig(personTOthing(8,115)). +legacyConfig(personTOthing(9,116)). +legacyConfig(personTOthing(9,117)). +legacyConfig(personTOthing(9,118)). +legacyConfig(personTOthing(9,119)). +legacyConfig(personTOthing(9,120)). +legacyConfig(personTOthing(10,121)). +legacyConfig(personTOthing(10,122)). +legacyConfig(personTOthing(10,123)). +legacyConfig(personTOthing(10,124)). +legacyConfig(personTOthing(10,125)). +legacyConfig(personTOthing(11,126)). +legacyConfig(personTOthing(11,127)). +legacyConfig(personTOthing(11,128)). +legacyConfig(personTOthing(11,129)). +legacyConfig(personTOthing(11,130)). +legacyConfig(personTOthing(12,131)). +legacyConfig(personTOthing(12,132)). +legacyConfig(personTOthing(12,133)). +legacyConfig(personTOthing(12,134)). +legacyConfig(personTOthing(12,135)). +legacyConfig(personTOthing(13,136)). +legacyConfig(personTOthing(13,137)). +legacyConfig(personTOthing(13,138)). +legacyConfig(personTOthing(13,139)). +legacyConfig(personTOthing(13,140)). +legacyConfig(personTOthing(14,141)). +legacyConfig(personTOthing(14,142)). +legacyConfig(personTOthing(14,143)). +legacyConfig(personTOthing(14,144)). +legacyConfig(personTOthing(14,145)). +legacyConfig(personTOthing(15,146)). +legacyConfig(personTOthing(15,147)). +legacyConfig(personTOthing(15,148)). +legacyConfig(personTOthing(15,149)). +legacyConfig(personTOthing(15,150)). +legacyConfig(personTOthing(16,151)). +legacyConfig(personTOthing(16,152)). +legacyConfig(personTOthing(16,153)). +legacyConfig(personTOthing(16,154)). +legacyConfig(personTOthing(16,155)). +legacyConfig(personTOthing(17,156)). +legacyConfig(personTOthing(17,157)). +legacyConfig(personTOthing(17,158)). +legacyConfig(personTOthing(17,159)). +legacyConfig(personTOthing(17,160)). +legacyConfig(personTOthing(18,161)). +legacyConfig(personTOthing(18,162)). +legacyConfig(personTOthing(18,163)). +legacyConfig(personTOthing(18,164)). +legacyConfig(personTOthing(18,165)). +legacyConfig(personTOthing(19,166)). +legacyConfig(personTOthing(19,167)). +legacyConfig(personTOthing(19,168)). +legacyConfig(personTOthing(19,169)). +legacyConfig(personTOthing(19,170)). +legacyConfig(personTOthing(20,171)). +legacyConfig(personTOthing(20,172)). +legacyConfig(personTOthing(20,173)). +legacyConfig(personTOthing(20,174)). +legacyConfig(personTOthing(20,175)). +legacyConfig(personTOthing(21,176)). +legacyConfig(personTOthing(21,177)). +legacyConfig(personTOthing(21,178)). +legacyConfig(personTOthing(21,179)). +legacyConfig(personTOthing(21,180)). +legacyConfig(personTOthing(22,181)). +legacyConfig(personTOthing(22,182)). +legacyConfig(personTOthing(22,183)). +legacyConfig(personTOthing(22,184)). +legacyConfig(personTOthing(22,185)). +legacyConfig(personTOthing(23,186)). +legacyConfig(personTOthing(23,187)). +legacyConfig(personTOthing(23,188)). +legacyConfig(personTOthing(23,189)). +legacyConfig(personTOthing(23,190)). +legacyConfig(personTOthing(24,191)). +legacyConfig(personTOthing(24,192)). +legacyConfig(personTOthing(24,193)). +legacyConfig(personTOthing(24,194)). +legacyConfig(personTOthing(24,195)). +legacyConfig(personTOthing(25,196)). +legacyConfig(personTOthing(25,197)). +legacyConfig(personTOthing(25,198)). +legacyConfig(personTOthing(25,199)). +legacyConfig(personTOthing(25,200)). +legacyConfig(personTOthing(26,201)). +legacyConfig(personTOthing(26,202)). +legacyConfig(personTOthing(26,203)). +legacyConfig(personTOthing(26,204)). +legacyConfig(personTOthing(26,205)). +legacyConfig(personTOthing(27,206)). +legacyConfig(personTOthing(27,207)). +legacyConfig(personTOthing(27,208)). +legacyConfig(personTOthing(27,209)). +legacyConfig(personTOthing(27,210)). +legacyConfig(personTOthing(28,211)). +legacyConfig(personTOthing(28,212)). +legacyConfig(personTOthing(28,213)). +legacyConfig(personTOthing(28,214)). +legacyConfig(personTOthing(28,215)). +legacyConfig(personTOthing(29,216)). +legacyConfig(personTOthing(29,217)). +legacyConfig(personTOthing(29,218)). +legacyConfig(personTOthing(29,219)). +legacyConfig(personTOthing(29,220)). +legacyConfig(personTOthing(30,221)). +legacyConfig(personTOthing(30,222)). +legacyConfig(personTOthing(30,223)). +legacyConfig(personTOthing(30,224)). +legacyConfig(personTOthing(30,225)). +legacyConfig(personTOthing(31,226)). +legacyConfig(personTOthing(31,227)). +legacyConfig(personTOthing(31,228)). +legacyConfig(personTOthing(31,229)). +legacyConfig(personTOthing(31,230)). +legacyConfig(personTOthing(32,231)). +legacyConfig(personTOthing(32,232)). +legacyConfig(personTOthing(32,233)). +legacyConfig(personTOthing(32,234)). +legacyConfig(personTOthing(32,235)). +legacyConfig(personTOthing(33,236)). +legacyConfig(personTOthing(33,237)). +legacyConfig(personTOthing(33,238)). +legacyConfig(personTOthing(33,239)). +legacyConfig(personTOthing(33,240)). +legacyConfig(personTOthing(34,241)). +legacyConfig(personTOthing(34,242)). +legacyConfig(personTOthing(34,243)). +legacyConfig(personTOthing(34,244)). +legacyConfig(personTOthing(34,245)). +legacyConfig(personTOthing(35,246)). +legacyConfig(personTOthing(35,247)). +legacyConfig(personTOthing(35,248)). +legacyConfig(personTOthing(35,249)). +legacyConfig(personTOthing(35,250)). +legacyConfig(personTOthing(36,251)). +legacyConfig(personTOthing(36,252)). +legacyConfig(personTOthing(36,253)). +legacyConfig(personTOthing(36,254)). +legacyConfig(personTOthing(36,255)). +legacyConfig(personTOthing(37,256)). +legacyConfig(personTOthing(37,257)). +legacyConfig(personTOthing(37,258)). +legacyConfig(personTOthing(37,259)). +legacyConfig(personTOthing(37,260)). +legacyConfig(personTOthing(38,261)). +legacyConfig(personTOthing(38,262)). +legacyConfig(personTOthing(38,263)). +legacyConfig(personTOthing(38,264)). +legacyConfig(personTOthing(38,265)). +legacyConfig(personTOthing(39,266)). +legacyConfig(personTOthing(39,267)). +legacyConfig(personTOthing(39,268)). +legacyConfig(personTOthing(39,269)). +legacyConfig(personTOthing(39,270)). +legacyConfig(personTOthing(40,271)). +legacyConfig(personTOthing(40,272)). +legacyConfig(personTOthing(40,273)). +legacyConfig(personTOthing(40,274)). +legacyConfig(personTOthing(40,275)). +legacyConfig(personTOthing(41,276)). +legacyConfig(personTOthing(41,277)). +legacyConfig(personTOthing(41,278)). +legacyConfig(personTOthing(41,279)). +legacyConfig(personTOthing(41,280)). +legacyConfig(personTOthing(42,281)). +legacyConfig(personTOthing(42,282)). +legacyConfig(personTOthing(42,283)). +legacyConfig(personTOthing(42,284)). +legacyConfig(personTOthing(42,285)). +legacyConfig(personTOthing(43,286)). +legacyConfig(personTOthing(43,287)). +legacyConfig(personTOthing(43,288)). +legacyConfig(personTOthing(43,289)). +legacyConfig(personTOthing(43,290)). +legacyConfig(personTOthing(44,291)). +legacyConfig(personTOthing(44,292)). +legacyConfig(personTOthing(44,293)). +legacyConfig(personTOthing(44,294)). +legacyConfig(personTOthing(44,295)). +legacyConfig(personTOthing(45,296)). +legacyConfig(personTOthing(45,297)). +legacyConfig(personTOthing(45,298)). +legacyConfig(personTOthing(45,299)). +legacyConfig(personTOthing(45,300)). +legacyConfig(personTOthing(46,301)). +legacyConfig(personTOthing(46,302)). +legacyConfig(personTOthing(46,303)). +legacyConfig(personTOthing(46,304)). +legacyConfig(personTOthing(46,305)). +legacyConfig(personTOthing(47,306)). +legacyConfig(personTOthing(47,307)). +legacyConfig(personTOthing(47,308)). +legacyConfig(personTOthing(47,309)). +legacyConfig(personTOthing(47,310)). +legacyConfig(personTOthing(48,311)). +legacyConfig(personTOthing(48,312)). +legacyConfig(personTOthing(48,313)). +legacyConfig(personTOthing(48,314)). +legacyConfig(personTOthing(48,315)). +legacyConfig(personTOthing(49,316)). +legacyConfig(personTOthing(49,317)). +legacyConfig(personTOthing(49,318)). +legacyConfig(personTOthing(49,319)). +legacyConfig(personTOthing(49,320)). +legacyConfig(personTOthing(50,321)). +legacyConfig(personTOthing(50,322)). +legacyConfig(personTOthing(50,323)). +legacyConfig(personTOthing(50,324)). +legacyConfig(personTOthing(50,325)). +legacyConfig(personTOthing(51,326)). +legacyConfig(personTOthing(51,327)). +legacyConfig(personTOthing(51,328)). +legacyConfig(personTOthing(51,329)). +legacyConfig(personTOthing(51,330)). +legacyConfig(personTOthing(52,331)). +legacyConfig(personTOthing(52,332)). +legacyConfig(personTOthing(52,333)). +legacyConfig(personTOthing(52,334)). +legacyConfig(personTOthing(52,335)). +legacyConfig(personTOthing(53,336)). +legacyConfig(personTOthing(53,337)). +legacyConfig(personTOthing(53,338)). +legacyConfig(personTOthing(53,339)). +legacyConfig(personTOthing(53,340)). +legacyConfig(personTOthing(54,341)). +legacyConfig(personTOthing(54,342)). +legacyConfig(personTOthing(54,343)). +legacyConfig(personTOthing(54,344)). +legacyConfig(personTOthing(54,345)). +legacyConfig(personTOthing(55,346)). +legacyConfig(personTOthing(55,347)). +legacyConfig(personTOthing(55,348)). +legacyConfig(personTOthing(55,349)). +legacyConfig(personTOthing(55,350)). +legacyConfig(personTOthing(56,351)). +legacyConfig(personTOthing(56,352)). +legacyConfig(personTOthing(56,353)). +legacyConfig(personTOthing(56,354)). +legacyConfig(personTOthing(56,355)). +legacyConfig(personTOthing(57,356)). +legacyConfig(personTOthing(57,357)). +legacyConfig(personTOthing(57,358)). +legacyConfig(personTOthing(57,359)). +legacyConfig(personTOthing(57,360)). +legacyConfig(personTOthing(58,361)). +legacyConfig(personTOthing(58,362)). +legacyConfig(personTOthing(58,363)). +legacyConfig(personTOthing(58,364)). +legacyConfig(personTOthing(58,365)). +legacyConfig(personTOthing(59,366)). +legacyConfig(personTOthing(59,367)). +legacyConfig(personTOthing(59,368)). +legacyConfig(personTOthing(59,369)). +legacyConfig(personTOthing(59,370)). +legacyConfig(personTOthing(60,371)). +legacyConfig(personTOthing(60,372)). +legacyConfig(personTOthing(60,373)). +legacyConfig(personTOthing(60,374)). +legacyConfig(personTOthing(60,375)). +legacyConfig(personTOthing(61,376)). +legacyConfig(personTOthing(61,377)). +legacyConfig(personTOthing(61,378)). +legacyConfig(personTOthing(61,379)). +legacyConfig(personTOthing(61,380)). +legacyConfig(personTOthing(62,381)). +legacyConfig(personTOthing(62,382)). +legacyConfig(personTOthing(62,383)). +legacyConfig(personTOthing(62,384)). +legacyConfig(personTOthing(62,385)). +legacyConfig(personTOthing(63,386)). +legacyConfig(personTOthing(63,387)). +legacyConfig(personTOthing(63,388)). +legacyConfig(personTOthing(63,389)). +legacyConfig(personTOthing(63,390)). +legacyConfig(personTOthing(64,391)). +legacyConfig(personTOthing(64,392)). +legacyConfig(personTOthing(64,393)). +legacyConfig(personTOthing(64,394)). +legacyConfig(personTOthing(64,395)). +legacyConfig(personTOthing(65,396)). +legacyConfig(personTOthing(65,397)). +legacyConfig(personTOthing(65,398)). +legacyConfig(personTOthing(65,399)). +legacyConfig(personTOthing(65,400)). +legacyConfig(personTOthing(66,401)). +legacyConfig(personTOthing(66,402)). +legacyConfig(personTOthing(66,403)). +legacyConfig(personTOthing(66,404)). +legacyConfig(personTOthing(66,405)). +legacyConfig(personTOthing(67,406)). +legacyConfig(personTOthing(67,407)). +legacyConfig(personTOthing(67,408)). +legacyConfig(personTOthing(67,409)). +legacyConfig(personTOthing(67,410)). +legacyConfig(personTOthing(68,411)). +legacyConfig(personTOthing(68,412)). +legacyConfig(personTOthing(68,413)). +legacyConfig(personTOthing(68,414)). +legacyConfig(personTOthing(68,415)). +legacyConfig(personTOthing(69,416)). +legacyConfig(personTOthing(69,417)). +legacyConfig(personTOthing(69,418)). +legacyConfig(personTOthing(69,419)). +legacyConfig(personTOthing(69,420)). +legacyConfig(personTOthing(70,421)). +legacyConfig(personTOthing(70,422)). +legacyConfig(personTOthing(70,423)). +legacyConfig(personTOthing(70,424)). +legacyConfig(personTOthing(70,425)). +legacyConfig(personTOthing(71,426)). +legacyConfig(personTOthing(71,427)). +legacyConfig(personTOthing(71,428)). +legacyConfig(personTOthing(71,429)). +legacyConfig(personTOthing(71,430)). +legacyConfig(personTOthing(72,431)). +legacyConfig(personTOthing(72,432)). +legacyConfig(personTOthing(72,433)). +legacyConfig(personTOthing(72,434)). +legacyConfig(personTOthing(72,435)). +legacyConfig(personTOthing(73,436)). +legacyConfig(personTOthing(73,437)). +legacyConfig(personTOthing(73,438)). +legacyConfig(personTOthing(73,439)). +legacyConfig(personTOthing(73,440)). +legacyConfig(personTOthing(74,441)). +legacyConfig(personTOthing(74,442)). +legacyConfig(personTOthing(74,443)). +legacyConfig(personTOthing(74,444)). +legacyConfig(personTOthing(74,445)). +legacyConfig(personTOthing(75,446)). +legacyConfig(personTOthing(75,447)). +legacyConfig(personTOthing(75,448)). +legacyConfig(personTOthing(75,449)). +legacyConfig(personTOthing(75,450)). +% domains +cabinetDomainNew(500..874). +roomDomainNew(1000..1374). +cabinetUpper(375). +roomUpper(375). +cabinetLower(75). +roomLower(19). +% reuse costs +reuseCabinetTOthingCost(0). +reuseRoomTOcabinetCost(0). +reusePersonTOroomCost(0). +reuseCabinetAsHighCost(3). +reuseCabinetAsSmallCost(0). +reuseRoomCost(0). +% remove costs +removeCabinetTOthingCost(2). +removeRoomTOcabinetCost(2). +removePersonTOroomCost(2). +removeCabinetCost(2). +removeRoomCost(2). +% create costs +cabinetHighCost(100). +cabinetSmallCost(1). +roomCost(5). diff --git a/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p80t400.edb b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p80t400.edb new file mode 100644 index 000000000..9b24005cc --- /dev/null +++ b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p80t400.edb @@ -0,0 +1,1304 @@ +legacyConfig(person(1)). +legacyConfig(person(2)). +legacyConfig(person(3)). +legacyConfig(person(4)). +legacyConfig(person(5)). +legacyConfig(person(6)). +legacyConfig(person(7)). +legacyConfig(person(8)). +legacyConfig(person(9)). +legacyConfig(person(10)). +legacyConfig(person(11)). +legacyConfig(person(12)). +legacyConfig(person(13)). +legacyConfig(person(14)). +legacyConfig(person(15)). +legacyConfig(person(16)). +legacyConfig(person(17)). +legacyConfig(person(18)). +legacyConfig(person(19)). +legacyConfig(person(20)). +legacyConfig(person(21)). +legacyConfig(person(22)). +legacyConfig(person(23)). +legacyConfig(person(24)). +legacyConfig(person(25)). +legacyConfig(person(26)). +legacyConfig(person(27)). +legacyConfig(person(28)). +legacyConfig(person(29)). +legacyConfig(person(30)). +legacyConfig(person(31)). +legacyConfig(person(32)). +legacyConfig(person(33)). +legacyConfig(person(34)). +legacyConfig(person(35)). +legacyConfig(person(36)). +legacyConfig(person(37)). +legacyConfig(person(38)). +legacyConfig(person(39)). +legacyConfig(person(40)). +legacyConfig(person(41)). +legacyConfig(person(42)). +legacyConfig(person(43)). +legacyConfig(person(44)). +legacyConfig(person(45)). +legacyConfig(person(46)). +legacyConfig(person(47)). +legacyConfig(person(48)). +legacyConfig(person(49)). +legacyConfig(person(50)). +legacyConfig(person(51)). +legacyConfig(person(52)). +legacyConfig(person(53)). +legacyConfig(person(54)). +legacyConfig(person(55)). +legacyConfig(person(56)). +legacyConfig(person(57)). +legacyConfig(person(58)). +legacyConfig(person(59)). +legacyConfig(person(60)). +legacyConfig(person(61)). +legacyConfig(person(62)). +legacyConfig(person(63)). +legacyConfig(person(64)). +legacyConfig(person(65)). +legacyConfig(person(66)). +legacyConfig(person(67)). +legacyConfig(person(68)). +legacyConfig(person(69)). +legacyConfig(person(70)). +legacyConfig(person(71)). +legacyConfig(person(72)). +legacyConfig(person(73)). +legacyConfig(person(74)). +legacyConfig(person(75)). +legacyConfig(person(76)). +legacyConfig(person(77)). +legacyConfig(person(78)). +legacyConfig(person(79)). +legacyConfig(person(80)). +legacyConfig(thing(81)). +thingShort(81). +legacyConfig(thing(82)). +thingShort(82). +legacyConfig(thing(83)). +thingShort(83). +legacyConfig(thing(84)). +thingShort(84). +legacyConfig(thing(85)). +thingShort(85). +legacyConfig(thing(86)). +thingShort(86). +legacyConfig(thing(87)). +thingShort(87). +legacyConfig(thing(88)). +thingShort(88). +legacyConfig(thing(89)). +thingShort(89). +legacyConfig(thing(90)). +thingShort(90). +legacyConfig(thing(91)). +thingShort(91). +legacyConfig(thing(92)). +thingShort(92). +legacyConfig(thing(93)). +thingShort(93). +legacyConfig(thing(94)). +thingShort(94). +legacyConfig(thing(95)). +thingShort(95). +legacyConfig(thing(96)). +thingShort(96). +legacyConfig(thing(97)). +thingShort(97). +legacyConfig(thing(98)). +thingShort(98). +legacyConfig(thing(99)). +thingShort(99). +legacyConfig(thing(100)). +thingShort(100). +legacyConfig(thing(101)). +thingShort(101). +legacyConfig(thing(102)). +thingShort(102). +legacyConfig(thing(103)). +thingShort(103). +legacyConfig(thing(104)). +thingShort(104). +legacyConfig(thing(105)). +thingShort(105). +legacyConfig(thing(106)). +thingShort(106). +legacyConfig(thing(107)). +thingShort(107). +legacyConfig(thing(108)). +thingShort(108). +legacyConfig(thing(109)). +thingShort(109). +legacyConfig(thing(110)). +thingShort(110). +legacyConfig(thing(111)). +thingShort(111). +legacyConfig(thing(112)). +thingShort(112). +legacyConfig(thing(113)). +thingShort(113). +legacyConfig(thing(114)). +thingShort(114). +legacyConfig(thing(115)). +thingShort(115). +legacyConfig(thing(116)). +thingShort(116). +legacyConfig(thing(117)). +thingShort(117). +legacyConfig(thing(118)). +thingShort(118). +legacyConfig(thing(119)). +thingShort(119). +legacyConfig(thing(120)). +thingShort(120). +legacyConfig(thing(121)). +thingShort(121). +legacyConfig(thing(122)). +thingShort(122). +legacyConfig(thing(123)). +thingShort(123). +legacyConfig(thing(124)). +thingShort(124). +legacyConfig(thing(125)). +thingShort(125). +legacyConfig(thing(126)). +thingShort(126). +legacyConfig(thing(127)). +thingShort(127). +legacyConfig(thing(128)). +thingShort(128). +legacyConfig(thing(129)). +thingShort(129). +legacyConfig(thing(130)). +thingShort(130). +legacyConfig(thing(131)). +thingShort(131). +legacyConfig(thing(132)). +thingShort(132). +legacyConfig(thing(133)). +thingShort(133). +legacyConfig(thing(134)). +thingShort(134). +legacyConfig(thing(135)). +thingShort(135). +legacyConfig(thing(136)). +thingShort(136). +legacyConfig(thing(137)). +thingShort(137). +legacyConfig(thing(138)). +thingShort(138). +legacyConfig(thing(139)). +thingShort(139). +legacyConfig(thing(140)). +thingShort(140). +legacyConfig(thing(141)). +thingShort(141). +legacyConfig(thing(142)). +thingShort(142). +legacyConfig(thing(143)). +thingShort(143). +legacyConfig(thing(144)). +thingShort(144). +legacyConfig(thing(145)). +thingShort(145). +legacyConfig(thing(146)). +thingShort(146). +legacyConfig(thing(147)). +thingShort(147). +legacyConfig(thing(148)). +thingShort(148). +legacyConfig(thing(149)). +thingShort(149). +legacyConfig(thing(150)). +thingShort(150). +legacyConfig(thing(151)). +thingShort(151). +legacyConfig(thing(152)). +thingShort(152). +legacyConfig(thing(153)). +thingShort(153). +legacyConfig(thing(154)). +thingShort(154). +legacyConfig(thing(155)). +thingShort(155). +legacyConfig(thing(156)). +thingShort(156). +legacyConfig(thing(157)). +thingShort(157). +legacyConfig(thing(158)). +thingShort(158). +legacyConfig(thing(159)). +thingShort(159). +legacyConfig(thing(160)). +thingShort(160). +legacyConfig(thing(161)). +thingShort(161). +legacyConfig(thing(162)). +thingShort(162). +legacyConfig(thing(163)). +thingShort(163). +legacyConfig(thing(164)). +thingShort(164). +legacyConfig(thing(165)). +thingShort(165). +legacyConfig(thing(166)). +thingShort(166). +legacyConfig(thing(167)). +thingShort(167). +legacyConfig(thing(168)). +thingShort(168). +legacyConfig(thing(169)). +thingShort(169). +legacyConfig(thing(170)). +thingShort(170). +legacyConfig(thing(171)). +thingShort(171). +legacyConfig(thing(172)). +thingShort(172). +legacyConfig(thing(173)). +thingShort(173). +legacyConfig(thing(174)). +thingShort(174). +legacyConfig(thing(175)). +thingShort(175). +legacyConfig(thing(176)). +thingShort(176). +legacyConfig(thing(177)). +thingShort(177). +legacyConfig(thing(178)). +thingShort(178). +legacyConfig(thing(179)). +thingShort(179). +legacyConfig(thing(180)). +thingShort(180). +legacyConfig(thing(181)). +thingShort(181). +legacyConfig(thing(182)). +thingShort(182). +legacyConfig(thing(183)). +thingShort(183). +legacyConfig(thing(184)). +thingShort(184). +legacyConfig(thing(185)). +thingShort(185). +legacyConfig(thing(186)). +thingShort(186). +legacyConfig(thing(187)). +thingShort(187). +legacyConfig(thing(188)). +thingShort(188). +legacyConfig(thing(189)). +thingShort(189). +legacyConfig(thing(190)). +thingShort(190). +legacyConfig(thing(191)). +thingShort(191). +legacyConfig(thing(192)). +thingShort(192). +legacyConfig(thing(193)). +thingShort(193). +legacyConfig(thing(194)). +thingShort(194). +legacyConfig(thing(195)). +thingShort(195). +legacyConfig(thing(196)). +thingShort(196). +legacyConfig(thing(197)). +thingShort(197). +legacyConfig(thing(198)). +thingShort(198). +legacyConfig(thing(199)). +thingShort(199). +legacyConfig(thing(200)). +thingShort(200). +legacyConfig(thing(201)). +thingShort(201). +legacyConfig(thing(202)). +thingShort(202). +legacyConfig(thing(203)). +thingShort(203). +legacyConfig(thing(204)). +thingShort(204). +legacyConfig(thing(205)). +thingShort(205). +legacyConfig(thing(206)). +thingShort(206). +legacyConfig(thing(207)). +thingShort(207). +legacyConfig(thing(208)). +thingShort(208). +legacyConfig(thing(209)). +thingShort(209). +legacyConfig(thing(210)). +thingShort(210). +legacyConfig(thing(211)). +thingShort(211). +legacyConfig(thing(212)). +thingShort(212). +legacyConfig(thing(213)). +thingShort(213). +legacyConfig(thing(214)). +thingShort(214). +legacyConfig(thing(215)). +thingShort(215). +legacyConfig(thing(216)). +thingShort(216). +legacyConfig(thing(217)). +thingShort(217). +legacyConfig(thing(218)). +thingShort(218). +legacyConfig(thing(219)). +thingShort(219). +legacyConfig(thing(220)). +thingShort(220). +legacyConfig(thing(221)). +thingShort(221). +legacyConfig(thing(222)). +thingShort(222). +legacyConfig(thing(223)). +thingShort(223). +legacyConfig(thing(224)). +thingShort(224). +legacyConfig(thing(225)). +thingShort(225). +legacyConfig(thing(226)). +thingShort(226). +legacyConfig(thing(227)). +thingShort(227). +legacyConfig(thing(228)). +thingShort(228). +legacyConfig(thing(229)). +thingShort(229). +legacyConfig(thing(230)). +thingShort(230). +legacyConfig(thing(231)). +thingShort(231). +legacyConfig(thing(232)). +thingShort(232). +legacyConfig(thing(233)). +thingShort(233). +legacyConfig(thing(234)). +thingShort(234). +legacyConfig(thing(235)). +thingShort(235). +legacyConfig(thing(236)). +thingShort(236). +legacyConfig(thing(237)). +thingShort(237). +legacyConfig(thing(238)). +thingShort(238). +legacyConfig(thing(239)). +thingShort(239). +legacyConfig(thing(240)). +thingShort(240). +legacyConfig(thing(241)). +thingShort(241). +legacyConfig(thing(242)). +thingShort(242). +legacyConfig(thing(243)). +thingShort(243). +legacyConfig(thing(244)). +thingShort(244). +legacyConfig(thing(245)). +thingShort(245). +legacyConfig(thing(246)). +thingShort(246). +legacyConfig(thing(247)). +thingShort(247). +legacyConfig(thing(248)). +thingShort(248). +legacyConfig(thing(249)). +thingShort(249). +legacyConfig(thing(250)). +thingShort(250). +legacyConfig(thing(251)). +thingShort(251). +legacyConfig(thing(252)). +thingShort(252). +legacyConfig(thing(253)). +thingShort(253). +legacyConfig(thing(254)). +thingShort(254). +legacyConfig(thing(255)). +thingShort(255). +legacyConfig(thing(256)). +thingShort(256). +legacyConfig(thing(257)). +thingShort(257). +legacyConfig(thing(258)). +thingShort(258). +legacyConfig(thing(259)). +thingShort(259). +legacyConfig(thing(260)). +thingShort(260). +legacyConfig(thing(261)). +thingShort(261). +legacyConfig(thing(262)). +thingShort(262). +legacyConfig(thing(263)). +thingShort(263). +legacyConfig(thing(264)). +thingShort(264). +legacyConfig(thing(265)). +thingShort(265). +legacyConfig(thing(266)). +thingShort(266). +legacyConfig(thing(267)). +thingShort(267). +legacyConfig(thing(268)). +thingShort(268). +legacyConfig(thing(269)). +thingShort(269). +legacyConfig(thing(270)). +thingShort(270). +legacyConfig(thing(271)). +thingShort(271). +legacyConfig(thing(272)). +thingShort(272). +legacyConfig(thing(273)). +thingShort(273). +legacyConfig(thing(274)). +thingShort(274). +legacyConfig(thing(275)). +thingShort(275). +legacyConfig(thing(276)). +thingShort(276). +legacyConfig(thing(277)). +thingShort(277). +legacyConfig(thing(278)). +thingShort(278). +legacyConfig(thing(279)). +thingShort(279). +legacyConfig(thing(280)). +thingShort(280). +legacyConfig(thing(281)). +thingShort(281). +legacyConfig(thing(282)). +thingShort(282). +legacyConfig(thing(283)). +thingShort(283). +legacyConfig(thing(284)). +thingShort(284). +legacyConfig(thing(285)). +thingShort(285). +legacyConfig(thing(286)). +thingShort(286). +legacyConfig(thing(287)). +thingShort(287). +legacyConfig(thing(288)). +thingShort(288). +legacyConfig(thing(289)). +thingShort(289). +legacyConfig(thing(290)). +thingShort(290). +legacyConfig(thing(291)). +thingShort(291). +legacyConfig(thing(292)). +thingShort(292). +legacyConfig(thing(293)). +thingShort(293). +legacyConfig(thing(294)). +thingShort(294). +legacyConfig(thing(295)). +thingShort(295). +legacyConfig(thing(296)). +thingShort(296). +legacyConfig(thing(297)). +thingShort(297). +legacyConfig(thing(298)). +thingShort(298). +legacyConfig(thing(299)). +thingShort(299). +legacyConfig(thing(300)). +thingShort(300). +legacyConfig(thing(301)). +thingShort(301). +legacyConfig(thing(302)). +thingShort(302). +legacyConfig(thing(303)). +thingShort(303). +legacyConfig(thing(304)). +thingShort(304). +legacyConfig(thing(305)). +thingShort(305). +legacyConfig(thing(306)). +thingShort(306). +legacyConfig(thing(307)). +thingShort(307). +legacyConfig(thing(308)). +thingShort(308). +legacyConfig(thing(309)). +thingShort(309). +legacyConfig(thing(310)). +thingShort(310). +legacyConfig(thing(311)). +thingShort(311). +legacyConfig(thing(312)). +thingShort(312). +legacyConfig(thing(313)). +thingShort(313). +legacyConfig(thing(314)). +thingShort(314). +legacyConfig(thing(315)). +thingShort(315). +legacyConfig(thing(316)). +thingShort(316). +legacyConfig(thing(317)). +thingShort(317). +legacyConfig(thing(318)). +thingShort(318). +legacyConfig(thing(319)). +thingShort(319). +legacyConfig(thing(320)). +thingShort(320). +legacyConfig(thing(321)). +thingShort(321). +legacyConfig(thing(322)). +thingShort(322). +legacyConfig(thing(323)). +thingShort(323). +legacyConfig(thing(324)). +thingShort(324). +legacyConfig(thing(325)). +thingShort(325). +legacyConfig(thing(326)). +thingShort(326). +legacyConfig(thing(327)). +thingShort(327). +legacyConfig(thing(328)). +thingShort(328). +legacyConfig(thing(329)). +thingShort(329). +legacyConfig(thing(330)). +thingShort(330). +legacyConfig(thing(331)). +thingShort(331). +legacyConfig(thing(332)). +thingShort(332). +legacyConfig(thing(333)). +thingShort(333). +legacyConfig(thing(334)). +thingShort(334). +legacyConfig(thing(335)). +thingShort(335). +legacyConfig(thing(336)). +thingShort(336). +legacyConfig(thing(337)). +thingShort(337). +legacyConfig(thing(338)). +thingShort(338). +legacyConfig(thing(339)). +thingShort(339). +legacyConfig(thing(340)). +thingShort(340). +legacyConfig(thing(341)). +thingShort(341). +legacyConfig(thing(342)). +thingShort(342). +legacyConfig(thing(343)). +thingShort(343). +legacyConfig(thing(344)). +thingShort(344). +legacyConfig(thing(345)). +thingShort(345). +legacyConfig(thing(346)). +thingShort(346). +legacyConfig(thing(347)). +thingShort(347). +legacyConfig(thing(348)). +thingShort(348). +legacyConfig(thing(349)). +thingShort(349). +legacyConfig(thing(350)). +thingShort(350). +legacyConfig(thing(351)). +thingShort(351). +legacyConfig(thing(352)). +thingShort(352). +legacyConfig(thing(353)). +thingShort(353). +legacyConfig(thing(354)). +thingShort(354). +legacyConfig(thing(355)). +thingShort(355). +legacyConfig(thing(356)). +thingShort(356). +legacyConfig(thing(357)). +thingShort(357). +legacyConfig(thing(358)). +thingShort(358). +legacyConfig(thing(359)). +thingShort(359). +legacyConfig(thing(360)). +thingShort(360). +legacyConfig(thing(361)). +thingShort(361). +legacyConfig(thing(362)). +thingShort(362). +legacyConfig(thing(363)). +thingShort(363). +legacyConfig(thing(364)). +thingShort(364). +legacyConfig(thing(365)). +thingShort(365). +legacyConfig(thing(366)). +thingShort(366). +legacyConfig(thing(367)). +thingShort(367). +legacyConfig(thing(368)). +thingShort(368). +legacyConfig(thing(369)). +thingShort(369). +legacyConfig(thing(370)). +thingShort(370). +legacyConfig(thing(371)). +thingShort(371). +legacyConfig(thing(372)). +thingShort(372). +legacyConfig(thing(373)). +thingShort(373). +legacyConfig(thing(374)). +thingShort(374). +legacyConfig(thing(375)). +thingShort(375). +legacyConfig(thing(376)). +thingShort(376). +legacyConfig(thing(377)). +thingShort(377). +legacyConfig(thing(378)). +thingShort(378). +legacyConfig(thing(379)). +thingShort(379). +legacyConfig(thing(380)). +thingShort(380). +legacyConfig(thing(381)). +thingShort(381). +legacyConfig(thing(382)). +thingShort(382). +legacyConfig(thing(383)). +thingShort(383). +legacyConfig(thing(384)). +thingShort(384). +legacyConfig(thing(385)). +thingShort(385). +legacyConfig(thing(386)). +thingShort(386). +legacyConfig(thing(387)). +thingShort(387). +legacyConfig(thing(388)). +thingShort(388). +legacyConfig(thing(389)). +thingShort(389). +legacyConfig(thing(390)). +thingShort(390). +legacyConfig(thing(391)). +thingShort(391). +legacyConfig(thing(392)). +thingShort(392). +legacyConfig(thing(393)). +thingShort(393). +legacyConfig(thing(394)). +thingShort(394). +legacyConfig(thing(395)). +thingShort(395). +legacyConfig(thing(396)). +thingShort(396). +legacyConfig(thing(397)). +thingShort(397). +legacyConfig(thing(398)). +thingShort(398). +legacyConfig(thing(399)). +thingShort(399). +legacyConfig(thing(400)). +thingShort(400). +legacyConfig(thing(401)). +thingShort(401). +legacyConfig(thing(402)). +thingShort(402). +legacyConfig(thing(403)). +thingShort(403). +legacyConfig(thing(404)). +thingShort(404). +legacyConfig(thing(405)). +thingShort(405). +legacyConfig(thing(406)). +thingShort(406). +legacyConfig(thing(407)). +thingShort(407). +legacyConfig(thing(408)). +thingShort(408). +legacyConfig(thing(409)). +thingShort(409). +legacyConfig(thing(410)). +thingShort(410). +legacyConfig(thing(411)). +thingShort(411). +legacyConfig(thing(412)). +thingShort(412). +legacyConfig(thing(413)). +thingShort(413). +legacyConfig(thing(414)). +thingShort(414). +legacyConfig(thing(415)). +thingShort(415). +legacyConfig(thing(416)). +thingShort(416). +legacyConfig(thing(417)). +thingShort(417). +legacyConfig(thing(418)). +thingShort(418). +legacyConfig(thing(419)). +thingShort(419). +legacyConfig(thing(420)). +thingShort(420). +legacyConfig(thing(421)). +thingShort(421). +legacyConfig(thing(422)). +thingShort(422). +legacyConfig(thing(423)). +thingShort(423). +legacyConfig(thing(424)). +thingShort(424). +legacyConfig(thing(425)). +thingShort(425). +legacyConfig(thing(426)). +thingShort(426). +legacyConfig(thing(427)). +thingShort(427). +legacyConfig(thing(428)). +thingShort(428). +legacyConfig(thing(429)). +thingShort(429). +legacyConfig(thing(430)). +thingShort(430). +legacyConfig(thing(431)). +thingShort(431). +legacyConfig(thing(432)). +thingShort(432). +legacyConfig(thing(433)). +thingShort(433). +legacyConfig(thing(434)). +thingShort(434). +legacyConfig(thing(435)). +thingShort(435). +legacyConfig(thing(436)). +thingShort(436). +legacyConfig(thing(437)). +thingShort(437). +legacyConfig(thing(438)). +thingShort(438). +legacyConfig(thing(439)). +thingShort(439). +legacyConfig(thing(440)). +thingShort(440). +legacyConfig(thing(441)). +thingShort(441). +legacyConfig(thing(442)). +thingShort(442). +legacyConfig(thing(443)). +thingShort(443). +legacyConfig(thing(444)). +thingShort(444). +legacyConfig(thing(445)). +thingShort(445). +legacyConfig(thing(446)). +thingShort(446). +legacyConfig(thing(447)). +thingShort(447). +legacyConfig(thing(448)). +thingShort(448). +legacyConfig(thing(449)). +thingShort(449). +legacyConfig(thing(450)). +thingShort(450). +legacyConfig(thing(451)). +thingShort(451). +legacyConfig(thing(452)). +thingShort(452). +legacyConfig(thing(453)). +thingShort(453). +legacyConfig(thing(454)). +thingShort(454). +legacyConfig(thing(455)). +thingShort(455). +legacyConfig(thing(456)). +thingShort(456). +legacyConfig(thing(457)). +thingShort(457). +legacyConfig(thing(458)). +thingShort(458). +legacyConfig(thing(459)). +thingShort(459). +legacyConfig(thing(460)). +thingShort(460). +legacyConfig(thing(461)). +thingShort(461). +legacyConfig(thing(462)). +thingShort(462). +legacyConfig(thing(463)). +thingShort(463). +legacyConfig(thing(464)). +thingShort(464). +legacyConfig(thing(465)). +thingShort(465). +legacyConfig(thing(466)). +thingShort(466). +legacyConfig(thing(467)). +thingShort(467). +legacyConfig(thing(468)). +thingShort(468). +legacyConfig(thing(469)). +thingShort(469). +legacyConfig(thing(470)). +thingShort(470). +legacyConfig(thing(471)). +thingShort(471). +legacyConfig(thing(472)). +thingShort(472). +legacyConfig(thing(473)). +thingShort(473). +legacyConfig(thing(474)). +thingShort(474). +legacyConfig(thing(475)). +thingShort(475). +legacyConfig(thing(476)). +thingShort(476). +legacyConfig(thing(477)). +thingShort(477). +legacyConfig(thing(478)). +thingShort(478). +legacyConfig(thing(479)). +thingShort(479). +legacyConfig(thing(480)). +thingShort(480). +legacyConfig(personTOthing(1,81)). +legacyConfig(personTOthing(1,82)). +legacyConfig(personTOthing(1,83)). +legacyConfig(personTOthing(1,84)). +legacyConfig(personTOthing(1,85)). +legacyConfig(personTOthing(2,86)). +legacyConfig(personTOthing(2,87)). +legacyConfig(personTOthing(2,88)). +legacyConfig(personTOthing(2,89)). +legacyConfig(personTOthing(2,90)). +legacyConfig(personTOthing(3,91)). +legacyConfig(personTOthing(3,92)). +legacyConfig(personTOthing(3,93)). +legacyConfig(personTOthing(3,94)). +legacyConfig(personTOthing(3,95)). +legacyConfig(personTOthing(4,96)). +legacyConfig(personTOthing(4,97)). +legacyConfig(personTOthing(4,98)). +legacyConfig(personTOthing(4,99)). +legacyConfig(personTOthing(4,100)). +legacyConfig(personTOthing(5,101)). +legacyConfig(personTOthing(5,102)). +legacyConfig(personTOthing(5,103)). +legacyConfig(personTOthing(5,104)). +legacyConfig(personTOthing(5,105)). +legacyConfig(personTOthing(6,106)). +legacyConfig(personTOthing(6,107)). +legacyConfig(personTOthing(6,108)). +legacyConfig(personTOthing(6,109)). +legacyConfig(personTOthing(6,110)). +legacyConfig(personTOthing(7,111)). +legacyConfig(personTOthing(7,112)). +legacyConfig(personTOthing(7,113)). +legacyConfig(personTOthing(7,114)). +legacyConfig(personTOthing(7,115)). +legacyConfig(personTOthing(8,116)). +legacyConfig(personTOthing(8,117)). +legacyConfig(personTOthing(8,118)). +legacyConfig(personTOthing(8,119)). +legacyConfig(personTOthing(8,120)). +legacyConfig(personTOthing(9,121)). +legacyConfig(personTOthing(9,122)). +legacyConfig(personTOthing(9,123)). +legacyConfig(personTOthing(9,124)). +legacyConfig(personTOthing(9,125)). +legacyConfig(personTOthing(10,126)). +legacyConfig(personTOthing(10,127)). +legacyConfig(personTOthing(10,128)). +legacyConfig(personTOthing(10,129)). +legacyConfig(personTOthing(10,130)). +legacyConfig(personTOthing(11,131)). +legacyConfig(personTOthing(11,132)). +legacyConfig(personTOthing(11,133)). +legacyConfig(personTOthing(11,134)). +legacyConfig(personTOthing(11,135)). +legacyConfig(personTOthing(12,136)). +legacyConfig(personTOthing(12,137)). +legacyConfig(personTOthing(12,138)). +legacyConfig(personTOthing(12,139)). +legacyConfig(personTOthing(12,140)). +legacyConfig(personTOthing(13,141)). +legacyConfig(personTOthing(13,142)). +legacyConfig(personTOthing(13,143)). +legacyConfig(personTOthing(13,144)). +legacyConfig(personTOthing(13,145)). +legacyConfig(personTOthing(14,146)). +legacyConfig(personTOthing(14,147)). +legacyConfig(personTOthing(14,148)). +legacyConfig(personTOthing(14,149)). +legacyConfig(personTOthing(14,150)). +legacyConfig(personTOthing(15,151)). +legacyConfig(personTOthing(15,152)). +legacyConfig(personTOthing(15,153)). +legacyConfig(personTOthing(15,154)). +legacyConfig(personTOthing(15,155)). +legacyConfig(personTOthing(16,156)). +legacyConfig(personTOthing(16,157)). +legacyConfig(personTOthing(16,158)). +legacyConfig(personTOthing(16,159)). +legacyConfig(personTOthing(16,160)). +legacyConfig(personTOthing(17,161)). +legacyConfig(personTOthing(17,162)). +legacyConfig(personTOthing(17,163)). +legacyConfig(personTOthing(17,164)). +legacyConfig(personTOthing(17,165)). +legacyConfig(personTOthing(18,166)). +legacyConfig(personTOthing(18,167)). +legacyConfig(personTOthing(18,168)). +legacyConfig(personTOthing(18,169)). +legacyConfig(personTOthing(18,170)). +legacyConfig(personTOthing(19,171)). +legacyConfig(personTOthing(19,172)). +legacyConfig(personTOthing(19,173)). +legacyConfig(personTOthing(19,174)). +legacyConfig(personTOthing(19,175)). +legacyConfig(personTOthing(20,176)). +legacyConfig(personTOthing(20,177)). +legacyConfig(personTOthing(20,178)). +legacyConfig(personTOthing(20,179)). +legacyConfig(personTOthing(20,180)). +legacyConfig(personTOthing(21,181)). +legacyConfig(personTOthing(21,182)). +legacyConfig(personTOthing(21,183)). +legacyConfig(personTOthing(21,184)). +legacyConfig(personTOthing(21,185)). +legacyConfig(personTOthing(22,186)). +legacyConfig(personTOthing(22,187)). +legacyConfig(personTOthing(22,188)). +legacyConfig(personTOthing(22,189)). +legacyConfig(personTOthing(22,190)). +legacyConfig(personTOthing(23,191)). +legacyConfig(personTOthing(23,192)). +legacyConfig(personTOthing(23,193)). +legacyConfig(personTOthing(23,194)). +legacyConfig(personTOthing(23,195)). +legacyConfig(personTOthing(24,196)). +legacyConfig(personTOthing(24,197)). +legacyConfig(personTOthing(24,198)). +legacyConfig(personTOthing(24,199)). +legacyConfig(personTOthing(24,200)). +legacyConfig(personTOthing(25,201)). +legacyConfig(personTOthing(25,202)). +legacyConfig(personTOthing(25,203)). +legacyConfig(personTOthing(25,204)). +legacyConfig(personTOthing(25,205)). +legacyConfig(personTOthing(26,206)). +legacyConfig(personTOthing(26,207)). +legacyConfig(personTOthing(26,208)). +legacyConfig(personTOthing(26,209)). +legacyConfig(personTOthing(26,210)). +legacyConfig(personTOthing(27,211)). +legacyConfig(personTOthing(27,212)). +legacyConfig(personTOthing(27,213)). +legacyConfig(personTOthing(27,214)). +legacyConfig(personTOthing(27,215)). +legacyConfig(personTOthing(28,216)). +legacyConfig(personTOthing(28,217)). +legacyConfig(personTOthing(28,218)). +legacyConfig(personTOthing(28,219)). +legacyConfig(personTOthing(28,220)). +legacyConfig(personTOthing(29,221)). +legacyConfig(personTOthing(29,222)). +legacyConfig(personTOthing(29,223)). +legacyConfig(personTOthing(29,224)). +legacyConfig(personTOthing(29,225)). +legacyConfig(personTOthing(30,226)). +legacyConfig(personTOthing(30,227)). +legacyConfig(personTOthing(30,228)). +legacyConfig(personTOthing(30,229)). +legacyConfig(personTOthing(30,230)). +legacyConfig(personTOthing(31,231)). +legacyConfig(personTOthing(31,232)). +legacyConfig(personTOthing(31,233)). +legacyConfig(personTOthing(31,234)). +legacyConfig(personTOthing(31,235)). +legacyConfig(personTOthing(32,236)). +legacyConfig(personTOthing(32,237)). +legacyConfig(personTOthing(32,238)). +legacyConfig(personTOthing(32,239)). +legacyConfig(personTOthing(32,240)). +legacyConfig(personTOthing(33,241)). +legacyConfig(personTOthing(33,242)). +legacyConfig(personTOthing(33,243)). +legacyConfig(personTOthing(33,244)). +legacyConfig(personTOthing(33,245)). +legacyConfig(personTOthing(34,246)). +legacyConfig(personTOthing(34,247)). +legacyConfig(personTOthing(34,248)). +legacyConfig(personTOthing(34,249)). +legacyConfig(personTOthing(34,250)). +legacyConfig(personTOthing(35,251)). +legacyConfig(personTOthing(35,252)). +legacyConfig(personTOthing(35,253)). +legacyConfig(personTOthing(35,254)). +legacyConfig(personTOthing(35,255)). +legacyConfig(personTOthing(36,256)). +legacyConfig(personTOthing(36,257)). +legacyConfig(personTOthing(36,258)). +legacyConfig(personTOthing(36,259)). +legacyConfig(personTOthing(36,260)). +legacyConfig(personTOthing(37,261)). +legacyConfig(personTOthing(37,262)). +legacyConfig(personTOthing(37,263)). +legacyConfig(personTOthing(37,264)). +legacyConfig(personTOthing(37,265)). +legacyConfig(personTOthing(38,266)). +legacyConfig(personTOthing(38,267)). +legacyConfig(personTOthing(38,268)). +legacyConfig(personTOthing(38,269)). +legacyConfig(personTOthing(38,270)). +legacyConfig(personTOthing(39,271)). +legacyConfig(personTOthing(39,272)). +legacyConfig(personTOthing(39,273)). +legacyConfig(personTOthing(39,274)). +legacyConfig(personTOthing(39,275)). +legacyConfig(personTOthing(40,276)). +legacyConfig(personTOthing(40,277)). +legacyConfig(personTOthing(40,278)). +legacyConfig(personTOthing(40,279)). +legacyConfig(personTOthing(40,280)). +legacyConfig(personTOthing(41,281)). +legacyConfig(personTOthing(41,282)). +legacyConfig(personTOthing(41,283)). +legacyConfig(personTOthing(41,284)). +legacyConfig(personTOthing(41,285)). +legacyConfig(personTOthing(42,286)). +legacyConfig(personTOthing(42,287)). +legacyConfig(personTOthing(42,288)). +legacyConfig(personTOthing(42,289)). +legacyConfig(personTOthing(42,290)). +legacyConfig(personTOthing(43,291)). +legacyConfig(personTOthing(43,292)). +legacyConfig(personTOthing(43,293)). +legacyConfig(personTOthing(43,294)). +legacyConfig(personTOthing(43,295)). +legacyConfig(personTOthing(44,296)). +legacyConfig(personTOthing(44,297)). +legacyConfig(personTOthing(44,298)). +legacyConfig(personTOthing(44,299)). +legacyConfig(personTOthing(44,300)). +legacyConfig(personTOthing(45,301)). +legacyConfig(personTOthing(45,302)). +legacyConfig(personTOthing(45,303)). +legacyConfig(personTOthing(45,304)). +legacyConfig(personTOthing(45,305)). +legacyConfig(personTOthing(46,306)). +legacyConfig(personTOthing(46,307)). +legacyConfig(personTOthing(46,308)). +legacyConfig(personTOthing(46,309)). +legacyConfig(personTOthing(46,310)). +legacyConfig(personTOthing(47,311)). +legacyConfig(personTOthing(47,312)). +legacyConfig(personTOthing(47,313)). +legacyConfig(personTOthing(47,314)). +legacyConfig(personTOthing(47,315)). +legacyConfig(personTOthing(48,316)). +legacyConfig(personTOthing(48,317)). +legacyConfig(personTOthing(48,318)). +legacyConfig(personTOthing(48,319)). +legacyConfig(personTOthing(48,320)). +legacyConfig(personTOthing(49,321)). +legacyConfig(personTOthing(49,322)). +legacyConfig(personTOthing(49,323)). +legacyConfig(personTOthing(49,324)). +legacyConfig(personTOthing(49,325)). +legacyConfig(personTOthing(50,326)). +legacyConfig(personTOthing(50,327)). +legacyConfig(personTOthing(50,328)). +legacyConfig(personTOthing(50,329)). +legacyConfig(personTOthing(50,330)). +legacyConfig(personTOthing(51,331)). +legacyConfig(personTOthing(51,332)). +legacyConfig(personTOthing(51,333)). +legacyConfig(personTOthing(51,334)). +legacyConfig(personTOthing(51,335)). +legacyConfig(personTOthing(52,336)). +legacyConfig(personTOthing(52,337)). +legacyConfig(personTOthing(52,338)). +legacyConfig(personTOthing(52,339)). +legacyConfig(personTOthing(52,340)). +legacyConfig(personTOthing(53,341)). +legacyConfig(personTOthing(53,342)). +legacyConfig(personTOthing(53,343)). +legacyConfig(personTOthing(53,344)). +legacyConfig(personTOthing(53,345)). +legacyConfig(personTOthing(54,346)). +legacyConfig(personTOthing(54,347)). +legacyConfig(personTOthing(54,348)). +legacyConfig(personTOthing(54,349)). +legacyConfig(personTOthing(54,350)). +legacyConfig(personTOthing(55,351)). +legacyConfig(personTOthing(55,352)). +legacyConfig(personTOthing(55,353)). +legacyConfig(personTOthing(55,354)). +legacyConfig(personTOthing(55,355)). +legacyConfig(personTOthing(56,356)). +legacyConfig(personTOthing(56,357)). +legacyConfig(personTOthing(56,358)). +legacyConfig(personTOthing(56,359)). +legacyConfig(personTOthing(56,360)). +legacyConfig(personTOthing(57,361)). +legacyConfig(personTOthing(57,362)). +legacyConfig(personTOthing(57,363)). +legacyConfig(personTOthing(57,364)). +legacyConfig(personTOthing(57,365)). +legacyConfig(personTOthing(58,366)). +legacyConfig(personTOthing(58,367)). +legacyConfig(personTOthing(58,368)). +legacyConfig(personTOthing(58,369)). +legacyConfig(personTOthing(58,370)). +legacyConfig(personTOthing(59,371)). +legacyConfig(personTOthing(59,372)). +legacyConfig(personTOthing(59,373)). +legacyConfig(personTOthing(59,374)). +legacyConfig(personTOthing(59,375)). +legacyConfig(personTOthing(60,376)). +legacyConfig(personTOthing(60,377)). +legacyConfig(personTOthing(60,378)). +legacyConfig(personTOthing(60,379)). +legacyConfig(personTOthing(60,380)). +legacyConfig(personTOthing(61,381)). +legacyConfig(personTOthing(61,382)). +legacyConfig(personTOthing(61,383)). +legacyConfig(personTOthing(61,384)). +legacyConfig(personTOthing(61,385)). +legacyConfig(personTOthing(62,386)). +legacyConfig(personTOthing(62,387)). +legacyConfig(personTOthing(62,388)). +legacyConfig(personTOthing(62,389)). +legacyConfig(personTOthing(62,390)). +legacyConfig(personTOthing(63,391)). +legacyConfig(personTOthing(63,392)). +legacyConfig(personTOthing(63,393)). +legacyConfig(personTOthing(63,394)). +legacyConfig(personTOthing(63,395)). +legacyConfig(personTOthing(64,396)). +legacyConfig(personTOthing(64,397)). +legacyConfig(personTOthing(64,398)). +legacyConfig(personTOthing(64,399)). +legacyConfig(personTOthing(64,400)). +legacyConfig(personTOthing(65,401)). +legacyConfig(personTOthing(65,402)). +legacyConfig(personTOthing(65,403)). +legacyConfig(personTOthing(65,404)). +legacyConfig(personTOthing(65,405)). +legacyConfig(personTOthing(66,406)). +legacyConfig(personTOthing(66,407)). +legacyConfig(personTOthing(66,408)). +legacyConfig(personTOthing(66,409)). +legacyConfig(personTOthing(66,410)). +legacyConfig(personTOthing(67,411)). +legacyConfig(personTOthing(67,412)). +legacyConfig(personTOthing(67,413)). +legacyConfig(personTOthing(67,414)). +legacyConfig(personTOthing(67,415)). +legacyConfig(personTOthing(68,416)). +legacyConfig(personTOthing(68,417)). +legacyConfig(personTOthing(68,418)). +legacyConfig(personTOthing(68,419)). +legacyConfig(personTOthing(68,420)). +legacyConfig(personTOthing(69,421)). +legacyConfig(personTOthing(69,422)). +legacyConfig(personTOthing(69,423)). +legacyConfig(personTOthing(69,424)). +legacyConfig(personTOthing(69,425)). +legacyConfig(personTOthing(70,426)). +legacyConfig(personTOthing(70,427)). +legacyConfig(personTOthing(70,428)). +legacyConfig(personTOthing(70,429)). +legacyConfig(personTOthing(70,430)). +legacyConfig(personTOthing(71,431)). +legacyConfig(personTOthing(71,432)). +legacyConfig(personTOthing(71,433)). +legacyConfig(personTOthing(71,434)). +legacyConfig(personTOthing(71,435)). +legacyConfig(personTOthing(72,436)). +legacyConfig(personTOthing(72,437)). +legacyConfig(personTOthing(72,438)). +legacyConfig(personTOthing(72,439)). +legacyConfig(personTOthing(72,440)). +legacyConfig(personTOthing(73,441)). +legacyConfig(personTOthing(73,442)). +legacyConfig(personTOthing(73,443)). +legacyConfig(personTOthing(73,444)). +legacyConfig(personTOthing(73,445)). +legacyConfig(personTOthing(74,446)). +legacyConfig(personTOthing(74,447)). +legacyConfig(personTOthing(74,448)). +legacyConfig(personTOthing(74,449)). +legacyConfig(personTOthing(74,450)). +legacyConfig(personTOthing(75,451)). +legacyConfig(personTOthing(75,452)). +legacyConfig(personTOthing(75,453)). +legacyConfig(personTOthing(75,454)). +legacyConfig(personTOthing(75,455)). +legacyConfig(personTOthing(76,456)). +legacyConfig(personTOthing(76,457)). +legacyConfig(personTOthing(76,458)). +legacyConfig(personTOthing(76,459)). +legacyConfig(personTOthing(76,460)). +legacyConfig(personTOthing(77,461)). +legacyConfig(personTOthing(77,462)). +legacyConfig(personTOthing(77,463)). +legacyConfig(personTOthing(77,464)). +legacyConfig(personTOthing(77,465)). +legacyConfig(personTOthing(78,466)). +legacyConfig(personTOthing(78,467)). +legacyConfig(personTOthing(78,468)). +legacyConfig(personTOthing(78,469)). +legacyConfig(personTOthing(78,470)). +legacyConfig(personTOthing(79,471)). +legacyConfig(personTOthing(79,472)). +legacyConfig(personTOthing(79,473)). +legacyConfig(personTOthing(79,474)). +legacyConfig(personTOthing(79,475)). +legacyConfig(personTOthing(80,476)). +legacyConfig(personTOthing(80,477)). +legacyConfig(personTOthing(80,478)). +legacyConfig(personTOthing(80,479)). +legacyConfig(personTOthing(80,480)). +% domains +cabinetDomainNew(500..899). +roomDomainNew(1000..1399). +cabinetUpper(400). +roomUpper(400). +cabinetLower(80). +roomLower(20). +% reuse costs +reuseCabinetTOthingCost(0). +reuseRoomTOcabinetCost(0). +reusePersonTOroomCost(0). +reuseCabinetAsHighCost(3). +reuseCabinetAsSmallCost(0). +reuseRoomCost(0). +% remove costs +removeCabinetTOthingCost(2). +removeRoomTOcabinetCost(2). +removePersonTOroomCost(2). +removeCabinetCost(2). +removeRoomCost(2). +% create costs +cabinetHighCost(100). +cabinetSmallCost(1). +roomCost(5). diff --git a/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p85t425.edb b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p85t425.edb new file mode 100644 index 000000000..bf3fd682d --- /dev/null +++ b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p85t425.edb @@ -0,0 +1,1384 @@ +legacyConfig(person(1)). +legacyConfig(person(2)). +legacyConfig(person(3)). +legacyConfig(person(4)). +legacyConfig(person(5)). +legacyConfig(person(6)). +legacyConfig(person(7)). +legacyConfig(person(8)). +legacyConfig(person(9)). +legacyConfig(person(10)). +legacyConfig(person(11)). +legacyConfig(person(12)). +legacyConfig(person(13)). +legacyConfig(person(14)). +legacyConfig(person(15)). +legacyConfig(person(16)). +legacyConfig(person(17)). +legacyConfig(person(18)). +legacyConfig(person(19)). +legacyConfig(person(20)). +legacyConfig(person(21)). +legacyConfig(person(22)). +legacyConfig(person(23)). +legacyConfig(person(24)). +legacyConfig(person(25)). +legacyConfig(person(26)). +legacyConfig(person(27)). +legacyConfig(person(28)). +legacyConfig(person(29)). +legacyConfig(person(30)). +legacyConfig(person(31)). +legacyConfig(person(32)). +legacyConfig(person(33)). +legacyConfig(person(34)). +legacyConfig(person(35)). +legacyConfig(person(36)). +legacyConfig(person(37)). +legacyConfig(person(38)). +legacyConfig(person(39)). +legacyConfig(person(40)). +legacyConfig(person(41)). +legacyConfig(person(42)). +legacyConfig(person(43)). +legacyConfig(person(44)). +legacyConfig(person(45)). +legacyConfig(person(46)). +legacyConfig(person(47)). +legacyConfig(person(48)). +legacyConfig(person(49)). +legacyConfig(person(50)). +legacyConfig(person(51)). +legacyConfig(person(52)). +legacyConfig(person(53)). +legacyConfig(person(54)). +legacyConfig(person(55)). +legacyConfig(person(56)). +legacyConfig(person(57)). +legacyConfig(person(58)). +legacyConfig(person(59)). +legacyConfig(person(60)). +legacyConfig(person(61)). +legacyConfig(person(62)). +legacyConfig(person(63)). +legacyConfig(person(64)). +legacyConfig(person(65)). +legacyConfig(person(66)). +legacyConfig(person(67)). +legacyConfig(person(68)). +legacyConfig(person(69)). +legacyConfig(person(70)). +legacyConfig(person(71)). +legacyConfig(person(72)). +legacyConfig(person(73)). +legacyConfig(person(74)). +legacyConfig(person(75)). +legacyConfig(person(76)). +legacyConfig(person(77)). +legacyConfig(person(78)). +legacyConfig(person(79)). +legacyConfig(person(80)). +legacyConfig(person(81)). +legacyConfig(person(82)). +legacyConfig(person(83)). +legacyConfig(person(84)). +legacyConfig(person(85)). +legacyConfig(thing(86)). +thingShort(86). +legacyConfig(thing(87)). +thingShort(87). +legacyConfig(thing(88)). +thingShort(88). +legacyConfig(thing(89)). +thingShort(89). +legacyConfig(thing(90)). +thingShort(90). +legacyConfig(thing(91)). +thingShort(91). +legacyConfig(thing(92)). +thingShort(92). +legacyConfig(thing(93)). +thingShort(93). +legacyConfig(thing(94)). +thingShort(94). +legacyConfig(thing(95)). +thingShort(95). +legacyConfig(thing(96)). +thingShort(96). +legacyConfig(thing(97)). +thingShort(97). +legacyConfig(thing(98)). +thingShort(98). +legacyConfig(thing(99)). +thingShort(99). +legacyConfig(thing(100)). +thingShort(100). +legacyConfig(thing(101)). +thingShort(101). +legacyConfig(thing(102)). +thingShort(102). +legacyConfig(thing(103)). +thingShort(103). +legacyConfig(thing(104)). +thingShort(104). +legacyConfig(thing(105)). +thingShort(105). +legacyConfig(thing(106)). +thingShort(106). +legacyConfig(thing(107)). +thingShort(107). +legacyConfig(thing(108)). +thingShort(108). +legacyConfig(thing(109)). +thingShort(109). +legacyConfig(thing(110)). +thingShort(110). +legacyConfig(thing(111)). +thingShort(111). +legacyConfig(thing(112)). +thingShort(112). +legacyConfig(thing(113)). +thingShort(113). +legacyConfig(thing(114)). +thingShort(114). +legacyConfig(thing(115)). +thingShort(115). +legacyConfig(thing(116)). +thingShort(116). +legacyConfig(thing(117)). +thingShort(117). +legacyConfig(thing(118)). +thingShort(118). +legacyConfig(thing(119)). +thingShort(119). +legacyConfig(thing(120)). +thingShort(120). +legacyConfig(thing(121)). +thingShort(121). +legacyConfig(thing(122)). +thingShort(122). +legacyConfig(thing(123)). +thingShort(123). +legacyConfig(thing(124)). +thingShort(124). +legacyConfig(thing(125)). +thingShort(125). +legacyConfig(thing(126)). +thingShort(126). +legacyConfig(thing(127)). +thingShort(127). +legacyConfig(thing(128)). +thingShort(128). +legacyConfig(thing(129)). +thingShort(129). +legacyConfig(thing(130)). +thingShort(130). +legacyConfig(thing(131)). +thingShort(131). +legacyConfig(thing(132)). +thingShort(132). +legacyConfig(thing(133)). +thingShort(133). +legacyConfig(thing(134)). +thingShort(134). +legacyConfig(thing(135)). +thingShort(135). +legacyConfig(thing(136)). +thingShort(136). +legacyConfig(thing(137)). +thingShort(137). +legacyConfig(thing(138)). +thingShort(138). +legacyConfig(thing(139)). +thingShort(139). +legacyConfig(thing(140)). +thingShort(140). +legacyConfig(thing(141)). +thingShort(141). +legacyConfig(thing(142)). +thingShort(142). +legacyConfig(thing(143)). +thingShort(143). +legacyConfig(thing(144)). +thingShort(144). +legacyConfig(thing(145)). +thingShort(145). +legacyConfig(thing(146)). +thingShort(146). +legacyConfig(thing(147)). +thingShort(147). +legacyConfig(thing(148)). +thingShort(148). +legacyConfig(thing(149)). +thingShort(149). +legacyConfig(thing(150)). +thingShort(150). +legacyConfig(thing(151)). +thingShort(151). +legacyConfig(thing(152)). +thingShort(152). +legacyConfig(thing(153)). +thingShort(153). +legacyConfig(thing(154)). +thingShort(154). +legacyConfig(thing(155)). +thingShort(155). +legacyConfig(thing(156)). +thingShort(156). +legacyConfig(thing(157)). +thingShort(157). +legacyConfig(thing(158)). +thingShort(158). +legacyConfig(thing(159)). +thingShort(159). +legacyConfig(thing(160)). +thingShort(160). +legacyConfig(thing(161)). +thingShort(161). +legacyConfig(thing(162)). +thingShort(162). +legacyConfig(thing(163)). +thingShort(163). +legacyConfig(thing(164)). +thingShort(164). +legacyConfig(thing(165)). +thingShort(165). +legacyConfig(thing(166)). +thingShort(166). +legacyConfig(thing(167)). +thingShort(167). +legacyConfig(thing(168)). +thingShort(168). +legacyConfig(thing(169)). +thingShort(169). +legacyConfig(thing(170)). +thingShort(170). +legacyConfig(thing(171)). +thingShort(171). +legacyConfig(thing(172)). +thingShort(172). +legacyConfig(thing(173)). +thingShort(173). +legacyConfig(thing(174)). +thingShort(174). +legacyConfig(thing(175)). +thingShort(175). +legacyConfig(thing(176)). +thingShort(176). +legacyConfig(thing(177)). +thingShort(177). +legacyConfig(thing(178)). +thingShort(178). +legacyConfig(thing(179)). +thingShort(179). +legacyConfig(thing(180)). +thingShort(180). +legacyConfig(thing(181)). +thingShort(181). +legacyConfig(thing(182)). +thingShort(182). +legacyConfig(thing(183)). +thingShort(183). +legacyConfig(thing(184)). +thingShort(184). +legacyConfig(thing(185)). +thingShort(185). +legacyConfig(thing(186)). +thingShort(186). +legacyConfig(thing(187)). +thingShort(187). +legacyConfig(thing(188)). +thingShort(188). +legacyConfig(thing(189)). +thingShort(189). +legacyConfig(thing(190)). +thingShort(190). +legacyConfig(thing(191)). +thingShort(191). +legacyConfig(thing(192)). +thingShort(192). +legacyConfig(thing(193)). +thingShort(193). +legacyConfig(thing(194)). +thingShort(194). +legacyConfig(thing(195)). +thingShort(195). +legacyConfig(thing(196)). +thingShort(196). +legacyConfig(thing(197)). +thingShort(197). +legacyConfig(thing(198)). +thingShort(198). +legacyConfig(thing(199)). +thingShort(199). +legacyConfig(thing(200)). +thingShort(200). +legacyConfig(thing(201)). +thingShort(201). +legacyConfig(thing(202)). +thingShort(202). +legacyConfig(thing(203)). +thingShort(203). +legacyConfig(thing(204)). +thingShort(204). +legacyConfig(thing(205)). +thingShort(205). +legacyConfig(thing(206)). +thingShort(206). +legacyConfig(thing(207)). +thingShort(207). +legacyConfig(thing(208)). +thingShort(208). +legacyConfig(thing(209)). +thingShort(209). +legacyConfig(thing(210)). +thingShort(210). +legacyConfig(thing(211)). +thingShort(211). +legacyConfig(thing(212)). +thingShort(212). +legacyConfig(thing(213)). +thingShort(213). +legacyConfig(thing(214)). +thingShort(214). +legacyConfig(thing(215)). +thingShort(215). +legacyConfig(thing(216)). +thingShort(216). +legacyConfig(thing(217)). +thingShort(217). +legacyConfig(thing(218)). +thingShort(218). +legacyConfig(thing(219)). +thingShort(219). +legacyConfig(thing(220)). +thingShort(220). +legacyConfig(thing(221)). +thingShort(221). +legacyConfig(thing(222)). +thingShort(222). +legacyConfig(thing(223)). +thingShort(223). +legacyConfig(thing(224)). +thingShort(224). +legacyConfig(thing(225)). +thingShort(225). +legacyConfig(thing(226)). +thingShort(226). +legacyConfig(thing(227)). +thingShort(227). +legacyConfig(thing(228)). +thingShort(228). +legacyConfig(thing(229)). +thingShort(229). +legacyConfig(thing(230)). +thingShort(230). +legacyConfig(thing(231)). +thingShort(231). +legacyConfig(thing(232)). +thingShort(232). +legacyConfig(thing(233)). +thingShort(233). +legacyConfig(thing(234)). +thingShort(234). +legacyConfig(thing(235)). +thingShort(235). +legacyConfig(thing(236)). +thingShort(236). +legacyConfig(thing(237)). +thingShort(237). +legacyConfig(thing(238)). +thingShort(238). +legacyConfig(thing(239)). +thingShort(239). +legacyConfig(thing(240)). +thingShort(240). +legacyConfig(thing(241)). +thingShort(241). +legacyConfig(thing(242)). +thingShort(242). +legacyConfig(thing(243)). +thingShort(243). +legacyConfig(thing(244)). +thingShort(244). +legacyConfig(thing(245)). +thingShort(245). +legacyConfig(thing(246)). +thingShort(246). +legacyConfig(thing(247)). +thingShort(247). +legacyConfig(thing(248)). +thingShort(248). +legacyConfig(thing(249)). +thingShort(249). +legacyConfig(thing(250)). +thingShort(250). +legacyConfig(thing(251)). +thingShort(251). +legacyConfig(thing(252)). +thingShort(252). +legacyConfig(thing(253)). +thingShort(253). +legacyConfig(thing(254)). +thingShort(254). +legacyConfig(thing(255)). +thingShort(255). +legacyConfig(thing(256)). +thingShort(256). +legacyConfig(thing(257)). +thingShort(257). +legacyConfig(thing(258)). +thingShort(258). +legacyConfig(thing(259)). +thingShort(259). +legacyConfig(thing(260)). +thingShort(260). +legacyConfig(thing(261)). +thingShort(261). +legacyConfig(thing(262)). +thingShort(262). +legacyConfig(thing(263)). +thingShort(263). +legacyConfig(thing(264)). +thingShort(264). +legacyConfig(thing(265)). +thingShort(265). +legacyConfig(thing(266)). +thingShort(266). +legacyConfig(thing(267)). +thingShort(267). +legacyConfig(thing(268)). +thingShort(268). +legacyConfig(thing(269)). +thingShort(269). +legacyConfig(thing(270)). +thingShort(270). +legacyConfig(thing(271)). +thingShort(271). +legacyConfig(thing(272)). +thingShort(272). +legacyConfig(thing(273)). +thingShort(273). +legacyConfig(thing(274)). +thingShort(274). +legacyConfig(thing(275)). +thingShort(275). +legacyConfig(thing(276)). +thingShort(276). +legacyConfig(thing(277)). +thingShort(277). +legacyConfig(thing(278)). +thingShort(278). +legacyConfig(thing(279)). +thingShort(279). +legacyConfig(thing(280)). +thingShort(280). +legacyConfig(thing(281)). +thingShort(281). +legacyConfig(thing(282)). +thingShort(282). +legacyConfig(thing(283)). +thingShort(283). +legacyConfig(thing(284)). +thingShort(284). +legacyConfig(thing(285)). +thingShort(285). +legacyConfig(thing(286)). +thingShort(286). +legacyConfig(thing(287)). +thingShort(287). +legacyConfig(thing(288)). +thingShort(288). +legacyConfig(thing(289)). +thingShort(289). +legacyConfig(thing(290)). +thingShort(290). +legacyConfig(thing(291)). +thingShort(291). +legacyConfig(thing(292)). +thingShort(292). +legacyConfig(thing(293)). +thingShort(293). +legacyConfig(thing(294)). +thingShort(294). +legacyConfig(thing(295)). +thingShort(295). +legacyConfig(thing(296)). +thingShort(296). +legacyConfig(thing(297)). +thingShort(297). +legacyConfig(thing(298)). +thingShort(298). +legacyConfig(thing(299)). +thingShort(299). +legacyConfig(thing(300)). +thingShort(300). +legacyConfig(thing(301)). +thingShort(301). +legacyConfig(thing(302)). +thingShort(302). +legacyConfig(thing(303)). +thingShort(303). +legacyConfig(thing(304)). +thingShort(304). +legacyConfig(thing(305)). +thingShort(305). +legacyConfig(thing(306)). +thingShort(306). +legacyConfig(thing(307)). +thingShort(307). +legacyConfig(thing(308)). +thingShort(308). +legacyConfig(thing(309)). +thingShort(309). +legacyConfig(thing(310)). +thingShort(310). +legacyConfig(thing(311)). +thingShort(311). +legacyConfig(thing(312)). +thingShort(312). +legacyConfig(thing(313)). +thingShort(313). +legacyConfig(thing(314)). +thingShort(314). +legacyConfig(thing(315)). +thingShort(315). +legacyConfig(thing(316)). +thingShort(316). +legacyConfig(thing(317)). +thingShort(317). +legacyConfig(thing(318)). +thingShort(318). +legacyConfig(thing(319)). +thingShort(319). +legacyConfig(thing(320)). +thingShort(320). +legacyConfig(thing(321)). +thingShort(321). +legacyConfig(thing(322)). +thingShort(322). +legacyConfig(thing(323)). +thingShort(323). +legacyConfig(thing(324)). +thingShort(324). +legacyConfig(thing(325)). +thingShort(325). +legacyConfig(thing(326)). +thingShort(326). +legacyConfig(thing(327)). +thingShort(327). +legacyConfig(thing(328)). +thingShort(328). +legacyConfig(thing(329)). +thingShort(329). +legacyConfig(thing(330)). +thingShort(330). +legacyConfig(thing(331)). +thingShort(331). +legacyConfig(thing(332)). +thingShort(332). +legacyConfig(thing(333)). +thingShort(333). +legacyConfig(thing(334)). +thingShort(334). +legacyConfig(thing(335)). +thingShort(335). +legacyConfig(thing(336)). +thingShort(336). +legacyConfig(thing(337)). +thingShort(337). +legacyConfig(thing(338)). +thingShort(338). +legacyConfig(thing(339)). +thingShort(339). +legacyConfig(thing(340)). +thingShort(340). +legacyConfig(thing(341)). +thingShort(341). +legacyConfig(thing(342)). +thingShort(342). +legacyConfig(thing(343)). +thingShort(343). +legacyConfig(thing(344)). +thingShort(344). +legacyConfig(thing(345)). +thingShort(345). +legacyConfig(thing(346)). +thingShort(346). +legacyConfig(thing(347)). +thingShort(347). +legacyConfig(thing(348)). +thingShort(348). +legacyConfig(thing(349)). +thingShort(349). +legacyConfig(thing(350)). +thingShort(350). +legacyConfig(thing(351)). +thingShort(351). +legacyConfig(thing(352)). +thingShort(352). +legacyConfig(thing(353)). +thingShort(353). +legacyConfig(thing(354)). +thingShort(354). +legacyConfig(thing(355)). +thingShort(355). +legacyConfig(thing(356)). +thingShort(356). +legacyConfig(thing(357)). +thingShort(357). +legacyConfig(thing(358)). +thingShort(358). +legacyConfig(thing(359)). +thingShort(359). +legacyConfig(thing(360)). +thingShort(360). +legacyConfig(thing(361)). +thingShort(361). +legacyConfig(thing(362)). +thingShort(362). +legacyConfig(thing(363)). +thingShort(363). +legacyConfig(thing(364)). +thingShort(364). +legacyConfig(thing(365)). +thingShort(365). +legacyConfig(thing(366)). +thingShort(366). +legacyConfig(thing(367)). +thingShort(367). +legacyConfig(thing(368)). +thingShort(368). +legacyConfig(thing(369)). +thingShort(369). +legacyConfig(thing(370)). +thingShort(370). +legacyConfig(thing(371)). +thingShort(371). +legacyConfig(thing(372)). +thingShort(372). +legacyConfig(thing(373)). +thingShort(373). +legacyConfig(thing(374)). +thingShort(374). +legacyConfig(thing(375)). +thingShort(375). +legacyConfig(thing(376)). +thingShort(376). +legacyConfig(thing(377)). +thingShort(377). +legacyConfig(thing(378)). +thingShort(378). +legacyConfig(thing(379)). +thingShort(379). +legacyConfig(thing(380)). +thingShort(380). +legacyConfig(thing(381)). +thingShort(381). +legacyConfig(thing(382)). +thingShort(382). +legacyConfig(thing(383)). +thingShort(383). +legacyConfig(thing(384)). +thingShort(384). +legacyConfig(thing(385)). +thingShort(385). +legacyConfig(thing(386)). +thingShort(386). +legacyConfig(thing(387)). +thingShort(387). +legacyConfig(thing(388)). +thingShort(388). +legacyConfig(thing(389)). +thingShort(389). +legacyConfig(thing(390)). +thingShort(390). +legacyConfig(thing(391)). +thingShort(391). +legacyConfig(thing(392)). +thingShort(392). +legacyConfig(thing(393)). +thingShort(393). +legacyConfig(thing(394)). +thingShort(394). +legacyConfig(thing(395)). +thingShort(395). +legacyConfig(thing(396)). +thingShort(396). +legacyConfig(thing(397)). +thingShort(397). +legacyConfig(thing(398)). +thingShort(398). +legacyConfig(thing(399)). +thingShort(399). +legacyConfig(thing(400)). +thingShort(400). +legacyConfig(thing(401)). +thingShort(401). +legacyConfig(thing(402)). +thingShort(402). +legacyConfig(thing(403)). +thingShort(403). +legacyConfig(thing(404)). +thingShort(404). +legacyConfig(thing(405)). +thingShort(405). +legacyConfig(thing(406)). +thingShort(406). +legacyConfig(thing(407)). +thingShort(407). +legacyConfig(thing(408)). +thingShort(408). +legacyConfig(thing(409)). +thingShort(409). +legacyConfig(thing(410)). +thingShort(410). +legacyConfig(thing(411)). +thingShort(411). +legacyConfig(thing(412)). +thingShort(412). +legacyConfig(thing(413)). +thingShort(413). +legacyConfig(thing(414)). +thingShort(414). +legacyConfig(thing(415)). +thingShort(415). +legacyConfig(thing(416)). +thingShort(416). +legacyConfig(thing(417)). +thingShort(417). +legacyConfig(thing(418)). +thingShort(418). +legacyConfig(thing(419)). +thingShort(419). +legacyConfig(thing(420)). +thingShort(420). +legacyConfig(thing(421)). +thingShort(421). +legacyConfig(thing(422)). +thingShort(422). +legacyConfig(thing(423)). +thingShort(423). +legacyConfig(thing(424)). +thingShort(424). +legacyConfig(thing(425)). +thingShort(425). +legacyConfig(thing(426)). +thingShort(426). +legacyConfig(thing(427)). +thingShort(427). +legacyConfig(thing(428)). +thingShort(428). +legacyConfig(thing(429)). +thingShort(429). +legacyConfig(thing(430)). +thingShort(430). +legacyConfig(thing(431)). +thingShort(431). +legacyConfig(thing(432)). +thingShort(432). +legacyConfig(thing(433)). +thingShort(433). +legacyConfig(thing(434)). +thingShort(434). +legacyConfig(thing(435)). +thingShort(435). +legacyConfig(thing(436)). +thingShort(436). +legacyConfig(thing(437)). +thingShort(437). +legacyConfig(thing(438)). +thingShort(438). +legacyConfig(thing(439)). +thingShort(439). +legacyConfig(thing(440)). +thingShort(440). +legacyConfig(thing(441)). +thingShort(441). +legacyConfig(thing(442)). +thingShort(442). +legacyConfig(thing(443)). +thingShort(443). +legacyConfig(thing(444)). +thingShort(444). +legacyConfig(thing(445)). +thingShort(445). +legacyConfig(thing(446)). +thingShort(446). +legacyConfig(thing(447)). +thingShort(447). +legacyConfig(thing(448)). +thingShort(448). +legacyConfig(thing(449)). +thingShort(449). +legacyConfig(thing(450)). +thingShort(450). +legacyConfig(thing(451)). +thingShort(451). +legacyConfig(thing(452)). +thingShort(452). +legacyConfig(thing(453)). +thingShort(453). +legacyConfig(thing(454)). +thingShort(454). +legacyConfig(thing(455)). +thingShort(455). +legacyConfig(thing(456)). +thingShort(456). +legacyConfig(thing(457)). +thingShort(457). +legacyConfig(thing(458)). +thingShort(458). +legacyConfig(thing(459)). +thingShort(459). +legacyConfig(thing(460)). +thingShort(460). +legacyConfig(thing(461)). +thingShort(461). +legacyConfig(thing(462)). +thingShort(462). +legacyConfig(thing(463)). +thingShort(463). +legacyConfig(thing(464)). +thingShort(464). +legacyConfig(thing(465)). +thingShort(465). +legacyConfig(thing(466)). +thingShort(466). +legacyConfig(thing(467)). +thingShort(467). +legacyConfig(thing(468)). +thingShort(468). +legacyConfig(thing(469)). +thingShort(469). +legacyConfig(thing(470)). +thingShort(470). +legacyConfig(thing(471)). +thingShort(471). +legacyConfig(thing(472)). +thingShort(472). +legacyConfig(thing(473)). +thingShort(473). +legacyConfig(thing(474)). +thingShort(474). +legacyConfig(thing(475)). +thingShort(475). +legacyConfig(thing(476)). +thingShort(476). +legacyConfig(thing(477)). +thingShort(477). +legacyConfig(thing(478)). +thingShort(478). +legacyConfig(thing(479)). +thingShort(479). +legacyConfig(thing(480)). +thingShort(480). +legacyConfig(thing(481)). +thingShort(481). +legacyConfig(thing(482)). +thingShort(482). +legacyConfig(thing(483)). +thingShort(483). +legacyConfig(thing(484)). +thingShort(484). +legacyConfig(thing(485)). +thingShort(485). +legacyConfig(thing(486)). +thingShort(486). +legacyConfig(thing(487)). +thingShort(487). +legacyConfig(thing(488)). +thingShort(488). +legacyConfig(thing(489)). +thingShort(489). +legacyConfig(thing(490)). +thingShort(490). +legacyConfig(thing(491)). +thingShort(491). +legacyConfig(thing(492)). +thingShort(492). +legacyConfig(thing(493)). +thingShort(493). +legacyConfig(thing(494)). +thingShort(494). +legacyConfig(thing(495)). +thingShort(495). +legacyConfig(thing(496)). +thingShort(496). +legacyConfig(thing(497)). +thingShort(497). +legacyConfig(thing(498)). +thingShort(498). +legacyConfig(thing(499)). +thingShort(499). +legacyConfig(thing(500)). +thingShort(500). +legacyConfig(thing(501)). +thingShort(501). +legacyConfig(thing(502)). +thingShort(502). +legacyConfig(thing(503)). +thingShort(503). +legacyConfig(thing(504)). +thingShort(504). +legacyConfig(thing(505)). +thingShort(505). +legacyConfig(thing(506)). +thingShort(506). +legacyConfig(thing(507)). +thingShort(507). +legacyConfig(thing(508)). +thingShort(508). +legacyConfig(thing(509)). +thingShort(509). +legacyConfig(thing(510)). +thingShort(510). +legacyConfig(personTOthing(1,86)). +legacyConfig(personTOthing(1,87)). +legacyConfig(personTOthing(1,88)). +legacyConfig(personTOthing(1,89)). +legacyConfig(personTOthing(1,90)). +legacyConfig(personTOthing(2,91)). +legacyConfig(personTOthing(2,92)). +legacyConfig(personTOthing(2,93)). +legacyConfig(personTOthing(2,94)). +legacyConfig(personTOthing(2,95)). +legacyConfig(personTOthing(3,96)). +legacyConfig(personTOthing(3,97)). +legacyConfig(personTOthing(3,98)). +legacyConfig(personTOthing(3,99)). +legacyConfig(personTOthing(3,100)). +legacyConfig(personTOthing(4,101)). +legacyConfig(personTOthing(4,102)). +legacyConfig(personTOthing(4,103)). +legacyConfig(personTOthing(4,104)). +legacyConfig(personTOthing(4,105)). +legacyConfig(personTOthing(5,106)). +legacyConfig(personTOthing(5,107)). +legacyConfig(personTOthing(5,108)). +legacyConfig(personTOthing(5,109)). +legacyConfig(personTOthing(5,110)). +legacyConfig(personTOthing(6,111)). +legacyConfig(personTOthing(6,112)). +legacyConfig(personTOthing(6,113)). +legacyConfig(personTOthing(6,114)). +legacyConfig(personTOthing(6,115)). +legacyConfig(personTOthing(7,116)). +legacyConfig(personTOthing(7,117)). +legacyConfig(personTOthing(7,118)). +legacyConfig(personTOthing(7,119)). +legacyConfig(personTOthing(7,120)). +legacyConfig(personTOthing(8,121)). +legacyConfig(personTOthing(8,122)). +legacyConfig(personTOthing(8,123)). +legacyConfig(personTOthing(8,124)). +legacyConfig(personTOthing(8,125)). +legacyConfig(personTOthing(9,126)). +legacyConfig(personTOthing(9,127)). +legacyConfig(personTOthing(9,128)). +legacyConfig(personTOthing(9,129)). +legacyConfig(personTOthing(9,130)). +legacyConfig(personTOthing(10,131)). +legacyConfig(personTOthing(10,132)). +legacyConfig(personTOthing(10,133)). +legacyConfig(personTOthing(10,134)). +legacyConfig(personTOthing(10,135)). +legacyConfig(personTOthing(11,136)). +legacyConfig(personTOthing(11,137)). +legacyConfig(personTOthing(11,138)). +legacyConfig(personTOthing(11,139)). +legacyConfig(personTOthing(11,140)). +legacyConfig(personTOthing(12,141)). +legacyConfig(personTOthing(12,142)). +legacyConfig(personTOthing(12,143)). +legacyConfig(personTOthing(12,144)). +legacyConfig(personTOthing(12,145)). +legacyConfig(personTOthing(13,146)). +legacyConfig(personTOthing(13,147)). +legacyConfig(personTOthing(13,148)). +legacyConfig(personTOthing(13,149)). +legacyConfig(personTOthing(13,150)). +legacyConfig(personTOthing(14,151)). +legacyConfig(personTOthing(14,152)). +legacyConfig(personTOthing(14,153)). +legacyConfig(personTOthing(14,154)). +legacyConfig(personTOthing(14,155)). +legacyConfig(personTOthing(15,156)). +legacyConfig(personTOthing(15,157)). +legacyConfig(personTOthing(15,158)). +legacyConfig(personTOthing(15,159)). +legacyConfig(personTOthing(15,160)). +legacyConfig(personTOthing(16,161)). +legacyConfig(personTOthing(16,162)). +legacyConfig(personTOthing(16,163)). +legacyConfig(personTOthing(16,164)). +legacyConfig(personTOthing(16,165)). +legacyConfig(personTOthing(17,166)). +legacyConfig(personTOthing(17,167)). +legacyConfig(personTOthing(17,168)). +legacyConfig(personTOthing(17,169)). +legacyConfig(personTOthing(17,170)). +legacyConfig(personTOthing(18,171)). +legacyConfig(personTOthing(18,172)). +legacyConfig(personTOthing(18,173)). +legacyConfig(personTOthing(18,174)). +legacyConfig(personTOthing(18,175)). +legacyConfig(personTOthing(19,176)). +legacyConfig(personTOthing(19,177)). +legacyConfig(personTOthing(19,178)). +legacyConfig(personTOthing(19,179)). +legacyConfig(personTOthing(19,180)). +legacyConfig(personTOthing(20,181)). +legacyConfig(personTOthing(20,182)). +legacyConfig(personTOthing(20,183)). +legacyConfig(personTOthing(20,184)). +legacyConfig(personTOthing(20,185)). +legacyConfig(personTOthing(21,186)). +legacyConfig(personTOthing(21,187)). +legacyConfig(personTOthing(21,188)). +legacyConfig(personTOthing(21,189)). +legacyConfig(personTOthing(21,190)). +legacyConfig(personTOthing(22,191)). +legacyConfig(personTOthing(22,192)). +legacyConfig(personTOthing(22,193)). +legacyConfig(personTOthing(22,194)). +legacyConfig(personTOthing(22,195)). +legacyConfig(personTOthing(23,196)). +legacyConfig(personTOthing(23,197)). +legacyConfig(personTOthing(23,198)). +legacyConfig(personTOthing(23,199)). +legacyConfig(personTOthing(23,200)). +legacyConfig(personTOthing(24,201)). +legacyConfig(personTOthing(24,202)). +legacyConfig(personTOthing(24,203)). +legacyConfig(personTOthing(24,204)). +legacyConfig(personTOthing(24,205)). +legacyConfig(personTOthing(25,206)). +legacyConfig(personTOthing(25,207)). +legacyConfig(personTOthing(25,208)). +legacyConfig(personTOthing(25,209)). +legacyConfig(personTOthing(25,210)). +legacyConfig(personTOthing(26,211)). +legacyConfig(personTOthing(26,212)). +legacyConfig(personTOthing(26,213)). +legacyConfig(personTOthing(26,214)). +legacyConfig(personTOthing(26,215)). +legacyConfig(personTOthing(27,216)). +legacyConfig(personTOthing(27,217)). +legacyConfig(personTOthing(27,218)). +legacyConfig(personTOthing(27,219)). +legacyConfig(personTOthing(27,220)). +legacyConfig(personTOthing(28,221)). +legacyConfig(personTOthing(28,222)). +legacyConfig(personTOthing(28,223)). +legacyConfig(personTOthing(28,224)). +legacyConfig(personTOthing(28,225)). +legacyConfig(personTOthing(29,226)). +legacyConfig(personTOthing(29,227)). +legacyConfig(personTOthing(29,228)). +legacyConfig(personTOthing(29,229)). +legacyConfig(personTOthing(29,230)). +legacyConfig(personTOthing(30,231)). +legacyConfig(personTOthing(30,232)). +legacyConfig(personTOthing(30,233)). +legacyConfig(personTOthing(30,234)). +legacyConfig(personTOthing(30,235)). +legacyConfig(personTOthing(31,236)). +legacyConfig(personTOthing(31,237)). +legacyConfig(personTOthing(31,238)). +legacyConfig(personTOthing(31,239)). +legacyConfig(personTOthing(31,240)). +legacyConfig(personTOthing(32,241)). +legacyConfig(personTOthing(32,242)). +legacyConfig(personTOthing(32,243)). +legacyConfig(personTOthing(32,244)). +legacyConfig(personTOthing(32,245)). +legacyConfig(personTOthing(33,246)). +legacyConfig(personTOthing(33,247)). +legacyConfig(personTOthing(33,248)). +legacyConfig(personTOthing(33,249)). +legacyConfig(personTOthing(33,250)). +legacyConfig(personTOthing(34,251)). +legacyConfig(personTOthing(34,252)). +legacyConfig(personTOthing(34,253)). +legacyConfig(personTOthing(34,254)). +legacyConfig(personTOthing(34,255)). +legacyConfig(personTOthing(35,256)). +legacyConfig(personTOthing(35,257)). +legacyConfig(personTOthing(35,258)). +legacyConfig(personTOthing(35,259)). +legacyConfig(personTOthing(35,260)). +legacyConfig(personTOthing(36,261)). +legacyConfig(personTOthing(36,262)). +legacyConfig(personTOthing(36,263)). +legacyConfig(personTOthing(36,264)). +legacyConfig(personTOthing(36,265)). +legacyConfig(personTOthing(37,266)). +legacyConfig(personTOthing(37,267)). +legacyConfig(personTOthing(37,268)). +legacyConfig(personTOthing(37,269)). +legacyConfig(personTOthing(37,270)). +legacyConfig(personTOthing(38,271)). +legacyConfig(personTOthing(38,272)). +legacyConfig(personTOthing(38,273)). +legacyConfig(personTOthing(38,274)). +legacyConfig(personTOthing(38,275)). +legacyConfig(personTOthing(39,276)). +legacyConfig(personTOthing(39,277)). +legacyConfig(personTOthing(39,278)). +legacyConfig(personTOthing(39,279)). +legacyConfig(personTOthing(39,280)). +legacyConfig(personTOthing(40,281)). +legacyConfig(personTOthing(40,282)). +legacyConfig(personTOthing(40,283)). +legacyConfig(personTOthing(40,284)). +legacyConfig(personTOthing(40,285)). +legacyConfig(personTOthing(41,286)). +legacyConfig(personTOthing(41,287)). +legacyConfig(personTOthing(41,288)). +legacyConfig(personTOthing(41,289)). +legacyConfig(personTOthing(41,290)). +legacyConfig(personTOthing(42,291)). +legacyConfig(personTOthing(42,292)). +legacyConfig(personTOthing(42,293)). +legacyConfig(personTOthing(42,294)). +legacyConfig(personTOthing(42,295)). +legacyConfig(personTOthing(43,296)). +legacyConfig(personTOthing(43,297)). +legacyConfig(personTOthing(43,298)). +legacyConfig(personTOthing(43,299)). +legacyConfig(personTOthing(43,300)). +legacyConfig(personTOthing(44,301)). +legacyConfig(personTOthing(44,302)). +legacyConfig(personTOthing(44,303)). +legacyConfig(personTOthing(44,304)). +legacyConfig(personTOthing(44,305)). +legacyConfig(personTOthing(45,306)). +legacyConfig(personTOthing(45,307)). +legacyConfig(personTOthing(45,308)). +legacyConfig(personTOthing(45,309)). +legacyConfig(personTOthing(45,310)). +legacyConfig(personTOthing(46,311)). +legacyConfig(personTOthing(46,312)). +legacyConfig(personTOthing(46,313)). +legacyConfig(personTOthing(46,314)). +legacyConfig(personTOthing(46,315)). +legacyConfig(personTOthing(47,316)). +legacyConfig(personTOthing(47,317)). +legacyConfig(personTOthing(47,318)). +legacyConfig(personTOthing(47,319)). +legacyConfig(personTOthing(47,320)). +legacyConfig(personTOthing(48,321)). +legacyConfig(personTOthing(48,322)). +legacyConfig(personTOthing(48,323)). +legacyConfig(personTOthing(48,324)). +legacyConfig(personTOthing(48,325)). +legacyConfig(personTOthing(49,326)). +legacyConfig(personTOthing(49,327)). +legacyConfig(personTOthing(49,328)). +legacyConfig(personTOthing(49,329)). +legacyConfig(personTOthing(49,330)). +legacyConfig(personTOthing(50,331)). +legacyConfig(personTOthing(50,332)). +legacyConfig(personTOthing(50,333)). +legacyConfig(personTOthing(50,334)). +legacyConfig(personTOthing(50,335)). +legacyConfig(personTOthing(51,336)). +legacyConfig(personTOthing(51,337)). +legacyConfig(personTOthing(51,338)). +legacyConfig(personTOthing(51,339)). +legacyConfig(personTOthing(51,340)). +legacyConfig(personTOthing(52,341)). +legacyConfig(personTOthing(52,342)). +legacyConfig(personTOthing(52,343)). +legacyConfig(personTOthing(52,344)). +legacyConfig(personTOthing(52,345)). +legacyConfig(personTOthing(53,346)). +legacyConfig(personTOthing(53,347)). +legacyConfig(personTOthing(53,348)). +legacyConfig(personTOthing(53,349)). +legacyConfig(personTOthing(53,350)). +legacyConfig(personTOthing(54,351)). +legacyConfig(personTOthing(54,352)). +legacyConfig(personTOthing(54,353)). +legacyConfig(personTOthing(54,354)). +legacyConfig(personTOthing(54,355)). +legacyConfig(personTOthing(55,356)). +legacyConfig(personTOthing(55,357)). +legacyConfig(personTOthing(55,358)). +legacyConfig(personTOthing(55,359)). +legacyConfig(personTOthing(55,360)). +legacyConfig(personTOthing(56,361)). +legacyConfig(personTOthing(56,362)). +legacyConfig(personTOthing(56,363)). +legacyConfig(personTOthing(56,364)). +legacyConfig(personTOthing(56,365)). +legacyConfig(personTOthing(57,366)). +legacyConfig(personTOthing(57,367)). +legacyConfig(personTOthing(57,368)). +legacyConfig(personTOthing(57,369)). +legacyConfig(personTOthing(57,370)). +legacyConfig(personTOthing(58,371)). +legacyConfig(personTOthing(58,372)). +legacyConfig(personTOthing(58,373)). +legacyConfig(personTOthing(58,374)). +legacyConfig(personTOthing(58,375)). +legacyConfig(personTOthing(59,376)). +legacyConfig(personTOthing(59,377)). +legacyConfig(personTOthing(59,378)). +legacyConfig(personTOthing(59,379)). +legacyConfig(personTOthing(59,380)). +legacyConfig(personTOthing(60,381)). +legacyConfig(personTOthing(60,382)). +legacyConfig(personTOthing(60,383)). +legacyConfig(personTOthing(60,384)). +legacyConfig(personTOthing(60,385)). +legacyConfig(personTOthing(61,386)). +legacyConfig(personTOthing(61,387)). +legacyConfig(personTOthing(61,388)). +legacyConfig(personTOthing(61,389)). +legacyConfig(personTOthing(61,390)). +legacyConfig(personTOthing(62,391)). +legacyConfig(personTOthing(62,392)). +legacyConfig(personTOthing(62,393)). +legacyConfig(personTOthing(62,394)). +legacyConfig(personTOthing(62,395)). +legacyConfig(personTOthing(63,396)). +legacyConfig(personTOthing(63,397)). +legacyConfig(personTOthing(63,398)). +legacyConfig(personTOthing(63,399)). +legacyConfig(personTOthing(63,400)). +legacyConfig(personTOthing(64,401)). +legacyConfig(personTOthing(64,402)). +legacyConfig(personTOthing(64,403)). +legacyConfig(personTOthing(64,404)). +legacyConfig(personTOthing(64,405)). +legacyConfig(personTOthing(65,406)). +legacyConfig(personTOthing(65,407)). +legacyConfig(personTOthing(65,408)). +legacyConfig(personTOthing(65,409)). +legacyConfig(personTOthing(65,410)). +legacyConfig(personTOthing(66,411)). +legacyConfig(personTOthing(66,412)). +legacyConfig(personTOthing(66,413)). +legacyConfig(personTOthing(66,414)). +legacyConfig(personTOthing(66,415)). +legacyConfig(personTOthing(67,416)). +legacyConfig(personTOthing(67,417)). +legacyConfig(personTOthing(67,418)). +legacyConfig(personTOthing(67,419)). +legacyConfig(personTOthing(67,420)). +legacyConfig(personTOthing(68,421)). +legacyConfig(personTOthing(68,422)). +legacyConfig(personTOthing(68,423)). +legacyConfig(personTOthing(68,424)). +legacyConfig(personTOthing(68,425)). +legacyConfig(personTOthing(69,426)). +legacyConfig(personTOthing(69,427)). +legacyConfig(personTOthing(69,428)). +legacyConfig(personTOthing(69,429)). +legacyConfig(personTOthing(69,430)). +legacyConfig(personTOthing(70,431)). +legacyConfig(personTOthing(70,432)). +legacyConfig(personTOthing(70,433)). +legacyConfig(personTOthing(70,434)). +legacyConfig(personTOthing(70,435)). +legacyConfig(personTOthing(71,436)). +legacyConfig(personTOthing(71,437)). +legacyConfig(personTOthing(71,438)). +legacyConfig(personTOthing(71,439)). +legacyConfig(personTOthing(71,440)). +legacyConfig(personTOthing(72,441)). +legacyConfig(personTOthing(72,442)). +legacyConfig(personTOthing(72,443)). +legacyConfig(personTOthing(72,444)). +legacyConfig(personTOthing(72,445)). +legacyConfig(personTOthing(73,446)). +legacyConfig(personTOthing(73,447)). +legacyConfig(personTOthing(73,448)). +legacyConfig(personTOthing(73,449)). +legacyConfig(personTOthing(73,450)). +legacyConfig(personTOthing(74,451)). +legacyConfig(personTOthing(74,452)). +legacyConfig(personTOthing(74,453)). +legacyConfig(personTOthing(74,454)). +legacyConfig(personTOthing(74,455)). +legacyConfig(personTOthing(75,456)). +legacyConfig(personTOthing(75,457)). +legacyConfig(personTOthing(75,458)). +legacyConfig(personTOthing(75,459)). +legacyConfig(personTOthing(75,460)). +legacyConfig(personTOthing(76,461)). +legacyConfig(personTOthing(76,462)). +legacyConfig(personTOthing(76,463)). +legacyConfig(personTOthing(76,464)). +legacyConfig(personTOthing(76,465)). +legacyConfig(personTOthing(77,466)). +legacyConfig(personTOthing(77,467)). +legacyConfig(personTOthing(77,468)). +legacyConfig(personTOthing(77,469)). +legacyConfig(personTOthing(77,470)). +legacyConfig(personTOthing(78,471)). +legacyConfig(personTOthing(78,472)). +legacyConfig(personTOthing(78,473)). +legacyConfig(personTOthing(78,474)). +legacyConfig(personTOthing(78,475)). +legacyConfig(personTOthing(79,476)). +legacyConfig(personTOthing(79,477)). +legacyConfig(personTOthing(79,478)). +legacyConfig(personTOthing(79,479)). +legacyConfig(personTOthing(79,480)). +legacyConfig(personTOthing(80,481)). +legacyConfig(personTOthing(80,482)). +legacyConfig(personTOthing(80,483)). +legacyConfig(personTOthing(80,484)). +legacyConfig(personTOthing(80,485)). +legacyConfig(personTOthing(81,486)). +legacyConfig(personTOthing(81,487)). +legacyConfig(personTOthing(81,488)). +legacyConfig(personTOthing(81,489)). +legacyConfig(personTOthing(81,490)). +legacyConfig(personTOthing(82,491)). +legacyConfig(personTOthing(82,492)). +legacyConfig(personTOthing(82,493)). +legacyConfig(personTOthing(82,494)). +legacyConfig(personTOthing(82,495)). +legacyConfig(personTOthing(83,496)). +legacyConfig(personTOthing(83,497)). +legacyConfig(personTOthing(83,498)). +legacyConfig(personTOthing(83,499)). +legacyConfig(personTOthing(83,500)). +legacyConfig(personTOthing(84,501)). +legacyConfig(personTOthing(84,502)). +legacyConfig(personTOthing(84,503)). +legacyConfig(personTOthing(84,504)). +legacyConfig(personTOthing(84,505)). +legacyConfig(personTOthing(85,506)). +legacyConfig(personTOthing(85,507)). +legacyConfig(personTOthing(85,508)). +legacyConfig(personTOthing(85,509)). +legacyConfig(personTOthing(85,510)). +% domains +cabinetDomainNew(1000..1424). +roomDomainNew(1500..1924). +cabinetUpper(425). +roomUpper(425). +cabinetLower(85). +roomLower(22). +% reuse costs +reuseCabinetTOthingCost(0). +reuseRoomTOcabinetCost(0). +reusePersonTOroomCost(0). +reuseCabinetAsHighCost(3). +reuseCabinetAsSmallCost(0). +reuseRoomCost(0). +% remove costs +removeCabinetTOthingCost(2). +removeRoomTOcabinetCost(2). +removePersonTOroomCost(2). +removeCabinetCost(2). +removeRoomCost(2). +% create costs +cabinetHighCost(100). +cabinetSmallCost(1). +roomCost(5). diff --git a/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p90t450.edb b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p90t450.edb new file mode 100644 index 000000000..6ac16cab9 --- /dev/null +++ b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p90t450.edb @@ -0,0 +1,1464 @@ +legacyConfig(person(1)). +legacyConfig(person(2)). +legacyConfig(person(3)). +legacyConfig(person(4)). +legacyConfig(person(5)). +legacyConfig(person(6)). +legacyConfig(person(7)). +legacyConfig(person(8)). +legacyConfig(person(9)). +legacyConfig(person(10)). +legacyConfig(person(11)). +legacyConfig(person(12)). +legacyConfig(person(13)). +legacyConfig(person(14)). +legacyConfig(person(15)). +legacyConfig(person(16)). +legacyConfig(person(17)). +legacyConfig(person(18)). +legacyConfig(person(19)). +legacyConfig(person(20)). +legacyConfig(person(21)). +legacyConfig(person(22)). +legacyConfig(person(23)). +legacyConfig(person(24)). +legacyConfig(person(25)). +legacyConfig(person(26)). +legacyConfig(person(27)). +legacyConfig(person(28)). +legacyConfig(person(29)). +legacyConfig(person(30)). +legacyConfig(person(31)). +legacyConfig(person(32)). +legacyConfig(person(33)). +legacyConfig(person(34)). +legacyConfig(person(35)). +legacyConfig(person(36)). +legacyConfig(person(37)). +legacyConfig(person(38)). +legacyConfig(person(39)). +legacyConfig(person(40)). +legacyConfig(person(41)). +legacyConfig(person(42)). +legacyConfig(person(43)). +legacyConfig(person(44)). +legacyConfig(person(45)). +legacyConfig(person(46)). +legacyConfig(person(47)). +legacyConfig(person(48)). +legacyConfig(person(49)). +legacyConfig(person(50)). +legacyConfig(person(51)). +legacyConfig(person(52)). +legacyConfig(person(53)). +legacyConfig(person(54)). +legacyConfig(person(55)). +legacyConfig(person(56)). +legacyConfig(person(57)). +legacyConfig(person(58)). +legacyConfig(person(59)). +legacyConfig(person(60)). +legacyConfig(person(61)). +legacyConfig(person(62)). +legacyConfig(person(63)). +legacyConfig(person(64)). +legacyConfig(person(65)). +legacyConfig(person(66)). +legacyConfig(person(67)). +legacyConfig(person(68)). +legacyConfig(person(69)). +legacyConfig(person(70)). +legacyConfig(person(71)). +legacyConfig(person(72)). +legacyConfig(person(73)). +legacyConfig(person(74)). +legacyConfig(person(75)). +legacyConfig(person(76)). +legacyConfig(person(77)). +legacyConfig(person(78)). +legacyConfig(person(79)). +legacyConfig(person(80)). +legacyConfig(person(81)). +legacyConfig(person(82)). +legacyConfig(person(83)). +legacyConfig(person(84)). +legacyConfig(person(85)). +legacyConfig(person(86)). +legacyConfig(person(87)). +legacyConfig(person(88)). +legacyConfig(person(89)). +legacyConfig(person(90)). +legacyConfig(thing(91)). +thingShort(91). +legacyConfig(thing(92)). +thingShort(92). +legacyConfig(thing(93)). +thingShort(93). +legacyConfig(thing(94)). +thingShort(94). +legacyConfig(thing(95)). +thingShort(95). +legacyConfig(thing(96)). +thingShort(96). +legacyConfig(thing(97)). +thingShort(97). +legacyConfig(thing(98)). +thingShort(98). +legacyConfig(thing(99)). +thingShort(99). +legacyConfig(thing(100)). +thingShort(100). +legacyConfig(thing(101)). +thingShort(101). +legacyConfig(thing(102)). +thingShort(102). +legacyConfig(thing(103)). +thingShort(103). +legacyConfig(thing(104)). +thingShort(104). +legacyConfig(thing(105)). +thingShort(105). +legacyConfig(thing(106)). +thingShort(106). +legacyConfig(thing(107)). +thingShort(107). +legacyConfig(thing(108)). +thingShort(108). +legacyConfig(thing(109)). +thingShort(109). +legacyConfig(thing(110)). +thingShort(110). +legacyConfig(thing(111)). +thingShort(111). +legacyConfig(thing(112)). +thingShort(112). +legacyConfig(thing(113)). +thingShort(113). +legacyConfig(thing(114)). +thingShort(114). +legacyConfig(thing(115)). +thingShort(115). +legacyConfig(thing(116)). +thingShort(116). +legacyConfig(thing(117)). +thingShort(117). +legacyConfig(thing(118)). +thingShort(118). +legacyConfig(thing(119)). +thingShort(119). +legacyConfig(thing(120)). +thingShort(120). +legacyConfig(thing(121)). +thingShort(121). +legacyConfig(thing(122)). +thingShort(122). +legacyConfig(thing(123)). +thingShort(123). +legacyConfig(thing(124)). +thingShort(124). +legacyConfig(thing(125)). +thingShort(125). +legacyConfig(thing(126)). +thingShort(126). +legacyConfig(thing(127)). +thingShort(127). +legacyConfig(thing(128)). +thingShort(128). +legacyConfig(thing(129)). +thingShort(129). +legacyConfig(thing(130)). +thingShort(130). +legacyConfig(thing(131)). +thingShort(131). +legacyConfig(thing(132)). +thingShort(132). +legacyConfig(thing(133)). +thingShort(133). +legacyConfig(thing(134)). +thingShort(134). +legacyConfig(thing(135)). +thingShort(135). +legacyConfig(thing(136)). +thingShort(136). +legacyConfig(thing(137)). +thingShort(137). +legacyConfig(thing(138)). +thingShort(138). +legacyConfig(thing(139)). +thingShort(139). +legacyConfig(thing(140)). +thingShort(140). +legacyConfig(thing(141)). +thingShort(141). +legacyConfig(thing(142)). +thingShort(142). +legacyConfig(thing(143)). +thingShort(143). +legacyConfig(thing(144)). +thingShort(144). +legacyConfig(thing(145)). +thingShort(145). +legacyConfig(thing(146)). +thingShort(146). +legacyConfig(thing(147)). +thingShort(147). +legacyConfig(thing(148)). +thingShort(148). +legacyConfig(thing(149)). +thingShort(149). +legacyConfig(thing(150)). +thingShort(150). +legacyConfig(thing(151)). +thingShort(151). +legacyConfig(thing(152)). +thingShort(152). +legacyConfig(thing(153)). +thingShort(153). +legacyConfig(thing(154)). +thingShort(154). +legacyConfig(thing(155)). +thingShort(155). +legacyConfig(thing(156)). +thingShort(156). +legacyConfig(thing(157)). +thingShort(157). +legacyConfig(thing(158)). +thingShort(158). +legacyConfig(thing(159)). +thingShort(159). +legacyConfig(thing(160)). +thingShort(160). +legacyConfig(thing(161)). +thingShort(161). +legacyConfig(thing(162)). +thingShort(162). +legacyConfig(thing(163)). +thingShort(163). +legacyConfig(thing(164)). +thingShort(164). +legacyConfig(thing(165)). +thingShort(165). +legacyConfig(thing(166)). +thingShort(166). +legacyConfig(thing(167)). +thingShort(167). +legacyConfig(thing(168)). +thingShort(168). +legacyConfig(thing(169)). +thingShort(169). +legacyConfig(thing(170)). +thingShort(170). +legacyConfig(thing(171)). +thingShort(171). +legacyConfig(thing(172)). +thingShort(172). +legacyConfig(thing(173)). +thingShort(173). +legacyConfig(thing(174)). +thingShort(174). +legacyConfig(thing(175)). +thingShort(175). +legacyConfig(thing(176)). +thingShort(176). +legacyConfig(thing(177)). +thingShort(177). +legacyConfig(thing(178)). +thingShort(178). +legacyConfig(thing(179)). +thingShort(179). +legacyConfig(thing(180)). +thingShort(180). +legacyConfig(thing(181)). +thingShort(181). +legacyConfig(thing(182)). +thingShort(182). +legacyConfig(thing(183)). +thingShort(183). +legacyConfig(thing(184)). +thingShort(184). +legacyConfig(thing(185)). +thingShort(185). +legacyConfig(thing(186)). +thingShort(186). +legacyConfig(thing(187)). +thingShort(187). +legacyConfig(thing(188)). +thingShort(188). +legacyConfig(thing(189)). +thingShort(189). +legacyConfig(thing(190)). +thingShort(190). +legacyConfig(thing(191)). +thingShort(191). +legacyConfig(thing(192)). +thingShort(192). +legacyConfig(thing(193)). +thingShort(193). +legacyConfig(thing(194)). +thingShort(194). +legacyConfig(thing(195)). +thingShort(195). +legacyConfig(thing(196)). +thingShort(196). +legacyConfig(thing(197)). +thingShort(197). +legacyConfig(thing(198)). +thingShort(198). +legacyConfig(thing(199)). +thingShort(199). +legacyConfig(thing(200)). +thingShort(200). +legacyConfig(thing(201)). +thingShort(201). +legacyConfig(thing(202)). +thingShort(202). +legacyConfig(thing(203)). +thingShort(203). +legacyConfig(thing(204)). +thingShort(204). +legacyConfig(thing(205)). +thingShort(205). +legacyConfig(thing(206)). +thingShort(206). +legacyConfig(thing(207)). +thingShort(207). +legacyConfig(thing(208)). +thingShort(208). +legacyConfig(thing(209)). +thingShort(209). +legacyConfig(thing(210)). +thingShort(210). +legacyConfig(thing(211)). +thingShort(211). +legacyConfig(thing(212)). +thingShort(212). +legacyConfig(thing(213)). +thingShort(213). +legacyConfig(thing(214)). +thingShort(214). +legacyConfig(thing(215)). +thingShort(215). +legacyConfig(thing(216)). +thingShort(216). +legacyConfig(thing(217)). +thingShort(217). +legacyConfig(thing(218)). +thingShort(218). +legacyConfig(thing(219)). +thingShort(219). +legacyConfig(thing(220)). +thingShort(220). +legacyConfig(thing(221)). +thingShort(221). +legacyConfig(thing(222)). +thingShort(222). +legacyConfig(thing(223)). +thingShort(223). +legacyConfig(thing(224)). +thingShort(224). +legacyConfig(thing(225)). +thingShort(225). +legacyConfig(thing(226)). +thingShort(226). +legacyConfig(thing(227)). +thingShort(227). +legacyConfig(thing(228)). +thingShort(228). +legacyConfig(thing(229)). +thingShort(229). +legacyConfig(thing(230)). +thingShort(230). +legacyConfig(thing(231)). +thingShort(231). +legacyConfig(thing(232)). +thingShort(232). +legacyConfig(thing(233)). +thingShort(233). +legacyConfig(thing(234)). +thingShort(234). +legacyConfig(thing(235)). +thingShort(235). +legacyConfig(thing(236)). +thingShort(236). +legacyConfig(thing(237)). +thingShort(237). +legacyConfig(thing(238)). +thingShort(238). +legacyConfig(thing(239)). +thingShort(239). +legacyConfig(thing(240)). +thingShort(240). +legacyConfig(thing(241)). +thingShort(241). +legacyConfig(thing(242)). +thingShort(242). +legacyConfig(thing(243)). +thingShort(243). +legacyConfig(thing(244)). +thingShort(244). +legacyConfig(thing(245)). +thingShort(245). +legacyConfig(thing(246)). +thingShort(246). +legacyConfig(thing(247)). +thingShort(247). +legacyConfig(thing(248)). +thingShort(248). +legacyConfig(thing(249)). +thingShort(249). +legacyConfig(thing(250)). +thingShort(250). +legacyConfig(thing(251)). +thingShort(251). +legacyConfig(thing(252)). +thingShort(252). +legacyConfig(thing(253)). +thingShort(253). +legacyConfig(thing(254)). +thingShort(254). +legacyConfig(thing(255)). +thingShort(255). +legacyConfig(thing(256)). +thingShort(256). +legacyConfig(thing(257)). +thingShort(257). +legacyConfig(thing(258)). +thingShort(258). +legacyConfig(thing(259)). +thingShort(259). +legacyConfig(thing(260)). +thingShort(260). +legacyConfig(thing(261)). +thingShort(261). +legacyConfig(thing(262)). +thingShort(262). +legacyConfig(thing(263)). +thingShort(263). +legacyConfig(thing(264)). +thingShort(264). +legacyConfig(thing(265)). +thingShort(265). +legacyConfig(thing(266)). +thingShort(266). +legacyConfig(thing(267)). +thingShort(267). +legacyConfig(thing(268)). +thingShort(268). +legacyConfig(thing(269)). +thingShort(269). +legacyConfig(thing(270)). +thingShort(270). +legacyConfig(thing(271)). +thingShort(271). +legacyConfig(thing(272)). +thingShort(272). +legacyConfig(thing(273)). +thingShort(273). +legacyConfig(thing(274)). +thingShort(274). +legacyConfig(thing(275)). +thingShort(275). +legacyConfig(thing(276)). +thingShort(276). +legacyConfig(thing(277)). +thingShort(277). +legacyConfig(thing(278)). +thingShort(278). +legacyConfig(thing(279)). +thingShort(279). +legacyConfig(thing(280)). +thingShort(280). +legacyConfig(thing(281)). +thingShort(281). +legacyConfig(thing(282)). +thingShort(282). +legacyConfig(thing(283)). +thingShort(283). +legacyConfig(thing(284)). +thingShort(284). +legacyConfig(thing(285)). +thingShort(285). +legacyConfig(thing(286)). +thingShort(286). +legacyConfig(thing(287)). +thingShort(287). +legacyConfig(thing(288)). +thingShort(288). +legacyConfig(thing(289)). +thingShort(289). +legacyConfig(thing(290)). +thingShort(290). +legacyConfig(thing(291)). +thingShort(291). +legacyConfig(thing(292)). +thingShort(292). +legacyConfig(thing(293)). +thingShort(293). +legacyConfig(thing(294)). +thingShort(294). +legacyConfig(thing(295)). +thingShort(295). +legacyConfig(thing(296)). +thingShort(296). +legacyConfig(thing(297)). +thingShort(297). +legacyConfig(thing(298)). +thingShort(298). +legacyConfig(thing(299)). +thingShort(299). +legacyConfig(thing(300)). +thingShort(300). +legacyConfig(thing(301)). +thingShort(301). +legacyConfig(thing(302)). +thingShort(302). +legacyConfig(thing(303)). +thingShort(303). +legacyConfig(thing(304)). +thingShort(304). +legacyConfig(thing(305)). +thingShort(305). +legacyConfig(thing(306)). +thingShort(306). +legacyConfig(thing(307)). +thingShort(307). +legacyConfig(thing(308)). +thingShort(308). +legacyConfig(thing(309)). +thingShort(309). +legacyConfig(thing(310)). +thingShort(310). +legacyConfig(thing(311)). +thingShort(311). +legacyConfig(thing(312)). +thingShort(312). +legacyConfig(thing(313)). +thingShort(313). +legacyConfig(thing(314)). +thingShort(314). +legacyConfig(thing(315)). +thingShort(315). +legacyConfig(thing(316)). +thingShort(316). +legacyConfig(thing(317)). +thingShort(317). +legacyConfig(thing(318)). +thingShort(318). +legacyConfig(thing(319)). +thingShort(319). +legacyConfig(thing(320)). +thingShort(320). +legacyConfig(thing(321)). +thingShort(321). +legacyConfig(thing(322)). +thingShort(322). +legacyConfig(thing(323)). +thingShort(323). +legacyConfig(thing(324)). +thingShort(324). +legacyConfig(thing(325)). +thingShort(325). +legacyConfig(thing(326)). +thingShort(326). +legacyConfig(thing(327)). +thingShort(327). +legacyConfig(thing(328)). +thingShort(328). +legacyConfig(thing(329)). +thingShort(329). +legacyConfig(thing(330)). +thingShort(330). +legacyConfig(thing(331)). +thingShort(331). +legacyConfig(thing(332)). +thingShort(332). +legacyConfig(thing(333)). +thingShort(333). +legacyConfig(thing(334)). +thingShort(334). +legacyConfig(thing(335)). +thingShort(335). +legacyConfig(thing(336)). +thingShort(336). +legacyConfig(thing(337)). +thingShort(337). +legacyConfig(thing(338)). +thingShort(338). +legacyConfig(thing(339)). +thingShort(339). +legacyConfig(thing(340)). +thingShort(340). +legacyConfig(thing(341)). +thingShort(341). +legacyConfig(thing(342)). +thingShort(342). +legacyConfig(thing(343)). +thingShort(343). +legacyConfig(thing(344)). +thingShort(344). +legacyConfig(thing(345)). +thingShort(345). +legacyConfig(thing(346)). +thingShort(346). +legacyConfig(thing(347)). +thingShort(347). +legacyConfig(thing(348)). +thingShort(348). +legacyConfig(thing(349)). +thingShort(349). +legacyConfig(thing(350)). +thingShort(350). +legacyConfig(thing(351)). +thingShort(351). +legacyConfig(thing(352)). +thingShort(352). +legacyConfig(thing(353)). +thingShort(353). +legacyConfig(thing(354)). +thingShort(354). +legacyConfig(thing(355)). +thingShort(355). +legacyConfig(thing(356)). +thingShort(356). +legacyConfig(thing(357)). +thingShort(357). +legacyConfig(thing(358)). +thingShort(358). +legacyConfig(thing(359)). +thingShort(359). +legacyConfig(thing(360)). +thingShort(360). +legacyConfig(thing(361)). +thingShort(361). +legacyConfig(thing(362)). +thingShort(362). +legacyConfig(thing(363)). +thingShort(363). +legacyConfig(thing(364)). +thingShort(364). +legacyConfig(thing(365)). +thingShort(365). +legacyConfig(thing(366)). +thingShort(366). +legacyConfig(thing(367)). +thingShort(367). +legacyConfig(thing(368)). +thingShort(368). +legacyConfig(thing(369)). +thingShort(369). +legacyConfig(thing(370)). +thingShort(370). +legacyConfig(thing(371)). +thingShort(371). +legacyConfig(thing(372)). +thingShort(372). +legacyConfig(thing(373)). +thingShort(373). +legacyConfig(thing(374)). +thingShort(374). +legacyConfig(thing(375)). +thingShort(375). +legacyConfig(thing(376)). +thingShort(376). +legacyConfig(thing(377)). +thingShort(377). +legacyConfig(thing(378)). +thingShort(378). +legacyConfig(thing(379)). +thingShort(379). +legacyConfig(thing(380)). +thingShort(380). +legacyConfig(thing(381)). +thingShort(381). +legacyConfig(thing(382)). +thingShort(382). +legacyConfig(thing(383)). +thingShort(383). +legacyConfig(thing(384)). +thingShort(384). +legacyConfig(thing(385)). +thingShort(385). +legacyConfig(thing(386)). +thingShort(386). +legacyConfig(thing(387)). +thingShort(387). +legacyConfig(thing(388)). +thingShort(388). +legacyConfig(thing(389)). +thingShort(389). +legacyConfig(thing(390)). +thingShort(390). +legacyConfig(thing(391)). +thingShort(391). +legacyConfig(thing(392)). +thingShort(392). +legacyConfig(thing(393)). +thingShort(393). +legacyConfig(thing(394)). +thingShort(394). +legacyConfig(thing(395)). +thingShort(395). +legacyConfig(thing(396)). +thingShort(396). +legacyConfig(thing(397)). +thingShort(397). +legacyConfig(thing(398)). +thingShort(398). +legacyConfig(thing(399)). +thingShort(399). +legacyConfig(thing(400)). +thingShort(400). +legacyConfig(thing(401)). +thingShort(401). +legacyConfig(thing(402)). +thingShort(402). +legacyConfig(thing(403)). +thingShort(403). +legacyConfig(thing(404)). +thingShort(404). +legacyConfig(thing(405)). +thingShort(405). +legacyConfig(thing(406)). +thingShort(406). +legacyConfig(thing(407)). +thingShort(407). +legacyConfig(thing(408)). +thingShort(408). +legacyConfig(thing(409)). +thingShort(409). +legacyConfig(thing(410)). +thingShort(410). +legacyConfig(thing(411)). +thingShort(411). +legacyConfig(thing(412)). +thingShort(412). +legacyConfig(thing(413)). +thingShort(413). +legacyConfig(thing(414)). +thingShort(414). +legacyConfig(thing(415)). +thingShort(415). +legacyConfig(thing(416)). +thingShort(416). +legacyConfig(thing(417)). +thingShort(417). +legacyConfig(thing(418)). +thingShort(418). +legacyConfig(thing(419)). +thingShort(419). +legacyConfig(thing(420)). +thingShort(420). +legacyConfig(thing(421)). +thingShort(421). +legacyConfig(thing(422)). +thingShort(422). +legacyConfig(thing(423)). +thingShort(423). +legacyConfig(thing(424)). +thingShort(424). +legacyConfig(thing(425)). +thingShort(425). +legacyConfig(thing(426)). +thingShort(426). +legacyConfig(thing(427)). +thingShort(427). +legacyConfig(thing(428)). +thingShort(428). +legacyConfig(thing(429)). +thingShort(429). +legacyConfig(thing(430)). +thingShort(430). +legacyConfig(thing(431)). +thingShort(431). +legacyConfig(thing(432)). +thingShort(432). +legacyConfig(thing(433)). +thingShort(433). +legacyConfig(thing(434)). +thingShort(434). +legacyConfig(thing(435)). +thingShort(435). +legacyConfig(thing(436)). +thingShort(436). +legacyConfig(thing(437)). +thingShort(437). +legacyConfig(thing(438)). +thingShort(438). +legacyConfig(thing(439)). +thingShort(439). +legacyConfig(thing(440)). +thingShort(440). +legacyConfig(thing(441)). +thingShort(441). +legacyConfig(thing(442)). +thingShort(442). +legacyConfig(thing(443)). +thingShort(443). +legacyConfig(thing(444)). +thingShort(444). +legacyConfig(thing(445)). +thingShort(445). +legacyConfig(thing(446)). +thingShort(446). +legacyConfig(thing(447)). +thingShort(447). +legacyConfig(thing(448)). +thingShort(448). +legacyConfig(thing(449)). +thingShort(449). +legacyConfig(thing(450)). +thingShort(450). +legacyConfig(thing(451)). +thingShort(451). +legacyConfig(thing(452)). +thingShort(452). +legacyConfig(thing(453)). +thingShort(453). +legacyConfig(thing(454)). +thingShort(454). +legacyConfig(thing(455)). +thingShort(455). +legacyConfig(thing(456)). +thingShort(456). +legacyConfig(thing(457)). +thingShort(457). +legacyConfig(thing(458)). +thingShort(458). +legacyConfig(thing(459)). +thingShort(459). +legacyConfig(thing(460)). +thingShort(460). +legacyConfig(thing(461)). +thingShort(461). +legacyConfig(thing(462)). +thingShort(462). +legacyConfig(thing(463)). +thingShort(463). +legacyConfig(thing(464)). +thingShort(464). +legacyConfig(thing(465)). +thingShort(465). +legacyConfig(thing(466)). +thingShort(466). +legacyConfig(thing(467)). +thingShort(467). +legacyConfig(thing(468)). +thingShort(468). +legacyConfig(thing(469)). +thingShort(469). +legacyConfig(thing(470)). +thingShort(470). +legacyConfig(thing(471)). +thingShort(471). +legacyConfig(thing(472)). +thingShort(472). +legacyConfig(thing(473)). +thingShort(473). +legacyConfig(thing(474)). +thingShort(474). +legacyConfig(thing(475)). +thingShort(475). +legacyConfig(thing(476)). +thingShort(476). +legacyConfig(thing(477)). +thingShort(477). +legacyConfig(thing(478)). +thingShort(478). +legacyConfig(thing(479)). +thingShort(479). +legacyConfig(thing(480)). +thingShort(480). +legacyConfig(thing(481)). +thingShort(481). +legacyConfig(thing(482)). +thingShort(482). +legacyConfig(thing(483)). +thingShort(483). +legacyConfig(thing(484)). +thingShort(484). +legacyConfig(thing(485)). +thingShort(485). +legacyConfig(thing(486)). +thingShort(486). +legacyConfig(thing(487)). +thingShort(487). +legacyConfig(thing(488)). +thingShort(488). +legacyConfig(thing(489)). +thingShort(489). +legacyConfig(thing(490)). +thingShort(490). +legacyConfig(thing(491)). +thingShort(491). +legacyConfig(thing(492)). +thingShort(492). +legacyConfig(thing(493)). +thingShort(493). +legacyConfig(thing(494)). +thingShort(494). +legacyConfig(thing(495)). +thingShort(495). +legacyConfig(thing(496)). +thingShort(496). +legacyConfig(thing(497)). +thingShort(497). +legacyConfig(thing(498)). +thingShort(498). +legacyConfig(thing(499)). +thingShort(499). +legacyConfig(thing(500)). +thingShort(500). +legacyConfig(thing(501)). +thingShort(501). +legacyConfig(thing(502)). +thingShort(502). +legacyConfig(thing(503)). +thingShort(503). +legacyConfig(thing(504)). +thingShort(504). +legacyConfig(thing(505)). +thingShort(505). +legacyConfig(thing(506)). +thingShort(506). +legacyConfig(thing(507)). +thingShort(507). +legacyConfig(thing(508)). +thingShort(508). +legacyConfig(thing(509)). +thingShort(509). +legacyConfig(thing(510)). +thingShort(510). +legacyConfig(thing(511)). +thingShort(511). +legacyConfig(thing(512)). +thingShort(512). +legacyConfig(thing(513)). +thingShort(513). +legacyConfig(thing(514)). +thingShort(514). +legacyConfig(thing(515)). +thingShort(515). +legacyConfig(thing(516)). +thingShort(516). +legacyConfig(thing(517)). +thingShort(517). +legacyConfig(thing(518)). +thingShort(518). +legacyConfig(thing(519)). +thingShort(519). +legacyConfig(thing(520)). +thingShort(520). +legacyConfig(thing(521)). +thingShort(521). +legacyConfig(thing(522)). +thingShort(522). +legacyConfig(thing(523)). +thingShort(523). +legacyConfig(thing(524)). +thingShort(524). +legacyConfig(thing(525)). +thingShort(525). +legacyConfig(thing(526)). +thingShort(526). +legacyConfig(thing(527)). +thingShort(527). +legacyConfig(thing(528)). +thingShort(528). +legacyConfig(thing(529)). +thingShort(529). +legacyConfig(thing(530)). +thingShort(530). +legacyConfig(thing(531)). +thingShort(531). +legacyConfig(thing(532)). +thingShort(532). +legacyConfig(thing(533)). +thingShort(533). +legacyConfig(thing(534)). +thingShort(534). +legacyConfig(thing(535)). +thingShort(535). +legacyConfig(thing(536)). +thingShort(536). +legacyConfig(thing(537)). +thingShort(537). +legacyConfig(thing(538)). +thingShort(538). +legacyConfig(thing(539)). +thingShort(539). +legacyConfig(thing(540)). +thingShort(540). +legacyConfig(personTOthing(1,91)). +legacyConfig(personTOthing(1,92)). +legacyConfig(personTOthing(1,93)). +legacyConfig(personTOthing(1,94)). +legacyConfig(personTOthing(1,95)). +legacyConfig(personTOthing(2,96)). +legacyConfig(personTOthing(2,97)). +legacyConfig(personTOthing(2,98)). +legacyConfig(personTOthing(2,99)). +legacyConfig(personTOthing(2,100)). +legacyConfig(personTOthing(3,101)). +legacyConfig(personTOthing(3,102)). +legacyConfig(personTOthing(3,103)). +legacyConfig(personTOthing(3,104)). +legacyConfig(personTOthing(3,105)). +legacyConfig(personTOthing(4,106)). +legacyConfig(personTOthing(4,107)). +legacyConfig(personTOthing(4,108)). +legacyConfig(personTOthing(4,109)). +legacyConfig(personTOthing(4,110)). +legacyConfig(personTOthing(5,111)). +legacyConfig(personTOthing(5,112)). +legacyConfig(personTOthing(5,113)). +legacyConfig(personTOthing(5,114)). +legacyConfig(personTOthing(5,115)). +legacyConfig(personTOthing(6,116)). +legacyConfig(personTOthing(6,117)). +legacyConfig(personTOthing(6,118)). +legacyConfig(personTOthing(6,119)). +legacyConfig(personTOthing(6,120)). +legacyConfig(personTOthing(7,121)). +legacyConfig(personTOthing(7,122)). +legacyConfig(personTOthing(7,123)). +legacyConfig(personTOthing(7,124)). +legacyConfig(personTOthing(7,125)). +legacyConfig(personTOthing(8,126)). +legacyConfig(personTOthing(8,127)). +legacyConfig(personTOthing(8,128)). +legacyConfig(personTOthing(8,129)). +legacyConfig(personTOthing(8,130)). +legacyConfig(personTOthing(9,131)). +legacyConfig(personTOthing(9,132)). +legacyConfig(personTOthing(9,133)). +legacyConfig(personTOthing(9,134)). +legacyConfig(personTOthing(9,135)). +legacyConfig(personTOthing(10,136)). +legacyConfig(personTOthing(10,137)). +legacyConfig(personTOthing(10,138)). +legacyConfig(personTOthing(10,139)). +legacyConfig(personTOthing(10,140)). +legacyConfig(personTOthing(11,141)). +legacyConfig(personTOthing(11,142)). +legacyConfig(personTOthing(11,143)). +legacyConfig(personTOthing(11,144)). +legacyConfig(personTOthing(11,145)). +legacyConfig(personTOthing(12,146)). +legacyConfig(personTOthing(12,147)). +legacyConfig(personTOthing(12,148)). +legacyConfig(personTOthing(12,149)). +legacyConfig(personTOthing(12,150)). +legacyConfig(personTOthing(13,151)). +legacyConfig(personTOthing(13,152)). +legacyConfig(personTOthing(13,153)). +legacyConfig(personTOthing(13,154)). +legacyConfig(personTOthing(13,155)). +legacyConfig(personTOthing(14,156)). +legacyConfig(personTOthing(14,157)). +legacyConfig(personTOthing(14,158)). +legacyConfig(personTOthing(14,159)). +legacyConfig(personTOthing(14,160)). +legacyConfig(personTOthing(15,161)). +legacyConfig(personTOthing(15,162)). +legacyConfig(personTOthing(15,163)). +legacyConfig(personTOthing(15,164)). +legacyConfig(personTOthing(15,165)). +legacyConfig(personTOthing(16,166)). +legacyConfig(personTOthing(16,167)). +legacyConfig(personTOthing(16,168)). +legacyConfig(personTOthing(16,169)). +legacyConfig(personTOthing(16,170)). +legacyConfig(personTOthing(17,171)). +legacyConfig(personTOthing(17,172)). +legacyConfig(personTOthing(17,173)). +legacyConfig(personTOthing(17,174)). +legacyConfig(personTOthing(17,175)). +legacyConfig(personTOthing(18,176)). +legacyConfig(personTOthing(18,177)). +legacyConfig(personTOthing(18,178)). +legacyConfig(personTOthing(18,179)). +legacyConfig(personTOthing(18,180)). +legacyConfig(personTOthing(19,181)). +legacyConfig(personTOthing(19,182)). +legacyConfig(personTOthing(19,183)). +legacyConfig(personTOthing(19,184)). +legacyConfig(personTOthing(19,185)). +legacyConfig(personTOthing(20,186)). +legacyConfig(personTOthing(20,187)). +legacyConfig(personTOthing(20,188)). +legacyConfig(personTOthing(20,189)). +legacyConfig(personTOthing(20,190)). +legacyConfig(personTOthing(21,191)). +legacyConfig(personTOthing(21,192)). +legacyConfig(personTOthing(21,193)). +legacyConfig(personTOthing(21,194)). +legacyConfig(personTOthing(21,195)). +legacyConfig(personTOthing(22,196)). +legacyConfig(personTOthing(22,197)). +legacyConfig(personTOthing(22,198)). +legacyConfig(personTOthing(22,199)). +legacyConfig(personTOthing(22,200)). +legacyConfig(personTOthing(23,201)). +legacyConfig(personTOthing(23,202)). +legacyConfig(personTOthing(23,203)). +legacyConfig(personTOthing(23,204)). +legacyConfig(personTOthing(23,205)). +legacyConfig(personTOthing(24,206)). +legacyConfig(personTOthing(24,207)). +legacyConfig(personTOthing(24,208)). +legacyConfig(personTOthing(24,209)). +legacyConfig(personTOthing(24,210)). +legacyConfig(personTOthing(25,211)). +legacyConfig(personTOthing(25,212)). +legacyConfig(personTOthing(25,213)). +legacyConfig(personTOthing(25,214)). +legacyConfig(personTOthing(25,215)). +legacyConfig(personTOthing(26,216)). +legacyConfig(personTOthing(26,217)). +legacyConfig(personTOthing(26,218)). +legacyConfig(personTOthing(26,219)). +legacyConfig(personTOthing(26,220)). +legacyConfig(personTOthing(27,221)). +legacyConfig(personTOthing(27,222)). +legacyConfig(personTOthing(27,223)). +legacyConfig(personTOthing(27,224)). +legacyConfig(personTOthing(27,225)). +legacyConfig(personTOthing(28,226)). +legacyConfig(personTOthing(28,227)). +legacyConfig(personTOthing(28,228)). +legacyConfig(personTOthing(28,229)). +legacyConfig(personTOthing(28,230)). +legacyConfig(personTOthing(29,231)). +legacyConfig(personTOthing(29,232)). +legacyConfig(personTOthing(29,233)). +legacyConfig(personTOthing(29,234)). +legacyConfig(personTOthing(29,235)). +legacyConfig(personTOthing(30,236)). +legacyConfig(personTOthing(30,237)). +legacyConfig(personTOthing(30,238)). +legacyConfig(personTOthing(30,239)). +legacyConfig(personTOthing(30,240)). +legacyConfig(personTOthing(31,241)). +legacyConfig(personTOthing(31,242)). +legacyConfig(personTOthing(31,243)). +legacyConfig(personTOthing(31,244)). +legacyConfig(personTOthing(31,245)). +legacyConfig(personTOthing(32,246)). +legacyConfig(personTOthing(32,247)). +legacyConfig(personTOthing(32,248)). +legacyConfig(personTOthing(32,249)). +legacyConfig(personTOthing(32,250)). +legacyConfig(personTOthing(33,251)). +legacyConfig(personTOthing(33,252)). +legacyConfig(personTOthing(33,253)). +legacyConfig(personTOthing(33,254)). +legacyConfig(personTOthing(33,255)). +legacyConfig(personTOthing(34,256)). +legacyConfig(personTOthing(34,257)). +legacyConfig(personTOthing(34,258)). +legacyConfig(personTOthing(34,259)). +legacyConfig(personTOthing(34,260)). +legacyConfig(personTOthing(35,261)). +legacyConfig(personTOthing(35,262)). +legacyConfig(personTOthing(35,263)). +legacyConfig(personTOthing(35,264)). +legacyConfig(personTOthing(35,265)). +legacyConfig(personTOthing(36,266)). +legacyConfig(personTOthing(36,267)). +legacyConfig(personTOthing(36,268)). +legacyConfig(personTOthing(36,269)). +legacyConfig(personTOthing(36,270)). +legacyConfig(personTOthing(37,271)). +legacyConfig(personTOthing(37,272)). +legacyConfig(personTOthing(37,273)). +legacyConfig(personTOthing(37,274)). +legacyConfig(personTOthing(37,275)). +legacyConfig(personTOthing(38,276)). +legacyConfig(personTOthing(38,277)). +legacyConfig(personTOthing(38,278)). +legacyConfig(personTOthing(38,279)). +legacyConfig(personTOthing(38,280)). +legacyConfig(personTOthing(39,281)). +legacyConfig(personTOthing(39,282)). +legacyConfig(personTOthing(39,283)). +legacyConfig(personTOthing(39,284)). +legacyConfig(personTOthing(39,285)). +legacyConfig(personTOthing(40,286)). +legacyConfig(personTOthing(40,287)). +legacyConfig(personTOthing(40,288)). +legacyConfig(personTOthing(40,289)). +legacyConfig(personTOthing(40,290)). +legacyConfig(personTOthing(41,291)). +legacyConfig(personTOthing(41,292)). +legacyConfig(personTOthing(41,293)). +legacyConfig(personTOthing(41,294)). +legacyConfig(personTOthing(41,295)). +legacyConfig(personTOthing(42,296)). +legacyConfig(personTOthing(42,297)). +legacyConfig(personTOthing(42,298)). +legacyConfig(personTOthing(42,299)). +legacyConfig(personTOthing(42,300)). +legacyConfig(personTOthing(43,301)). +legacyConfig(personTOthing(43,302)). +legacyConfig(personTOthing(43,303)). +legacyConfig(personTOthing(43,304)). +legacyConfig(personTOthing(43,305)). +legacyConfig(personTOthing(44,306)). +legacyConfig(personTOthing(44,307)). +legacyConfig(personTOthing(44,308)). +legacyConfig(personTOthing(44,309)). +legacyConfig(personTOthing(44,310)). +legacyConfig(personTOthing(45,311)). +legacyConfig(personTOthing(45,312)). +legacyConfig(personTOthing(45,313)). +legacyConfig(personTOthing(45,314)). +legacyConfig(personTOthing(45,315)). +legacyConfig(personTOthing(46,316)). +legacyConfig(personTOthing(46,317)). +legacyConfig(personTOthing(46,318)). +legacyConfig(personTOthing(46,319)). +legacyConfig(personTOthing(46,320)). +legacyConfig(personTOthing(47,321)). +legacyConfig(personTOthing(47,322)). +legacyConfig(personTOthing(47,323)). +legacyConfig(personTOthing(47,324)). +legacyConfig(personTOthing(47,325)). +legacyConfig(personTOthing(48,326)). +legacyConfig(personTOthing(48,327)). +legacyConfig(personTOthing(48,328)). +legacyConfig(personTOthing(48,329)). +legacyConfig(personTOthing(48,330)). +legacyConfig(personTOthing(49,331)). +legacyConfig(personTOthing(49,332)). +legacyConfig(personTOthing(49,333)). +legacyConfig(personTOthing(49,334)). +legacyConfig(personTOthing(49,335)). +legacyConfig(personTOthing(50,336)). +legacyConfig(personTOthing(50,337)). +legacyConfig(personTOthing(50,338)). +legacyConfig(personTOthing(50,339)). +legacyConfig(personTOthing(50,340)). +legacyConfig(personTOthing(51,341)). +legacyConfig(personTOthing(51,342)). +legacyConfig(personTOthing(51,343)). +legacyConfig(personTOthing(51,344)). +legacyConfig(personTOthing(51,345)). +legacyConfig(personTOthing(52,346)). +legacyConfig(personTOthing(52,347)). +legacyConfig(personTOthing(52,348)). +legacyConfig(personTOthing(52,349)). +legacyConfig(personTOthing(52,350)). +legacyConfig(personTOthing(53,351)). +legacyConfig(personTOthing(53,352)). +legacyConfig(personTOthing(53,353)). +legacyConfig(personTOthing(53,354)). +legacyConfig(personTOthing(53,355)). +legacyConfig(personTOthing(54,356)). +legacyConfig(personTOthing(54,357)). +legacyConfig(personTOthing(54,358)). +legacyConfig(personTOthing(54,359)). +legacyConfig(personTOthing(54,360)). +legacyConfig(personTOthing(55,361)). +legacyConfig(personTOthing(55,362)). +legacyConfig(personTOthing(55,363)). +legacyConfig(personTOthing(55,364)). +legacyConfig(personTOthing(55,365)). +legacyConfig(personTOthing(56,366)). +legacyConfig(personTOthing(56,367)). +legacyConfig(personTOthing(56,368)). +legacyConfig(personTOthing(56,369)). +legacyConfig(personTOthing(56,370)). +legacyConfig(personTOthing(57,371)). +legacyConfig(personTOthing(57,372)). +legacyConfig(personTOthing(57,373)). +legacyConfig(personTOthing(57,374)). +legacyConfig(personTOthing(57,375)). +legacyConfig(personTOthing(58,376)). +legacyConfig(personTOthing(58,377)). +legacyConfig(personTOthing(58,378)). +legacyConfig(personTOthing(58,379)). +legacyConfig(personTOthing(58,380)). +legacyConfig(personTOthing(59,381)). +legacyConfig(personTOthing(59,382)). +legacyConfig(personTOthing(59,383)). +legacyConfig(personTOthing(59,384)). +legacyConfig(personTOthing(59,385)). +legacyConfig(personTOthing(60,386)). +legacyConfig(personTOthing(60,387)). +legacyConfig(personTOthing(60,388)). +legacyConfig(personTOthing(60,389)). +legacyConfig(personTOthing(60,390)). +legacyConfig(personTOthing(61,391)). +legacyConfig(personTOthing(61,392)). +legacyConfig(personTOthing(61,393)). +legacyConfig(personTOthing(61,394)). +legacyConfig(personTOthing(61,395)). +legacyConfig(personTOthing(62,396)). +legacyConfig(personTOthing(62,397)). +legacyConfig(personTOthing(62,398)). +legacyConfig(personTOthing(62,399)). +legacyConfig(personTOthing(62,400)). +legacyConfig(personTOthing(63,401)). +legacyConfig(personTOthing(63,402)). +legacyConfig(personTOthing(63,403)). +legacyConfig(personTOthing(63,404)). +legacyConfig(personTOthing(63,405)). +legacyConfig(personTOthing(64,406)). +legacyConfig(personTOthing(64,407)). +legacyConfig(personTOthing(64,408)). +legacyConfig(personTOthing(64,409)). +legacyConfig(personTOthing(64,410)). +legacyConfig(personTOthing(65,411)). +legacyConfig(personTOthing(65,412)). +legacyConfig(personTOthing(65,413)). +legacyConfig(personTOthing(65,414)). +legacyConfig(personTOthing(65,415)). +legacyConfig(personTOthing(66,416)). +legacyConfig(personTOthing(66,417)). +legacyConfig(personTOthing(66,418)). +legacyConfig(personTOthing(66,419)). +legacyConfig(personTOthing(66,420)). +legacyConfig(personTOthing(67,421)). +legacyConfig(personTOthing(67,422)). +legacyConfig(personTOthing(67,423)). +legacyConfig(personTOthing(67,424)). +legacyConfig(personTOthing(67,425)). +legacyConfig(personTOthing(68,426)). +legacyConfig(personTOthing(68,427)). +legacyConfig(personTOthing(68,428)). +legacyConfig(personTOthing(68,429)). +legacyConfig(personTOthing(68,430)). +legacyConfig(personTOthing(69,431)). +legacyConfig(personTOthing(69,432)). +legacyConfig(personTOthing(69,433)). +legacyConfig(personTOthing(69,434)). +legacyConfig(personTOthing(69,435)). +legacyConfig(personTOthing(70,436)). +legacyConfig(personTOthing(70,437)). +legacyConfig(personTOthing(70,438)). +legacyConfig(personTOthing(70,439)). +legacyConfig(personTOthing(70,440)). +legacyConfig(personTOthing(71,441)). +legacyConfig(personTOthing(71,442)). +legacyConfig(personTOthing(71,443)). +legacyConfig(personTOthing(71,444)). +legacyConfig(personTOthing(71,445)). +legacyConfig(personTOthing(72,446)). +legacyConfig(personTOthing(72,447)). +legacyConfig(personTOthing(72,448)). +legacyConfig(personTOthing(72,449)). +legacyConfig(personTOthing(72,450)). +legacyConfig(personTOthing(73,451)). +legacyConfig(personTOthing(73,452)). +legacyConfig(personTOthing(73,453)). +legacyConfig(personTOthing(73,454)). +legacyConfig(personTOthing(73,455)). +legacyConfig(personTOthing(74,456)). +legacyConfig(personTOthing(74,457)). +legacyConfig(personTOthing(74,458)). +legacyConfig(personTOthing(74,459)). +legacyConfig(personTOthing(74,460)). +legacyConfig(personTOthing(75,461)). +legacyConfig(personTOthing(75,462)). +legacyConfig(personTOthing(75,463)). +legacyConfig(personTOthing(75,464)). +legacyConfig(personTOthing(75,465)). +legacyConfig(personTOthing(76,466)). +legacyConfig(personTOthing(76,467)). +legacyConfig(personTOthing(76,468)). +legacyConfig(personTOthing(76,469)). +legacyConfig(personTOthing(76,470)). +legacyConfig(personTOthing(77,471)). +legacyConfig(personTOthing(77,472)). +legacyConfig(personTOthing(77,473)). +legacyConfig(personTOthing(77,474)). +legacyConfig(personTOthing(77,475)). +legacyConfig(personTOthing(78,476)). +legacyConfig(personTOthing(78,477)). +legacyConfig(personTOthing(78,478)). +legacyConfig(personTOthing(78,479)). +legacyConfig(personTOthing(78,480)). +legacyConfig(personTOthing(79,481)). +legacyConfig(personTOthing(79,482)). +legacyConfig(personTOthing(79,483)). +legacyConfig(personTOthing(79,484)). +legacyConfig(personTOthing(79,485)). +legacyConfig(personTOthing(80,486)). +legacyConfig(personTOthing(80,487)). +legacyConfig(personTOthing(80,488)). +legacyConfig(personTOthing(80,489)). +legacyConfig(personTOthing(80,490)). +legacyConfig(personTOthing(81,491)). +legacyConfig(personTOthing(81,492)). +legacyConfig(personTOthing(81,493)). +legacyConfig(personTOthing(81,494)). +legacyConfig(personTOthing(81,495)). +legacyConfig(personTOthing(82,496)). +legacyConfig(personTOthing(82,497)). +legacyConfig(personTOthing(82,498)). +legacyConfig(personTOthing(82,499)). +legacyConfig(personTOthing(82,500)). +legacyConfig(personTOthing(83,501)). +legacyConfig(personTOthing(83,502)). +legacyConfig(personTOthing(83,503)). +legacyConfig(personTOthing(83,504)). +legacyConfig(personTOthing(83,505)). +legacyConfig(personTOthing(84,506)). +legacyConfig(personTOthing(84,507)). +legacyConfig(personTOthing(84,508)). +legacyConfig(personTOthing(84,509)). +legacyConfig(personTOthing(84,510)). +legacyConfig(personTOthing(85,511)). +legacyConfig(personTOthing(85,512)). +legacyConfig(personTOthing(85,513)). +legacyConfig(personTOthing(85,514)). +legacyConfig(personTOthing(85,515)). +legacyConfig(personTOthing(86,516)). +legacyConfig(personTOthing(86,517)). +legacyConfig(personTOthing(86,518)). +legacyConfig(personTOthing(86,519)). +legacyConfig(personTOthing(86,520)). +legacyConfig(personTOthing(87,521)). +legacyConfig(personTOthing(87,522)). +legacyConfig(personTOthing(87,523)). +legacyConfig(personTOthing(87,524)). +legacyConfig(personTOthing(87,525)). +legacyConfig(personTOthing(88,526)). +legacyConfig(personTOthing(88,527)). +legacyConfig(personTOthing(88,528)). +legacyConfig(personTOthing(88,529)). +legacyConfig(personTOthing(88,530)). +legacyConfig(personTOthing(89,531)). +legacyConfig(personTOthing(89,532)). +legacyConfig(personTOthing(89,533)). +legacyConfig(personTOthing(89,534)). +legacyConfig(personTOthing(89,535)). +legacyConfig(personTOthing(90,536)). +legacyConfig(personTOthing(90,537)). +legacyConfig(personTOthing(90,538)). +legacyConfig(personTOthing(90,539)). +legacyConfig(personTOthing(90,540)). +% domains +cabinetDomainNew(1000..1449). +roomDomainNew(1500..1949). +cabinetUpper(450). +roomUpper(450). +cabinetLower(90). +roomLower(23). +% reuse costs +reuseCabinetTOthingCost(0). +reuseRoomTOcabinetCost(0). +reusePersonTOroomCost(0). +reuseCabinetAsHighCost(3). +reuseCabinetAsSmallCost(0). +reuseRoomCost(0). +% remove costs +removeCabinetTOthingCost(2). +removeRoomTOcabinetCost(2). +removePersonTOroomCost(2). +removeCabinetCost(2). +removeRoomCost(2). +% create costs +cabinetHighCost(100). +cabinetSmallCost(1). +roomCost(5). diff --git a/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p95t475.edb b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p95t475.edb new file mode 100644 index 000000000..8381383b8 --- /dev/null +++ b/src/test/resources/DomainHeuristics/House/instances_alpha/emptyconfig_p95t475.edb @@ -0,0 +1,1544 @@ +legacyConfig(person(1)). +legacyConfig(person(2)). +legacyConfig(person(3)). +legacyConfig(person(4)). +legacyConfig(person(5)). +legacyConfig(person(6)). +legacyConfig(person(7)). +legacyConfig(person(8)). +legacyConfig(person(9)). +legacyConfig(person(10)). +legacyConfig(person(11)). +legacyConfig(person(12)). +legacyConfig(person(13)). +legacyConfig(person(14)). +legacyConfig(person(15)). +legacyConfig(person(16)). +legacyConfig(person(17)). +legacyConfig(person(18)). +legacyConfig(person(19)). +legacyConfig(person(20)). +legacyConfig(person(21)). +legacyConfig(person(22)). +legacyConfig(person(23)). +legacyConfig(person(24)). +legacyConfig(person(25)). +legacyConfig(person(26)). +legacyConfig(person(27)). +legacyConfig(person(28)). +legacyConfig(person(29)). +legacyConfig(person(30)). +legacyConfig(person(31)). +legacyConfig(person(32)). +legacyConfig(person(33)). +legacyConfig(person(34)). +legacyConfig(person(35)). +legacyConfig(person(36)). +legacyConfig(person(37)). +legacyConfig(person(38)). +legacyConfig(person(39)). +legacyConfig(person(40)). +legacyConfig(person(41)). +legacyConfig(person(42)). +legacyConfig(person(43)). +legacyConfig(person(44)). +legacyConfig(person(45)). +legacyConfig(person(46)). +legacyConfig(person(47)). +legacyConfig(person(48)). +legacyConfig(person(49)). +legacyConfig(person(50)). +legacyConfig(person(51)). +legacyConfig(person(52)). +legacyConfig(person(53)). +legacyConfig(person(54)). +legacyConfig(person(55)). +legacyConfig(person(56)). +legacyConfig(person(57)). +legacyConfig(person(58)). +legacyConfig(person(59)). +legacyConfig(person(60)). +legacyConfig(person(61)). +legacyConfig(person(62)). +legacyConfig(person(63)). +legacyConfig(person(64)). +legacyConfig(person(65)). +legacyConfig(person(66)). +legacyConfig(person(67)). +legacyConfig(person(68)). +legacyConfig(person(69)). +legacyConfig(person(70)). +legacyConfig(person(71)). +legacyConfig(person(72)). +legacyConfig(person(73)). +legacyConfig(person(74)). +legacyConfig(person(75)). +legacyConfig(person(76)). +legacyConfig(person(77)). +legacyConfig(person(78)). +legacyConfig(person(79)). +legacyConfig(person(80)). +legacyConfig(person(81)). +legacyConfig(person(82)). +legacyConfig(person(83)). +legacyConfig(person(84)). +legacyConfig(person(85)). +legacyConfig(person(86)). +legacyConfig(person(87)). +legacyConfig(person(88)). +legacyConfig(person(89)). +legacyConfig(person(90)). +legacyConfig(person(91)). +legacyConfig(person(92)). +legacyConfig(person(93)). +legacyConfig(person(94)). +legacyConfig(person(95)). +legacyConfig(thing(96)). +thingShort(96). +legacyConfig(thing(97)). +thingShort(97). +legacyConfig(thing(98)). +thingShort(98). +legacyConfig(thing(99)). +thingShort(99). +legacyConfig(thing(100)). +thingShort(100). +legacyConfig(thing(101)). +thingShort(101). +legacyConfig(thing(102)). +thingShort(102). +legacyConfig(thing(103)). +thingShort(103). +legacyConfig(thing(104)). +thingShort(104). +legacyConfig(thing(105)). +thingShort(105). +legacyConfig(thing(106)). +thingShort(106). +legacyConfig(thing(107)). +thingShort(107). +legacyConfig(thing(108)). +thingShort(108). +legacyConfig(thing(109)). +thingShort(109). +legacyConfig(thing(110)). +thingShort(110). +legacyConfig(thing(111)). +thingShort(111). +legacyConfig(thing(112)). +thingShort(112). +legacyConfig(thing(113)). +thingShort(113). +legacyConfig(thing(114)). +thingShort(114). +legacyConfig(thing(115)). +thingShort(115). +legacyConfig(thing(116)). +thingShort(116). +legacyConfig(thing(117)). +thingShort(117). +legacyConfig(thing(118)). +thingShort(118). +legacyConfig(thing(119)). +thingShort(119). +legacyConfig(thing(120)). +thingShort(120). +legacyConfig(thing(121)). +thingShort(121). +legacyConfig(thing(122)). +thingShort(122). +legacyConfig(thing(123)). +thingShort(123). +legacyConfig(thing(124)). +thingShort(124). +legacyConfig(thing(125)). +thingShort(125). +legacyConfig(thing(126)). +thingShort(126). +legacyConfig(thing(127)). +thingShort(127). +legacyConfig(thing(128)). +thingShort(128). +legacyConfig(thing(129)). +thingShort(129). +legacyConfig(thing(130)). +thingShort(130). +legacyConfig(thing(131)). +thingShort(131). +legacyConfig(thing(132)). +thingShort(132). +legacyConfig(thing(133)). +thingShort(133). +legacyConfig(thing(134)). +thingShort(134). +legacyConfig(thing(135)). +thingShort(135). +legacyConfig(thing(136)). +thingShort(136). +legacyConfig(thing(137)). +thingShort(137). +legacyConfig(thing(138)). +thingShort(138). +legacyConfig(thing(139)). +thingShort(139). +legacyConfig(thing(140)). +thingShort(140). +legacyConfig(thing(141)). +thingShort(141). +legacyConfig(thing(142)). +thingShort(142). +legacyConfig(thing(143)). +thingShort(143). +legacyConfig(thing(144)). +thingShort(144). +legacyConfig(thing(145)). +thingShort(145). +legacyConfig(thing(146)). +thingShort(146). +legacyConfig(thing(147)). +thingShort(147). +legacyConfig(thing(148)). +thingShort(148). +legacyConfig(thing(149)). +thingShort(149). +legacyConfig(thing(150)). +thingShort(150). +legacyConfig(thing(151)). +thingShort(151). +legacyConfig(thing(152)). +thingShort(152). +legacyConfig(thing(153)). +thingShort(153). +legacyConfig(thing(154)). +thingShort(154). +legacyConfig(thing(155)). +thingShort(155). +legacyConfig(thing(156)). +thingShort(156). +legacyConfig(thing(157)). +thingShort(157). +legacyConfig(thing(158)). +thingShort(158). +legacyConfig(thing(159)). +thingShort(159). +legacyConfig(thing(160)). +thingShort(160). +legacyConfig(thing(161)). +thingShort(161). +legacyConfig(thing(162)). +thingShort(162). +legacyConfig(thing(163)). +thingShort(163). +legacyConfig(thing(164)). +thingShort(164). +legacyConfig(thing(165)). +thingShort(165). +legacyConfig(thing(166)). +thingShort(166). +legacyConfig(thing(167)). +thingShort(167). +legacyConfig(thing(168)). +thingShort(168). +legacyConfig(thing(169)). +thingShort(169). +legacyConfig(thing(170)). +thingShort(170). +legacyConfig(thing(171)). +thingShort(171). +legacyConfig(thing(172)). +thingShort(172). +legacyConfig(thing(173)). +thingShort(173). +legacyConfig(thing(174)). +thingShort(174). +legacyConfig(thing(175)). +thingShort(175). +legacyConfig(thing(176)). +thingShort(176). +legacyConfig(thing(177)). +thingShort(177). +legacyConfig(thing(178)). +thingShort(178). +legacyConfig(thing(179)). +thingShort(179). +legacyConfig(thing(180)). +thingShort(180). +legacyConfig(thing(181)). +thingShort(181). +legacyConfig(thing(182)). +thingShort(182). +legacyConfig(thing(183)). +thingShort(183). +legacyConfig(thing(184)). +thingShort(184). +legacyConfig(thing(185)). +thingShort(185). +legacyConfig(thing(186)). +thingShort(186). +legacyConfig(thing(187)). +thingShort(187). +legacyConfig(thing(188)). +thingShort(188). +legacyConfig(thing(189)). +thingShort(189). +legacyConfig(thing(190)). +thingShort(190). +legacyConfig(thing(191)). +thingShort(191). +legacyConfig(thing(192)). +thingShort(192). +legacyConfig(thing(193)). +thingShort(193). +legacyConfig(thing(194)). +thingShort(194). +legacyConfig(thing(195)). +thingShort(195). +legacyConfig(thing(196)). +thingShort(196). +legacyConfig(thing(197)). +thingShort(197). +legacyConfig(thing(198)). +thingShort(198). +legacyConfig(thing(199)). +thingShort(199). +legacyConfig(thing(200)). +thingShort(200). +legacyConfig(thing(201)). +thingShort(201). +legacyConfig(thing(202)). +thingShort(202). +legacyConfig(thing(203)). +thingShort(203). +legacyConfig(thing(204)). +thingShort(204). +legacyConfig(thing(205)). +thingShort(205). +legacyConfig(thing(206)). +thingShort(206). +legacyConfig(thing(207)). +thingShort(207). +legacyConfig(thing(208)). +thingShort(208). +legacyConfig(thing(209)). +thingShort(209). +legacyConfig(thing(210)). +thingShort(210). +legacyConfig(thing(211)). +thingShort(211). +legacyConfig(thing(212)). +thingShort(212). +legacyConfig(thing(213)). +thingShort(213). +legacyConfig(thing(214)). +thingShort(214). +legacyConfig(thing(215)). +thingShort(215). +legacyConfig(thing(216)). +thingShort(216). +legacyConfig(thing(217)). +thingShort(217). +legacyConfig(thing(218)). +thingShort(218). +legacyConfig(thing(219)). +thingShort(219). +legacyConfig(thing(220)). +thingShort(220). +legacyConfig(thing(221)). +thingShort(221). +legacyConfig(thing(222)). +thingShort(222). +legacyConfig(thing(223)). +thingShort(223). +legacyConfig(thing(224)). +thingShort(224). +legacyConfig(thing(225)). +thingShort(225). +legacyConfig(thing(226)). +thingShort(226). +legacyConfig(thing(227)). +thingShort(227). +legacyConfig(thing(228)). +thingShort(228). +legacyConfig(thing(229)). +thingShort(229). +legacyConfig(thing(230)). +thingShort(230). +legacyConfig(thing(231)). +thingShort(231). +legacyConfig(thing(232)). +thingShort(232). +legacyConfig(thing(233)). +thingShort(233). +legacyConfig(thing(234)). +thingShort(234). +legacyConfig(thing(235)). +thingShort(235). +legacyConfig(thing(236)). +thingShort(236). +legacyConfig(thing(237)). +thingShort(237). +legacyConfig(thing(238)). +thingShort(238). +legacyConfig(thing(239)). +thingShort(239). +legacyConfig(thing(240)). +thingShort(240). +legacyConfig(thing(241)). +thingShort(241). +legacyConfig(thing(242)). +thingShort(242). +legacyConfig(thing(243)). +thingShort(243). +legacyConfig(thing(244)). +thingShort(244). +legacyConfig(thing(245)). +thingShort(245). +legacyConfig(thing(246)). +thingShort(246). +legacyConfig(thing(247)). +thingShort(247). +legacyConfig(thing(248)). +thingShort(248). +legacyConfig(thing(249)). +thingShort(249). +legacyConfig(thing(250)). +thingShort(250). +legacyConfig(thing(251)). +thingShort(251). +legacyConfig(thing(252)). +thingShort(252). +legacyConfig(thing(253)). +thingShort(253). +legacyConfig(thing(254)). +thingShort(254). +legacyConfig(thing(255)). +thingShort(255). +legacyConfig(thing(256)). +thingShort(256). +legacyConfig(thing(257)). +thingShort(257). +legacyConfig(thing(258)). +thingShort(258). +legacyConfig(thing(259)). +thingShort(259). +legacyConfig(thing(260)). +thingShort(260). +legacyConfig(thing(261)). +thingShort(261). +legacyConfig(thing(262)). +thingShort(262). +legacyConfig(thing(263)). +thingShort(263). +legacyConfig(thing(264)). +thingShort(264). +legacyConfig(thing(265)). +thingShort(265). +legacyConfig(thing(266)). +thingShort(266). +legacyConfig(thing(267)). +thingShort(267). +legacyConfig(thing(268)). +thingShort(268). +legacyConfig(thing(269)). +thingShort(269). +legacyConfig(thing(270)). +thingShort(270). +legacyConfig(thing(271)). +thingShort(271). +legacyConfig(thing(272)). +thingShort(272). +legacyConfig(thing(273)). +thingShort(273). +legacyConfig(thing(274)). +thingShort(274). +legacyConfig(thing(275)). +thingShort(275). +legacyConfig(thing(276)). +thingShort(276). +legacyConfig(thing(277)). +thingShort(277). +legacyConfig(thing(278)). +thingShort(278). +legacyConfig(thing(279)). +thingShort(279). +legacyConfig(thing(280)). +thingShort(280). +legacyConfig(thing(281)). +thingShort(281). +legacyConfig(thing(282)). +thingShort(282). +legacyConfig(thing(283)). +thingShort(283). +legacyConfig(thing(284)). +thingShort(284). +legacyConfig(thing(285)). +thingShort(285). +legacyConfig(thing(286)). +thingShort(286). +legacyConfig(thing(287)). +thingShort(287). +legacyConfig(thing(288)). +thingShort(288). +legacyConfig(thing(289)). +thingShort(289). +legacyConfig(thing(290)). +thingShort(290). +legacyConfig(thing(291)). +thingShort(291). +legacyConfig(thing(292)). +thingShort(292). +legacyConfig(thing(293)). +thingShort(293). +legacyConfig(thing(294)). +thingShort(294). +legacyConfig(thing(295)). +thingShort(295). +legacyConfig(thing(296)). +thingShort(296). +legacyConfig(thing(297)). +thingShort(297). +legacyConfig(thing(298)). +thingShort(298). +legacyConfig(thing(299)). +thingShort(299). +legacyConfig(thing(300)). +thingShort(300). +legacyConfig(thing(301)). +thingShort(301). +legacyConfig(thing(302)). +thingShort(302). +legacyConfig(thing(303)). +thingShort(303). +legacyConfig(thing(304)). +thingShort(304). +legacyConfig(thing(305)). +thingShort(305). +legacyConfig(thing(306)). +thingShort(306). +legacyConfig(thing(307)). +thingShort(307). +legacyConfig(thing(308)). +thingShort(308). +legacyConfig(thing(309)). +thingShort(309). +legacyConfig(thing(310)). +thingShort(310). +legacyConfig(thing(311)). +thingShort(311). +legacyConfig(thing(312)). +thingShort(312). +legacyConfig(thing(313)). +thingShort(313). +legacyConfig(thing(314)). +thingShort(314). +legacyConfig(thing(315)). +thingShort(315). +legacyConfig(thing(316)). +thingShort(316). +legacyConfig(thing(317)). +thingShort(317). +legacyConfig(thing(318)). +thingShort(318). +legacyConfig(thing(319)). +thingShort(319). +legacyConfig(thing(320)). +thingShort(320). +legacyConfig(thing(321)). +thingShort(321). +legacyConfig(thing(322)). +thingShort(322). +legacyConfig(thing(323)). +thingShort(323). +legacyConfig(thing(324)). +thingShort(324). +legacyConfig(thing(325)). +thingShort(325). +legacyConfig(thing(326)). +thingShort(326). +legacyConfig(thing(327)). +thingShort(327). +legacyConfig(thing(328)). +thingShort(328). +legacyConfig(thing(329)). +thingShort(329). +legacyConfig(thing(330)). +thingShort(330). +legacyConfig(thing(331)). +thingShort(331). +legacyConfig(thing(332)). +thingShort(332). +legacyConfig(thing(333)). +thingShort(333). +legacyConfig(thing(334)). +thingShort(334). +legacyConfig(thing(335)). +thingShort(335). +legacyConfig(thing(336)). +thingShort(336). +legacyConfig(thing(337)). +thingShort(337). +legacyConfig(thing(338)). +thingShort(338). +legacyConfig(thing(339)). +thingShort(339). +legacyConfig(thing(340)). +thingShort(340). +legacyConfig(thing(341)). +thingShort(341). +legacyConfig(thing(342)). +thingShort(342). +legacyConfig(thing(343)). +thingShort(343). +legacyConfig(thing(344)). +thingShort(344). +legacyConfig(thing(345)). +thingShort(345). +legacyConfig(thing(346)). +thingShort(346). +legacyConfig(thing(347)). +thingShort(347). +legacyConfig(thing(348)). +thingShort(348). +legacyConfig(thing(349)). +thingShort(349). +legacyConfig(thing(350)). +thingShort(350). +legacyConfig(thing(351)). +thingShort(351). +legacyConfig(thing(352)). +thingShort(352). +legacyConfig(thing(353)). +thingShort(353). +legacyConfig(thing(354)). +thingShort(354). +legacyConfig(thing(355)). +thingShort(355). +legacyConfig(thing(356)). +thingShort(356). +legacyConfig(thing(357)). +thingShort(357). +legacyConfig(thing(358)). +thingShort(358). +legacyConfig(thing(359)). +thingShort(359). +legacyConfig(thing(360)). +thingShort(360). +legacyConfig(thing(361)). +thingShort(361). +legacyConfig(thing(362)). +thingShort(362). +legacyConfig(thing(363)). +thingShort(363). +legacyConfig(thing(364)). +thingShort(364). +legacyConfig(thing(365)). +thingShort(365). +legacyConfig(thing(366)). +thingShort(366). +legacyConfig(thing(367)). +thingShort(367). +legacyConfig(thing(368)). +thingShort(368). +legacyConfig(thing(369)). +thingShort(369). +legacyConfig(thing(370)). +thingShort(370). +legacyConfig(thing(371)). +thingShort(371). +legacyConfig(thing(372)). +thingShort(372). +legacyConfig(thing(373)). +thingShort(373). +legacyConfig(thing(374)). +thingShort(374). +legacyConfig(thing(375)). +thingShort(375). +legacyConfig(thing(376)). +thingShort(376). +legacyConfig(thing(377)). +thingShort(377). +legacyConfig(thing(378)). +thingShort(378). +legacyConfig(thing(379)). +thingShort(379). +legacyConfig(thing(380)). +thingShort(380). +legacyConfig(thing(381)). +thingShort(381). +legacyConfig(thing(382)). +thingShort(382). +legacyConfig(thing(383)). +thingShort(383). +legacyConfig(thing(384)). +thingShort(384). +legacyConfig(thing(385)). +thingShort(385). +legacyConfig(thing(386)). +thingShort(386). +legacyConfig(thing(387)). +thingShort(387). +legacyConfig(thing(388)). +thingShort(388). +legacyConfig(thing(389)). +thingShort(389). +legacyConfig(thing(390)). +thingShort(390). +legacyConfig(thing(391)). +thingShort(391). +legacyConfig(thing(392)). +thingShort(392). +legacyConfig(thing(393)). +thingShort(393). +legacyConfig(thing(394)). +thingShort(394). +legacyConfig(thing(395)). +thingShort(395). +legacyConfig(thing(396)). +thingShort(396). +legacyConfig(thing(397)). +thingShort(397). +legacyConfig(thing(398)). +thingShort(398). +legacyConfig(thing(399)). +thingShort(399). +legacyConfig(thing(400)). +thingShort(400). +legacyConfig(thing(401)). +thingShort(401). +legacyConfig(thing(402)). +thingShort(402). +legacyConfig(thing(403)). +thingShort(403). +legacyConfig(thing(404)). +thingShort(404). +legacyConfig(thing(405)). +thingShort(405). +legacyConfig(thing(406)). +thingShort(406). +legacyConfig(thing(407)). +thingShort(407). +legacyConfig(thing(408)). +thingShort(408). +legacyConfig(thing(409)). +thingShort(409). +legacyConfig(thing(410)). +thingShort(410). +legacyConfig(thing(411)). +thingShort(411). +legacyConfig(thing(412)). +thingShort(412). +legacyConfig(thing(413)). +thingShort(413). +legacyConfig(thing(414)). +thingShort(414). +legacyConfig(thing(415)). +thingShort(415). +legacyConfig(thing(416)). +thingShort(416). +legacyConfig(thing(417)). +thingShort(417). +legacyConfig(thing(418)). +thingShort(418). +legacyConfig(thing(419)). +thingShort(419). +legacyConfig(thing(420)). +thingShort(420). +legacyConfig(thing(421)). +thingShort(421). +legacyConfig(thing(422)). +thingShort(422). +legacyConfig(thing(423)). +thingShort(423). +legacyConfig(thing(424)). +thingShort(424). +legacyConfig(thing(425)). +thingShort(425). +legacyConfig(thing(426)). +thingShort(426). +legacyConfig(thing(427)). +thingShort(427). +legacyConfig(thing(428)). +thingShort(428). +legacyConfig(thing(429)). +thingShort(429). +legacyConfig(thing(430)). +thingShort(430). +legacyConfig(thing(431)). +thingShort(431). +legacyConfig(thing(432)). +thingShort(432). +legacyConfig(thing(433)). +thingShort(433). +legacyConfig(thing(434)). +thingShort(434). +legacyConfig(thing(435)). +thingShort(435). +legacyConfig(thing(436)). +thingShort(436). +legacyConfig(thing(437)). +thingShort(437). +legacyConfig(thing(438)). +thingShort(438). +legacyConfig(thing(439)). +thingShort(439). +legacyConfig(thing(440)). +thingShort(440). +legacyConfig(thing(441)). +thingShort(441). +legacyConfig(thing(442)). +thingShort(442). +legacyConfig(thing(443)). +thingShort(443). +legacyConfig(thing(444)). +thingShort(444). +legacyConfig(thing(445)). +thingShort(445). +legacyConfig(thing(446)). +thingShort(446). +legacyConfig(thing(447)). +thingShort(447). +legacyConfig(thing(448)). +thingShort(448). +legacyConfig(thing(449)). +thingShort(449). +legacyConfig(thing(450)). +thingShort(450). +legacyConfig(thing(451)). +thingShort(451). +legacyConfig(thing(452)). +thingShort(452). +legacyConfig(thing(453)). +thingShort(453). +legacyConfig(thing(454)). +thingShort(454). +legacyConfig(thing(455)). +thingShort(455). +legacyConfig(thing(456)). +thingShort(456). +legacyConfig(thing(457)). +thingShort(457). +legacyConfig(thing(458)). +thingShort(458). +legacyConfig(thing(459)). +thingShort(459). +legacyConfig(thing(460)). +thingShort(460). +legacyConfig(thing(461)). +thingShort(461). +legacyConfig(thing(462)). +thingShort(462). +legacyConfig(thing(463)). +thingShort(463). +legacyConfig(thing(464)). +thingShort(464). +legacyConfig(thing(465)). +thingShort(465). +legacyConfig(thing(466)). +thingShort(466). +legacyConfig(thing(467)). +thingShort(467). +legacyConfig(thing(468)). +thingShort(468). +legacyConfig(thing(469)). +thingShort(469). +legacyConfig(thing(470)). +thingShort(470). +legacyConfig(thing(471)). +thingShort(471). +legacyConfig(thing(472)). +thingShort(472). +legacyConfig(thing(473)). +thingShort(473). +legacyConfig(thing(474)). +thingShort(474). +legacyConfig(thing(475)). +thingShort(475). +legacyConfig(thing(476)). +thingShort(476). +legacyConfig(thing(477)). +thingShort(477). +legacyConfig(thing(478)). +thingShort(478). +legacyConfig(thing(479)). +thingShort(479). +legacyConfig(thing(480)). +thingShort(480). +legacyConfig(thing(481)). +thingShort(481). +legacyConfig(thing(482)). +thingShort(482). +legacyConfig(thing(483)). +thingShort(483). +legacyConfig(thing(484)). +thingShort(484). +legacyConfig(thing(485)). +thingShort(485). +legacyConfig(thing(486)). +thingShort(486). +legacyConfig(thing(487)). +thingShort(487). +legacyConfig(thing(488)). +thingShort(488). +legacyConfig(thing(489)). +thingShort(489). +legacyConfig(thing(490)). +thingShort(490). +legacyConfig(thing(491)). +thingShort(491). +legacyConfig(thing(492)). +thingShort(492). +legacyConfig(thing(493)). +thingShort(493). +legacyConfig(thing(494)). +thingShort(494). +legacyConfig(thing(495)). +thingShort(495). +legacyConfig(thing(496)). +thingShort(496). +legacyConfig(thing(497)). +thingShort(497). +legacyConfig(thing(498)). +thingShort(498). +legacyConfig(thing(499)). +thingShort(499). +legacyConfig(thing(500)). +thingShort(500). +legacyConfig(thing(501)). +thingShort(501). +legacyConfig(thing(502)). +thingShort(502). +legacyConfig(thing(503)). +thingShort(503). +legacyConfig(thing(504)). +thingShort(504). +legacyConfig(thing(505)). +thingShort(505). +legacyConfig(thing(506)). +thingShort(506). +legacyConfig(thing(507)). +thingShort(507). +legacyConfig(thing(508)). +thingShort(508). +legacyConfig(thing(509)). +thingShort(509). +legacyConfig(thing(510)). +thingShort(510). +legacyConfig(thing(511)). +thingShort(511). +legacyConfig(thing(512)). +thingShort(512). +legacyConfig(thing(513)). +thingShort(513). +legacyConfig(thing(514)). +thingShort(514). +legacyConfig(thing(515)). +thingShort(515). +legacyConfig(thing(516)). +thingShort(516). +legacyConfig(thing(517)). +thingShort(517). +legacyConfig(thing(518)). +thingShort(518). +legacyConfig(thing(519)). +thingShort(519). +legacyConfig(thing(520)). +thingShort(520). +legacyConfig(thing(521)). +thingShort(521). +legacyConfig(thing(522)). +thingShort(522). +legacyConfig(thing(523)). +thingShort(523). +legacyConfig(thing(524)). +thingShort(524). +legacyConfig(thing(525)). +thingShort(525). +legacyConfig(thing(526)). +thingShort(526). +legacyConfig(thing(527)). +thingShort(527). +legacyConfig(thing(528)). +thingShort(528). +legacyConfig(thing(529)). +thingShort(529). +legacyConfig(thing(530)). +thingShort(530). +legacyConfig(thing(531)). +thingShort(531). +legacyConfig(thing(532)). +thingShort(532). +legacyConfig(thing(533)). +thingShort(533). +legacyConfig(thing(534)). +thingShort(534). +legacyConfig(thing(535)). +thingShort(535). +legacyConfig(thing(536)). +thingShort(536). +legacyConfig(thing(537)). +thingShort(537). +legacyConfig(thing(538)). +thingShort(538). +legacyConfig(thing(539)). +thingShort(539). +legacyConfig(thing(540)). +thingShort(540). +legacyConfig(thing(541)). +thingShort(541). +legacyConfig(thing(542)). +thingShort(542). +legacyConfig(thing(543)). +thingShort(543). +legacyConfig(thing(544)). +thingShort(544). +legacyConfig(thing(545)). +thingShort(545). +legacyConfig(thing(546)). +thingShort(546). +legacyConfig(thing(547)). +thingShort(547). +legacyConfig(thing(548)). +thingShort(548). +legacyConfig(thing(549)). +thingShort(549). +legacyConfig(thing(550)). +thingShort(550). +legacyConfig(thing(551)). +thingShort(551). +legacyConfig(thing(552)). +thingShort(552). +legacyConfig(thing(553)). +thingShort(553). +legacyConfig(thing(554)). +thingShort(554). +legacyConfig(thing(555)). +thingShort(555). +legacyConfig(thing(556)). +thingShort(556). +legacyConfig(thing(557)). +thingShort(557). +legacyConfig(thing(558)). +thingShort(558). +legacyConfig(thing(559)). +thingShort(559). +legacyConfig(thing(560)). +thingShort(560). +legacyConfig(thing(561)). +thingShort(561). +legacyConfig(thing(562)). +thingShort(562). +legacyConfig(thing(563)). +thingShort(563). +legacyConfig(thing(564)). +thingShort(564). +legacyConfig(thing(565)). +thingShort(565). +legacyConfig(thing(566)). +thingShort(566). +legacyConfig(thing(567)). +thingShort(567). +legacyConfig(thing(568)). +thingShort(568). +legacyConfig(thing(569)). +thingShort(569). +legacyConfig(thing(570)). +thingShort(570). +legacyConfig(personTOthing(1,96)). +legacyConfig(personTOthing(1,97)). +legacyConfig(personTOthing(1,98)). +legacyConfig(personTOthing(1,99)). +legacyConfig(personTOthing(1,100)). +legacyConfig(personTOthing(2,101)). +legacyConfig(personTOthing(2,102)). +legacyConfig(personTOthing(2,103)). +legacyConfig(personTOthing(2,104)). +legacyConfig(personTOthing(2,105)). +legacyConfig(personTOthing(3,106)). +legacyConfig(personTOthing(3,107)). +legacyConfig(personTOthing(3,108)). +legacyConfig(personTOthing(3,109)). +legacyConfig(personTOthing(3,110)). +legacyConfig(personTOthing(4,111)). +legacyConfig(personTOthing(4,112)). +legacyConfig(personTOthing(4,113)). +legacyConfig(personTOthing(4,114)). +legacyConfig(personTOthing(4,115)). +legacyConfig(personTOthing(5,116)). +legacyConfig(personTOthing(5,117)). +legacyConfig(personTOthing(5,118)). +legacyConfig(personTOthing(5,119)). +legacyConfig(personTOthing(5,120)). +legacyConfig(personTOthing(6,121)). +legacyConfig(personTOthing(6,122)). +legacyConfig(personTOthing(6,123)). +legacyConfig(personTOthing(6,124)). +legacyConfig(personTOthing(6,125)). +legacyConfig(personTOthing(7,126)). +legacyConfig(personTOthing(7,127)). +legacyConfig(personTOthing(7,128)). +legacyConfig(personTOthing(7,129)). +legacyConfig(personTOthing(7,130)). +legacyConfig(personTOthing(8,131)). +legacyConfig(personTOthing(8,132)). +legacyConfig(personTOthing(8,133)). +legacyConfig(personTOthing(8,134)). +legacyConfig(personTOthing(8,135)). +legacyConfig(personTOthing(9,136)). +legacyConfig(personTOthing(9,137)). +legacyConfig(personTOthing(9,138)). +legacyConfig(personTOthing(9,139)). +legacyConfig(personTOthing(9,140)). +legacyConfig(personTOthing(10,141)). +legacyConfig(personTOthing(10,142)). +legacyConfig(personTOthing(10,143)). +legacyConfig(personTOthing(10,144)). +legacyConfig(personTOthing(10,145)). +legacyConfig(personTOthing(11,146)). +legacyConfig(personTOthing(11,147)). +legacyConfig(personTOthing(11,148)). +legacyConfig(personTOthing(11,149)). +legacyConfig(personTOthing(11,150)). +legacyConfig(personTOthing(12,151)). +legacyConfig(personTOthing(12,152)). +legacyConfig(personTOthing(12,153)). +legacyConfig(personTOthing(12,154)). +legacyConfig(personTOthing(12,155)). +legacyConfig(personTOthing(13,156)). +legacyConfig(personTOthing(13,157)). +legacyConfig(personTOthing(13,158)). +legacyConfig(personTOthing(13,159)). +legacyConfig(personTOthing(13,160)). +legacyConfig(personTOthing(14,161)). +legacyConfig(personTOthing(14,162)). +legacyConfig(personTOthing(14,163)). +legacyConfig(personTOthing(14,164)). +legacyConfig(personTOthing(14,165)). +legacyConfig(personTOthing(15,166)). +legacyConfig(personTOthing(15,167)). +legacyConfig(personTOthing(15,168)). +legacyConfig(personTOthing(15,169)). +legacyConfig(personTOthing(15,170)). +legacyConfig(personTOthing(16,171)). +legacyConfig(personTOthing(16,172)). +legacyConfig(personTOthing(16,173)). +legacyConfig(personTOthing(16,174)). +legacyConfig(personTOthing(16,175)). +legacyConfig(personTOthing(17,176)). +legacyConfig(personTOthing(17,177)). +legacyConfig(personTOthing(17,178)). +legacyConfig(personTOthing(17,179)). +legacyConfig(personTOthing(17,180)). +legacyConfig(personTOthing(18,181)). +legacyConfig(personTOthing(18,182)). +legacyConfig(personTOthing(18,183)). +legacyConfig(personTOthing(18,184)). +legacyConfig(personTOthing(18,185)). +legacyConfig(personTOthing(19,186)). +legacyConfig(personTOthing(19,187)). +legacyConfig(personTOthing(19,188)). +legacyConfig(personTOthing(19,189)). +legacyConfig(personTOthing(19,190)). +legacyConfig(personTOthing(20,191)). +legacyConfig(personTOthing(20,192)). +legacyConfig(personTOthing(20,193)). +legacyConfig(personTOthing(20,194)). +legacyConfig(personTOthing(20,195)). +legacyConfig(personTOthing(21,196)). +legacyConfig(personTOthing(21,197)). +legacyConfig(personTOthing(21,198)). +legacyConfig(personTOthing(21,199)). +legacyConfig(personTOthing(21,200)). +legacyConfig(personTOthing(22,201)). +legacyConfig(personTOthing(22,202)). +legacyConfig(personTOthing(22,203)). +legacyConfig(personTOthing(22,204)). +legacyConfig(personTOthing(22,205)). +legacyConfig(personTOthing(23,206)). +legacyConfig(personTOthing(23,207)). +legacyConfig(personTOthing(23,208)). +legacyConfig(personTOthing(23,209)). +legacyConfig(personTOthing(23,210)). +legacyConfig(personTOthing(24,211)). +legacyConfig(personTOthing(24,212)). +legacyConfig(personTOthing(24,213)). +legacyConfig(personTOthing(24,214)). +legacyConfig(personTOthing(24,215)). +legacyConfig(personTOthing(25,216)). +legacyConfig(personTOthing(25,217)). +legacyConfig(personTOthing(25,218)). +legacyConfig(personTOthing(25,219)). +legacyConfig(personTOthing(25,220)). +legacyConfig(personTOthing(26,221)). +legacyConfig(personTOthing(26,222)). +legacyConfig(personTOthing(26,223)). +legacyConfig(personTOthing(26,224)). +legacyConfig(personTOthing(26,225)). +legacyConfig(personTOthing(27,226)). +legacyConfig(personTOthing(27,227)). +legacyConfig(personTOthing(27,228)). +legacyConfig(personTOthing(27,229)). +legacyConfig(personTOthing(27,230)). +legacyConfig(personTOthing(28,231)). +legacyConfig(personTOthing(28,232)). +legacyConfig(personTOthing(28,233)). +legacyConfig(personTOthing(28,234)). +legacyConfig(personTOthing(28,235)). +legacyConfig(personTOthing(29,236)). +legacyConfig(personTOthing(29,237)). +legacyConfig(personTOthing(29,238)). +legacyConfig(personTOthing(29,239)). +legacyConfig(personTOthing(29,240)). +legacyConfig(personTOthing(30,241)). +legacyConfig(personTOthing(30,242)). +legacyConfig(personTOthing(30,243)). +legacyConfig(personTOthing(30,244)). +legacyConfig(personTOthing(30,245)). +legacyConfig(personTOthing(31,246)). +legacyConfig(personTOthing(31,247)). +legacyConfig(personTOthing(31,248)). +legacyConfig(personTOthing(31,249)). +legacyConfig(personTOthing(31,250)). +legacyConfig(personTOthing(32,251)). +legacyConfig(personTOthing(32,252)). +legacyConfig(personTOthing(32,253)). +legacyConfig(personTOthing(32,254)). +legacyConfig(personTOthing(32,255)). +legacyConfig(personTOthing(33,256)). +legacyConfig(personTOthing(33,257)). +legacyConfig(personTOthing(33,258)). +legacyConfig(personTOthing(33,259)). +legacyConfig(personTOthing(33,260)). +legacyConfig(personTOthing(34,261)). +legacyConfig(personTOthing(34,262)). +legacyConfig(personTOthing(34,263)). +legacyConfig(personTOthing(34,264)). +legacyConfig(personTOthing(34,265)). +legacyConfig(personTOthing(35,266)). +legacyConfig(personTOthing(35,267)). +legacyConfig(personTOthing(35,268)). +legacyConfig(personTOthing(35,269)). +legacyConfig(personTOthing(35,270)). +legacyConfig(personTOthing(36,271)). +legacyConfig(personTOthing(36,272)). +legacyConfig(personTOthing(36,273)). +legacyConfig(personTOthing(36,274)). +legacyConfig(personTOthing(36,275)). +legacyConfig(personTOthing(37,276)). +legacyConfig(personTOthing(37,277)). +legacyConfig(personTOthing(37,278)). +legacyConfig(personTOthing(37,279)). +legacyConfig(personTOthing(37,280)). +legacyConfig(personTOthing(38,281)). +legacyConfig(personTOthing(38,282)). +legacyConfig(personTOthing(38,283)). +legacyConfig(personTOthing(38,284)). +legacyConfig(personTOthing(38,285)). +legacyConfig(personTOthing(39,286)). +legacyConfig(personTOthing(39,287)). +legacyConfig(personTOthing(39,288)). +legacyConfig(personTOthing(39,289)). +legacyConfig(personTOthing(39,290)). +legacyConfig(personTOthing(40,291)). +legacyConfig(personTOthing(40,292)). +legacyConfig(personTOthing(40,293)). +legacyConfig(personTOthing(40,294)). +legacyConfig(personTOthing(40,295)). +legacyConfig(personTOthing(41,296)). +legacyConfig(personTOthing(41,297)). +legacyConfig(personTOthing(41,298)). +legacyConfig(personTOthing(41,299)). +legacyConfig(personTOthing(41,300)). +legacyConfig(personTOthing(42,301)). +legacyConfig(personTOthing(42,302)). +legacyConfig(personTOthing(42,303)). +legacyConfig(personTOthing(42,304)). +legacyConfig(personTOthing(42,305)). +legacyConfig(personTOthing(43,306)). +legacyConfig(personTOthing(43,307)). +legacyConfig(personTOthing(43,308)). +legacyConfig(personTOthing(43,309)). +legacyConfig(personTOthing(43,310)). +legacyConfig(personTOthing(44,311)). +legacyConfig(personTOthing(44,312)). +legacyConfig(personTOthing(44,313)). +legacyConfig(personTOthing(44,314)). +legacyConfig(personTOthing(44,315)). +legacyConfig(personTOthing(45,316)). +legacyConfig(personTOthing(45,317)). +legacyConfig(personTOthing(45,318)). +legacyConfig(personTOthing(45,319)). +legacyConfig(personTOthing(45,320)). +legacyConfig(personTOthing(46,321)). +legacyConfig(personTOthing(46,322)). +legacyConfig(personTOthing(46,323)). +legacyConfig(personTOthing(46,324)). +legacyConfig(personTOthing(46,325)). +legacyConfig(personTOthing(47,326)). +legacyConfig(personTOthing(47,327)). +legacyConfig(personTOthing(47,328)). +legacyConfig(personTOthing(47,329)). +legacyConfig(personTOthing(47,330)). +legacyConfig(personTOthing(48,331)). +legacyConfig(personTOthing(48,332)). +legacyConfig(personTOthing(48,333)). +legacyConfig(personTOthing(48,334)). +legacyConfig(personTOthing(48,335)). +legacyConfig(personTOthing(49,336)). +legacyConfig(personTOthing(49,337)). +legacyConfig(personTOthing(49,338)). +legacyConfig(personTOthing(49,339)). +legacyConfig(personTOthing(49,340)). +legacyConfig(personTOthing(50,341)). +legacyConfig(personTOthing(50,342)). +legacyConfig(personTOthing(50,343)). +legacyConfig(personTOthing(50,344)). +legacyConfig(personTOthing(50,345)). +legacyConfig(personTOthing(51,346)). +legacyConfig(personTOthing(51,347)). +legacyConfig(personTOthing(51,348)). +legacyConfig(personTOthing(51,349)). +legacyConfig(personTOthing(51,350)). +legacyConfig(personTOthing(52,351)). +legacyConfig(personTOthing(52,352)). +legacyConfig(personTOthing(52,353)). +legacyConfig(personTOthing(52,354)). +legacyConfig(personTOthing(52,355)). +legacyConfig(personTOthing(53,356)). +legacyConfig(personTOthing(53,357)). +legacyConfig(personTOthing(53,358)). +legacyConfig(personTOthing(53,359)). +legacyConfig(personTOthing(53,360)). +legacyConfig(personTOthing(54,361)). +legacyConfig(personTOthing(54,362)). +legacyConfig(personTOthing(54,363)). +legacyConfig(personTOthing(54,364)). +legacyConfig(personTOthing(54,365)). +legacyConfig(personTOthing(55,366)). +legacyConfig(personTOthing(55,367)). +legacyConfig(personTOthing(55,368)). +legacyConfig(personTOthing(55,369)). +legacyConfig(personTOthing(55,370)). +legacyConfig(personTOthing(56,371)). +legacyConfig(personTOthing(56,372)). +legacyConfig(personTOthing(56,373)). +legacyConfig(personTOthing(56,374)). +legacyConfig(personTOthing(56,375)). +legacyConfig(personTOthing(57,376)). +legacyConfig(personTOthing(57,377)). +legacyConfig(personTOthing(57,378)). +legacyConfig(personTOthing(57,379)). +legacyConfig(personTOthing(57,380)). +legacyConfig(personTOthing(58,381)). +legacyConfig(personTOthing(58,382)). +legacyConfig(personTOthing(58,383)). +legacyConfig(personTOthing(58,384)). +legacyConfig(personTOthing(58,385)). +legacyConfig(personTOthing(59,386)). +legacyConfig(personTOthing(59,387)). +legacyConfig(personTOthing(59,388)). +legacyConfig(personTOthing(59,389)). +legacyConfig(personTOthing(59,390)). +legacyConfig(personTOthing(60,391)). +legacyConfig(personTOthing(60,392)). +legacyConfig(personTOthing(60,393)). +legacyConfig(personTOthing(60,394)). +legacyConfig(personTOthing(60,395)). +legacyConfig(personTOthing(61,396)). +legacyConfig(personTOthing(61,397)). +legacyConfig(personTOthing(61,398)). +legacyConfig(personTOthing(61,399)). +legacyConfig(personTOthing(61,400)). +legacyConfig(personTOthing(62,401)). +legacyConfig(personTOthing(62,402)). +legacyConfig(personTOthing(62,403)). +legacyConfig(personTOthing(62,404)). +legacyConfig(personTOthing(62,405)). +legacyConfig(personTOthing(63,406)). +legacyConfig(personTOthing(63,407)). +legacyConfig(personTOthing(63,408)). +legacyConfig(personTOthing(63,409)). +legacyConfig(personTOthing(63,410)). +legacyConfig(personTOthing(64,411)). +legacyConfig(personTOthing(64,412)). +legacyConfig(personTOthing(64,413)). +legacyConfig(personTOthing(64,414)). +legacyConfig(personTOthing(64,415)). +legacyConfig(personTOthing(65,416)). +legacyConfig(personTOthing(65,417)). +legacyConfig(personTOthing(65,418)). +legacyConfig(personTOthing(65,419)). +legacyConfig(personTOthing(65,420)). +legacyConfig(personTOthing(66,421)). +legacyConfig(personTOthing(66,422)). +legacyConfig(personTOthing(66,423)). +legacyConfig(personTOthing(66,424)). +legacyConfig(personTOthing(66,425)). +legacyConfig(personTOthing(67,426)). +legacyConfig(personTOthing(67,427)). +legacyConfig(personTOthing(67,428)). +legacyConfig(personTOthing(67,429)). +legacyConfig(personTOthing(67,430)). +legacyConfig(personTOthing(68,431)). +legacyConfig(personTOthing(68,432)). +legacyConfig(personTOthing(68,433)). +legacyConfig(personTOthing(68,434)). +legacyConfig(personTOthing(68,435)). +legacyConfig(personTOthing(69,436)). +legacyConfig(personTOthing(69,437)). +legacyConfig(personTOthing(69,438)). +legacyConfig(personTOthing(69,439)). +legacyConfig(personTOthing(69,440)). +legacyConfig(personTOthing(70,441)). +legacyConfig(personTOthing(70,442)). +legacyConfig(personTOthing(70,443)). +legacyConfig(personTOthing(70,444)). +legacyConfig(personTOthing(70,445)). +legacyConfig(personTOthing(71,446)). +legacyConfig(personTOthing(71,447)). +legacyConfig(personTOthing(71,448)). +legacyConfig(personTOthing(71,449)). +legacyConfig(personTOthing(71,450)). +legacyConfig(personTOthing(72,451)). +legacyConfig(personTOthing(72,452)). +legacyConfig(personTOthing(72,453)). +legacyConfig(personTOthing(72,454)). +legacyConfig(personTOthing(72,455)). +legacyConfig(personTOthing(73,456)). +legacyConfig(personTOthing(73,457)). +legacyConfig(personTOthing(73,458)). +legacyConfig(personTOthing(73,459)). +legacyConfig(personTOthing(73,460)). +legacyConfig(personTOthing(74,461)). +legacyConfig(personTOthing(74,462)). +legacyConfig(personTOthing(74,463)). +legacyConfig(personTOthing(74,464)). +legacyConfig(personTOthing(74,465)). +legacyConfig(personTOthing(75,466)). +legacyConfig(personTOthing(75,467)). +legacyConfig(personTOthing(75,468)). +legacyConfig(personTOthing(75,469)). +legacyConfig(personTOthing(75,470)). +legacyConfig(personTOthing(76,471)). +legacyConfig(personTOthing(76,472)). +legacyConfig(personTOthing(76,473)). +legacyConfig(personTOthing(76,474)). +legacyConfig(personTOthing(76,475)). +legacyConfig(personTOthing(77,476)). +legacyConfig(personTOthing(77,477)). +legacyConfig(personTOthing(77,478)). +legacyConfig(personTOthing(77,479)). +legacyConfig(personTOthing(77,480)). +legacyConfig(personTOthing(78,481)). +legacyConfig(personTOthing(78,482)). +legacyConfig(personTOthing(78,483)). +legacyConfig(personTOthing(78,484)). +legacyConfig(personTOthing(78,485)). +legacyConfig(personTOthing(79,486)). +legacyConfig(personTOthing(79,487)). +legacyConfig(personTOthing(79,488)). +legacyConfig(personTOthing(79,489)). +legacyConfig(personTOthing(79,490)). +legacyConfig(personTOthing(80,491)). +legacyConfig(personTOthing(80,492)). +legacyConfig(personTOthing(80,493)). +legacyConfig(personTOthing(80,494)). +legacyConfig(personTOthing(80,495)). +legacyConfig(personTOthing(81,496)). +legacyConfig(personTOthing(81,497)). +legacyConfig(personTOthing(81,498)). +legacyConfig(personTOthing(81,499)). +legacyConfig(personTOthing(81,500)). +legacyConfig(personTOthing(82,501)). +legacyConfig(personTOthing(82,502)). +legacyConfig(personTOthing(82,503)). +legacyConfig(personTOthing(82,504)). +legacyConfig(personTOthing(82,505)). +legacyConfig(personTOthing(83,506)). +legacyConfig(personTOthing(83,507)). +legacyConfig(personTOthing(83,508)). +legacyConfig(personTOthing(83,509)). +legacyConfig(personTOthing(83,510)). +legacyConfig(personTOthing(84,511)). +legacyConfig(personTOthing(84,512)). +legacyConfig(personTOthing(84,513)). +legacyConfig(personTOthing(84,514)). +legacyConfig(personTOthing(84,515)). +legacyConfig(personTOthing(85,516)). +legacyConfig(personTOthing(85,517)). +legacyConfig(personTOthing(85,518)). +legacyConfig(personTOthing(85,519)). +legacyConfig(personTOthing(85,520)). +legacyConfig(personTOthing(86,521)). +legacyConfig(personTOthing(86,522)). +legacyConfig(personTOthing(86,523)). +legacyConfig(personTOthing(86,524)). +legacyConfig(personTOthing(86,525)). +legacyConfig(personTOthing(87,526)). +legacyConfig(personTOthing(87,527)). +legacyConfig(personTOthing(87,528)). +legacyConfig(personTOthing(87,529)). +legacyConfig(personTOthing(87,530)). +legacyConfig(personTOthing(88,531)). +legacyConfig(personTOthing(88,532)). +legacyConfig(personTOthing(88,533)). +legacyConfig(personTOthing(88,534)). +legacyConfig(personTOthing(88,535)). +legacyConfig(personTOthing(89,536)). +legacyConfig(personTOthing(89,537)). +legacyConfig(personTOthing(89,538)). +legacyConfig(personTOthing(89,539)). +legacyConfig(personTOthing(89,540)). +legacyConfig(personTOthing(90,541)). +legacyConfig(personTOthing(90,542)). +legacyConfig(personTOthing(90,543)). +legacyConfig(personTOthing(90,544)). +legacyConfig(personTOthing(90,545)). +legacyConfig(personTOthing(91,546)). +legacyConfig(personTOthing(91,547)). +legacyConfig(personTOthing(91,548)). +legacyConfig(personTOthing(91,549)). +legacyConfig(personTOthing(91,550)). +legacyConfig(personTOthing(92,551)). +legacyConfig(personTOthing(92,552)). +legacyConfig(personTOthing(92,553)). +legacyConfig(personTOthing(92,554)). +legacyConfig(personTOthing(92,555)). +legacyConfig(personTOthing(93,556)). +legacyConfig(personTOthing(93,557)). +legacyConfig(personTOthing(93,558)). +legacyConfig(personTOthing(93,559)). +legacyConfig(personTOthing(93,560)). +legacyConfig(personTOthing(94,561)). +legacyConfig(personTOthing(94,562)). +legacyConfig(personTOthing(94,563)). +legacyConfig(personTOthing(94,564)). +legacyConfig(personTOthing(94,565)). +legacyConfig(personTOthing(95,566)). +legacyConfig(personTOthing(95,567)). +legacyConfig(personTOthing(95,568)). +legacyConfig(personTOthing(95,569)). +legacyConfig(personTOthing(95,570)). +% domains +cabinetDomainNew(1000..1474). +roomDomainNew(1500..1974). +cabinetUpper(475). +roomUpper(475). +cabinetLower(95). +roomLower(24). +% reuse costs +reuseCabinetTOthingCost(0). +reuseRoomTOcabinetCost(0). +reusePersonTOroomCost(0). +reuseCabinetAsHighCost(3). +reuseCabinetAsSmallCost(0). +reuseRoomCost(0). +% remove costs +removeCabinetTOthingCost(2). +removeRoomTOcabinetCost(2). +removePersonTOroomCost(2). +removeCabinetCost(2). +removeRoomCost(2). +% create costs +cabinetHighCost(100). +cabinetSmallCost(1). +roomCost(5). diff --git a/src/test/resources/DomainHeuristics/House/instances_alpha/longthings_2_p02t030c3.edb b/src/test/resources/DomainHeuristics/House/instances_alpha/longthings_2_p02t030c3.edb new file mode 100644 index 000000000..b06420707 --- /dev/null +++ b/src/test/resources/DomainHeuristics/House/instances_alpha/longthings_2_p02t030c3.edb @@ -0,0 +1,160 @@ +legacyConfig(person(1)). +legacyConfig(person(2)). +legacyConfig(room(3)). +legacyConfig(roomTOcabinet(3,5)). +legacyConfig(roomTOcabinet(3,6)). +legacyConfig(roomTOcabinet(3,7)). +legacyConfig(room(4)). +legacyConfig(roomTOcabinet(4,8)). +legacyConfig(roomTOcabinet(4,9)). +legacyConfig(roomTOcabinet(4,10)). +legacyConfig(thing(11)). +thingShort(11). +legacyConfig(thing(12)). +thingShort(12). +legacyConfig(thing(13)). +thingShort(13). +legacyConfig(thing(14)). +thingShort(14). +legacyConfig(thing(15)). +thingLong(15). +legacyConfig(thing(16)). +thingShort(16). +legacyConfig(thing(17)). +thingShort(17). +legacyConfig(thing(18)). +thingShort(18). +legacyConfig(thing(19)). +thingShort(19). +legacyConfig(thing(20)). +thingLong(20). +legacyConfig(thing(21)). +thingShort(21). +legacyConfig(thing(22)). +thingShort(22). +legacyConfig(thing(23)). +thingLong(23). +legacyConfig(thing(24)). +thingLong(24). +legacyConfig(thing(25)). +thingLong(25). +legacyConfig(thing(26)). +thingShort(26). +legacyConfig(thing(27)). +thingShort(27). +legacyConfig(thing(28)). +thingShort(28). +legacyConfig(thing(29)). +thingShort(29). +legacyConfig(thing(30)). +thingLong(30). +legacyConfig(thing(31)). +thingShort(31). +legacyConfig(thing(32)). +thingShort(32). +legacyConfig(thing(33)). +thingShort(33). +legacyConfig(thing(34)). +thingShort(34). +legacyConfig(thing(35)). +thingLong(35). +legacyConfig(thing(36)). +thingShort(36). +legacyConfig(thing(37)). +thingShort(37). +legacyConfig(thing(38)). +thingLong(38). +legacyConfig(thing(39)). +thingLong(39). +legacyConfig(thing(40)). +thingLong(40). +legacyConfig(cabinet(9)). +legacyConfig(cabinetTOthing(9,31)). +legacyConfig(cabinetTOthing(9,32)). +legacyConfig(cabinetTOthing(9,33)). +legacyConfig(cabinetTOthing(9,34)). +legacyConfig(cabinetTOthing(9,35)). +legacyConfig(cabinet(10)). +legacyConfig(cabinetTOthing(10,36)). +legacyConfig(cabinetTOthing(10,37)). +legacyConfig(cabinetTOthing(10,38)). +legacyConfig(cabinetTOthing(10,39)). +legacyConfig(cabinetTOthing(10,40)). +legacyConfig(cabinet(5)). +legacyConfig(cabinetTOthing(5,11)). +legacyConfig(cabinetTOthing(5,12)). +legacyConfig(cabinetTOthing(5,13)). +legacyConfig(cabinetTOthing(5,14)). +legacyConfig(cabinetTOthing(5,15)). +legacyConfig(cabinet(6)). +legacyConfig(cabinetTOthing(6,16)). +legacyConfig(cabinetTOthing(6,17)). +legacyConfig(cabinetTOthing(6,18)). +legacyConfig(cabinetTOthing(6,19)). +legacyConfig(cabinetTOthing(6,20)). +legacyConfig(cabinet(7)). +legacyConfig(cabinetTOthing(7,21)). +legacyConfig(cabinetTOthing(7,22)). +legacyConfig(cabinetTOthing(7,23)). +legacyConfig(cabinetTOthing(7,24)). +legacyConfig(cabinetTOthing(7,25)). +legacyConfig(cabinet(8)). +legacyConfig(cabinetTOthing(8,26)). +legacyConfig(cabinetTOthing(8,27)). +legacyConfig(cabinetTOthing(8,28)). +legacyConfig(cabinetTOthing(8,29)). +legacyConfig(cabinetTOthing(8,30)). +legacyConfig(personTOthing(1,11)). +legacyConfig(personTOthing(1,12)). +legacyConfig(personTOthing(1,13)). +legacyConfig(personTOthing(1,14)). +legacyConfig(personTOthing(1,15)). +legacyConfig(personTOthing(1,16)). +legacyConfig(personTOthing(1,17)). +legacyConfig(personTOthing(1,18)). +legacyConfig(personTOthing(1,19)). +legacyConfig(personTOthing(1,20)). +legacyConfig(personTOthing(1,21)). +legacyConfig(personTOthing(1,22)). +legacyConfig(personTOthing(1,23)). +legacyConfig(personTOthing(1,24)). +legacyConfig(personTOthing(1,25)). +legacyConfig(personTOthing(2,26)). +legacyConfig(personTOthing(2,27)). +legacyConfig(personTOthing(2,28)). +legacyConfig(personTOthing(2,29)). +legacyConfig(personTOthing(2,30)). +legacyConfig(personTOthing(2,31)). +legacyConfig(personTOthing(2,32)). +legacyConfig(personTOthing(2,33)). +legacyConfig(personTOthing(2,34)). +legacyConfig(personTOthing(2,35)). +legacyConfig(personTOthing(2,36)). +legacyConfig(personTOthing(2,37)). +legacyConfig(personTOthing(2,38)). +legacyConfig(personTOthing(2,39)). +legacyConfig(personTOthing(2,40)). +% domains +cabinetDomainNew(500..523). +roomDomainNew(1000..1027). +cabinetUpper(30). +roomUpper(30). +cabinetLower(6). +roomLower(2). +% reuse costs +reuseCabinetTOthingCost(0). +reuseRoomTOcabinetCost(0). +reusePersonTOroomCost(0). +reuseCabinetAsHighCost(3). +reuseCabinetAsSmallCost(0). +reuseRoomCost(0). +% remove costs +removeCabinetTOthingCost(2). +removeRoomTOcabinetCost(2). +removePersonTOroomCost(2). +removeCabinetCost(2). +removeRoomCost(2). +% create costs +cabinetHighCost(100). +cabinetSmallCost(1). +roomCost(5). diff --git a/src/test/resources/DomainHeuristics/House/instances_alpha/longthings_newroom_p02t024c3.edb b/src/test/resources/DomainHeuristics/House/instances_alpha/longthings_newroom_p02t024c3.edb new file mode 100644 index 000000000..202729056 --- /dev/null +++ b/src/test/resources/DomainHeuristics/House/instances_alpha/longthings_newroom_p02t024c3.edb @@ -0,0 +1,136 @@ +legacyConfig(person(1)). +legacyConfig(person(2)). +legacyConfig(room(3)). +legacyConfig(roomTOcabinet(3,5)). +legacyConfig(roomTOcabinet(3,6)). +legacyConfig(roomTOcabinet(3,7)). +legacyConfig(room(4)). +legacyConfig(roomTOcabinet(4,8)). +legacyConfig(roomTOcabinet(4,9)). +legacyConfig(roomTOcabinet(4,10)). +legacyConfig(thing(11)). +thingShort(11). +legacyConfig(thing(12)). +thingShort(12). +legacyConfig(thing(13)). +thingShort(13). +legacyConfig(thing(14)). +thingLong(14). +legacyConfig(thing(15)). +thingLong(15). +legacyConfig(thing(16)). +thingShort(16). +legacyConfig(thing(17)). +thingShort(17). +legacyConfig(thing(18)). +thingLong(18). +legacyConfig(thing(19)). +thingLong(19). +legacyConfig(thing(20)). +thingShort(20). +legacyConfig(thing(21)). +thingLong(21). +legacyConfig(thing(22)). +thingLong(22). +legacyConfig(thing(23)). +thingShort(23). +legacyConfig(thing(24)). +thingShort(24). +legacyConfig(thing(25)). +thingShort(25). +legacyConfig(thing(26)). +thingLong(26). +legacyConfig(thing(27)). +thingLong(27). +legacyConfig(thing(28)). +thingShort(28). +legacyConfig(thing(29)). +thingShort(29). +legacyConfig(thing(30)). +thingLong(30). +legacyConfig(thing(31)). +thingLong(31). +legacyConfig(thing(32)). +thingShort(32). +legacyConfig(thing(33)). +thingLong(33). +legacyConfig(thing(34)). +thingLong(34). +legacyConfig(cabinet(9)). +legacyConfig(cabinetTOthing(9,28)). +legacyConfig(cabinetTOthing(9,29)). +legacyConfig(cabinetTOthing(9,30)). +legacyConfig(cabinetTOthing(9,31)). +legacyConfig(cabinet(10)). +legacyConfig(cabinetTOthing(10,32)). +legacyConfig(cabinetTOthing(10,33)). +legacyConfig(cabinetTOthing(10,34)). +legacyConfig(cabinet(5)). +legacyConfig(cabinetTOthing(5,11)). +legacyConfig(cabinetTOthing(5,12)). +legacyConfig(cabinetTOthing(5,13)). +legacyConfig(cabinetTOthing(5,14)). +legacyConfig(cabinetTOthing(5,15)). +legacyConfig(cabinet(6)). +legacyConfig(cabinetTOthing(6,16)). +legacyConfig(cabinetTOthing(6,17)). +legacyConfig(cabinetTOthing(6,18)). +legacyConfig(cabinetTOthing(6,19)). +legacyConfig(cabinet(7)). +legacyConfig(cabinetTOthing(7,20)). +legacyConfig(cabinetTOthing(7,21)). +legacyConfig(cabinetTOthing(7,22)). +legacyConfig(cabinet(8)). +legacyConfig(cabinetTOthing(8,23)). +legacyConfig(cabinetTOthing(8,24)). +legacyConfig(cabinetTOthing(8,25)). +legacyConfig(cabinetTOthing(8,26)). +legacyConfig(cabinetTOthing(8,27)). +legacyConfig(personTOthing(1,11)). +legacyConfig(personTOthing(1,12)). +legacyConfig(personTOthing(1,13)). +legacyConfig(personTOthing(1,14)). +legacyConfig(personTOthing(1,15)). +legacyConfig(personTOthing(1,16)). +legacyConfig(personTOthing(1,17)). +legacyConfig(personTOthing(1,18)). +legacyConfig(personTOthing(1,19)). +legacyConfig(personTOthing(1,20)). +legacyConfig(personTOthing(1,21)). +legacyConfig(personTOthing(1,22)). +legacyConfig(personTOthing(2,23)). +legacyConfig(personTOthing(2,24)). +legacyConfig(personTOthing(2,25)). +legacyConfig(personTOthing(2,26)). +legacyConfig(personTOthing(2,27)). +legacyConfig(personTOthing(2,28)). +legacyConfig(personTOthing(2,29)). +legacyConfig(personTOthing(2,30)). +legacyConfig(personTOthing(2,31)). +legacyConfig(personTOthing(2,32)). +legacyConfig(personTOthing(2,33)). +legacyConfig(personTOthing(2,34)). +% domains +cabinetDomainNew(500..517). +roomDomainNew(1000..1021). +cabinetUpper(24). +roomUpper(24). +cabinetLower(5). +roomLower(2). +% reuse costs +reuseCabinetTOthingCost(0). +reuseRoomTOcabinetCost(0). +reusePersonTOroomCost(0). +reuseCabinetAsHighCost(3). +reuseCabinetAsSmallCost(0). +reuseRoomCost(0). +% remove costs +removeCabinetTOthingCost(2). +removeRoomTOcabinetCost(2). +removePersonTOroomCost(2). +removeCabinetCost(2). +removeRoomCost(2). +% create costs +cabinetHighCost(100). +cabinetSmallCost(1). +roomCost(5). diff --git a/src/test/resources/DomainHeuristics/House/instances_alpha/switchthingsize_r02t035.edb b/src/test/resources/DomainHeuristics/House/instances_alpha/switchthingsize_r02t035.edb new file mode 100644 index 000000000..36bb3bced --- /dev/null +++ b/src/test/resources/DomainHeuristics/House/instances_alpha/switchthingsize_r02t035.edb @@ -0,0 +1,181 @@ +legacyConfig(person(1)). +legacyConfig(room(2)). +legacyConfig(roomTOcabinet(2,4)). +legacyConfig(roomTOcabinet(2,10)). +legacyConfig(roomTOcabinet(2,16)). +legacyConfig(roomTOcabinet(2,22)). +legacyConfig(room(3)). +legacyConfig(roomTOcabinet(3,28)). +legacyConfig(roomTOcabinet(3,34)). +legacyConfig(roomTOcabinet(3,40)). +legacyConfig(thing(9)). +thingShort(9). +legacyConfig(thing(11)). +thingShort(11). +legacyConfig(thing(12)). +thingShort(12). +legacyConfig(thing(13)). +thingShort(13). +legacyConfig(thing(14)). +thingShort(14). +legacyConfig(thing(15)). +thingShort(15). +legacyConfig(thing(17)). +thingShort(17). +legacyConfig(thing(18)). +thingShort(18). +legacyConfig(thing(19)). +thingShort(19). +legacyConfig(thing(20)). +thingShort(20). +legacyConfig(thing(21)). +thingShort(21). +legacyConfig(thing(23)). +thingLong(23). +legacyConfig(thing(24)). +thingShort(24). +legacyConfig(thing(25)). +thingShort(25). +legacyConfig(thing(26)). +thingShort(26). +legacyConfig(thing(27)). +thingShort(27). +legacyConfig(thing(29)). +thingShort(29). +legacyConfig(thing(30)). +thingShort(30). +legacyConfig(thing(31)). +thingShort(31). +legacyConfig(thing(32)). +thingShort(32). +legacyConfig(thing(33)). +thingShort(33). +legacyConfig(thing(35)). +thingShort(35). +legacyConfig(thing(36)). +thingShort(36). +legacyConfig(thing(37)). +thingShort(37). +legacyConfig(thing(38)). +thingShort(38). +legacyConfig(thing(39)). +thingShort(39). +legacyConfig(thing(41)). +thingShort(41). +legacyConfig(thing(42)). +thingShort(42). +legacyConfig(thing(43)). +thingShort(43). +legacyConfig(thing(44)). +thingShort(44). +legacyConfig(thing(45)). +thingShort(45). +legacyConfig(thing(5)). +thingShort(5). +legacyConfig(thing(6)). +thingShort(6). +legacyConfig(thing(7)). +thingShort(7). +legacyConfig(thing(8)). +thingShort(8). +legacyConfig(cabinet(10)). +legacyConfig(cabinetTOthing(10,11)). +legacyConfig(cabinetTOthing(10,12)). +legacyConfig(cabinetTOthing(10,13)). +legacyConfig(cabinetTOthing(10,14)). +legacyConfig(cabinetTOthing(10,15)). +legacyConfig(cabinet(16)). +legacyConfig(cabinetTOthing(16,17)). +legacyConfig(cabinetTOthing(16,18)). +legacyConfig(cabinetTOthing(16,19)). +legacyConfig(cabinetTOthing(16,20)). +legacyConfig(cabinetTOthing(16,21)). +legacyConfig(cabinet(22)). +legacyConfig(cabinetTOthing(22,23)). +legacyConfig(cabinetTOthing(22,24)). +legacyConfig(cabinetTOthing(22,25)). +legacyConfig(cabinetTOthing(22,26)). +legacyConfig(cabinetTOthing(22,27)). +legacyConfig(cabinet(28)). +legacyConfig(cabinetTOthing(28,29)). +legacyConfig(cabinetTOthing(28,30)). +legacyConfig(cabinetTOthing(28,31)). +legacyConfig(cabinetTOthing(28,32)). +legacyConfig(cabinetTOthing(28,33)). +legacyConfig(cabinet(34)). +legacyConfig(cabinetTOthing(34,35)). +legacyConfig(cabinetTOthing(34,36)). +legacyConfig(cabinetTOthing(34,37)). +legacyConfig(cabinetTOthing(34,38)). +legacyConfig(cabinetTOthing(34,39)). +legacyConfig(cabinet(40)). +legacyConfig(cabinetTOthing(40,41)). +legacyConfig(cabinetTOthing(40,42)). +legacyConfig(cabinetTOthing(40,43)). +legacyConfig(cabinetTOthing(40,44)). +legacyConfig(cabinetTOthing(40,45)). +legacyConfig(cabinet(4)). +legacyConfig(cabinetTOthing(4,5)). +legacyConfig(cabinetTOthing(4,6)). +legacyConfig(cabinetTOthing(4,7)). +legacyConfig(cabinetTOthing(4,8)). +legacyConfig(cabinetTOthing(4,9)). +legacyConfig(personTOthing(1,5)). +legacyConfig(personTOthing(1,6)). +legacyConfig(personTOthing(1,7)). +legacyConfig(personTOthing(1,8)). +legacyConfig(personTOthing(1,9)). +legacyConfig(personTOthing(1,11)). +legacyConfig(personTOthing(1,12)). +legacyConfig(personTOthing(1,13)). +legacyConfig(personTOthing(1,14)). +legacyConfig(personTOthing(1,15)). +legacyConfig(personTOthing(1,17)). +legacyConfig(personTOthing(1,18)). +legacyConfig(personTOthing(1,19)). +legacyConfig(personTOthing(1,20)). +legacyConfig(personTOthing(1,21)). +legacyConfig(personTOthing(1,23)). +legacyConfig(personTOthing(1,24)). +legacyConfig(personTOthing(1,25)). +legacyConfig(personTOthing(1,26)). +legacyConfig(personTOthing(1,27)). +legacyConfig(personTOthing(1,29)). +legacyConfig(personTOthing(1,30)). +legacyConfig(personTOthing(1,31)). +legacyConfig(personTOthing(1,32)). +legacyConfig(personTOthing(1,33)). +legacyConfig(personTOthing(1,35)). +legacyConfig(personTOthing(1,36)). +legacyConfig(personTOthing(1,37)). +legacyConfig(personTOthing(1,38)). +legacyConfig(personTOthing(1,39)). +legacyConfig(personTOthing(1,41)). +legacyConfig(personTOthing(1,42)). +legacyConfig(personTOthing(1,43)). +legacyConfig(personTOthing(1,44)). +legacyConfig(personTOthing(1,45)). +% domains +cabinetDomainNew(500..527). +roomDomainNew(1000..1032). +cabinetUpper(35). +roomUpper(35). +cabinetLower(7). +roomLower(2). +% reuse costs +reuseCabinetTOthingCost(0). +reuseRoomTOcabinetCost(0). +reusePersonTOroomCost(0). +reuseCabinetAsHighCost(3). +reuseCabinetAsSmallCost(0). +reuseRoomCost(0). +% remove costs +removeCabinetTOthingCost(2). +removeRoomTOcabinetCost(2). +removePersonTOroomCost(2). +removeCabinetCost(2). +removeRoomCost(2). +% create costs +cabinetHighCost(10). +cabinetSmallCost(5). +roomCost(5). diff --git a/src/test/resources/DomainHeuristics/PartnerUnits/instances/generated/simple003_bf_startZ1.asp b/src/test/resources/DomainHeuristics/PartnerUnits/instances/generated/simple003_bf_startZ1.asp new file mode 100644 index 000000000..1b77bf995 --- /dev/null +++ b/src/test/resources/DomainHeuristics/PartnerUnits/instances/generated/simple003_bf_startZ1.asp @@ -0,0 +1,23 @@ +maxPU(2). + +comUnit(1). +comUnit(2). +comUnit(3). + +zone2sensor(1,1). +zone2sensor(1,2). +zone2sensor(2,1). +zone2sensor(2,3). +zone2sensor(2,4). +zone2sensor(3,3). + + +% breadth-first ordering: +maxLayer(4). +sensorLayer(1,1). +sensorLayer(2,1). +sensorLayer(3,3). +sensorLayer(4,3). +zoneLayer(1,0). +zoneLayer(2,2). +zoneLayer(3,4). diff --git a/src/test/resources/DomainHeuristics/PartnerUnits/instances/generated/simple010_bf_startZ1.asp b/src/test/resources/DomainHeuristics/PartnerUnits/instances/generated/simple010_bf_startZ1.asp new file mode 100644 index 000000000..9c5b876ec --- /dev/null +++ b/src/test/resources/DomainHeuristics/PartnerUnits/instances/generated/simple010_bf_startZ1.asp @@ -0,0 +1,72 @@ +maxPU(2). + +comUnit(1). +comUnit(2). +comUnit(3). +comUnit(4). +comUnit(5). +comUnit(6). +comUnit(7). +comUnit(8). +comUnit(9). +comUnit(10). + +zone2sensor(1,1). +zone2sensor(1,2). +zone2sensor(2,1). +zone2sensor(2,3). +zone2sensor(2,4). +zone2sensor(3,3). +zone2sensor(3,5). +zone2sensor(3,6). +zone2sensor(4,5). +zone2sensor(4,7). +zone2sensor(4,8). +zone2sensor(5,7). +zone2sensor(5,9). +zone2sensor(5,10). +zone2sensor(6,9). +zone2sensor(6,11). +zone2sensor(6,12). +zone2sensor(7,11). +zone2sensor(7,13). +zone2sensor(7,14). +zone2sensor(8,13). +zone2sensor(8,15). +zone2sensor(8,16). +zone2sensor(9,15). +zone2sensor(9,17). +zone2sensor(9,18). +zone2sensor(10,17). + + +% breadth-first ordering: +maxLayer(18). +sensorLayer(1,1). +sensorLayer(2,1). +sensorLayer(3,3). +sensorLayer(4,3). +sensorLayer(5,5). +sensorLayer(6,5). +sensorLayer(7,7). +sensorLayer(8,7). +sensorLayer(9,9). +sensorLayer(10,9). +sensorLayer(11,11). +sensorLayer(12,11). +sensorLayer(13,13). +sensorLayer(14,13). +sensorLayer(15,15). +sensorLayer(16,15). +sensorLayer(17,17). +sensorLayer(18,17). +zoneLayer(1,0). +zoneLayer(2,2). +zoneLayer(3,4). +zoneLayer(4,6). +zoneLayer(5,8). +zoneLayer(6,10). +zoneLayer(7,12). +zoneLayer(8,14). +zoneLayer(9,16). +zoneLayer(10,18). diff --git a/src/test/resources/DomainHeuristics/PartnerUnits/instances/generated/simple020_bf_startZ1.asp b/src/test/resources/DomainHeuristics/PartnerUnits/instances/generated/simple020_bf_startZ1.asp new file mode 100644 index 000000000..53c392cc5 --- /dev/null +++ b/src/test/resources/DomainHeuristics/PartnerUnits/instances/generated/simple020_bf_startZ1.asp @@ -0,0 +1,142 @@ +maxPU(2). + +comUnit(1). +comUnit(2). +comUnit(3). +comUnit(4). +comUnit(5). +comUnit(6). +comUnit(7). +comUnit(8). +comUnit(9). +comUnit(10). +comUnit(11). +comUnit(12). +comUnit(13). +comUnit(14). +comUnit(15). +comUnit(16). +comUnit(17). +comUnit(18). +comUnit(19). +comUnit(20). + +zone2sensor(1,1). +zone2sensor(1,2). +zone2sensor(2,1). +zone2sensor(2,3). +zone2sensor(2,4). +zone2sensor(3,3). +zone2sensor(3,5). +zone2sensor(3,6). +zone2sensor(4,5). +zone2sensor(4,7). +zone2sensor(4,8). +zone2sensor(5,7). +zone2sensor(5,9). +zone2sensor(5,10). +zone2sensor(6,9). +zone2sensor(6,11). +zone2sensor(6,12). +zone2sensor(7,11). +zone2sensor(7,13). +zone2sensor(7,14). +zone2sensor(8,13). +zone2sensor(8,15). +zone2sensor(8,16). +zone2sensor(9,15). +zone2sensor(9,17). +zone2sensor(9,18). +zone2sensor(10,17). +zone2sensor(10,19). +zone2sensor(10,20). +zone2sensor(11,19). +zone2sensor(11,21). +zone2sensor(11,22). +zone2sensor(12,21). +zone2sensor(12,23). +zone2sensor(12,24). +zone2sensor(13,23). +zone2sensor(13,25). +zone2sensor(13,26). +zone2sensor(14,25). +zone2sensor(14,27). +zone2sensor(14,28). +zone2sensor(15,27). +zone2sensor(15,29). +zone2sensor(15,30). +zone2sensor(16,29). +zone2sensor(16,31). +zone2sensor(16,32). +zone2sensor(17,31). +zone2sensor(17,33). +zone2sensor(17,34). +zone2sensor(18,33). +zone2sensor(18,35). +zone2sensor(18,36). +zone2sensor(19,35). +zone2sensor(19,37). +zone2sensor(19,38). +zone2sensor(20,37). + + +% breadth-first ordering: +maxLayer(38). +sensorLayer(1,1). +sensorLayer(2,1). +sensorLayer(3,3). +sensorLayer(4,3). +sensorLayer(5,5). +sensorLayer(6,5). +sensorLayer(7,7). +sensorLayer(8,7). +sensorLayer(9,9). +sensorLayer(10,9). +sensorLayer(11,11). +sensorLayer(12,11). +sensorLayer(13,13). +sensorLayer(14,13). +sensorLayer(15,15). +sensorLayer(16,15). +sensorLayer(17,17). +sensorLayer(18,17). +sensorLayer(19,19). +sensorLayer(20,19). +sensorLayer(21,21). +sensorLayer(22,21). +sensorLayer(23,23). +sensorLayer(24,23). +sensorLayer(25,25). +sensorLayer(26,25). +sensorLayer(27,27). +sensorLayer(28,27). +sensorLayer(29,29). +sensorLayer(30,29). +sensorLayer(31,31). +sensorLayer(32,31). +sensorLayer(33,33). +sensorLayer(34,33). +sensorLayer(35,35). +sensorLayer(36,35). +sensorLayer(37,37). +sensorLayer(38,37). +zoneLayer(1,0). +zoneLayer(2,2). +zoneLayer(3,4). +zoneLayer(4,6). +zoneLayer(5,8). +zoneLayer(6,10). +zoneLayer(7,12). +zoneLayer(8,14). +zoneLayer(9,16). +zoneLayer(10,18). +zoneLayer(11,20). +zoneLayer(12,22). +zoneLayer(13,24). +zoneLayer(14,26). +zoneLayer(15,28). +zoneLayer(16,30). +zoneLayer(17,32). +zoneLayer(18,34). +zoneLayer(19,36). +zoneLayer(20,38). diff --git a/src/test/resources/DomainHeuristics/PartnerUnits/instances/generated/simple030_bf_startZ1.asp b/src/test/resources/DomainHeuristics/PartnerUnits/instances/generated/simple030_bf_startZ1.asp new file mode 100644 index 000000000..d94b82094 --- /dev/null +++ b/src/test/resources/DomainHeuristics/PartnerUnits/instances/generated/simple030_bf_startZ1.asp @@ -0,0 +1,212 @@ +maxPU(2). + +comUnit(1). +comUnit(2). +comUnit(3). +comUnit(4). +comUnit(5). +comUnit(6). +comUnit(7). +comUnit(8). +comUnit(9). +comUnit(10). +comUnit(11). +comUnit(12). +comUnit(13). +comUnit(14). +comUnit(15). +comUnit(16). +comUnit(17). +comUnit(18). +comUnit(19). +comUnit(20). +comUnit(21). +comUnit(22). +comUnit(23). +comUnit(24). +comUnit(25). +comUnit(26). +comUnit(27). +comUnit(28). +comUnit(29). +comUnit(30). + +zone2sensor(1,1). +zone2sensor(1,2). +zone2sensor(2,1). +zone2sensor(2,3). +zone2sensor(2,4). +zone2sensor(3,3). +zone2sensor(3,5). +zone2sensor(3,6). +zone2sensor(4,5). +zone2sensor(4,7). +zone2sensor(4,8). +zone2sensor(5,7). +zone2sensor(5,9). +zone2sensor(5,10). +zone2sensor(6,9). +zone2sensor(6,11). +zone2sensor(6,12). +zone2sensor(7,11). +zone2sensor(7,13). +zone2sensor(7,14). +zone2sensor(8,13). +zone2sensor(8,15). +zone2sensor(8,16). +zone2sensor(9,15). +zone2sensor(9,17). +zone2sensor(9,18). +zone2sensor(10,17). +zone2sensor(10,19). +zone2sensor(10,20). +zone2sensor(11,19). +zone2sensor(11,21). +zone2sensor(11,22). +zone2sensor(12,21). +zone2sensor(12,23). +zone2sensor(12,24). +zone2sensor(13,23). +zone2sensor(13,25). +zone2sensor(13,26). +zone2sensor(14,25). +zone2sensor(14,27). +zone2sensor(14,28). +zone2sensor(15,27). +zone2sensor(15,29). +zone2sensor(15,30). +zone2sensor(16,29). +zone2sensor(16,31). +zone2sensor(16,32). +zone2sensor(17,31). +zone2sensor(17,33). +zone2sensor(17,34). +zone2sensor(18,33). +zone2sensor(18,35). +zone2sensor(18,36). +zone2sensor(19,35). +zone2sensor(19,37). +zone2sensor(19,38). +zone2sensor(20,37). +zone2sensor(20,39). +zone2sensor(20,40). +zone2sensor(21,39). +zone2sensor(21,41). +zone2sensor(21,42). +zone2sensor(22,41). +zone2sensor(22,43). +zone2sensor(22,44). +zone2sensor(23,43). +zone2sensor(23,45). +zone2sensor(23,46). +zone2sensor(24,45). +zone2sensor(24,47). +zone2sensor(24,48). +zone2sensor(25,47). +zone2sensor(25,49). +zone2sensor(25,50). +zone2sensor(26,49). +zone2sensor(26,51). +zone2sensor(26,52). +zone2sensor(27,51). +zone2sensor(27,53). +zone2sensor(27,54). +zone2sensor(28,53). +zone2sensor(28,55). +zone2sensor(28,56). +zone2sensor(29,55). +zone2sensor(29,57). +zone2sensor(29,58). +zone2sensor(30,57). + + +% breadth-first ordering: +maxLayer(58). +sensorLayer(1,1). +sensorLayer(2,1). +sensorLayer(3,3). +sensorLayer(4,3). +sensorLayer(5,5). +sensorLayer(6,5). +sensorLayer(7,7). +sensorLayer(8,7). +sensorLayer(9,9). +sensorLayer(10,9). +sensorLayer(11,11). +sensorLayer(12,11). +sensorLayer(13,13). +sensorLayer(14,13). +sensorLayer(15,15). +sensorLayer(16,15). +sensorLayer(17,17). +sensorLayer(18,17). +sensorLayer(19,19). +sensorLayer(20,19). +sensorLayer(21,21). +sensorLayer(22,21). +sensorLayer(23,23). +sensorLayer(24,23). +sensorLayer(25,25). +sensorLayer(26,25). +sensorLayer(27,27). +sensorLayer(28,27). +sensorLayer(29,29). +sensorLayer(30,29). +sensorLayer(31,31). +sensorLayer(32,31). +sensorLayer(33,33). +sensorLayer(34,33). +sensorLayer(35,35). +sensorLayer(36,35). +sensorLayer(37,37). +sensorLayer(38,37). +sensorLayer(39,39). +sensorLayer(40,39). +sensorLayer(41,41). +sensorLayer(42,41). +sensorLayer(43,43). +sensorLayer(44,43). +sensorLayer(45,45). +sensorLayer(46,45). +sensorLayer(47,47). +sensorLayer(48,47). +sensorLayer(49,49). +sensorLayer(50,49). +sensorLayer(51,51). +sensorLayer(52,51). +sensorLayer(53,53). +sensorLayer(54,53). +sensorLayer(55,55). +sensorLayer(56,55). +sensorLayer(57,57). +sensorLayer(58,57). +zoneLayer(1,0). +zoneLayer(2,2). +zoneLayer(3,4). +zoneLayer(4,6). +zoneLayer(5,8). +zoneLayer(6,10). +zoneLayer(7,12). +zoneLayer(8,14). +zoneLayer(9,16). +zoneLayer(10,18). +zoneLayer(11,20). +zoneLayer(12,22). +zoneLayer(13,24). +zoneLayer(14,26). +zoneLayer(15,28). +zoneLayer(16,30). +zoneLayer(17,32). +zoneLayer(18,34). +zoneLayer(19,36). +zoneLayer(20,38). +zoneLayer(21,40). +zoneLayer(22,42). +zoneLayer(23,44). +zoneLayer(24,46). +zoneLayer(25,48). +zoneLayer(26,50). +zoneLayer(27,52). +zoneLayer(28,54). +zoneLayer(29,56). +zoneLayer(30,58). diff --git a/src/test/resources/DomainHeuristics/PartnerUnits/pup.alpha_heu_20210205.asp b/src/test/resources/DomainHeuristics/PartnerUnits/pup.alpha_heu_20210205.asp new file mode 100644 index 000000000..d6bcaa67f --- /dev/null +++ b/src/test/resources/DomainHeuristics/PartnerUnits/pup.alpha_heu_20210205.asp @@ -0,0 +1,56 @@ +% QP*-like heuristic that processes zones and sensors by layers, avoids assigning units that are already full and zones/sensors that are already assigned, and tries existing units in decreasing order first and then a fresh unit. +% Revised version of pup.alpha_heu_20210108.asp in which some things are simplified + +elem(z,Z) :- zone2sensor(Z,D). +elem(s,D) :- zone2sensor(Z,D). + +{ assign(U,T,X) } :- elem(T,X), comUnit(U). + +#heuristic assign(U,T,X) : comUnit(U), elem(T,X), maxLayer(ML), layer(T,X,L), not full(U,T), not T assigned(T,X), not T used(U), nUnits(NU), U=1, Level=ML-L. [ NU@Level ] % start with 1st unit +#heuristic assign(U,T,X) : comUnit(U), elem(T,X), maxLayer(ML), layer(T,X,L), not full(U,T), not T assigned(T,X), T used(U), Level=ML-L. [ U@Level ] % try preceding units in decreasing order +#heuristic assign(U,T,X) : comUnit(U), elem(T,X), maxLayer(ML), layer(T,X,L), not full(U,T), not T assigned(T,X), not T used(U), comUnit(Um1), T used(Um1), F assign(Um1,T,X), Um1=U-1, Level=ML-L. [ U@Level ] % use the next fresh unit after all preceding units have been tried +#heuristic F assign(U,T,X) : comUnit(U), elem(T,X), not assign(U,T,X), full(U,T), maxLayer(ML). [ 1@ML ] % do not use full units +#heuristic F assign(U,T,X) : comUnit(U), elem(T,X), not assign(U,T,X). [1@-1] % close remaining choices + +:- assign(U,T,X1), assign(U,T,X2), assign(U,T,X3), X1