UnityAI.Core.Fuzzy.ContinuousFuzzyRuleVariable.GetOrAddHedgedSet C# (CSharp) Method

GetOrAddHedgedSet() private method

Get the Hedged Set or Add it
private GetOrAddHedgedSet ( string setName, string hedges ) : FuzzySet
setName string
hedges string
return FuzzySet
        internal virtual FuzzySet GetOrAddHedgedSet(string setName, string hedges)
        {
            string hedgeName = setName + " " + hedges;

            // The base set must, of course, exist!
            if (!SetExist(setName))
            {
                Console.Out.WriteLine("Error: Unknown Set " + msName + " " + setName);
            }

            // If the hedged set already exists, simply return it.
            if (SetExist(hedgeName))
            {
                return GetSet(hedgeName);
            }

            // The hedged set does not exist; create it.
            // Attempt to create a clone of the specified set.
            ((FuzzySet)(moSetList[setName])).AddClone(hedgeName);

            // Clone was created and added to the set list;
            // Now apply the hedges to the clone.
            ((FuzzySet)(moSetList[hedgeName])).ApplyHedges(hedges);

            // Now return the newly created hedged set.
            return GetSet(hedgeName);
        }

Usage Example

Example #1
0
        /// <summary>
        /// Get the FuzzySet based on the hedges
        /// </summary>
        /// <param name="lhs">Left Hand Side</param>
        /// <param name="setName">The Set Name that contains the Right Hand Side</param>
        /// <param name="hedges">The Hedge Name that contains the list of hedges</param>
        /// <returns></returns>
        private FuzzySet GetFuzzySet(ContinuousFuzzyRuleVariable lhs, string setName, string hedges)
        {
            FuzzySet rhs = null;
            string sValue = setName.Trim();
            string tmpHedges = hedges.Trim();

            // The value on the Rhs represents a fuzzy set name;
            // The named set must exist.
            if (lhs.SetExist(sValue))
            {
                if (tmpHedges.Length == 0)
                {
                    rhs = lhs.GetSet(sValue);
                }
                else
                {
                    rhs = lhs.GetOrAddHedgedSet(sValue, tmpHedges);
                }
            }
            else
            {
                Console.Out.WriteLine("Error: Invalid fuzzy set name " + sValue);
            }
            return rhs;
        }