A competition program generation method based on blackboard-driven search and agent cooperation

By employing blackboard-driven search and agent collaboration, the problems of repeated trial and error and lack of global planning in large language models for competitive algorithm problems are solved. This enables the generation of efficient programs that meet correctness and performance constraints within a limited computational budget, thereby improving the accuracy and efficiency of competitive program generation.

CN122173062APending Publication Date: 2026-06-09NANTONG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
NANTONG UNIV
Filing Date
2026-02-02
Publication Date
2026-06-09

AI Technical Summary

Technical Problem

Existing large language models struggle to construct accurate problem-solving strategies for competitive algorithm problems. They lack structured shared knowledge representations, and cross-round reasoning evidence and repair history are often inconsistent. They also lack global planning mechanisms, leading to repeated trial and error and early suboptimal decisions, which affect the correctness and efficiency of the generated program.

Method used

The method employs blackboard-driven search and agent collaboration. Through problem modeling and blackboard initialization, a structured representation is generated. Combined with Monte Carlo tree search and multi-module collaboration, global planning and iterative optimization are performed to achieve explicit planning of candidate programs and multi-strategy collaboration. Open bidding and policy priors guide the search. Combined with rapid screening and deep evaluation, multiple agents are dynamically collaborated to generate, test and repair.

Benefits of technology

It significantly reduced the generation failure rate, improved the ability to handle complex constraints and multi-strategy branches, enhanced the correctness and efficiency of program generation, reduced repeated trial and error and computational costs, and enhanced the interpretability and auditability of the process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122173062A_ABST
    Figure CN122173062A_ABST
Patent Text Reader

Abstract

The application provides a competition program generation method based on blackboard-driven search and agent cooperation, and belongs to the technical field of software engineering and intelligent code generation. The method comprises the following steps: S1, obtaining a competition topic and completing problem modeling, initializing a shared blackboard and a search tree root node, and writing in constraint and boundary points; S2, generating multiple competition strategies and scoring to form strategy priori, and writing back to the blackboard for guiding subsequent search; S3, taking a candidate code + blackboard context as a state, taking generation / evaluation / repair as an action, and using the iterative search of the Monte Carlo tree search to score back; S4, dynamically cooperating to execute generation, testing and repair according to blackboard information, continuously writing back evidence and outputting the optimal candidate result. The method can realize multi-agent cooperation and knowledge reuse under global search constraints, thereby improving the correctness and stability of the competition program generation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of software engineering and intelligent code generation, and relates to a method for generating competition programs based on blackboard-driven search and agent collaboration. Background Technology

[0002] Competition program generation aims to automatically synthesize correct and efficient program solutions for algorithmic problems in programming competitions. Unlike general code generation, competition problems typically require explicit algorithm strategy selection, multi-step logical reasoning, strict time and space complexity constraints, and systematic handling of boundary cases, thus relying more on the planning and searching of the candidate solution space.

[0003] As the application of large language models in natural language processing and code generation tasks expands, automated program generation solutions based on large language models are gradually increasing. However, existing large language models still generally suffer from the problem of "difficulty in constructing accurate problem-solving strategies" for competitive algorithm problems. This is because such tasks are often not a one-time mapping from problem description to code, but rather require searching, trial and error, and iterative improvement among multiple algorithm strategies and multiple code improvement paths.

[0004] To improve the accuracy and efficiency of competition program generation, existing research has attempted to combine search methods with large language models, using Monte Carlo tree search to iteratively execute in the sequential decision space to balance exploration and utilization and guide code generation and improvement. However, shortcomings remain in practical applications: on the one hand, the lack of structured shared knowledge representation makes it difficult for cross-round reasoning evidence, test feedback, and repair history to be consistent, easily leading to context drift and repeated trial and error; on the other hand, the lack of a global planning mechanism means that multi-module collaboration often relies on fixed processes or experience-based heuristics, making it difficult to systematically explore alternative strategies and recover from early suboptimal decisions.

[0005] How to solve the above-mentioned technical problems is the challenge facing this invention. Summary of the Invention

[0006] The purpose of this invention is to provide a competition program generation method based on blackboard-driven search and agent collaboration. This method enables the transformation of problem requirements into a structured shared context simply by reading the problem description of the basic competition algorithm problem. Within a limited computational budget, a submitable program that meets the correctness and performance constraints can be generated through global planning and multi-module collaborative iteration. This reduces the failure rate of one-time generation and improves the ability to handle complex constraints, boundary cases, and multi-strategy branches.

[0007] To achieve the above objectives, the technical solution adopted by this invention is as follows: a competition program generation method based on blackboard-driven search and agent collaboration. The method is executed at the orchestration layer of the competition program generation system. After obtaining the problem description of the target competition programming problem and before outputting the final submitable candidate program, the method performs explicit planning and iterative optimization of the candidate solution space, thereby generating the optimal candidate program that satisfies correctness and performance constraints within a limited budget. The method includes the following steps:

