public void HS(string fileName1, string fileName2) { List <Observation> observationsList = MOCreator.ReadObsModelFiles(fileName1, fileName2); if (observationsList == null || observationsList.Count == 0) { return; } FlipFunction flip = new FlipFunction(); TimeSpan x = new TimeSpan(0, 5, 0); IterativeDeepening salgo = new IterativeDeepening(flip, x); ConesAlgorithm algo = new ConesAlgorithm(salgo); Stopwatch stopwtch = new Stopwatch(); CSVExport myExport = new CSVExport(); salgo.agenda = DiagnosesSearcher.Agenda.helthState; foreach (Observation obs in observationsList) { stopwtch.Start(); DiagnosisSet diagnoses = algo.FindDiagnoses(obs); stopwtch.Stop(); if (diagnoses != null) { myExport.AddRow(); myExport["System"] = obs.TheModel.Id; myExport["Observation"] = obs.Id; myExport["# diagnoses"] = diagnoses.Count; myExport["Runtime"] = stopwtch.Elapsed; } stopwtch.Reset(); } myExport.ExportToFile(observationsList.First().TheModel.Id + "HS.csv"); }
private void createNewDiagnoser() { FlipFunction flip = new FlipFunction(); TimeSpan x = new TimeSpan(0, 1, 0); IterativeDeepening salgo = new IterativeDeepening(flip, x); ConesAlgorithm algo = new ConesAlgorithm(salgo); this.Diagnoser = algo; }
public void CheckMinCard(string fileName1, string fileName2) { List <Observation> observationsList = MOCreator.ReadObsModelFiles(fileName1, fileName2); if (observationsList == null || observationsList.Count == 0) { return; } FlipFunction flip = new FlipFunction(); TimeSpan x = new TimeSpan(0, 5, 0); IterativeDeepening salgo = new IterativeDeepening(flip, x); ConesAlgorithm algo = new ConesAlgorithm(salgo); CSVExport myExport = new CSVExport(); foreach (Observation obs in observationsList) { algo.CheckMinCard(obs, myExport); } myExport.ExportToFile(observationsList.First().TheModel.Id + "MinCard.csv"); }
public void CalcProbabilityMass(string fileModel, string fileObs) { createNewDiagnoser(); ConesAlgorithm conesAlgo = (ConesAlgorithm)Diagnoser; List <Observation> observationsList = parser.ReadObsModelFiles(fileModel, fileObs); CSVExport myExport = new CSVExport(); SystemModel model = observationsList[0].TheModel; Dictionary <int, Gate> compDic = model.CreateCompDic(); string diagnosesFilesPath = "diagnoses/"; string tldiagnosesFilesPath = "tldiagnoses/"; model.createCones(); Dictionary <int, Cone> conesDic = new Dictionary <int, Cone>(); foreach (Cone c in model.Cones) { if (!conesDic.ContainsKey(c.Id)) { conesDic.Add(c.Id, c); } } foreach (Observation obs in observationsList) { string diagFileName = diagnosesFilesPath + model.Id + "_" + obs.Id + "_Diag.txt"; DiagnosisSet allDiagnoses = parser.ReadDiagnosisFile(diagFileName, compDic); string tldFileName = tldiagnosesFilesPath + model.Id + "_iscas85_" + obs.Id + ".tld"; //!!! txt? DiagnosisSet tlDiagnoses = parser.ReadTLDiagnosisFile(tldFileName, conesDic); DiagnosisSet minCardDiagnoses = conesAlgo.AbstractDiagGrounding(obs, tlDiagnoses); myExport.AddRow(); myExport["Observation"] = obs.Id; myExport["# all diagnoses"] = allDiagnoses.Count; myExport["all diagnoses probability"] = allDiagnoses.SetProbability; myExport["# min card diagnoses"] = minCardDiagnoses.Count; myExport["min card diagnoses probability"] = minCardDiagnoses.SetProbability; } myExport.ExportToFile(model.Id + "_probabilityMass.csv"); }