public void Fifth_B(Expression exp) { List <Event> possibleEvents = EventCalculator.CopyEventList(exp.PossibleEvents); List <Event> exactEvents = EventCalculator.CopyEventList(exp.ExactEvents); Event child = new Event(); foreach (Event e in exp.ExactEvents) { if (EventCalc.IfEventIsParent(e, possibleEvents[0])) { child = e; exactEvents = exactEvents.Where(t => t.ReturnName() != child.ReturnName()).ToList(); break; } } exp.ChildExpressions = new List <Expression>(); exp.ChildExpressions.Add(new Expression { PossibleEvents = possibleEvents, ExactEvents = exactEvents }); Expression second = new Expression(); second.PossibleEvents.Add(child); second.ExactEvents.Add(possibleEvents[0]); second.ExactEvents.AddRange(exactEvents); exp.ChildExpressions.Add(second); Expression third = new Expression(); third.PossibleEvents.Add(child); third.ExactEvents.AddRange(exactEvents); exp.ChildExpressions.Add(third); }
public void First(Expression exp) { if (exp.PossibleEvents.Count() == 0) { throw new Exception("Empty expression"); } exp.ChildExpressions = new List <Expression>(); List <Event> possibleEvents = EventCalculator.CopyEventList(exp.PossibleEvents); List <Event> exactEvents = EventCalculator.CopyEventList(exp.ExactEvents); List <Event> f_possibleEvents = possibleEvents.GetRange(0, 1); List <Event> f_exactEvents = new List <Event>(exactEvents); exp.ChildExpressions.Add(new Expression { PossibleEvents = f_possibleEvents, ExactEvents = f_exactEvents }); List <Event> s_possibleEvents = new List <Event>(possibleEvents); s_possibleEvents.RemoveAt(0); List <Event> s_exactEvents = new List <Event>(); s_exactEvents.Add(possibleEvents[0]); s_exactEvents.InsertRange(1, exactEvents); exp.ChildExpressions.Add(new Expression() { PossibleEvents = s_possibleEvents, ExactEvents = s_exactEvents }); }
public ExpertSystem() { CalculatedExpressions = new List <Expression>(); Events = new List <Event>(); EventCalc = new EventCalculator(this); ExpCalc = new ExpressionCalculator(this); }
internal static bool IfTwoListIsSimmilar(List <Event> first, List <Event> second) { int firstQuan = first.Count; int secondQuan = second.Count; if (firstQuan != secondQuan) { return(false); } List <Event> firstList = EventCalculator.CopyEventList(first).OrderBy(t => t.ReturnName()).ToList(); List <Event> secondList = EventCalculator.CopyEventList(second).OrderBy(t => t.ReturnName()).ToList(); for (int i = 0; i < firstQuan;) { for (int j = 0; j < secondQuan;) { if (firstList[i].ReturnName() == secondList[j].ReturnName()) { i += 1; j += 1; } else { return(false); } } } return(true); }
public void Fourth(Expression exp) { exp.ChildExpressions = new List <Expression>(); exp.ChildExpressions.Add(new Expression { Probability = 1 }); List <Event> s_possibleEvents = EventCalculator.CopyEventList(exp.PossibleEvents); s_possibleEvents[0].Sign = true; List <Event> s_exactEvents = EventCalculator.CopyEventList(exp.ExactEvents); exp.ChildExpressions.Add(new Expression { PossibleEvents = s_possibleEvents, ExactEvents = s_exactEvents }); }
public void Fifth_A(Expression exp) { List <Event> possibleEvents = EventCalculator.CopyEventList(exp.PossibleEvents); List <Event> exactEvents = EventCalculator.CopyEventList(exp.ExactEvents); exp.ChildExpressions = new List <Expression>(); exp.ChildExpressions.Add(new Expression() { PossibleEvents = possibleEvents }); exp.ChildExpressions.Add(new Expression() { PossibleEvents = exactEvents, ExactEvents = possibleEvents }); exp.ChildExpressions.Add(new Expression() { PossibleEvents = exactEvents }); }