[0008] (1) Problem modeling and blackboard initialization steps: Obtain the problem The constraints, input / output specifications, invariants, and boundary cases in the problem statement are extracted and written into the problem model blackboard to form a structured representation. Based on this, the joint state of "candidate code + blackboard context" is defined, and the root node of the search tree and statistics such as the number of visits and value are initialized to provide a unified context for subsequent search and collaboration.

[0009] (1-1) Obtain the target competition programming problem to be solved and determine the search and scoring parameters: Obtain the target competition programming problem to be solved. and set search budget And the set of hyperparameters for search and evaluation, including exploration coefficients. Temperature coefficient Reward weight Bidding weight .

[0010] (1-2) Constructing a problem model blackboard and forming a structured problem representation: The problem description is transformed into structured fields and written into the problem model blackboard. The structured fields include at least: constraints, objective description, required invariants and boundary condition checklist, so as to form reusable constraints and specifications.

[0011] (1-3) Perform normalization processing to reduce semantic ambiguity and duplicate constraints: Perform unified expression and deduplication processing on the constraint set and specification description, including symbol / unit unification, range expression standardization and semantic equivalent constraint merging, thereby forming a normalized problem model representation and writing it on the blackboard.

[0012] (1-4) Define the joint state and initialize the root node of the search tree: Define the search state as a joint state consisting of candidate codes and blackboard context, and initialize the state of the root node of the search tree accordingly. The joint state is formally defined as:

[0013]

[0014] in, Indicates the first Candidate programs for the next iteration. Indicates the first The blackboard context for the next iteration. Simultaneously, the visit statistics and value statistics for each node in the search tree are initialized according to the following rules:

[0015]

[0016] in, For nodes Number of visits, For nodes The average value.

[0017] (2) The strategy hypothesis generation steps based on open bidding: The strategy analysis agent proposes multiple competing algorithm strategies based on the problem model blackboard; the success probability, implementation cost and risk of each strategy are quantitatively evaluated and the bidding score is calculated. The bidding score is normalized into the strategy prior and written into the strategy hypothesis blackboard to guide the subsequent strategy selection and expansion.

[0018] (2-1) Generate multiple policy hypotheses and write them into the policy hypothesis blackboard: The policy analysis agent generates multiple competing sets of algorithm policy hypotheses based on the problem model blackboard. The applicable conditions, complexity estimates, risk warnings, and key points of correctness for each strategy hypothesis are written into the strategy hypothesis blackboard for subsequent search phases for reference and reuse.

[0019] (2-2) Calculate the bid score and form the strategy prior distribution: for each strategy hypothesis Estimate its probability of success Implementation cost Risk of implementation The success probability, cost, and risk are combined according to preset weights to obtain a bidding score, which is then used to form a strategy prior distribution to achieve search bias. The bidding score is defined as:

[0020]

[0021] Execution of bid scores Normalization yields the policy prior:

[0022]

[0023] And Write the strategy hypothesis blackboard as a prior bias term for the subsequent search tree selection and expansion stages.

[0024] (3) Steps for joint state space planning based on Monte Carlo tree search: Taking the joint state as the node and policy selection / code generation / evaluation / patch application as the action, iteratively search according to the Monte Carlo tree search process of selection—simulation and evaluation—expansion—backhaul; the selection phase uses... Determine the expansion path, conduct a lightweight and rapid screening during the evaluation phase, and if successful, conduct a comprehensive screening. At the same time, write the failure evidence and diagnostic information back onto the blackboard for subsequent decision-making.

[0025] (3) Steps of joint state space planning based on Monte Carlo tree search

[0026] (3-1) Execute an iterative search process that includes selection, simulation and evaluation, expansion and backtracking: within budget Under the condition that the budget is not exhausted, a Monte Carlo tree search iterative process is performed on the joint state space of the "candidate code-blackboard context". The iterative process includes the following steps in sequence: selection phase, simulation and evaluation phase, expansion phase and backhaul update phase. Each phase is executed in a preset order until the termination condition is met (e.g., budget is exhausted or all candidate programs are obtained).

[0027] (3-2) Selection Phase: Based on Criteria determine the expansion path:

[0028] During the selection phase, an upper confidence bound is calculated for each candidate child node of the parent node. ) value, and according to the The value determines the expansion path to achieve a balance between utilizing high-value nodes and exploring low-access nodes. One implementation method is defined as:

[0029]

[0030] In an alternative implementation, to enhance exploration diversity, the... Value temperature This is converted into selection probabilities, and the expanded nodes are sampled and selected accordingly. The probabilities are defined as follows:

[0031]

[0032] (3-3) Simulation and Evaluation Phase: Rapid Screening, Deep Sandbox Evaluation, and Failure Evidence Write-Back: In the simulation and evaluation phase, a lightweight rapid screening is first performed on candidate programs to identify significant errors and reduce unnecessary computational overhead. When the rapid screening passes, a deep sandbox evaluation is triggered to obtain more reliable correctness and performance judgments. Failure evidence, diagnostic information, and counterexample inputs generated during the evaluation process are written back to the blackboard to drive subsequent strategy adjustments, patch generation, and repair decisions.

