A Joint Scheduling Method for Port Resources Based on Multi-Agent Collaboration and Retrieval Enhancement
By constructing a domain knowledge base and generating structured mathematical models from natural language input, and combining them with large language models for automated code generation, the problem of coordinated optimization of energy and berth allocation in port scheduling was solved, achieving rapid response and global optimization, and reducing reliance on professional personnel.
Patent Information
- Application Number
- CN202611360978.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-03
- Publication Date
- 2026-11-17
AI Technical Summary
Existing port scheduling methods fail to effectively coordinate energy system operation and berth allocation, resulting in a lack of global optimization between energy and logistics decisions. Model adjustments are complex and dependent on professional personnel, making it difficult to respond quickly to sudden load changes and changes in business conditions.
A joint scheduling method for port resources based on multi-agent collaboration and retrieval enhancement is adopted. A domain knowledge base is constructed and a structured mathematical model is generated through natural language input. Combined with a large language model, automated code generation and debugging are performed to achieve joint optimization scheduling of energy and berths.
It has achieved overall optimization and control of energy system and berth allocation, reduced reliance on professional personnel, shortened model adjustment time, ensured the integrity and traceability of the model, and adapted to business scenarios with frequent adjustments.
Smart Images

Figure CN123117953A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the fields of artificial intelligence and port scheduling technology, and specifically relates to a joint scheduling method for port resources. Background Technology
[0002] With the continued growth of maritime trade, the construction of green and smart ports has become a core direction for the transformation of the global shipping industry. Against the backdrop of comprehensive port electrification, the large-scale adoption of High-Voltage Shore Power (HVSP) technology has significantly reduced carbon emissions during ship berthing, but it has also made port load structures increasingly complex. Modern port integrated energy systems typically include distributed renewable energy sources (photovoltaics, wind power), core power generation equipment (gas turbines), energy conversion equipment (electric chillers, electric boilers, heat exchangers), energy storage devices, and logistics infrastructure consisting of quay cranes and berths.
[0003] However, with the increasing scale of ports and the rising frequency of ship arrivals, existing technologies still face the following challenges in handling port energy scheduling and logistics allocation: First, energy operation and berth allocation are typically planned separately in traditional scheduling models. This information silo leads to poor collaborative decision-making capabilities between energy sources and loads. When faced with sudden load fluctuations caused by unexpected situations such as ships temporarily cutting in line or extreme weather fluctuations, the response speed is limited, potentially causing local power grid overload or energy waste. Second, joint scheduling of energy and berths involves discrete berth allocation and continuous energy flow control. The number of decision variables increases significantly with the number of berths and the scale of equipment. Traditional algorithms are prone to excessive computational scale and increased solution time when handling massive high-frequency business, making it difficult to meet the efficient solution requirements of full-process white-box decision-making. Third, the decision-making threshold is high and there is a lack of agile automated interaction. The underlying code of traditional models is usually written according to fixed scenarios, and the time required for adjustment and reconstruction is long. On-site dispatchers cannot easily adjust scheduling strategies quickly through natural language commands, and the system operation usually requires the participation of professionals with experience in operations research and programming. Therefore, the joint scheduling and intelligent decision-making of port energy systems and berth logistics, which are deeply integrated, has become an important issue of concern in the current cross-disciplinary field of transportation engineering and power systems.
[0004] There are also some existing scheduling methods that can achieve port resource scheduling, but existing technologies generally have the following problems:
[0005] 1. Traditional port scheduling methods treat energy system operation and berth allocation as two separate issues, resulting in a lack of effective coordination between logistics decisions and energy flow decisions, making it difficult to achieve global optimization at the system level.
[0006] 2. As the number of port berths, ships, and energy equipment increases, the existing joint optimization model also increases the number of discrete and continuous decision variables, constraints, and coupling relationships. This leads to a corresponding increase in the time required for model construction, parameter adjustment, and solution, making it difficult to adapt to scheduling scenarios that require frequent adjustments to business conditions.
[0007] 3. Existing scheduling systems typically rely on pre-written mathematical models, which require a high level of operations research and programming skills from on-site personnel. They are not convenient for quickly adjusting strategies using natural language, and the time required for model modification and verification is long when business conditions change.
[0008] 4. General-purpose large language models or single-keyword retrieval lack joint verification of formula symbols, variable units, equipment applicability, and business rules, which can easily lead to omissions of constraints, mismatches of variable meanings, or unclear sources of evidence, making it difficult to guarantee the integrity and traceability of the generated model. Summary of the Invention
[0009] To address the above problems, this invention proposes a joint scheduling method for port resources based on multi-agent collaboration and enhanced retrieval generation, comprising:
[0010] A joint scheduling method for port resources based on multi-agent cooperation and enhanced retrieval includes:
[0011] S1. Construct a domain knowledge base and vector index for joint scheduling of port energy and berths;
[0012] S2. Demand Modeling and Structured Mathematical Model Generation Based on Retrieval Enhancement: The system receives port scheduling requirements input by the user in natural language and generates five modeling sub-queries according to five fixed dimensions: objective function composition, energy balance, equipment operation constraints, scheduling and demand response, and expansion mechanism. Using the same text embedding model as when knowledge fragments are entered into the database, the five modeling sub-queries are converted into query vectors, and candidate knowledge fragments are retrieved from the vector space of the domain knowledge base. The candidate knowledge fragments retrieved from all modeling sub-queries are merged, and duplicates are uniformly removed according to the unique chunk_id of each knowledge fragment, generating recommended tags for the knowledge fragments. After user review, the fixed task description, global symbol dictionary, user-confirmed knowledge fragments, user's original requirements, and output structure requirements are assembled into the final modeling prompts. The system prompts, the final modeling prompts, and preset model generation parameters are input into the large language model to obtain a modeling output containing model variables, objective functions, and constraints. The demand modeling agent then forms a structured mathematical model element set M and a mixed-integer linear programming modeling scheme based on the modeling output.
[0013] S3. Business Data Access and Automatic Code Generation and Layered Closed-Loop Debugging Based on Multi-Agent Collaboration: Receives user-uploaded files, maps business fields to a user-confirmed set of mixed-integer linear programming modeling schemes, indices, and parameters, and performs automated quality verification; then, the code generation and debugging agent generates solver code based on the structured mathematical model, field mapping relationships, and standard data set, and performs static checks and controlled operation; when code, data, or model errors occur, code-level repair, data-level repair, or model-level repair is triggered according to the error category until the solution passes acceptance.
[0014] S4. Perform joint optimization solution for port energy and berths: Call the mathematical programming solver to execute the debugged code, with the objective of minimizing the sum of fuel procurement cost, power grid interaction cost and equipment start-up and shutdown cost, and output berth arrangement and energy supply equipment operation plan under the condition of satisfying actual constraints.
[0015] Furthermore, the process of constructing a domain knowledge base and vector index for joint scheduling of port energy and berths includes:
[0016] Collect domain knowledge data on the joint scheduling of port energy and berths and segment the data into knowledge fragments. For the j-th knowledge fragment, generate a knowledge fragment vector. Simultaneously, the original variable symbol set of knowledge fragments and its symbol-unit correspondence Perform joint normalization to obtain a set of normalized variable symbols. The system will convert knowledge fragment vectors The fragment text, the fragment's unique ID (chunk_id), the knowledge category, the constraint type (constraint_type), the included variables, and the source file information are all written into the local Chroma vector database to form a domain knowledge base and vector index.
[0017] Furthermore, the process of receiving port scheduling requests input by users in natural language and generating five modeling sub-queries according to five fixed dimensions—objective function composition, energy balance, equipment operation constraints, scheduling and demand response, and expansion mechanism—includes the following:
[0018] A structured task description R is constructed based on optimization target information, business object information, constraint information, data requirement information, and hard condition information. Based on the target information O, business object A, constraint information C, data requirement D, and hard condition H in the structured task description R, query rewriting and query decomposition are performed on user requirements. Query rewriting includes unifying device names, business terms, variable symbols, units of measurement, and time expressions, and converting synonyms in natural language into preset professional terms.
[0019] Based on query rewriting, the global symbol dictionary is first read. Then, based on the user's modeling requirements, modeling sub-queries are generated according to five dimensions: objective function composition, energy balance, equipment operation constraints, scheduling and demand response, and extension mechanisms. One query is generated for each dimension. The objective function composition modeling sub-query retrieves the user-selected optimization objective, objective function term, cost or benefit, calculation parameters, and linearization rules. The energy balance modeling sub-query retrieves the port's electrical, thermal, and cooling power balance, as well as the energy input-output relationships between various energy supply, conversion, and storage devices and ship loads. The equipment operation constraint modeling sub-query retrieves equipment output boundaries, operating status, start-stop logic, ramp constraints, minimum operating time, minimum downtime, and conversion efficiency. The scheduling and demand response modeling sub-query retrieves ship arrival time, berth allocation, continuous berthing, berth overlap prevention, ship load, and demand response. The extension mechanism modeling sub-query retrieves extension requirements explicitly proposed by the user and supported by equipment configuration or business data.
[0020] The five generated modeling subqueries are validated for completeness. If a subquery is missing a target item, business object, constraint category, or user hard condition, the missing content is marked as a pending confirmation item and a supplementary query is generated. Only after user confirmation is the subquery used for subsequent vector retrieval. The five validated modeling subqueries are used to retrieve knowledge fragments corresponding to the current model elements.
[0021] Furthermore, using the same text embedding model as when the knowledge fragments were added to the database, the five modeling subqueries are converted into query vectors respectively. The process of retrieving candidate knowledge fragments in the vector space of the domain knowledge base includes:
[0022] For the l-th modeling subquery, the system generates a query vector using the same text embedding model as when the knowledge fragment was added to the database; the vector of the j-th knowledge fragment in the knowledge base was generated and saved using the same model during the knowledge base construction phase; the similarity between the query vector and the vector of the j-th knowledge fragment is calculated, and the top vectors with the highest similarity are selected. Each knowledge fragment, and each modeling subquery, yields... A knowledge fragment.
[0023] Furthermore, the process of uniformly deduplicating candidate knowledge fragments according to their unique chunk_id and generating recommended tags for those fragments includes:
[0024] All modeling subquery results are merged and deduplicated once according to the unique chunk_id of the knowledge fragment. When the same knowledge fragment is retrieved by multiple modeling subqueries, only the highest vector similarity of the knowledge fragment in the modeling subquery retrieval and the modeling subquery that generated the highest vector similarity are retained. The system generates recommendation tags based on the sorting position and relevance threshold.
[0025] Furthermore, after user review, the process of assembling the fixed task description, global symbol dictionary, user-confirmed knowledge fragments, user's original requirements, and output structure requirements into the final modeling prompts includes:
[0026] Regarding the review of knowledge fragment c j For each normalized variable ω involved, record the variable name, physical meaning, unit of measurement, value range, energy flow direction, applicable equipment, and constraint relationships to form a variable attribute record. If two audit knowledge fragments involve the same normalized variable ω, first perform synonym normalization and unit conversion; after conversion, based on any two audit knowledge fragments... Perform conflict checks, and compile the checked knowledge fragments into a set of audited knowledge fragments.
[0027] For the set of knowledge fragments to be reviewed, based on the fixed task description Global symbol dictionary Knowledge fragments verified by users Original user needs and output structure requirements The modeling prompts are determined to be: , ⊕ indicates that text and structured content are concatenated in a preset order.
[0028] Furthermore, the process by which the demand modeling agent forms a structured mathematical model element set M and a mixed-integer linear programming modeling scheme based on the modeling output includes:
[0029] Demand modeling intelligent agent based on The set of elements M forming the structured mathematical model is as follows:
[0030]
[0031] Where M represents the complete set of structured model elements for the current scheduling task; I, P, X, F, G, These represent sets and indices, input parameters, decision variables, objective functions, constraint sets, and evidence mappings, respectively. Record the knowledge fragment number, user rule number, data field, and review status corresponding to each objective function item and constraint;
[0032] Format M according to the preset template into a MILP modeling scheme for user confirmation.
[0033] Furthermore, the process of mapping business fields to a user-confirmed set of mixed-integer linear programming modeling schemes, indexes, and parameters, and performing automated quality checks, includes:
[0034] Let the set of model input parameters after user confirmation be... , The input parameters for the u-th model are given; the set of candidate data fields extracted from user-uploaded files is as follows: , For the v-th candidate data field; and Perform field association, in Searching for parameters of each model Matching candidate fields And bind it;
[0035] Further checks were conducted on the number of ships, equipment, time series length, missing fields, and index range. If the data matched the model, the quality check was considered passed. The fields that have passed quality verification and have been bound, along with their data, will form a standard data set. .
[0036] Beneficial effects:
[0037] 1. This invention optimizes and controls the operation of the energy system and the allocation of berths as a whole, and can effectively coordinate logistics decisions and energy flow decisions to achieve global optimization at the system level.
[0038] 2. The joint optimization model of the present invention can effectively cope with the situation where the number of port berths, ships and energy equipment increases, and the discrete and continuous decision variables, constraints and coupling relationships increase accordingly. It can effectively control the solution time and can effectively adapt to scheduling scenarios that require frequent adjustment of business conditions.
[0039] 3. This invention uses natural language to quickly adjust strategies, reducing the requirements for personnel and effectively shortening the time required for model modification and verification when business conditions change.
[0040] 4. This invention achieves joint verification of formula symbols, variable units, equipment applicability, and business rules, which can effectively solve problems such as missing constraints, mismatched variable meanings, or unclear sources of evidence, and can ensure the integrity and traceability of the generated model. Attached Figure Description
[0041] Figure 1 The RAG model is based on the search and manual review interface;
[0042] Figure 2 This is a diagram showing the results of the joint scheduling of ships and berths.
[0043] Figure 3 This is a diagram showing the power balance of cooling, heating, and electricity in the port and the linkage between time-of-use electricity prices. Detailed Implementation
[0044] To address the problems existing in the background technology, and considering the economy, reliability, and logistical efficiency of port energy scheduling and berth allocation, this invention proposes a joint scheduling method for port energy and berths based on multi-agent collaboration and retrieval-enhanced generation. This method sets up four functional agents: demand modeling, data analysis, code generation and debugging, and result interpretation. It combines a domain knowledge base with retrieval-enhanced generation (RAG) technology and a large language model, aiming to solve problems such as the separation of logistics and energy flow in traditional scheduling, long adjustment cycles of joint models, high barriers to manual modeling, and the lack of professional verification and traceability of general models. Simulation verification shows that this invention can improve the generation efficiency, verifiability, and resource synergy of joint scheduling schemes while meeting the constraints of port energy system operation and berth operation. Its main processing steps include the following:
[0045] (1) Construct a knowledge base for the joint scheduling of port energy and berths:
[0046] This invention first constructs a domain knowledge base for the joint scheduling of port energy and berths, providing a searchable, verifiable, and traceable professional basis for subsequent user requirement structuring, mathematical model generation, and model verification. The domain knowledge base consists of five stages: knowledge data collection, knowledge fragment segmentation, knowledge fragment annotation, hybrid feature representation, and knowledge index writing.
[0047] The knowledge materials include the following four categories: The first category consists of publicly available papers and technical documents in the fields of port integrated energy systems, berth allocation, ship berthing, combined cooling, heating and power (CCHP), photovoltaic and wind power output, time-of-use pricing, gas turbines, CHP conversion equipment, and energy storage equipment operation. The second category includes national standards, industry standards, technical specifications, and equipment technical manuals related to the aforementioned equipment and business processes. The third category comprises user-uploaded equipment parameter files, ship data files, solar intensity data, wind speed data, and electricity price data that can be converted into model rules or parameter descriptions. The fourth category consists of historical mathematical models, modeling schemes, and error correction records generated by this system and manually confirmed by dispatchers or administrators, with checks completed on symbol meanings, units of measurement, constraint relationships, and solution results. The historical mathematical models are port energy and berth joint scheduling model files with clear sources, version numbers, and review records.
[0048] The Port Resource Joint Scheduling Decision System (hereinafter referred to as the System) assigns a source document number to each imported knowledge document and retains information such as file name, file version, source type, publication date, or import time. For documents containing text, formulas, and tables, the System identifies the title, paragraphs, formula groups, and table cells according to the original document's reading order and uses them as logical units to be segmented.
[0049] Logical units within the same source document are sequentially segmented. Adjacent logical units refer to two logical units within the same source document that are directly adjacent in reading order and without any other text paragraphs, formula groups, or table units inserted between them. When adjacent logical units belong to different heading levels, different formula groups, different tables, or different constraint categories, a segmentation boundary is set between them; similarly, a segmentation boundary is set when the semantic distance between adjacent logical units exceeds a preset threshold. The semantic distance is calculated from the initial text vectors of the adjacent logical units. ;in, This represents the semantic distance between the a-th logical unit and the (a+1)-th logical unit. and These are the initial semantic vectors of the two logical units; cos(·) is the cosine similarity function; when When the value exceeds a preset segmentation threshold, a segmentation boundary is set between the two logical units. The preset segmentation threshold is a numerical parameter configured before the knowledge base is built and can be adjusted according to the type of knowledge data. Complete formulas, formula groups, and their corresponding variable descriptions, unit descriptions, and constraint descriptions are saved as a whole and are not segmented into different knowledge fragments.
[0050] After segmentation, information such as segment text, source metadata, symbol set, symbol-unit correspondence, unique ID, and source reliability is established for each knowledge segment. The j-th knowledge segment is represented as:
[0051] ;
[0052] in, This is the j-th knowledge fragment; The main body of the passage should include at least text, formulas, table content, and their variable descriptions; For fragment metadata, at least the source document number, file name, version, chapter, page number or table location, knowledge category, and applicable device should be included; This refers to the set of variable symbols that appear in the text and formulas of the passage, such as ship berthing state variables, equipment operating state variables, power variables, and energy storage state variables; It is not a set of units mixed with symbols, but a set of correspondences between symbols and units of measurement, such as power symbols corresponding to MW, energy symbols corresponding to MWh, and time symbols corresponding to h; Each knowledge fragment is uniquely numbered; This represents the reliability of the fragment source. All the quantities mentioned above are deterministic data generated or registered during the knowledge base construction phase and are not random variables in the optimization model.
[0053] Source reliability The score is determined by the source authority and review status according to preset rules. Specifically, a normalized score is assigned to both the source authority and the review status. and The reliability of the fragment source is calculated according to a preset weight: ;in, A score for the authority of a source, determined based on the type of source material, the entity that published or compiled it, and the validity of the version. The review status score is determined based on whether the symbols, units, constraints, and solution results have been reviewed. and These are the preset non-negative weights for the source authority score and the review status score, respectively. .
[0054] For knowledge fragments with incomplete source and review information, the system reduces the reliability of their source or marks them as fragments pending review, and does not use them as unconditional modeling basis.
[0055] The system uses a pre-configured text embedding model to embed the j-th knowledge fragment into the main text. Convert to knowledge fragment vectors The project saves the knowledge fragment text, knowledge fragment vectors, and metadata to a local vector database. It uses an existing text embedding model and does not retrain it. The processing relationships are as follows:
[0056]
[0057] in, The text embedding function is used for both the knowledge fragment text and the subsequent modeling subqueries, ensuring they reside in the same vector space. This implementation uses text-embedding-v4 as the text embedding model, converting the knowledge fragment text into a 1024-dimensional vector. This model is pre-trained and will not be retrained in this project.
[0058] Use the global symbol dictionary For the original set of variable symbols and its symbol-unit correspondence Perform joint normalization to obtain a set of normalized variable symbols. Then and Input the formula symbol feature extraction function together. The processing relationship is as follows:
[0059] ;
[0060] in, To normalize the function, it first starts from... Read the original symbols one by one, and then combine them. Unit relations and global symbol dictionary This maps different ways of writing the same physical quantity to a unique standard symbol.
[0061] When different knowledge fragments each have their own set of original variable symbols When variable symbols with the same written form exist, but their physical meanings, units of measurement, or energy flow directions are inconsistent, the system marks potential conflicts based on the fragment's source, review status, and the global symbol dictionary. The variable symbols mentioned above are... The variable symbols in the text; after normalization, the corresponding normalized symbols belong to... The metadata field for normalized symbols is included_variables.
[0062] The system will use knowledge fragment vectors The fragment text, its unique fragment ID (chunk_id), knowledge category, constraint type (constraint_type), included variables (included_variables), and source file information are all written into the local Chroma vector database to form a domain knowledge base and vector index. The chunk_id is used for unified deduplication of candidate knowledge fragments and fragment referencing; the category, constraint_type, and included_variables are used for displaying search results, manual review, model element consistency verification, and evidence tracing, and are not used as independent search channels in this embodiment.
[0063] (2) Demand modeling and structured mathematical model generation based on retrieval enhancement:
[0064] 2.1 User Requirement Structuring and Modeling Subquery Generation:
[0065] The demand modeling intelligent agent is a demand modeling software module running in the port resource joint scheduling decision system. It is used to convert user-input natural language scheduling requirements into searchable and verifiable structured modeling tasks. This demand modeling software module does not act as a decision variable in the optimization model; instead, it uses demand parsing templates, a global symbol dictionary, an equipment label dictionary, a constraint category dictionary, and a business data field dictionary to perform entity recognition, parameter extraction, terminology normalization, constraint classification, and query decomposition of user requirements.
[0066] After a user inputs port scheduling requirements through a graphical interface, the requirement modeling software's functional modules parse the natural language requirements, such as... Figure 1 As shown, extract the following five types of information:
[0067] 1) Optimization target information: This includes the optimization direction and the target items explicitly requested by the user. The target items include one or more of the following: fuel consumption cost, grid power purchase and sale cost, power generation unit start-up and shutdown cost, carbon trading cost, flexible load compensation cost, and shore power service revenue; when the user does not specify a target item, or the business data does not support the target item, the system will not automatically add that target item.
[0068] 2) Business object information: including ships to be dispatched, berths, energy supply equipment, energy storage equipment, photovoltaic equipment, wind power equipment, main power grid, and ship load objects.
[0069] 3) Constraint information: including ship arrival time, departure time, required continuous berthing time, berth capacity, ship cannot be moved midway, ships cannot overlap, power output range of energy supply equipment, equipment start-up and shutdown logic, minimum start-up and shutdown time of equipment, equipment ramp-up rate, cold, heat and electricity power balance, and energy storage equipment charging and discharging constraints.
[0070] 4) Data requirements: This includes fields such as vessel number, vessel size, estimated arrival time, estimated berthing duration, number of berths, rated power of equipment, upper and lower limits of equipment output, equipment efficiency, coefficient of performance (COP), energy storage capacity, charging and discharging power, charging and discharging efficiency, light intensity, wind speed, and time-of-use electricity price, as well as the time index, unit of measurement, and data source for each field.
[0071] 5) Hard condition information: This includes conditions that are explicitly specified by the user and cannot be automatically modified by the system, such as scheduling time granularity, optimization time domain, number of berths, initial and final states of energy storage, equipment capacity limit, ships must complete berthing operations, and all binary variables must remain binary variables.
[0072] The above parsing results can be represented as a structured task description: Wherein, O is the set of target information consisting of optimization objectives and directions; A is the set of business objects consisting of ships, berths, energy supply equipment, energy storage equipment, new energy equipment, and the main power grid; C is the set of time constraints, berth constraints, energy balance constraints, equipment operation constraints, and energy storage constraints identified based on user needs; D is the set of data requirements consisting of data fields, field units, time indexes, and data sources needed for subsequent model solving; H is the set of hard conditions explicitly specified by the user and not allowed to be changed automatically. H is a user hard condition record identified and separately marked from O, A, C, and D, used to ensure that related fields are not changed without user confirmation during subsequent retrieval, model generation, and error correction stages. The above sets are intermediate structured data generated for the current scheduling task and are not random variables in the optimization model.
[0073] To avoid retrieving all knowledge using a single long query, the system rewrites and decomposes user requirements based on the target information O, business object A, constraint information C, data requirements D, and hard conditions H in the structured task description R. Query rewriting includes standardizing equipment names, business terms, variable symbols, units of measurement, and time expressions, and converting synonyms in natural language into preset professional terms. For example, "gas turbine," "micro gas turbine," and "PGU" are normalized to the same equipment label, and "battery state of charge" and "energy storage SOC" are normalized to the same energy storage state label.
[0074] Based on query rewriting, the system first reads the global symbol dictionary and determines whether the user input contains a modeling intent for joint scheduling of port energy and berths, as well as the equipment, load, and constraint elements involved in the user's requirements, through modeling intent judgment. This modeling intent judgment is only used to determine whether the user's requirements enter the subsequent retrieval and enhanced modeling process; it does not prove that the user's requirements are complete or that the mathematical model is feasible. Once the entry conditions are met, the system generates modeling sub-queries according to five fixed dimensions: objective function composition, energy balance, equipment operation constraints, scheduling and demand response, and extension mechanisms. One query is generated for each dimension. Extension mechanisms refer to mechanisms for specific requirements explicitly proposed by the user, such as carbon trading, hydrogen energy, electric ships, and flexible loads.
[0075] The objective function modeling subquery retrieves the user-selected optimization objective, objective function term, cost or benefit, calculation parameters, and linearization rules. The energy balance modeling subquery retrieves the port's electrical, thermal, and cooling power balance, as well as the energy input-output relationships between various energy supply, conversion, and storage devices and ship loads. The equipment operation constraint modeling subquery retrieves equipment output boundaries, operating states, start-stop logic, ramp constraints, minimum operating time, minimum downtime, and conversion efficiency. The scheduling and demand response modeling subquery retrieves ship arrival times, berth allocation, continuous berthing, berth overlap prevention, ship load, and demand response. The extension mechanism modeling subquery retrieves explicitly proposed extension requirements supported by equipment configuration or business data. Business data field information is stored as a data requirement set D in the structured task description R, used for subsequent model input parameter confirmation and business data binding, and does not form a separate modeling subquery.
[0076] The system performs integrity checks on the five generated modeling subqueries. When a subquery lacks a target item, business object, constraint category, or user-defined hard condition, the system marks the missing content as pending confirmation and generates a supplementary query; only after user confirmation is the subquery sent to the subsequent vector retrieval module. The five validated modeling subqueries are used to retrieve knowledge fragments corresponding to the current model elements.
[0077] 2.2 Knowledge Fragment Vector Retrieval Based on Five Modeling Subqueries:
[0078] The system receives the five modeling subqueries generated and verified for integrity in step 2.1. For the l-th modeling subquery, the system uses the same text-embedding-v4 model as when the knowledge fragment was added to the database to generate a 1024-dimensional query vector; the 1024-dimensional vector of the j-th knowledge fragment in the knowledge base has already been generated and saved using the same model during the knowledge base construction phase. Both reside in the same vector space. Their encoding and similarity calculation relationship is as follows:
[0079]
[0080]
[0081] in, For the l-th modeled subquery text; This is the main text of the j-th knowledge segment; and These are the query vector and the knowledge fragment vector, respectively. This represents the vector similarity between the two vectors. When either vector is zero, it represents the vector similarity between the two vectors. Set to 0. The retrieval score is only used to measure relevance and ranking, and does not indicate that the knowledge fragment is necessarily applicable to the current task, nor does it indicate the probability of the model generating the correct result.
[0082] This embodiment uses a local Chroma vector database for retrieval. Five modeling subqueries are each executed once for vector retrieval, and each modeling subquery returns only the top vectors with the highest similarity. A knowledge fragment, in this embodiment Take 8. The initial candidate fragment set for the l-th modeling subquery is:
[0083]
[0084] in, For knowledge fragments The similarity ranking in the results returned by the l-th modeling subquery;
[0085] Metadata such as chunk_id, category, constraint_type, included_variables, and source file are saved along with the candidate knowledge fragment for subsequent deduplication, manual review, and evidence tracing.
[0086] 2.3 Deduplication, rearrangement, and conflict suppression for model feature coverage:
[0087] This embodiment employs five modeling subqueries to perform text vector retrieval. The vector similarity obtained in step 2.2 is used for ranking candidate knowledge fragments; metadata is used for display, deduplication, manual review, and evidence tracing. Each of the five modeling subqueries returns the previous results. After identifying 8 candidate knowledge fragments, the system merges the five sets of returned results and performs a unified deduplication process based on the unique chunk_id of each knowledge fragment. When the same knowledge fragment is retrieved by multiple modeling subqueries, only the highest vector similarity of that knowledge fragment across all retrievals is retained. And the modeling subquery that generates the highest vector similarity;
[0088]
[0089] in, To retrieve knowledge fragments The set of modeling subquery IDs; Excerpt The highest vector similarity among all hit subqueries.
[0090] The system generates recommendation tags based on sorting position and relevance threshold. Recommendation Tags Determined according to the following formula: ;in, For knowledge fragments The rankings are arranged in descending order of the highest vector similarity; I[·] is the indicator function, which takes the value 1 if the condition in parentheses is true, and 0 otherwise. =1 indicates a recommendation. =0 indicates not recommended. The recommendation flag is only used to assist user review and does not directly replace user selection.
[0091] For knowledge fragments ranked in the top 5 and with the highest vector similarity greater than 0.65, the system marks them as recommended fragments; other fragments that have been retrieved are marked as optional fragments; knowledge fragments that have not been retrieved by any modeling subquery can be displayed as missing fragments in the review interface, but by default, no subsequent enhancement prompts are injected.
[0092] The system checks whether candidate knowledge fragments cover the objective function, energy balance (mainly referring to cooling, heating, and electrical power balance in this implementation), equipment operation constraints (mainly referring to energy supply equipment operation constraints), scheduling and demand response (mainly referring to berth and ship scheduling in this implementation), and user-specified extension mechanisms required for the current task, based on the user's original requirements and modeling subqueries. If the user has not proposed extension mechanisms such as carbon trading, hydrogen energy, electric ships, or flexible loads, they will not be automatically added to the current model, even if relevant fragments exist in the knowledge base. For electrical or thermal energy storage, the corresponding energy storage variables and constraints are only included in the model when explicitly enabled in the user's requirements, equipment configuration, or user-confirmed modeling scheme.
[0093] The system displays the knowledge fragment number, category, relevance, matching modeling subqueries, and fragment content on the review interface. Users can select recommended fragments, add selectable fragments, or deselect system recommendations. The knowledge fragments ultimately confirmed by the user constitute the reviewed knowledge fragment set C. app Knowledge fragments that have not been confirmed by the user are only retained in the search records and are not included in subsequent enhanced suggestion keywords.
[0094] 2.4 Variable / Unit Conflict Validation with Business Rules:
[0095] The system only performs consistency checks on model elements already enabled in the current modeling task. The same variable refers to a variable that, after normalization using the global symbol dictionary and device label dictionary, has the same standardized symbol, the same index meaning, and the same business object. For example, "Electric power of gas turbine in time period t" belongs to the same variable; although the charging power of electric energy storage and the heating power of thermal energy storage both belong to energy storage-related variables, they are different in physical objects and are not considered the same variable. This represents the power generation of the gas turbine PGU in time period t, which, after being normalized by the global symbol dictionary, refers to the same physical quantity as the natural language expression "electric power of the gas turbine in time period t".
[0096] Regarding the review of knowledge fragment c jFor each normalized variable ω involved, the system records the variable name, physical meaning, unit of measurement, value range, energy flow direction, applicable equipment, and constraint relationships, forming a variable attribute record: ;in, For knowledge fragment c j The attribute record of the normalized variable ω records ω in the knowledge fragment. The physical meaning, unit of measurement, range of values, energy flow direction, applicable equipment, and constraint relationships in the text; For the physical meaning of the variable; Units of measurement; The allowed range of values; Indicates the direction of energy input or output; For applicable equipment; This represents the direction of the variable's relationship within the objective function or constraints. ω is the same normalized variable symbol defined in step 2.2, formula symbol matching, and belongs to... ; From the set of original variable symbols of knowledge fragments Symbol-Unit Correspondence It is obtained by normalization together with the global symbol dictionary.
[0097] If two knowledge fragments under review involve the same normalized variable ω, the system first performs synonym normalization and unit conversion; after conversion, if the physical meaning of the variable, allowed units, energy flow direction, applicable equipment, value range, or constraint direction of the two fragments still cannot be simultaneously satisfied, a potential conflict flag is generated. ;in, For knowledge fragment c j and c m The conflict flag for variable ω is used to compare whether two audit knowledge fragments are compatible with the attribute definitions of the same normalized variable symbol ω; I is an indicator function, which takes the value 1 when the condition is true and 0 otherwise; the system writes the conflicting variable, conflicting attribute, involved fragment and applicable conversion relationship into the conflict record. Let m be the m-th audited knowledge fragment in the knowledge base, where m is the knowledge fragment index and m ≠ j; To standardize the variable symbol ω in knowledge fragments The attribute records in the file.
[0098] The system performs pairwise comparisons of audit knowledge fragments containing the same normalized variable symbol ω. First, it standardizes symbol names, index meanings, and standard units of measurement based on the global symbol dictionary; when units are convertible, the values and ranges are converted to standard units. Second, it compares the physical meaning of the variable, the business object, the applicable equipment, and the energy flow direction; a conflict record is generated if any item is inconsistent. Third, assuming consistent physical meanings, it compares the converted ranges and constraint directions; a conflict record is generated if the ranges do not overlap or the constraint directions cannot be simultaneously met. Fourth, it processes conflicts in the following order: "user-confirmed hard conditions H, user-uploaded and confirmed equipment parameters and business data, global symbol dictionary, and audit knowledge fragments." The global symbol dictionary is only used to standardize representations and does not provide candidate objective functions or constraints; therefore, it does not compete with knowledge fragments for adoption. Audit knowledge fragments are only used to supplement missing objective function terms, constraint expressions, or linearization rules after being consistent with the first three categories and confirmed by the user. Conflicts that cannot be eliminated are marked as pending confirmation, and the relevant fragments are not written with enhanced prompts before user confirmation.
[0099] The content that passes the verification is used to form the knowledge fragment set for subsequent review and enters the enhanced prompt words and evidence mapping table in step 2.5; the excluded content is not included in the enhanced prompt words. Thus, a clear data transfer relationship is established between the conflict resolution results and the subsequent model generation.
[0100] 2.5 Enhanced prompt word assembly and structured model generation:
[0101] The system does not directly provide the entire knowledge base content to the large language model. Instead, it assembles enhanced prompt words using only audited knowledge fragments that have undergone sorting, business scope checks, variable consistency verification, and user confirmation. These enhanced prompt words are input to the requirement modeling agent, not a structured mathematical model. Based on the user's original requirements, modeling subqueries, retrieval evidence, global symbol dictionary, hard condition set, and output structure requirements from the enhanced prompt words, the requirement modeling agent generates a set of structured mathematical model elements for the current scheduling task. The set of elements of the structured mathematical model. Including sets and indexes Input parameters Decision variables Objective function Constraint Sets and evidence mapping The system will generate The modeling scheme is formatted according to a preset template to a mixed integer linear programming modeling scheme that is confirmed by the user; the modeling scheme after user confirmation then enters the business data binding and code generation stage.
[0102] System prompt words Pre-defined by the system, these parameters specify the task roles, general modeling principles, and output requirements of the intelligent agent used for demand modeling. The final modeling prompts are derived from the fixed task description. Global symbol dictionary Knowledge fragments verified by users Original user needs and output structure requirements The system is composed of several parts; the global symbol dictionary is read separately and does not participate in the recommendation and filtering of ordinary knowledge fragments. The final modeling prompts are:
[0103]
[0104] The enhanced prompts explicitly state that user-confirmed original requirements and hard conditions have the highest priority; reviewed knowledge fragments are only used as a basis for modeling; equipment, variables, cost items, or benefit items that do not exist in the user scenario should not be added simply because the knowledge base exists in an extended model. This implementation does not confirm carbon trading, therefore no carbon trading cost item is generated; energy storage devices are only included in the model when enabled in the equipment configuration or user-confirmed scheme.
[0105] The system will display the system prompt. As a system message, the final modeling prompt will be given. As a user message, both are combined with a preset model to generate a parameter set. By inputting the large language model together, we obtain the modeling output for this task:
[0106]
[0107] This includes model variables, objective functions, constraints and their descriptions; the demand modeling agent is based on... A set of structured mathematical model elements M is formed, and M is formatted into a mixed-integer linear programming modeling scheme for user confirmation. This process generates the structured mathematical model, and the resulting modeling scheme is not the pre-solved ship schedule or energy operation values.
[0108] The set of elements M for the structured mathematical model is as follows:
[0109]
[0110] Where M represents the complete set of structured model elements for the current scheduling task, and is not the port resource joint scheduling decision system itself; I, P, X, F, G, These represent sets and indices, input parameters, decision variables, objective functions, constraint sets, and evidence mappings, respectively. Record the knowledge fragment number, user rule number, data field, and review status corresponding to each objective function item and constraint. The system is the software carrier for processing M. The system formats M into a MILP modeling scheme for user confirmation according to a preset template; only after the user confirms the modeling scheme will it enter the business data binding and code generation stage.
[0111] 2.6 Model Element Review and Error Correction Retrieval:
[0112] Before outputting the modeling scheme, the system performs six checks on the model element set M: symbolic integrity, unit consistency, constraint coverage, linear solvability, data mappability, and evidence traceability. Each check has clearly defined inputs and judgment rules, and does not directly use abstract scores without computational basis.
[0113] Symbolic Integrity: Every symbol appearing in the objective function and constraints can be uniquely defined in the set and index, parameter, or decision variable table; the same standard symbol must not represent multiple physical quantities. Unit Consistency: The units of physical quantities in addition terms and on both sides of the equation are consistent; if a preset conversion relationship exists, unit conversion is performed first; failure occurs if conversion fails or remains inconsistent. Constraint Coverage: User-confirmed hard conditions and model elements required for the current task each correspond to at least one variable definition, objective function term, or constraint. Linear Solvability: The model does not contain the multiplication of two unlinearized decision variables, decision variables as divisors, exponential functions, or other nonlinear relationships. Data Mappability: Each input parameter can be mapped to user-uploaded data fields, device parameters, or user-confirmed fixed values, and the time length and index dimension are consistent with the model. Evidence Traceability: Each objective function term and constraint can be traced back to user rules, the global symbol dictionary, or user-confirmed knowledge fragments.
[0114] If any of the following criteria are not met: symbolic integrity, unity consistency, linear solvability, or data mappability, the system will prevent the current model from directly entering the code generation stage. The system will then process the code based on the set of failed audit items. And generate error-correcting subqueries for model elements with corresponding undefined symbols, unit conflicts, missing constraints, nonlinear expressions, unmapped fields, or lack of evidence: ; For error correction subqueries; The system uses preset error correction subquery generation rules; R represents the structured task description; and M represents the current model element set. The system reads the corresponding problem object based on the failed review item, only re-searching the knowledge category corresponding to that failed item, without rewriting the complete user requirements. The re-searched knowledge fragments still need to undergo sorting and manual confirmation in step 2.3, and consistency verification in step 2.4. If the system still fails to pass after reaching the preset maximum number of error correction attempts, it outputs items pending confirmation and stops automatically entering code generation.
[0115] For M that has passed the six checks, based on the correspondence of the structured model element set M-MILP modeling scheme, it is organized into a mixed integer linear programming modeling scheme for joint scheduling of port energy and berths according to the preset template, and then enters the subsequent business data binding and code generation stage after user confirmation.
[0116] (3) Business data access and automatic code generation and hierarchical closed-loop debugging based on multi-agent collaboration:
[0117] After the user confirms the modeling scheme, the system enters the business data access phase. The data analysis software's functional modules read the user-uploaded ship data, equipment parameters, light intensity, wind speed, and electricity price files, extracting filenames, worksheets or paragraphs, field names, data types, units of measurement, number of rows and columns, time indexes, and sample data. For each file, a data quality check record with source file identification is generated. For Excel files, the column names, total number of rows, and sample records for each worksheet are read; for Word-type equipment parameter files, valid paragraphs and table content are read. The data quality check record checks field completeness, data type consistency, unit of measurement consistency, time index continuity, and whether data values meet model input requirements. It establishes candidate binding relationships between the checked business fields and the input parameters in the structured mathematical model. Fields that fail the check or cannot complete parameter matching are marked as pending confirmation items, not written to the standard data set, and not included in the subsequent code generation process. Only fields that pass the check and are bound after user confirmation are used for model parameter assignment and optimized code generation. The data analysis phase only generates field identification, quality checks, and model parameter mapping suggestions; it does not directly rewrite the user's original files.
[0118] This embodiment integrates ship data, equipment parameters, solar irradiance, wind speed, and electricity price files. Ship data is used to obtain the ship's number, size, estimated arrival time, estimated berthing duration, and existing berth information. Equipment parameters are used to obtain the capacity, efficiency, and operating boundaries of the energy supply equipment. Solar irradiance and wind speed are used to calculate the available output of photovoltaic and wind power during specific time periods. The electricity price file is used to obtain the grid purchase price for each dispatch period. This embodiment does not include carbon quota and carbon trading price data; therefore, no carbon trading objective function term is generated. Energy storage parameters are only included in data binding if they exist in the equipment parameters and the user-confirmed model.
[0119] 3.1 Automatic binding of model parameters to business data:
[0120] Let the set of model input parameters after user confirmation be... The data analysis software's functional modules extract the candidate data field set from user-uploaded files as follows: ; It is the set of input parameter components P of the structured model element set M in step 2.5 after user confirmation, and does not include decision variable X; Input parameters for the u-th model. It is a set of candidate fields extracted from user-uploaded files by the functional modules of data analysis software, after normalization of field names, units of measurement, data types, and index dimensions; For the v-th candidate data field. Each Record its original file, worksheet or paragraph location, original field name, normalized field name, field description, data type, original unit, target unit, index dimension, and sample value. Only after parameter binding and data quality verification are completed... The standard data set is formed by the items in the middle. .
[0121] Determine the input parameters that the mathematical model, confirmed by the user, actually needs to be assigned values; the data analysis software functional modules in Searching for parameters of each model Matching candidate fields A normalized field refers to a field record obtained by unifying the original field names according to a pre-defined business field dictionary and converting the original units to the units required by the model when there are explicit conversion relationships.
[0122] The system prioritizes establishing deterministic mappings based on standardized field names and a pre-defined dictionary of business fields. For example, vessel number, vessel size, estimated arrival time, and estimated berthing duration are mapped to the vessel index, vessel load category, arrival time parameter, and continuous berthing duration parameter, respectively; solar irradiance, wind speed, and electricity price are mapped to the inputs for calculating maximum available photovoltaic power, maximum available wind power, and time-of-use electricity price, respectively. For parameters and fields that cannot be uniquely matched by deterministic rules, the system calculates a comprehensive mapping score. ;in, The evaluation items are a set representing the field name, field description, unit of measurement, data type, and index dimension, respectively. For model parameters With candidate fields The matching result for the f-th item has a value range of [0,1]. Let f be the preset non-negative weight, and satisfy the following conditions: The matching result for field name and field description is determined based on the keyword or semantic consistency after terminology normalization; when the units of measurement are the same or can be converted through preset conversion rules, the matching result for the unit of measurement is 1, and 0 when it cannot be converted; when the data types are the same, the matching result for the type is 1, otherwise it is 0; when the time, ship or equipment index dimensions are the same, the matching result for the dimension is 1, otherwise it is 0.
[0123] The binding relationship between model input parameters and candidate fields is represented as follows: ;in, This is a set of binding relationships between model input parameters and candidate data fields. for and The rules for field name conversion, unit conversion, and index alignment used between them.
[0124] when Not lower than the automatic mapping threshold When the units of measurement, data types, and index dimensions are compatible, the system establishes... and Automatic binding relationship between them, and in The record includes the original file, field position, original field, target parameter, unit conversion, and time alignment rules; when Located in the unconfirmed range [ , When the system displays the candidate field name, file location, sample value, unit of measurement, index dimension, and mapping score, it is then confirmed by the user. Below the automatic mapping threshold If the units, time lengths, or index dimensions are incompatible, the system will refuse automatic binding and pause code generation. In this embodiment, Take 0.80, The value is set to 0.50, both of which are preset deterministic thresholds.
[0125] The system further examines the number of ships, equipment, time series length, missing fields, and index range. Once the data matches the model, a standard dataset is formed from the fields that have passed quality verification and have been bound. When data inconsistencies can be resolved through explicit unit conversions, user-confirmed period expansion, aggregation, or length truncation rules, the system records the processing rules and awaits user confirmation. When necessary fields are missing, units cannot be converted, or indexes cannot be matched, the system returns to the data analysis stage and does not proceed to code generation.
[0126] 3.2 Structured intermediate representation oriented towards the solver:
[0127] To avoid generating the entire program from a long natural language document at once during code generation and debugging, the system includes the user-confirmed set of model elements M, and the binding relationships between parameters and fields. And the solver configuration is converted into a structured intermediate representation decoupled from the specific programming language: Among them, I, X, F, G and These correspond to the sets and indices, input parameters, decision variables, objective function, constraint sets, and evidence mappings in step 2.5, respectively. This is the set of binding relationships between the model input parameters and candidate data fields formed in step 3.1; Solver program template and configuration; This is a template for the output fields of the current solver, specifying the berth arrangement, energy equipment power, cost details, solution status, solution log, and visualization data fields that the solver should output after executing MILP.
[0128] Code generation and debugging agent reads IR and Generate the initial solver in the following order. : Generate sets and indices based on I; based on and from Read parameter values; generate continuous, integer, and 0-1 variables based on X and set upper and lower bounds; generate the objective function based on F; generate constraints iteratively by index based on G; write solver parameters; based on... Write the serialization and log output code. For each code block generated, the system writes the model feature number and evidence mapping number involved to the code block record. The processing relationship is as follows: ;in, This represents the structured code generation process implemented by the code generation and debugging agent. The generated trial code is only used to verify data reading, variable declaration, constraint construction, and output interface, and must be marked as trial results; the formal scheduling results are only generated by the formal MILP solver that passes the acceptance test in step 3.6.
[0129] 3.3 Static consistency check after code generation:
[0130] The static consistency check referred to in this embodiment refers to the check performed on the automatically generated solver without calling the solver or executing the solver program. The system parses and performs rule checks on the model elements, input data, and output configurations it references to determine whether the solver program has errors such as syntax errors, undefined symbols, inconsistent indexes or data dimensions, mismatched decision variable types, non-linear objective functions or constraints, and incorrectly bound model parameters before execution. The static consistency check is performed by the code parsing module and the rule check module, and the check results are used to determine whether the current solver program is allowed to enter the subsequent controlled execution phase.
[0131] set up For the first The solution program that awaits inspection, in which When =0, The initial solver program generated in step 3.2 ; When ≥1, This is the solution procedure that re-enters the inspection after the previous round of repairs. Let... for Let the set of referenced symbols be... for If the set of symbols has been defined, then the set of undefined symbols is: ;
[0132] The system proceeds in the following order Perform static consistency checks:
[0133] First, perform code syntax and symbol reference checks. (Code parsing module) The variable declarations, parameter declarations, set definitions, objective functions, constraint expressions, and solver call configurations are all extracted, along with the sets of symbols referenced by the program. and the already defined set of symbols .when If the value is not empty, record the name of the undefined symbol, its code location, and the model element to which it belongs, and determine that the current solver fails the check.
[0134] Second, perform collection, index, and data dimension checks. The rule validation module compares the time index, ship index, berth index, and equipment index in the code with the structured model element set. Sets and Indexes Perform a comparison and check whether the index ranges of the decision variables, parameters, and constraint expressions are consistent. Simultaneously, the input parameter set... With standard datasets The system compares the number of fields, time length, array dimensions, and index order to identify issues such as missing fields, redundant fields, inconsistent dimensions, and index out-of-bounds errors.
[0135] Third, check the type and value range of the decision variables. (Rule validation module reads...) The declaration information of the decision variables and their association with the model element set. The definitions of decision variables in the modeling scheme are compared to check whether the types of binary, integer, and continuous variables are consistent, and whether the upper and lower bounds, value ranges, and constraint forms of the variables conform to the user-confirmed modeling scheme. For example, the discrete decision variables corresponding to the berth activation status, equipment operation status, and energy storage charging and discharging status should be declared as binary variables according to the modeling scheme.
[0136] Fourth, a linear structure check is performed on the objective function and constraints. The code parsing module converts the objective function and constraint expressions into an expression structure tree. The rule verification module checks each expression to see if it contains only constants, linear combinations of input parameters and decision variables, identifies multiplication of decision variables, exponentiation of variables, nonlinear function calls, and other expressions that do not meet the requirements of mixed integer linear programming, and checks the objective function and constraint set. Is it a set of structured model elements confirmed by the user? Consistent.
[0137] Fifth, perform model parameter binding and output configuration checks. The system checks the set of input parameters. Can the model parameters in the dataset be obtained from a standard dataset? Locate the corresponding data field and check if the field name, data type, unit of measurement, time index, and value range meet the parameter assignment requirements. Also check if the output path, output file name, and result fields have been configured. For parameters that cannot be bound or do not meet the requirements, the system records the item pending confirmation and does not directly call the solver.
[0138] When all the above checks are passed and When empty, the system generates a static check pass log for the current solver and allows... Entering the controlled execution phase; if any check fails, the system generates a static check error record containing the error type, error location, affected model elements, and repair suggestions, and does not start the solver. The solver program, after multi-agent collaborative repair, is renumbered. Then, perform the static consistency check again.
[0139] 3.4 Controlled Execution and Error Classification:
[0140] Only when the first Round solver Only after passing the above static consistency checks, finding no undefined symbols, index or data dimension errors, variable type errors, non-linear expressions, or incomplete parameter bindings, and generating a static check pass record, does the system execute in a controlled manner within the independent working directory assigned to the currently scheduled task. The system collects standard output, standard error, exit codes, exception information, exception locations, solver status, solver logs, and the actual result files generated in this round to form the execution status of the nth round: ;in, Error type; The location of the error in the program module or code; This is an error message; This is information about an abnormal call; The solver state; This is the set of result files actually generated in the nth round. Compared with step 3.2 Belonging to different objects Specify the fields that should be output. Record the actual result file generated in this round.
[0141] The system first checks the Python runtime environment, solver installation status, license status, and runtime resources. If an environment error occurs, the system does not proceed to model repair but instead pauses the current execution and prompts the user for assistance. Errors that can enter the repair process are categorized into three types: code-level errors (including syntax, import, type, index, undefined variables, and file path errors); data-level errors (including missing fields, inconsistent units, null values, duplicate values, inconsistent time series lengths, and field mapping errors); and model-level errors (including model infeasibility, unbounded model, nonlinear expressions, variable boundary conflicts, and constraint contradictions).
[0142] 3.5 Layered Closed-Loop Repair Strategy:
[0143] The system according to The error type, error location, exception call information, and IR code block location to be modified are as follows:
[0144] Syntax errors are regenerated; imported error correction module names and interfaces are updated; undefined variable errors are corrected by supplementing variable declarations or uniform reference names based on IR; index errors are corrected by correcting loop ranges based on I; path errors are corrected by using the current task's working directory. The system only replaces the code block where the error occurred, keeping the model elements, data bindings, and protected elements that have already passed the checks unchanged. Code-level repair is represented as: For data-level errors, the system returns to the field identification and mapping stage, processing missing fields, unit conversions, time lengths, or index dimensions based on the error record, and forming a new standard dataset after user confirmation. For model-level errors, the system updates the current model feature set based on the results of infeasibility constraint, variable boundary, and energy flow direction checks, and regenerates the solver: .in, , and These represent the system-defined code-level, data-level, and model-level repair processes, respectively; H represents the user-defined hard conditions formed in step 2.1. Model-level repairs must not delete, relax, or replace optimization targets, equipment configurations, scheduling cycles, berth numbers, continuous berthing requirements, and equipment safety boundaries without user confirmation. The system sets a maximum number of repair iterations; if the maximum number of iterations is reached and the repair still fails, automatic repair stops and error records and pending confirmation items are output. Each round saves the program before repair, the program after repair, the error type, the error location, and the repair reason.
[0145] 3.6 Record of Solution Result Acceptance and Debugging Process:
[0146] The nth round of the solution program After execution, the system does not use an exit code of 0 as the sole success condition. Instead, it simultaneously checks the number of runtime errors, solver status, constraint violations, and result file integrity. For the g-th constraint in the constraint set G, its left-hand side value is calculated at the n-th round of candidate solutions. and right-hand side value According to the constraint type, the violation amount is defined as follows:
[0147]
[0148]
[0149]
[0150] set up This represents the number of errors in the nth round of execution. For the reason The defined set of required output fields includes at least berth scheduling, energy output, cost details, and solution log; For the nth round of the solution program The set of output fields actually generated and successfully parsed by the system after calling the mathematical programming solver; ξ is the allowable constraint violation tolerance, and the acceptance criterion is:
[0151]
[0152] Where I[·] is the indicator function; Optimal represents obtaining the optimal solution that satisfies the solver termination criterion; Feasible represents obtaining the feasible solution that satisfies the constraints. The formal solver program constructs MILP using Python and PuLP and calls Gurobi to solve it. Trial code or demonstration fallback results must not be included. Formal acceptance can only be marked as trial operation or demonstration results. After acceptance, the system enters "Scheduling result interpretation, visualization and full process archiving"; this fourth stage is not the mathematical model of the following step (4).
[0153] (4) The joint optimization mathematical model of port energy and berths generated and solved in step (3):
[0154] Step (4) is a detailed description of the MILP mathematical model instantiated by the code generation and debugging agent in step (3) and executed by the mathematical programming solver. It does not imply that a new solution process will be executed again after step 3.6. Step 3.2 generates a solution program based on the set, parameters, decision variables, objective function, and constraints defined in steps 4.1 to 4.5; Step 3.4 calls the solver and, within the feasible solution set that satisfies the constraints of steps 4.2, 4.4, and 4.5, jointly determines the ship berth arrangement and energy equipment operating power based on the minimum objective function in step 4.1; Step 3.5 handles code, data, or model errors; Step 3.6 accepts the solution results. Step 4.3 calculates the ship's electrical, thermal, and cooling loads based on the berthing status in step 4.2 and uses them as the load items in step 4.4. Energy storage devices are only included in step 4.5 if they exist in the user-confirmed equipment configuration and parameter files.
[0155] 4.1 Joint Scheduling Objective Function:
[0156] Based on the actual business inputs in this embodiment, the joint scheduling objective function consists of fuel procurement costs, grid interaction costs, and unit start-up and shutdown costs:
[0157]
[0158] In the formula, The total cost of port energy supply during the scheduling cycle; For gas turbine fuel procurement costs; Net costs incurred for the interaction between the port and the main power grid; This refers to the start-up and shutdown costs of controllable power supply units. All costs mentioned above are calculated based on input prices, equipment parameters, and decision variables, and are not random variables. Fuel procurement costs are:
[0159]
[0160] Where t is the scheduling period index; T is the total number of scheduling periods; The fuel unit price for time period t; Let be the fuel energy input rate of the gas turbine during time period t; Δt is the length of a single dispatch period. The grid interaction cost is:
[0161]
[0162] in, The electricity purchase price for time period t in the electricity price document; The electricity price for the time period t, which has been confirmed and recorded by the user. and These are the power purchased and the power sold, respectively. When the electricity price is not confirmed or the electricity sales function is not activated, the fixed amount... The unit start-up and shutdown costs are:
[0163]
[0164] in, A set of controllable power supply devices that require setting start / stop status; and These are the single startup cost and shutdown cost of device i, respectively; and These are 0-1 variables for startup and shutdown, respectively. This embodiment does not include carbon quotas, carbon trading prices, green certificates, or hydrogen energy data; therefore, the objective function does not contain corresponding cost or benefit terms.
[0165] 4.2 Berth allocation and continuous berthing constraints:
[0166] Let K be the set of ships to be dispatched, and B be the set of available berths. , `t` represents the total number of berths that can be used simultaneously in the port; `t` is the scheduling period index, and `b` is the berth index. (Definition) Let be a 0-1 decision variable for whether ship k begins berthing at berth b in time period t. For the estimated arrival time of vessel k, For the required continuous berthing duration, Given the maximum allowed waiting time and T as the total number of scheduling periods, the set of berthing start times that ship k is allowed to choose is: ;
[0167] Each vessel must select one berth within the permitted start time window and choose only one berthing start time: ;definition Let k be a 0-1 variable representing whether vessel k occupies berth b during time period t. Its berthing status is determined by the start time and the duration of continuous berthing. At any given time, a berth may be occupied by a maximum of one vessel. The overall berthing status of vessel k in time period t is defined as follows: ;
[0168] Therefore, the number of ships berthed at any given time satisfies: ;in, This only indicates the total number of berths; Used to output the correspondence between ships and specific berths; For the reason The summarized berthing statuses are used as coupling variables in step 4.3 for ship load calculation. These constraints ensure that each ship selects a berth upon arrival and occupies that berth continuously. There is no overlap in the use of the same berth during the same time period, and the operation is completed within the scheduling cycle.
[0169] 4.3 Calculation of multi-energy loads of ships driven by berth status:
[0170] set up , and These are the preset electrical load, thermal load, and cooling load parameters for vessel k when it is berthed. These parameters are obtained from the vessel load mapping table in the equipment parameter file based on the scale or type field in the vessel's business data.
[0171] The total shore power load of all ships at berth during time period t is: ;set up For the subset of ships with heat load requirements, the total heat load of ships in time period t is: ;set up For the subset of ships with cooling load requirements, the total cooling load of ships in time period t is: Among them, K, and All are sets determined by the ship business data in this transaction; k is the ship index; This is the summary berthing status calculated in step 4.2; , and All are deterministic input parameters. , and The derived loads are calculated from the berthing status and single-ship load parameters. They are not independent decision variables and are used as load items for the electrical, thermal, and cooling power balance constraints in step 4.4.
[0172] 4.4. Balance constraints of heating, cooling, and electrical power:
[0173] The port's integrated energy system ensures power balance during every scheduling period: ;in, , , , , , and The decision variables jointly determined by the solver; and These represent the actual utilized power of photovoltaic and wind power, respectively. The total shore power load calculated in step 4.3; For other basic electrical loads of the port. The current task does not provide a basic electrical load schedule. Electricity sales order not activated .
[0174] The waste heat from the gas turbine, the absorption chiller, and the heat storage tank must be balanced to maintain the waste heat level. ;in, The recoverable waste heat power generated by the gas turbine; and These are the heat release and heat charging power of the heat storage tank, respectively. This is the waste heat power input to the heat exchanger; This refers to the waste heat power input to the absorption chiller.
[0175] The terminal heat load balance is as follows: ;in, To improve the heating efficiency of the heat exchanger; The electrothermal conversion efficiency of the electric boiler; This represents the port's baseline heat load. This data is not currently available for the task. .
[0176] The terminal cooling load balance is as follows: ;in, and These are the coefficients of performance for absorption chillers and electric chillers, respectively. For the port's basic cooling load, this data is not currently provided for the task. .
[0177] 4.5. Constraints on the operation of energy supply equipment and energy storage:
[0178] The listed equipment constraints are selectively enabled based on the user-confirmed equipment configuration and parameter files. Constraints for equipment included in the current task, such as gas turbines, electric boilers, heat exchangers, absorption chillers, and electric chillers, are included in this model; electric energy storage and thermal storage tanks are only enabled when capacity, power, efficiency, and initial state parameters are complete, and missing user business data is not replaced by default parameters. For a set of controllable power supply devices that require start / stop settings, their operating power must satisfy:
[0179] ; ;
[0180] in, Let i be the operating power of device i during time period t; and These are the minimum and maximum operating power, respectively. , and These are 0-1 variables representing operation, startup, and shutdown, respectively. For devices configured with ramp rate and minimum start / stop time, the following conditions must also be met:
[0181] , ,
[0182] ;
[0183] in, and These are the maximum uphill and downhill power, respectively; and These represent the minimum continuous operating time and the minimum continuous downtime, respectively; τ is the index of the summation period. The fuel input and recoverable waste heat of the gas turbine satisfy the following:
[0184]
[0185] in, For power generation efficiency; The efficiency of converting fuel into waste heat; For waste heat recovery efficiency. The power grid's purchase and sale of electricity meet the following requirements:
[0186] in, and These are 0-1 state variables for electricity purchase and electricity sale, respectively. This is the upper limit of the power exchange with the main grid. Fixed when electricity sales are not enabled. and The maximum available photovoltaic power is calculated based on the light intensity and photovoltaic equipment parameters:
[0187]
[0188] in, The maximum available photovoltaic power during time period t; This refers to the rated installed capacity. To improve overall conversion efficiency; The effective area of the component; Light intensity. Based on wind speed. The maximum available wind power is calculated using the power curves corresponding to the wind turbine's cut-in, rated, and cut-out wind velocities. The actual power utilization of photovoltaic and wind power meets the following requirements:
[0189] ;
[0190] in, Unutilized renewable energy power, compared to power sold to the main grid These are not the same physical quantity. The parameters for the electrical energy storage (EES) and the thermal storage tank (TES) are already provided in the equipment parameter file; therefore, the corresponding constraints are enabled in this embodiment. The electrical energy storage satisfies:
[0191]
[0192]
[0193]
[0194] in, The stored energy at the end of time period t; , and These are the minimum, maximum, and initial allowable storage capacity, respectively. and These are the maximum charging and discharging power, respectively. and These are the charging and discharging efficiencies, respectively. and These represent the 0-1 state variables for charging and discharging, respectively. The thermal storage tank satisfies:
[0195]
[0196]
[0197]
[0198] in, The stored heat at the end of time period t; , and These are the minimum, maximum, and initial allowable heat storage, respectively; and These are the maximum heat charging and heat dissipation power, respectively. and These are the heat charging efficiency and the heat dissipation efficiency, respectively. and These are the 0-1 state variables for heat charging and heat release, respectively.
[0199] Example 1: This example describes the workflow of a port dispatcher using the port resource joint scheduling decision system of the present invention to perform a joint optimization task.
[0200] Step 1: Natural Language Demand Modeling Based on Multi-Knowledge Fragment Retrieval Enhancement.
[0201] The dispatcher inputs the port's joint dispatch requirements: "The port currently has 6 berths. This task includes 22 vessels awaiting dispatch, with a dispatch cycle of 72 hours. The requirements are to jointly arrange berths and dispatch photovoltaic, wind power, gas turbines, electric boilers, refrigeration equipment, electric energy storage, and thermal storage tanks, while meeting the conditions of vessel arrival time windows, continuous berthing, non-overlapping single berths, and a maximum waiting time of 24 hours. The goal is to generate a dispatch plan with the minimum sum of fuel procurement costs, grid interaction costs, and equipment start-up and shutdown costs."
[0202] The demand modeling agent structures the above demands according to step 2.1, obtaining the number of berths N_B=6, the size of the vessel group |K|=22, the total number of scheduling periods T=72, and the maximum waiting time W_max=24 h. It then generates five modeling sub-queries based on five fixed dimensions: objective function composition, energy balance, equipment operation constraints, scheduling and demand response, and expansion mechanism. All of these parameters are determined by user input, equipment parameter files, and vessel business data, and are not random variables.
[0203] The system pre-segments port energy dispatch data, equipment operation specifications, and audited historical models into knowledge fragments according to step (1), and records the fragment number, source document, knowledge type, applicable equipment, constraint category, and related symbols. For the five modeling sub-queries, the system performs text vector retrieval according to step 2.2, returning the top 8 candidate knowledge fragments for each query; then, according to step 2.3, it uniformly removes duplicates by chunk_id, retains the highest vector similarity, sorts and generates recommendation tags, and displays the candidate knowledge fragments, similarity, recommendation status, and manual selection status in the modeling basis audit interface.
[0204] This embodiment retains knowledge fragments consistent with unit start-up and shutdown and output, power balance (cooling, heating, and electricity), discrete berth allocation, ship load mapping, energy storage continuity, and data mapping. If candidate results include extended model fragments such as carbon trading, hydrogen energy, green certificate trading, or flexible loads, the system marks them as unused and excludes them from the objective function and constraint set of this embodiment because the user requirements, equipment configuration, and uploaded data do not have corresponding business conditions configured. After the user confirms the knowledge fragments, the system assembles the final modeling prompts and inputs the system prompts, final modeling prompts, and preset model generation parameters into the large language model. The demand modeling agent then outputs a model element table and a mixed-integer linear programming modeling scheme based on the large language model, which are displayed in the system workspace for dispatcher confirmation.
[0205] Step 2: Confirm the modeling scheme, import business data and perform automatic analysis.
[0206] After the dispatcher confirms the modeling scheme, the system saves the user requirements, knowledge fragment numbers, enhanced prompts, model element table, and model version, and enables the data upload function. The dispatcher uploads the following data: ship business data table (data.xlsx), equipment parameter document (equipment parameters.docx), electricity price time series table (electricity price.xls), light intensity data table (light intensity data.xlsx), and wind speed data table (wind speed data.xlsx). The data analysis agent extracts fields, standardizes units and time indexes, and maps them to the confirmed model according to Table 1.
[0207] Table 1. Mapping Relationship between Business Data and Model Elements
[0208]
[0209] The data analysis agent performs field name matching, time index alignment, unit conversion, missing value detection, duplicate value detection, outlier range detection, and dimension validation. For light and wind speed sequences with sampling granularity or length inconsistent with the 72 one-hour time periods, it generates 72 time-period input sequences according to user-confirmed aggregation, truncation, or period expansion rules, and records the processing rules in the data mapping table. Data that cannot be automatically mapped or contains anomalies is marked as pending confirmation; it does not enter the code generation stage until the user completes the correction. After successful validation, a standard dataset is formed. ;in, A subset of ship business data; A subset of equipment parameters and ship load mapping; Configure subsets for time-of-use electricity pricing and confirmed electricity sales prices; This is a subset of light intensity and maximum available photovoltaic power. This represents a subset of wind speed and maximum available wind power. The system also generates a data mapping table containing the original files, original fields, original units, target model symbols, unit conversions, and time alignment rules, for use by the code generation and debugging agents.
[0210] Step 3: Generating solution code, closed-loop debugging, and joint optimization based on multi-agent collaboration.
[0211] After the modeling scheme and standard dataset are confirmed, the code generation and debugging agent first converts the sets, parameters, variables, objective functions, constraints, solver configurations, and output terms into a structured intermediate representation, and then generates a Python solver program. It then checks whether variables are defined, whether index ranges are consistent, whether binary variables are correctly declared, whether parameter dimensions match, and whether constraints maintain linearity. After passing static checks, the program executes by calling the mathematical programming solver in a controlled environment.
[0212] If the program encounters syntax, indexing, or interface errors, the code generation and debugging agent only modifies the corresponding program module. If there are missing fields, inconsistent units, or mismatched time series lengths, the process returns to the data analysis stage for repair. If the solver returns that the model is infeasible, unbounded, or has constraint conflicts, the process enters the model-level repair path, checking variable boundaries, constraint directions, and linearization conditions based on the error log and the set of infeasible constraints. However, it must not automatically change the user-confirmed number of berths, scheduling cycle, equipment capacity, and safety boundaries. Each round of repair records the version, error category, modification location, and reason for modification.
[0213] In this embodiment, the solver aims to minimize the sum of fuel procurement costs, grid interaction costs, and equipment start-up and shutdown costs. It performs joint optimization under the following conditions: 6 berth capacities, 22 ships arriving and berthing consecutively, ship electrical, thermal, and cold load mapping, supply and demand balance for heating, cooling, and electricity, equipment output boundaries, and continuity constraints for electrical and thermal energy storage. The program passes acceptance testing only when the solver is in an optimal or feasible state, the maximum constraint violation does not exceed the set tolerance, and berth scheduling, energy output, cost details, and solution logs have all been generated.
[0214] Step 4: Interpretation, visualization, and archiving of scheduling results. The system will display the solution results as a ship-berth joint scheduling diagram and a port power balance diagram. For example... Figure 2 As shown, the operational areas of 22 vessels across 6 berths are represented by horizontal task bars, with different shades of gray corresponding to different vessel sizes. Each task bar corresponds to the continuous operational process of one vessel at a designated berth, which can be used to verify whether there is overlapping occupation of the same berth, whether vessels complete their operations within the 72-hour scheduling cycle, and whether the berthing arrangements meet the requirements for continuous operation. Figure 3 As shown in the figure, the upper half represents the power supplied by gas turbine units, grid power purchases, energy storage discharges, wind power, and photovoltaic power, while the lower half represents ship loads, cooling loads, electric boiler loads, energy storage charging, and power sold to the grid. The dashed lines represent time-of-use pricing. This figure allows verification of whether power supply and load remain balanced at different times and observation of the linkage between energy storage, grid interaction, and renewable energy output changes with time-of-use pricing. The system simultaneously saves user requirements, search fragments, enhanced prompts, model versions, data mapping tables, round-robin codes, error logs, and final results, forming a verifiable chain of evidence for the entire process.
[0215] The joint scheduling result verification indicators in this embodiment are as follows: scheduling cycle: 72 hours, number of berths: 6, number of vessels: 22, number of overlapping berth occupancy: 0, earliest start time of operation: 0 hours, latest end time of operation: 72 hours, number of power data periods: 72, maximum power supply and demand balance error: 6.35 × 10⁻⁶. (-11) MW Non-zero power shortage periods: 0; Non-zero power curtailment periods: 0. This embodiment completes the joint scheduling of 22 ships and 6 berths within a 72-hour scheduling cycle, with no overlapping berth occupancy; the power supply and demand balance error for cooling, heating, and electricity in each period is... MW, less than MW indicates that the method can output verifiable joint scheduling results while satisfying the constraints of continuous berth operation and energy balance.
[0216] A traceable RAG modeling method for port energy and berth joint scheduling model elements: The modeling sub-queries are decomposed according to objective function, berth allocation, ship load mapping, cooling, heating and electricity balance, equipment operation, energy storage continuity and data mapping, and then retrieved. The sub-queries are rearranged based on model element coverage, content redundancy and rule conflict. The filtered fragments, global symbol dictionary and user hard conditions are assembled into enhanced prompt words, and a structured model is output with the objective function and constraints corresponding to the knowledge fragment sources item by item.
[0217] A berth-energy load coupled joint scheduling model based on ship berthing state variables: The berthing state of ships in each time period is used as the coupling variable between berth scheduling and energy load. Arrival time window, continuous berthing and berth capacity constraints are established. According to ship type and business rules, the berthing state is mapped to shore power, heat load and cold load, so that berth arrangement and the operation of cooling, heating and power supply equipment are solved jointly in the same mixed integer linear programming model.
[0218] A multi-agent hierarchical closed-loop repair architecture for joint scheduling of port berths and energy: This architecture consists of a demand modeling agent, a data analysis agent, a code generation and debugging agent, and a result interpretation agent that work collaboratively around a unified task state. The code generation and debugging agent categorizes runtime errors into code-level, data-level, and model-level errors, triggering program module repair, field mapping repair, or model element repair respectively. During the repair process, it locks in the user-confirmed business hard conditions and associates and saves the retrieval basis, model version, data mapping, code differences, solution logs, and scheduling results.
[0219] To illustrate the effectiveness of this invention, CN115293697A, "A Coordinated Scheduling Method for Integrated Port Energy System and Container Logistics System," and CN118446463A, "A Berth Allocation Method and System Based on Ship Demand Analysis," are used as comparative port integrated energy and logistics coordinated scheduling technologies. Compared to these technologies, this invention does not use berth allocation results as external input for energy scheduling. Instead, it establishes a mapping relationship between berth occupancy and ship electrical, thermal, and cooling loads based on ship berthing state variables. Arrival time windows, continuous berthing, berth capacity, supply and demand balance of heating, cooling, and electricity, equipment output boundaries, and energy storage continuity constraints are all solved within the same mixed-integer linear programming model. Therefore, changes in berth decisions can be synchronously reflected in energy load and energy supply equipment operation plans, reducing inconsistencies caused by the separate formulation of logistics and energy plans. This embodiment completes the joint scheduling of 22 ships and 6 berths within 72 hours, with zero overlapping berth occupancy and a maximum supply and demand power balance error of [missing value]. MW indicates that the proposed solution can simultaneously meet the constraints of berth operation and energy balance.
[0220] Compared to methods that directly generate models using general large language models or rely solely on keyword retrieval, this invention breaks down model elements into sub-queries for retrieval. Through coverage rearrangement, duplication suppression, conflict verification, manual confirmation, and evidence mapping constraints, the model generation process ensures that the objective function and constraints are linked to relevant knowledge fragments and user-defined hard conditions. Based on this, four intelligent agents—requirement modeling, data analysis, code generation and debugging, and result interpretation—work collaboratively under a unified task state. Code-level, data-level, and model-level errors discovered during execution are returned to their respective stages for processing, and model version, data mapping, code differences, and solution logs are retained. This reduces the risks of formula illusion, constraint omissions, field mismatches, and unfounded modifications, minimizes repetitive modeling and debugging work, and improves the verifiability, traceability, and scenario adaptability of the scheduling scheme.
[0221] The above examples of the present invention are merely illustrative of the computational model and process of the present invention, and are not intended to limit the implementation of the present invention. Those skilled in the art will recognize that other variations or modifications can be made based on the above description. It is impossible to exhaustively list all possible implementations here. Any obvious variations or modifications derived from the technical solutions of the present invention are still within the scope of protection of the present invention.
Claims
1. A joint scheduling method for port resources based on multi-agent collaboration and enhanced retrieval generation, characterized in that, include: S1. Construct a domain knowledge base and vector index for joint scheduling of port energy and berths; S2. Demand Modeling and Structured Mathematical Model Generation Based on Retrieval Enhancement: Receive port scheduling requirements input by users in natural language, and generate five modeling sub-queries according to five fixed dimensions: objective function composition, energy balance, equipment operation constraints, scheduling and demand response, and expansion mechanism. Using the same text embedding model as when knowledge fragments are entered into the database, convert the five modeling sub-queries into query vectors, and retrieve candidate knowledge fragments in the vector space of the domain knowledge base. Merge the candidate knowledge fragments retrieved from all modeling sub-queries, uniformly deduplicate the candidate knowledge fragments according to their unique chunk_id, and generate recommended tags for the knowledge fragments. After user review, the fixed task description, global symbol dictionary, user-confirmed knowledge fragments, user's original requirements, and output structure requirements are assembled into the final modeling prompt words; The system prompts, final modeling prompts, and preset model generation parameters are input into the large language model to obtain a modeling output containing model variables, objective functions, and constraints. The demand modeling agent then forms a set of structured mathematical model elements M and a mixed-integer linear programming modeling scheme based on the modeling output. S3. Business Data Access and Automatic Code Generation and Layered Closed-Loop Debugging Based on Multi-Agent Collaboration: Receives user-uploaded files, maps business fields to a user-confirmed set of mixed-integer linear programming modeling schemes, indices, and parameters, and performs automated quality verification; then, the code generation and debugging agent generates solver code based on the structured mathematical model, field mapping relationships, and standard data set, and performs static checks and controlled operation; when code, data, or model errors occur, code-level repair, data-level repair, or model-level repair is triggered according to the error category until the solution passes acceptance. S4. Perform joint optimization solution for port energy and berths: Call the mathematical programming solver to execute the debugged code, with the objective of minimizing the sum of fuel procurement cost, power grid interaction cost and equipment start-up and shutdown cost, and output berth arrangement and energy supply equipment operation plan under the condition of satisfying actual constraints.
2. The port resource joint scheduling method based on multi-agent collaboration and retrieval enhancement as described in claim 1, characterized in that, The process of constructing a domain knowledge base and vector index for joint scheduling of port energy and berths includes: Collect domain knowledge data on the joint scheduling of port energy and berths and segment the data into knowledge fragments. For the j-th knowledge fragment, generate a knowledge fragment vector. Simultaneously, the original variable symbol set of knowledge fragments and its symbol-unit correspondence Perform joint normalization to obtain a set of normalized variable symbols. The system will convert knowledge fragment vectors The fragment text, the fragment's unique ID (chunk_id), the knowledge category, the constraint type (constraint_type), the included variables, and the source file information are all written into the local Chroma vector database to form a domain knowledge base and vector index.
3. The port resource joint scheduling method based on multi-agent collaboration and retrieval enhancement as described in claim 2, characterized in that, The process of receiving port scheduling requests input by users in natural language and generating five modeling sub-queries according to five fixed dimensions—objective function composition, energy balance, equipment operation constraints, scheduling and demand response, and expansion mechanism—includes the following: A structured task description R is constructed based on optimization target information, business object information, constraint information, data requirement information, and hard condition information. Based on the target information O, business object A, constraint information C, data requirement D, and hard condition H in the structured task description R, query rewriting and query decomposition are performed on user requirements. Query rewriting includes unifying device names, business terms, variable symbols, units of measurement, and time expressions, and converting synonyms in natural language into preset professional terms. Based on query rewriting, the global symbol dictionary is first read. Based on the user's modeling requirements, modeling subqueries are generated according to five dimensions: objective function composition, energy balance, equipment operation constraints, scheduling and demand response, and extension mechanism. One query is generated for each dimension. The completeness of the five generated modeling subqueries is checked. When a subquery is missing an objective item, business object, constraint category, or user hard condition, the missing content is marked as a pending confirmation item and a supplementary query is generated. Only after user confirmation is the subquery used for subsequent vector retrieval. The five validated modeling subqueries are used to retrieve knowledge fragments corresponding to the current model elements.
4. The port resource joint scheduling method based on multi-agent collaboration and retrieval enhancement as described in claim 3, characterized in that, Using the same text embedding model as when knowledge fragments were added to the database, the five modeling subqueries are converted into query vectors. The process of retrieving candidate knowledge fragments in the vector space of the domain knowledge base includes: For the l-th modeling subquery, the system generates a query vector using the same text embedding model as when the knowledge fragment was added to the database; the vector of the j-th knowledge fragment in the knowledge base was generated and saved using the same model during the knowledge base construction phase; the similarity between the query vector and the vector of the j-th knowledge fragment is calculated, and the top vectors with the highest similarity are selected. Each knowledge fragment, and each modeling subquery, yields... A knowledge fragment.
5. The port resource joint scheduling method based on multi-agent collaboration and retrieval enhancement as described in claim 4, characterized in that, The process of uniformly deduplicating candidate knowledge fragments according to their unique chunk_id and generating recommended tags for those fragments includes: All modeling subquery results are merged and deduplicated once according to the unique chunk_id of the knowledge fragment. When the same knowledge fragment is retrieved by multiple modeling subqueries, only the highest vector similarity of the knowledge fragment in the modeling subquery retrieval and the modeling subquery that generated the highest vector similarity are retained. The system generates recommendation tags based on the sorting position and relevance threshold.
6. The port resource joint scheduling method based on multi-agent collaboration and retrieval enhancement as described in claim 5, characterized in that, After user review, the process of assembling the fixed task description, global symbol dictionary, user-confirmed knowledge fragments, user's original requirements, and output structure requirements into the final modeling prompts includes: Regarding the review of knowledge fragment c j For each normalized variable ω involved, record the variable name, physical meaning, unit of measurement, value range, energy flow direction, applicable equipment, and constraint relationships to form a variable attribute record. If two audit knowledge fragments involve the same normalized variable ω, first perform synonym normalization and unit conversion; after conversion, based on any two audit knowledge fragments... Perform conflict checks, and compile the checked knowledge fragments into a set of audited knowledge fragments. For the set of knowledge fragments to be reviewed, based on the fixed task description Global symbol dictionary Knowledge fragments verified by users Original user needs and output structure requirements The modeling prompts are determined to be: , ⊕ indicates that text and structured content are concatenated in a preset order.
7. The port resource joint scheduling method based on multi-agent collaboration and retrieval enhancement generation according to claim 6, characterized in that, The process by which the demand modeling agent generates a set of structured mathematical model elements M and a mixed-integer linear programming modeling scheme based on the modeling output includes: Demand modeling intelligent agent based on The set of elements M forming the structured mathematical model is as follows: Where M represents the complete set of structured model elements for the current scheduling task; I, P, X, F, G, These represent sets and indices, input parameters, decision variables, objective functions, constraint sets, and evidence mappings, respectively. Record the knowledge fragment number, user rule number, data field, and review status corresponding to each objective function item and constraint; Format M according to the preset template into a MILP modeling scheme for user confirmation.
8. The port resource joint scheduling method based on multi-agent collaboration and retrieval enhancement as described in claim 7, characterized in that, The process of mapping business fields to a user-confirmed set of mixed-integer linear programming modeling schemes, indexes, and parameters, and then performing automated quality checks, includes: Let the set of model input parameters after user confirmation be... , The input parameters for the u-th model are given; the set of candidate data fields extracted from user-uploaded files is as follows: , For the v-th candidate data field; and Perform field association, in Searching for parameters of each model Matching candidate fields And bind it; Further checks were conducted on the number of ships, equipment, time series length, missing fields, and index range. If the data matched the model, the quality check was considered passed. The fields that have passed quality verification and have been bound, along with their data, will form a standard data set. .
9. A joint scheduling method for port resources based on multi-agent collaboration and enhanced retrieval generation as described in claim 8, characterized in that, The process by which the code generation and debugging agent generates solver code based on the structured mathematical model, field mapping relationships, and standard datasets, and performs static checks and controlled execution includes: Binding relationships between the user-confirmed model element set M, parameters, and fields. And the solver configuration is converted into a structured intermediate representation decoupled from the specific programming language. Among them, I, X, F, G and These correspond to sets and indices, input parameters, decision variables, objective functions, constraint sets, and evidence mappings, respectively. This is a set of relationships between model input parameters and candidate data fields. Solver program template and configuration; Output field templates for the results of the current solver; Code generation and debugging agent reads IR and Generate the initial solver in the following order. : Generate sets and indices based on I; based on and from Read parameter values; generate continuous, integer, and 0-1 variables based on X and set upper and lower bounds; generate the objective function based on F; generate constraints iteratively by index based on G; write solver parameters; based on... Write the serialization and log output code for the results; for each code block generated, write the model feature number and evidence mapping number involved to the code block record; Before invoking the mathematical programming solver, the code generation and debugging agent processes the generated solver program. Perform static consistency checks; the static consistency checks include: checking code syntax and symbol references, and determining... Is it empty?; Combine the time index, ship index, berth index, and equipment index in the code with the structured model element set. Sets and Indexes Perform a comparison and check the set of input parameters. With standard datasets The number of fields, time duration, array dimensions, and index order are checked; the types of decision variables, their value ranges, the linear structure of the objective function and constraints are examined; model parameter binding and result output configuration are checked; only if all the above checks pass and When empty, generate static check pass record and allow Enter controlled operation; otherwise, generate a static check error log containing the error type, error location, and involved model features, and do not start the solver; set up For the first The solution program that awaits inspection, in which This is the initial solution program. This is a solver program that re-enters the check after the previous round of repairs; subsequent runtime status acquisition, error classification, layered repair, solver acceptance, and Gurobi calls are generally retained; however, it must be ensured that "controlled operation" only occurs after the static check passes; based on the nth round of the solver program. Collect standard output, standard error, exit code, exception information, exception location, solver status, solver log, and the actual result file generated in this round to form the execution status of the nth round. ,in Error type The location of the error in the program module or code. This is an error message. This is an abnormal call message. For the solver state, This is the set of result files actually generated in the nth round; according to Error types, error locations, exception call information, and IR code block location to be modified: Syntax errors: regenerate the statement containing the error; import error correction module name and interface; Undefined variable errors: supplement variable declaration or uniform reference name according to IR; Index errors: correct loop range according to I; Path errors: change to the current task working directory; The nth round of the solution program After execution, check the number of runtime errors, solver status, constraint violations, and result file integrity; for the g-th constraint in constraint set G, calculate its left-hand side value at the n-th round of candidate solutions. and right-hand side value Then, the violation amount is determined based on the constraint type. ,Pick And determine the acceptance criteria: Where I[·] is the indicator function; Optimal represents obtaining the optimal solution that satisfies the solver termination criterion; Feasible represents obtaining the feasible solution that satisfies the constraints; This represents the number of errors in the nth round of execution. For the reason The defined set of required output fields includes at least berth scheduling, energy output, cost details, and solution log; For the nth round of the solution program The set of output fields actually generated and successfully parsed by the system after calling the mathematical programming solver; ξ is the allowable constraint violation tolerance; The Gurobi algorithm is called to solve the problem, and the final scheduling result is obtained after acceptance testing.
10. A joint scheduling method for port resources based on multi-agent collaboration and enhanced retrieval generation according to any one of claims 1 to 9, characterized in that, The objective function is a joint scheduling objective function for port energy and berths, aiming to minimize the sum of fuel procurement costs, grid interaction costs, and start-up and shutdown costs of controllable energy supply equipment within the scheduling cycle. in, The total cost of port energy supply during the scheduling cycle; For gas turbine fuel procurement costs; Net costs incurred for the interaction between the port and the main power grid; The cost of starting up and shutting down controllable power supply equipment.
Citation Information
Patent Citations
Cooperative scheduling method for port comprehensive energy system and container logistics system
CN115293697A
Ship demand analysis-based berth allocation method and system
CN118446463A
