Esempio n. 1
0
        private void HandlePredicateDefine(PlanningParser.PredicateDefineContext context)
        {
            _exclusiveAxiom = CUDD.Constant(1);
            _predicateDict  = new Dictionary <string, Predicate>();
            foreach (var atomFormSkeleton in context.atomFormSkeleton())
            {
                PredicateEnumerator enumerator = new PredicateEnumerator(atomFormSkeleton, _predicateDict, _currentCuddIndex);
                Algorithms.IterativeScanMixedRadix(enumerator);
                _currentCuddIndex = enumerator.CurrentCuddIndex;

                if (atomFormSkeleton.oneofDefine() != null)
                {
                    Console.WriteLine("Predicate {0} have oneOf", atomFormSkeleton.predicate().GetText());
                    //Console.WriteLine("Hello!");
                    //Console.ReadLine();
                    string           predicateName         = atomFormSkeleton.predicate().GetText();
                    int              oneOfVarsCount        = atomFormSkeleton.oneofDefine().VAR().Count;
                    string[]         oneOfVarNameArray     = new string[oneOfVarsCount];
                    var              varNameList           = atomFormSkeleton.listVariable().GetVariableNameList();
                    var              collection            = atomFormSkeleton.listVariable().GetCollection();
                    IList <string>[] notOneOfVarCollection = new IList <string> [varNameList.Count - oneOfVarsCount];

                    Parallel.For(0, oneOfVarsCount,
                                 i => oneOfVarNameArray[i] = atomFormSkeleton.oneofDefine().VAR(i).GetText());

                    for (int i = 0, k = 0; i < varNameList.Count; i++)
                    {
                        bool exists = oneOfVarNameArray.Any(s => s == varNameList[i]);

                        if (!exists)
                        {
                            notOneOfVarCollection[k] = collection[i];
                            k++;
                            if (k == notOneOfVarCollection.Length)
                            {
                                break;
                            }
                        }
                    }

                    ExclusiveAxiomEnumerator exclusiveAxiomEnumerator = new ExclusiveAxiomEnumerator(predicateName,
                                                                                                     _predicateDict, notOneOfVarCollection);
                    Algorithms.IterativeScanMixedRadix(exclusiveAxiomEnumerator);
                    _exclusiveAxiom = CUDD.Function.And(_exclusiveAxiom, exclusiveAxiomEnumerator.ExclusiveAxiom);
                }
            }

            //foreach (var predicate in _predicateDict.Values)
            //{
            //    Console.WriteLine("name: {0}, Previous index: {1}, successive index: {2}", predicate.FullName, predicate.PreviousCuddIndex, predicate.SuccessiveCuddIndex);
            //}
        }
Esempio n. 2
0
        private void HandlePredicateDefine(PlanningParser.PredicateDefineContext context)
        {
            _predicateDict = new Dictionary <string, Predicate>();
            //_predicateExclusiveAxiom = new Dictionary<string, CUDDNode>();
            foreach (var atomFormSkeleton in context.atomFormSkeleton())
            {
                PredicateEnumerator enumerator = new PredicateEnumerator(atomFormSkeleton, _predicateDict, _currentCuddIndex);
                Algorithms.IterativeScanMixedRadix(enumerator);
                _currentCuddIndex = enumerator.CurrentCuddIndex;

                //string predicateName = atomFormSkeleton.predicate().GetText();

                //_predicateExclusiveAxiom.Add();
            }

            //foreach (var predicate in _predicateDict.Values)
            //{
            //    Console.WriteLine("name: {0}, Previous index: {1}, successive index: {2}", predicate.FullName, predicate.PreviousCuddIndex, predicate.SuccessiveCuddIndex);
            //}
            //Console.ReadLine();
        }