static void Main() { var biosensor = new TwoLayerAnalyticalBiosensor(); var simulationParameters = new SimulationParametersSuplier1(biosensor); //var resultPrinter = new ConsolePrinter(); var resultPrinter = new FilePrinter($@"C:\BiosensorSimulations\{biosensor.Name}"); BaseSimulation simulation = new SingleLayerSimulation1D(simulationParameters, biosensor, resultPrinter); simulation.PrintParameters(); simulation.ShowValidationValues(); new ExplicitSchemeStabilityChecker().AssertStability(simulationParameters, biosensor); /*if (biosensor is BaseHomogenousBiosensor homogenousBiosensor && homogenousBiosensor.IsHomogenized) * biosensor.Homogenize();*/ simulation.SchemeCalculator = new ExplicitSchemeCalculator(biosensor, simulationParameters); if (simulation.SchemeCalculator is ImplicitSchemeCalculator) { resultPrinter.Print("====Implicit Scheme Calculator===="); } else { resultPrinter.Print("====Explicit Scheme Calculator===="); } resultPrinter.Print("====Results===="); simulation.RunStableCurrentSimulation(); //simulation.RunSimulation(30); //TwoLayer //simulation.RunSimulation(124, new []{6.8, 8.4, 16, 18.3, 27.8}, true); //First Order //simulation.RunSimulation(24.5, new[] { 0.5, 1, 3 }); if (resultPrinter is ConsolePrinter) { Console.ReadKey(); Console.ReadKey(); Console.ReadKey(); } else { resultPrinter.CloseStream(); } }
static void DZ3() { // Assume that the number of rows in the text file is always at least 10. // Assume a valid input file. string fileName = "shows.tv"; string outputFileName = "storage.tv"; IPrinter printer = new ConsolePrinter(); printer.Print($"Reading data from file {fileName}"); Episode[] episodes = TvUtilities.LoadEpisodesFromFile(fileName); Season season = new Season(1, episodes); printer.Print(season.ToString()); for (int i = 0; i < season.Length; i++) { season[i].AddView(TvUtilities.GenerateRandomScore()); } printer.Print(season.ToString()); printer = new FilePrinter(outputFileName); printer.Print(season.ToString()); }
private static void SimilaritySolver(string resultPath, IGraph graph, ISimilarityCalculationStrategy[] calculationStrategies, GraspEdgeFinder edgeFinder) { var similaritySolver = new PathSimilaritySolver(graph, new InitializationSolver(new TspSolver(graph), new RandomPathAlgorithm(Steps, edgeFinder)), calculationStrategies); similaritySolver.Solve(new LocalSearchAlgorithm(Steps, edgeFinder)); foreach (var similairityValue in similaritySolver.SimilairityValues) { var resultString = new StringBuilder(); var title = similairityValue.Key; var filePrinter = new FilePrinter(resultPath, $"{title.Replace(' ', '_').Replace('|', '_')}_results.res"); resultString.AppendLine($"{nameof(SimilaritySolverResult.Cost)} {nameof(SimilaritySolverResult.SimilarityValue)}"); foreach (var similaritySolverResult in similairityValue.Value) { resultString.AppendLine($"{similaritySolverResult.Cost} {similaritySolverResult.SimilarityValue:F}"); } resultString.AppendLine(); filePrinter.Print(resultString.ToString()); } Console.WriteLine("SUCCES!!!"); }
private void OnBuildClick(object sender, EventArgs e) { logger.Info("Нажата кнопка 'построить', количество строк массива " + _view.NumRows + ", количество столбцов " + _view.NumColumns + "."); var model = SnakeService.CalculateModel(_view.NumColumns, _view.NumRows); IPrinter dgPrinter = new DataGridViewPrinter { DataGrid = _view.MyDataGridView }; dgPrinter.Print(model); var result = MessageBox.Show("Сохранить в файл?", "Сохранение в файл", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (result != DialogResult.OK) { logger.Info("Отказ сохранить построенный массив в файл"); return; } if (string.IsNullOrEmpty(_view.FilePath)) { logger.Info("Ошибка сохранения массива в файл - не указан путь."); MessageBox.Show("Файл не указан", "Сохранение файла", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } IPrinter fPrinter = new FilePrinter { Path = _view.FilePath }; fPrinter.Print(model); }
/// <summary> /// Creates the text file for the job separator and submits it to the print queue /// </summary> /// <param name="executionData"></param> /// <param name="printQueue"></param> protected virtual void PrintJobSeparator(PluginExecutionData executionData, PrintQueue printQueue) { StringBuilder strFileContent = PrintTag(printQueue, executionData); string tagfileName = Path.Combine(Path.GetTempPath(), executionData.ActivityExecutionId + ".txt"); File.WriteAllText(tagfileName, strFileContent.ToString(), Encoding.ASCII); FilePrinter printer = FilePrinterFactory.Create(tagfileName); printer.Print(printQueue); File.Delete(tagfileName); }
public void Print(List <Profile> data, IPrinter printer, DataFormatter formatter) { if (_options.Verbose) { printer.Print(formatter.Format(data)); } if (_options.Log) { printer = new FilePrinter(); formatter = new ReportFormatter(); printer.Print(formatter.Format(data)); wg.Generate(data); } }
private void OnBuildClick(object sender, EventArgs e) { logger.Info("Нажата кнопка 'построить', количество строк массива " + _view.NumRows + ", количество столбцов " + _view.NumColumns + "."); var model = _snakeService.CalculateModel(_view.NumRows, _view.NumColumns); var printer = _view.GetViewPrinter(); printer.Print(model); if (!string.IsNullOrEmpty(_view.FilePath)) { IPrinter fPrinter = new FilePrinter { Path = _view.FilePath }; fPrinter.Print(model); } }
private void PrintTag(PrintQueue printQueue, PluginExecutionData executionData) { StringBuilder strFileContent = new StringBuilder(); strFileContent.AppendLine(); strFileContent.AppendLine(); strFileContent.AppendLine($"UserName: {_userName}"); strFileContent.AppendLine($"Session ID: {_sessionId}"); strFileContent.AppendLine($"Actvity ID: {executionData.ActivityExecutionId}"); strFileContent.AppendLine($"Date: {DateTime.Now.ToShortDateString()}"); strFileContent.AppendLine($"Time: {DateTime.Now.ToShortTimeString()}"); string tagfileName = Path.Combine(Path.GetTempPath(), $"{executionData.ActivityExecutionId}.txt"); File.WriteAllText(tagfileName, strFileContent.ToString(), Encoding.ASCII); FilePrinter printer = FilePrinterFactory.Create(tagfileName); printer.Print(printQueue); File.Delete(tagfileName); }
private static void PrintTag(PrintQueue printQueue, PluginExecutionData executionData) { StringBuilder strFileContent = new StringBuilder(); strFileContent.AppendLine(); strFileContent.AppendLine(); strFileContent.AppendLine(string.Format("UserName: {0}", Environment.UserName)); strFileContent.AppendLine(string.Format("Session ID: {0}", executionData.SessionId)); strFileContent.AppendLine(string.Format("Activity ID:{0}", executionData.ActivityExecutionId)); strFileContent.AppendLine(string.Format("Date: {0}", DateTime.Now.ToShortDateString())); strFileContent.AppendLine(string.Format("Time: {0}", DateTime.Now.ToShortTimeString())); string tagfileName = Path.Combine(Path.GetTempPath(), executionData.ActivityExecutionId + ".txt"); File.WriteAllText(tagfileName, strFileContent.ToString(), Encoding.ASCII); FilePrinter printer = FilePrinterFactory.Create(tagfileName); printer.Print(printQueue); File.Delete(tagfileName); }
static void Main(string[] args) { string fileName = "shows.tv"; string outputFileName = "storage.tv"; IPrinter printer = new ConsolePrinter(); printer.Print($"Reading data from file {fileName}"); Episode[] episodes = TvUtilities.LoadEpisodesFromFile(fileName); Season season = new Season(1, episodes); printer.Print(season.ToString()); for (int i = 0; i < season.Length; i++) { season[i].AddView(TvUtilities.GenerateRandomScore()); } printer.Print(season.ToString()); printer = new FilePrinter(outputFileName); printer.Print(season.ToString()); }
public static void Main(string[] args) { var sourceFile = ConfigurationManager.AppSettings["sourceFile"]; var destinationFile = ConfigurationManager.AppSettings["destinationFile"]; try { using (var reader = new StreamReader(sourceFile)) { var fileReader = new CustomReader(10); var builder = new SentenceBuilder(); var sentences = new List <Sentence>(0); var pageBuilder = new PageBuilder(5); while (fileReader.Read(reader) != 0) { while (builder.ExtractSentence(fileReader)) { sentences.Add(builder.Build()); } } var text = new Text(sentences); var concordance = new Concordance(); concordance.Fill(text, pageBuilder.Build(text)); IPrinter printer = new FilePrinter(destinationFile); printer.Print(concordance); } } catch (FileNotFoundException e) { Logger.Error($"File {e.FileName} is not found: {e.Message}"); } catch (ArgumentException e) { Logger.Error($"Wrong argument: {e.Message}"); } }
public static void Main(string[] args) { var buildConfig = BuildConfiguration(); var config = buildConfig.GetSection(nameof(AppConfiguration)); var dataPath = config["data"]; var resultPath = config["results"]; var graphEdges = System.IO.Path.Combine(dataPath, config["graphEdges"]); var graphCoordinates = System.IO.Path.Combine(dataPath, config["graphCoordinates"]); var dataLoader = new GraphLoader(graphEdges, 100); var graph = dataLoader.Load(); var calculationStrategies = new ISimilarityCalculationStrategy[] { new EdgeSimillarityStrategy(), new NodeSimilarityStrategy() }; var simpleSolver = new TspSolver(graph); var localSearchSolver = new TspLocalSearchSolver(graph); var edgeFinder = new GraspEdgeFinder(3); var evolutinarySolver = new EvolutionarySolver(graph, new Recombinator(new SimilarityFinder(calculationStrategies), Steps, graph), new Selector(), 41000); var localSearch = new LocalSearchAlgorithm(Steps, edgeFinder); var stats = new BasicSolverStatistics(); var bestCost = int.MaxValue; ISolverStatistics bestStatistics = new BasicSolverStatistics(); for (var i = 0; i < 10; i++) { var generatedPaths = simpleSolver.Solve(new RandomPathAlgorithm(Steps, edgeFinder)); generatedPaths = localSearchSolver.Solve(localSearch, generatedPaths); evolutinarySolver.Solve(localSearch, generatedPaths); if (evolutinarySolver.SolvingStatistics.BestPath.Cost < bestCost) { bestCost = evolutinarySolver.SolvingStatistics.BestPath.Cost; bestStatistics = evolutinarySolver.SolvingStatistics; } stats.UpdateSolvingResults(evolutinarySolver.SolvingStatistics.BestPath, evolutinarySolver.SolvingStatistics.MeanSolvingTime); } var statsPrinter = new FilePrinter(resultPath, "evo_stats.res"); statsPrinter.Print(stats.ToString()); var output = new StringBuilder(); output.AppendLine($"{"Id".PadRight(4)}\tCost\tTime"); for (var i = 0; i < bestStatistics.Costs.Count; i++) { output.AppendLine($"{i.ToString().PadRight(4)}\t{bestStatistics.Costs[i].ToString().PadRight(4)}\t{bestStatistics.SolvingTimes[i].Milliseconds:D}"); } var evoResultsPrinter = new FilePrinter(resultPath, "evolutionary_results.res"); evoResultsPrinter.Print(output.ToString()); Console.WriteLine("Evolutionary solver ended his work!"); //SimilaritySolver(resultPath, graph, calculationStrategies, edgeFinder); }
static void Main(string[] args) { //Episode ep1, ep2; //ep1 = new Episode(); //ep2 = new Episode(10, 64.39, 8.7); //int viewers = 10; //for (int i = 0; i < viewers; i++) //{ // ep1.AddView(TvUtilities.GenerateRandomScore()); // Console.WriteLine(ep1.GetMaxScore()); //} //if (ep1.GetAverageScore() > ep2.GetAverageScore()) //{ // Console.WriteLine($"Viewers: {ep1.GetViewerCount()}"); //} //else //{ // Console.WriteLine($"Viewers: {ep2.GetViewerCount()}"); //} //Description description = new Description(1, TimeSpan.FromMinutes(45), "Pilot"); //Console.WriteLine(description); //Episode episode = new Episode(10, 88.64, 9.78, description); //Console.WriteLine(episode); //// Assume that the number of rows in the text file is always at least 10. //// Assume a valid input file. //string fileName = "shows.tv"; //string[] episodesInputs = File.ReadAllLines(fileName); //Episode[] episodes = new Episode[episodesInputs.Length]; //for (int i = 0; i < episodes.Length; i++) //{ // episodes[i] = TvUtilities.Parse(episodesInputs[i]); //} //Console.WriteLine("Episodes:"); //Console.WriteLine(string.Join<Episode>(Environment.NewLine, episodes)); //TvUtilities.Sort(episodes); //Console.WriteLine("Sorted episodes:"); //string sortedEpisodesOutput = string.Join<Episode>(Environment.NewLine, episodes); //Console.WriteLine(sortedEpisodesOutput); //File.WriteAllText("sorted.tv", sortedEpisodesOutput); // Assume that the number of rows in the text file is always at least 10. // Assume a valid input file. string fileName = "shows.tv"; // u TvUtilities i FilePrinter se dodaje ekstenzija .txt na fileName i outputFileName string outputFileName = "storage.tv"; IPrinter printer = new ConsolePrinter(); printer.Print($"Reading data from file {fileName}"); Episode[] episodes = TvUtilities.LoadEpisodesFromFile(fileName); Season season = new Season(1, episodes); printer.Print(season.ToString()); for (int i = 0; i < season.Length; i++) { season[i].AddView(TvUtilities.GenerateRandomScore()); } printer.Print(season.ToString()); printer = new FilePrinter(outputFileName); printer.Print(season.ToString()); }