diff options
Diffstat (limited to 'subprojects/language-semantics/src/main')
-rw-r--r-- | subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/ModelInitializer.java | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/ModelInitializer.java b/subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/ModelInitializer.java index a86e2c47..02b2f920 100644 --- a/subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/ModelInitializer.java +++ b/subprojects/language-semantics/src/main/java/tools/refinery/language/semantics/ModelInitializer.java | |||
@@ -31,6 +31,7 @@ import tools.refinery.store.dse.transition.DesignSpaceExplorationBuilder; | |||
31 | import tools.refinery.store.dse.transition.Rule; | 31 | import tools.refinery.store.dse.transition.Rule; |
32 | import tools.refinery.store.dse.transition.RuleBuilder; | 32 | import tools.refinery.store.dse.transition.RuleBuilder; |
33 | import tools.refinery.store.dse.transition.actions.ActionLiteral; | 33 | import tools.refinery.store.dse.transition.actions.ActionLiteral; |
34 | import tools.refinery.store.dse.transition.actions.ActionLiterals; | ||
34 | import tools.refinery.store.model.ModelStoreBuilder; | 35 | import tools.refinery.store.model.ModelStoreBuilder; |
35 | import tools.refinery.store.reasoning.ReasoningAdapter; | 36 | import tools.refinery.store.reasoning.ReasoningAdapter; |
36 | import tools.refinery.store.reasoning.actions.PartialActionLiterals; | 37 | import tools.refinery.store.reasoning.actions.PartialActionLiterals; |
@@ -968,7 +969,7 @@ public class ModelInitializer { | |||
968 | } | 969 | } |
969 | } | 970 | } |
970 | for (var action : body.getActions()) { | 971 | for (var action : body.getActions()) { |
971 | actionLiterals.add(toActionLiteral(action, localScope)); | 972 | toActionLiterals(action, localScope, actionLiterals); |
972 | } | 973 | } |
973 | builder.action(actionLiterals); | 974 | builder.action(actionLiterals); |
974 | } catch (RuntimeException e) { | 975 | } catch (RuntimeException e) { |
@@ -976,8 +977,9 @@ public class ModelInitializer { | |||
976 | } | 977 | } |
977 | } | 978 | } |
978 | 979 | ||
979 | private ActionLiteral toActionLiteral( | 980 | private void toActionLiterals( |
980 | Action action, HashMap<tools.refinery.language.model.problem.Variable, NodeVariable> localScope) { | 981 | Action action, HashMap<tools.refinery.language.model.problem.Variable, NodeVariable> localScope, |
982 | List<ActionLiteral> actionLiterals) { | ||
981 | if (!(action instanceof AssertionAction assertionAction)) { | 983 | if (!(action instanceof AssertionAction assertionAction)) { |
982 | throw new TracedException(action, "Unknown action"); | 984 | throw new TracedException(action, "Unknown action"); |
983 | } | 985 | } |
@@ -991,11 +993,18 @@ public class ModelInitializer { | |||
991 | throw new TracedException(problemArgument, "Invalid argument"); | 993 | throw new TracedException(problemArgument, "Invalid argument"); |
992 | } | 994 | } |
993 | var variableOrNode = nodeAssertionArgument.getNode(); | 995 | var variableOrNode = nodeAssertionArgument.getNode(); |
994 | if (!(variableOrNode instanceof tools.refinery.language.model.problem.Variable problemVariable)) { | 996 | switch (variableOrNode) { |
995 | throw new TracedException(problemArgument, "Invalid argument"); | 997 | case tools.refinery.language.model.problem.Variable problemVariable -> |
998 | arguments[i] = localScope.get(problemVariable); | ||
999 | case Node node -> { | ||
1000 | int nodeId = getNodeId(node); | ||
1001 | var tempVariable = Variable.of(semanticsUtils.getNameWithoutRootPrefix(node).orElse("_" + nodeId)); | ||
1002 | actionLiterals.add(ActionLiterals.constant(tempVariable, nodeId)); | ||
1003 | arguments[i] = tempVariable; | ||
1004 | } | ||
1005 | default -> throw new TracedException(problemArgument, "Invalid argument"); | ||
996 | } | 1006 | } |
997 | arguments[i] = localScope.get(problemVariable); | ||
998 | } | 1007 | } |
999 | return PartialActionLiterals.merge(partialRelation, truthValue, arguments); | 1008 | actionLiterals.add(PartialActionLiterals.merge(partialRelation, truthValue, arguments)); |
1000 | } | 1009 | } |
1001 | } | 1010 | } |