/// <summary> /// Visits the given input data node. /// </summary> /// <param name="data">Input data node.</param> public override void Visit(AxiomRule data) { Location = "Axiom rules"; if (!ProblemContext.Variables[data.GetAffectedVariable()].IsAxiomatic()) { throw GetException($"Axiom rule cannot affect a non-axiomatic variable {data.PrimitiveEffect.Variable}."); } }
/// <summary> /// Loads a SAS+ axioms section. /// </summary> private void LoadAxiomRules() { int axiomRulesCount = ParseAndCheckNumber(GetNextLine()); for (int i = 0; i < axiomRulesCount; ++i) { CheckExpected(GetNextLine(), "begin_rule"); AxiomRule axiomRule = new AxiomRule(); int conditionsCount = ParseAndCheckNumber(GetNextLine()); for (int j = 0; j < conditionsCount; ++j) { var numberPair = ParseAndCheckNumberPair(GetNextLine()); axiomRule.Conditions.Add(new Assignment(numberPair.Item1, numberPair.Item2)); } var ruleHeadList = ParseAndCheckNumberList(GetNextLine()); if (ruleHeadList.Count != 3) { throw GetException($"Head of axiom rule '{string.Join(" ", ruleHeadList)}' is not in a correct form."); } int ruleVariable = ruleHeadList[0]; int rulePreconditionValue = ruleHeadList[1]; int ruleNewValue = ruleHeadList[2]; if (rulePreconditionValue != -1) { // convert the rule precondition value into the rule conditions axiomRule.Conditions.Add(new Assignment(ruleVariable, rulePreconditionValue)); } axiomRule.PrimitiveEffect = new Assignment(ruleVariable, ruleNewValue); Problem.AxiomRules.Add(axiomRule); CheckExpected(GetNextLine(), "end_rule"); } }
public virtual void Visit(AxiomRule data) { }