[0033] (3-4) Calculate the comprehensive reward and use it as a node value estimate: Decompose the evaluation results into correctness score, performance score, and structural quality score, and combine them according to preset weights to obtain a comprehensive reward to represent the node value. The comprehensive reward is defined as:

[0034]

[0035] (3-5) Backhaul Update: Perform recursive updates on the number of visits and average value: Backhaul the comprehensive reward R along the selected path to each node on the path to update the tree statistics, thereby providing data support for decision-making in subsequent selection stages. The update rules are as follows:

[0036] :

[0037]

[0038] (4) Dynamic collaboration and result output steps based on blackboard context: In the expansion phase, multi-agents are scheduled to perform generation, testing, diagnosis and repair according to the blackboard context, generate successor candidates and update the blackboard to add to the search tree; if all deep evaluations pass, the final program is output; otherwise, the reward update tree statistics are sent back and the iteration continues. After the budget is exhausted, the candidate with the best comprehensive score is output.

[0039] (4-1) Expansion phase: Enumeration and filtering actions based on blackboard context:

[0040] In state The next enumeration uses a set of actions and selects a subset from it to perform an expansion to control the branching factor. The action enumeration can be represented as:

[0041]

[0042] In one embodiment, this method adopts the principle of "evaluate first, then expand": that is, the current candidate is evaluated before expansion to generate actionable failure evidence and repair suggestions; the failure evidence and repair suggestions are used to constrain the selection of expansion actions and the construction of successor nodes, thereby distinguishing it from the "expand first, then evaluate" process of traditional Monte Carlo tree search and improving the effectiveness of expansion.

[0043] (4-2) Multi-agent cooperative scheduling: During the expansion and repair process, closed-loop cooperation among multiple agents is achieved through a shared blackboard. The reading and writing responsibilities of each agent are as follows:

[0044] 1) Policy Analysis Agent: Reads constraint, objective, invariant and boundary information from the problem model blackboard, generates and bids multiple policy hypotheses, and writes the policy set and its priors back to the policy hypothesis blackboard.

[0045] 2) Code generation agent: Reads the problem model blackboard and policy hypothesis blackboard, generates candidate programs based on the selected policy, and records the relevant metadata of the policy commitment and writes it back to the blackboard for tracking and reuse.

[0046] 3) Test Generating Agent: Read the boundary test case list and counterexamples from the problem model blackboard and the existing counterexample set in the test blackboard, generate high-discrimination tests and minimize failed inputs, and then write the new tests and counterexamples back to the test blackboard.

[0047] 4) Scoring agent: Outputs comprehensive reward based on a two-layer evaluation process. The system will also generate diagnostic reports and write new failure evidence back to the test blackboard and repair trigger information back to the repair blackboard.

[0048] 5) Code Repair Agent: Reads failure evidence and context information from counterexamples and test blackboards, problem model blackboards, policy hypothesis blackboards and repair blackboards, generates multi-granular patches and attaches applicable conditions, conflict sets, order dependencies and utility estimates to the patches, and then writes them back to the repair blackboard.

[0049] (4-3) Composable constraints and three-layer granularity parameterization of patch objects: In one embodiment, the patch is divided into three layers according to granularity:

[0050] L1: Low-cost local repair, including boundary handling, initialization correction, overflow repair, index correction, etc.;

[0051] L2: Medium-scale structural adjustments, including data structure replacement, loop reconstruction, and recursion to iteration;

[0052] L3: High-level strategy repair, including strategy switching, strategy combination, or decision logic reconstruction.

[0053] Simultaneously, to suppress combinatorial explosion in the repair space, each patch is configured with composable constraints, which include at least: applicable prerequisites, a set of mutually exclusive patches, and sequential dependencies. A patch object can be formally represented as:

[0054]

[0055] in, Indicates the patch granularity level. Indicates the conditions under which it applies. Represents a set of mutually exclusive relationships. This indicates a sequence dependency constraint. This represents a change operator for the candidate code.

[0056] (4-4) Child node construction and tree update: For the selected action The process involves performing the action and obtaining the successor state, then creating child nodes and attaching them to the search tree. This process can be represented as follows:

[0057]

[0058]

[0059] in, The subsequent joint state after the action is performed. To create a new child node, For the current node, For the search tree.

[0060] (4-5) Termination conditions and output strategy: When the depth evaluation meets the requirements... Immediately output the final program. As the result of the solution. Otherwise, a reward will be given. Feedback is sent to update tree statistics and continue iterating; when the budget is exhausted, the historical best candidate procedure is returned. ,in Based on historical best reward Maximum certainty.

[0061] Meanwhile, this invention also provides a competition program generation method system based on blackboard-driven search and agent collaboration, comprising:

[0062] The problem modeling and blackboard initialization module is configured to perform the following process: obtain the target competition programming problem to be solved, construct the problem model blackboard, convert the problem description into a structured representation and write the constraints, target description, required invariants, boundary condition check key information; initialize the search tree root node state based on the blackboard, and complete the tree initialization settings;

