public Probability(SerialProbability serial) { probability = serial.Probabilities; condition = serial.Conditions; List <Node> pNodes = new List <Node>(); foreach (string serialNode in serial.ProbNodes) { foreach (Node node in MDiagram.Nodes) { if (node.ID == serialNode) { pNodes.Add(node); } } } List <Node> cNodes = new List <Node>(); foreach (string serialNode in serial.CondNodes) { foreach (Node node in MDiagram.Nodes) { if (node.ID == serialNode) { cNodes.Add(node); } } } probNodes = pNodes.ToArray(); condNodes = cNodes.ToArray(); mValue = serial.Value; Calculator.AddProbability(this); }
public SerialProbability Serialize() { SerialProbability prob = new SerialProbability(); prob.Probabilities = Probabilities; prob.Conditions = Conditions; List <string> probNodes = new List <string>(); foreach (Node node in ProbNodes) { probNodes.Add(node.ID); } List <string> condNodes = new List <string>(); foreach (Node node in CondNodes) { condNodes.Add(node.ID); } prob.ProbNodes = probNodes.ToArray(); prob.CondNodes = condNodes.ToArray(); prob.Value = Value; return(prob); }