Machine learning-based menu planning scheme optimization generation method and system
By constructing a multi-dimensional basic dataset for meal planning and hierarchical coding, and combining multi-objective optimization and preference prediction models, the problem of combining food inventory and cost constraints with nutritionist preferences in group meal supply systems was solved, and efficient and flexible meal planning solutions were generated.
Patent Information
- Application Number
- CN202611142640.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-30
- Publication Date
- 2026-11-03
AI Technical Summary
In existing technologies, group meal supply systems fail to effectively combine operational constraints such as food inventory and cost budgets. Optimization targets are limited to single nutritional indicators, failing to balance inventory turnover and category diversity. Furthermore, they lack the ability to learn nutritionist preferences from historical data, making it difficult to balance recommended solutions among multiple objectives. This necessitates frequent manual adjustments and results in a low adoption rate.
By acquiring a multi-dimensional basic dataset for meal planning that includes dish information, ingredient information, inventory data, and historical records, a hierarchical coding structure is established. Combined with multi-objective optimization algorithms and preference prediction models, meal planning schemes that take into account nutrition, cost, inventory, and category diversity are optimized and generated.
It achieves a flexible balance between nutrition, cost, inventory, and category diversity, improving the practicality and adoption rate of meal planning programs. The system can adapt to changes in nutritionist preferences, reducing manual adjustments.
Smart Images