[0063] The algorithm strategy hypothesis module is configured to perform the following process: open bidding-based strategy hypothesis generation: the strategy analysis agent generates multiple competing algorithm strategy hypotheses based on the problem model blackboard; for each strategy hypothesis, the success probability, implementation cost and risk are estimated and the bidding score is calculated. The bidding score is normalized to form the strategy prior and written into the strategy hypothesis blackboard for subsequent search bias and reuse.

[0064] The joint state space planning module is configured to execute the following process: Monte Carlo tree search-based joint state space planning: defining the search state as a joint state consisting of candidate codes and blackboard context, and setting the action space as policy selection, code generation, patch application, and action evaluation; iterating the search using a four-stage process of Monte Carlo tree search: selection, simulation and evaluation, expansion, and backhaul update, where the selection stage is based on... The guidelines define the expansion path. In the assessment phase, a lightweight and rapid screening is conducted first, followed by a sandbox depth test and calculation of a comprehensive score. At the same time, diagnostic information and evidence of failure are written back to the blackboard to support subsequent decision-making.

[0065] The successor candidate program module is configured to perform the following process: dynamic coordination and result output based on blackboard context: during the expansion phase, based on the current blackboard context, the multi-agent coordinates code generation, test generation, scoring diagnosis and code repair actions to generate successor candidate programs and corresponding blackboard updates and add them as child nodes to the search tree; if all deep evaluations pass, the final program is output; otherwise, the reward is returned to the update tree statistics and the iteration continues until the budget is exhausted and the optimal candidate program is returned.

[0066] Meanwhile, the present invention proposes an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed, it implements the steps of the method described in the present invention.

[0067] Furthermore, the present invention proposes a computer-readable storage medium having a computer program stored thereon, the computer program being configured to implement the steps of the method described in the present invention when invoked by a processor.

[0068] Finally, the present invention provides a computer program product comprising a computer program / instructions that, when executed by a processor, implement the steps of the method described in the present invention.

[0069] Compared with the prior art, the beneficial effects of the present invention are as follows:

[0070] 1) Improved success rate and robustness: By using the problem model blackboard to structure and unify constraints, target specifications, invariants and boundary test cases, code generation, testing and fixing are all executed under consistent semantics, which significantly reduces failures caused by misinterpretation of the question and omission of boundaries, thereby improving the pass rate and adaptability across question types.

[0071] 2) Wider search coverage and less prone to getting stuck in local optima: Open bidding is used to generate multi-strategy competition, and the bidding scores are used to form strategy priors to guide the allocation of search resources, reducing early convergence and strategy bias caused by single-path heuristics, and improving the coverage of different algorithm routes and the probability of discovering the global optimum.

[0072] 3) Higher computational efficiency and lower trial-and-error costs: A two-layer evaluation mechanism of "rapid screening + sandbox deep testing" is introduced to prioritize the elimination of obviously erroneous candidates at low cost and concentrate deep testing resources on high-potential branches; at the same time, failure evidence is written back to the blackboard for subsequent decision-making, reducing repeated ineffective expansion and blind rewriting.

[0073] 4) More controllable, more efficient and interpretable repair: Driven by failure evidence, targeted repair is achieved, and the repair space combinatorial explosion is suppressed by three-layer patch granularity and composability constraints; multi-agent closed-loop collaboration and intermediate product reuse are achieved with the help of blackboard, while retaining policy priors, counterexamples and patch metadata, enhancing process auditability and interpretability.

[0074] 5) By maintaining a structured shared context through the blackboard system and using Monte Carlo tree search as a global planner to dynamically schedule the generation, evaluation and repair actions of each functional module, the candidate algorithm strategies and code improvement paths can be explored more systematically within a limited budget, thereby improving the correctness and efficiency of the final program. Attached Figure Description

[0075] Figure 1 This invention provides a schematic diagram of the overall architecture and workflow of a competition program generation method based on blackboard-driven search and agent collaboration.

[0076] Figure 2 This is a schematic diagram of the Monte Carlo tree search process in an embodiment of the present invention.

[0077] Figure 3 This is a schematic diagram illustrating the information and data flow between the blackboard and the intelligent agent in an embodiment of the present invention. Detailed Implementation

[0078] To make the objectives, technical solutions, and advantages of this invention clearer, specific embodiments of the invention will be described below with reference to the accompanying drawings. It should be understood that this invention is not limited to the following embodiments, and any equivalent substitutions or modifications made by those skilled in the art without departing from the spirit and substance of this invention should fall within the protection scope of this invention.

[0079] Example 1: See Figures 1 to 3 In this embodiment, the tested system is a competition program generation system. After obtaining the problem description of the target competition programming problem P and before outputting the final submitable candidate program, the system executes the method of this invention at the orchestration layer to explicitly plan and iteratively optimize the candidate solution space, thereby generating the optimal candidate program that satisfies the correctness and performance constraints within a limited budget.

