public void RefreshPage() { if (_context.AlgorithmsChanged) { _model.Initialize(); } Results.Clear(); for (int i = 0; i < _context.GetAlgorithms.Count; i++) { Results.Add(new StableMarriagePanel(_context.GetAlgorithms[i].Name, i) { State = "Futtatható", Time = 0, Runable = true, Done = false, }); } }
public void NewRunModel() { StablePairsEvaluation stablePairsEvaluation = new StablePairsEvaluation(); GroupHappinessEvaluation groupHappinessEvaluation = new GroupHappinessEvaluation(); EgalitarianHappinessEvaluation egalitarianHappinessEvaluation = new EgalitarianHappinessEvaluation(); NewModel(); SetupModel setupModel = _model.NewSetupModel(); setupModel.Initialize(); ParticipantsModel participantsModel = _model.NewParticipantsModel(); participantsModel.Initialize(); PreferencesModel preferencesModel = _model.NewPreferencesModel(); preferencesModel.Initialize(); AlgorithmModel algorithmModel = _model.NewAlgorithmModel(); algorithmModel.Initialize(); RunModel runModel = _model.NewRunModel(); runModel.Initialize(); int receivedEvents = 0; Task task; NewModel(); runModel.AlgorithmStarted += (object sender, AlgorithmEventArgs e) => receivedEvents++; runModel.AlgorithmFinished += (object sender, AlgorithmEventArgs e) => { receivedEvents++; Assert.AreEqual(_context.Algorithms[e.Index].Algorithm.Evaluate(stablePairsEvaluation), e.StablePairs); Assert.AreEqual(_context.Algorithms[e.Index].Algorithm.Evaluate(groupHappinessEvaluation), e.GroupHappiness); Assert.AreEqual(_context.Algorithms[e.Index].Algorithm.Evaluate(egalitarianHappinessEvaluation), e.EgalitarianHappiness); }; task = Task.Run(async() => { await runModel.RunSingleAlgorithm(0); Assert.AreEqual(2, receivedEvents); }); }
private void NewModel() { _context = new ModelContext(); SetupModel setupModel = new SetupModel(_context); setupModel.Initialize(); ParticipantsModel participantsModel = new ParticipantsModel(_context); participantsModel.Initialize(); PreferencesModel preferencesModel = new PreferencesModel(_context); preferencesModel.Initialize(); AlgorithmModel algorithmModel = new AlgorithmModel(_context); algorithmModel.Initialize(); algorithmModel.CreateGaleShapleyAlgorithm(); algorithmModel.CreateGeneticAlgorithm(); _model = new RunModel(_context); _model.Initialize(); _context.AlgorithmsChanged = false; }