public bool CheckConnected() { try { CustomLogger.Write("Research - " + ResearchName + ". CHECK CONNECTED STARTED for network - " + NetworkID.ToString()); bool result = false; Debug.Assert(networkGenerator.Container != null); networkAnalyzer.Container = networkGenerator.Container; Object ccd = networkAnalyzer.CalculateOption(AnalyzeOption.ConnectedComponentDistribution); Debug.Assert(ccd is SortedDictionary <Double, Double>); SortedDictionary <Double, Double> r = ccd as SortedDictionary <Double, Double>; result = r.ContainsKey(networkGenerator.Container.Size); if (!result) { UpdateStatus(NetworkStatus.StepCompleted); // for analyze } CustomLogger.Write("Research - " + ResearchName + ". CHECK COMPLETED FINISHED for network - " + NetworkID.ToString()); return(result); } catch (CoreException ex) { UpdateStatus(NetworkStatus.Failed); CustomLogger.Write("Research - " + ResearchName + "CHECK COMPLETED FAILED for network - " + NetworkID.ToString() + ". Exception message: " + ex.Message); return(false); } }
/// <summary> /// Saves the results of research analyze. /// </summary> protected void SaveResearch() { if (result.EnsembleResults.Count == 0 || result.EnsembleResults[0] == null) { StatusInfo = new ResearchStatusInfo(ResearchStatus.Failed, StatusInfo.CompletedStepsCount + 1); return; } result.ResearchID = ResearchID; result.ResearchName = ResearchName; result.ResearchType = GetResearchType(); result.ModelType = modelType; result.RealizationCount = realizationCount; result.Size = result.EnsembleResults[0].NetworkSize; result.Edges = result.EnsembleResults[0].EdgesCount; result.Date = DateTime.Now; result.ResearchParameterValues = ResearchParameterValues; result.GenerationParameterValues = GenerationParameterValues; Storage.Save(result); StatusInfo = new ResearchStatusInfo(ResearchStatus.Completed, StatusInfo.CompletedStepsCount + 1); CustomLogger.Write("Research - " + ResearchName + ". Result is SAVED"); result.Clear(); CustomLogger.Write("Research - " + ResearchName + ". Result is CLEARED."); }
protected override void ValidateResearchParameters() { if (!ResearchParameterValues.ContainsKey(ResearchParameter.InputPath) || ResearchParameterValues[ResearchParameter.InputPath] == null || ((MatrixPath)ResearchParameterValues[ResearchParameter.InputPath]).Path == "") { CustomLogger.Write("Research - " + ResearchName + ". Invalid research parameters."); throw new InvalidResearchParameters(); } MatrixPath mp = ((MatrixPath)ResearchParameterValues[ResearchParameter.InputPath]); if ((File.GetAttributes(mp.Path) & FileAttributes.Directory) != FileAttributes.Directory) { CustomLogger.Write("Research - " + ResearchName + ". Invalid research parameters." + " Directory should be specified."); throw new InvalidResearchParameters(); } if (Directory.GetFiles(mp.Path, "*.txt").Count() != 1) { CustomLogger.Write("Research - " + ResearchName + ". Invalid research parameters." + " Directory should contain only 1 .txt file."); throw new InvalidResearchParameters(); } base.ValidateResearchParameters(); }
protected override void ValidateResearchParameters() { if (!ResearchParameterValues.ContainsKey(ResearchParameter.ActivationStepCount) || !ResearchParameterValues.ContainsKey(ResearchParameter.ActivationSpeed) || !ResearchParameterValues.ContainsKey(ResearchParameter.DeactivationSpeed) || !ResearchParameterValues.ContainsKey(ResearchParameter.TracingStepIncrement) || !ResearchParameterValues.ContainsKey(ResearchParameter.InitialActivationProbability)) { CustomLogger.Write("Research - " + ResearchName + ". Invalid research parameters."); throw new InvalidResearchParameters(); } Int32 Time = Convert.ToInt32(ResearchParameterValues[ResearchParameter.ActivationStepCount]); Double Lambda = Double.Parse(ResearchParameterValues[ResearchParameter.ActivationSpeed].ToString(), CultureInfo.InvariantCulture); Double Mu = Double.Parse(ResearchParameterValues[ResearchParameter.DeactivationSpeed].ToString(), CultureInfo.InvariantCulture); Double IP = Double.Parse(ResearchParameterValues[ResearchParameter.InitialActivationProbability].ToString(), CultureInfo.InvariantCulture); if (Time <= 0 || Lambda < 0 || Mu < 0 || IP < 0 || IP > 1) { CustomLogger.Write("Research - " + ResearchName + ". Invalid research parameters."); throw new InvalidResearchParameters(); } base.ValidateResearchParameters(); }
/// <summary> /// Force stops the research. /// </summary> public virtual void StopResearch() { currentManager.Cancel(); StatusInfo = new ResearchStatusInfo(ResearchStatus.Stopped, StatusInfo.CompletedStepsCount); CustomLogger.Write("Research ID - " + ResearchID.ToString() + ". Research - " + ResearchName + ". STOPPED " + GetResearchType() + " RESEARCH."); }
/// <summary> /// Calculates specified analyze options values. /// </summary> public bool Analyze(bool visualMode = false) { if (networkAnalyzer.Container == null) { networkAnalyzer.Container = networkGenerator.Container; } try { CustomLogger.Write("Research - " + ResearchName + ". ANALYZE STARTED for network - " + NetworkID.ToString()); NetworkResult.NetworkSize = networkAnalyzer.Container.Size; NetworkResult.EdgesCount = networkAnalyzer.CalculateEdgesCount(); Array existingOptions = Enum.GetValues(typeof(AnalyzeOption)); foreach (AnalyzeOption opt in existingOptions) { if (opt != AnalyzeOption.None && (AnalyzeOptions & opt) == opt) { NetworkResult.Result.Add(opt, networkAnalyzer.CalculateOption(opt, visualMode)); if ((opt == AnalyzeOption.Algorithm_1_By_All_Nodes || opt == AnalyzeOption.Algorithm_2_By_Active_Nodes_List || opt == AnalyzeOption.Algorithm_Final) && visualMode) { ActivesInformation = networkAnalyzer.ActivesInformation; } if ((opt == AnalyzeOption.Cycles3Evolution) && visualMode) { EvolutionInformation = networkAnalyzer.EvolutionInformation; } UpdateStatus(NetworkStatus.StepCompleted); CustomLogger.Write("Research - " + ResearchName + ". CALCULATED analyze option: " + opt.ToString() + " for network - " + NetworkID.ToString()); } } SuccessfullyCompleted = true; CustomLogger.Write("Research - " + ResearchName + ". ANALYZE FINISHED for network - " + NetworkID.ToString()); } catch (SystemException ex) { UpdateStatus(NetworkStatus.Failed); CustomLogger.Write("Research - " + ResearchName + ". ANALYZE FAILED for network - " + NetworkID.ToString() + ". Exception message: " + ex.Message); return(false); } return(true); }
private void MainWindow_FormClosing(Object sender, FormClosingEventArgs e) { if (!CheckClosing()) { e.Cancel = true; } CustomLogger.Write("-------------------------------- xRandNet FINISHED --------------------------------"); }
public MainWindow() { RandNetSettings.InitializeLogging("randnet_" + DateTime.Now.AddHours(4).ToString("yyyy_MM_dd_HH_mm_ss")); CustomLogger.Write("-------------------------------- xRandNet STARTED --------------------------------"); InitializeComponent(); CheckForIllegalCrossThreadCalls = false; }
private void nonRegularHierarchicTestsToolStripMenuItem_Click(Object sender, EventArgs e) { CustomLogger.Write("-------------------------------- NON REGULAR HIERARCHIC TESTS STARTED --------------------------------"); RunTestsWindow w = new RunTestsWindow(); w.ModelType = ModelType.NonRegularHierarchic; w.ShowDialog(); CustomLogger.Write("-------------------------------- NON REGULAR HIERARCHIC TESTS FINISHED --------------------------------"); }
private void classicalTestsToolStripMenuItem_Click(Object sender, EventArgs e) { CustomLogger.Write("-------------------------------- CLASSICAL TESTS STARTED --------------------------------"); RunTestsWindow w = new RunTestsWindow(); w.ModelType = ModelType.ER; w.ShowDialog(); CustomLogger.Write("-------------------------------- CLASSICAL TESTS FINISHED --------------------------------"); }
private void ThreadEntry(Object p) { ThreadEntryData d = (ThreadEntryData)p; try { for (int i = 0; (d.ThreadIndex + i * d.ThreadCount) < networks.Length; ++i) { int networkToRun = d.ThreadIndex + i * d.ThreadCount; if (!networks[networkToRun].Generate(VisualMode)) { continue; } if (VisualMode) { GenerationSteps = networks[networkToRun].GenerationSteps; Branches = networks[networkToRun].Branches; } if (CheckConnected) { if (!networks[networkToRun].CheckConnected()) { continue; } } // Throws exception in Activation research if (!VisualMode && TracingPath != "") { if (!networks[networkToRun].Trace(TracingDirectory, TracingPath + "_" + networkToRun.ToString())) { continue; } } if (!networks[networkToRun].Analyze(VisualMode)) { continue; } if (VisualMode) { ActivesInformation = networks[networkToRun].ActivesInformation; EvolutionInformation = networks[networkToRun].EvolutionInformation; } Interlocked.Increment(ref realizationsDone); } } catch (SystemException ex) { CustomLogger.Write("Exception is thrown in LocalEnsembleManager. Exception message is: " + ex.Message); } finally { waitHandles[d.ThreadIndex].Set(); } }
protected override void ValidateResearchParameters() { if (!ResearchParameterValues.ContainsKey(ResearchParameter.ProbabilityDelta) || !ResearchParameterValues.ContainsKey(ResearchParameter.ProbabilityMax)) { CustomLogger.Write("Research - " + ResearchName + ". Invalid research parameters."); throw new InvalidResearchParameters(); } base.ValidateResearchParameters(); }
/// <summary> /// Generates random network from generation parameters. /// </summary> public bool Generate(bool visualMode = false) { try { CustomLogger.Write("Research - " + ResearchName + ". GENERATION STARTED for network - " + NetworkID.ToString()); if (GenerationType == GenerationType.Static) { Debug.Assert(GenerationParameterValues.ContainsKey(GenerationParameter.AdjacencyMatrix)); MatrixPath fp = (MatrixPath)GenerationParameterValues[GenerationParameter.AdjacencyMatrix]; Debug.Assert(fp.Path != null && fp.Path != ""); NetworkInfoToRead ni = FileManager.Read(fp.Path, fp.Size); networkGenerator.StaticGeneration(ni); CustomLogger.Write("Research - " + ResearchName + ". Static GENERATION FINISHED for network - " + NetworkID.ToString()); } else { Debug.Assert(!GenerationParameterValues.ContainsKey(GenerationParameter.AdjacencyMatrix)); networkGenerator.RandomGeneration(GenerationParameterValues, visualMode); if (ResearchType == ResearchType.Activation) { Debug.Assert(ResearchParameterValues.ContainsKey(ResearchParameter.InitialActivationProbability)); Double IP = Double.Parse(ResearchParameterValues[ResearchParameter.InitialActivationProbability].ToString(), CultureInfo.InvariantCulture); (networkGenerator.Container as AbstractNetworkContainer).RandomActivating(IP); } if (visualMode) { Debug.Assert(networkGenerator.GenerationSteps != null); GenerationSteps = networkGenerator.GenerationSteps; Branches = networkGenerator.Container.GetBranches(); } CustomLogger.Write("Research - " + ResearchName + ". Random GENERATION FINISHED for network - " + NetworkID.ToString()); } UpdateStatus(NetworkStatus.StepCompleted); } catch (CoreException ex) { UpdateStatus(NetworkStatus.Failed); CustomLogger.Write("Research - " + ResearchName + "GENERATION FAILED for network - " + NetworkID.ToString() + ". Exception message: " + ex.Message); return(false); } return(true); }
public override void StopResearch() { if (subResearches != null) { foreach (AbstractResearch r in subResearches) { r.StopResearch(); } StatusInfo = new ResearchStatusInfo(ResearchStatus.Stopped, StatusInfo.CompletedStepsCount); CustomLogger.Write("Research ID - " + ResearchID.ToString() + ". Research - " + ResearchName + ". STOPPED COLLECTION RESEARCH."); } }
/// <summary> /// Creates single EnsembleManager, runs in background thread. /// </summary> public virtual Task StartResearch() { ValidateResearchParameters(); CreateEnsembleManager(); StatusInfo = new ResearchStatusInfo(ResearchStatus.Running, 0); CustomLogger.Write("Research ID - " + ResearchID.ToString() + ". Research - " + ResearchName + ". STARTED " + GetResearchType() + " RESEARCH."); return(Task.Run(() => { currentManager.Run(); RunCompleted(); })); }
/// <summary> /// Traces the adjacency matrix of generated network to file. /// </summary> public bool Trace(String tracingDirectory, String tracingPath) { try { CustomLogger.Write("Research - " + ResearchName + ". TRACING STARTED for network - " + NetworkID.ToString()); if (TracingIsNotSupported()) { return(true); } if (TracingType == TracingType.Matrix) { MatrixInfoToWrite matrixInfo = new MatrixInfoToWrite(); matrixInfo.Matrix = networkGenerator.Container.GetMatrix(); matrixInfo.Branches = networkGenerator.Container.GetBranches(); matrixInfo.ActiveStates = (networkGenerator.Container as AbstractNetworkContainer).GetActiveStatuses(); FileManager.Write(tracingDirectory, matrixInfo, tracingPath); } else if (TracingType == TracingType.Neighbourship) { NeighbourshipInfoToWrite neighbourshipInfo = new NeighbourshipInfoToWrite(); neighbourshipInfo.Neighbourship = networkGenerator.Container.GetNeighbourship(); neighbourshipInfo.Branches = networkGenerator.Container.GetBranches(); neighbourshipInfo.ActiveStates = (networkGenerator.Container as AbstractNetworkContainer).GetActiveStatuses(); FileManager.Write(tracingDirectory, neighbourshipInfo, tracingPath); } UpdateStatus(NetworkStatus.StepCompleted); CustomLogger.Write("Research - " + ResearchName + ". TRACING FINISHED for network - " + NetworkID.ToString()); } catch (CoreException ex) { UpdateStatus(NetworkStatus.Failed); CustomLogger.Write("Research - " + ResearchName + "TRACING FAILED for network - " + NetworkID.ToString() + ". Exception message: " + ex.Message); return(false); } return(true); }
public async Task <ActionResult> Index() { string loginUserId = TempData[WebConstants.LoginUserId].ToString(); string loginUserName = TempData[WebConstants.LoginUserName].ToString(); string authmode = TempData[WebConstants.AuthenticationMode].ToString(); HttpResponseMessage response_Cat = null; HttpResponseMessage response_Printer = null; IEnumerable <Catridge> list_Cat = null; IEnumerable <Printer> list_Printer = null; if (loginUserId == "1" && authmode == "Admin") { CustomLogger.Write("Service Call: Get All Catridge: Start"); response_Cat = await ServiceGet(ClientConfig.ServiceLayerUrl + ClientConfig.GetAllCatridgeUrl); CustomLogger.Write("Service Call: Get All Catridge: End"); var result_Cat = response_Cat.Content.ReadAsStringAsync().Result; list_Cat = JsonConvert.DeserializeObject <IEnumerable <Catridge> >(result_Cat).OrderByDescending(s => s.Id); CustomLogger.Write("Service Call: Get All Printer: Start"); response_Printer = await ServiceGet(ClientConfig.ServiceLayerUrl + ClientConfig.GetAllPrinterUrl); CustomLogger.Write("Service Call: Get All Printer: End"); var result_Printer = response_Printer.Content.ReadAsStringAsync().Result; list_Printer = JsonConvert.DeserializeObject <IEnumerable <Printer> >(result_Printer).OrderByDescending(s => s.Id); dynamic mymodel = new ExpandoObject(); mymodel.Catridge = list_Cat; mymodel.Printer = list_Printer; return(View(mymodel)); } else { CustomLogger.Write("Service Call: GetAllPrinters: Failed|" + response_Printer); ModelState.AddModelError(Resources.Resource.MasterError, Resources.Resource.UnableToProcessRequest); list_Printer = new List <Printer>(); return(View(list_Printer.AsEnumerable())); } }
public override Task StartResearch() { ValidateResearchParameters(); Debug.Assert(GenerationParameterValues.ContainsKey(GenerationParameter.Probability) || GenerationParameterValues.ContainsKey(GenerationParameter.Mu)); probabilityParameter = GenerationParameterValues.ContainsKey(GenerationParameter.Probability) ? GenerationParameter.Probability : GenerationParameter.Mu; minProbability = Double.Parse(GenerationParameterValues[probabilityParameter].ToString(), CultureInfo.InvariantCulture); currentProbability = minProbability; maxProbability = Double.Parse(ResearchParameterValues[ResearchParameter.ProbabilityMax].ToString(), CultureInfo.InvariantCulture); delta = Double.Parse(ResearchParameterValues[ResearchParameter.ProbabilityDelta].ToString(), CultureInfo.InvariantCulture); StatusInfo = new ResearchStatusInfo(ResearchStatus.Running, 0); CustomLogger.Write("Research ID - " + ResearchID.ToString() + ". Research - " + ResearchName + ". STARTED Threshold RESEARCH."); return(StartCurrentEnsemble()); }
private bool TracingIsNotSupported() { bool support = networkGenerator.Container.Size > 30000; //if (networkGenerator.Container is AbstractHierarchicContainer) //{ // networkAnalyzer.Container = networkGenerator.Container; // support = (networkAnalyzer.CalculateEdgesCount() > 10000000); //} //else support = (networkGenerator.Container.Size > 30000); if (support) { UpdateStatus(NetworkStatus.StepCompleted); CustomLogger.Write("Research - " + ResearchName + ". TRACING is SKIPPED for network - " + NetworkID.ToString()); } return(support); }
public override Task StartResearch() { ValidateResearchParameters(); StatusInfo = new ResearchStatusInfo(ResearchStatus.Running, 0); CustomLogger.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); NetworkInfoToRead mr = FileManager.Read(m.Path, m.Size); // TODO FIX Debug.Assert(mr is MatrixInfoToRead); string storageString = Storage.StorageString; // depraceting sql storage /*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.ReadSubnetworkMatrix(fn, out s); MatrixInfoToWrite tmp = new MatrixInfoToWrite(); // TODO FIX //tmp.Matrix = CreateMatrixForSubgraph((mr as MatrixInfoToRead).Matrix, s); // Create temporary .txt files for each matrix string tmpFileName = storageString + "\\" + Path.GetFileNameWithoutExtension(fn); FileManager.Write(RandNetSettings.TracingDirectory, 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; return(subResearches[currentResearchIndex].StartResearch()); } return(Task.Run(() => {})); }
static SessionManager() { CustomLogger.Write("---------------------- SESSION MANAGER STARTED ----------------------"); existingResearches = new Dictionary <Guid, AbstractResearch>(); }
public override Task StartResearch() { ValidateResearchParameters(); StatusInfo = new ResearchStatusInfo(ResearchStatus.Running, 0); CustomLogger.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.Activation; // TODO think about 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.RealizationCount = RealizationCount; r.ModelType = ModelType; r.TracingPath = ""; r.ResearchParameterValues = ResearchParameterValues; Debug.Assert(r.GenerationParameterValues.ContainsKey(GenerationParameter.AdjacencyMatrix)); r.GenerationParameterValues[GenerationParameter.AdjacencyMatrix] = m; r.AnalyzeOption = AnalyzeOption; string storageString = Storage.StorageString; // depracate sql storage /*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; return(subResearches[currentResearchIndex].StartResearch()); } return(Task.Run(() => {})); }
/// <summary> /// Validates research parameters. /// </summary> /// <exception>InvalidResearchParameters.</exception> protected virtual void ValidateResearchParameters() { CustomLogger.Write("Research - " + ResearchName + ". Validated research parameters."); }