private void RunTest(uint matrixIndex, uint erIndex, uint hIndex, uint nhIndex) { Debug.Assert(matrixIndex < matrixFiles.Count()); MatrixPath m = new MatrixPath(); m.Path = matrixesPath + "\\" + matrixFiles[matrixIndex]; Dictionary<GenerationParameter, object> gp = new Dictionary<GenerationParameter, object>(); gp.Add(GenerationParameter.AdjacencyMatrix, m); AnalyzeOption opts = SessionManager.GetAvailableAnalyzeOptions(ResearchType.Basic, ModelType); opts &= ~AnalyzeOption.EigenValues; opts &= ~AnalyzeOption.EigenDistanceDistribution; opts &= ~AnalyzeOption.CycleDistribution; AbstractNetwork n = AbstractNetwork.CreateNetworkByType(ModelType, "", GenerationType.Static, new Dictionary<ResearchParameter,object>(), gp, opts); n.Generate(); n.Analyze(); RealizationResult rn = n.NetworkResult; ResearchResult er = null; if(erIndex < erFiles.Count()) er = erStorage.Load(erPath + "\\" + erFiles[erIndex]); Debug.Assert(hIndex < regularHierarchicFiles.Count()); ResearchResult hr = regularHierarchicStorage.Load(regularHierarchicPath + "\\" + regularHierarchicFiles[hIndex]); Debug.Assert(nhIndex < nonRegularHierarchicFiles.Count()); ResearchResult nhr = nonRegularHierarchicStorage.Load(nonRegularHierarchicPath + "\\" + nonRegularHierarchicFiles[nhIndex]); string s; foreach (AnalyzeOption o in rn.Result.Keys) { if (er != null) { s = Check(o, rn, er) ? "Passed" : "Failed"; optionsTable.Rows.Add(o.ToString(), er.ResearchName, s); optionsTable.FirstDisplayedScrollingRowIndex = optionsTable.RowCount - 1; Application.DoEvents(); } s = Check(o, rn, hr) ? "Passed" : "Failed"; optionsTable.Rows.Add(o.ToString(), hr.ResearchName, s); optionsTable.FirstDisplayedScrollingRowIndex = optionsTable.RowCount - 1; Application.DoEvents(); s = Check(o, rn, nhr) ? "Passed" : "Failed"; optionsTable.Rows.Add(o.ToString(), nhr.ResearchName, s); optionsTable.FirstDisplayedScrollingRowIndex = optionsTable.RowCount - 1; Application.DoEvents(); } }
public override void StartResearch() { ValidateResearchParameters(); StatusInfo = new ResearchStatusInfo(ResearchStatus.Running, 0); Logger.Write("Research ID - " + ResearchID.ToString() + ". Research - " + ResearchName + ". STARTED STRUCTURAL RESEARCH."); MatrixPath mp = ((MatrixPath)ResearchParameterValues[ResearchParameter.InputPath]); List<MatrixPath> matrixes = new List<MatrixPath>(); Debug.Assert((File.GetAttributes(mp.Path) & FileAttributes.Directory) == FileAttributes.Directory); Debug.Assert(Directory.GetFiles(mp.Path, "*.txt").Count() == 1); MatrixPath m = new MatrixPath(); m.Path = Directory.GetFiles(mp.Path, "*.txt")[0]; m.Size = mp.Size; matrixes.Add(m); MatrixInfoToRead mr = FileManager.Read(m.Path, m.Size); string storageString = Storage.StorageString; if (Storage.GetStorageType() != StorageType.SQLStorage) { storageString += ResearchName; if (!Directory.Exists(storageString)) Directory.CreateDirectory(storageString); } foreach (string fn in Directory.GetFiles(mp.Path, "*.sm")) { int[] s; FileManager.ReadSubgraphMatrix(fn, out s); MatrixInfoToWrite tmp = new MatrixInfoToWrite(); tmp.Matrix = CreateMatrixForSubgraph(mr.Matrix, s); // Create temporary .txt files for each matrix string tmpFileName = storageString + "\\" + Path.GetFileNameWithoutExtension(fn); FileManager.Write(tmp, tmpFileName); MatrixPath sm = new MatrixPath(); sm.Path = tmpFileName + ".txt"; matrixes.Add(sm); } ResearchType rt = ResearchType.Basic; // subresearch type is not supported and is always Basic subResearches = new List<AbstractResearch>(); foreach (MatrixPath p in matrixes) { AbstractResearch r = AbstractResearch.CreateResearchByType(rt); r.ResearchName = ResearchName + "_" + Path.GetFileNameWithoutExtension(p.Path); r.GenerationType = GenerationType.Static; r.ModelType = ModelType; Debug.Assert(r.GenerationParameterValues.ContainsKey(GenerationParameter.AdjacencyMatrix)); r.GenerationParameterValues[GenerationParameter.AdjacencyMatrix] = p; r.AnalyzeOption = AnalyzeOption; r.Storage = AbstractResultStorage.CreateStorage(Storage.GetStorageType(), storageString); r.OnUpdateResearchStatus += method; subResearches.Add(r); } if (subResearches.Count() != 0) { ++currentResearchIndex; subResearches[currentResearchIndex].StartResearch(); } }
private Object GetValueFromControl(Control c) { Debug.Assert(!(c is Label)); if (c is TextBox) return (c as TextBox).Text; else if (c is CheckBox) return (c as CheckBox).Checked; else if (c is ComboBox) return (c as ComboBox).Text; else if (c is FileInput) { FileInput fi = c as FileInput; MatrixPath mp = new MatrixPath(); mp.Path = fi.MatrixPath; mp.Size = fi.MatrixSize; return mp; } else { Debug.Assert(false); return null; } }
public override void StartResearch() { ValidateResearchParameters(); StatusInfo = new ResearchStatusInfo(ResearchStatus.Running, 0); Logger.Write("Research ID - " + ResearchID.ToString() + ". Research - " + ResearchName + ". STARTED COLLECTION RESEARCH."); MatrixPath mp = ((MatrixPath)ResearchParameterValues[ResearchParameter.InputPath]); List<MatrixPath> matrixes = new List<MatrixPath>(); Debug.Assert((File.GetAttributes(mp.Path) & FileAttributes.Directory) == FileAttributes.Directory); foreach (string fn in Directory.GetFiles(mp.Path, "*.txt")) { MatrixPath m = new MatrixPath(); m.Path = fn; m.Size = mp.Size; matrixes.Add(m); } ResearchType rt = ResearchType.Basic; // subresearch type is not supported and is always Basic subResearches = new List<AbstractResearch>(); foreach (MatrixPath m in matrixes) { AbstractResearch r = AbstractResearch.CreateResearchByType(rt); r.ResearchName = ResearchName + "_" + Path.GetFileNameWithoutExtension(m.Path); r.GenerationType = GenerationType.Static; r.ModelType = ModelType; Debug.Assert(r.GenerationParameterValues.ContainsKey(GenerationParameter.AdjacencyMatrix)); r.GenerationParameterValues[GenerationParameter.AdjacencyMatrix] = m; r.AnalyzeOption = AnalyzeOption; string storageString = Storage.StorageString; if (Storage.GetStorageType() != StorageType.SQLStorage) { storageString += ResearchName; if (!Directory.Exists(storageString)) Directory.CreateDirectory(storageString); } r.Storage = AbstractResultStorage.CreateStorage(Storage.GetStorageType(), storageString); r.OnUpdateResearchStatus += method; subResearches.Add(r); } if (subResearches.Count() != 0) { ++currentResearchIndex; subResearches[currentResearchIndex].StartResearch(); } }
private void LoadResearchParameters(ResearchResult r) { while (reader.Read()) { if (reader.Name == "ResearchParameter") { reader.MoveToAttribute("name"); ResearchParameter rp = (ResearchParameter)Enum.Parse(typeof(ResearchParameter), reader.ReadContentAsString()); reader.MoveToAttribute("value"); ResearchParameterInfo rpInfo = (ResearchParameterInfo)(rp.GetType().GetField(rp.ToString()).GetCustomAttributes(typeof(ResearchParameterInfo), false)[0]); if (rpInfo.Type.Equals(typeof(UInt32))) r.ResearchParameterValues.Add(rp, UInt32.Parse(reader.Value)); else if (rpInfo.Type.Equals(typeof(Double))) r.ResearchParameterValues.Add(rp, Double.Parse(reader.Value)); else if (rpInfo.Type.Equals(typeof(Boolean))) r.ResearchParameterValues.Add(rp, Boolean.Parse(reader.Value)); else if (rpInfo.Type.Equals(typeof(ResearchType))) r.ResearchParameterValues.Add(rp, reader.Value.ToString()); else if (rpInfo.Type.Equals(typeof(MatrixPath))) { MatrixPath mp = new MatrixPath(); mp.Path = reader.Value.ToString(); r.ResearchParameterValues.Add(rp, mp); } else { Debug.Assert(false); //throw new InvalidResearchParameters(); } } else if (reader.Name == "GenerationParameterValues") break; } }
private void LoadGenerationParameters(ResearchResult r) { while (reader.Read()) { if (reader.Name == "GenerationParameter") { reader.MoveToAttribute("name"); string g = reader.ReadContentAsString(); GenerationParameter gp; if (g == "FileName") gp = GenerationParameter.AdjacencyMatrix; else gp = (GenerationParameter)Enum.Parse(typeof(GenerationParameter), g); reader.MoveToAttribute("value"); GenerationParameterInfo gpInfo = (GenerationParameterInfo)(gp.GetType().GetField(gp.ToString()).GetCustomAttributes(typeof(GenerationParameterInfo), false)[0]); if (gpInfo.Type.Equals(typeof(UInt32))) r.GenerationParameterValues.Add(gp, UInt32.Parse(reader.Value)); else if (gpInfo.Type.Equals(typeof(Double))) r.GenerationParameterValues.Add(gp, Double.Parse(reader.Value)); else if (gpInfo.Type.Equals(typeof(Boolean))) r.GenerationParameterValues.Add(gp, Boolean.Parse(reader.Value)); else if (gpInfo.Type.Equals(typeof(MatrixPath))) { MatrixPath mp = new MatrixPath(); mp.Path = reader.Value.ToString(); r.GenerationParameterValues.Add(gp, mp); } else { Debug.Assert(false); //throw new InvalidGenerationParameters(); } } if (reader.Name == "Ensembles") break; } }