Due to the popularity of fast food culture,widespread sales of high-sugar foods and unhealthy eating habits,the number of diabetes patients is increasing.To alleviate symptoms,patients need to pay attention to dietary regulation in their daily lives.The recipe recommendation problem can be described as a multi-objective optimization problem that aims to obtain the best recipe recommendation plan based on the proportion of three major nutrients required by diabetes patients while considering the total energy and total quality of food.This paper uses an improved NSGA-Ⅱ algorithm to solve this complex problem and conducts experimental verification and analysis.The main work content is as follows:(1)This paper designs a multi-objective optimization model suitable for diabetic recipe recommendation based on patient’s food needs.The model aims to maximize the total energy and total weight of food while minimizing the error between three nutrients and recommended values under the premise that each index intake does not exceed recommended values.By setting reasonable objective functions and constraint conditions,it improves the efficiency and quality of solving recipe recommendation problems.(2)Based on characteristics of recipe recommendation problems and working principle of genetic algorithms,this paper adopts integer coding to represent individuals and proposes an improved NSGA-Ⅱ algorithm.In binary tournament selection operation,a penalty mechanism is added to reduce probability that previously selected individuals are selected again,enhancing population diversity.In crossover operation,by discretizing genes in real number coding of parent individuals into multiple chromosomes and randomly selecting two chromosomes for two-point partial matching crossover effectively avoids repeated recipe recommendations.In mutation operation,mutation probability is adaptively adjusted according to individual fitness value and mutation degree is adjusted according to evolution generation to accelerate convergence speed.In elite retention strategy a proportional selection mechanism for retaining non-dominated layer individuals is added ensuring population diversity.Through comparative experiments,the improved NSGA-Ⅱ algorithm has increased the diversity of staple foods and dishes by 1.3 times and 2 times respectively compared to the traditional NSGA-Ⅱ algorithm.The average accuracy of energy and nutrients has been improved by 1.02%.(3)This paper introduces the firefly algorithm into the improved NSGA-Ⅱ algorithm,forming a hybrid algorithm.After the improved NSGA-Ⅱ algorithm generates a descendant population,the attractiveness operator and position updating mechanism of the firefly algorithm are used to update the position of individuals in the descendant population,making inferior individuals approach excellent individuals.The updated population is used as a new descendant population and merged with the original parental population.The improved elitist preservation strategy is used to select a new parental population.A comparative experiment was conducted on recipe recommendation problem between the hybrid algorithm and the improved NSGA-Ⅱ algorithm.The results showed that the hybrid algorithm could better balance three objectives,effectively improving the accuracy of the algorithm’s solution.(4)To demonstrate practical application effect of recipe recommendation algorithms this paper developed a simple easy-to-use recipe recommendation tool based on Python’s Flask framework capable of quickly generating recipes meeting patient nutritional standards based on patient input personal information meal type. |