[0080] In this embodiment, the system uses a shared blackboard to maintain a structured context, which includes at least: a problem model blackboard, a policy hypothesis blackboard, a test evidence blackboard, and a repair patch blackboard. Monte Carlo tree search is used as a global planner to model "candidate code + blackboard context" as a joint state. Policy selection, code generation, patch application, and evaluation are used as actions. During the search process, multiple agents are dynamically scheduled to collaboratively execute generation, testing, diagnosis, and repair.

[0081] The technical solution of this embodiment is: a competition program generation method based on blackboard-driven search and agent collaboration, comprising the following steps:

[0082] (1) Problem modeling and blackboard initialization

[0083] (1-1) Obtain the target competition programming problem to be solved and determine the search and scoring parameters: Obtain the target competition programming problem P to be solved, set the search budget, and set the set of hyperparameters for search and evaluation, including at least the exploration coefficient. Temperature coefficient Reward weight Bidding weight In one embodiment, the exploration coefficient is... Take 1.4, temperature coefficient Take 0.7; the reward weight is satisfied. and take respectively This is used to weight and combine the correctness component, performance component, and structural quality component; the bidding weights satisfy... and take respectively This is used to weight and combine the success probability, implementation cost, and implementation risk to obtain the bid score, where the success probability component is included positively, and the cost and risk components are included as penalty items.

[0084] (1-2) Constructing a problem model blackboard and forming a structured problem representation: The problem description is transformed into structured fields and written into the problem model blackboard. The structured fields include at least: constraint set, target specification, invariant set and boundary / degenerate use case set, so as to form a reusable constraint and specification set.

[0085] (1-3) Perform normalization processing to reduce semantic ambiguity and duplicate constraints: Perform unified expression and deduplication processing on the constraint set and specification description, including symbol / unit unification, range expression standardization and semantic equivalent constraint merging, thereby forming a normalized problem model representation and writing it on the blackboard.

[0086] (1-4) Define the joint state and initialize the root node of the search tree: Define the search state as a joint state consisting of candidate code and blackboard context, and initialize the state of the root node of the search tree accordingly; at the same time, initialize the statistics such as the number of visits and value of each node of the search tree according to the rules described in the invention, which are used for the selection and backhaul update of the Monte Carlo tree search in the future.

[0087] (2) Generation based on the strategy assumption of open bidding

[0088] (2-1) Generate multiple strategy hypotheses and write them into the strategy hypothesis blackboard: The strategy analysis agent generates multiple sets of competing algorithm strategy hypotheses based on the problem model blackboard, and writes the applicable conditions, complexity estimates, risk warnings and correctness points of each strategy hypothesis into the strategy hypothesis blackboard for subsequent search phase calls and reuse.

[0089] (2-2) Calculate the bid score and form the strategy prior distribution: For each strategy hypothesis, estimate its success probability, implementation cost and implementation risk, combine the success probability, cost and risk according to the preset weight to obtain the bid score, and normalize the bid score to obtain the strategy prior; write the strategy prior into the strategy hypothesis blackboard as the prior bias term for the subsequent search tree selection and expansion stage.

[0090] (3) Joint state space programming based on Monte Carlo tree search

[0091] (3-1) Execute an iterative search process including selection, simulation and evaluation, expansion and backhaul: Under the condition that the budget is not exhausted, perform a Monte Carlo tree search iterative process on the joint state space of "candidate code-blackboard context". The iterative process includes the selection phase, simulation and evaluation phase, expansion phase and backhaul update phase in sequence. Each phase is executed in a preset order until the termination condition is met (e.g., the budget is exhausted or all candidate programs are obtained).

[0092] (3-2) Selection Phase: Based on Criteria for determining the expansion path: Calculate the candidate child nodes of the parent node. Value, and based on The value determines the expansion path to balance utilization and exploration; in an alternative implementation, it can be... The temperature value is converted into a selection probability, and the expanded nodes are selected based on this probability to improve exploration diversity.

[0093] (3-3) Simulation and evaluation phase: First, perform a light-weight quick screening on the candidate program to identify significant errors and reduce unnecessary computational overhead; when the quick screening passes, trigger a sandbox deep evaluation to obtain more reliable correctness and performance judgment; the failure evidence, diagnostic information and counterexample input generated during the evaluation process are written back to the blackboard to drive subsequent strategy adjustment, patch generation and repair decisions.

[0094] (3-4) Calculate the comprehensive reward and use it as a node value estimate: Decompose the evaluation results into correctness score, performance score and structural quality score, and combine them according to preset weights to obtain the comprehensive reward to represent the node value.

[0095] (3-5) Backhaul update: Perform recursive update on the number of visits and average value: Backhaul the comprehensive reward along the selected path to each node on the path to update the tree statistics, thereby providing data support for the subsequent selection stage.

[0096] (4) Dynamic collaboration and result output based on blackboard context

