Example #1
0
        /// <summary>
        /// 将相邻两项(邻键)添加到集合中
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="keyHead"></param>
        /// <param name="keyTail"></param>
        /// <param name="objMemoryBondColl"></param>
        public static void UpdateMemoryBondColl <T>(T keyHead, T keyTail, MemoryBondColl <T> objMemoryBondColl)
        {
            if (!objMemoryBondColl.Contains(keyHead))
            {
                MemoryBondMDL <T> bond = new MemoryBondMDL <T>();
                bond.KeyItem.Key = keyHead;
                bond.LinkColl.OffsetTotalCount = 0;
                bond.LinkColl.MinuteOffsetSize = objMemoryBondColl.MinuteOffsetSize;
                objMemoryBondColl.Add(bond);
            }

            MemoryBondMDL <T> objBondMDL = objMemoryBondColl[keyHead];


            MemoryItemMDL <T> mdl           = objBondMDL.KeyItem;
            double            dRemeberValue = MemoryDAL.CalcRemeberValue(objMemoryBondColl.OffsetTotalCount - mdl.UpdateOffsetCount, objMemoryBondColl.MinuteOffsetSize);

            mdl.TotalCount       += 1;                                       //累加总计数
            mdl.ValidDegree       = CalcValidDegree <T>(mdl, dRemeberValue); //计算成熟度
            mdl.ValidCount        = mdl.ValidCount * dRemeberValue + 1;      // 遗忘累频=记忆保留量+1
            mdl.UpdateOffsetCount = objMemoryBondColl.OffsetTotalCount;      //更新时的偏移量

            MemoryItemColl <T> objLinkColl = objBondMDL.LinkColl;

            objLinkColl.OffsetTotalCount = objMemoryBondColl.OffsetTotalCount;
            UpdateMemoryItemColl(keyTail, objLinkColl);


            objMemoryBondColl.OffsetTotalCount += 1;
        }
Example #2
0
        /// <summary>
        /// 计算邻键尾项记忆剩余量
        /// </summary>
        /// <typeparam name="T">泛型,具体类别由调用者传入</typeparam>
        /// <param name="keyHead">相邻两项的首项</param>
        /// <param name="keyTail">相邻两项的尾项</param>
        /// <param name="objMemoryBondColl">邻键集合</param>
        /// <returns>返回记忆剩余量</returns>
        public static double CalcRemeberValue <T>(T keyHead, T keyTail, MemoryBondColl <T> objMemoryBondColl)
        {
            if (!objMemoryBondColl.Contains(keyHead))
            {
                return(0);
            }
            MemoryBondMDL <T>  objBondMDL  = objMemoryBondColl[keyHead];
            MemoryItemColl <T> objLinkColl = objBondMDL.LinkColl;

            return(CalcRemeberValue <T>(keyTail, objLinkColl));
        }
Example #3
0
        /// <summary>
        /// 计算邻键首项记忆剩余量
        /// </summary>
        /// <typeparam name="T">泛型,具体类别由调用者传入</typeparam>
        /// <param name="key">相邻两项的首项</param>
        /// <param name="objMemoryBondColl">邻键集合</param>
        /// <returns>返回记忆剩余量</returns>
        public static double CalcRemeberValue <T>(T key, MemoryBondColl <T> objMemoryBondColl)
        {
            if (!objMemoryBondColl.Contains(key))
            {
                return(0);
            }
            MemoryBondMDL <T> objBondMDL    = objMemoryBondColl[key];
            MemoryItemMDL <T> mdl           = objBondMDL.KeyItem;
            double            dRemeberValue = MemoryDAL.CalcRemeberValue(objMemoryBondColl.OffsetTotalCount - mdl.UpdateOffsetCount, objMemoryBondColl.MinuteOffsetSize);

            return(mdl.ValidCount * dRemeberValue);
        }
Example #4
0
 protected override T GetKeyForItem(MemoryBondMDL <T> item)
 {
     return(item.KeyItem.Key);
 }