Figure CN123032044A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of machine learning technology, and in particular to a method and system for optimizing and generating meal planning schemes based on machine learning. Background Technology
[0002] Group catering scenarios such as school cafeterias, corporate restaurants, and hospital nutrition departments require the periodic development of nutritionally balanced, cost-effective, and easily implemented meal plans. Traditional methods rely on nutritionists manually creating plans based on experience. Faced with hundreds of dishes and dozens of ingredients, it's difficult to simultaneously address multiple needs, including achieving nutritional goals, managing inventory, controlling costs, and ensuring menu diversity. With the development of information technology, automated meal planning systems based on optimization algorithms are beginning to be applied to support decision-making.
[0003] In existing technologies, CN115798684A discloses a multi-stage nutritional meal planning system for smart school canteens. This system builds a meal planning rule base and a food tag base, and uses the NSGA-III algorithm for dish pairing and nutritional analysis to achieve multi-stage recipe recommendations. However, this solution does not incorporate real-time ingredient inventory as a constraint during the generation process, leading to the possibility that some recommended dishes may be unavailable due to ingredient shortages, requiring manual adjustments. Furthermore, its optimization objective primarily focuses on the achievement of nutritional indicators, failing to incorporate operational indicators such as ingredient costs and inventory turnover rate into the optimization framework, making it difficult to achieve a balance between nutrition and operational efficiency. CN115359869A discloses a dietary nutrition matching method based on multi-objective optimization. This method sets constraints and objective functions for a multi-objective optimization function, combining an ingredient scoring mechanism to solve for ingredient selection. This method also ignores dynamic constraints on ingredient inventory and cost budget limitations, and its optimization objective does not cover the uniformity of dish category coverage, potentially leading to excessive repetition of dish categories in recommended solutions within a week. Furthermore, both of these approaches lack a mechanism to learn from historical meal planning records and the nutritionist's personalized preferences. Each meal planning session requires resetting the rules or adjusting the plan, making it impossible to continuously improve the adoption rate and practicality of the recommended plan over time. Summary of the Invention
[0004] This application provides a method and system for optimizing and generating meal plans based on machine learning. It improves upon the existing technologies where the meal plan generation process relies heavily on static rules, fails to incorporate operational constraints such as ingredient inventory and cost budgets into the search framework, limits optimization targets to single nutritional indicators while ignoring inventory turnover and category diversity, and cannot learn nutritionist preferences from historical adoption data. This results in recommended plans being frequently manually adjusted due to their disconnect from actual operations and having a low adoption rate.
[0005] This application discloses the following technical solution: Firstly, this application provides a method for optimizing and generating meal planning schemes based on machine learning, the method comprising: Obtain a basic dataset for meal preparation, wherein the basic dataset for meal preparation includes dish information data and ingredient information data, and each dish in the dish information data is associated with a dish category label; Based on the dish information data and the ingredient information data, the weekly meal plan to be generated is encoded into a hierarchical structure encoding result, which includes a dish category encoding layer and an ingredient encoding layer. Based on the inventory information and nutritional standards in the basic meal planning data, multidimensional constraints are established. Using the encoding results as optimization variables, the multidimensional constraints as feasibility constraints, and the optimization objectives of maximizing nutrition scores, minimizing ingredient costs, maximizing inventory turnover rate, and maximizing the uniformity of dish category coverage, a multi-objective optimization algorithm is used for iterative search to obtain a set of Pareto optimal meal planning schemes. A preference prediction model is trained using historical meal planning records in the basic meal planning data. The preference prediction model is used to predict the probability of a corresponding solution being adopted based on the multi-objective features of the solution, including dish category preference features. The preference prediction model selects the option with the highest preference score from the Pareto optimal meal plan set as the recommended meal plan.
[0006] Secondly, this application provides a meal planning optimization and generation system based on machine learning, the system comprising: The data acquisition module is used to acquire the basic dataset for meal preparation, wherein the basic dataset for meal preparation includes dish information data and ingredient information data, and each dish in the dish information data is associated with a dish category label; The scheme coding module is used to encode the weekly meal plan to be generated into a hierarchical structure coding result based on the dish information data and the ingredient information data. The hierarchical structure coding result includes a dish category coding layer and an ingredient coding layer. The constraint establishment module is used to establish multi-dimensional constraints based on the inventory information and nutritional standards in the basic meal planning data. The multi-objective optimization module is used to use the encoding result as the optimization variable, the multi-dimensional constraints as the feasibility constraints, and the optimization objectives of maximizing the nutrition score, minimizing the ingredient cost, maximizing the inventory turnover rate, and maximizing the uniformity of the dish category coverage. It uses a multi-objective optimization algorithm to perform iterative search to obtain a set of Pareto optimal meal planning schemes. The preference learning module is used to train a preference prediction model using historical meal records in the basic meal planning data. The preference prediction model is used to predict the probability of a corresponding solution being adopted based on the multi-objective features of the solution, including dish category preference features. The solution recommendation module is used to select the solution with the highest preference score from the Pareto optimal meal plan set using the preference prediction model as the recommended meal plan.
[0007] One or more technical solutions provided in this application have at least the following technical effects or advantages: This application's technical solution utilizes a machine learning-based method for optimizing and generating meal planning schemes. First, it acquires a multi-dimensional meal planning dataset containing dish information, ingredient information, inventory data, nutritional reference standards, and historical meal planning records. Each dish is associated with multi-level classification labels, integrating end-to-end data from raw material supply status and detailed dish composition to historical decision feedback, thus constructing a comprehensive and standardized data foundation. This approach links the range of available dishes, the quantity of available ingredients, and nutrient reference standards within the same data framework, providing a unified input for subsequent coding, constraints, and optimization. Simultaneously, the introduction of historical meal planning records provides supervisory signals for preference learning. This method changes the traditional approach of meal planning systems that rely solely on a static dish database and ignore real-time inventory information. It solves the technical problems in existing technologies where, due to limited data dimensions and the failure to incorporate ingredient inventory as a precondition, automatically generated schemes cannot be implemented due to material shortages, requiring repeated manual adjustments.
[0008] Furthermore, by dividing the weekly meal planning cycle into multiple meal units, assigning dish combinations to each meal, and associating dishes with ingredient names and quantities, a three-layer hierarchical coding structure is established, from the meal unit level to the dish category coding layer and then to the ingredient coding layer. The dish category coding layer records the category labels of the dishes selected for each meal, facilitating the statistical analysis and control of the even distribution of major food categories; the ingredient coding layer specifies the exact ingredients and quantities for each dish, supporting daily summary calculations of nutrition and cost. This structured coding transforms the abstract weekly meal planning scheme into a mathematical entity that can directly participate in genetic operator operations, enabling the optimization algorithm to simultaneously control meal time scheduling, dish category diversity, and ingredient granular consumption at three levels. This solves the technical problem of traditional single-level coding, which cannot simultaneously consider macro-level category control and micro-level material accounting during optimization, resulting in low search efficiency and difficulty in ensuring scheme diversity.
[0009] Furthermore, based on the ingredient inventory data, nutritional reference standards, dish category labels, and ingredient unit prices in the aforementioned meal planning dataset, inventory constraints, nutritional constraints, dish category coverage constraints, and cost constraints are established. The inventory constraint stipulates that the total weekly demand for all ingredients in any candidate solution must be less than or equal to its current inventory quantity; the nutritional constraint requires that the intake of each nutrient per meal day fall within the range recommended by dietary guidelines; the category coverage constraint specifies the minimum number of dish label types that must be covered within a week, and the frequency of the same label must not exceed a threshold; the cost constraint controls the total weekly ingredient cost below the budget limit. By quantifying the above business rules into explicit mathematical inequality boundaries, a realistic and feasible solution search space is constructed, effectively filtering out solutions that do not conform to operational realities. This solves the technical problems of traditional meal planning optimization algorithms ignoring inventory dynamics and cost budgets, and generating solutions that frequently reach material ceilings or exceed budgets, resulting in low adoption rates.
[0010] Furthermore, using the hierarchical coding results as optimization variables, within the feasible region satisfying multidimensional constraints, a multi-objective optimization algorithm is employed for iterative search, with four optimization objectives: maximizing the comprehensive nutrition score, minimizing the total weekly ingredient cost, maximizing the average inventory turnover rate, and maximizing the dish category coverage uniformity score. The nutrition score is obtained by calculating and weighting the degree to which energy, protein, and vitamins for each meal day meet the recommended intake range; the inventory turnover rate encourages prioritizing the consumption of high-inventory or near-expiry materials; and the category coverage uniformity is calculated based on the variance of the distribution of the frequency of each label across all meals. Through non-dominated sorting and elite retention mechanisms, the algorithm explores Pareto optimal trade-offs without pre-setting objective weights, ultimately outputting a set of non-dominated solutions with varying emphases on nutrition, cost, inventory, and diversity. This provides nutritionists with a diverse and high-quality selection space, solving the technical problem that traditional single-objective or fixed-weight optimization can only produce a single solution and cannot demonstrate flexible trade-offs among multiple operational indicators.
[0011] Furthermore, a preference prediction model is trained using historical meal planning records. For each historical weekly meal planning scheme, its nutritional score, ingredient cost, inventory turnover rate, category coverage evenness score, and dish category distribution vector are extracted as multi-objective feature vectors. Whether the scheme is actually adopted is used as a supervision signal, and a random forest algorithm is employed to learn the mapping relationship between features and adoption probabilities. The trained model can output the adoption probability for any candidate scheme, comprehensively reflecting the nutritionist's implicit preferences in terms of nutritional composition, cost control, inventory utilization, and category combination. Through a data-driven approach, subjective and difficult-to-express selection experience is transformed into a quantifiable preference function, solving the technical problems of existing technologies that require manual rule setting or re-selection of schemes for each meal planning session, and the lack of system capabilities to automatically learn from historical decisions and reproduce personalized meal planning styles.
[0012] Finally, the preference prediction model iterates through the Pareto-optimal meal planning scheme set, calculates the adoption probability of each scheme, selects the scheme with the highest preference score as the recommended meal planning scheme, and simultaneously outputs decision explanation information, including the satisfaction of constraints in each dimension, the category coverage evenness score, and the quantitative changes in nutritional score, ingredient cost, inventory turnover rate, and category coverage evenness compared to the current scheme, making the recommendation reasons transparent and verifiable. Simultaneously, the system receives user modifications to the recommended scheme, automatically calculates the multi-objective features of the modified scheme, generates incremental training samples, and incrementally learns the preference prediction model to quickly adapt to the latest preference changes. This closed-loop mechanism realizes a complete link from recommendation generation and explanation feedback to model evolution, solving the technical problems of the black box recommendation process and the inability of the model to adapt to the dynamic evolution of decision-makers' preferences in traditional meal planning systems.
[0013] In summary, this application integrates multi-source data, including dishes, ingredients, inventory, and historical meal planning, to transform weekly meal planning schemes into a structured representation that balances category distribution and ingredient consumption. Under multi-dimensional constraints of inventory, nutrition, category, and cost, it optimizes multiple schemes with a focus on achieving nutritional goals, cost savings, inventory utilization, and category diversity. Simultaneously, it learns the implicit preferences of nutritionists from historical adoption records, automatically selecting the optimal scheme from the candidate set and continuously evolving through feedback. This method overcomes the problems of automated meal planning schemes being detached from operational realities, struggling to balance multiple objectives, and failing to adapt to personalized preferences, thus improving the technical issues of insufficient practicality and adoption efficiency of meal planning schemes in group catering scenarios. Attached Figure Description
[0014] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0015] Figure 1 A flowchart illustrating the machine learning-based meal planning optimization generation method provided in this application embodiment.
[0016] Figure 2 A flowchart illustrating the Pareto optimal meal planning scheme generation process of the machine learning-based meal planning scheme optimization generation method provided in this application embodiment.
[0017] Figure 3 This is a schematic diagram of the structure of the machine learning-based meal planning optimization generation system provided in the embodiments of this application.
[0018] In the attached diagram, Figure 3The components represented by each number are explained as follows: Data acquisition module 11, scheme coding module 12, constraint establishment module 13, multi-objective optimization module 14, preference learning module 15, and scheme recommendation module 16. Detailed Implementation
[0019] This application provides a machine learning-based method and system for optimizing and generating meal plans. It addresses the technical problem in existing intelligent meal planning systems for group catering that, due to the lack of comprehensive utilization of inventory constraint modeling, multi-operational objective collaborative optimization, and decision-maker preference machine learning, the automatically generated plans are difficult to balance between nutrition, cost, and inventory utilization, and cannot continuously evolve with user feedback to better match personalized meal planning styles.
[0020] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application. It should be noted that the numerical values in the embodiments are for illustrative purposes only and do not constitute a limitation on this application.
[0021] Example 1, as shown in the appendix Figure 1 As shown, this application provides a method for optimizing and generating meal planning schemes based on machine learning, the method comprising the following steps: S100: Obtain the basic dataset for meal preparation, wherein the basic dataset for meal preparation includes dish information data and ingredient information data, and each dish in the dish information data is associated with a dish classification label.
[0022] In this embodiment of the application, in the scenario of group catering, in order to generate an executable weekly meal plan, it is necessary to obtain multi-dimensional data including dish information, ingredient information, inventory data, nutritional standards and historical records, and construct a basic meal planning dataset covering dish attributes, ingredient composition, inventory status and adoption feedback, so as to provide a unified data input for subsequent coding, constraint establishment and optimization search.
[0023] The method provided in this application embodiment obtains a basic meal planning dataset, including: obtaining a dish information dataset, wherein any dish information data in the dish information dataset includes a dish name, a dish category label, and a list of dish ingredients, and the dish category label is at least one level label in a pre-configured multi-level classification label system; obtaining an ingredient information dataset, wherein any ingredient information data in the ingredient information dataset includes an ingredient name, an ingredient number, and an ingredient nutrient content table; and obtaining an ingredient inventory dataset, wherein any ingredient inventory data in the ingredient inventory dataset includes an ingredient name, an ingredient number, and a current inventory list. The system stores quantity and shelf-life information of ingredients; obtains a nutritional reference standard dataset, which includes recommended daily intakes of energy, protein, fat, carbohydrates, vitamin A, vitamin C, and sodium; and obtains a historical meal planning record dataset, where each historical meal planning record includes a historical weekly meal planning scheme, a distribution vector of the corresponding dish category, a multi-objective feature vector, and a label indicating whether the scheme was actually adopted. Detailed explanation follows: In this embodiment, the dish information dataset refers to a structured data set containing attribute information of all available dishes within the system. Each dish records its name, corresponding category label, and a complete list of ingredients, serving as the source library for dish selection in the meal planning scheme. The dish category label is a category identifier for each dish, belonging to a predefined hierarchical labeling system. First-level labels can include major categories such as staple foods, side dishes, soups, and fruits. Second-level labels are further subdivided under staple foods into noodles, rice dishes, porridge, etc., and under side dishes into meat dishes, vegetarian dishes, semi-meat dishes, etc. The column headings for noodles, porridge, and side dishes in the system interface are specific examples of dish category labels. Through multi-level labels, the diversity of dishes can be controlled at different granularities during scheme generation. The ingredient information dataset is a standardized data table indexed by ingredient names. Each record contains the standardized name of the ingredient, a unique number, and the content of nutrients such as energy, protein, fat, carbohydrates, vitamin A, vitamin C, and sodium per 100 grams of ingredient. In addition, this dataset also contains ingredient unit price information, used to calculate the ingredient cost of the scheme, serving as the underlying basis for calculating the nutritional indicators and ingredient costs of the scheme.
[0024] The food inventory dataset records the real-time availability and status of each food ingredient in the current warehouse. The current inventory quantity is a dynamic value in grams, and the expiration date of each batch of ingredients is marked. This information is used to construct inventory feasibility constraints and provide a basis for optimizing inventory turnover. The nutrition reference standard dataset sets daily recommended values and acceptable ranges for various indicators based on dietary nutrient reference intakes. The recommended daily energy intake is typically 2000 kcal to 2400 kcal, and the recommended daily protein intake is 60g to 80g, serving as a benchmark for judging whether a meal plan meets nutritional standards. The historical meal plan record dataset is a sample set composed of previously generated weekly meal plan records. The dish category distribution vector counts the frequency of each dish category label during the week. The multi-objective feature vector includes quantitative evaluation values such as the nutritional score, ingredient cost, inventory turnover rate, and dish category coverage evenness score of the plan. Labels are taken from the operation system records; if the plan is confirmed and published by a nutritionist, it is marked as 1 to indicate adoption; otherwise, it is marked as 0 to indicate non-adoption.
[0025] In this step, firstly, in order to establish a reliable dish selection space for subsequent optimization and to ensure that the category attributes of each dish can serve diversity control, it is necessary to export the complete dish data table that has been maintained from the recipe management module of the meal preparation backend. The accuracy of the dish name and category label is verified one by one to ensure that each dish is associated with at least one primary or secondary label. For dishes with missing labels, the labels are added by rule matching or manual labeling. At the same time, the names and standard quantities of the ingredients contained in each dish are listed one by one, so as to obtain a complete and accurately labeled dish information dataset.
[0026] Next, to support the calculation of total nutrient intake and total ingredient cost for any candidate plan from the perspective of ingredients, a standard ingredient information table needs to be retrieved from the ingredient management module. The standardized name, unique number, and nutrient content per 100 grams of each ingredient are verified one by one, and a fast mapping table is established from ingredient number to nutrient content vector, resulting in an ingredient information dataset covering all available ingredients. After obtaining the ingredient information, to ensure the feasibility of the subsequently generated plans at the material level, a real-time ingredient inventory database needs to be connected via an application programming interface (API). The current inventory quantity of each ingredient is queried using its ingredient number as an index, and the shelf life information of each batch is extracted simultaneously. The total effective inventory is then summarized according to the first-in, first-out (FIFO) principle, resulting in an ingredient inventory dataset reflecting the current inventory dynamics.
[0027] Subsequently, in order to establish the evaluation criteria for the nutritional rationality of the plan, a pre-set nutritional reference standard dataset needs to be read from the static library configured in the system. This dataset sets the daily recommended intake of seven core nutrients and the acceptable range of fluctuation based on the dietary guidelines. For example, the daily recommended intake range of energy is 2000 kcal to 2400 kcal, and the range of protein is 60g to 80g. It also allows for parameter adjustments for different dining groups, thus obtaining a standard dataset for subsequent nutritional constraints and scoring.
[0028] Finally, in order for the system to learn personalized preferences from the nutritionist's historical behavior, it is necessary to extract the execution records of meal planning plans over a period of time from the operations management module, analyze the distribution vector of the dish categories for each historical plan, calculate or read the values of various evaluation indicators at that time, and extract the operation mark of the final confirmation and release in the system as a binary label of whether it is adopted. After sorting, a historical meal planning record dataset containing features and labels can be obtained.
[0029] In summary, this step, by collecting dish attributes and classification tags, ingredient nutrient content, real-time inventory quantity and shelf life, recommended dietary intake standards, and historical plan adoption records from the dish library, ingredient library, inventory system, nutritional standards, and historical operation records, forms a basic dataset for meal planning that covers all elements of supply and demand. This provides a unified data input for subsequent hierarchical coding representation, multi-dimensional constraint establishment, multi-objective optimization search, and preference prediction model training.
[0030] S200: Based on the dish information data and the ingredient information data, the weekly meal plan to be generated is encoded into a hierarchical structure encoding result, which includes a dish category encoding layer and an ingredient encoding layer.
[0031] In this embodiment of the application, given that a basic dataset for meal planning containing dish information and ingredient information has already been constructed, in order to further transform the abstract weekly meal planning scheme into a structured mathematical representation that can be directly operated by multi-objective optimization algorithms, it is necessary to design an encoding method that simultaneously covers the order of meal times, dish category attributes, and ingredient consumption details. This is to solve the problem that traditional scheme representations often use simple lists or one-dimensional vectors, which only record the dish code for each meal and do not include the food category label to which the dish belongs and the underlying ingredient usage in a unified encoding framework. This results in subsequent optimization searches being unable to control the diversity of dishes at the category level, nor being able to summarize nutritional intake and costs daily at the ingredient level, making it difficult to simultaneously consider the macroscopic rationality of the combination and the microscopic computability of materials in the scheme generation.
[0032] Step S200 of the method provided in this application embodiment includes: dividing a weekly meal preparation cycle into multiple meal units; configuring each meal unit as a combination of dishes that selects at least one dish from the dish information dataset; associating each dish with the corresponding ingredient name and quantity in the dish ingredient list, establishing a three-layer coding structure from the meal unit to the dish combination and then to the ingredient composition, wherein the first layer of the three-layer coding structure is the meal layer, the second layer is the dish category coding layer, and the third layer is the ingredient coding layer, obtaining the hierarchical structure coding result. A detailed explanation follows: In this embodiment, a meal unit refers to the basic time unit for each meal service within a weekly meal preparation cycle. It is divided into 15 units based on the three meals (breakfast, lunch, and dinner) from Monday to Friday, serving as the time-division nodes for the meal preparation scheme. Whether weekends and extra meals are included can be flexibly configured according to actual meal needs; by default, only weekday meals are covered. A dish combination refers to the entire set of dishes allocated to a single meal unit. Each meal by default includes at least one staple food dish and one side dish. The total number of dishes is adjustable between 2 and 5 depending on the number of diners and the food standard. The number of dishes in different meal units is allowed to differ. The dish category coding layer is a three-layer coding structure that specifically records the classification labels corresponding to the selected dishes in each meal unit. The labels are taken from a pre-set multi-level classification label system in the dish information dataset. This layer allows for the statistical analysis of the frequency and variance of each label across all meals within a week, providing a calculable numerical basis for subsequent control of dish diversity and category coverage uniformity.
[0033] The ingredient coding layer is the third layer in the three-layer coding structure, used to record the specific names and quantities of ingredients used in each dish. Each dish is associated with multiple ingredients in the ingredient list and their standard quantities. This layer summarizes the total amount of each ingredient consumed in all meals throughout the week, providing detailed ingredient-by-ingredient data for nutritional intake calculations and ingredient cost accounting, in grams. The hierarchical coding structure is a whole composed of the meal layer, dish category coding layer, and ingredient coding layer, which are sequentially linked. The layers are mapped to each other through a unique dish identifier: the meal layer records the list of identifiers for the dishes selected in each meal unit; the category coding layer queries the category tags based on the dish identifiers and accumulates the occurrence count of each tag; the ingredient coding layer expands the ingredient list based on the dish identifiers and adds the quantities of each ingredient to the vector position of the corresponding ingredient number, ultimately forming a fixed-dimensional data structure that can be directly manipulated by optimization algorithms.
[0034] In this step, to expand the weekly meal schedule along a time dimension and enable the optimization search to distinguish different meal periods and perform independent operations and comparisons on each meal period, it is first necessary to determine the coverage of the meal distribution cycle and define basic orchestration nodes. Using the default meal service calendar, breakfast, lunch, and dinner from Monday to Friday are taken, with each meal period considered a meal period unit, resulting in 15 ordered meal period units, numbered sequentially from Meal Period 1 to Meal Period 15, forming the meal period layer skeleton of the coding structure. This division method clearly defines the granularity and coverage of meal periods. In the actual system, administrators are allowed to modify the number of meal service days and the number of meals per day through the configuration interface, but the coding logic remains consistent.
[0035] Next, to assign specific dishes to each meal unit, dishes need to be selected from the dish information dataset to form a dish combination for each meal. The selection must follow basic pairing rules: each meal must include at least one staple food dish and one side dish to ensure a reasonable meal structure. The selection method can be probabilistic sampling from historical high-frequency combinations or random initialization to provide an initial solution for subsequent optimization iterations. Each position in the meal level stores a list of dish identifiers, with the list length equal to the number of dishes selected for that meal. The list length can vary between different meals.
[0036] Furthermore, to explicitly express the category attributes of dishes in the encoding, enabling the optimization algorithm to directly perceive and control dish diversity during the search process, after the dish combination is determined, it is necessary to query the classification label associated with each dish in the dish information dataset one by one, and fill the label encoding into the category encoding layer. If a multi-level labeling system is adopted, first-level and second-level labels can be recorded simultaneously, or only first-level labels can be counted according to management needs. In specific implementation, the category encoding layer is an integer vector with a length equal to the total number of category labels. It iterates through all dishes in all 15 meal units, incrementing the label of each dish by 1 at the corresponding position in the vector, and finally obtaining a dish category distribution count vector.
[0037] Finally, to support the accurate calculation of total weekly nutritional intake and total food cost from the perspective of ingredients, the ingredient composition of each dish needs to be expanded to the lowest level of the coding structure. For each dish, its ingredient composition list is queried to obtain the names of the included ingredients and their corresponding standard quantities. The quantity values are then accumulated in the position corresponding to the ingredient number in the ingredient coding layer. The ingredient coding layer is a floating-point vector with a length equal to the total number of ingredient types, initially all zeros. After traversing all meals and all dishes, each element in the vector represents the total weekly quantity of the corresponding ingredient. This design solves the problems of traditional planar coding, which cannot directly extract detailed ingredient consumption from the optimized individual and requires frequent queries to external databases, resulting in low search efficiency. At the same time, by accumulating the quantities into a fixed-dimensional vector, the coding dimension is kept consistent across different schemes, facilitating crossover and mutation operations by genetic operators.
[0038] Thus, by constructing the meal order layer, category coding layer, and ingredient coding layer layer one by one, and linking the three into a whole through dish identifiers, a hierarchical coding result is obtained. Each coding result uniquely corresponds to a complete weekly meal plan, which can be directly used as an individual in the optimization algorithm population to participate in subsequent selection, crossover, and mutation operations.
[0039] In summary, this step organizes the weekly meal planning scheme into a three-layer coding structure, from meal number to dish category to ingredient quantity, allowing the optimization variables to simultaneously carry three types of information: meal sequence, category distribution, and ingredient consumption details. Compared with existing technologies, this step has the following advantages: First, by making the dish category label an independent coding layer, the category distribution can be directly calculated and constrained during the optimization process, solving the problem that traditional list-based coding cannot explicitly control dish diversity and is prone to serious category duplication within a week; Second, by sinking the ingredient quantity to the bottom layer of the coding structure and unifying it into a fixed-dimensional vector, nutritional scores and cost accounting can be performed directly on the coded individuals without repeatedly parsing external data, while ensuring that different individuals can perform unified cross-mutation operations, solving the problem that traditional coding only records dish codes, leading to frequent data table lookups, low search efficiency, and inability to guarantee the executability of the plan's materials during optimization searches.
[0040] S300: Based on the inventory information and nutritional standards in the basic meal planning data, establish multidimensional constraints.
[0041] In this embodiment, given that the basic meal planning dataset has been obtained and the weekly meal planning scheme has been encoded into a hierarchical structure, in order to ensure that the subsequent multi-objective optimization search is only carried out within the space of realistically executable schemes, it is necessary to establish constraints covering multiple dimensions such as ingredient inventory, daily nutritional intake, dish category coverage, and ingredient cost. This addresses the problem that existing meal planning optimization methods typically only set simple total nutritional constraints, without incorporating real-time ingredient inventory, the diversity of dish category coverage, and the upper limit of cost budget into a unified feasibility judgment framework. This results in the search-generated schemes frequently touching the actual operational red lines such as material shortages, excessive category duplication, or budget overruns. Although the schemes theoretically meet the nutritional calculation standards, they require significant manual adjustments before execution, resulting in low automation.
[0042] Step S300 of the method provided in this application embodiment includes: establishing inventory constraints based on the ingredient inventory dataset, wherein the inventory constraints limit the total weekly demand of all ingredients for any candidate meal planning scheme to be less than or equal to the current inventory quantity of the corresponding ingredients in the ingredient inventory dataset; establishing nutritional constraints based on the nutritional reference standard dataset, wherein the nutritional constraints limit the daily nutritional indicators of any candidate meal planning scheme to be within the recommended range of the nutritional reference standard dataset; establishing dish category coverage constraints based on the dish category tags of the dish information dataset, wherein the dish category coverage constraints limit the number of dish category tags covered by any candidate meal planning scheme within a week meal planning cycle to be greater than or equal to a preset minimum coverage threshold, and the number of times the same dish category tag appears in all meal units does not exceed a preset maximum number of times the category appears; establishing cost constraints based on the ingredient nutrient content table of the ingredient information dataset and the dish ingredient composition list of the dish information dataset, wherein the cost constraints limit the total weekly ingredient cost of any candidate meal planning scheme to be less than or equal to a preset weekly cost upper limit threshold. Detailed explanation follows: In this embodiment, the inventory constraint refers to a hard boundary that limits the total weekly consumption of each ingredient in the candidate meal plan to no more than the available inventory of that ingredient in the current stock. This is used to screen out plans that cannot be prepared due to ingredient shortages from a material perspective. The nutritional constraint refers to the constraint that the intake of each nutrient in the candidate meal plan on each meal day must fall within the recommended intake range specified by the Dietary Reference Intakes. The feasible range for each nutrient is usually 80% to 120% of the recommended value. Each nutrient is subject to independent constraints, and all constraints must be met.
[0043] The dish category coverage constraint is a combination of two constraints set from the perspective of dish diversity. First, the minimum number of covered categories constraint requires that the number of different dish category labels appearing within a weekly meal preparation cycle must not be less than a preset lower limit. Second, the maximum number of times a category appears requires that the cumulative number of times the same dish category label appears across all meal units must not exceed a preset upper limit. These constraints prevent imbalances in category distribution from both breadth and frequency perspectives. The preset minimum number of covered categories threshold refers to the lower limit of the number of different dish category labels that should be included within a week. This threshold is determined based on the canteen's meal management requirements and the statistical distribution of category coverage in historical meal preparation plans, and is typically set to 8. Counting is based on primary labels; if the system is configured to use secondary labels, then the count is based on secondary labels.
[0044] The preset maximum frequency threshold for a category refers to the upper limit of the maximum cumulative number of times the same dish category label is allowed to appear in all 15 meal units of a week. This threshold is set by considering the balance between the total number of meals and the number of categories to be covered, and is usually set to 10 times to avoid a certain type of dish, such as noodles, appearing too frequently and causing a monotonous dining experience. The cost constraint refers to the constraint that the total procurement cost of all ingredients for the candidate meal plan within a week does not exceed the preset weekly cost budget limit. The cost of ingredients is obtained by summing the total consumption of each ingredient for the whole week multiplied by its unit price. The preset weekly cost limit threshold can be calculated by referring to the per capita food cost standard multiplied by the number of diners and then multiplied by the number of days of meal service. For example, if the cost is 15 yuan per person per day, 100 people are dining, and the meal service is provided for 5 days, then the weekly cost limit threshold is set to 7,500 yuan.
[0045] In this step, to ensure the generated meal plan can be implemented without being rejected due to ingredient shortages, inventory constraints need to be established based on the collected ingredient inventory dataset. Specifically, for each ingredient's total weekly consumption summarized in the ingredient coding layer of the hierarchical coding result, the total weekly consumption of each ingredient is compared with its current inventory in the ingredient inventory dataset. The total weekly consumption of each ingredient must be less than or equal to its current inventory. If the consumption of any ingredient exceeds its current inventory, the candidate plan corresponding to that coding result is deemed infeasible. By upgrading ingredient inventory from a simple data collection dimension to a hard criterion for plan feasibility, this solves the problem of traditional methods failing to verify inventory, leading to material shortages only being discovered during the actual preparation stage, requiring nutritionists to readjust the dish composition.
[0046] Furthermore, to ensure that each meal service day meets dietary guidelines at the nutritional level and to avoid situations where a single meal day has a severe deficiency or excess of a particular nutrient while the weekly average barely meets the standard, it is necessary to establish daily nutritional constraints based on the nutritional reference standard dataset. For the total amount of food consumed in all meals of each day in the candidate scheme, the nutrient content table of the food ingredients is used to calculate the total intake of each nutrient for that day. The daily intake of seven indicators—energy, protein, fat, carbohydrates, vitamin A, vitamin C, and sodium—is compared with the recommended intake range in the nutritional reference standard dataset, requiring that each indicator fall within 80% to 120% of the recommended intake. The method of using independent daily constraints instead of a weekly average is adopted because excessive daily fluctuations in nutrient intake also violate dietary guidelines. Daily verification ensures the stability of the nutritional quality of the scheme and solves the problem that traditional methods, which only constrain the weekly average, lead to significant deviations from the standards for some meal days.
[0047] Meanwhile, to avoid overly concentrated dish categories in the meal planning scheme and diners repeatedly encountering similar dishes throughout the week, it is necessary to establish dish category coverage constraints based on the dish classification labels in the dish information dataset. By traversing the occurrence of various labels recorded in the category coding layer of the hierarchical structure coding results, the total number of different classification labels appearing within a week's meal planning cycle is counted, requiring that the number of different label types be greater than or equal to a preset minimum coverage threshold. Simultaneously, the cumulative occurrence count of each classification label across all 15 meal units is counted, requiring that the occurrence count of any single label not exceed a preset maximum occurrence count threshold for that category. The combined use of these two thresholds ensures both the breadth of dish categories used and the diversification experienced by diners, while limiting excessive repetition of a single category. This solves the problem of traditional methods lacking category diversity constraints and optimization algorithms favoring the repeated selection of a few high-value dishes in pursuit of nutritional or cost goals, leading to a monotonous dining experience.
[0048] Finally, to control the economic feasibility of the meal planning scheme, cost constraints need to be established based on the unit price information of ingredients and the list of ingredients in the ingredient information dataset. For the total weekly consumption of each ingredient summarized in the ingredient coding layer of the hierarchical structure coding results, multiply each ingredient by its purchase unit price, sum the costs of all ingredients to obtain the total weekly ingredient cost, and compare this value with a preset weekly cost upper limit threshold, requiring the total weekly ingredient cost to be less than or equal to this threshold. The unit price of ingredients can be obtained from the ingredient information dataset; if no unit price is entered, the reference price in the system configuration is used by default. The cost upper limit threshold is preset according to operational standards and can be flexibly adjusted by the meal planner according to the weekly budget in actual use. By incorporating cost constraints as a hard boundary into the search, it ensures that all candidate solutions are within the budgetable range, solving the problem of traditional methods that optimize first and then price, resulting in a large number of solutions being discarded due to exceeding the budget.
[0049] In summary, this step establishes hard constraints from four dimensions: ingredient inventory, nutritional standards, dish categories, and ingredient costs. This quantifies business rules into clear mathematically feasible domain boundaries, ensuring that all candidate solutions generated by subsequent multi-objective optimization meet actual operational requirements in terms of material feasibility, nutritional rationality, category diversity, and economic feasibility. Compared to existing technologies, this step has the following advantages: First, by incorporating real-time ingredient inventory as a hard constraint into the optimization, it prevents solutions that cannot be executed due to stock shortages from entering the candidate set, solving the inefficiency problem caused by post-event adjustments in traditional methods. Second, by adding a dish category coverage constraint, it ensures the diversity of meal plans and the dining experience through dual control of the minimum number of covered categories and the maximum frequency of occurrence, solving the problem of highly repetitive dish categories in traditional optimization results. Third, by establishing nutritional constraints on a daily basis rather than a weekly average, it ensures the stability of daily nutritional quality and eliminates the risk of excessive fluctuations in nutritional levels within a week.
[0050] S400: Using the encoding result as the optimization variable, the multidimensional constraints as the feasibility constraints, and the optimization objectives of maximizing the nutrition score, minimizing the ingredient cost, maximizing the inventory turnover rate, and maximizing the uniformity of the dish category coverage, a multi-objective optimization algorithm is used for iterative search to obtain a set of Pareto optimal meal planning schemes.
[0051] In this embodiment, based on the established multidimensional constraints and the hierarchical structure coding results as optimization variables, in order to simultaneously meet multiple operational requirements such as nutritional compliance, cost control, efficient inventory utilization, and balanced dish category matching, it is necessary to jointly optimize four conflicting objectives within the feasible domain and search for a set of balanced solutions representing different emphases. This process aims to solve the problem that existing meal planning optimization methods often use single-objective or fixed-weighted summation methods, which combine multiple objectives into a composite function, failing to present the true trade-off relationship between different operational indicators. Furthermore, the search process lacks explicit measurement of the uniformity of solution category distribution and protective operations on the coding structure, resulting in severe homogenization of output solutions or imbalanced category distribution. Nutritionists can only passively accept a single solution and cannot flexibly choose the best among multiple dimensions.
[0052] The process of generating the Pareto optimal meal plan set based on the multi-objective optimization algorithm in this step is as follows: Figure 2 As shown.
[0053] Step S400 of the method provided in this application embodiment includes: initializing an algorithm population, wherein the algorithm population contains N individuals, each individual being a hierarchical structure encoding result; performing a feasibility check on each individual in the algorithm population, marking individuals that do not satisfy any one of the multidimensional constraints as infeasible solutions and removing them from the algorithm population; for each feasible solution that passes the feasibility check, calculating the nutritional score, ingredient cost, inventory turnover rate, and dish category coverage uniformity score corresponding to the feasible solution, wherein the dish category coverage uniformity score is based on feasibility... The variance of the distribution of each dish category label in all meal units is calculated. With the optimization directions of maximizing the nutritional score, minimizing the ingredient cost, maximizing the inventory turnover rate, and maximizing the dish category coverage uniformity score, a non-dominated sorting genetic algorithm is used to perform selection, crossover, and mutation operations on the algorithm population to generate a new generation of algorithm population. Feasibility verification, multi-objective calculation, and population iteration steps are repeatedly executed until a preset convergence condition is met to obtain the final algorithm population. All non-dominated individuals in the final algorithm population are extracted to form the Pareto optimal meal planning scheme set.
[0054] Furthermore, the crossover operation adopts a segmented crossover method based on meal units, exchanging the dish combinations of the same meal unit in two parent individuals, including: selecting a first parent individual and a second parent individual from the algorithm population; randomly selecting at least one target meal unit from multiple meal units; exchanging the dish combination of the target meal unit in the first parent individual with the dish combination of the target meal unit in the second parent individual to generate a first child individual and a second child individual; wherein, after the exchange, it is verified whether the dish category coverage uniformity score of the first child individual and the second child individual is not lower than the dish category coverage uniformity score of their respective parent individuals, and if not, the exchange operation is canceled.
[0055] Furthermore, the mutation operations include three types: dish replacement mutation, meal exchange mutation, and ingredient quantity adjustment mutation. Specifically: the dish replacement mutation involves randomly selecting a dish from a meal unit within the target individual and replacing it with another dish from the dish information dataset that shares the same dish category label; the meal exchange mutation involves randomly selecting two different meal units within the target individual and exchanging all dish combinations from those two meal units; the ingredient quantity adjustment mutation involves randomly selecting a dish from the target individual and increasing or decreasing the quantity of a certain ingredient in that dish according to a preset adjustment step size. After performing the dish replacement mutation, the uniformity score of the dish category coverage of the target individual after replacement is checked to ensure it is not lower than the uniformity score of the dish category coverage of the target individual before replacement. If this condition is not met, the dish replacement mutation operation is cancelled. Detailed explanations are as follows: In this embodiment, feasibility verification refers to checking each candidate solution in the population to see if it simultaneously meets the four types of constraints: inventory constraints, nutritional constraints, dish category coverage constraints, and cost constraints. If any one of these constraints fails, the individual is marked as an infeasible solution and removed from the current population, ensuring that subsequent operations are only performed within the feasible domain. Nutritional scoring quantifies the solution's performance in the nutritional dimension. It is calculated as follows: for each meal day in the solution, the daily intake of seven nutrients is calculated based on the daily consumption of each ingredient and the nutrient content table. Each intake is compared with the corresponding recommended intake range in the nutritional reference standard dataset. If the intake falls within 90% to 110% of the recommended intake range, the item receives full marks; if it is below 80% of the lower limit or above 120% of the upper limit, the item receives zero marks; if the intake is between 80% and 90% of the lower limit or between 110% and 120% of the upper limit, points are deducted linearly according to the excess. Then, the scores for each nutrient on each meal day are weighted, summed, and normalized to a percentage score according to preset weights. The weights for energy, protein, fat, carbohydrates, vitamin A, vitamin C, and sodium are 0.20, 0.20, 0.15, 0.15, 0.10, 0.10, and 0.10, respectively. The linear deduction rule is: for every percentage point deviation from the 90% to 110% range boundary, 10% of the full score for that item is deducted. Ingredient cost refers to the sum of all ingredient consumption in a week multiplied by their corresponding unit price, in yuan, obtained directly by multiplying the quantity of each ingredient in the ingredient coding layer by its unit price in the ingredient information dataset and then summing the results.
[0056] Inventory turnover rate measures the efficiency of a meal preparation plan in utilizing current inventory. Its optimization aims to guide the plan to prioritize and fully utilize existing inventory, especially for ingredients with significant overstocking or nearing their expiration date, thereby reducing food holding costs and the risk of spoilage due to expiration. Specifically, for each ingredient k in the ingredient information dataset, its initial inventory quantity is obtained. and remaining shelf life days Define its single ingredient turnover urgency coefficient. The shorter the shelf life, the higher the urgency. Then, the inventory turnover rate for the entire solution corresponding to any feasible solution is... ,in, This represents the total weekly consumption of ingredient k under this scheme. The inventory consumption ratio of the ingredient, weighted and summed with the urgency coefficient, comprehensively reflects the consumption level and turnover urgency of various ingredients in the plan. The dish category coverage evenness score is an indicator reflecting the degree of balance in the distribution of dish labels across different meal units in the plan. It is calculated as follows: Let the total number of dish category labels be L, and count the total number of times each label appears in all meal units. Calculate the variance of these L degree values. ,in Average value Then the uniformity score The closer the score is to 1, the smaller the difference in the frequency of occurrence of various tags and the more even the distribution. The closer it is to 0, the more likely that a very small number of tags are repeatedly used while the rest of the tags rarely appear.
[0057] The non-dominated sorting genetic algorithm is the multi-objective optimization framework used in this step. The algorithm iteratively evolves by maintaining a population of size N. In each generation, the feasibility of each individual in the population is first checked, and individuals that do not meet the multi-dimensional constraints are removed. Then, for feasible solutions, four objective values are calculated: nutritional score, ingredient cost, inventory turnover rate, and dish category coverage evenness score. Since the four objective values have different dimensions, they are Min-Max normalized before non-dominated sorting and crowding calculation, uniformly mapping them to the [0,1] interval. Next, individuals are non-dominated sorted according to the normalized objective values, dividing the population into different non-dominated frontier levels. Individuals in the same level... Next, the crowding distance is assessed by calculating the sum of the Euclidean distances between the individual and its neighboring individuals across each normalized objective dimension. The selection operation employs a binary tournament approach, prioritizing individuals with high non-dominated levels and high crowding to enter the mating pool. The crossover operation uses a segmented crossover method based on meal units. Three mutation types are employed. Offspring populations are generated through selection, crossover, and mutation. Parent and offspring are merged, and non-dominated ranking and crowding selection are performed again, retaining the optimal N individuals for the next generation, maintaining a constant population size while preserving elite individuals. This process is repeated iteratively until a preset convergence condition is met, such as a maximum iteration count of 200 generations, or the composition of the Pareto front remains largely unchanged for 10 consecutive generations. Finally, all non-dominated individuals in the population constitute the Pareto-optimal meal set, representing the equilibrium solution set where simultaneous improvement across the four objectives is no longer possible.
[0058] In this step, to conduct an equilibrium search for multiple conflicting objectives within the feasible region defined by multidimensional constraints, it is first necessary to initialize an algorithmic population consisting of N candidate solutions. Each candidate solution directly uses the hierarchical structure encoding result as its individual gene expression, and its data content includes a complete weekly meal plan. The initial population can be generated randomly, that is, for each meal unit, dishes are randomly selected from the dish information dataset, and a hierarchical structure encoding result is formed through the three-layer encoding mapping of the previous step. The value of N needs to balance population diversity and computational cost, for example, 100 or 200 individuals.
[0059] Subsequently, to eliminate solutions that violate business rules or are practically unfeasible, feasibility checks must be performed on the initial population and each subsequent generation of individuals. The checks are conducted one by one based on the established constraints across four dimensions: extracting the weekly usage of each ingredient from the ingredient coding layer and comparing it with inventory levels; calculating the daily nutrient intake for each meal from the ingredient coding layer and the nutrient content table and comparing it with recommended ranges; counting the number of categories covered and the frequency of each category from the category coding layer and comparing it with preset thresholds; and calculating the total cost from the ingredient coding layer and the unit price of ingredients and comparing it with the weekly cost ceiling. If any constraint fails, the individual is marked as an infeasible solution and removed from the current generation of the population. This step ensures that subsequent objective evaluations and genetic operations target only realistically feasible solutions.
[0060] Next, the values of the four optimization objectives need to be calculated for each feasible solution that passes the feasibility check, serving as the basis for non-dominated ranking and selection. Regarding nutritional scores, using the aforementioned weighted formula, the daily compliance status is calculated item by item based on the amount of each ingredient provided by the ingredient coding layer, combined with the nutrient content table of the ingredient information dataset, and then weighted to form a percentage score. For ingredient costs, the cost is obtained by multiplying the ingredient usage by the unit price and summing the results. For inventory turnover rate, the average ratio of consumption to initial inventory is used. For the evenness of dish category coverage score, the variance is calculated based on the frequency statistics of each label in the category coding layer and then normalized using a formula. These four objective values will serve as the fitness of an individual across four dimensions, guiding the non-dominated ranking.
[0061] In each generation of evolution, in order to generate new candidate solutions while preserving superior solutions, selection, crossover, and mutation operations need to be performed on the population. The selection operation employs a tournament selection method based on non-dominated ordering and crowding: two individuals are randomly selected from the current population, and their non-dominated front levels are compared; the one with the lower level wins. If they are at the same level, their crowding distance is compared; the one with the higher crowding distance wins. This method selects the parent generation to participate in mating. The crossover operation is implemented in a segmented crossover manner based on meal units: one or more identical meal units are randomly selected from the first and second parent generations as target meal units. The dish combination lists of these two parent generations at the i-th target meal unit are swapped, generating the first and second offspring generations. After the exchange, the evenness score of dish category coverage for the first and second offspring must be calculated immediately and compared with the evenness score of their respective parents. If the score of the first offspring is lower than that of the first parent, or the score of the second offspring is lower than that of the second parent, it indicates that the crossover operation has worsened the category distribution of the offspring. In this case, the crossover is cancelled, and the offspring revert to the original individuals of their parents. If neither score is lower than that of their respective parents, the exchanged offspring are accepted into the population. This category protection mechanism helps to maintain the overall performance of the population in terms of dish diversity and prevents it from deteriorating.
[0062] Mutation operations further increase population diversity, including three types of mutations: Dish replacement mutation randomly selects a dish from a specific meal unit of the target individual, searches the dish information dataset for other dishes with the same classification label as the replaced dish, and randomly selects one to replace it, thus changing the specific dish without altering the category composition. After replacement, it is necessary to verify whether the category coverage evenness score of the replaced individual is not lower than that before replacement; if not, the replacement is revoked. Meal exchange mutation randomly selects two different meal units of the target individual and swaps all their dish combinations, changing the arrangement of the menu at different meal times. Ingredient quantity adjustment mutation randomly selects a specific ingredient from a dish of the target individual and increases or decreases its quantity according to a preset adjustment step size. The step size can be set according to the ingredient type, such as a step size of 10 grams for main ingredients and 2 grams for seasonings, to finely adjust nutritional and cost indicators. The three mutation types can be triggered with preset probabilities; for example, one type can be randomly selected uniformly each time mutation is performed, or multiple types can be performed sequentially. New hierarchical coded individuals are generated through crossover and mutation. After merging the parent populations, a new round of non-dominated ranking and elite selection is carried out, and the process is repeated until convergence.
[0063] Finally, when the preset convergence condition is met, all individuals located at the first non-dominated front are extracted from the final algorithm population to form a Pareto optimal meal plan set. Each plan in this set cannot continue to improve on one objective without deteriorating on others, representing different best-case trade-offs among the four dimensions of nutrition, cost, inventory utilization, and category distribution, providing diverse and high-quality alternatives for subsequent preference decisions.
[0064] For example, consider the optimization of weekly meal distribution in a school cafeteria. This cafeteria serves 15 meals a day from Monday to Friday (breakfast, lunch, and dinner). The menu contains 80 dishes, covering 10 primary category tags, and the ingredient library contains 45 commonly used ingredients. The algorithm's population size N is set to 100 individuals, with a crossover probability of 0.9, a mutation probability of 0.1, and equal probability for each of the three mutation types. The ingredient weight adjustment step size is 10 grams. The maximum number of iterations is set to 200 generations; if the Pareto front does not update for 10 consecutive generations, the algorithm terminates early. In the first generation, 100 randomly generated individuals undergo feasibility verification, retaining 83 feasible solutions. After multi-objective evaluation, the initial population has an average nutritional score of 76, an average ingredient cost of 450 yuan, an average inventory turnover rate of 0.52, and an average evenness score of 0.68. As iterations progress, the population gradually moves towards the constraint front. Early termination was triggered at generation 178, resulting in a population with 98 feasible solutions. Fifteen individuals were located at the first non-dominated frontier, forming a Pareto-optimal meal plan set. This set exhibits diverse trade-offs among the solutions: Solution A has a nutritional score of 95, a food cost of 520 yuan, an inventory turnover rate of 0.5, and a uniformity of 0.85; Solution B has a nutritional score of 85, a food cost of only 380 yuan, an inventory turnover rate of 0.75, and a uniformity of 0.75; Solution C has a nutritional score of 90, a food cost of 420 yuan, an inventory turnover rate of 0.65, and a uniformity of 0.80. Nutritionists can choose the solution that best suits their current operational priorities or make further compromises among multiple indicators.
[0065] In summary, this step uses the hierarchical coding results as individuals and employs a non-dominated sorting genetic algorithm incorporating category-protected segmented crossover and various mutation operators to jointly optimize four objectives: nutrition score, ingredient cost, inventory turnover rate, and category coverage uniformity, under the constraints of four dimensions: inventory, nutrition, category, and cost. Finally, it outputs a set of Pareto optimal meal planning schemes.
[0066] Compared with existing technologies, this step has the following advantages: First, it incorporates four conflicting operational objectives into a multi-objective optimization framework simultaneously, without relying on manually preset weights. It can demonstrate the complete trade-offs between objectives in a cutting-edge form, solving the problem that traditional single-objective optimization can only provide a single solution and cannot reflect the possibility of compromise between multiple indicators. Second, through segmented crossover based on meal units and category uniformity protection verification, the genetic operation can explore new solutions without disrupting the reasonable distribution of dish categories, avoiding the degeneration of the population into inferior solutions with highly repetitive categories during evolution. Third, it provides three granularity mutation operations: dish replacement, meal exchange, and ingredient quantity adjustment, which enhance population diversity from the micro-level of dishes, the meso-level of meals, and the macro-level of ingredient usage, respectively, effectively improving the completeness of the search space coverage and the polymorphism of solution generation.
[0067] S500: Train a preference prediction model using the historical meal planning records in the basic meal planning data. The preference prediction model is used to predict the probability of the corresponding solution being adopted based on the multi-objective features of the solution. The multi-objective features include dish category preference features.
[0068] In this embodiment, based on the already obtained Pareto optimal meal planning scheme set, in order to automatically select the scheme that best matches the nutritionist's personalized selection tendency from multiple alternative schemes with different focuses in terms of nutrition, cost, inventory utilization, and category distribution, it is necessary to learn the implicit preferences from historical meal planning records and establish a mapping relationship between the multi-objective characteristics of the scheme and the adoption behavior. This is to solve the problem that existing meal planning systems rely heavily on preset fixed target weights or expert rules in the scheme selection stage, and cannot automatically capture the nutritionist's real preferences for dimensions such as the degree of nutritional achievement, the cost of ingredients, the speed of inventory consumption, and the combination of dish categories from historical decision data. This results in recommended schemes that are numerically superior but deviate from actual operating habits, have low adoption rates, and cannot adapt to changes in preferences over time.
[0069] Step S500 of the method provided in this application embodiment includes: training a preference prediction model using historical meal planning records in the basic meal planning data. The preference prediction model is used to predict the probability of a corresponding plan being adopted based on the multi-objective features of the plan. The multi-objective features include dish category preference features. This includes: extracting a multi-objective feature vector corresponding to each historical weekly meal planning plan from the historical meal planning record dataset. The multi-objective feature vector includes the historical nutritional score, historical ingredient cost, historical inventory turnover rate, historical dish category coverage evenness score, and historical dish category distribution vector of the historical weekly meal planning plan. Using the label indicating whether the historical weekly meal planning plan was actually adopted as a supervision label, and the multi-objective feature vector as the input feature, the preference prediction model is trained using a random forest algorithm. The output of the preference prediction model is the adoption probability value corresponding to the multi-objective feature vector. Detailed explanation follows: In this embodiment, the preference prediction model is a mapping model built on machine learning. It takes multiple dimensions of the meal plan as input and outputs an estimate of the probability that the plan will be adopted by the nutritionist. The closer the probability value is to 1, the higher the consistency between the plan and the nutritionist's historical selection behavior. The multi-objective feature vector is a fixed-dimensional numerical vector composed of various evaluation indicators and category distribution information of a meal plan. It consists of four continuous-value features: nutritional score, ingredient cost, inventory turnover rate, and dish category coverage evenness score; and a dish category distribution vector, which is a discrete feature sequence representing the cumulative number of times each dish category label appears throughout the week's meals. The complete vector dimension is equal to 4 plus the total number of dish category labels. This vector provides standardized input to the preference prediction model.
[0070] Dishes category preference features are an important component of multi-objective feature vectors. Specifically, they refer to the frequency information of each label represented by the dish category distribution vector, used to allow the model to learn the nutritionist's habits in dish pairings, such as a preference for vegetables and fruits over fried pasta. The adoption probability value is a scalar prediction value calculated by the model for the input plan, ranging from 0 to 1. It directly serves as the preference score for the plan; the closer it is to 1, the higher the degree of matching between the plan and historical adoption records. Supervision labels are binary labels corresponding to each historical week's meal planning plan in the historical meal planning records. If the plan was confirmed and implemented by the nutritionist during the meal planning operation, it is marked as 1, indicating adoption; if the plan was discarded or significantly modified after generation, it is marked as 0, indicating non-adoption. This label serves as a target reference for updating model parameters during training.
[0071] In this step, to extract implicit preference patterns from past adoption and rejection behaviors of nutritionists, training samples first need to be compiled from the acquired historical meal planning record dataset. For each historical weekly meal planning scheme, its multi-objective feature vector is extracted, including four numerical features: historical nutrition score, historical ingredient cost, historical inventory turnover rate, and historical dish category coverage evenness score. Simultaneously, the cumulative occurrence frequency of each category label is extracted from the dish category distribution vector of the scheme, and concatenated with the historical nutrition score, historical ingredient cost, historical inventory turnover rate, and historical dish category coverage evenness score to form an initial feature vector. The initial feature vector undergoes dimensionless preprocessing: the nutrition score, ingredient cost, inventory turnover rate, and dish category coverage evenness score are normalized to the [0,1] interval using Min-Max normalization; the occurrence frequency of each label in the dish category distribution vector is normalized to obtain the multi-objective feature vector. The feature vector and its corresponding adoption label are combined to form a training sample. This process is repeated across all records in the historical meal planning record dataset to construct a training sample set. At this point, the training data for the preference prediction model is ready, thus clarifying the composition of feature vectors and the sample construction process.
[0072] Next, to encode the nonlinear relationship between multi-objective features and adoption probabilities into a computable model, a suitable regression algorithm needs to be selected and the model constructed. This embodiment uses the random forest algorithm to construct the preference prediction model. The random forest classifier is an ensemble learning algorithm that constructs multiple decision trees and combines the classification voting results of each tree to output class probabilities. It can effectively capture the interactions and nonlinear relationships between features and is insensitive to differences in the dimensions of the input features, making it suitable for multi-objective feature vectors composed of indicators of different calibers. The dimension of the model's input layer is equal to the dimension of the multi-objective feature vector, and the output layer is a continuous scalar, i.e., the adoption probability estimate. Hyperparameters such as the number of decision trees, the maximum depth of each tree, and the minimum number of samples per leaf node are determined through cross-validation based on the training data scale. This algorithm addresses the problem that traditional fixed-weight methods cannot express complex preference relationships between features.
[0073] Then, to fit the model parameters to the nutritionist behavior patterns reflected in historical data, the random forest classifier needs to be trained using a pre-constructed training sample set. The multi-objective feature vectors from the training samples are used as model input, and the supervision label indicating whether a plan is adopted is used as the true objective value. The cross-entropy loss between the model's output adoption probability and the supervision label is used as the loss function. During training, a differentiated training subset is constructed for each decision tree through bootstrapping. Each tree randomly selects some features to search for the optimal split point when splitting nodes. Finally, a stable adoption probability is obtained by integrating the prediction outputs of all trees. By minimizing the overall loss function, the decision tree parameters within the model gradually converge until the loss no longer decreases significantly or reaches the preset training epochs, resulting in a pre-constructed preference prediction model. This model can calculate the predicted adoption probability for any new weekly meal plan based on its multi-objective features.
[0074] For example, the pre-training process of the preference prediction model is as follows: Taking a school cafeteria as an example, 120 historical weekly meal plans generated by the system and reviewed by a nutritionist over the past semester were collected. Of these, 68 plans were actually adopted and implemented, and 52 plans were not adopted. All samples were randomly divided into a training set of 84 samples and a test set of 36 samples at a ratio of 7:3. The multi-objective feature vector includes four numerical features: nutrition score, ingredient cost, inventory turnover rate, and dish category coverage evenness score, as well as the frequency of occurrence of 25 dish classification labels, for a total dimension of 29. The random forest classifier contains 100 decision trees with a maximum depth of 10 layers. The minimum number of samples per leaf node is 5, and the number of features considered when splitting a node is the square root of the total number of features, which is 5. After training, the model performance was evaluated on the test set. The AUC value between the model's output adoption probability and the actual adoption label was calculated to be 0.87. AUC stands for Area Under Curve, which is a commonly used indicator to measure the predictive ability of binary classification models. The AUC value ranges from 0 to 1. The closer it is to 1, the stronger the model's ability to distinguish between adoption and non-adoption options. 0.87 indicates that the model has good preference recognition ability.
[0075] In summary, this step extracts multi-objective feature vectors containing numerical evaluation indicators and dish category distribution information from historical meal preparation records. Using actual adoption status as the supervision label, a preference prediction model is trained using the random forest algorithm, achieving quantitative learning of nutritionists' implicit preferences. Compared with existing technologies, this step has the following advantages: First, it transforms historical adoption data into supervised learning samples, automatically capturing nutritionists' true trade-off tendencies among multiple objectives through model training, solving the problem that traditional methods rely on manually preset fixed rules or weights and cannot reflect personalized selection habits. Second, using the random forest algorithm as the preference prediction model can effectively handle high-dimensional feature vectors composed of different dimensions and data types, and is less prone to overfitting to a few samples, ensuring the stability and generalization ability of preference prediction. Third, the adoption probability output by the model provides a sortable continuous score value for subsequent scheme selection, enabling rapid adaptation to new preference patterns by transferring training data between different times or different canteens, improving the system's adaptability.
[0076] S600: Select the option with the highest preference score from the Pareto optimal meal plan set using the preference prediction model as the recommended meal plan.
[0077] In this embodiment of the application, based on the Pareto optimal meal plan set already obtained and the preference prediction model already trained, this step uses the model to select the plan with the highest preference score from the candidate set as the recommendation, while outputting multi-dimensional decision explanation information, and converting the nutritionist's modification operation of the recommended plan into incremental training samples. Through incremental learning, the preference prediction model is continuously updated, forming a closed loop of plan recommendation, explanation feedback and model evolution.
[0078] Step S600 of the method provided in this application embodiment includes: outputting the recommended meal plan and its corresponding decision explanation information, wherein the decision explanation information includes the satisfaction status of the recommended meal plan under each of the multidimensional constraints, the dish category coverage uniformity score of the recommended meal plan, and the changes of the recommended meal plan relative to the current meal plan in terms of nutritional score, ingredient cost, inventory turnover rate, and dish category coverage uniformity; obtaining the modified meal plan based on the user's modification operation on the recommended meal plan, wherein the modification operation includes at least one of dish replacement operation, meal exchange operation, and ingredient portion adjustment operation; calculating the modified dish category distribution vector of the modified meal plan, associating the modified dish category distribution vector with the modified multi-objective feature vector corresponding to the modified meal plan and the positive label of the recommended meal plan being adopted, and adding it as an incremental training sample to the historical meal plan record dataset; performing incremental learning on the preference prediction model based on the updated historical meal plan record dataset, and updating the model parameters of the preference prediction model. Detailed explanation follows: In this embodiment, the decision explanation information is a set of transparent explanatory information accompanying the output of the recommended meal plan. Specifically, it includes a description of the plan's complete or near-complete satisfaction of each constraint, a score for the evenness of dish category coverage, and the changes in four main indicators relative to the current system meal plan. This information enables nutritionists to quickly assess the rationality and degree of improvement of the recommended plan. The current system meal plan refers to an existing, currently executing, or most recently generated confirmed weekly meal plan in the system, serving as a comparison benchmark. The modified meal plan refers to a new plan obtained after the nutritionist manually adjusts the recommended meal plan. Adjustments can include at least one of dish replacement, meal exchange, and ingredient quantity adjustment operations, and its coding structure remains consistent with the original plan.
[0079] The modified dish category distribution vector is a vector representing the frequency of each dish category label throughout the week, recalculated based on the modified meal planning scheme. It is used to update the dish category preference features in the model. Incremental training samples are new training samples formed by concatenating the multi-objective feature vector of the modified meal planning scheme, the modified dish category distribution vector, and positive labels. These are used to expand the historical meal planning record dataset. Positive labels indicate that a scheme has been adopted; for schemes actively modified and confirmed for implementation by nutritionists, a value of 1 is assigned, indicating that the scheme aligns with current preferences. Incremental learning refers to updating the model parameters of the random forest classifier using only the newly added incremental training samples, rather than re-initializing and retraining the entire model. This allows the model parameters to be continuously updated according to user preferences with lower computational overhead.
[0080] In this step, to automatically determine the Pareto optimal solution that best matches the nutritionist's historical preferences from multiple options, the adoption probability of each solution in the Pareto optimal meal plan set is first predicted using a trained preference prediction model. For each solution, nutritional score, ingredient cost, inventory turnover rate, and dish category coverage uniformity score are extracted or recalculated from the solution's hierarchical coding results. A dish category distribution vector is extracted from the category coding layer and concatenated into a multi-objective feature vector with the same dimensions as during model training. This vector is then input into the preference prediction model to obtain the preference score, i.e., the adoption probability value, for that solution. After traversing all solutions in the set, the preference scores of each solution are compared, and the solution with the highest score is selected as the recommended meal plan. This selection process does not require manual weighting and is entirely driven by historical adoption data, thus solving the problem of traditional methods relying on manual experience for weighting, which leads to a disconnect between solution selection and actual preferences.
[0081] While selecting recommended meal plans, to ensure transparency for nutritionists regarding the basis of their decisions and to improve the efficiency and trustworthiness of plan review, it is necessary to generate decision explanation information and output it along with the meal plan. The satisfaction status of each constraint condition in the decision explanation information is obtained by comparing each constraint indicator of the recommended plan with its corresponding threshold one by one. This clearly lists whether all inventory constraints are met, whether the nutritional indicators for each meal day are within the recommended range, whether the number of dish categories covered is greater than or equal to the minimum coverage threshold, whether the maximum frequency of each category does not exceed the limit, and whether the total weekly ingredient cost is within the weekly cost ceiling.
[0082] The evenness score of the recommended menu category coverage is directly obtained from the multi-objective features of the plan. The changes of each indicator relative to the current system meal plan are obtained by calculating the difference between the recommended plan and the current system plan in terms of nutritional score, ingredient cost, inventory turnover rate, and evenness of menu category coverage. Positive values indicate improvement, and negative values indicate decline. This allows nutritionists to intuitively see which dimensions the recommended plan has improved and which dimensions have been compromised, and thus decide whether to adopt or adjust it based on actual operational priorities. This solves the problem that traditional recommendations lack quantitative comparisons, making it difficult for nutritionists to judge the actual merits of the plan.
[0083] Subsequently, after reviewing the recommended plan, the nutritionist may modify it based on daily fluctuations in ingredient supply, changes in the number of diners, or personal experience. Modifications may include replacing a dish with another dish of the same category, swapping all dish combinations between two meals, or increasing or decreasing the amount of a certain ingredient in a dish. To transform these modifications into learnable signals for the model and enable continuous evolution of the preference model, the modified meal plan needs to be automatically retrieved when the nutritionist completes and confirms the modification. Based on the modified hierarchical coding results, the same calculation process as described above is invoked to recalculate the nutritional score, ingredient cost, inventory turnover rate, and dish category coverage evenness score, resulting in the modified multi-objective feature vector. Simultaneously, the frequency of each category label is recounted from the category coding layer to obtain the modified dish category distribution vector. The modified multi-objective feature vector and the modified dish category distribution vector are concatenated and assigned a positive label 1 to indicate that the scheme has been finally adopted. This is then added as an incremental training sample to the historical meal matching record dataset, solving the problem that traditional methods discard manually modified information, causing the model to be unable to learn from actual preference feedback.
[0084] Finally, in order to enable the preference prediction model to quickly respond to changes in user preferences without increasing the computational burden, incremental learning needs to be triggered after the historical meal planning record dataset is updated. The specific implementation of incremental learning is as follows: For the random forest classifier, when the newly accumulated incremental training samples reach a preset number, for example, every 10 new samples, incremental learning is triggered once, and each decision tree in the model is expanded or partially structurally adjusted based on this set of new samples; The incremental learning can employ a batch update strategy: it can be performed at fixed time intervals, such as daily, or when the accumulated incremental training samples reach a preset threshold, the preference prediction model is retrained using all samples in the updated historical meal planning record dataset. The updated model parameters replace the original model parameters, allowing the model to gradually drift towards recent preferences without needing to train the entire decision tree from scratch. By continuously updating the preference prediction model parameters in this way, subsequent meal planning recommendations can automatically align with the nutritionist's latest operating habits and preferences, solving the problem that traditional models become fixed once trained and cannot adaptively evolve with usage.
[0085] For example, taking a week's meal preparation in a school cafeteria as an example, continuing the previous example, the Pareto optimal meal preparation scheme set contains 15 schemes. After the preference prediction model scores them one by one, scheme 7 has the highest adoption probability of 0.92 and is selected as the recommended meal preparation scheme. The output decision explanation information shows that: all four constraints of scheme 7 are met; the uniformity score of dish category coverage is 0.85, which is 0.07 higher than the current system meal preparation scheme of 0.78; the nutrition score is 92 points, which is 3 points higher than the current scheme; the ingredient cost is 480 yuan, which is 20 yuan lower than the current scheme; and the inventory turnover rate is 0.68, which is 0.12 higher than the current scheme. Nutritionists can quickly determine that the plan improves cost control and inventory utilization while also increasing category evenness, and decide to adopt it. If the nutritionist simply replaces one meat dish in Wednesday's lunch in Plan 7 with another meat dish of the same category, the system automatically calculates the multi-target feature vector of the modified plan after confirmation, and adds it to the historical dataset as an incremental training sample along with the positive label 1. That evening, the system detects that 10 new samples have been added, triggering incremental learning. It retrains the preference prediction model using the updated historical meal planning record dataset, updates the model parameters, and the subsequent generated meal plans will be closer to the nutritionist's recent replacement tendencies in meat selection.
[0086] In summary, this step, through preference optimization, decision explanation output, and incremental learning updates, achieves dynamic alignment between the recommended plan and the nutritionist's personalized preferences, thereby improving the adoption rate of the plan and the system's adaptability.
[0087] The embodiments of this application, through the specific implementation methods described above, achieve the following technical effects: This application proposes a machine learning-based method for optimizing and generating meal planning schemes. By acquiring a multidimensional dataset encompassing dishes, ingredients, inventory, nutrition, and historical records, and constructing a hierarchical encoding structure, weekly meal planning schemes are transformed into optimized individuals. Under four-dimensional constraints—inventory, nutrition, category coverage, and cost—a non-dominated sorting genetic algorithm incorporating category-protected crossover and polymorphic mutation is employed to optimize nutrition scores, ingredient costs, inventory turnover rate, and category coverage uniformity, outputting a Pareto set of solutions. A random forest preference model is trained using historical adoption records to select the optimal scheme and output a decision explanation. Simultaneously, the model is incrementally updated based on user feedback. These combined methods effectively address the technical problems of existing meal planning scheme generation methods, such as ignoring inventory constraints, having a single optimization objective, and failing to adapt to preferences, resulting in poor practicality.
[0088] Example 2, as shown in the appendix Figure 3 As shown, based on the inventive concept of the machine learning-based meal planning optimization generation method provided in Embodiment 1, this application also provides a machine learning-based meal planning optimization generation system, specifically including: The data acquisition module 11 is used to acquire the basic dataset for meal preparation, wherein the basic dataset for meal preparation includes dish information data and ingredient information data, and each dish in the dish information data is associated with a dish category label; Scheme encoding module 12 is used to encode the weekly meal plan to be generated into a hierarchical structure encoding result based on the dish information data and the ingredient information data. The hierarchical structure encoding result includes a dish category encoding layer and an ingredient encoding layer. The constraint establishment module 13 is used to establish multi-dimensional constraint conditions based on the inventory information and nutritional standards in the meal preparation basic data. The multi-objective optimization module 14 is used to use the encoding result as the optimization variable, the multi-dimensional constraints as the feasibility constraints, and the optimization objectives of maximizing the nutrition score, minimizing the ingredient cost, maximizing the inventory turnover rate, and maximizing the uniformity of the coverage of dish categories. It uses a multi-objective optimization algorithm to perform iterative search to obtain a set of Pareto optimal meal planning schemes. The preference learning module 15 is used to train a preference prediction model using historical meal records in the basic meal planning data. The preference prediction model is used to predict the probability of a corresponding solution being adopted based on the multi-objective features of the solution. The multi-objective features include dish category preference features. The solution recommendation module 16 is used to select the solution with the highest preference score from the Pareto optimal meal plan set using the preference prediction model as the recommended meal plan.
[0089] In one embodiment, the data acquisition module 11 is further configured to: obtain a dish information dataset, wherein any dish information data in the dish information dataset includes a dish name, a dish category label, and a list of dish ingredients, wherein the dish category label is at least one level label in a pre-configured multi-level category label system; obtain an ingredient information dataset, wherein any ingredient information data in the ingredient information dataset includes an ingredient name, an ingredient number, and an ingredient nutrient content table; and obtain an ingredient inventory dataset, wherein any ingredient inventory data in the ingredient inventory dataset includes an ingredient name, an ingredient number, and a current inventory quantity. The data includes information on food shelf-life; a nutritional reference standard dataset, comprising recommended daily intakes of energy, protein, fat, carbohydrates, vitamin A, vitamin C, and sodium; and a historical meal planning record dataset, wherein each historical meal planning record includes a historical weekly meal planning scheme, a distribution vector of the corresponding dish category, a multi-objective feature vector corresponding to the historical weekly meal planning scheme, and a label indicating whether the historical weekly meal planning scheme was actually adopted.
[0090] In one embodiment, the scheme coding module 12 is further configured to: divide a weekly meal preparation cycle into multiple meal units; configure each meal unit as a combination of dishes that selects at least one dish from the dish information dataset; associate each dish with the corresponding ingredient name and ingredient quantity in the dish ingredient composition list, establish a three-layer coding structure from the meal unit to the dish combination and then to the ingredient composition, wherein the first layer of the three-layer coding structure is the meal layer, the second layer is the dish category coding layer, and the third layer is the ingredient coding layer, and obtain the hierarchical structure coding result.
[0091] In one embodiment, the constraint establishment module 13 is further configured to: establish inventory constraints based on the ingredient inventory dataset, wherein the inventory constraints limit the total weekly demand of all ingredients for any candidate meal planning scheme to be less than or equal to the current inventory quantity of the corresponding ingredients in the ingredient inventory dataset; establish nutritional constraints based on the nutritional reference standard dataset, wherein the nutritional constraints limit the daily nutritional indicators of any candidate meal planning scheme to be within the recommended range of the nutritional reference standard dataset; establish dish category coverage constraints based on the dish category labels of the dish information dataset, wherein the dish category coverage constraints limit the number of dish category labels covered by any candidate meal planning scheme within a week meal planning cycle to be greater than or equal to a preset minimum coverage threshold, and the number of times the same dish category label appears in all meal units does not exceed a preset maximum number of times a category appears; and establish cost constraints based on the ingredient nutrient content table of the ingredient information dataset and the dish ingredient composition list of the dish information dataset, wherein the cost constraints limit the total weekly ingredient cost of any candidate meal planning scheme to be less than or equal to a preset weekly cost upper limit threshold.
[0092] In one embodiment, the multi-objective optimization module 14 is further configured to: initialize an algorithm population, wherein the algorithm population contains N individuals, each individual being a hierarchical structure encoding result; perform a feasibility check on each individual in the algorithm population, marking individuals that do not satisfy any of the multidimensional constraints as infeasible solutions and removing them from the algorithm population; for each feasible solution that passes the feasibility check, calculate the nutritional score, ingredient cost, inventory turnover rate, and dish category coverage uniformity score corresponding to the feasible solution, wherein the dish category coverage uniformity score is based on the feasible solution. The variance of the distribution of each dish category label across all meal units is calculated. With the optimization goals of maximizing the nutritional score, minimizing the ingredient cost, maximizing the inventory turnover rate, and maximizing the dish category coverage uniformity score, a non-dominated sorting genetic algorithm is used to perform selection, crossover, and mutation operations on the algorithm population to generate a new generation of algorithm population. Feasibility verification, multi-objective calculation, and population iteration steps are repeatedly executed until a preset convergence condition is met to obtain the final algorithm population. All non-dominated individuals in the final algorithm population are extracted to form the Pareto optimal meal planning scheme set.
[0093] Furthermore, the multi-objective optimization module 14 is also used to: select a first parent individual and a second parent individual from the algorithm population; randomly select at least one target meal unit from multiple meal units; swap the dish combination of the target meal unit in the first parent individual with the dish combination of the target meal unit in the second parent individual to generate a first child individual and a second child individual; wherein, after the swap, it is verified whether the dish category coverage uniformity score of the first child individual and the second child individual is not lower than the dish category coverage uniformity score of their respective parent individuals, and if not satisfied, the swap operation is canceled.
[0094] Furthermore, the multi-objective optimization module 14 is also used for: the mutation operation includes three types: dish replacement mutation, meal exchange mutation, and ingredient quantity adjustment mutation, wherein: the dish replacement mutation is to randomly select a dish from a meal unit in the target individual, and select another dish with the same dish classification label as the replaced dish from the dish information dataset for replacement; the meal exchange mutation is to randomly select two different meal units in the target individual and exchange all dish combinations of the two meal units; the ingredient quantity adjustment mutation is to randomly select a dish in the target individual and increase or decrease the amount of a certain ingredient in the dish according to a preset adjustment step size; after performing the dish replacement mutation, it is verified that the dish category coverage uniformity score of the target individual after replacement is not lower than the dish category coverage uniformity score of the target individual before replacement, and if it is not satisfied, the dish replacement mutation operation is cancelled.
[0095] In one embodiment, the preference learning module 15 is further configured to: extract a multi-objective feature vector corresponding to each historical weekly meal plan from the historical meal plan record dataset, wherein the multi-objective feature vector includes the historical nutritional score, historical ingredient cost, historical inventory turnover rate, historical dish category coverage uniformity score, and historical dish category distribution vector of the historical weekly meal plan; use the label indicating whether the historical weekly meal plan was actually adopted as the supervision label, and use the multi-objective feature vector as the input feature, and train the preference prediction model using the random forest algorithm, wherein the output of the preference prediction model is the adoption probability value corresponding to the multi-objective feature vector.
[0096] In one embodiment, the solution recommendation module 16 is further configured to: output the recommended meal plan and its corresponding decision explanation information, wherein the decision explanation information includes the satisfaction status of the recommended meal plan under each of the multidimensional constraints, the dish category coverage uniformity score of the recommended meal plan, and the changes of the recommended meal plan relative to the current meal plan in terms of nutritional score, ingredient cost, inventory turnover rate, and dish category coverage uniformity; obtain the modified meal plan based on the user's modification operation on the recommended meal plan, wherein the modification operation includes at least one of dish replacement operation, meal exchange operation, and ingredient portion adjustment operation; calculate the modified dish category distribution vector of the modified meal plan, associate the modified dish category distribution vector with the modified multi-objective feature vector corresponding to the modified meal plan and the positive label of the recommended meal plan being adopted, and add it as an incremental training sample to the historical meal plan record dataset; and perform incremental learning on the preference prediction model based on the updated historical meal plan record dataset to update the model parameters of the preference prediction model.
[0097] The machine learning-based meal planning optimization and generation system provided in this application can automatically generate multi-objective meal planning solutions in group catering scenarios such as school canteens, corporate restaurants, and hospital nutrition departments. This includes verifying ingredient inventory, balancing nutrition, controlling costs, and ensuring a diverse range of dishes. The system can be integrated into existing smart canteen management platforms or nutrition-based meal planning software, effectively improving the feasibility and nutritional balance of meal planning solutions and reducing the workload of manual adjustments due to ingredient shortages or budget overruns. Simultaneously, by learning from historical meal planning records and continuously updating the system with personalized nutritionist preferences, it provides nutritionists with continuously optimized decision support, increasing the adoption rate of solutions and providing structured data support for the refined operation and management of group catering. For details on the specific meal planning optimization and generation process and preference learning, please refer to Example 1.
[0098] It should be noted that the order of the embodiments in this application is merely for descriptive purposes and does not represent the superiority or inferiority of the embodiments. Furthermore, the above description focuses on specific embodiments of this specification. Additionally, the processes depicted in the accompanying drawings do not necessarily require a specific or sequential order to achieve the desired results. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
Claims
1. A method for optimizing and generating meal planning schemes based on machine learning, characterized in that, include: Obtain a basic dataset for meal preparation, wherein the basic dataset for meal preparation includes dish information data and ingredient information data, and each dish in the dish information data is associated with a dish category label; Based on the dish information data and the ingredient information data, the weekly meal plan to be generated is encoded into a hierarchical structure encoding result, which includes a dish category encoding layer and an ingredient encoding layer. Based on the inventory information and nutritional standards in the basic meal planning data, multidimensional constraints are established. Using the encoding results as optimization variables, the multidimensional constraints as feasibility constraints, and the optimization objectives of maximizing nutrition scores, minimizing ingredient costs, maximizing inventory turnover rate, and maximizing the uniformity of dish category coverage, a multi-objective optimization algorithm is used for iterative search to obtain a set of Pareto optimal meal planning schemes. A preference prediction model is trained using historical meal planning records in the basic meal planning data. The preference prediction model is used to predict the probability of a corresponding solution being adopted based on the multi-objective features of the solution, including dish category preference features. The preference prediction model selects the option with the highest preference score from the Pareto optimal meal plan set as the recommended meal plan.
2. The method as described in claim 1, characterized in that, Obtain the basic dataset for meal preparation, including: Obtain a dish information dataset, wherein any dish information data in the dish information dataset includes a dish name, a dish category label, and a list of dish ingredients, and the dish category label is at least one level label in a pre-configured multi-level classification label system; Obtain a food information dataset, wherein any food information data in the food information dataset includes the food name, food number, and food nutrient content table; Obtain a food inventory dataset, wherein any food inventory data in the food inventory dataset includes the food name, food number, current inventory quantity, and food shelf life information; Obtain a nutritional reference standard dataset, wherein the nutritional reference standard dataset includes the recommended daily intake of energy, protein, fat, carbohydrates, vitamin A, vitamin C and sodium. Obtain a historical meal planning record dataset, wherein each historical meal planning record in the dataset includes a historical weekly meal planning scheme, a distribution vector of the dish category corresponding to the historical weekly meal planning scheme, a multi-target feature vector corresponding to the historical weekly meal planning scheme, and a label indicating whether the historical weekly meal planning scheme was actually adopted.
3. The method as described in claim 2, characterized in that, Based on the dish information data and the ingredient information data, the weekly meal plan to be generated is encoded into a hierarchical structure encoding result. The hierarchical structure encoding result includes a dish category encoding layer and an ingredient encoding layer, including: The weekly meal preparation cycle is divided into multiple meal units; Each meal unit is configured to be a combination of dishes that selects at least one dish from the dish information dataset; Each dish is associated with the corresponding ingredient name and quantity in the ingredient composition list, establishing a three-layer coding structure from the meal unit to the dish combination and then to the ingredient composition. The first layer of the three-layer coding structure is the meal layer, the second layer is the dish category coding layer, and the third layer is the ingredient coding layer, thus obtaining the hierarchical structure coding result.
4. The method as described in claim 2, characterized in that, Based on the inventory information and nutritional standards in the aforementioned basic meal planning data, multidimensional constraints are established, including: Based on the food inventory dataset, an inventory constraint is established, wherein the inventory constraint limits the total weekly demand of all ingredients for any candidate meal preparation scheme to be less than or equal to the current inventory quantity of the corresponding ingredient in the food inventory dataset. Based on the nutritional reference standard dataset, nutritional constraints are established, wherein the nutritional constraints limit the daily nutritional indicators of any candidate meal plan to be within the recommended range of the nutritional reference standard dataset. Based on the dish classification labels of the dish information dataset, a dish category coverage constraint is established. The dish category coverage constraint limits the number of dish classification labels covered by any candidate meal plan within a one-week meal planning cycle to be greater than or equal to a preset minimum coverage threshold, and the number of times the same dish classification label appears in all meal units does not exceed a preset maximum number of times the category appears. Based on the nutrient content table of the ingredients in the ingredient information dataset and the ingredient composition list of the dishes in the dish information dataset, cost constraints are established, wherein the cost constraints limit the total weekly ingredient cost of any candidate meal plan to be less than or equal to a preset weekly cost upper limit threshold.
5. The method as described in claim 1, characterized in that, Using the encoding results as optimization variables, the multidimensional constraints as feasibility constraints, and maximizing nutritional scores, minimizing ingredient costs, maximizing inventory turnover, and maximizing the uniformity of dish category coverage as optimization objectives, a multi-objective optimization algorithm is used for iterative search to obtain a set of Pareto optimal meal planning schemes, including: Initialize the algorithm population, wherein the algorithm population contains N individuals, and each individual is a hierarchical structure encoding result; Perform a feasibility check on each individual in the algorithm population, and mark individuals that do not meet any of the multidimensional constraints as infeasible solutions and remove them from the algorithm population; For each feasible solution that passes the feasibility check, calculate the nutritional score, ingredient cost, inventory turnover rate and dish category coverage uniformity score corresponding to the feasible solution. The dish category coverage uniformity score is calculated based on the distribution variance of each dish category label in the feasible solution across all meal units. With the optimization directions of maximizing the nutritional score, minimizing the ingredient cost, maximizing the inventory turnover rate, and maximizing the dish category coverage uniformity score, a non-dominated sorting genetic algorithm is used to perform selection, crossover, and mutation operations on the algorithm population to generate a new generation of algorithm population. Repeat the feasibility verification, multi-objective calculation and population iteration steps until the preset convergence condition is met to obtain the final algorithm population; Extract all non-dominated individuals from the final algorithm population to form the Pareto optimal meal plan set.
6. The method as described in claim 5, characterized in that, The crossover operation employs a segmented crossover method based on meal units, exchanging dish combinations of the same meal unit from two parent individuals, including: Select the first parent individual and the second parent individual from the population described in the algorithm; At least one target meal unit is randomly selected from multiple meal units; The dish combination of the target meal unit in the first parent individual is interchanged with the dish combination of the target meal unit in the second parent individual to generate the first child individual and the second child individual. After the swap, it is verified whether the dish category coverage uniformity score of the first and second offspring individuals is not lower than the dish category coverage uniformity score of their respective parent individuals. If the condition is not met, the swap operation is canceled.
7. The method as described in claim 5, characterized in that, The mutation operations include three types: dish replacement mutation, meal exchange mutation, and ingredient portion adjustment mutation, among which: The dish replacement mutation involves randomly selecting one dish from a meal unit of the target individual and then selecting another dish with the same dish classification label as the replaced dish from the dish information dataset to replace it. The meal exchange variation involves randomly selecting two different meal units from the target individual and exchanging all the dish combinations in the two meal units. The ingredient quantity adjustment variation involves randomly selecting a dish from the target individuals and increasing or decreasing the amount of a certain ingredient in that dish according to a preset adjustment step size. After performing the dish replacement mutation, verify that the dish category coverage uniformity score of the target individual after replacement is not lower than the dish category coverage uniformity score of the target individual before replacement. If the condition is not met, cancel the dish replacement mutation operation.
8. The method as described in claim 1, characterized in that, A preference prediction model is trained using historical meal planning records from the aforementioned basic meal planning data. This model predicts the probability of a corresponding option being adopted based on its multi-objective features, including dish category preference features, such as: Extract the multi-objective feature vector corresponding to each historical weekly meal plan from the historical meal plan dataset. The multi-objective feature vector includes the historical nutritional score, historical ingredient cost, historical inventory turnover rate, historical dish category coverage uniformity score, and historical dish category distribution vector of the historical weekly meal plan. Using the labels indicating whether the historical weekly meal plan was actually adopted as supervision labels, and the multi-objective feature vector as input features, the preference prediction model is trained using the random forest algorithm. The output of the preference prediction model is the adoption probability value corresponding to the multi-objective feature vector.
9. The method as described in claim 8, characterized in that, The preferred meal plan is selected from the Pareto optimal meal plan set by the preference prediction model, with the highest preference score as the recommended meal plan. The process then includes: Output the recommended meal plan and its corresponding decision explanation information, wherein the decision explanation information includes the satisfaction of the recommended meal plan under each of the multidimensional constraints, the dish category coverage uniformity score of the recommended meal plan, and the changes of the recommended meal plan relative to the current meal plan of the system in terms of the nutritional score, the ingredient cost, the inventory turnover rate, and the dish category coverage uniformity. Based on the user's modification operation of the recommended meal plan, the modified meal plan is obtained. The modification operation includes at least one of the following: dish replacement operation, meal exchange operation, and ingredient quantity adjustment operation. Calculate the modified dish category distribution vector of the modified meal plan, associate the modified dish category distribution vector with the modified multi-objective feature vector corresponding to the modified meal plan and the positive label of the recommended meal plan being adopted, and add it as an incremental training sample to the historical meal plan record dataset. Based on the updated historical meal planning data set, incremental learning is performed on the preference prediction model to update the model parameters.
10. A meal planning optimization and generation system based on machine learning, characterized in that, The system is used to execute the machine learning-based meal planning optimization generation method according to any one of claims 1-9, the system comprising: The data acquisition module is used to acquire the basic dataset for meal preparation, wherein the basic dataset for meal preparation includes dish information data and ingredient information data, and each dish in the dish information data is associated with a dish category label; The scheme coding module is used to encode the weekly meal plan to be generated into a hierarchical structure coding result based on the dish information data and the ingredient information data. The hierarchical structure coding result includes a dish category coding layer and an ingredient coding layer. The constraint establishment module is used to establish multi-dimensional constraints based on the inventory information and nutritional standards in the basic meal planning data. The multi-objective optimization module is used to use the encoding result as the optimization variable, the multi-dimensional constraints as the feasibility constraints, and the optimization objectives of maximizing the nutrition score, minimizing the ingredient cost, maximizing the inventory turnover rate, and maximizing the uniformity of the dish category coverage. It uses a multi-objective optimization algorithm to perform iterative search to obtain a set of Pareto optimal meal planning schemes. The preference learning module is used to train a preference prediction model using historical meal records in the basic meal planning data. The preference prediction model is used to predict the probability of a corresponding solution being adopted based on the multi-objective features of the solution, including dish category preference features. The solution recommendation module is used to select the solution with the highest preference score from the Pareto optimal meal plan set using the preference prediction model as the recommended meal plan.
Citation Information
Patent Citations
Dietary nutrition collocation method based on multi-objective optimization
CN115359869A
