public void ExecuteNONE(Elimination <T> elimination, Matrix <T> x, Matrix <T> a, Matrix <T> b) { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); Matrix <T> result = elimination.Eliminate(a.ConcatenateWithVector(b)); stopwatch.Stop(); File.WriteAllText(@$ "C:\Users\marci\Tests\none_{typeof(T)}{x.Rows}.txt", "NONE: \nTime:" + stopwatch.Elapsed + x.Difference(result));
public void getSolutionTest() //Проверка отсева (получения хороших точек) { //Хорошая точка-значение градиента больше порогового значения //arrange IMathematical strat = new MathematicialSearchPoint1(); Elimination elemenation = new Elimination(strat); Data.Image img = new Data.Image("Data\\sample_10.png"); elemenation.calculateGradientImage(img); //Вычисление градиента //act double maxGradient = elemenation.swingSharpness[0, 0]; double minGradient = elemenation.swingSharpness[0, 0]; for (int i = 0; i < img.width(); i++) //Найти макс и мин { for (int j = 0; j < img.height(); j++) { maxGradient = Math.Max(maxGradient, elemenation.swingSharpness[i, j]); minGradient = Math.Min(minGradient, elemenation.swingSharpness[i, j]); } } double threshold = minGradient + ((maxGradient - minGradient) * 0.1); //порог List <Data.Point> exepected = new List <Data.Point>(); for (int i = 0; i < img.width(); i++) { for (int j = 0; j < img.height(); j++) { if (elemenation.swingSharpness[i, j] >= threshold) { exepected.Add(new Data.Point(i, j)); } } } List <Data.Point> actual = new List <Data.Point>(); actual = elemenation.getSolution(); //assert Debug.WriteLine("Проверка количества точек"); Assert.AreEqual(actual.Count, exepected.Count); Debug.WriteLine("Проверка самих точек"); int t = 0; foreach (Data.Point p1 in exepected) { Assert.AreEqual(p1.x, actual[t].x); Assert.AreEqual(p1.y, actual[t].y); t++; } }
public static Elimination CreateElimination(OptimizationParameters optimizationParameters, int[][] population, Random random) { Elimination elimination = optimizationParameters.EliminationMethod switch { EliminationMethod.Elitism => new ElitismElimination(population, random), EliminationMethod.RouletteWheel => new RouletteWheelElimination(population, random), EliminationMethod.Tournament => new TournamentElimination(population, random) { ParticipantsCount = optimizationParameters.TournamentEliminationParticipantsCount }, _ => throw new ArgumentException("Wrong elimination method name") }; return(elimination); }
public Elimination Update(Elimination elimination) { var obj = FindById(elimination.IdElimination); if (obj == null) { return(null); } else { obj = elimination; _context.SaveChanges(); return(obj); } }
private static void PlayTournaments() { foreach (Tournament t in AllTournaments) // Play all Tournaments based on their type { Tournament tournament = null; if (t.isElimination()) { tournament = new Elimination(t.Id, t.Surface, t.Type); } else if (t.isLeague()) { tournament = new League(t.Id, t.Surface, t.Type); } tournament.Play(AllPlayers); } }
public Elimination Update(Elimination elimination) { var obj = FindById(elimination.IdElimination); if (obj == null) { return(null); } else { obj.EliminationDate = elimination.EliminationDate; obj.IdCompetition = obj.IdCompetition; obj.Note = elimination.Note; var result = eliminationRepository.Update(obj); return(result); } }
public ActionResult <Elimination> AddElimination(Elimination elimination) { Elimination obj; if (elimination.IdElimination != 0) { obj = eliminationService.Update(elimination); if (obj == null) { return(NoContent()); } } else { obj = eliminationService.Add(elimination); } return(Ok(obj)); }
static void Main(string[] args) { var data = new ExcelReader(@"c:\temp\accordemo\accordemo\titanic.xls").GetWorksheet("titanic3"); data.Rows.RemoveAt(data.Rows.Count - 1); var d = new Elimination("age").Apply(data); var fdata = new Codification(d, "sex").Apply(d); var outp = fdata.Columns["survived"].ToArray <int>(); var input = fdata.ToArray <double>("pclass", "sex", "age", "parch", "sibsp"); DecisionTree T = new DecisionTree( DecisionVariable.FromData(input), 2); var learn = new C45Learning(T); learn.Run(input, outp); var r1 = T.Decide(new double[] { 0, 1, 23, 0, 0 }); var r2 = T.Decide(new double[] { 1, 0, 30, 1, 1 }); Console.WriteLine($"Male={r1}, Female={r2}"); Console.ReadKey(); }
public void CreateTest5Teams3Teams() { var eliminationSystem = new Elimination { Tournament = new EliminationTournament { CreatorId = "test", Id = 1, Teams = CreateTeams(9), TeamsByMatch = 3, Sport = new Sport { MinTeams = 2, MaxTeams = 4 } } }; eliminationSystem.Create(); Assert.AreEqual(eliminationSystem.Tournament.Qualifications.Count, 2); }
public Tournoi(Tournoi tournoiEnCours) { Nom = tournoiEnCours.Nom; TypeTournoi = tournoiEnCours.TypeTournoi; Date = tournoiEnCours.Date; Heure = tournoiEnCours.Heure; Description = tournoiEnCours.Description; _nbTour = 0; _nbPartie = 0; LstLocaux = tournoiEnCours.LstLocaux; LstVolontaires = tournoiEnCours.LstVolontaires; LstJoueurs = tournoiEnCours.LstJoueurs; LstEquipes = tournoiEnCours.LstEquipes; LstPrix = tournoiEnCours.LstPrix; LstTours = tournoiEnCours.LstTours; GenerationTourPossible = true; GenerateurTour = new Elimination(); }
public async Task PlayNextGameAsync() { var nextCompetitors = Elimination.GetNextCompetitors(); GameOverTextVisibility = Visibility.Collapsed; if (nextCompetitors != null) { var gameHistoryEntry = new GameHistoryEntryViewModel() { GameDescription = Elimination.GetGameDescription(), History = new ObservableCollection <RoundPartialHistory>() }; Game.SetupNewGame(nextCompetitors); GameHistory.Add(gameHistoryEntry); OutputText += "Game starting: " + gameHistoryEntry.GameDescription + "\n"; await PlayGameAsync(gameHistoryEntry); } }
public async Task PlayNextGameAsync() { var nextCompetitors = Elimination.GetNextCompetitors(); if (nextCompetitors != null) { await SetArenaMessage(ArenaMessageHelper.GetInitialMessage(nextCompetitors)); var gameHistoryEntry = new GameHistoryEntryViewModel() { GameDescription = Elimination.GetGameDescription(), History = new ObservableCollection <RoundPartialHistory>() }; Game.SetupNewGame(nextCompetitors); GameHistory.Add(gameHistoryEntry); OutputText += "Game starting: " + gameHistoryEntry.GameDescription + "\n"; await PlayGameAsync(gameHistoryEntry); } }
public Tournoi() { // Infos de base du tournoi Nom = "Le tournoi"; TypeTournoi = "Simple élimination"; Date = DateTime.Now.Date; Heure = DateTime.Now.TimeOfDay; Description = null; _nbTour = 0; _nbPartie = 0; LstLocaux = new ObservableCollection <Local>(); LstVolontaires = new ObservableCollection <Volontaire>(); LstJoueurs = new ObservableCollection <Joueur>(); LstEquipes = new ObservableCollection <Equipe>(); LstPrix = new ObservableCollection <Prix>(); LstTours = new ObservableCollection <Tour>(); GenerationTourPossible = true; GenerateurTour = new Elimination(); }
/// <summary> /// Eliminates a variable from PXModel instance. /// </summary> /// <param name="px"></param> /// <param name="variableCode">Code of variable to eliminate.</param> /// <returns></returns> public static PXModel Eliminate(this PXModel px, string variableCode) { if (elimination == null) { elimination = new Elimination(); } Variable v = px.Meta.Variables.First(x => x.Code == variableCode); if (!v.Elimination && v.Values.Count > 1) { throw new PxExtendExceptions.EliminatinNotAllowedException("Elimination of variable \"" + v.Name + "\" is not allowed."); } return (elimination.Execute( px, new EliminationDescription[] { new EliminationDescription(v.Code, v.EliminationValue != null) } )); }
private async Task PlayGameAsync(GameHistoryEntryViewModel gameHistoryEntry) { RoundResult result; do { result = await Game.PerformNextRoundAsync(); OutputText += result.OutputText; foreach (var roundPartialHistory in result.History) { gameHistoryEntry.History.Add(roundPartialHistory); } } while (!result.IsFinished && IsGameInProgress && !IsGamePaused); if (result.IsFinished) { Elimination.SetLastDuelResult(result.FinalResult); ScoreList.SaveScore(result.FinalResult); GameOverTextVisibility = Visibility.Visible; } }
public Elimination Add(Elimination entity) { _context.Elimination.Add(entity); _context.SaveChanges(); return(entity); }
public Elimination Add(Elimination entity) { return(eliminationRepository.Add(entity)); }
static void Main(string[] args) { IParser parser = new Parser(); ICalculated calculated; IPreserveOBJ preserveOBJ = new PreserveOBJ(); IPreservePNG preservePNG = new PreservePNG(); IElimination elimination; IAnalysis analysis; Setting setting = null; INIManager manager; List <string> filesImagesname; string pathFolder; string pathConfig; string pathSetting; string saveFolder; if (args.Length == 0) { Console.WriteLine("usage: Get3DModel.exe <path to folder>"); Environment.Exit(-1); } pathFolder = args[0]; pathSetting = pathFolder + "\\setting.ini"; manager = new INIManager(pathSetting); string[] separators = { "\\" }; string[] words = pathFolder.Split(separators, StringSplitOptions.RemoveEmptyEntries); saveFolder = words[0]; for (int i = 1; i < words.Length - 1; i++) { saveFolder = saveFolder + "\\" + words[i]; } saveFolder = saveFolder + "\\Resulst_" + words[words.Length - 1]; Directory.CreateDirectory(saveFolder); StreamWriter timeTxt = new StreamWriter(saveFolder + "\\time.txt"); string[] listFileFolder = Directory.GetDirectories(pathFolder); foreach (string folder in listFileFolder) { FileInfo fileInfFolder = new FileInfo(folder); string nameFolder = fileInfFolder.Name; string saveFolderCurrent = saveFolder + "\\" + nameFolder; Directory.CreateDirectory(saveFolderCurrent); filesImagesname = Directory.GetFiles(folder, "*.png").ToList <string>(); pathConfig = Directory.GetFiles(folder).ToList().First( x => x.EndsWith(".camera") || x.EndsWith(".ini") || x.EndsWith("ConfigurationFile.txt")); FileInfo fileInf = new FileInfo(pathConfig); if (fileInf.Exists) { setting = new Setting(pathConfig); } else { Console.WriteLine("the configuration file is not found"); Environment.Exit(-1); } Stopwatch timeForParsing = new Stopwatch(); timeForParsing.Restart(); string nameCoreElimination = manager.GetPrivateString("ELIMINATION", "core"); IMathematical coreElimination = getMathematical(nameCoreElimination); if (coreElimination != null) { string thresholdElimination = manager.GetPrivateString("ELIMINATION", "threshold"); if (thresholdElimination != "default") { double deltaTheshold = Convert.ToDouble(thresholdElimination); coreElimination.setDeltaThreshold(deltaTheshold); } elimination = new Elimination(coreElimination); } else { elimination = new Elimination(); } for (int i = 0; i < filesImagesname.Count; i++) { if (filesImagesname[i].EndsWith("sharpImage.png")) { continue; } Data.Image itemImage = new Data.Image(filesImagesname[i]); elimination.calculateGradientImage(itemImage); } List <Data.Point> goodPoint = elimination.getSolution(); string boolSelectionCore = manager.GetPrivateString("SELECTION_CORE", "selection_core"); if (boolSelectionCore == "true") { string nameCore3x3 = manager.GetPrivateString("CORE", "3_core"); IMathematical core3x3 = getMathematical(nameCore3x3); if (core3x3 == null) { core3x3 = new MathematicialSearchPoint1(); } string nameCore5x5 = manager.GetPrivateString("CORE", "5_core"); IMathematical core5x5 = getMathematical(nameCore5x5); if (core5x5 == null) { core5x5 = new MathematicialSearchPoint8(); } string nameCore7x7 = manager.GetPrivateString("CORE", "7_core"); IMathematical core7x7 = getMathematical(nameCore5x5); if (core7x7 == null) { core7x7 = new MathematicialSearchPoint9(); } analysis = new Analysis(goodPoint, core3x3, core5x5, core7x7); for (int i = 0; i < filesImagesname.Count; i++) { if (filesImagesname[i].EndsWith("sharpImage.png")) { continue; } Data.Image itemImage = new Data.Image(filesImagesname[i]); analysis.addImageAnalysis(itemImage); } List <IMathematical> coreGoodPoint = analysis.getCore(); calculated = new Calculated(); calculated.createdBeginSolution(); for (int i = 0; i < filesImagesname.Count; i++) { if (filesImagesname[i].EndsWith("sharpImage.png")) { continue; } Data.Image itemImage = new Data.Image(filesImagesname[i]); calculated.clarifySolution(itemImage, coreGoodPoint, goodPoint); } } else { string nameCore = manager.GetPrivateString("SELECTION_CORE", "default_core"); IMathematical core = getMathematical(nameCore); if (core == null) { core = new MathematicialSearchPoint1(); } calculated = new Calculated(core); calculated.createdBeginSolution(); for (int i = 0; i < filesImagesname.Count; i++) { if (filesImagesname[i].EndsWith("sharpImage.png")) { continue; } Data.Image itemImage = new Data.Image(filesImagesname[i]); calculated.clarifySolution(itemImage, goodPoint); } } Solution solution = calculated.getSolution(); timeForParsing.Stop(); timeTxt.WriteLine(nameFolder + " - " + timeForParsing.ElapsedMilliseconds + " timeForParsing"); preserveOBJ.saveOBJ(solution, setting, saveFolderCurrent); preservePNG.savePNG(solution, saveFolderCurrent); saveDat(solution.Map, saveFolderCurrent); } timeTxt.Close(); }
public void startGame(int scene) { if (GenerateGame.instance.whiteKing != true && GenerateGame.instance.blackKing != true) { return; } int boardSize = GenerateGame.instance.boardSize; int promoRows = int.Parse(GameObject.Find("PromoRows").GetComponentInChildren <Text>().text); List <Piece> white = new List <Piece>(); List <Piece> black = new List <Piece>(); foreach (List <GeneratedTile> item in GenerateGame.instance.board) { foreach (GeneratedTile i in item) { if (i.occupied) { if (i.isWhite) { white.Add(i.occupiedBy); } else { black.Add(i.occupiedBy); } } } } int s = GameObject.Find("Rules").GetComponent <Dropdown>().value; Rules rules; switch (s) { case 0: rules = new Checkmate(); break; case 1: rules = new Capture(); break; case 2: rules = new Elimination(); break; default: rules = new Checkmate(); break; } GameObject setupObject = new GameObject(); setupObject.name = "SetupObject"; setupObject.AddComponent <GameInfoHolder>(); setupObject.GetComponent <GameInfoHolder>().black = black; setupObject.GetComponent <GameInfoHolder>().white = white; setupObject.GetComponent <GameInfoHolder>().boardSize = boardSize; setupObject.GetComponent <GameInfoHolder>().promoRows = promoRows; setupObject.GetComponent <GameInfoHolder>().useCaptured = GameObject.Find("Captured").GetComponentInChildren <Toggle>().isOn; setupObject.GetComponent <GameInfoHolder>().rules = rules; if (GameObject.Find("Player")) { setupObject.GetComponent <GameInfoHolder>().player = GameObject.Find("Player").GetComponent <Dropdown>().value; } if (GameObject.Find("AI")) { setupObject.GetComponent <GameInfoHolder>().ai = GameObject.Find("AI").GetComponent <Dropdown>().value; } DontDestroyOnLoad(GameObject.Find("SetupObject")); SceneManager.LoadScene(scene); }
public async Task MakeEndGameConfiguration(RoundResult result) { Elimination.SetLastDuelResult(result.FinalResult); ScoreList.SaveScore(result.FinalResult); await SetArenaMessage(ArenaMessageHelper.GetEndGameMessage(result.FinalResult)); }
private void MenuItem_Click(object sender, RoutedEventArgs e) { string path = ""; DartBoard.UnsetCricket(); OnSpielWechsel?.Invoke(this, new EventArgs()); MenuItem item = (MenuItem)sender; if (item.Tag.ToString().Equals("Close")) { Close(); } if (item.Tag.ToString().Equals("101")) { path = "pack://application:,,,/Images/101.png"; spiel = new X01(grdWurfanzeige, grdTabelle, Mitspieler, DartBoard, 101, this); } if (item.Tag.ToString().Equals("301")) { path = "pack://application:,,,/Images/301.png"; spiel = new X01(grdWurfanzeige, grdTabelle, Mitspieler, DartBoard, 301, this); } if (item.Tag.ToString().Equals("501")) { path = "pack://application:,,,/Images/501.png"; spiel = new X01(grdWurfanzeige, grdTabelle, Mitspieler, DartBoard, 501, this); } if (item.Tag.ToString().Equals("701")) { path = "pack://application:,,,/Images/701.png"; spiel = new X01(grdWurfanzeige, grdTabelle, Mitspieler, DartBoard, 701, this); } if (item.Tag.ToString().Equals("901")) { path = "pack://application:,,,/Images/901.png"; spiel = new X01(grdWurfanzeige, grdTabelle, Mitspieler, DartBoard, 901, this); } if (item.Tag.ToString().Equals("Cricket")) { path = "pack://application:,,,/Images/Cricket.png"; DartBoard.SetCricket(); Cricket cricket = new Cricket(grdWurfanzeige, grdTabelle, Mitspieler, DartBoard, this); } if (item.Tag.ToString().Equals("SplitScore")) { path = "pack://application:,,,/Images/SplitScore.png"; SplitScore splitscore = new SplitScore(grdWurfanzeige, grdTabelle, Mitspieler, DartBoard, this); } if (item.Tag.ToString().Equals("Elimination")) { path = "pack://application:,,,/Images/Elimination.png"; Elimination elimination = new Elimination(grdWurfanzeige, grdTabelle, Mitspieler, DartBoard, this); } var image = new BitmapImage(new Uri(path)); LblSpielIcon.Background = new ImageBrush(image); BtnSpielerPlus.Visibility = Visibility.Visible; Background = new ImageBrush(new BitmapImage(new Uri(BaseUriHelper.GetBaseUri(this), "Images/BgMainscreen.png"))); DartBoard.Visibility = Visibility.Visible; }
static void Main(string[] args) { IParser parser = new Parser(); ICalculated calculated = new Calculated(new MathematicialSearchPoint1()); IPreserveOBJ preserveOBJ = new PreserveOBJ(); IPreservePNG preservePNG = new PreservePNG(); IElimination elimination = new Elimination(); IAnalysis analysis; Setting setting = null; double delta = 0.0; List <string> filesImagesname; string pathFolder; string pathConfig; if (args.Length == 0) { Console.WriteLine("usage: Get3DModel.exe <path to folder>"); Environment.Exit(-1); } pathFolder = args[0]; filesImagesname = Directory.GetFiles(pathFolder, "*.png").ToList <string>(); if (args.Length > 1) { delta = Convert.ToDouble(args[1]); } pathConfig = Directory.GetFiles(pathFolder).ToList().First( x => x.EndsWith(".camera")); FileInfo fileInf = new FileInfo(pathConfig); if (fileInf.Exists) { setting = new Setting(pathConfig); Console.WriteLine("the verification of the optics configuration file completed successfully"); } else { Console.WriteLine("the configuration file is not found"); Environment.Exit(-1); } Stopwatch timeForParsing = new Stopwatch(); for (int i = 0; i < filesImagesname.Count && i < 50; i++) { if (filesImagesname[i].EndsWith("sharpImage.png")) { continue; } timeForParsing.Restart(); Data.Image itemImage = new Data.Image(filesImagesname[i]); elimination.calculateGradientImage(itemImage); timeForParsing.Stop(); Console.WriteLine( string.Format("elimination of the {0} has finished\n\telapsed time: {1} milliseconds", filesImagesname[i], timeForParsing.ElapsedMilliseconds)); GC.Collect(); } List <Data.Point> goodPoint = elimination.getSolution(); analysis = new Analysis(goodPoint); for (int i = 0; i < filesImagesname.Count; i++) // Parallel.For(0, filesImagesname.Count, i => { if (filesImagesname[i].EndsWith("sharpImage.png")) { continue; } timeForParsing.Restart(); Data.Image itemImage = new Data.Image(filesImagesname[i]); lock (analysis) analysis.addImageAnalysis(itemImage); timeForParsing.Stop(); Console.WriteLine( string.Format("analysing of the {0} has finished\n\telapsed time: {1} milliseconds", filesImagesname[i], timeForParsing.ElapsedMilliseconds)); } //); List <IMathematical> coreGoodPoint = analysis.getCore(); analysis = null; elimination = null; GC.Collect(); calculated.createdBeginSolution(); for (int i = 0; i < filesImagesname.Count; i++) { if (filesImagesname[i].EndsWith("sharpImage.png")) { continue; } timeForParsing.Restart(); Data.Image itemImage = new Data.Image(filesImagesname[i]); calculated.clarifySolution(itemImage, coreGoodPoint, goodPoint); timeForParsing.Stop(); Console.WriteLine( string.Format("processing of the {0} has finished\n\telapsed time: {1} milliseconds", filesImagesname[i], timeForParsing.ElapsedMilliseconds)); } Solution solution = calculated.getSolution(); Console.WriteLine("saving data was started"); preserveOBJ.saveOBJ(solution, setting, pathFolder); preservePNG.savePNG(solution, pathFolder); }