[0097] (4-1) Expansion phase: Enumerate and filter actions based on blackboard context: Enumerate the set of available actions in the current joint state, and select a subset from them to perform expansion to control the branch factor; In one implementation, the principle of "evaluate first, then expand" is adopted, that is, the current candidates are evaluated before expansion to generate actionable failure evidence and repair suggestions, and these are used to constrain the selection of expansion actions and the construction of successor nodes to improve the effectiveness of expansion.

[0098] (4-2) Multi-agent cooperative scheduling: During the expansion and repair process, multi-agent closed-loop cooperation is achieved through a shared blackboard. The reading and writing responsibilities of each agent are as follows:

[0099] 1) Policy Analysis Agent: Reads constraint, objective, invariant and boundary information from the problem model blackboard, generates and bids multiple policy hypotheses, and writes the policy set and its priors back to the policy hypothesis blackboard;

[0100] 2) Code generation agent: Reads the problem model blackboard and policy hypothesis blackboard, generates candidate programs based on the selected policy, and records the relevant metadata of the policy commitment and writes it back to the blackboard for tracking and reuse;

[0101] 3) Test Generator Agent: Read the boundary test case list from the problem model blackboard and the existing set of counterexamples from the test evidence blackboard, generate high-discrimination tests and minimize failed inputs, and then write the new tests and counterexamples back to the test evidence blackboard;

[0102] 4) Scoring agent: Based on the two-layer evaluation process, output comprehensive rewards and diagnostic reports, and write new failure evidence back to the test evidence blackboard and repair trigger information back to the repair patch blackboard;

[0103] 5) Code Repair Agent: Reads failure evidence and context information from the test evidence blackboard, problem model blackboard, policy hypothesis blackboard and repair patch blackboard, generates multi-granularity patches and attaches applicable conditions, conflict sets, order dependencies and utility estimates to the patches, and then writes them back to the repair patch blackboard.

[0104] (4-3) Combinatorial constraints and three-layer granularity parameterization of patch objects: The patches are divided into three layers according to granularity: L1 low-cost local repair, L2 medium-scale structural adjustment, and L3 high-level strategy repair; at the same time, in order to suppress the explosion of repair space combination, each patch is configured with composable constraints, including at least the applicable premise, mutually exclusive patch set and sequential dependency.

[0105] (4-4) Child node construction and tree update: Execute the selected action and obtain the successor joint state, create child nodes and attach them to the search tree to form a search structure that can be selected, evaluated, expanded and updated back.

[0106] (4-5) Termination conditions and output strategy: When the sandbox depth evaluation meets the full pass condition, the final program is immediately output as the solution result; otherwise, the reward is returned and the iteration continues; when the budget is exhausted, the historical best candidate program is returned, and the historical best is determined according to the maximum reward of the historical best.

[0107] To verify the ability of the method of this invention to solve competitive algorithmic problems, two state-of-the-art methods were compared under example test conditions. Experiments were conducted on multiple public benchmark datasets, and a single-submission evaluation criterion was uniformly used to verify and statistically analyze the generated programs. Simultaneously, to reduce the dependence of the conclusions on a single model, four representative large models were selected as code generation engines and run under the same evaluation process and constraints to compare and observe the stable performance of the method under different model configurations. The results are shown in Table 1.

[0108] Table 1. Results of the present invention and baseline methods on four large language models and four datasets in terms of pass rate metrics.

[0109]

[0110] Experiments show that, on different large model configurations and multiple benchmark datasets, the overall pass rate of the proposed method is consistently improved compared to the comparative methods. This improvement can be attributed to the global planning collaboration mechanism of blackboard-based structured information maintenance and Monte Carlo tree search, thus proving that the proposed method outperforms representative baseline solutions in competitive program generation tasks.

[0111] Example 2: The present invention also provides a competition program generation method system based on blackboard-driven search and agent collaboration, comprising:

[0112] The problem modeling and blackboard initialization module is configured to perform the following process: obtain the target competition programming problem to be solved, construct the problem model blackboard, convert the problem description into a structured representation and write the constraints, target description, required invariants, boundary condition check key information; initialize the search tree root node state based on the blackboard, and complete the tree initialization settings;

[0113] The algorithm strategy hypothesis module is configured to perform the following process: open bidding-based strategy hypothesis generation: the strategy analysis agent generates multiple competing algorithm strategy hypotheses based on the problem model blackboard; for each strategy hypothesis, the success probability, implementation cost and risk are estimated and the bidding score is calculated. The bidding score is normalized to form the strategy prior and written into the strategy hypothesis blackboard for subsequent search bias and reuse.

[0114] The joint state space planning module is configured to execute the following process: Monte Carlo tree search-based joint state space planning: defining the search state as a joint state consisting of candidate codes and blackboard context, and setting the action space as policy selection, code generation, patch application, and action evaluation; iterating the search using a four-stage process of Monte Carlo tree search: selection, simulation and evaluation, expansion, and backhaul update, where the selection stage is based on... The guidelines define the expansion path. In the assessment phase, a lightweight and rapid screening is conducted first, followed by a sandbox depth test and calculation of a comprehensive score. At the same time, diagnostic information and evidence of failure are written back to the blackboard to support subsequent decision-making.

