public ProcessInformationCollector()
 {
     Watcher = new ProcessWatcher();
     for (int i = 0; i < ProcessInfo.CriterionNames.Length; i++)
     {
         m_Speeds[i] = new VectorN(ProcessInfo.CriterionNames.Length - 1);
         m_SpeedsWithIgnored[i] = new VectorN(ProcessInfo.CriterionNames.Length - 1);
     }
 }
Пример #2
0
 public static VectorN operator *(VectorN v, double c)
 {
     VectorN result = new VectorN(v.Size);
     for (int i = 0; i < v.Size; i++)
     {
         result[i] = v[i] * c;
     }
     return result;
 }
Пример #3
0
 public static VectorN operator +(VectorN v1, VectorN v2)
 {
     if (v1.Size != v2.Size)
         throw new InvalidOperationException("Vector lengths must be equals");
     VectorN result = new VectorN(v1.Size);
     for (int i = 0; i < v1.Size; i++)
     {
         result[i] = v1[i] + v2[i];
     }
     return result;
 }
        private void ComputeMassCenters(Process[] currentProcesses)
        {
            m_Speeds = ComputeMassCenter();
            foreach (Process process in currentProcesses)
            {
                VectorN[] speedsWithout = ComputeMassCenter(process.Id);
                if (process.Id == Pid)
                    m_SpeedsWithIgnored = speedsWithout;

                VectorN result = new VectorN(m_Speeds.Length);
                for (int i = 0; i < m_Speeds.Length; i++)
                {
                    result[i] = ((m_Speeds[i] - speedsWithout[i]) / m_Speeds[i]).Length();
                }

                SpeedEntry se = GetSpeedEntry(process.Id);
                if (se == null)
                {
                    m_AllSpeeds.Add(new SpeedEntry(process.Id, result.Length(), process.ProcessName));
                }
                else
                {
                    se.Value = result.Length();
                }
            }
            m_AllSpeeds.Sort();
        }
        private VectorN[] ComputeMassCenter(int pid)
        {
            // Для каждого критерия считаем центр масс (вектор)
            // Текущий критерий - масса
            VectorN[] speeds = new VectorN[ProcessInfo.CriterionNames.Length];
            for (int i = 0; i < speeds.Length; i++)
            {
                speeds[i] = new VectorN(ProcessInfo.CriterionNames.Length - 1);
            }
            Watcher.StrangeProcesses.Clear();
            int critIndex = 0;
            foreach (string massCriteriaName in ProcessInfo.CriterionNames)
            {
                // Центр масс
                VectorN sumVector = new VectorN(ProcessInfo.CriterionNames.Length - 1);
                VectorN prevVector = null;
                if (pid == NoProcess)
                {
                    prevVector = Watcher.MassCenter;
                }
                else
                {
                    if (Watcher.MassCenters.ContainsKey(pid))
                    {
                        prevVector = Watcher.MassCenters[pid];
                    }
                }
                double massSumm = 0;
                foreach (ProcessInfo info in Watcher.Processes)
                {
                    if (info.Pid != pid)
                    {
                        // Calc E(m_i)
                        massSumm += info.Criterions[massCriteriaName].Last().Value;
                        // k - 1 других критериев
                        double mValue = info.Criterions[massCriteriaName].Last().Value;
                        int c = 0;
                        foreach (string criteriaName in ProcessInfo.CriterionNames)
                        {
                            if (criteriaName.Equals(massCriteriaName))
                                continue;

                            sumVector[c++] += info.Criterions[criteriaName].Last().Value * mValue;
                        }
                    }
                }
                sumVector = sumVector / massSumm;
                if (prevVector != null)
                {
                    VectorN speedVector = sumVector;// -prevVector;
                    speeds[critIndex] = speedVector;
                }
                if (pid == NoProcess)
                {
                    Watcher.MassCenter.CopyFrom(sumVector);
                }
                else
                {
                    if (Watcher.MassCenters.ContainsKey(pid))
                    {
                        Watcher.MassCenters[pid].CopyFrom(sumVector);
                    }
                    else
                    {
                        Watcher.MassCenters.Add(pid, sumVector);
                    }
                }
                critIndex++;
            }
            return speeds;
        }
Пример #6
0
 public void CopyFrom(VectorN original)
 {
     if (original.Size != this.Size)
     {
         m_size = original.Size;
         m_data = new double[original.Size];
     }
     for (int i = 0; i < original.Size; i++)
     {
         this[i] = original[i];
     }
 }