コード例 #1
0
ファイル: Implication.cs プロジェクト: ilkerhalil/NxBRE
 /// <summary>
 /// Instantiates a new Implication.
 /// </summary>
 /// <param name="label">The label of the new implication.</param>
 /// <param name="priority">The priority  of the new implication.</param>
 /// <param name="mutex">String.Empty or the label of an implication mutexed by the new one.</param>
 /// <param name="precondition">String.Empty or the label of an implication that preconditions the new one.</param>
 /// <param name="deduction">The Atom used as a prototype for what this Implication tries to proove.</param>
 /// <param name="atomGroup">The top level group of atoms used in the query part (pattern matching) of the new Implication.</param>
 /// <param name="action">The implication action.</param>
 /// <see cref="NxBRE.InferenceEngine.Rules.ImplicationAction"/>
 /// <see cref="NxBRE.InferenceEngine.Rules.ImplicationPriority"/>
 public Implication(string label,
                    ImplicationPriority priority,
                    string mutex,
                    string precondition,
                    Atom deduction,
                    AtomGroup atomGroup,
                    ImplicationAction action) : this(label,
                                                     (int)priority,
                                                     mutex,
                                                     precondition,
                                                     deduction,
                                                     atomGroup,
                                                     action)
 {
 }
コード例 #2
0
ファイル: Implication.cs プロジェクト: ilkerhalil/NxBRE
        /// <summary>
        /// Instantiates a new Implication.
        /// </summary>
        /// <param name="label">The label of the new implication.</param>
        /// <param name="priority">The priority  of the new implication.</param>
        /// <param name="mutex">String.Empty or the label of an implication mutexed by the new one.</param>
        /// <param name="precondition">String.Empty or the label of an implication that preconditions the new one.</param>
        /// <param name="deduction">The Atom used as a prototype for what this Implication tries to proove.</param>
        /// <param name="atomGroup">The top level group of atoms used in the query part (pattern matching) of the new Implication.</param>
        /// <param name="action">The implication action.</param>
        /// <see cref="NxBRE.InferenceEngine.Rules.ImplicationAction"/>
        /// <see cref="NxBRE.InferenceEngine.Rules.ImplicationPriority"/>
        public Implication(string label,
                           int priority,
                           string mutex,
                           string precondition,
                           Atom deduction,
                           AtomGroup atomGroup,
                           ImplicationAction action) : base(label, atomGroup)
        {
            if (deduction.HasFunction)
            {
                throw new BREException("Can not create Implication with functions in the Deduction: " + deduction.ToString());
            }

            if ((mutex != null) && (mutex == label))
            {
                throw new BREException("An Implication can not Mutex itself: " + mutex);
            }

            if ((precondition != null) && (precondition == label))
            {
                throw new BREException("An Implication can not Pre-Condition itself: " + precondition);
            }

            /* Commented out to solve bug #1469851 : this test was not necessary anymore as the engine can now handle typed data in implications
             * foreach(object member in AtomGroup.Members)
             *      if ((member is Atom) && (((Atom)member).HasNotStringIndividual))
             *              throw new BREException("Can not create Implication with non-String individuals in the atoms: " + member.ToString());
             */

            if ((priority < (int)ImplicationPriority.Minimum) || (priority > (int)ImplicationPriority.Maximum))
            {
                throw new ArgumentOutOfRangeException("Priority must be in the [" +
                                                      ImplicationPriority.Minimum +
                                                      "-" +
                                                      ImplicationPriority.Maximum +
                                                      "] range.");
            }
            if (action == ImplicationAction.Count)
            {
                if (deduction.IsFact)
                {
                    throw new BREException("A counting Implication must have one Variable predicate in its deduction atom.");
                }
                var varCount = 0;
                foreach (var member in deduction.Members)
                {
                    if (member is Variable)
                    {
                        varCount++;
                    }
                    if (varCount > 1)
                    {
                        throw new BREException("A counting Implication must have only one Variable predicate in its deduction atom.");
                    }
                }
            }

            this.priority     = priority;
            this.deduction    = deduction;
            this.mutex        = mutex;
            this.precondition = precondition;
            this.action       = action;

            hasNaf = false;
            foreach (var atom in AtomGroup.AllAtoms.Where(atom => atom.Negative))
            {
                hasNaf = true;
                break;
            }
        }
