Recipe optimization method and device based on nutrient intake and storage medium
By constructing a nutrient content equation and optimizing recipes using the Gemma3-27B model and artificial bee colony algorithm, the problem of neglecting personalized nutrient needs in existing technologies has been solved, achieving personalized nutrient intake matching and nutritional balance for users.
Patent Information
- Application Number
- CN202511320604.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-16
- Publication Date
- 2026-01-23
AI Technical Summary
Existing recipe optimization methods are based on user preferences or general health standards, ignoring users' personalized needs for nutrient intake, resulting in optimized recipes that fail to meet users' nutritional requirements.
By constructing equations and constraints based on nutrient content, and using the Gemma3-27B model and artificial bee colony algorithm to optimize recipes, we ensure that the intake of each nutrient is within the range of users' personalized needs. We also construct an optimization objective function to minimize the types of nutrients that do not meet the constraints, thereby achieving personalized matching of recipes.
It achieves precise matching of personalized nutrient intake in recipes, ensuring users achieve a nutritional balance and avoiding the problems of insufficient or excessive nutrient intake caused by general health scoring methods.
Smart Images

Figure CN121393754A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of recipe optimization, in particular to a recipe optimization method and device based on nutrient intake and a computer readable storage medium. BACKGROUND
[0002] With people increasingly recognizing the profound impact of diet on health outcomes, nutrition optimization has become a core in intelligent food systems and personalized health interventions. As individuals take primary responsibility for maintaining a healthy diet and lifestyle, the development of customized food is an important step to achieve a longer and healthier life, and most online recipes currently can only simply prompt users with cooking steps, usually using vague ingredient quantities and thus ignoring the user's nutrient intake needs.
[0003] The prior art proposes a recipe optimization method with user preferences as the main target and a recipe health score as the main target, the former optimizes the existing recipe by introducing a user preference score for the recipe, so that the optimized recipe is more in line with the user's taste, this way meets the user's preference, but ignores whether the nutrient intake of the recipe can meet the user's needs; the latter evaluates the health of the recipe according to multiple indicators such as calories, saturated fat and sodium of the recipe, so as to optimize the recipe to improve the health of the recipe and generate a healthier recipe, this way considers the health of the recipe based on general health standards, but does not consider the individual nutrient intake needs of the user, and does not consider the differences in nutrient intake needs of users of different ages, genders or physical conditions, generating the same recipe for all users, which is difficult to achieve personalized matching of nutrient intake, resulting in different users unable to achieve their own nutritional balance.
[0004] In summary, the existing recipe optimization method optimizes the recipe based on user preferences or general health standards, ignoring the individual needs of users for nutrient intake, resulting in the optimized recipe failing to meet the nutritional needs of the user. SUMMARY
[0005] Therefore, the technical problem to be solved by the present application is to overcome the problem that the existing recipe optimization method optimizes the recipe based on user preferences or general health standards, ignoring the individual needs of users for nutrient intake, resulting in the optimized recipe failing to meet the nutritional needs of the user.
[0006] To solve the above technical problems, the present application provides a recipe optimization method based on nutrient intake, comprising: Obtaining various ingredients and their initial amounts in the recipe to be optimized; constructing a content equation of each nutrient in the to-be-optimized recipe based on the content of each nutrient in each food material and the initial amount of each food material; constructing a nutrient type equation of the to-be-optimized recipe that does not satisfy the constraint based on the content equation of each nutrient in the to-be-optimized recipe, with the content of each nutrient in the to-be-optimized recipe being greater than or equal to the minimum intake amount and less than or equal to the maximum intake amount as the constraint; constructing an optimization objective function of the to-be-optimized recipe with the goal of minimizing the nutrient type in the to-be-optimized recipe that does not satisfy the constraint; solving the optimization objective function to obtain the target amount of each food material in the to-be-optimized recipe, thereby optimizing the to-be-optimized recipe.
[0007] Preferably, solving the optimization objective function to obtain the target amount of each food material in the to-be-optimized recipe includes: Step 1: storing the to-be-optimized recipe to a result buffer and obtaining the amount of each food material and the nutrient content thereof in the to-be-optimized recipe; Step 2: inputting the to-be-optimized objective function, the amount of each food material and the nutrient content thereof in the to-be-optimized recipe, into a Gemma3-27B model, outputting the initial optimization amount of each food material, and obtaining an initial optimization recipe; Step 3: if the number of nutrient types that satisfy the constraint in the initial optimization recipe is greater than the number of nutrient types that satisfy the constraint in the to-be-optimized recipe, obtaining the target amount of each food material in the to-be-optimized recipe based on the initial optimization recipe; Step 4: if the number of nutrient types that satisfy the constraint in the initial optimization recipe is less than or equal to the number of nutrient types that satisfy the constraint in the to-be-optimized recipe, regarding the initial optimization recipe as an invalid recipe; solving the optimization objective function by using an artificial bee colony algorithm based on the upper and lower bounds of the amount of each food material in the to-be-optimized recipe and the nutrient content thereof, to obtain the first optimization amount of each food material, thereby obtaining a first optimization recipe; Step 5: if the number of nutrient types that satisfy the constraint in the first optimization recipe is greater than the number of nutrient types that satisfy the constraint in the to-be-optimized recipe, obtaining the target amount of each food material in the to-be-optimized recipe based on the first optimization recipe; Step 6: if the number of nutrient types that satisfy the constraint in the first optimization recipe is less than or equal to the number of nutrient types that satisfy the constraint in the to-be-optimized recipe, inputting the to-be-optimized objective function, the amount of each food material and the nutrient content thereof in the to-be-optimized recipe, and a prompt word for prompting the model to output an invalid recipe into the Gemma3-27B model, outputting a new initial optimization recipe, and returning to execute Step 3 until the target amount of each food material in the to-be-optimized recipe is obtained.
[0008] Preferably, if the number of nutrient types that satisfy the constraint in the initial optimization recipe is greater than the number of nutrient types that satisfy the constraint in the to-be-optimized recipe, obtaining the target amount of each food material in the to-be-optimized recipe based on the initial optimization recipe includes: Step 3-1: replace the initial optimization recipe as the new to-be-optimized recipe with the to-be-optimized recipe in the result buffer; Step 3-2: input the to-be-optimized objective function, the amount of each food material in the to-be-optimized recipe in the result buffer, the nutrient content of each food material, and the prompt word for prompting the model output to be valid into the Gemma3-27B model, and output a new initial optimization recipe; Step 3-3: if the number of nutrients meeting the constraint in the new initial optimization recipe is greater than the number of nutrients meeting the constraint in the to-be-optimized recipe in the result buffer, replace the new initial optimization recipe as the new to-be-optimized recipe with the to-be-optimized recipe in the result buffer; return to execute step 3-2 until the number of nutrients meeting the constraint in the new initial optimization recipe is less than or equal to the number of nutrients meeting the constraint in the to-be-optimized recipe in the result buffer, and execute step 4.
[0009] Preferably, if the number of nutrients meeting the constraint in the first optimization recipe is greater than the number of nutrients meeting the constraint in the to-be-optimized recipe, the target amount of each food material in the to-be-optimized recipe is obtained based on the first optimization recipe, including: Step 5-1: replace the first optimization recipe as the new to-be-optimized recipe with the to-be-optimized recipe in the result buffer; Step 5-2: input the to-be-optimized objective function, the to-be-optimized recipe in the result buffer, and the prompt word for prompting the model output to be invalid into the Gemma3-27B model, output a new initial optimization recipe, and return to execute step 3.
[0010] Preferably, until the target amount of each food material in the to-be-optimized recipe is obtained, including: When the cumulative number of invalid recipes reaches a preset value, the target amount of each food material in the to-be-optimized recipe is obtained based on the recipes in the result buffer.
[0011] Preferably, the lower bound of the amount of each food material is 0, and the upper bound is twice the initial amount of the food material.
[0012] Preferably, the minimum intake is the recommended intake of the nutrient; and the maximum intake is the maximum tolerable intake of the nutrient.
[0013] Preferably, the equation representing the number of nutrients in the to-be-optimized recipe that do not meet the constraint is: , wherein, represents a variable indicating whether the nth nutrient in the to-be-optimized recipe A meets the constraint; represents the number of food materials in the to-be-optimized recipe; represents the nth food material; represents the nth nutrient in each unit of the nth food material. a content of a nutrient; a first an amount of a food material; a type of nutrient; a first a minimum intake of a nutrient; a first a maximum intake of a nutrient; An optimization objective function of the recipe to be optimized is represented as: , wherein, The optimization objective function of the recipe to be optimized A is represented as.
[0014] The application further provides a recipe optimization device based on nutrient intake, comprising: A data acquisition module is configured to acquire various food materials and initial amounts of the food materials in a recipe to be optimized; A first equation construction module is configured to construct a content equation of various nutrients in the recipe to be optimized based on the content of various nutrients in each food material and the initial amount of each food material; A second equation construction module is configured to construct a nutrient type equation of the recipe to be optimized which does not meet the constraint based on the content equation of various nutrients in the recipe to be optimized, with the constraint that the content of each nutrient in the recipe to be optimized is greater than or equal to a minimum intake and less than or equal to a maximum intake; An objective function construction module is configured to construct an optimization objective function of the recipe to be optimized with the goal of minimizing the type of nutrients in the recipe to be optimized which do not meet the constraint; An optimization module is configured to solve the optimization objective function to obtain a target amount of each food material in the recipe to be optimized, thereby optimizing the recipe to be optimized.
[0015] The application further provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the steps of the recipe optimization method based on nutrient intake.
[0016] The recipe optimization method based on nutrient intake provided by the application has the following beneficial effects: Firstly, by the amount of each food material in the to-be-optimized recipe and the nutrient content, the nutrient content equation of each nutrient in the to-be-optimized recipe is constructed, thereby establishing a direct mapping relationship between the food material content and the final nutrient intake, ensuring that the optimization of the food material content is always targeted at the user's nutrient intake; then, the content of each nutrient within the intake range is taken as a hard constraint, and since the nutrient intake range of different users is different, the user's personalized needs can be ensured when constructing the constraint, so that the nutrient content of the optimized recipe meets the user's personalized intake range, avoiding the problem that the unified optimization of the to-be-optimized recipe by using the general health score method cannot meet the user's personalized needs; finally, the target function is constructed by taking the minimization of the nutrient types that do not meet the constraint as the target, and by solving the target function, as many nutrient contents in the adjusted recipe as possible enter the user's intake range of the nutrient, thereby meeting the user's nutrient intake needs to the greatest extent. The present application optimizes the recipe from the perspective of nutrient intake, and decomposes the personalized nutrient intake needs of different users into quantifiable constraints and targets, and through mathematical modeling and solving, the optimized recipe accurately matches the user's intake needs of various nutrients, thereby achieving the user's required nutritional balance state. BRIEF DESCRIPTION OF DRAWINGS
[0017] In order to make the content of the present application more easily understood, the present application will be further described in detail below according to specific embodiments of the present application and in conjunction with the drawings, in which: Figure 1 A flow chart of the recipe optimization method based on nutrient intake provided by the present application is shown in FIG. 1; Figure 2 A pre-processing schematic diagram of the to-be-optimized recipe provided by the present application is shown in FIG. 2; Figure 3 A schematic diagram of the principle of the recipe optimization based on nutrient intake provided by the present application is shown in FIG. 3; Figure 4 An optimization schematic diagram of the target function provided by the present application is shown in FIG. 4; wherein, Figure 4 (a) in FIG. 4 is an initial optimized recipe schematic diagram output by the Gemma3-27B model, Figure 4 (b) in FIG. 4 is an invalid recipe schematic diagram output by the Gemma3-27B model after introducing the effective prompt word, Figure 4 (c) in FIG. 4 is an initial optimized recipe schematic diagram output by the Gemma3-27B model after introducing the artificial bee colony algorithm and the invalid prompt word, Figure 4 (d) in FIG. 4 is an initial optimized recipe schematic diagram output by the Gemma3-27B model after introducing the invalid prompt word. DETAILED DESCRIPTION
[0018] The application will be further described below in conjunction with the accompanying drawings and specific embodiments so that those skilled in the art can better understand and implement the application, but the embodiments are not limiting of the application.
[0019] Specifically, the present application first collects a large number of recipes and nutrition data from various online resources, and the recipes contain an average of 9 ingredients, each of which contains 19 different nutrients. Using web scraping technology, the present application scrapes data from three food ingredient websites and builds a food nutrient ingredient dataset, resulting in a dataset containing 2,212 different ingredients, each containing 19 different nutrients, including three macronutrients (protein, fat and dietary fiber) and sixteen micronutrients, which are subdivided into six vitamins (vitamin A, vitamin B1, vitamin B2, vitamin B3, vitamin C and vitamin E) and ten minerals (calcium, magnesium, iron, manganese, zinc, copper, potassium, phosphorus, sodium and selenium).
[0020] Referring to Figure 1 , Figure 1 The present application provides a recipe optimization method based on nutrient intake, as shown in the flowchart, which specifically includes: S10: Obtain various ingredients and their initial amounts in the recipe to be optimized.
[0021] Specifically, the present application obtains 9,241 different original recipes by crawling public recipe data and removing duplicates with the same dish name. However, several challenges are faced when calculating the nutritional ingredients of these recipes: (1) ingredient amounts are often expressed in vague terms such as "appropriate amount" or "small amount"; (2) measurement units are mostly non-standard units such as "pieces" and "sticks", rather than standard units such as "grams". To solve these problems and achieve accurate analysis of nutritional ingredients, the present application first uses the natural language understanding capabilities of large models (such as Wenxin Yiyang) to convert ingredient amounts to standard recipes in grams, as shown in Figure 2 .
[0022] During this preprocessing process, the key implementation step is to guide the model to parse and convert the recipe text using prompt words. For example, the following is the prompt word used by the present application to guide the process: "Strictly convert the following ingredient amounts to 'ingredient: grams' format, and leave the rest unchanged. If there is no ingredient amount written, automatically supplement it. Directly output the converted result of the ingredients." Figure 2The content in the left dashed box on the right side of the flowchart is a supplementary explanation of each step of the right side flowchart, taking a to-be-optimized recipe as an example (green beans: appropriate amount; cooked shrimp: some; palace explosion sauce: a small amount; salt: a small amount; sugar: appropriate amount), which is submitted to Wenxin Yiyang. Wenxin Yiyang understands the input content according to the preset prompt word and outputs the corresponding standardized recipe (green beans: 100g; cooked shrimp: 50g; palace explosion sauce: 10g; salt: 2g; sugar: 10g).
[0023] Further, after converting the to-be-optimized recipe into a standard recipe according to the flowchart shown in Figure 2 , a data cleaning step is further applied to process 9,241 standard recipes into 9,152 basic recipes. Data cleaning includes the following operations: first, deleting recipes that lack available food material information. In addition, for standard recipes that lack common cooking oil and salt, "peanut oil: 1.0g" and "salt: 1.0g" are uniformly added at the end of the recipe to improve data consistency. Then, the food material names in the standard recipe are aligned with the entries in the nutrition database, so that the nutritional components of each recipe can be accurately calculated.
[0024] S20: Based on the content of various nutrients in each food material and the initial amount of each food material, an equation for the content of various nutrients in the to-be-optimized recipe is constructed.
[0025] S30: Based on the content equation of various nutrients in the to-be-optimized recipe, the constraint that the content of each nutrient in the to-be-optimized recipe is greater than or equal to the minimum intake and less than or equal to the maximum intake is constructed. The nutrient type equation of the to-be-optimized recipe that does not meet the constraint is constructed.
[0026] Further, the minimum intake is the recommended intake of the nutrient; the maximum intake is the maximum tolerable intake of the nutrient.
[0027] Further, the nutrient type equation that does not meet the constraint in the to-be-optimized recipe is expressed as: , wherein, represents a variable indicating whether the th nutrient in the to-be-optimized recipe A meets the constraint; represents the food material type of the to-be-optimized recipe; represents the content of the th nutrient per unit of the th food material; represents the amount of the th food material; represents the nutrient type; represents the minimum intake of the th nutrient; represents the maximum intake of the a maximum intake of a nutrient.
[0028] The present application assumes that an individual only consumes one dish at a time, and the goal is to convert a general recipe into a personalized version that meets the nutritional needs of the individual. The meal problem can be modeled in a mathematical form to achieve adaptive adjustment of the recipe at the ingredient level, where meal constraints are usually defined by nutrient intake thresholds. For example, according to the Dietary Reference Intakes for Chinese Residents (2023 Edition), for nutrients that have both recommended intake (RNI) and maximum tolerable intake (UL), the target intake range is defined as the interval between the two; for nutrients with only RNI, the acceptable intake range is set to ±10% of RNI; for nutrients with only adequate intake (AI), the acceptable intake range is set to ±10% of AI. Specifically, both RNI and acceptable macronutrient energy supply ratio range (AMDR) are available for protein and fat; in such cases, RNI is taken as the minimum intake requirement, and AMDR is taken as the maximum allowable intake.
[0029] Specifically, the present application determines the nutrient optimization target of each recipe by dividing the daily recommended intake of 19 nutrients by three to reflect the assumption of "three meals a day", and these nutrition targets will vary depending on the age, gender and physical activity level of the population, which is set according to the population classification in the Dietary Reference Intakes for Chinese Residents (2023 Edition). The present application supports dynamic adjustment of the optimization objective function according to individual characteristics such as gender, age, and physical activity level, significantly enhancing the personalized nutrition capability of the system, suitable for a variety of populations and application scenarios, and solving the problem of poor generalization of existing methods.
[0030] S40: An optimization objective function of the recipe to be optimized is constructed with the goal of minimizing the number of nutrients in the recipe to be optimized that do not meet the constraints.
[0031] Further, the optimization objective function of the recipe to be optimized is represented as: , wherein, represents the optimization objective function of the recipe to be optimized A.
[0032] S50: The optimization objective function is solved to obtain the target amount of each ingredient in the recipe to be optimized, thereby optimizing the recipe to be optimized.
[0033] Further, when solving the optimization objective function, the present application introduces Gemma3-27B and artificial bee colony algorithm (ABC) to perform iterative optimization together, as shown in Figure 3 The present application provides a recipe optimization principle based on nutrient intake, Figure 4The optimization of the objective function provided in this application is shown in the figure. Gemma3-27B is a lightweight model in the Google Gemma series with 27 billion parameters, which performs well in tasks such as question answering, summary generation, and reasoning. The size of the artificial bee colony algorithm is set to 10, including three types of individuals: employed bees, onlooker bees, and scout bees. The algorithm runs a maximum of 1000 iterations, with a maximum of 100 attempts for each solution. If no improvement is made within this limit, the solution is discarded and replaced with a randomly generated solution, enhancing the exploration of the solution space.
[0034] Specifically, the specific process of solving the optimization objective function in step S50 includes:
[0035] Step 1: Store the recipe to be optimized in the result buffer and obtain the amount of each ingredient and its nutrient content in the recipe to be optimized.
[0036] Specifically, the 19 nutrients per 100g of each ingredient can be retrieved from the ingredient-nutrient database.
[0037] Step 2: Input the optimization objective function, the amount of each ingredient in the recipe to be optimized, and its nutrient content into the Gemma3-27B model, output the initial optimization amount of each ingredient, and obtain the initial optimization recipe, as shown in (a) of Figure 4
[0038] Specifically, the formula for Gemma3-27B to output the initial optimization recipe is: , where represents the recipe to be optimized, represents the initial optimization recipe generated.
[0039] Step 3: If the number of nutrients meeting the constraints in the initial optimization recipe is greater than that in the recipe to be optimized, obtain the target amount of each ingredient in the recipe to be optimized based on the initial optimization recipe.
[0040] Further, if the number of nutrients meeting the constraints in the initial optimization recipe is greater than that in the recipe to be optimized, obtain the target amount of each ingredient in the recipe to be optimized based on the initial optimization recipe, including: Step 3-1: Replace the recipe to be optimized in the result buffer with the initial optimization recipe as a new recipe to be optimized.
[0041] Step 3-2: input the to-be-optimized objective function, the amount of each food material in the to-be-optimized recipe in the result buffer, the nutrient content of each food material in the to-be-optimized recipe in the result buffer, and the prompt word used to prompt the model output into the Gemma3-27B model, and output a new initial optimization recipe, as shown in (b) of Figure 4 .
[0042] Specifically, based on the nutrient category equation that does not meet the constraint in the to-be-optimized recipe, the application designs a binary validity function to evaluate whether the optimized recipe is a valid recipe, which is specifically represented as:
[0043] wherein, represents the to-be-optimized recipe in the result buffer, represents the optimized recipe (the initial optimization recipe or the first optimization recipe in the application); = 0 indicates that the optimized recipe is valid, that is, B has reduced the nutrient category that does not meet the constraint compared with A; = 1 indicates that the optimized recipe is invalid, and B has failed to reduce the nutrient category that does not meet the constraint.
[0044] Specifically, the formula representation of the Gemma3-27B further outputting the new initial optimization recipe is: wherein, represents the initial optimization recipe, represents the new candidate solution generated. The variable informs that the previous output is valid, which is determined by RelativeValidity(r0, r1) = 0.
[0045] Step 3-3: if the nutrient category that meets the constraint in the new initial optimization recipe is greater than the nutrient category that meets the constraint in the to-be-optimized recipe in the result buffer, the new initial optimization recipe is taken as a new to-be-optimized recipe, and the to-be-optimized optimization recipe in the result buffer is replaced; return to execute step 3-2 until the nutrient category that meets the constraint in the new initial optimization recipe is less than or equal to the nutrient category that meets the constraint in the to-be-optimized recipe in the result buffer, and execute step 4.
[0046] Step 4: if the nutrient category that meets the constraint in the initial optimization recipe is less than or equal to the nutrient category that meets the constraint in the to-be-optimized recipe, the initial optimization recipe is taken as an invalid recipe; based on the upper and lower bounds of the amount of each food material and the nutrient content of each food material in the to-be-optimized recipe, the artificial bee colony algorithm is used to solve the optimization objective function, to obtain the first optimized amount of each food material, thereby obtaining the first optimization recipe.
[0047] Specifically, the artificial bee colony algorithm outputs a formula representation of the first optimized recipe as: , wherein, represents the recipe stored in the result buffer, is the output of the artificial bee colony algorithm.
[0048] Step 5: If the number of nutrient categories satisfying the constraints in the first optimized recipe is greater than the number of nutrient categories satisfying the constraints in the to-be-optimized recipe, obtain the target amount of each food material in the to-be-optimized recipe based on the first optimized recipe.
[0049] Further, if the number of nutrient categories satisfying the constraints in the first optimized recipe is greater than the number of nutrient categories satisfying the constraints in the to-be-optimized recipe in step 5, obtaining the target amount of each food material in the to-be-optimized recipe based on the first optimized recipe comprises: Step 5-1: Replace the to-be-optimized recipe in the result buffer with the first optimized recipe as a new to-be-optimized recipe.
[0050] Step 5-2: Input the to-be-optimized objective function, the to-be-optimized recipe in the result buffer, and the prompt word for prompting the model to output an invalid solution into the Gemma3-27B model, output a new initial optimized recipe, and return to execute step 3, as shown in (c) of Figure 4 .
[0051] Specifically, the Gemma3-27B further outputs a formula representation of the new initial optimized recipe as: , wherein, is the first optimized recipe from the artificial bee colony algorithm, is the new solution generated by the Gemma3-27B, the variable informs that the previous output is invalid, based on RelativeValidity(r0, r1) = 1 or RelativeValidity(r1, r2) = 1.
[0052] Step 6: If the number of nutrient categories satisfying the constraints in the first optimized recipe is less than or equal to the number of nutrient categories satisfying the constraints in the to-be-optimized recipe, input the to-be-optimized objective function, the amount of each food material in the to-be-optimized recipe and its nutrient content, and the prompt word for prompting the model to output an invalid solution into the Gemma3-27B model, output a new initial optimized recipe, and return to execute step 3 until the target amount of each food material in the to-be-optimized recipe is obtained, as shown in (d) of Figure 4 .
[0053] Specifically, Gemma3-27B further outputs a formula representation of the new initial optimization recipe as: , wherein, is the recipe stored in the result buffer, is the new solution generated, the variable again indicates that the previous solution is invalid, based on RelativeValidity(r0, r1) = 1 or RelativeValidity(r1, r2) = 1.
[0054] Specifically, the target amount of each food material in the recipe to be optimized is obtained, including: when the cumulative number of invalid recipes output by the Gemma3-27B model reaches a preset value, the target amount of each food material in the recipe to be optimized is obtained based on the recipes in the result buffer.
[0055] Specifically, the present application integrates Gemma3-27B and artificial bee colony algorithm to realize automatic iterative optimization of recipes. First, Gemma3-27B adjusts the amount of food materials in the recipe to be optimized. If the solution generated by Gemma3-27B is valid, the solution is stored in the result buffer. Thereafter, Gemma3-27B is continuously called through prompt B until an invalid result is output. When Gemma3-27B outputs an invalid result, the artificial bee colony algorithm is called. If the artificial bee colony algorithm further optimizes the recipe, the content of the result buffer is updated, and prompt C is called to guide Gemma3-27B away from the previous invalid output and encourage convergence to the feasible region of the solution space, inspiring Gemma3-27B to further optimize the recipe using its mathematical reasoning potential. Otherwise, prompt D is called to continue optimizing the recipe. This process continues until the cumulative number of invalid solutions of Gemma3-27B reaches a preset number (e.g. 3), and the recipe stored in the result buffer is considered as the best optimized solution. In addition, the present application utilizes the "invalid response counting mechanism" (i.e. Gemma3-27B stops when it continuously generates invalid responses exceeding a threshold) and the "result buffer updating strategy" to form a self-adaptive optimization closed loop, which no longer relies on manual trial and error prompt design, thereby improving the automation degree and efficiency of the prompt optimization process and solving the problem of strong dependence on human experience.
[0056] Figure 4The four prompting strategies shown in the middle are used to guide Gemma3-27B to generate specific structured responses in the recipe optimization scenario, realizing the automatic adjustment of the nutrient target. Prompt A is used to guide Gemma3-27B to perform precise food material adjustment operations in the nutrition optimization task; Prompt B introduces positive feedback signals (“answer valid”) on the basis of Prompt A, simulating a context of “positive evaluation of the last output result”; Prompt C not only introduces negative feedback signals (“answer invalid”), but also informs Gemma3-27B of the effective optimization scheme of the artificial bee colony algorithm, which is designed to guide the model away from previous ineffective outputs and encourage convergence to the feasible region of the solution space. By embedding correction signals and high-quality samples in the prompt at the same time, the exploration range is effectively reduced and the optimization efficiency is improved in the iterative improvement process; Prompt D introduces negative feedback signals (“answer invalid”) to prompt Gemma3-27B that its previous answer has problems, thereby guiding it to perform more stringent rule following or logic checking.
[0057] The above-mentioned recipe optimization method based on nutrient intake is further explained and described below through a specific example, which takes the nutrient target of a male aged 18-29 years with a physical activity level defined in the Dietary Reference Intakes for Nutrients as an example.
[0058] Embodiment 1 of the present application is the personalized nutrition optimization of the recipe “Tofu Soup”: During the personalized nutrition optimization of “Tofu Soup”, the content of Prompt A is as follows: “100 grams of tofu (inner fat) contains thiamine 0.06 mg, calcium 17 mg, protein 5.0 g, riboflavin 0.03 mg, magnesium 24.0 mg, fat 1.9 g, niacin 0.3 mg, iron 0.8 mg, vitamin C 0.0 mg, manganese 0.26 mg, dietary fiber 0.4 g, vitamin E 3.26 mg, zinc 0.55 mg, vitamin A 0.0 μg, copper 0.13 mg, potassium 95 mg, phosphorus 57.0 mg, sodium 6.4 mg, selenium 0.81 μg.
[0059] 100 grams of egg contains thiamine 0.11 mg, calcium 56 mg, protein 13.3 g, riboflavin 0.27 mg, magnesium 10.0 mg, fat 8.8 g, niacin 0.2 mg, iron 2.0 mg, vitamin C 0.0 mg, manganese 0.04 mg, dietary fiber 0.0 g, vitamin E 1.84 mg, zinc 1.1 mg, vitamin A 234.0 μg, copper 0.15 mg, potassium 154 mg, phosphorus 130.0 mg, sodium 131.5 mg, selenium 14.34 μg.
[0060] 100 g of coriander contains thiamine 0.04 mg, calcium 101 mg, protein 1.8 g, riboflavin 0.14 mg, magnesium 33.0 mg, fat 0.4 g, niacin 2.2 mg, iron 2.9 mg, vitamin C 48.0 mg, manganese 0.28 mg, dietary fiber 1.2 g, vitamin E 0.8 mg, zinc 0.45 mg, vitamin A 0.0 μg, copper 0.21 mg, potassium 272 mg, phosphorus 49.0 mg, sodium 48.5 mg, selenium 0.53 μg.
[0061] 100 g of ham contains thiamine 0.28 mg, calcium 3 mg, protein 16.0 g, riboflavin 0.09 mg, magnesium 20.0 mg, fat 27.4 g, niacin 8.6 mg, iron 2.2 mg, vitamin C 0.0 mg, manganese 0.04 mg, dietary fiber 0.0 g, vitamin E 0.8 mg, zinc 2.16 mg, vitamin A 46.0 μg, copper 0.08 mg, potassium 220 mg, phosphorus 90.0 mg, sodium 1086.7 mg, selenium 2.95 μg.
[0062] 100 g of pork (lean) contains thiamine 0.54 mg, calcium 6 mg, protein 20.3 g, riboflavin 0.1 mg, magnesium 25.0 mg, fat 6.2 g, niacin 5.3 mg, iron 3.0 mg, vitamin C 0.0 mg, manganese 0.03 mg, dietary fiber 0.0 g, vitamin E 0.34 mg, zinc 2.99 mg, vitamin A 44.0 μg, copper 0.11 mg, potassium 305 mg, phosphorus 189.0 mg, sodium 57.5 mg, selenium 9.5 μg.
[0063] 100 g of corn starch contains thiamine 0.03 mg, calcium 18 mg, protein 1.2 g, riboflavin 0.04 mg, magnesium 6.0 mg, fat 0.1 g, niacin 1.1 mg, iron 4.0 mg, vitamin C 0.0 mg, manganese 0.05 mg, dietary fiber 0.1 g, vitamin E 0.0 mg, zinc 0.09 mg, vitamin A 0.0 μg, copper 0.07 mg, potassium 8 mg, phosphorus 25.0 mg, sodium 6.3 mg, selenium 0.7 μg.
[0064] 100 grams of refined salt contains thiamine 0.0 mg, calcium 22 mg, protein 0.0 g, riboflavin 0.0 mg, magnesium 2.0 mg, fat 0.0 g, niacin 0.0 mg, iron 1.0 mg, vitamin C 0.0 mg, manganese 0.29 mg, dietary fiber 0.0 g, vitamin E 0.0 mg, zinc 0.24 mg, vitamin A 0.0 μg, copper 0.14 mg, potassium 14 mg, phosphorus 0.0 mg, sodium 39311.0 mg, selenium 1.0 μg.
[0065] 100 grams of peanut oil contains thiamine 0.0 mg, calcium 12 mg, protein 0.0 g, riboflavin 0.0 mg, magnesium 2.0 mg, fat 99.9 g, niacin 0.0 mg, iron 2.9 mg, vitamin C 0.0 mg, manganese 0.33 mg, dietary fiber 0.0 g, vitamin E 42.06 mg, zinc 0.48 mg, vitamin A 0.0 μg, copper 0.15 mg, potassium 1 mg, phosphorus 15.0 mg, sodium 3.5 mg, selenium 0.0 μg.
[0066] For (tofu (inner fat): 400.0 grams, egg: 50.0 grams, coriander: 10.0 grams, ham: 50.0 grams, pork (lean): 50.0 grams, corn starch: 25.0 grams, salt: 1.0 grams, peanut oil: 1.0 grams), the adjustment strategy of nutrients is as follows: thiamine decreases by 0.25 mg, the addition amount of calcium is between 151.23 mg to 551.23 mg, the addition amount of protein is between -23.61 g to -9.45 g, riboflavin increases by 0.09 mg, magnesium decreases by 18.34 mg, the addition amount of fat is between -13.93 g to -5.96 g, the addition amount of niacin is between -3.75 mg to 2.92 mg, the addition amount of iron is between -4.13 mg to 5.87 mg, the addition amount of vitamin C is between 28.53 mg to 661.87 mg, the addition amount of manganese is between 0.36 mg to 2.52 mg, the addition amount of dietary fiber is between 6.59 g to 8.25 g, the addition amount of vitamin E is between -10.36 mg to 218.30 mg, the addition amount of zinc is between -1.40 mg to 7.93 mg, the addition amount of vitamin A is between 94.67 mcg to 838.00 mcg, the addition amount of copper is between -0.46 mg to 1.94 mg, potassium decreases by 82.18 mg, the addition amount of phosphorus is between -203.80 mg to 722.87 mg, sodium decreases by 563.02 mg, the addition amount of selenium is between 3.13 mcg to 116.46 mcg. Please change the ingredient amount of (tofu (inner fat): 400.0 grams, egg: 50.0 grams, coriander: 10.0 grams, ham: 50.0 grams, pork (lean): 50.0 grams, corn starch: 25.0 grams, salt: 1.0 grams, peanut oil: 1.0 grams). The output only contains food material name and amount.
[0067] As shown in Table 1 is the recipe content of the recipe to be optimized "Tofu Soup" at different stages: Table 1
[0068] Table 1 shows the recipe content of the dish "Tofu Soup" at different stages, the original recipe includes: one box of inner fat tofu, one egg, two roots of chives or coriander, one ham, a small piece of lean meat, and a small bowl of cornstarch. Based on this, the personalized results generated by the method provided in the present application are: tofu (inner fat): 250.0 g, egg: 75.0 g, coriander: 20.0 g, ham: 25.0 g, pork (lean): 75.0 g, cornstarch: 50.0 g, salt: 0.5 g, peanut oil: 0.5 g. According to the nutrient analysis, the nutrients in the basic recipe that meet the recommended intake include: niacin, iron, vitamin E, zinc, copper, and phosphorus; while in the optimized recipe, the nutrients that meet the standard increase to: riboflavin, magnesium, fat, niacin, iron, vitamin E, zinc, copper, potassium, phosphorus, and selenium, covering more key trace elements and lipid nutrients.
[0069] Example 2 of the present application optimizes the nutrition of the recipe "Enoki Mushroom Egg Soup": During the process of individualized nutrition optimization of "Enoki Mushroom Egg Soup", the content of prompt A is as follows: "100 grams of Enoki mushrooms contain thiamine 0.15 mg, calcium 0 mg, protein 2.4 g, riboflavin 0.19 mg, magnesium 17.0 mg, fat 0.4 g, niacin 0.0 mg, iron 1.4 mg, vitamin C 2.0 mg, manganese 0.1 mg, dietary fiber 2.7 g, vitamin E 1.14 mg, zinc 0.39 mg, vitamin A 0.0 μg, copper 0.14 mg, potassium 195 mg, phosphorus 97.0 mg, sodium 4.3 mg, selenium 0.28 μg.
[0070] 100 grams of egg contains thiamine 0.11 mg, calcium 56 mg, protein 13.3 g, riboflavin 0.27 mg, magnesium 10.0 mg, fat 8.8 g, niacin 0.2 mg, iron 2.0 mg, vitamin C 0.0 mg, manganese 0.04 mg, dietary fiber 0.0 g, vitamin E 1.84 mg, zinc 1.1 mg, vitamin A 234.0 μg, copper 0.15 mg, potassium 154 mg, phosphorus 130.0 mg, sodium 131.5 mg, selenium 14.34 μg.
[0071] 100 g of green onions contains thiamine 0.03 mg, calcium 29 mg, protein 1.7 g, riboflavin 0.05 mg, magnesium 19.0 mg, fat 0.3 g, niacin 0.5 mg, iron 0.7 mg, vitamin C 17.0 mg, manganese 0.28 mg, dietary fiber 1.3 g, vitamin E 0.3 mg, zinc 0.4 mg, vitamin A 10.0 μg, copper 0.08 mg, potassium 144 mg, phosphorus 38.0 mg, sodium 4.8 mg, selenium 0.67 μg.
[0072] 100 g of ginger contains thiamine 0.02 mg, calcium 27 mg, protein 1.3 g, riboflavin 0.03 mg, magnesium 44.0 mg, fat 0.6 g, niacin 0.8 mg, iron 1.4 mg, vitamin C 4.0 mg, manganese 3.2 mg, dietary fiber 2.7 g, vitamin E 0.0 mg, zinc 0.34 mg, vitamin A 0.0 μg, copper 0.14 mg, potassium 295 mg, phosphorus 25.0 mg, sodium 14.9 mg, selenium 0.56 μg.
[0073] 100 g of coriander contains thiamine 0.04 mg, calcium 101 mg, protein 1.8 g, riboflavin 0.14 mg, magnesium 33.0 mg, fat 0.4 g, niacin 2.2 mg, iron 2.9 mg, vitamin C 48.0 mg, manganese 0.28 mg, dietary fiber 1.2 g, vitamin E 0.8 mg, zinc 0.45 mg, vitamin A 0.0 μg, copper 0.21 mg, potassium 272 mg, phosphorus 49.0 mg, sodium 48.5 mg, selenium 0.53 μg.
[0074] 100 g of soy sauce contains thiamine 0.02 mg, calcium 16 mg, protein 4.8 g, riboflavin 0.11 mg, magnesium 29.0 mg, fat 0.1 g, niacin 1.08 mg, iron 2.7 mg, vitamin C 0.0 mg, manganese 0.29 mg, dietary fiber 0.0 g, vitamin E 0.0 mg, zinc 0.45 mg, vitamin A 0.0 μg, copper 0.08 mg, potassium 342 mg, phosphorus 59.0 mg, sodium 6385.0 mg, selenium 1.3 μg.
[0075] 100 grams of refined salt contains thiamine 0.0 mg, calcium 22 mg, protein 0.0 g, riboflavin 0.0 mg, magnesium 2.0 mg, fat 0.0 g, niacin 0.0 mg, iron 1.0 mg, vitamin C 0.0 mg, manganese 0.29 mg, dietary fiber 0.0 g, vitamin E 0.0 mg, zinc 0.24 mg, vitamin A 0.0 μg, copper 0.14 mg, potassium 14 mg, phosphorus 0.0 mg, sodium 39311.0 mg, selenium 1.0 μg.
[0076] 100 grams of sesame oil contains thiamine 0.0 mg, calcium 9 mg, protein 0.0 g, riboflavin 0.0 mg, magnesium 3.0 mg, fat 99.7 g, niacin 0.0 mg, iron 2.2 mg, vitamin C 0.0 mg, manganese 0.76 mg, dietary fiber 0.0 g, vitamin E 68.53 mg, zinc 0.17 mg, vitamin A 0.0 μg, copper 0.05 mg, potassium 0 mg, phosphorus 4.0 mg, sodium 1.1 mg, selenium 0.0 μg.
[0077] For (maitake mushrooms: 300.0 grams, eggs: 100.0 grams, green onions: 15.0 grams, ginger: 10.0 grams, cilantro: 10.0 grams, soy sauce: 7.5 grams, salt: 15.0 grams, sesame oil: 2.5 grams), the adjustment strategy for nutrients is as follows: thiamine decreases by 0.11 mg, calcium added between 188.79 mg and 588.79 mg, protein added between 0.24 g and 14.41 g, riboflavin decreases by 0.41 mg, magnesium increases by 35.90 mg, fat added between 3.29 g and 11.26 g, niacin added between 4.34 mg and 11.01 mg, iron added between -3.14 mg and 6.86 mg, vitamin C added between 19.58 mg and 652.92 mg, manganese added between 0.69 mg and 2.85 mg, dietary fiber added between -0.35 g and 1.31 g, vitamin E added between -2.43 mg and 226.24 mg, zinc added between 1.52 mg and 10.85 mg, vitamin A added between 21.17 mcg and 764.50 mcg, copper added between -0.38 mg and 2.02 mg, potassium decreases by 178.38 mg, phosphorus added between -198.62 mg and 728.04 mg, sodium decreases by 6027.01 mg, selenium added between 4.36 mcg and 117.70 mcg. Please change the ingredient amount of (maitake mushrooms: 300.0 grams, eggs: 100.0 grams, green onions: 15.0 grams, ginger: 10.0 grams, cilantro: 10.0 grams, soy sauce: 7.5 grams, salt: 15.0 grams, sesame oil: 2.5 grams). The output only contains the food name and amount.
[0078] As shown in Table 2, the recipe content of the recipe to be optimized "Maitake Mushroom Egg Soup" at different stages is shown: Table 2
[0079] Table 2 shows the recipe content of the dish "mushroom egg soup" at different stages, the original recipe includes: 300 grams of mushroom, 2 eggs, 3-5 centimeters of green onion, 2 pieces of ginger, 3-5 roots of coriander, 1 / 2 tablespoon of soy sauce, 3 spoons of salt, 5 drops of sesame oil. Based on this, the personalized result generated by the method provided in the application is: mushroom: 200.0 grams, egg: 150.0 grams, green onion: 30.0 grams, ginger: 20.0 grams, coriander: 20.0 grams, soy sauce: 5.0 grams, salt: 5.0 grams, sesame oil: 5.0 grams. According to the nutrient analysis, the nutrients in the basic recipe that meet the recommended intake include: iron, dietary fiber, vitamin E, copper, and phosphorus; and in the optimized recipe, the nutrients that meet the standard increase to: thiamine, protein, fat, iron, vitamin E, vitamin A, copper, phosphorus, and selenium.
[0080] Based on the recipe optimization method based on nutrient intake provided in the above embodiments, the embodiments of the application also provide a recipe optimization device based on nutrient intake, which specifically includes: A data acquisition module is configured to acquire various food materials and their initial amounts in a recipe to be optimized.
[0081] A first equation construction module is configured to construct an equation of the content of various nutrients in the recipe to be optimized based on the content of various nutrients in each food material and the initial amount of each food material.
[0082] A second equation construction module is configured to construct an equation of the type of nutrients that do not meet the constraint in the recipe to be optimized based on the equation of the content of various nutrients in the recipe to be optimized, with the constraint that the content of each nutrient in the recipe to be optimized is greater than or equal to the minimum intake and less than or equal to the maximum intake.
[0083] A target function construction module is configured to construct an optimization target function of the recipe to be optimized with the goal of minimizing the type of nutrients that do not meet the constraint in the recipe to be optimized.
[0084] An optimization module is configured to solve the optimization target function to obtain a target amount of each food material in the recipe to be optimized, thereby optimizing the recipe to be optimized.
[0085] The embodiments of the application also provide a computer readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the recipe optimization method based on nutrient intake described above.
[0086] The recipe optimization method based on nutrient intake provided in the application sets a prompt optimization mechanism of the large language model Gemma3-27B and the artificial bee colony algorithm, guides the large language model Gemma3-27B to automatically generate personalized prompts that can meet the nutritional goals of different users by mathematical modeling of personalized nutrition problems and introducing a constraint mechanism based on a nutritional objective function, and further designs a multi-round dialogue prompt generation strategy to guide the model to move away from previous ineffective outputs using the global search solving capability of the artificial bee colony algorithm and converge to the feasible region of the solution space, gradually adjust the amount of ingredients, and realize the progressive optimization of the recipe in the nutritional structure. In addition, an adaptive prompt optimization closed-loop mechanism based on performance evaluation is constructed in the optimization process, which can automatically judge the optimization effect and adjust the subsequent prompt content; at the same time, a personalized matching degree index is proposed to quantitatively evaluate the consistency between the recipe generated by Gemma3-27B or the artificial bee colony algorithm and the nutritional needs of the target user, so as to realize the closed-loop iteration of prompt generation and nutritional optimization. In addition, the scheme provided in the application has good modularity and model decoupling capability, the prompt generation module is designed to be pluggable, allowing to be replaced by large language models of different structures or scales (such as Gemma3-27B, LLaMA, GPT, Qwen, etc.), to adapt to differences in computing resources, task requirements or deployment environment, support prompt generation and output in a multi-language environment (such as Chinese, English, Japanese, etc.), and automatically switch to the applicable nutritional reference intake standards (such as different countries' nutrient intake guidelines) according to the user's location, realizing the generation of localized nutritional recommendations across cultures and regions.
[0087] Those skilled in the art will appreciate that embodiments of the application can be supplied as methods, systems, or computer program products. Accordingly, the application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the application can take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage media, etc.) having computer-usable program code embodied in the medium.
[0088] The application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the application. It should be understood that each flow and / or block in the flowcharts and / or block diagrams, and the combination of the flows and / or blocks in the flowcharts and / or block diagrams can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing devices produce a device that implements the flowcharts and / or block diagrams. Figure 1 Each flow or multiple flows and / or blocks Figure 1apparatuses that implement the functions specified in the individual block or multiple blocks.
[0089] These computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture including instructions which implement the flow Figure 1 the individual flow or multiple flows and / or blocks Figure 1 the functions specified in the individual block or multiple blocks.
[0090] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the flow Figure 1 the individual flow or multiple flows and / or blocks Figure 1 the functions specified in the individual block or multiple blocks.
[0091] Obviously, the above-described embodiments are only examples and are not intended to limit the present application. Based on the above description, one of ordinary skill in the art can make other variations and changes without departing from the present application. It is not necessary or possible to enumerate all the embodiments. The obvious variations and changes derived therefrom are still within the scope of the present application.
Claims
1. A recipe optimization method based on nutrient intake, characterized by, The method comprises the following steps: acquiring various food materials and their initial amounts in the recipe to be optimized; constructing a content equation of various nutrients in the recipe to be optimized based on the content of various nutrients in each food material and the initial amount of each food material; constructing a nutrient type equation of the recipe to be optimized that does not meet the constraint based on the content equation of various nutrients in the recipe to be optimized, with the constraint being that the content of each nutrient in the recipe to be optimized is greater than or equal to the minimum intake amount and less than or equal to the maximum intake amount; constructing an optimization objective function of the recipe to be optimized with the goal of minimizing the nutrient types in the recipe to be optimized that do not meet the constraint; solving the optimization objective function to obtain the target amount of each food material in the recipe to be optimized, thereby optimizing the recipe to be optimized.
2. The recipe optimization method based on nutrient intake amount according to claim 1, characterized in that, Solving the optimization objective function to obtain the target amount of each food material in the recipe to be optimized comprises the following steps: Step 1: storing the recipe to be optimized into a result buffer and acquiring the amount of each food material and its nutrient content in the recipe to be optimized; Step 2: inputting the optimization objective function, the amount of each food material and its nutrient content in the recipe to be optimized into a Gemma3-27B model to output the initial optimization amount of each food material and obtain an initial optimization recipe; Step 3: if the number of nutrient types that meet the constraint in the initial optimization recipe is greater than the number of nutrient types that meet the constraint in the recipe to be optimized, obtaining the target amount of each food material in the recipe to be optimized based on the initial optimization recipe; Step 4: if the number of nutrient types that meet the constraint in the initial optimization recipe is less than or equal to the number of nutrient types that meet the constraint in the recipe to be optimized, regarding the initial optimization recipe as an invalid recipe; solving the optimization objective function by using an artificial bee colony algorithm based on the upper and lower bounds of the amount of each food material and its nutrient content to obtain the first optimization amount of each food material and thereby obtain a first optimization recipe; Step 5: if the number of nutrient types that meet the constraint in the first optimization recipe is greater than the number of nutrient types that meet the constraint in the recipe to be optimized, obtaining the target amount of each food material in the recipe to be optimized based on the first optimization recipe; Step 6: if the number of nutrient types that meet the constraint in the first optimization recipe is less than or equal to the number of nutrient types that meet the constraint in the recipe to be optimized, inputting the optimization objective function, the amount of each food material and its nutrient content in the recipe to be optimized, and a prompt word for prompting the model to output an invalid result into the Gemma3-27B model to output a new initial optimization recipe and return to Step 3 until the target amount of each food material in the recipe to be optimized is obtained.
3. The recipe optimization method based on nutrient intake amount according to claim 2, characterized in that, If the number of nutrient types that meet the constraint in the initial optimization recipe is greater than the number of nutrient types that meet the constraint in the recipe to be optimized, obtaining the target amount of each food material in the recipe to be optimized based on the initial optimization recipe comprises the following steps: Step 3-1: replacing the recipe to be optimized in the result buffer with the initial optimization recipe as a new recipe to be optimized; Step 3-2: inputting the optimization objective function, the amount of each food material and its nutrient content in the recipe to be optimized in the result buffer, and a prompt word for prompting the model to output a valid result into the Gemma3-27B model to output a new initial optimization recipe; Step 3-3: If the number of nutrients meeting the constraint in the new initial optimization recipe is greater than the number of nutrients meeting the constraint in the optimization recipe in the result buffer, the new initial optimization recipe is taken as a new optimization recipe, and the optimization recipe in the result buffer is replaced; return to execute step 3-2 until the number of nutrients meeting the constraint in the new initial optimization recipe is less than or equal to the number of nutrients meeting the constraint in the optimization recipe in the result buffer, and step 4 is executed.
4. The recipe optimization method based on nutrient intake amount according to claim 3, characterized in that, If the number of nutrients meeting the constraint in the first optimization recipe is greater than the number of nutrients meeting the constraint in the optimization recipe, the target amount of each food material in the optimization recipe is obtained based on the first optimization recipe, including: Step 5-1: The first optimization recipe is taken as a new optimization recipe to replace the optimization recipe in the result buffer; Step 5-2: The optimization target function, the optimization recipe in the result buffer, and the prompt word for prompting the invalid model output are input into the Gemma3-27B model, and a new initial optimization recipe is output, and step 3 is returned to execute.
5. The recipe optimization method based on nutrient intake amount according to claim 4, characterized in that, Until the target amount of each food material in the optimization recipe is obtained, including: When the cumulative number of invalid recipes reaches a preset value, the target amount of each food material in the optimization recipe is obtained based on the recipe in the result buffer.
6. The recipe optimization method based on nutritional intake amount according to claim 2, characterized in that, The lower bound of the amount of each food material is 0, and the upper bound is twice the initial amount of the food material.
7. The recipe optimization method based on nutrient intake amount according to claim 1, characterized in that, The minimum intake is the recommended intake of the nutrient; the maximum intake is the maximum tolerable intake of the nutrient.
8. The recipe optimization method based on nutrient intake amount according to claim 1, characterized in that, The equation of the nutrient type not meeting the constraint in the optimization recipe is represented as: , in, This indicates the first item in recipe A that needs optimization. Variables indicating whether a nutrient satisfies the constraints; This indicates the types of ingredients in the recipe that need to be optimized; Indicates the first Each type of food ingredient in each unit of measurement The content of various nutrients; Indicates the first The amount of each ingredient used; Indicates the types of nutrients; Indicates the first Minimum intake of each nutrient; Indicates the first The maximum intake of a certain nutrient; The optimization target function of the optimization recipe is represented as: , wherein, represents an optimization objective function of the recipe A to be optimized.
9. A recipe optimization apparatus based on nutrient intake, characterized by, Including: The data acquisition module is configured to acquire various food materials and their initial amounts in the optimization recipe; The first equation construction module is configured to construct the content equation of each nutrient in the optimization recipe based on the content of each nutrient in each food material and the initial amount of each food material; The second equation construction module is configured to construct the equation of the nutrient type not meeting the constraint in the optimization recipe based on the content equation of each nutrient in the optimization recipe, with the constraint that the content of each nutrient in the optimization recipe is greater than or equal to the minimum intake and less than or equal to the maximum intake; The target function construction module is configured to construct the optimization target function of the optimization recipe with the goal of minimizing the number of nutrient types not meeting the constraint in the optimization recipe; The optimization module is configured to solve the optimization target function to obtain the target amount of each food material in the optimization recipe, thereby optimizing the optimization recipe.
10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is executed by the processor to implement the steps of the recipe optimization method based on the nutrient intake according to any one of claims 1-8.
Citation Information
Cited By
Campus recipe disassembly accounting method and system
CN122173576A