Exemple #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"));
        }
Exemple #2
0
        private static NsgaResult RunConfiguration(Configuration configuration, List <Recipe> recipes, List <PersonalData> personalData)
        {
            var nsgaFactory = new NsgaSolverFactory(new Random());

            var solver = nsgaFactory.GetGroupDietSolver(recipes, personalData, configuration);

            return(solver.Solve());
        }