示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="observation"></param>
        /// <param name="conflicts"></param>
        /// <returns></returns>
        public static DiagnosisSet FindHittingSets(Observation observation, ConflictSet conflicts)
        {
            IHSAlgorithm s = new HSOneThread();

            //IHSAlgorithm s = new  HSMultiThreads();
            //IHSAlgorithm s = new HSMultiTasks();

            return(s.FindHittingSets(observation, conflicts));
        }
示例#2
0
        private static void RunAllTest(string fileModel, string fileObs)
        {
            fileModel = "SystemFiles/" + fileModel;
            fileObs   = "SystemFiles/" + fileObs;

            ModelObservationCreator cc = new ModelObservationCreator();
            List <Observation>      allObservetions = cc.ReadObsModelFiles(fileModel, fileObs);

            int index = 1;

            foreach (Observation observation in allObservetions)
            {
                if (index > 50)
                {
                    break;
                }
                Debug.WriteLine("****************************************************************** Obs number = " + index + "   CAL CONFLICATES");
                //Get Conflict Set
                LtmsAlgorithm       ltmsAlgorithm = new LtmsAlgorithm(observation.TheModel, observation);
                List <List <Gate> > gatelList     = ltmsAlgorithm.findConflicts();
                ConflictSet         conflictSet   = ltmsAlgorithm.ConvertGateListToConflict(gatelList);

                Debug.WriteLine("****************************************************************** Obs number = " + index + "   Number Of Conflicts=" + conflictSet.Conflicts.Count);
                index++;


                ConstraintSystemSolver.Reset();

                Stopwatch    sw            = Stopwatch.StartNew();
                HSOneThread  s1            = new HSOneThread();
                DiagnosisSet diagnosisSet1 = s1.FindHittingSets(observation, conflictSet);
                sw.Stop();
                HittingSetStatistics statistics = new HittingSetStatistics(observation.TheModel.Id, observation.Id, conflictSet.Conflicts.Count, sw.Elapsed.TotalMilliseconds, "HSOneThread", diagnosisSet1.Count);
                _hittingSetStatisticses.Add(statistics);

                ConstraintSystemSolver.Reset();

                sw = Stopwatch.StartNew();
                HSMultiTasks s2            = new HSMultiTasks();
                DiagnosisSet diagnosisSet2 = s2.FindHittingSets(observation, conflictSet);
                sw.Stop();
                statistics = new HittingSetStatistics(observation.TheModel.Id, observation.Id, conflictSet.Conflicts.Count, sw.Elapsed.TotalMilliseconds, "HSMultiTasks", diagnosisSet2.Count);
                _hittingSetStatisticses.Add(statistics);

                ConstraintSystemSolver.Reset();



                sw = Stopwatch.StartNew();
                HSMultiThreads s3            = new HSMultiThreads();
                DiagnosisSet   diagnosisSet3 = s3.FindHittingSets(observation, conflictSet);
                sw.Stop();
                statistics = new HittingSetStatistics(observation.TheModel.Id, observation.Id, conflictSet.Conflicts.Count, sw.Elapsed.TotalMilliseconds, "HSMultiThreads", diagnosisSet3.Count);
                _hittingSetStatisticses.Add(statistics);

                ConstraintSystemSolver.Reset();
            }

            Debug.WriteLine("ModelID, ObservationID, NumberOfConflicts, AlgorithmName, NumberOfDiagnoses, RunTime");

            foreach (HittingSetStatistics stat in _hittingSetStatisticses)
            {
                string prints = "";
                prints += stat.ModelID + " ,";
                prints += stat.ObservationID + " ,";
                prints += stat.NumberOfConflicts + " ,";
                prints += stat.AlgorithmName + " ,";
                prints += stat.NumberOfDiagnoses + " ,";
                prints += stat.RunTime;

                Debug.WriteLine(prints);
            }
        }