コード例 #1
0
        public ICollection<Agent> TrainAll(IPID iPID, HistorySnapshot snapshot)
        {
            ICollection<Agent> readyAgents = new List<Agent>();
            foreach (LearningAgent learningAgent in m_LearningAgents)
            {
                if (learningAgent.IsNative(iPID))
                {
                    learningAgent.Train(snapshot, true);
                }
                else if (learningAgent.IsForeign(iPID))
                {
                    learningAgent.Train(snapshot, false);
                }
                else
                {
                    continue;
                }

                if (learningAgent.Ready)
                {
                    readyAgents.Add(learningAgent.TurnToAgent());
                }
            }
            return readyAgents;
        }
コード例 #2
0
ファイル: HistorySnapshot.cs プロジェクト: Evlikat/incinerate
 public static IEnumerable<HistorySnapshot> Divide(int snapshotLength, HistorySnapshot sourceSnapshot)
 {
     int parts = sourceSnapshot.Events.Count / snapshotLength;
     for (int i = 0; i < parts; i++)
     {
         yield return sourceSnapshot.Sub(i * snapshotLength, (i + 1) * snapshotLength);
     }
 }
コード例 #3
0
ファイル: LearningPair.cs プロジェクト: Evlikat/incinerate
 public LearningPair(HistorySnapshot snapshot, bool isExplorer)
 {
     input = new double[EventNameSpacePower];
     foreach (IProcessAction action in snapshot.Events)
     {
         EventName eventName = (EventName)Enum.Parse(typeof(EventName), action.EventName);
         input[(int)eventName]++;
     }
     output[isExplorer ? 0 : 1] = 1;
     output[isExplorer ? 1 : 0] = 0;
 }
コード例 #4
0
ファイル: AgentRegistry.cs プロジェクト: Evlikat/incinerate
        public ICollection<Agent> Handle(IPID iPID, IList<IProcessAction> actions)
        {
            HistorySnapshot snapshot = new HistorySnapshot(iPID, actions);

            IRecognizedAgent recognized = m_WatchingAgents.Compute(snapshot);
            if (recognized.Apply(iPID.PID))
            {
                m_History.SetDynamicName(iPID, recognized.Name, recognized.MaxRes);
            }

            IEnumerable<AgentReaction> reactions = m_GuardianAgents.Compute(snapshot);
            foreach (AgentReaction reaction in reactions)
            {
                reaction.Apply();
            }

            return m_LearningAgents.TrainAll(iPID, snapshot);
        }
コード例 #5
0
 public void Save(HistorySnapshot e, DateTime date)
 {
     if (e.PID.Name == null)
         return;
     FileStream fs = null;
     try
     {
         string fileName = String.Format(FileNameLayout, e.PID.ToString(), e.PID.Name, date);
         string filePath = Path.Combine(PathToSnapshotFolder, fileName);
         fs = File.Create(filePath);
         BinaryFormatter serializer = new BinaryFormatter();
         serializer.Serialize(fs, e);
     }
     catch
     {
         int i = 0;
     }
     finally
     {
         if (fs != null)
             fs.Close();
     }
 }
コード例 #6
0
 public IEnumerable<AgentReaction> Compute(HistorySnapshot snapshot)
 {
     lock (syncRoot)
     {
         foreach (KeyValuePair<Agent, GuardianAgentSession> agentSession in m_Agents)
         {
             if (!agentSession.Value.Check(snapshot.PID.PID))
             {
                 continue;
             }
             double res = agentSession.Key.Compute(snapshot);
             if (res >= agentSession.Value.E1)
             {
                 continue;
             }
             else if (res >= agentSession.Value.E2)
             {
                 yield return new AgentReaction(res, snapshot.PID.PID, agentSession.Value.YellowStrategy);
             }
             else
             {
                 yield return new AgentReaction(res, snapshot.PID.PID, agentSession.Value.RedStrategy);
             }
         }
     }
 }
コード例 #7
0
 public IRecognizedAgent Compute(HistorySnapshot snapshot)
 {
     double max = 0;
     IRecognizedAgent recognized = new NotRecognizedAgent();
     lock (syncRoot)
     {
         foreach (KeyValuePair<Agent, WatchingAgentSession> agentSession in m_Agents)
         {
             double res = agentSession.Key.Compute(snapshot);
             if (res > max - agentSession.Value.P1)
             {
                 max = res;
                 RecognizedAgent newRecognized = new RecognizedAgent(agentSession.Value.AgentName,
                     res,
                     agentSession.Value.RedStrategy,
                     agentSession.Value.YellowStrategy,
                     agentSession.Value.P1,
                     agentSession.Value.P2);
                 newRecognized.MaxRes = max;
                 recognized = newRecognized;
             }
         }
     }
     return recognized;
 }
コード例 #8
0
ファイル: Agent.cs プロジェクト: Evlikat/incinerate
 public void Train(HistorySnapshot snapshot, bool isTargetProcess)
 {
     m_Analyzer.RunTrain(snapshot, isTargetProcess);
 }
コード例 #9
0
ファイル: Agent.cs プロジェクト: Evlikat/incinerate
 public double Compute(HistorySnapshot snapshot)
 {
     IMultiNetworkComputationResult result = m_Analyzer.Compute(snapshot);
     return result.Result[0] - result.Result[1];
 }
コード例 #10
0
ファイル: HistorySnapshot.cs プロジェクト: Evlikat/incinerate
 public bool Duplicates(HistorySnapshot other)
 {
     IDictionary<String, int> thisCounter = this.Counter();
     IDictionary<String, int> otherCounter = other.Counter();
     return thisCounter.OrderBy(r => r.Key).SequenceEqual(otherCounter.OrderBy(r => r.Key));
 }
コード例 #11
0
ファイル: HistorySnapshot.cs プロジェクト: Evlikat/incinerate
 public HistorySnapshot Sub(int from, int to)
 {
     IList<IProcessAction> list = new List<IProcessAction>();
     for (int i = from; i < to; i++)
     {
         list.Add(Events[i]);
     }
     HistorySnapshot hs = new HistorySnapshot(PID, list);
     hs.ProcessName = this.ProcessName;
     return hs;
 }