public Variable(XElement xElement) { XAttribute name = xElement.Attribute("name"); Name = name != null ? name.Value : "No name"; XAttribute valueReference = xElement.Attribute("valueReference"); if (valueReference == null) { throw new ArgumentException("Value refence isn't allowed to be null or not set in the xml"); } ValueReference = uint.Parse(valueReference.Value); XAttribute description = xElement.Attribute("description"); Description = description != null ? description.Value : "No description"; XAttribute variability = xElement.Attribute("variability"); Variability = variability != null ? Enum.Parse <Variability>(variability.Value, true) : Variability.Unknown; XAttribute causality = xElement.Attribute("causality"); Causality = causality != null ? Enum.Parse <Causality>(causality.Value, true) : Causality.Unknown; VariableType = new VariableTypeImpl(xElement); }
public void CargarGrafo() { try { //using (StreamReader sr = new StreamReader("C:/datos.txt")) using (StreamReader sr = new StreamReader(AppDomain.CurrentDomain.BaseDirectory + "/datos_prueba.txt")) { //Causality.Visualizar(); string lines; var valores = new List <int[]>(); lines = sr.ReadLine(); var temp = lines.Split('\t'); Grafo g = new Grafo(); //Se Crean los Nodos for (int i = 0; i < temp.Length; i++) { Vertice a = new Vertice(temp[i]); g.AgregarVertice(a); } var causalMatrix = new int[g.ListaVertices.Count, g.ListaVertices.Count]; var rootCausePL = new Dictionary <string, double>(); //g.Pearson(causalMatrix, g.GrafoCount); Causality.ObtainCausality(); //Se obtiene la Lista de Prioridad de la Causa Raiz double temporal = 0.0; for (int i = 0; i < g.GrafoCount; i++) { for (int j = 0; j < g.GrafoCount; j++) { temporal += causalMatrix[i, j]; } rootCausePL.Add(g.ListaVertices[i].Nombre, temporal); } //Se valida el conocimiento del Proceso con los datos for (int i = 0; i < g.ListaVertices.Count; i++) { lines = sr.ReadLine(); if (lines == "") { break; } temp = lines.Split('\t'); for (int j = 0; j < temp.Length; j++) { for (int k = 0; k < g.ListaVertices.Count; k++) { if (temp[j] == g.ListaVertices[k].Nombre) { if (causalMatrix[i, k] != 0) { g.AgregarArco(g.ListaVertices[i].Nombre, temp[j], causalMatrix[i, k]); } } } } } //Se ponen los Limites Inferiores lines = sr.ReadLine(); temp = lines.Split('\t'); for (int j = 0; j < temp.Length; j++) { g.ListaVertices[j].LimInferior = int.Parse(temp[j]); } //Se ponen los Limites Superiores lines = sr.ReadLine(); temp = lines.Split('\t'); for (int j = 0; j < temp.Length; j++) { g.ListaVertices[j].LimSuperior = int.Parse(temp[j]); } g.MostrarVertices(); g.MostrarGrafo(); g.CrearTabla(); Console.WriteLine(); //g.Visualizar(); } } catch (Exception e) { //Console.WriteLine("No se pudo leer el archivo"); Console.WriteLine(e.Message); } }