public static int pow(IOTEventType type) { return DSClass.pow((int)type); }
public static int Conv(IOTEventType type) { int t = (int)type; //.... if (t > (int)IOTModifyPacketEventType.NotModifyPacket) return t - (int)IOTModifyPacketEventType.NotModifyPacket; else if(t>(int)IOTDropPacketEventType.NotDropPacket) return t - (int)IOTDropPacketEventType.NotDropPacket; return -1; }
public static int GetOffsetByCategory(IOTEventCategoryType category, IOTEventType type) { switch (category) { case IOTEventCategoryType.DropPacket: return (int)type - (int)IOTDropPacketEventType.NotDropPacket; case IOTEventCategoryType.ModifyPacket: return (int)type - (int)IOTModifyPacketEventType.NotModifyPacket; case IOTEventCategoryType.MakePacket: return (int)type - (int)IOTMakePacketEventType.NotMakePacket; case IOTEventCategoryType.DropCommand: return (int)type - (int)IOTDropCommandEventType.NotDropCommand; case IOTEventCategoryType.ModifyCommand: return (int)type - (int)IOTModifyCommandEventType.NotModifyCommand; case IOTEventCategoryType.MakeCommand: return (int)type - (int)IOTMakeCommandEventType.NotMakeCommand; //TODO others default: return -1; } }
/* 使用一个惩罚奖励函数,如果指定类型的事件发生率大于阈值,则惩罚之,否则奖励 * 使用指数函数作为系数,返回奖励或惩罚系数,取值在[1/p, p] */ static double f(double rate, IOTEventType type) { double p = 2; if (!rateThrethods.ContainsKey(type)) return 1; double rateThrethod = rateThrethods[type]; return Math.Pow(p, (rateThrethod - rate)); }