A method and device for synthesizing operations optimization data based on high-quality seed data
By building an initial task pool and few-sample prompt technology, expanding the scenarios of operations optimization problems, generating diverse operations optimization problem samples and mathematical models, the problem of insufficient flexibility of existing tools is solved, and a more efficient operations optimization solution is achieved.
Patent Information
- Application Number
- CN202510164162.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-14
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2045-02-14
AI Technical Summary
Existing operations research optimization tools rely on predefined fixed templates, lack flexibility, and are difficult to adapt to different problem scenarios. They also have limited capabilities in generating problem diversity and automatically expanding models, and are unable to efficiently respond to changing practical application needs.
By constructing an initial task pool containing multiple seed data samples, and using the few-sample prompting technology to expand to multiple problem scenarios, the corresponding complete problem samples and mathematical models are generated, and the corresponding code is generated in combination with the mathematical model. The data samples are expanded through enhancement operations and quality checks are performed.
The scenario expansion of problem samples has been achieved, which can cover more practical application scenarios and optimization needs, ensuring that each problem sample is equipped with a reasonable mathematical model, and improving the flexibility and efficiency of operations optimization.
Smart Images

Figure CN119623781B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of operations optimization, and in particular to an operations optimization data synthesis method and device based on high-quality seed data. Background Art
[0002] With the widespread adoption of operations research and optimization in various application fields, including industry, logistics, transportation, and supply chain management, the use of mathematical modeling and intelligent algorithms to optimize and solve complex problems has become a key means of improving enterprise operational efficiency and resource utilization. Traditional operations research and optimization methods typically rely on customized mathematical models built for specific problems, using methods such as linear programming, integer programming, mixed integer programming, and dynamic programming to solve them.
[0003] While some approaches have attempted to use automated tools or frameworks to assist in the modeling and solving of operations research and optimization problems, they still face numerous shortcomings when dealing with complex problem scenarios. First, existing tools often rely on predefined, fixed templates, lacking flexibility and making it difficult to adapt to different problem scenarios. Furthermore, their capabilities in generating diverse problems and automatically scaling models are limited, making them ineffective in addressing the ever-changing demands of real-world applications. Summary of the Invention
[0004] In view of the above existing problems, the present invention is proposed.
[0005] Therefore, this paper provides a data synthesis method for operations optimization based on high-quality seed data to address the problem that existing tools often rely on predefined, fixed templates, lack flexibility, and are difficult to adaptively expand for different problem scenarios. Furthermore, they are limited in their ability to generate diverse problems and automatically expand models, making them inefficient in responding to the ever-changing demands of real-world applications.
[0006] In order to solve the above technical problems, the present invention provides the following technical solutions:
[0007] In a first aspect, the present invention provides a method for synthesizing operations optimization data based on high-quality seed data, comprising: constructing an initial task pool, wherein the initial task pool comprises a plurality of seed data samples, each seed data sample comprising a question, a model, and a code;
[0008] Based on the problems in the seed data sample, we use the few-sample prompting technology to expand to multiple problem scenarios and generate corresponding complete problem samples;
[0009] Based on the problem samples, combined with the mathematical models in the initial task pool, a mathematical model corresponding to the corresponding problem samples is generated through the few-sample prompt technology;
[0010] Based on the generated mathematical model, the code corresponding to the mathematical model is generated through the few-shot prompting technology;
[0011] Expand the generated data samples through augmentation operations;
[0012] Perform quality checks by executing the generated code;
[0013] Construct an initial task pool, which contains multiple seed data samples. Each data sample includes a question, a model, and a code. Specifically, the following steps are included:
[0014] Defining problem types, including resource allocation problems, path planning problems, inventory management problems, and scheduling problems, and extracting key elements of the problems;
[0015] Extract models including linear programming, integer programming, mixed integer programming, dynamic programming and stochastic programming types, and extract the mathematical expressions, variables and parameters of the models;
[0016] Extract the code including model construction, solution process and result processing, as well as code comments and documentation;
[0017] Use data structures to define problem pools, model pools, and code pools;
[0018] Integrate the problem pool, model pool, and code pool to form the initial task pool;
[0019] Use a relational database to store task samples and add metadata and labels to the task samples.
[0020] As a preferred solution of the data synthesis method for operational optimization based on high-quality seed data described in the present invention, the method is extended to multiple problem scenarios based on the problems in the seed data samples through the small sample prompting technology, which specifically includes the following steps:
[0021] Select a seed problem from the constructed initial task pool, and the seed problem must conform to the type of operations optimization problem defined in the initial task pool;
[0022] Extract optimization objectives, constraints, and decision variables from the seed problem;
[0023] According to the description of the seed problem, a prompt template with an example is designed, wherein the prompt template includes the problem type, a description of the optimization goal, and constraints, and the content of the prompt template is adjusted according to the type of the problem;
[0024] Add specific scenarios and optimization requirements to the prompt template to complete the design of the prompt template;
[0025] Input the designed prompt template into the language model, which will generate N different operations optimization problem scenarios based on the seed data and prompt template;
[0026] The problem scenarios are verified and screened by verifying whether the scenario descriptions of the generated problems are reasonable and removing duplicate questions that are too similar to the seed questions.
[0027] As a preferred solution of the operational optimization data synthesis method based on high-quality seed data of the present invention, generating the corresponding complete problem sample specifically includes the following steps:
[0028] Extract background information from the seed question and further parse the question description using natural language processing technology to extract key elements and form a complete question description;
[0029] Extract optimization objectives from new problem scenarios and match mathematical model types based on the type and complexity of the problem;
[0030] Extract constraints from new problem scenarios and check whether the logic and conditions are reasonable;
[0031] Integrate the complete problem description, optimization objectives and constraints to form a complete operations optimization problem sample.
[0032] As a preferred solution of the operations optimization data synthesis method based on high-quality seed data described in the present invention, the method comprises the following steps: based on the problem sample, combined with the mathematical model in the initial task pool, a mathematical model corresponding to the corresponding problem sample is generated through a small sample prompting technology.
[0033] Analyze the background of the problem sample, identify the operational optimization type of the problem, and extract resource information;
[0034] Extract optimization objectives from problem samples, clarify the specific content of optimization, and identify the form of optimization objectives;
[0035] Extract all constraints from the problem sample and specify the numerical limits involved in each constraint;
[0036] Retrieve mathematical models of similar problems from the initial task pool based on the type of problem sample, and further match the form of the optimization objective and the complexity of the constraints;
[0037] Extracting mathematical model templates from the retrieved similar problems;
[0038] Structurally mark the extracted mathematical model template;
[0039] Design a few-shot prompt template that includes a problem description and a reference mathematical model template;
[0040] Input the few-shot prompt template into the language model, guide the language model to generate the optimization goal based on the problem sample and the constraints consistent with the problem description, and form a corresponding mathematical model for the corresponding problem sample;
[0041] Generate its decision variables based on the formed mathematical model and clarify its limitations.
[0042] As a preferred solution of the operational optimization data synthesis method based on high-quality seed data described in the present invention, wherein: based on the generated mathematical model, a code corresponding to the mathematical model is generated by a small sample prompting technology, specifically comprising the following steps:
[0043] Extract the problem description, optimization target description, constraint description and code prompts from the generated mathematical model to form a prompt template;
[0044] Input the prompt template into the language model to generate code that imports the relevant mathematical solution library;
[0045] Use the library classes to define classes of optimization problems;
[0046] Use LpVariable to define the decision variables in the optimization problem;
[0047] Generate optimization target code that defines the optimization goal and adds constraints;
[0048] By calling the solver, we start solving the optimization problem and find a solution that satisfies all constraints and optimizes the objective.
[0049] Outputs the optimal solution found by the solver.
[0050] As a preferred solution of the operational optimization data synthesis method based on high-quality seed data described in the present invention, the generated data samples are expanded by an enhancement operation, specifically comprising the following steps:
[0051] prompting the language model to identify modifiable parts in the mathematical model, wherein the modifiable parts include optimization objectives and constraints;
[0052] Randomly select one of the potential modifiable elements and generate new data samples with different optimization requirements by modifying the optimization objectives and constraints;
[0053] Restate the existing problem description in various forms by prompting the language model;
[0054] Generate problem descriptions with different semantic expressions, and the restatement process allows for diverse language expressions;
[0055] For complex operations optimization problems, language model recognition and modeling techniques are provided;
[0056] By prompting the language model to generate different modeling schemes, one of the modeling techniques is randomly selected to modify and replace the existing mathematical model;
[0057] By applying different modeling techniques, we can generate diverse data samples suitable for different problem complexities and scenario requirements;
[0058] By executing the generated code, quality check is performed, which includes the following steps:
[0059] Extract the core modules from the generated code, check the code integrity and whether the required mathematical solution libraries are correctly imported;
[0060] Create an isolated virtual environment for code execution and provide input data;
[0061] Call the solver to execute the generated code and capture the execution log and exceptions;
[0062] Set evaluation metrics based on code optimization time, solution accuracy, and resource usage;
[0063] Read the solver output to verify whether the solution was found successfully and check whether the solution output by the solver satisfies all constraints;
[0064] Evaluate the output solution based on the evaluation indicators to determine whether the quality of the solution meets expectations;
[0065] The solution that runs successfully and meets expectations is defined as the optimal solution;
[0066] For the code sample with the optimal solution, the execution result of the sample is recorded and saved, and marked as a successful sample.
[0067] In a second aspect, the present invention provides an operational optimization data synthesis device based on high-quality seed data, comprising:
[0068] The seed data management module builds and manages the initial task pool and stores multiple seed data samples containing questions, models, and codes;
[0069] The question expansion module uses a few-sample prompting technique to expand questions in the seed data to multiple different question scenarios and generate corresponding complete question samples;
[0070] The mathematical model generation module generates the corresponding mathematical model based on the expanded problem samples using the few-sample prompting technology;
[0071] The code generation module, based on the generated mathematical model, uses the few-shot hinting technology to generate operational optimization code that can solve the model;
[0072] Data enhancement module, which expands the generated data samples through various enhancement operations;
[0073] The execution and quality inspection module executes the generated code to check its functional integrity, the output quality of the solver, and the rationality of the solution.
[0074] In a third aspect, the present invention provides a computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: when the computer program is executed by the processor, it implements any step of the operational optimization data synthesis method based on high-quality seed data as described in the first aspect of the present invention.
[0075] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, wherein: when the computer program is executed by a processor, it implements any step of the operations optimization data synthesis method based on high-quality seed data as described in the first aspect of the present invention.
[0076] The beneficial effects of the present invention are as follows: through the few-sample prompting technology, the seed problems in the task pool are expanded to multiple different operations optimization problem scenarios. The use of the few-sample prompting technology makes it possible to generate a variety of operations optimization problem samples even when the sample data is limited. The scenario expansion of the problem samples is achieved, which can cover more practical application scenarios and optimization requirements. Through the few-sample prompting technology combined with the mathematical model in the initial task pool, a mathematical model that matches the problem sample is automatically generated. Combining the problem description with the appropriate mathematical model ensures that each generated problem sample is equipped with a reasonable mathematical model. A one-to-one mapping between the problem and the mathematical model is achieved, which solves the problem of model design relying on manual experience in traditional operations optimization. BRIEF DESCRIPTION OF THE DRAWINGS
[0077] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0078] Figure 1 This is a flow chart of the operational optimization data synthesis method based on high-quality seed data in Example 1.
[0079] Figure 2 Schematic diagram of the operational optimization data synthesis method based on high-quality seed data in Example 1. DETAILED DESCRIPTION
[0080] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0081] In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention may also be implemented in other ways different from those described herein. Those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.
[0082] Secondly, the term "one embodiment" or "embodiment" herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The phrase "in one embodiment" appearing in various places throughout this specification does not necessarily refer to the same embodiment, nor does it refer to a separate or selective embodiment that is mutually exclusive of other embodiments.
[0083] Example 1, with reference to Figure 1 and Figure 2 , which is the first embodiment of the present invention, provides a data synthesis method for operational optimization based on high-quality seed data, comprising the following steps:
[0084] S1. Define problem types, including but not limited to resource allocation problems, path planning problems, inventory management problems, and scheduling problems.
[0085] Specifically, by defining the problem type and extracting the key elements of each problem (such as optimization objectives, constraints, and decision variables), we can ensure targeted optimization of the subsequent model design and solution process. This step has the beneficial effect of clarifying the application scenario of the problem, ensuring the structured and standardized problem description, and thus providing a clear path for subsequent automated modeling and code generation. By properly defining the problem type, we can reduce ambiguity in problem modeling, thereby improving the efficiency and accuracy of the solution of the entire system.
[0086] S1.1. Extract mathematical expressions, variables, and parameters of various mathematical models from seed data and generate corresponding mathematical model templates for each problem. This ensures the parameterization and modular design of the model, allowing different optimization problems to be adapted to different model types.
[0087] S1.2. Extract the codes used for model construction, solution process and result processing to form a standardized code template, and extract code comments and documentation at the same time.
[0088] It is further explained that the automatic generation of solution codes suitable for different problems and models reduces the duplication of work in the development process, and at the same time improves the reliability and maintainability of the code by extracting code comments and documentation.
[0089] S1.3. Through reasonable data structure design, the seed data is organized into a problem pool, a model pool, and a code pool.
[0090] The problem pool stores different types of operations research optimization problems and their key elements, including problem description, optimization objectives, and constraints.
[0091] The model pool stores mathematical models that match the problem and the corresponding expressions, variables, and parameters.
[0092] The code pool stores the solution codes corresponding to the model, including codes for different modules such as construction, solution, and result processing.
[0093] Integrate the problem pool, model pool and code pool to form the initial task pool.
[0094] Metadata can include information such as the type, complexity, and application field of the task, while tags can quickly retrieve and filter task samples that meet specific conditions.
[0095] S2. Few-shot prompting is a method in natural language processing that uses language models for learning. It is particularly useful for large-scale pre-trained models (such as the GPT series). In few-shot prompting, a small amount of example data—just a few specific examples—is provided to the model, enabling it to understand the task and perform corresponding reasoning or generation.
[0096] Specifically, a seed problem that matches the defined operations research optimization problem type is selected from the initial task pool. Three core elements are extracted from the selected seed problem: optimization objective, constraints, and decision variables.
[0097] The optimization objective refers to the goal of the problem, such as minimizing cost, maximizing efficiency, etc.
[0098] The constraints are defined to define the restrictions that must be followed in the problem, such as resource constraints, time constraints, etc.
[0099] The decision variables refer to the variables that need to be solved in the problem, such as the amount of resource allocation, the choice of path, etc.
[0100] It is further explained that by automatically extracting optimization objectives, constraints, and decision variables, the workload of manual problem analysis is reduced and the consistency and accuracy of problem modeling are improved.
[0101] S2.1. The design of the prompt template mainly includes the problem type, the description of the optimization goal and the constraints.
[0102] The problem type refers to the type of operations research optimization that the problem belongs to (such as resource allocation or path planning).
[0103] The description of the optimization objective is used to clearly express the optimization goal of the problem, such as the cost to be minimized or the output to be maximized.
[0104] Constraints are used to list the constraints that must be followed in a problem, such as a budget cap or time limit.
[0105] It is further explained that by automatically extracting optimization objectives, constraints, and decision variables, the workload of manual problem analysis is reduced and the consistency and accuracy of problem modeling are improved.
[0106] S2.2. Design a prompt template that includes the problem type, description of the optimization goal, and constraints.
[0107] The problem type specifies which type of operations research optimization the problem belongs to (e.g., resource allocation or path planning).
[0108] The design of the prompt template needs to be adjusted according to the type of question to ensure that the template can correctly describe the characteristics of the seed question and provide sufficient information for generating new question scenarios.
[0109] S2.3. Further add specific scenarios and optimization requirements to the designed basic prompt template.
[0110] Specifically, the inclusion of specific scenarios is to enhance the realism and applicability of the questions and to ensure that the generated question samples can be applied in actual scenarios.
[0111] For example, in a route planning problem, the logistics scenario of a specific geographical area can be added; in a resource allocation problem, the resource and time constraints of a specific project can be added.
[0112] Furthermore, by incorporating specific scenarios and optimization requirements, the generated problem samples are closer to actual application scenarios and can better meet the diverse optimization needs in different scenarios. This process enhances the realism and operability of the generated problems, ensuring that the problem samples are not only theoretically meaningful but also applicable to various real-world optimization scenarios.
[0113] S2.4. Input the designed prompt template into the language model. The language model generates N different operations research optimization problem scenarios based on the seed data and prompt template. The language model's generative capabilities enable the generation of multiple operations research optimization problems with different scenarios and optimization requirements from the seed problem. These problem scenarios include different optimization objectives, constraints, and variable settings, ensuring the diversity and broad applicability of the problem sample.
[0114] Small-scale generation (N≈10-20) is suitable for some simple scenarios, or when the variation space of the seed problem itself is small, the number of generated problem samples can be small, which is suitable for refined analysis and manual verification.
[0115] Medium-scale generation (N≈50-100) is suitable for scenarios where a diverse set of problem examples is required. If the problem type is complex or requires verifying multiple scenarios and constraints, generating 50-100 problem examples ensures that most possible variations are covered.
[0116] Large-scale generation (N≈100-1000). In large-scale application scenarios, especially when training machine learning models or building large data sets are required, it is common to generate hundreds or even thousands of problem samples.
[0117] S2.5. After generating N different operations research optimization problem scenarios, these problem scenarios need to be verified and screened. Ensure that the generated problem scenarios are well described and remove duplicate problems that are too similar to the seed problem.
[0118] By verifying the rationality of the problem description, we can eliminate those problems that do not conform to actual logic or have no application significance; and by removing duplicate problems, we ensure the diversity and uniqueness of the problem samples.
[0119] For example, a simple path planning seed problem is selected from the initial task pool.
[0120] Problem Description: A logistics company needs to deliver goods from a warehouse to several customers. The company hopes to find the shortest route that passes all customers and returns to the warehouse, minimizing the total delivery time.
[0121] Optimization goal: minimize the total delivery time.
[0122] Constraints: Each customer must be visited once, vehicle capacity is limited, and working hours per day do not exceed 8 hours.
[0123] Decision variables: determine the order in which delivery vehicles travel.
[0124] Based on the above seed questions, multiple different operations optimization problem scenarios are generated through the language model.
[0125] Scenario 1, Problem Description: A courier company wants to optimize its delivery routes. The company needs to start from a distribution center, deliver to several customers, and then return. The requirement is to minimize the total delivery distance.
[0126] Optimization goal: minimize the total delivery distance.
[0127] Constraints: Each customer must be visited once, the vehicle's fuel consumption is limited to 300 kilometers, and the delivery must be completed within one day.
[0128] Scenario 2, Problem Description: A cold chain company needs to plan the delivery routes for its refrigerated trucks. The trucks depart from the warehouse, deliver frozen food to several retail stores, and return to the warehouse. The refrigerated trucks must travel the shortest distance possible to minimize fuel consumption.
[0129] Optimization goal: Minimize fuel consumption.
[0130] Constraints: Each retail store must be visited once, the maximum driving distance of the refrigerated truck is 400 kilometers, and the refrigeration equipment of the refrigerated truck must complete the delivery within 12 hours.
[0131] Scenario 3, Problem Description: A construction company needs to transport building materials from a warehouse to multiple construction sites. The company wants to find the shortest route that passes through all the construction sites and returns to the warehouse to minimize the total transportation cost.
[0132] Optimization goal: minimize transportation costs.
[0133] Constraints: Each construction site must be visited once, the maximum truck load is 10 tons, and the working time per day does not exceed 9 hours.
[0134] Scenario 4, Problem Description: A medical supplies company needs to optimize delivery routes to deliver medicines from its warehouse to multiple hospitals. The requirement is to minimize the total delivery time.
[0135] Optimization goal: minimize the total delivery time.
[0136] Constraints: Each hospital must be visited once, vehicle capacity is limited, and deliveries must be completed within 8 hours per day.
[0137] Scenario 5, Problem Description: An electronics company needs to transport electronic components from the warehouse to different factories and plan the shortest route that passes through all factories and returns to the warehouse.
[0138] Optimization goal: Minimize the total transportation time.
[0139] Constraints: Each factory must be visited once, the maximum working time of the vehicle is 10 hours, and traffic congestion needs to be considered during transportation.
[0140] After generating these scenarios, they were verified for plausibility and to remove duplication.
[0141] Reasonableness verification:
[0142] Scenario 1 is similar to the logistics company's initial seed problem, but emphasizes minimizing total delivery distance rather than delivery time, and also incorporates fuel consumption constraints. The scenario description is reasonable, and the constraints are practical.
[0143] Scenario 2, the cold chain distribution scenario, incorporates the fuel consumption of refrigerated trucks and the time limit of refrigeration equipment. The scenario is reasonable and has specific constraints for cold chain distribution, which conforms to the limitations in actual applications.
[0144] Scenario 3: A construction company needs to minimize transportation costs. Unlike traditional path planning problems, this scenario is reasonable and practical, as it takes into account the transportation of construction materials.
[0145] Scenario 4 is very similar to the seed question and is almost a restatement of the initial question. The only difference is that the type of supplies is medical supplies. Other conditions are almost the same, so it may be considered too similar.
[0146] Scenario 5: Special constraints of electronic product transportation and traffic congestion are added. The scenario is reasonable and has practical application significance.
[0147] Remove duplicate questions:
[0148] Scenario 4 is very similar to the seed problem, with nearly identical optimization objectives and constraints. The only difference is the type of goods (pharmaceuticals vs. general cargo). Despite the slight difference, its optimization objectives and constraints are too similar to the seed problem, so it can be considered a duplicate and needs to be removed.
[0149] Although scenario 1 is similar to the seed problem, the optimization objective changes from minimizing time to minimizing distance, and the constraints are changed (fuel consumption limit), so it can be retained.
[0150] Scenario 2, Scenario 3, and Scenario 5 are relatively unique, with different constraints and optimization goals. However, the scenarios are completely reasonable and can be retained.
[0151] After verification and screening, scenarios 1, 2, 4, and 5 were retained. Scenario 4 was removed because it was too similar to the seed problem.
[0152] Furthermore, through this verification and screening process, we ensure that the generated question scenarios are reasonable and do not repeat the seed questions. This ensures the diversity and uniqueness of the question samples.
[0153] S3. Extract background information from the seed problem. Background information usually refers to the application scenario and field of the problem, such as logistics distribution, factory scheduling, inventory management, etc.
[0154] Through natural language processing technology, the natural language description of the problem is parsed to identify the key elements therein, which are usually the optimization objectives, constraints and decision variables.
[0155] Through parsing, a structured complete problem description is generated, which includes background information and extracted key elements.
[0156] S3.1. Use NLP technology to extract optimization objectives from the problem description of the new problem scenario, and match the appropriate mathematical model based on the extracted optimization objectives.
[0157] Different optimization objectives may correspond to different mathematical model types, such as linear programming, integer programming, mixed integer programming, dynamic programming, and network flow models.
[0158] Specifically, not only will the appropriate mathematical model be selected, but the complexity of the problem will also be considered. For example, if the problem is small and the variables are continuous, linear programming may be sufficient; if the problem is large and the variables are discrete, mixed integer programming may be necessary.
[0159] S3.2 Automatically extract constraints from new problem scenarios, including their specific numerical values or logical relationships. For example, the "10 tons" in "the maximum capacity of the machine is 10 tons" is a specific quantity restriction.
[0160] After the constraints are extracted, a logical check is performed to ensure that they are reasonable. If there are conflicts or unreasonable constraints, they will be deleted.
[0161] For example, if a problem requires a task to be completed in 1 hour, but resource allocation indicates that the task will take at least 2 hours, then there is a logical conflict.
[0162] If the vehicle capacity in a scenario is limited to 10 tons, but the requirement for a certain task is 12 tons, this will also result in unreasonable constraints.
[0163] Furthermore, NLP technology automatically parses problem descriptions and extracts key elements, reducing manual intervention. Automated logic checks and constraint validation ensure that generated problems are practical and actionable. This significantly reduces the workload of manual design, verification, and problem solving, improving the efficiency of generating and solving operations research optimization problems.
[0164] S4. Analyze the background information of the generated problem sample and extract the type of operation optimization problem. For example, the system can identify whether it is a logistics distribution problem, a production scheduling problem, or an inventory control problem.
[0165] Further extracting resource information from the problem. Resources are variables directly related to the problem, such as vehicles, workers, machines, inventory, etc. Extracting this resource information helps the system identify which variables need to be optimized when building a mathematical model.
[0166] S4.1. Extract the optimization objective of the problem sample and identify the mathematical form of the optimization objective, for example, linear objective function and nonlinear objective function.
[0167] The form of the optimization objective determines the type of mathematical model required. For example, a linear objective function is often suitable for linear programming, while a nonlinear objective function may require a nonlinear programming model.
[0168] S4.2. Automatically extract all constraints from the problem sample and clarify the numerical limits of the constraints.
[0169] S4.3. Based on the analyzed problem type, retrieve mathematical models similar to the current problem sample from the initial task pool.
[0170] The retrieved similar problem models need to match not only the type of problem, but also the form of the optimization objective (such as linear or nonlinear) and the complexity of the constraints.
[0171] For example, if the optimization goal is a linear objective, a linear programming (LP) model is preferred.
[0172] If the constraints are complex, choose a model suitable for handling complex constraints, such as mixed integer programming (MIP) or dynamic programming (DP).
[0173] Extract the corresponding mathematical model templates from the retrieved similar problems.
[0174] S4.4. Structurally mark the mathematical model template to identify which parts need to be expanded or modified based on the problem sample. The marked expansion parts usually include the optimization objective and constraints.
[0175] S4.5. Design a few-shot prompt template that includes the problem description and a reference mathematical model template. The prompt template is passed as input to the language model.
[0176] The language model generates a mathematical model that matches the problem sample by taking the problem description and reference model in the prompt template.
[0177] S4.5.1. Automatically generate corresponding decision variables in the generated mathematical model. Generate appropriate decision variables based on the problem type.
[0178] For example, in a path planning problem, the decision variable might be “the path that each vehicle is planned to travel.”
[0179] In a resource allocation problem, the decision variable might be "the amount of resources to allocate to each task."
[0180] S4.5.2. For each decision variable, the system will also clearly define its value range and restrictions.
[0181] For example, whether the decision variable is an integer, the upper and lower limits of the variable, and whether there are other physical or logical restrictions.
[0182] It is further explained that through the few-sample prompting technology, a mathematical model that conforms to the problem sample can be automatically generated, which greatly reduces the workload of manual modeling and reduces the dependence on large amounts of training data.
[0183] S5. Extract the description of each key element from the generated operations optimization mathematical model, including the description of the problem, the description of the optimization goal and the description of the constraints.
[0184] The problem description, the description of the optimization goal and the description of the constraints are converted into a code prompt template to guide the language model to generate solution code.
[0185] Specifically, by extracting key information from the generated mathematical model and forming a code hint template, a clear generation guide is provided for the language model, reducing the ambiguity and uncertainty of code generation. The code hint template presents the problem description, optimization objectives and constraints in a structured manner, which helps to generate high-quality code.
[0186] S5.1. Input the generated code hint template into the language model. Based on the code hint template, the language model generates code for solving the optimization problem.
[0187] First, introduce or import relevant mathematical solution libraries, such as PuLP, SciPy, and Gurobi.
[0188] PuLP is a Python-based linear programming modeling library used to define, solve, and process linear optimization problems.
[0189] SciPy is an open source Python library for scientific computing, which includes many modules for mathematical, scientific, and engineering computing.
[0190] Gurobi is a commercial optimization software specifically used to solve various complex mathematical optimization problems.
[0191] S5.2. When the language model generates code, it selects an appropriate class to define the type of optimization problem based on the problem type. For example, in PuLP, the commonly used class is LpProblem, which is used to define linear programming problems.
[0192] If the problem is nonlinear programming, the language model might choose another library (such as SciPy) and use different classes to define the problem.
[0193] Furthermore, code generated from a language model can automatically define the category of optimization problems (such as linear programming or nonlinear programming) based on problem examples, avoiding errors or omissions in manual selection. It can also automatically adjust the problem definition in the code based on the optimization objective (maximization or minimization), enhancing the flexibility of the code.
[0194] S5.3. Based on the resource information in the problem sample, the language model uses the solver library classes to define decision variables when generating code. For example, in PuLP, LpVariable is used to define decision variables.
[0195] Automatically generate the definition of decision variables based on the description of the problem sample. For example, in a path planning problem, the decision variable may be the driving path of each vehicle; in a production scheduling problem, the variable may be the allocation of each task.
[0196] S5.4. Based on the optimization goal in the problem sample, the language model generates code to define the objective function. In PuLP, the objective function is usually a linear expression.
[0197] The language model automatically generates corresponding inequality or equality constraints based on the constraint description in the problem sample and adds them to the model.
[0198] Furthermore, the code for the optimization objective is automatically generated based on the problem description, ensuring the correctness and consistency of the objective function. The code generated by the language model automatically adds all constraints to ensure that the model is complete and covers all restrictions.
[0199] S5.5. The code generated by the language model will call the solver in the solution library to find the optimal solution that satisfies all constraints based on the objective function and constraints in the model.
[0200] Solvers solve optimization problems using internal mathematical algorithms (such as the simplex method, interior point method, branch and bound method, etc.). For different optimization problems, solvers may use different algorithms to find the optimal solution.
[0201] S5.6. After the solver completes the solution, the code generated by the language model will output the optimal solution to the optimization problem. For each decision variable, its optimal value will be output.
[0202] It is further explained that the solver using the solution library can quickly find the optimal solution that meets the constraints, significantly improving the solution efficiency, and can automatically select the appropriate solution library and method to handle different types of optimization problems.
[0203] S6. Expanding the generated data samples through enhancement operations, wherein the enhancement operations include modifying the optimization objectives or condition constraints, restating the problem, and modifying the modeling solution by including multiple modeling techniques.
[0204] S6.1. Modifying the optimization target or conditional constraints refers to prompting the language model to identify the modifiable parts in the existing mathematical model, and the modifiable parts include the optimization target and conditional constraints.
[0205] Randomly select an element from the identified modifiable parts and modify it. By modifying the optimization objective and constraints, new data samples are generated. The new samples exhibit different optimization requirements and constraints and are suitable for different scenarios.
[0206] For example, in a production scheduling problem, a new sample may be generated in which the optimization objective changes from minimizing production time to minimizing production cost, or the constraint changes from having at most 5 machines available to having at most 3 machines available.
[0207] It is further explained that by randomly selecting and modifying the modifiable elements in the model, a series of data samples with different optimization requirements are generated, which improves the diversity of the data. Moreover, by modifying the optimization objectives and constraints, the new data samples generated can adapt to different scenarios and problem requirements, making the model show good applicability in different environments.
[0208] S6.2. Prompt the language model to restate the existing problem description in multiple forms.
[0209] The restatement process allows the language model to generate diverse language representations, ensuring that each restatement has a different semantic expression.
[0210] For example, in the original problem statement, we need to minimize the transportation cost, and the vehicle's load cannot exceed 10 tons.
[0211] To reiterate 1, the goal is to reduce transportation costs, and the maximum load capacity per vehicle is 10 tons.
[0212] To reiterate 2, the maximum load capacity of the vehicle is 10 tons, and our optimization goal is to make the transportation cost as low as possible.
[0213] Further explanation: By restating the problem description and generating a variety of different representations, the problem description is more diverse and adapts to different language styles and user needs. Furthermore, diverse language representations help the model be universal across different users, application scenarios, or regions, ensuring that the model is adaptable to multilingual and multicultural backgrounds.
[0214] S6.3. For complex operations research optimization problems, prompt the language model to identify modeling techniques that can be used to build and optimize the model.
[0215] The language model automatically identifies the modeling technique that is appropriate for the problem based on its complexity and structure.
[0216] For example, faced with a production scheduling problem with a large number of variables and constraints, a language model might recommend using branch and bound or dynamic programming.
[0217] S6.3.1. The language model generates multiple different modeling schemes, each of which uses a different modeling technique to build or optimize an existing mathematical model.
[0218] For example, in a path optimization problem, multiple modeling options may be generated, including the use of mixed integer programming (MIP) or network flow models.
[0219] From the generated modeling solutions, the system randomly selects one of the techniques and modifies or replaces the existing mathematical model accordingly.
[0220] For example, if relaxation is selected, the model may make the problem easier to solve by relaxing some constraints.
[0221] Furthermore, generating different modeling solutions provides multiple solutions to the same problem, improving the model's flexibility. Furthermore, automatically selecting and applying different modeling techniques reduces the need for manual intervention and improves modeling efficiency.
[0222] S6.4. Generate diverse data samples tailored to the complexity of the problem and the requirements of the scenario through different modeling techniques. These data samples can reflect various optimization requirements and constraints.
[0223] For example, for a resource allocation problem, multiple different data samples are generated, reflecting different resource constraints, time constraints, and optimization objectives.
[0224] This further demonstrates that the data synthesized through augmentation operations can better cope with the dynamic changes in the modeling environment and effectively meet the needs of diverse representations by restating the problem. In addition, for more difficult problems, model modification and optimization can be carried out through different modeling techniques to better adapt to the possibility of multiple modeling solutions.
[0225] S7. Extract the core modules from the generated code and check the code for completeness, ensuring that every component is present and clearly structured, with no omissions. For example, check for missing necessary solver library imports or solver calls. Also check that the code correctly imports the required mathematical solver libraries. Ensure that the generated code contains the correct library import statements. Finally, check for version compatibility of the imported libraries to avoid runtime errors caused by version incompatibility.
[0226] S7.1. To avoid conflicts, create an isolated virtual environment for each code sample. The isolated virtual environment ensures that each code sample runs in an independent environment, avoiding package dependency and library version conflicts with other code samples.
[0227] S7.2. Run the generated code and call the pre-imported solver to solve the optimization problem.
[0228] During code execution, execution logs are captured, including solver output information, such as intermediate results, warning messages, iteration counts, etc. These logs help track code execution.
[0229] It also captures exceptions, such as errors that occur during code execution, such as library import errors, data type errors, solution failures, etc. By capturing exceptions, problems in the code can be identified and appropriate solutions can be taken.
[0230] S7.3. Set evaluation metrics based on code optimization time, solution accuracy, and resource usage.
[0231] The optimization time of the code is the time required by the solver to find the optimal solution, usually measured in seconds.
[0232] The accuracy of the solution indicates whether the solution output by the solver reaches the expected accuracy, and the accuracy can be evaluated by the value of the objective function or the degree of satisfaction of the constraint conditions.
[0233] The resource usage refers to the computing resources used during code execution, such as CPU and memory usage.
[0234] S7.4. Read the output of the solver, including the value of each decision variable and the value of the objective function.
[0235] Check whether the solver successfully found a solution and whether the solution output by the solver satisfies all constraints.
[0236] For example, if the constraint is x+y<=100, check whether the output values of x and y satisfy this condition.
[0237] S7.5. Compare the quality of the solution with the expected standards to determine whether the solution is of high quality. For example, whether the solution accuracy is high enough, whether the optimization time is within a reasonable range, and whether the resource usage is efficient.
[0238] S7.6. The code runs successfully and the output solution meets all evaluation criteria. This solution is defined as the optimal solution.
[0239] Record and save successfully run code samples and their output results.
[0240] Furthermore, the use of virtual environments ensures the independence between different code samples and avoids package dependency conflicts. The high quality of the solutions output by the solver is ensured by optimizing the evaluation of time, solution accuracy, and resource usage.
[0241] This embodiment also provides an operational optimization data synthesis device based on high-quality seed data, comprising:
[0242] The seed data management module builds and manages the initial task pool and stores multiple seed data samples containing questions, models, and codes;
[0243] The question expansion module uses a few-sample prompting technique to expand questions in the seed data to multiple different question scenarios and generate corresponding complete question samples;
[0244] The mathematical model generation module generates the corresponding mathematical model based on the expanded problem samples using the few-sample prompting technology;
[0245] The code generation module, based on the generated mathematical model, uses the few-shot hinting technology to generate operational optimization code that can solve the model;
[0246] Data enhancement module, which expands the generated data samples through various enhancement operations;
[0247] The execution and quality inspection module executes the generated code to check its functional integrity, the output quality of the solver, and the rationality of the solution.
[0248] This embodiment also provides a computer device, which is suitable for the case of an operations optimization data synthesis method based on high-quality seed data, including: a memory and a processor; the memory is used to store computer-executable instructions, and the processor is used to execute computer-executable instructions to implement the operations optimization data synthesis method based on high-quality seed data proposed in the above embodiment.
[0249] The computer device may be a terminal, comprising a processor, memory, a communication interface, a display, and an input device connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores an operating system and computer programs. The internal memory provides an environment for the operating system and computer programs stored in the non-volatile storage media. The communication interface of the computer device is used to communicate with external terminals via wired or wireless communication. Wireless communication may be achieved via Wi-Fi, a carrier network, NFC (near-field communication), or other technologies. The display of the computer device may be a liquid crystal display or an electronic ink display. The input device may be a touchscreen overlay on the display, buttons, a trackball, or a touchpad on the computer device housing, or an external keyboard, touchpad, or mouse.
[0250] This embodiment also provides a storage medium having a computer program stored thereon, which, when executed by a processor, implements the operational optimization data synthesis method based on high-quality seed data proposed in the above embodiment; the storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0251] In summary, the present invention achieves this by: using the few-sample prompting technology to expand the seed problems in the task pool to multiple different operations optimization problem scenarios. The use of the few-sample prompting technology enables the generation of diverse operations optimization problem samples even when the sample data is limited. The scenario expansion of the problem samples is achieved, which can cover more practical application scenarios and optimization requirements. By combining the few-sample prompting technology with the mathematical model in the initial task pool, a mathematical model that matches the problem sample is automatically generated. Combining the problem description with the appropriate mathematical model ensures that each generated problem sample is equipped with a reasonable mathematical model. A one-to-one mapping between the problem and the mathematical model is achieved, which solves the problem of model design relying on manual experience in traditional operations optimization.
[0252] Example 2, referring to Table 1, is the second embodiment of the present invention. In order to further verify the technical solution of the present invention, experimental simulation data of the operations optimization data synthesis method based on high-quality seed data is provided.
[0253] This example demonstrates the innovativeness and advantages of a data synthesis method for operations research optimization based on high-quality seed data in generating mathematical models and solving code. For comparative experiments, two operations research optimization problem scenarios were selected: path planning and inventory management. These problems were generated from an initial task pool using a few-shot prompting technique and automatically expanded to multiple problem scenarios. The generated mathematical model and code were then executed in an isolated virtual environment, and relevant performance data was recorded.
[0254] During the experimental preparation phase of this invention, an initial task pool consisting of multiple seed data samples is constructed based on historical project experience. Each seed data sample includes a problem description, a corresponding mathematical model, and a solution code. Specifically, the seed data for the path planning problem aims to optimize logistics distribution routes, with the goal of minimizing total transportation costs while considering transportation time windows and vehicle capacity constraints; the seed data for the inventory management problem aims to optimize inventory turnover, with the goal of minimizing inventory holding costs while meeting demand fluctuations and storage capacity constraints.
[0255] For the comparative test, the currently commonly used manual modeling and code generation methods were used as the control group for the comparative technology. The comparative technology process generally includes the following steps:
[0256] Problem modeling requires manual work by domain experts. For example, in the case of path planning, experts develop a mathematical model based on the problem description, typically based on linear programming or mixed integer programming. The optimization objective (such as minimizing path or cost) and constraints (such as time windows and capacity limits) in the model are manually analyzed and entered.
[0257] Code generation also requires manual effort. Typically, experts manually write code based on the model and solve it using open-source solvers such as PuLP or Gurobi. The code generation process involves importing the solver library, defining decision variables, and writing the objective function and constraints.
[0258] Execute the solver to obtain the optimal solution. Since the comparative technology relies on manual modeling and code generation, it is less efficient. Especially when the problem complexity is high, it is prone to model inaccuracy or long solution time.
[0259] In contrast, the present invention uses a few-sample hinting technique to automatically generate mathematical models and code suitable for different problem scenarios, significantly improving generation efficiency and model accuracy. During the experiment, researchers tested the performance of the present invention and comparative techniques in various problem scenarios, focusing on four metrics: model complexity (number of constraints), solution accuracy (objective function value), execution time, and memory usage.
[0260] Through enhanced operations, the present invention can expand the generated data samples. For example, in a path planning problem, the system generates multiple different data samples by modifying the optimization objective (e.g., from minimizing path length to minimizing travel time) and the constraints (e.g., increasing or decreasing the time window). The generated code is executed in an isolated virtual environment, and solution logs, execution time, and memory usage are recorded. Comparative experiments show that the present invention has significant advantages in terms of the complexity of the generated mathematical model and code execution efficiency.
[0261] The details are shown in Table 1 below:
[0262] Table 1 Comparison of generated results
[0263] Parameter name Path planning problem (this invention) Inventory Management Problem (This Invention) Path Planning Problem (Comparative Techniques) Inventory Management Problems (Comparative Technology) Model complexity (number of constraints) 18 20 11 15 Accuracy of the solution (objective function value) 98.70% 95.30% 90.20% 85.60% Execution time (seconds) 1.9 2.4 4.5 5.3 Memory usage (MB) 162 155 189 182 Optimal solution success rate (%) 96 92 83 78
[0264] It can be clearly seen from the table data that the method of the present invention is significantly superior to the comparison technology in many aspects, and has good adaptability and scalability in different problem scenarios.
[0265] First, in terms of model complexity (measured by the number of constraints), the present invention demonstrates stronger modeling capabilities. For the path planning problem, the present invention generated a mathematical model containing 18 constraints, while the comparative technique only generated 11 constraints. For the inventory management problem, the present invention's model contained 20 constraints, while the comparative technique's model contained only 15 constraints. This demonstrates that the present invention can automatically generate more complex and complete mathematical models through small-sample prompting technology, covering more business constraints and optimization requirements. This increase in complexity ensures that the model can more comprehensively describe the various constraints in real-world problems without significantly increasing computational cost, thereby improving the accuracy of the solution.
[0266] In terms of solution accuracy. In the path planning problem, the optimal solution solved by the code generated by the present invention has an accuracy of 98.7%. In comparison, the accuracy of the comparison technology of manual modeling is only 90.2%. In the inventory management problem, the accuracy of the present invention is 95.3%, while the comparison technology is only 85.6%. This difference shows that the mathematical model based on the automatic generation of the present invention can better capture the subtle differences in the problem and ensure that the solution is closer to the actual optimal solution. This improvement in accuracy is very critical, especially in scenarios with high accuracy requirements such as logistics and inventory management, which can bring significant cost savings and efficiency improvements.
[0267] In terms of execution time. In the path planning problem, the code execution time of the present invention is 1.9 seconds, while the comparison technology requires 4.5 seconds to complete the solution. In the inventory management problem, the execution time of the present invention is 2.4 seconds, while the comparison technology requires 5.3 seconds. The reason for this difference in execution time is that the present invention significantly reduces the time required for manual code writing and debugging by automatically generating code and efficiently calling the solver. At the same time, the model structure generated by the present invention is more efficient, reducing unnecessary calculation steps in the solution process. In large-scale optimization tasks, this time difference will be significantly amplified, resulting in huge efficiency advantages.
[0268] In terms of memory usage, the code generated by the present invention takes up less memory when executed. In the path planning problem, the memory usage of the present invention is 162MB, while the comparison technology is 189MB. In the inventory management problem, the memory usage of the present invention is 155MB, while the comparison technology is 182MB. The reduction in memory usage means that the present invention can better utilize computing resources when solving complex problems, avoiding solution interruptions or performance degradation caused by insufficient memory. This is especially important when dealing with large-scale data sets and complex problem scenarios, and can significantly improve the stability and processing power of the system.
[0269] Finally, regarding the success rate of optimal solutions, the present invention achieved a 96% success rate for path planning problems, while the comparison technique achieved an 83% success rate. In inventory management problems, the present invention achieved a 92% success rate, while the comparison technique achieved only 78%. This demonstrates that the present invention is able to more consistently find optimal solutions when generating code, reducing failures caused by inaccurate models or improper solver settings. In comparison techniques, manual modeling and code writing often involve significant manual errors and adjustment costs, often requiring multiple debugging sessions to find a suitable solution. However, the present invention significantly reduces this uncertainty through automated processes.
[0270] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.
Claims
1. A data synthesis method for operational optimization based on high-quality seed data, characterized by: include, Building an initial task pool, wherein the initial task pool includes multiple seed data samples, each seed data sample includes a question, a model, and a code; Based on the problems in the seed data sample, we use the few-sample prompting technology to expand to multiple problem scenarios and generate corresponding complete problem samples; Based on the problem samples, combined with the mathematical models in the initial task pool, a mathematical model corresponding to the corresponding problem samples is generated through the few-sample prompt technology; Based on the generated mathematical model, the code corresponding to the mathematical model is generated through the few-shot prompting technology; Expand the generated data samples through augmentation operations; Perform quality checks by executing the generated code; Construct an initial task pool, which contains multiple seed data samples. Each data sample includes a question, a model, and a code. Specifically, the following steps are included: Defining problem types, including resource allocation problems, path planning problems, inventory management problems, and scheduling problems, and extracting key elements of the problems; Extract models including linear programming, integer programming, mixed integer programming, dynamic programming and stochastic programming types, and extract the mathematical expressions, variables and parameters of the models; Extract the code including model construction, solution process and result processing, as well as code comments and documentation; Use data structures to define problem pools, model pools, and code pools; Integrate the problem pool, model pool, and code pool to form the initial task pool; Use a relational database to store task samples and add metadata and tags to them; Based on the problems in the seed data sample, the few-sample prompt technology is extended to multiple problem scenarios, which includes the following steps: Select a seed problem from the constructed initial task pool, and the seed problem must conform to the type of operations optimization problem defined in the initial task pool; Extract optimization objectives, constraints, and decision variables from the seed problem; According to the description of the seed problem, a prompt template with an example is designed, wherein the prompt template includes the problem type, the description of the optimization goal and the constraints, and the content of the prompt template is adjusted according to the type of the problem; Add specific scenarios and optimization requirements to the prompt template to complete the design of the prompt template; Input the designed prompt template into the language model, which will generate N different operations optimization problem scenarios based on the seed data and prompt template; The problem scenarios are verified and screened by verifying whether the scenario descriptions of the generated questions are reasonable and removing duplicate questions that are too similar to the seed questions. Generate the corresponding complete question sample, which includes the following steps: Extract background information from the seed question and further parse the question description using natural language processing technology to extract key elements and form a complete question description; Extract optimization objectives from new problem scenarios and match mathematical model types based on the type and complexity of the problem; Extract constraints from new problem scenarios and check whether the logic and conditions are reasonable; Integrate the complete problem description, optimization objectives and constraints to form a complete operations optimization problem sample; The generated data samples are expanded through enhancement operations, which specifically include the following steps: prompting the language model to identify modifiable parts in the mathematical model, wherein the modifiable parts include optimization objectives and constraints; Randomly select one of the potential modifiable elements and generate new data samples with different optimization requirements by modifying the optimization objectives and constraints; Prompt the language model to restate the existing problem description in various forms; Generate problem descriptions with different semantic expressions, and the restatement process allows for diverse language expressions; For complex operations optimization problems, language model recognition and modeling techniques are provided; By prompting the language model to generate different modeling schemes, one of the modeling techniques is randomly selected to modify and replace the existing mathematical model; By applying different modeling techniques, we can generate diverse data samples suitable for different problem complexities and scenario requirements; By executing the generated code, quality check is performed, which includes the following steps: Extract the core modules from the generated code, check the code integrity and whether the required mathematical solution libraries are correctly imported; Create an isolated virtual environment for code execution and provide input data; Call the solver to execute the generated code and capture the execution log and exceptions; Set evaluation metrics based on code optimization time, solution accuracy, and resource usage; Read the solver output to verify whether the solution was found successfully and check whether the solution output by the solver satisfies all constraints; Evaluate the output solution based on the evaluation indicators to determine whether the quality of the solution meets expectations; The solution that runs successfully and meets expectations is defined as the optimal solution; For the code sample with the optimal solution, the execution result of the sample is recorded and saved, and marked as a successful sample.
2. The method for synthesizing operations optimization data based on high-quality seed data according to claim 1, characterized in that: Based on the problem samples, combined with the mathematical model in the initial task pool, a mathematical model corresponding to the corresponding problem sample is generated through the few-sample prompt technology, which specifically includes the following steps: Analyze the background of the problem sample, identify the operational optimization type of the problem, and extract resource information; Extract optimization objectives from problem samples, clarify the specific content of optimization, and identify the form of optimization objectives; Extract all constraints from the problem sample and specify the numerical limits involved in each constraint; Retrieve mathematical models of similar problems from the initial task pool based on the type of problem sample, and further match the form of the optimization objective and the complexity of the constraints; Extracting mathematical model templates from the retrieved similar problems; Structurally mark the extracted mathematical model template; Design a few-shot prompt template that includes a problem description and a reference mathematical model template; Input the few-shot prompt template into the language model, guide the language model to generate the optimization goal based on the problem sample and the constraints consistent with the problem description, and form a corresponding mathematical model for the corresponding problem sample; Generate its decision variables based on the formed mathematical model and clarify its limitations.
3. The method for synthesizing operations optimization data based on high-quality seed data according to claim 1, characterized in that: Based on the generated mathematical model, the code corresponding to the mathematical model is generated through the few-sample prompting technology, which specifically includes the following steps: Extract the problem description, optimization target description, constraint description and code prompts from the generated mathematical model to form a prompt template; Input the prompt template into the language model to generate code that imports the relevant mathematical solution library; Use the library classes to define classes of optimization problems; Use LpVariable to define the decision variables in the optimization problem; Generate optimization target code that defines the optimization goal and adds constraints; By calling the solver, we start solving the optimization problem and find a solution that satisfies all constraints and optimizes the objective. Outputs the optimal solution found by the solver.
4. A data synthesis device for operations optimization based on high-quality seed data, based on the data synthesis method for operations optimization based on high-quality seed data according to any one of claims 1 to 3, characterized in that: include, The seed data management module builds and manages the initial task pool and stores multiple seed data samples containing questions, models, and codes; The question expansion module uses a few-sample prompting technique to expand questions in the seed data to multiple different question scenarios and generate corresponding complete question samples; The mathematical model generation module generates the corresponding mathematical model based on the expanded problem samples using the few-sample prompting technology; The code generation module, based on the generated mathematical model, uses the few-shot hinting technology to generate operational optimization code that can solve the model; Data enhancement module, which expands the generated data samples through various enhancement operations; The execution and quality inspection module executes the generated code to check its functional integrity, the output quality of the solver, and the rationality of the solution.
5. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the operations optimization data synthesis method based on high-quality seed data according to any one of claims 1 to 3 are implemented.
6. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the operations optimization data synthesis method based on high-quality seed data according to any one of claims 1 to 3 are implemented.
Citation Information
Patent Citations
Task processing method and task processing system
CN119336477A