void OnTriggerEnter(Collider other) { ExpertSystem es = GameObject.Find("Car(Clone)").GetComponent <ExpertSystem>(); if (other.name == "Prutik1") { var pr1 = GameObject.Find("Prutik1"); var heading = this.transform.position - pr1.transform.position; float Count1 = heading.sqrMagnitude; es.l_s = Count1; //int x = this.transform.position.x; //int y = this.transform.position.y; //int z = this.transform.position.z; //int px = pr1.transform.position.x; //int py = pr1.transform.position.y; //int pz = pr1.transform.position.z; } if (other.name == "Prutik2") { var pr2 = GameObject.Find("Prutik2"); var heading = this.transform.position - pr2.transform.position; float Count2 = heading.sqrMagnitude; es.middle_s = Count2; } if (other.name == "Prutik3") { var pr3 = GameObject.Find("Prutik1"); var heading = this.transform.position - pr3.transform.position; float Count3 = heading.sqrMagnitude; es.r_s = Count3; } }
private void ExpertMenuItem_Click(object sender, EventArgs e) { PharmacyExpertFactory expertFactory = new PharmacyExpertFactory(); ExpertSystem <Drug, Symptom> expert = expertFactory.GetExpert(); new ExpertViewForm(expert).ShowDialog(); }
private ExpertSystem LoadES(string fileName) { try { // TODO: общий код с Forms - сделать отдельный loader // TODO: кэш string findedFileName = EsFilesHelper.FindFullName(fileName); if (string.IsNullOrEmpty(findedFileName)) { throw new FileNotFoundException("Файл экспертной системы не найден"); } ExpertSystem result = null; BinaryFormatter bf = new BinaryFormatter(); using (FileStream fs = File.OpenRead(findedFileName)) { result = (ExpertSystem)bf.Deserialize(fs); } return(result); } catch (Exception ex) { throw new Exception("Ошибка при загрузке файла ЭС", ex); } }
public ExpertViewForm(ExpertSystem <Drug, Symptom> expert) { InitializeComponent(); _expert = expert ?? throw new ArgumentNullException(nameof(expert)); _symptoms = _expert.GetSigns().Select(x => new SymptomChecking { Symptom = x, Having = false }).ToArray(); }
public ConsultResultDto LoadAndStartConsult(StartEsArgs args) { // запуск консультации ExpertSystem es = LoadES(args.FileName); es.Goal = es.Vars[args.Goal]; Fact resFact = es.GoConsult(new VariableFromData(args.VarValues)); // объяснение var workedRules = es.WorkedRules.Where(r => r.Worked == RuleWork.Signifi).ToList(); ConsultResultDto result = new ConsultResultDto(resFact, workedRules); return(result); }
public List <VariableDto> GetQueriedVariables(string esName) { ExpertSystem es = LoadES(esName); List <VariableDto> result = new List <VariableDto>(); foreach (var varName in es.Vars) { if (es.Vars[varName].MyType == VarType.Queried || es.Vars[varName].MyType == VarType.DeductionQueried) { result.Add(new VariableDto(es.Vars[varName])); } } return(result); }
public IActionResult Post([FromBody] QuestionViewModel[] questionViewModel) { Question[] questions = new Question[questionViewModel.Length]; for (int i = 0; i < questionViewModel.Length; i++) { int[] answersTmp = new int[questionViewModel[i].answers.Length]; for (int j = 0; j < questionViewModel[i].answers.Length; j++) { answersTmp[j] = int.Parse(questionViewModel[i].answers[j]); } questions[i] = new Question { questionID = questionViewModel[i].questionID, answers = answersTmp }; } ExpertSystem.ProceedExpertSystem(questions); return(Ok(questions)); }
public Fact Запросить(Variable v, ExpertSystem es) { var data = varValues.FirstOrDefault(x => string.Equals(x.Variable, v.Name, StringComparison.InvariantCultureIgnoreCase)); Fact result = null; if (data == null) { throw new Exception($"Не удалось определить значение запрашиваемой переменной {v.Name}"); } else { string domainValue = v.Domain.ListVal.FirstOrDefault(x => string.Equals(x, data.Value, StringComparison.InvariantCultureIgnoreCase)); if (string.IsNullOrEmpty(domainValue)) { throw new Exception($"Значение переменной {v.Name} равное {data.Value} не принадлежит домену"); } result = new Fact(v, domainValue, Rightly.Yes); } return(result); }
private void Load_Click(object sender, EventArgs e) { es = ExpertSystem.LoadData(DataBaseName.Text); expressionsList.Text = es.ExpCalc.WriteExpressionsList().Replace("\n", "\r\n"); es.SaveData("dfdf"); }
// public static List<List<int>> listOLists = new List<List<int>>(); static void Main(string[] args) { /* const string path = "Headaches.xml"; XmlSerializer serializer = new XmlSerializer(typeof(ExpertSystem), "http://tempuri.org/XMLSchema.xsd"); StreamReader reader = new StreamReader(path); expert = (ExpertSystem)serializer.Deserialize(reader); reader.Close();*/ expert = new ExpertSystem(); expert.questions.Add(new Question(0, false, 1, 2, "")); expert.questions.Add(new Question(1, true, 0, 0, "wniosek")); expert.questions.Add(new Question(2, false, 3, 4, "")); expert.questions.Add(new Question(3, true, 0, 0, "wniosek")); expert.questions.Add(new Question(4, false, 5, 6, "")); expert.questions.Add(new Question(5, true, 0, 0, "wniosek")); expert.questions.Add(new Question(6, false, 7, 8, "")); expert.questions.Add(new Question(7, true, 0, 0, "wniosek")); expert.questions.Add(new Question(8, true, 0, 0, "wniosek")); listaList = new List<List<int>>(); int id = 0; Question q = null; q = expert.questions.Find(q1 => q1.Id == id); List<int> listaYes = new List<int>(); listaYes.Add(q.Id); //listaYes.Add(q.yes); // List<int> listaNo = new List<int>(); // listaNo.Add(q.Id); // listaNo.Add(q.no); // listaList.Add(listaYes); //listaList.Add(listaNo); // test(q, q.yes, listaList.FindIndex(x => x.Equals(listaYes))); // test(q, q.no, listaList.FindIndex(x => x.Equals(listaNo))); List<int> eeee = test(q, listaYes); /* for (int i = 0; i < eeee.Count; i++) { Console.WriteLine(eeee.ElementAt(i)); Console.WriteLine(); }*/ /* List<int> nowa = new List<int>(); listOLists.Add(nowa); test(nowa, 0); foreach (var lista in listOLists) { foreach (var id2 in lista) { Console.Write(id2 + ", "); } Console.WriteLine(); }*/ Console.ReadKey(); }