/// <summary>
        /// Visits the inner node of the SAS+ operator decision tree.
        /// </summary>
        /// <param name="treeNode">Inner node of the tree.</param>
        /// <param name="sourceConditions">Source conditions being evaluated.</param>
        /// <param name="currentSubConditions">Currently evaluated sub-conditions.</param>
        /// <returns>List of predecessors.</returns>
        public IEnumerable <IPredecessor> Visit(OperatorDecisionTreeInnerNode treeNode, IConditions sourceConditions, ISimpleConditions currentSubConditions)
        {
            int value;

            if (currentSubConditions.IsVariableConstrained(treeNode.DecisionVariable, out value))
            {
                // if constrained, collect the operators only in the corresponding subtree
                foreach (var predecessor in treeNode.OperatorsByDecisionVariableValue[value].Accept(this, sourceConditions, currentSubConditions))
                {
                    yield return(predecessor);
                }
            }
            else
            {
                // if not constrained, collect operators from all the subtrees
                foreach (var subTree in treeNode.OperatorsByDecisionVariableValue)
                {
                    foreach (var predecessor in subTree.Accept(this, sourceConditions, currentSubConditions))
                    {
                        yield return(predecessor);
                    }
                }
            }

            // always search in the subtree with the value-independent operators
            foreach (var successor in treeNode.OperatorsIndependentOnDecisionVariable.Accept(this, sourceConditions, currentSubConditions))
            {
                yield return(successor);
            }
        }
Пример #2
0
        /// <summary>
        /// Visits the inner node of the SAS+ operator decision tree.
        /// </summary>
        /// <param name="treeNode">Inner node of the tree.</param>
        /// <param name="state">Reference state.</param>
        /// <returns>List of successors.</returns>
        public IEnumerable <ISuccessor> Visit(OperatorDecisionTreeInnerNode treeNode, IState state)
        {
            foreach (var value in state.GetAllValues(treeNode.DecisionVariable))
            {
                foreach (var successor in treeNode.OperatorsByDecisionVariableValue[value].Accept(this, state))
                {
                    yield return(successor);
                }
            }

            foreach (var successor in treeNode.OperatorsIndependentOnDecisionVariable.Accept(this, state))
            {
                yield return(successor);
            }
        }