[0115] The successor candidate program module is configured to perform the following process: dynamic coordination and result output based on blackboard context: during the expansion phase, based on the current blackboard context, the multi-agent coordinates code generation, test generation, scoring diagnosis and code repair actions to generate successor candidate programs and corresponding blackboard updates and add them as child nodes to the search tree; if all deep evaluations pass, the final program is output; otherwise, the reward is returned to the update tree statistics and the iteration continues until the budget is exhausted and the optimal candidate program is returned.

[0116] Example 3: This example proposes an electronic system, including: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the method steps of the present invention.

[0117] Example 4: This example proposes a computer-readable storage medium storing a computer program thereon. When the computer program is executed by a processor, it implements the steps of the method described in this invention, which will not be repeated here.

[0118] Example 5: This example proposes a computer program product, including a computer program / instructions. When the computer program / instructions are executed by a processor, they implement the steps of the method described in this invention, which will not be repeated here.

[0119] It should be noted that the processing flow of embodiments 2-5 corresponds to the specific steps of the method provided in embodiment 1 of the present invention, and has the corresponding functional modules and beneficial effects of the method. Technical details not described in detail in this embodiment can be found in the method provided in embodiment 1 of the present invention.

[0120] The program code used to implement the methods of this application may be written in any combination of one or more programming languages. This program code may be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing device, such that when executed by the processor or controller, the functions / operations specified in the flowcharts and / or block diagrams are implemented. The program code may be executed entirely on a machine, partially on a machine, as a standalone software package partially on a machine and partially on a remote machine, or entirely on a remote machine or server.

[0121] The above are merely the most representative specific embodiments of the present invention. For those skilled in the art, various modifications, combinations, and substitutions can be made without departing from the principles and spirit of the present invention, and all such modifications, combinations, and substitutions should be considered to be included within the scope of protection defined by the appended claims.

Claims

1. A method for generating competition programs based on blackboard-driven search and agent collaboration, characterized in that, Includes the following steps: Step (1), Problem Modeling and Blackboard Initialization: Obtain the target competition programming problem to be solved, construct the problem model blackboard, convert the problem description into a structured representation and write the constraints, target description, required invariants, boundary condition check key information; initialize the search tree root node state based on the blackboard and complete the tree initialization settings; Step (2), generation of strategy hypotheses based on open bidding: The strategy analysis agent generates multiple competing algorithm strategy hypotheses based on the problem model blackboard; For each strategy hypothesis, estimate the success probability, implementation cost and risk, and calculate the bidding score. Normalize the bidding score to form the strategy prior, and write it into the strategy hypothesis blackboard for subsequent search bias and reuse. Step (3), joint state space planning based on Monte Carlo tree search: the search state is defined as a joint state consisting of candidate code and blackboard context, and the action space is set as strategy selection, code generation, patch application and evaluation actions; the Monte Carlo tree search is used to iterate the search in four stages: selection, simulation and evaluation, expansion and backlog update. In the selection stage, the expansion path is determined based on the UCB criterion. In the evaluation stage, a lightweight and fast screening is performed first, then the sandbox depth test is triggered and the comprehensive score is calculated. At the same time, the diagnostic information and failure evidence are written back to the blackboard to support subsequent decision-making. Step (4), Dynamic collaboration and result output based on blackboard context: In the expansion phase, based on the current blackboard context, the multi-agents are coordinated to perform code generation, test generation, scoring diagnosis and code repair actions, generate successor candidate programs and corresponding blackboard updates and add them as child nodes to the search tree; If all deep evaluations pass, the final program is output; otherwise, the reward is sent back to update the tree statistics and the iteration continues until the budget is exhausted, at which point the optimal candidate program is returned.

2. The method for generating competition programs based on blackboard-driven search and agent collaboration according to claim 1, characterized in that, Step (2) includes: The strategy analysis module reads the constraint information, target specifications, invariants, and boundary use case information accumulated in the problem model blackboard, and generates multiple competing sets of algorithm strategy assumptions. ; for any strategy assumption The probability of success is estimated by the strategy analysis module. Implementation cost With risk And normalize them respectively to obtain Based on this, the bid score is calculated. : ; in, These are bid weighting coefficients, used to adjust the probability of success. Implementation cost Risk of implementation Bid scores The intensity of the influence, and satisfying as well as The bid scores of each strategy assumption will be processed Normalization forms a priori strategy : ; The strategy assumptions, bid scores, and strategy priors are written into the strategy assumption blackboard to bias the subsequent expansion and selection process of the Monte Carlo tree search, and to support reuse in subsequent search iterations.