コード例 #3
0
ファイル: Implication.cs プロジェクト: Ghasan/NxBRE
        /// <summary>
        /// Instantiates a new Implication.
        /// </summary>
        /// <param name="label">The label of the new implication.</param>
        /// <param name="priority">The priority  of the new implication.</param>
        /// <param name="mutex">String.Empty or the label of an implication mutexed by the new one.</param>
        /// <param name="precondition">String.Empty or the label of an implication that preconditions the new one.</param>
        /// <param name="deduction">The Atom used as a prototype for what this Implication tries to proove.</param>
        /// <param name="atomGroup">The top level group of atoms used in the query part (pattern matching) of the new Implication.</param>
        /// <param name="action">The implication action.</param>
        /// <see cref="NxBRE.InferenceEngine.Rules.ImplicationAction"/>
        /// <see cref="NxBRE.InferenceEngine.Rules.ImplicationPriority"/>
        public Implication(string label,
            int priority,
            string mutex,
            string precondition,
            Atom deduction,
            AtomGroup atomGroup,
            ImplicationAction action)
            : base(label, atomGroup)
        {
            if (deduction.HasFunction)
                throw new BREException("Can not create Implication with functions in the Deduction: " + deduction.ToString());

            if ((mutex != null) && (mutex == label))
                throw new BREException("An Implication can not Mutex itself: " + mutex);

            if ((precondition != null) && (precondition == label))
                throw new BREException("An Implication can not Pre-Condition itself: " + precondition);

            /* Commented out to solve bug #1469851 : this test was not necessary anymore as the engine can now handle typed data in implications
            foreach(object member in AtomGroup.Members)
                if ((member is Atom) && (((Atom)member).HasNotStringIndividual))
                    throw new BREException("Can not create Implication with non-String individuals in the atoms: " + member.ToString());
            */

            if ((priority < (int)ImplicationPriority.Minimum) || (priority > (int)ImplicationPriority.Maximum))
                throw new ArgumentOutOfRangeException("Priority must be in the [" +
                                                      ImplicationPriority.Minimum +
                                                      "-" +
                                                      ImplicationPriority.Maximum +
                                                      "] range.");
            if (action == ImplicationAction.Count) {
                if (deduction.IsFact) throw new BREException("A counting Implication must have one Variable predicate in its deduction atom.");
                int varCount = 0;
                foreach(IPredicate member in deduction.Members) {
                    if (member is Variable) varCount++;
                    if (varCount > 1) throw new BREException("A counting Implication must have only one Variable predicate in its deduction atom.");
                }
            }

            this.priority = priority;
            this.deduction = deduction;
            this.mutex = mutex;
            this.precondition = precondition;
            this.action = action;

            hasNaf = false;
            foreach(Atom atom in AtomGroup.AllAtoms) {
                if (atom.Negative) {
                    hasNaf = true;
                    break;
                }
            }
        }
コード例 #4
0
ファイル: Implication.cs プロジェクト: Ghasan/NxBRE
        /// <summary>
        /// Instantiates a new Implication.
        /// </summary>
        /// <param name="label">The label of the new implication.</param>
        /// <param name="priority">The priority  of the new implication.</param>
        /// <param name="mutex">String.Empty or the label of an implication mutexed by the new one.</param>
        /// <param name="precondition">String.Empty or the label of an implication that preconditions the new one.</param>
        /// <param name="deduction">The Atom used as a prototype for what this Implication tries to proove.</param>
        /// <param name="atomGroup">The top level group of atoms used in the query part (pattern matching) of the new Implication.</param>
        /// <param name="action">The implication action.</param>
        /// <see cref="NxBRE.InferenceEngine.Rules.ImplicationAction"/>
        /// <see cref="NxBRE.InferenceEngine.Rules.ImplicationPriority"/>
        public Implication(string label,
            ImplicationPriority priority,
            string mutex,
            string precondition,
            Atom deduction,
            AtomGroup atomGroup,
            ImplicationAction action)
            : this(label,
																											(int)priority,
																											mutex,
																											precondition,
																											deduction,
																											atomGroup,
																											action)
        {
        }
コード例 #5
0
ファイル: Implication.cs プロジェクト: killbug2004/WSProf
		/// <summary>
		/// Instantiates a new Implication.
		/// </summary>
		/// <param name="label">The label of the new implication.</param>
		/// <param name="priority">The priority  of the new implication.</param>
		/// <param name="mutex">String.Empty or the label of an implication mutexed by the new one.</param>
		/// <param name="precondition">String.Empty or the label of an implication that preconditions the new one.</param>
		/// <param name="deduction">The Atom used as a prototype for what this Implication tries to proove.</param>
		/// <param name="atomGroup">The top level group of atoms used in the query part (pattern matching) of the new Implication.</param>
		/// <param name="action">The implication action.</param>
		/// <see cref="org.nxbre.ie.rule.ImplicationAction"/>
		/// <see cref="org.nxbre.ie.rule.ImplicationPriority"/>
		public Implication(string label,
		                   int priority,
		                   string mutex,
		                   string precondition,
		                   Atom deduction,
		                   AtomGroup atomGroup,
		                   ImplicationAction action):base(label, atomGroup)
		{
			if (deduction.HasFunction)
				throw new BREException("Can not create Implication with functions in the Deduction: " + deduction.ToString());
		
			if ((mutex != null) && (mutex == label))
				throw new BREException("An Implication can not Mutex itself: " + mutex);
		
			if ((precondition != null) && (precondition == label))
				throw new BREException("An Implication can not Pre-Condition itself: " + precondition);
		
			foreach(object member in AtomGroup.Members)
				if ((member is Atom) && (((Atom)member).HasNotStringIndividual))
					throw new BREException("Can not create Implication with non-String individuals in the atoms: " + member.ToString());
			
			if ((priority < (int)ImplicationPriority.Minimum) || (priority > (int)ImplicationPriority.Maximum))
				throw new ArgumentOutOfRangeException("Priority must be in the [" +
				                                      ImplicationPriority.Minimum +
				                                      "-" +
				                                      ImplicationPriority.Maximum +
				                                      "] range.");
			if (action == ImplicationAction.Count) {
				if (deduction.IsFact) throw new BREException("A counting Implication must have one Variable predicate in its deduction atom.");
				int varCount = 0;
				foreach(IPredicate member in deduction.Members) {
					if (member is Variable) varCount++;
					if (varCount > 1) throw new BREException("A counting Implication must have only one Variable predicate in its deduction atom.");
				}
			}

			this.priority = priority;
			this.deduction = deduction;
			this.mutex = mutex;
			this.precondition = precondition;
			this.action = action;
		}