Beispiel #1
0
        public ActionResult GenerateSummary()
        {
            var personalData = TempData.GetPersonalDataList();

            personalData.ForEach(pd => pd.Requirements = _requirementsProvider.GetRequirements(pd, 5));
            var bannedSubCategories  = GetBannedSubCategories();
            var bannedMainCategories = GetBannedMainCategories();

            var recipes = _recipeProvider.GetRecipes().Where(r => !bannedMainCategories.Contains(r.MainCategory) && !bannedSubCategories.Contains(r.SubCategory)).ToList();

            TempData.SavePersonalDataList(personalData);
            var nsgaSolver = _nsgaSolverFactory.GetGroupDietSolver(recipes, personalData, TempData.GetSettings().NsgaConfiguration);

            var nsgaResult = nsgaSolver.Solve();

            TempData.SaveLog(nsgaResult.Log);
            TempData.SaveNsgaResult(nsgaResult);

            var viewModelBuilder = new GroupDietViewModelBuilder();

            var dietsViewModel = viewModelBuilder.Build(nsgaResult, personalData);

            TempData.SaveGroupDietsResultViewModel(dietsViewModel);

            return(RedirectToAction("Summary"));
        }
Beispiel #2
0
        public void T1()
        {
            var groupDiet = GetDiet();
            var pd        = new List <PersonalData> {
                GetPersonalData(0), GetPersonalData(1)
            };
            var individual = new GroupDietIndividual(groupDiet);

            var ev = new GroupDietEvaluator(pd, new GroupDietAnalyzer());

            ev.Evaluate(individual);

            var builder = new GroupDietViewModelBuilder();
            var nsgRes  = new NsgaResult();

            nsgRes.Fronts.Add(new List <Individual> {
                individual
            });

            var vm = builder.Build(nsgRes, pd);

            vm.GroupDiets.First().Evaluations.First().Score.Should().Be(250);
        }