3. The method for generating competition programs based on blackboard-driven search and agent collaboration according to claim 1, characterized in that, Step (3) includes: The search state is defined as a joint state consisting of candidate codes and blackboard context. The candidate code is The blackboard context is ,satisfy: ; The action space is defined as: strategy selection action, code generation action, patch application action, and evaluation action; and based on the actions... Triggering state transition: ; The Monte Carlo tree search process employs an iterative four-stage workflow: selection, simulation and evaluation, expansion, and backtracking update. Step (3-1), Selection Phase: Select the child nodes of the current node. Calculate selection criteria : ; in, For nodes The return statistics, For the number of times a node is accessed. This represents the number of times the parent node has been visited. To explore coefficients; and to determine the expansion path based on the selection index; Will Temperature coefficient of The transformation yields the selection probability: ; in, This is a function for finding the maximum value of an input value within a candidate set. Let the set of candidate child nodes participating in the selection under the same parent node be denoted as . Its corresponding The values ​​are respectively ,but, ; In all candidate child nodes Take the largest value from the exponent terms. Perform a translation without changing Under the premise of relative probability distribution, the risk of numerical overflow in exponential operations is reduced, and numerical stability is improved; Step (3-2), Simulation and Evaluation Phase: The evaluation module first performs a lightweight quick screening on the candidate code; when the lightweight quick screening passes, a sandbox depth test is triggered and a comprehensive score is calculated. The diagnostic information and failure evidence generated from the assessment are written onto the test evidence blackboard to support subsequent decision-making and remediation. This is the combined reward value used for Monte Carlo tree search node value estimation and backhaul updates; The correctness score is used to characterize the degree to which the candidate program meets the functional specifications and constraints of the problem. The performance score is used to characterize the candidate program's performance in terms of time complexity, runtime, and memory usage. The structural quality score is used to characterize structural indicators such as readability, modularity, completeness of boundary handling, and potential defect risks of candidate programs. ; The This is a non-negative reward weighting coefficient used to weight and combine the scores of correctness, performance, and structural quality, and satisfies the following conditions: ; Step (3-3), Expansion Phase: In the expansion phase, based on the current blackboard context, the code generation module generates candidate code, the test generation module generates test cases, the diagnostic module outputs defect location information, and the repair module generates patches and applies them to the candidate code; the generated successor candidate programs and their corresponding blackboard updates are added to the search tree as child nodes, and the patches and repair records are written to the repair patch blackboard; Steps (3-4), Update Backhaul Phase: The overall score will be updated. The data is sent back along the extended path to update node statistics, where the number of visits is updated as follows: ; Return statistics are updated based on average returns as follows: ; in, Represents any node in a Monte Carlo tree search; Represents a node The access count statistic is used to record the cumulative number of times a node is accessed / updated during the selection-simulation-backhaul process; Represents a node The average return statistic is used to characterize the expected total reward of the node in the historical simulation evaluation; This represents the comprehensive score / comprehensive reward value obtained from the leaf node simulation and evaluation phase and transmitted back along the extension path; the symbol " "" indicates an assignment update operation, that is, updating the left-side statistic with the calculation result on the right.

4. A method system for generating competition programs based on blackboard-driven search and agent collaboration, characterized in that, The system comprising the steps of applying the method according to any one of claims 1 to 3, wherein the system includes: The problem modeling and blackboard initialization module is configured to perform the following process: obtain the target competition programming problem to be solved, construct the problem model blackboard, convert the problem description into a structured representation and write the constraints, target description, required invariants, boundary condition check key information; initialize the search tree root node state based on the blackboard, and complete the tree initialization settings; The algorithm strategy hypothesis module is configured to perform the following process: open bidding-based strategy hypothesis generation: the strategy analysis agent generates multiple competing algorithm strategy hypotheses based on the problem model blackboard; for each strategy hypothesis, the success probability, implementation cost and risk are estimated and the bidding score is calculated. The bidding score is normalized to form the strategy prior and written into the strategy hypothesis blackboard for subsequent search bias and reuse. The joint state space planning module is configured to execute the following process: Monte Carlo tree search-based joint state space planning: the search state is defined as a joint state consisting of candidate code and blackboard context, and the action space is set as policy selection, code generation, patch application, and evaluation actions; iterative search is performed using a four-stage process of Monte Carlo tree search: selection, simulation and evaluation, expansion, and backlog update. In the selection stage, the expansion path is determined based on the UCB criterion. In the evaluation stage, a lightweight and rapid screening is performed first, then a sandbox depth test is triggered and a comprehensive score is calculated. At the same time, diagnostic information and failure evidence are written back to the blackboard to support subsequent decision-making. The successor candidate program module is configured to perform the following process: dynamic coordination and result output based on blackboard context: during the expansion phase, based on the current blackboard context, the multi-agent coordinates code generation, test generation, scoring diagnosis and code repair actions to generate successor candidate programs and corresponding blackboard updates and add them as child nodes to the search tree; if all deep evaluations pass, the final program is output; otherwise, the reward is returned to the update tree statistics and the iteration continues until the budget is exhausted and the optimal candidate program is returned.

5. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the computer program is executed, it implements the steps of the method as described in any one of claims 1 to 3.

6. A computer-readable storage medium having a computer program stored thereon, characterized in that, The computer program is configured to implement the steps of the method according to any one of claims 1 to 3 when invoked by a processor.

7. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, they implement the steps of the method according to any one of claims 1 to 3.