A vehicle dispatching method and device based on large model intelligent agent
Through the method based on the large-model agent, the driving dispatching agent is defined and optimized, and combined with the reflection agent, the intelligent driving dispatching of the rail transit network command center is realized, and the problem of driving dispatching relies on human intervention in the existing technology has been solved, and the level of intelligence has been improved.
Patent Information
- Application Number
- CN202510000168.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-02
- Publication Date
- 2025-04-08
- Estimated Expiration
- 2045-01-02
AI Technical Summary
The existing technology cannot realize the intelligence of driving scheduling in the command center of the rail transit network, resulting in driving scheduling relying on human intervention and understanding, and lacks flexible and reasonable judgment and planning.
Using a driving scheduling method based on large-model agents, the driving scheduling agent is defined through the Autogen environment framework, a vector database, a Kafka distributed message queue, a query tool set and an execution tool set are configured to build a reflection agent, and associate it with the driving scheduling agent to achieve real-time perception and feedback.
The intelligent driving scheduling of the rail transit command center has been realized, assisted in completing the tasks of driving dispatchers, and improved the intelligent driving supervision of the urban rail network.
Smart Images

Figure CN119398460B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of vehicle dispatching, and in particular to a vehicle dispatching method and device based on a large model intelligent agent. Background Art
[0002] With the rapid development of urban rail transit construction in my country, the line network command center, as the core hub of urban rail transit network operation, has become a must for subway operations in various cities. The line network command center system generally implements a separate train monitoring system for driving services, which monitors the operation of trains by collecting train plans, actual operation diagrams, real-time train reporting information, and the status of train-related equipment, and realizes the operation monitoring of trains on the entire line network.
[0003] The current technical solution is mainly to perform abnormal monitoring by specifying clear judgment rules and setting corresponding thresholds. Although regularized automated monitoring also realizes the ability of vehicle monitoring, it cannot make flexible and reasonable judgments and plans based on actual scenarios, and still relies heavily on human understanding, intervention and execution.
[0004] Therefore, how to design a solution that can realize intelligent train dispatching in the rail transit network command center and assist the center's train dispatching personnel in completing their daily work has become a technical problem that urgently needs to be solved in this field. Summary of the invention
[0005] The purpose of this application is to provide a train dispatching method and device based on a large model intelligent body, which can realize the intelligent train dispatching of the rail transit network command center and assist in completing the daily work of the center's train dispatching personnel.
[0006] To achieve the above objectives, this application provides the following solutions.
[0007] In a first aspect, the present application provides a vehicle scheduling method based on a large model intelligent agent, and the vehicle scheduling method based on a large model intelligent agent includes the following steps.
[0008] Based on the Autogen environment framework, roles are defined for the traffic dispatching agent in the line network command center to obtain the traffic dispatching agent after role definition.
[0009] The driving dispatching intelligent body after the role definition is optimized to obtain the optimized driving dispatching intelligent body; the optimization process includes: configuring a vector database, building a Kafka distributed message queue, configuring a query tool set and configuring an execution tool set; the vector database is used to convert professional documents related to driving dispatching in the urban rail transit industry into vector form; the professional documents include: operation manuals, emergency plans and historical accident analysis reports; the Kafka distributed message queue is used to realize environmental perception capabilities; the query tool set provides the driving dispatching intelligent body with tools for querying historical related data; the execution tool set provides the driving dispatching intelligent body with tools for executing corresponding operations.
[0010] Construct a reflective agent; the reflective agent is used to reflect on the operations that have been performed by the traffic scheduling agent and the feedback obtained, analyze the shortcomings therefrom, and perform optimized execution.
[0011] The optimized traffic scheduling agent is associated with the reflective agent to obtain a final traffic scheduling agent.
[0012] According to the final train dispatching intelligent agent, the current line network train operation status is perceived in real time.
[0013] When the train operation status of the current line network is abnormal, a feedback result is generated; the feedback result includes: informing the corresponding train dispatching personnel and generating an emergency treatment plan.
[0014] In a second aspect, the present application provides a vehicle scheduling device based on a large model intelligent agent, and the vehicle scheduling device based on a large model intelligent agent includes the following contents.
[0015] The role definition module is used to define roles for the traffic dispatching agent of the line network command center based on the Autogen environment framework, and obtain the traffic dispatching agent after the role definition.
[0016] The optimization processing module is used to optimize the driving scheduling intelligent body after the role definition to obtain the optimized driving scheduling intelligent body; the optimization processing includes: configuring a vector database, building a Kafka distributed message queue, configuring a query tool set and configuring an execution tool set; the vector database is used to convert professional documents related to driving scheduling in the urban rail transit industry into vector form; the professional documents include: operation manuals, emergency plans and historical accident analysis reports; the Kafka distributed message queue is used to realize environmental perception capabilities; the query tool set provides the driving scheduling intelligent body with tools for querying historical related data; the execution tool set provides the driving scheduling intelligent body with tools for performing corresponding operations.
[0017] The reflective agent building module is used to build a reflective agent; the reflective agent is used to reflect on the operations that have been performed by the traffic scheduling agent and the feedback obtained, analyze the shortcomings therefrom, and perform optimized execution.
[0018] The association module is used to associate the optimized traffic scheduling agent with the reflective agent to obtain a final traffic scheduling agent.
[0019] The perception module is used to perceive the current line network train operation status in real time according to the final train scheduling intelligent agent.
[0020] The feedback result generating module is used to generate feedback results when there is an abnormality in the operation of the trains in the current line network; the feedback results include: informing the corresponding train dispatching personnel and generating an emergency treatment plan.
[0021] In a third aspect, the present application provides a computer device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement any of the above-mentioned large-model-agent-based vehicle scheduling methods.
[0022] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the above-mentioned vehicle scheduling methods based on a large model intelligent agent.
[0023] In a fifth aspect, the present application provides a computer program product, including a computer program, which, when executed by a processor, implements any of the above-mentioned vehicle scheduling methods based on a large model intelligent agent.
[0024] According to the specific embodiments provided in this application, this application discloses the following technical effects.
[0025] The present application provides a method and device for train scheduling based on a large model intelligent agent. First, based on the Autogen environment framework, the roles of the train scheduling intelligent agent of the line network command center are defined to obtain the train scheduling intelligent agent after role definition; the train scheduling intelligent agent after role definition is optimized to obtain the optimized train scheduling intelligent agent; secondly, a reflective intelligent agent is constructed; then, the optimized train scheduling intelligent agent is associated with the reflective intelligent agent to obtain the final train scheduling intelligent agent; finally, according to the final train scheduling intelligent agent, the current line network train operation status is perceived in real time; when the current line network train operation status is abnormal, feedback results are generated. With the help of the basic capabilities of the domain large model, the present application constructs the train scheduling intelligent agent of the rail transit line network command center, and gives the intelligent agent the ability to use brain, memory, and tools, so that it can have self-reflection, planning and execution capabilities in different train scheduling scenarios, and assist in completing the tasks of train dispatchers. This application uses a large model as its core hub, and configures corresponding query toolsets and execution toolsets to realize the intelligent dispatching of the rail transit network command center, assist in completing the daily work of the center's traffic dispatching personnel, and improve the intelligence level of urban rail network traffic monitoring. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0027] Figure 1 A schematic diagram of the overall structure of a vehicle dispatching intelligent agent provided in one embodiment of the present application.
[0028] Figure 2 A flowchart of a vehicle scheduling method based on a large model intelligent agent is provided for one embodiment of the present application.
[0029] Figure 3 A schematic diagram of a vehicle dispatching agent similarity query provided in one embodiment of the present application.
[0030] Figure 4 A vehicle operating environment perception map provided for an embodiment of the present application.
[0031] Figure 5 A flowchart of an emergency event handling method provided in accordance with an embodiment of the present application.
[0032] Figure 6 A schematic diagram of the functional modules of a vehicle dispatching device based on a large model intelligent agent provided in one embodiment of the present application.
[0033] Figure 7 A schematic diagram of the structure of a computer device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0034] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0035] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0036] This application is for the urban rail transit network command center platform. For the train dispatching business, the large model is used as the central system to realize the intelligent dispatching of the line network. In the actual verification process, this application uses the GPT-4 large model, based on the Autougen intelligent agent development framework and Python development language to realize the intelligent dispatching of trains. Autogen is designed to help developers create complex applications based on large language models, provide a basic framework for multi-agent conversations, and help automate related workflows, simplify construction, optimize processes, and realize automation.
[0037] In order to realize intelligent train dispatching at the line network level, the train dispatching intelligent body constructed in this application needs to connect to the line-level signal system and vehicle system to obtain real-time train operation data to give the intelligent body the ability to perceive the driving environment.
[0038] 1. Line-level signal system: It is a communication-based train control system (CBTC), which is responsible for controlling the operation of trains, including train and interlocking, route control, train interval control, etc. This application accesses the train position data and operation-related equipment status data from the signal system of each line in real time.
[0039] 2. Vehicle system: The vehicle system integrates a large number of sensors and monitoring equipment to collect vehicle operation data in real time, including key information such as speed, position, and status parameters. These data are transmitted to the central processing system through an efficient transmission network. The system monitors the health of the vehicle in real time and promptly detects and diagnoses potential faults. This application accesses the real-time operation status data of the train from the vehicle system of each line.
[0040] The application is summarized as follows: The train dispatching agent of the line network command center of urban rail transit consists of three modules: memory, large model, and tool set (i.e., the train dispatching agent of the line network command center = memory + large model + tool set). Figure 1 As shown, the traffic dispatcher is the core role ( Figure 1 The self-reflective agent ( Figure 1 The symbols 6 and 7 in the figure are to assist the traffic dispatching agent to think about the correctness of the decision and make suggestions to ensure that the traffic dispatching agent executes in the correct way. The traffic dispatching agent and the self-reflection agent work together to complete the network traffic dispatching task. The memory retrieval module includes environmental perception and long-term memory. Figure 1 The identifiers 2 and 3 in the figure support the ability of the traffic dispatching agent to perceive the subway operation environment and to have long-term historical memory. The domain model is the brain of the agent's thinking and decision-making, giving the agent the ability to make autonomous decisions. This application uses GPT-4 in the actual testing process. Toolset ( Figure 1 Identifiers 4 and 5 in the figure provide a series of tools for the traffic dispatching agent to perform specific tasks. The traffic dispatching agent can use different tools to solve practical problems in different scenarios after thinking and making decisions.
[0041] In an exemplary embodiment, Figure 2 As shown, a vehicle scheduling method based on a large model intelligent agent is provided, and the method includes the following steps.
[0042] S1: Based on the Autogen environment framework, define roles for the traffic dispatching agent in the line network command center to obtain the traffic dispatching agent after role definition.
[0043] S2: Optimize the driving dispatching agent after the role definition to obtain the optimized driving dispatching agent; the optimization process includes: configuring a vector database, building a Kafka distributed message queue, configuring a query tool set and configuring an execution tool set; the vector database is used to convert professional documents related to driving dispatching in the urban rail transit industry into vector form; the professional documents include: operation manuals, emergency plans and historical accident analysis reports; the Kafka distributed message queue is used to realize environmental perception capabilities; the query tool set provides the driving dispatching agent with tools for querying historical related data; the execution tool set provides the driving dispatching agent with tools for performing corresponding operations.
[0044] S3: Construct a reflective agent; the reflective agent is used to reflect on the operations that have been performed by the traffic dispatching agent and the feedback obtained, analyze the shortcomings, and optimize the execution.
[0045] S4: Associating the optimized traffic scheduling agent with the reflective agent to obtain a final traffic scheduling agent.
[0046] S5: Based on the final train dispatching intelligent agent, the current line network train operation status is perceived in real time.
[0047] S6: When there is an abnormality in the operation of the trains on the current line network, a feedback result is generated; the feedback result includes: informing the corresponding train dispatching personnel and generating an emergency treatment plan.
[0048] Implementing the above steps S1 to S6 can realize intelligent traffic dispatching of the rail transit network command center, assist the center's traffic dispatching personnel in completing their daily work, and improve the intelligence level of traffic monitoring of the urban rail network.
[0049] The following is an introduction to role definition.
[0050] In the urban rail transit network command center, the function of train dispatching is mainly different from line-level train dispatching in that line-level train dispatching is only for the dispatching of trains on the lines under its jurisdiction, which includes the preparation of train plan operation diagrams, train skipping, passenger clearance, rescue, adding cars, offline, route control and other specific train operations according to actual scenarios. The train dispatching function of the command center focuses more on the coordinated operation of the line network level, rather than the specific operation of the train operation of the designated line, which includes real-time status monitoring and alarm monitoring of trains on the entire line network. According to the actual operation situation, especially in emergency and special operation scenarios, the planned operation diagram is prepared in a coordinated manner, and the broadcast and passenger information screen playback content are distributed in a coordinated manner. Therefore, as an intelligent operator of line network-level train dispatching, the main function of the line network train dispatching agent should be to uniformly monitor the operation status of the entire line network trains, and to send information to the lines and stations in emergency and special operation scenarios. Before creating a line network-level train dispatching agent, you need to define its role first, so that it understands what role it is, what its tasks are, and what it should do. Let them have a basic understanding of their own functions. This application selects Autogen as the framework for agent development and uses Python language to implement it. The subsequent pseudocodes involving the initialization and creation of agents are all implemented in the Autogen framework. The prompt words for the role definition of the driving dispatching agent are as follows.
[0051] import os
[0052] from autogen import ConversableAgent
[0053] TRAIN_DISPATCHING_ROLE_PROMPT = "
[0054] You are an agent that provides driving support for the urban rail transit network command center. Your task is to ensure the smooth operation of the entire rail transit network, but you do not directly operate the trains on specific lines.
[0055] You need to do the following things.
[0056] Real-time monitoring: By collecting real-time train status data from signal and vehicle systems, including the real-time position of the train, the operating status of signal-related equipment, and the running status of the train, the operating status of the entire line network is continuously tracked.
[0057] Alarm response: When a signal-related equipment failure is detected, such as communication interruption at the centralized station, broken filament of a signal machine, switch not in the safe line position, emergency braking of the train, train door alarm, etc., these equipment failure messages should be quickly identified and responded to, and the dispatching personnel should be informed through the command center hall broadcast as soon as possible. Based on the emergency response plans and historical emergency analysis reports in long-term memory, consider the response measures to be taken in the current scenario.
[0058] Emergency handling: When the dispatcher confirms that it is necessary to initiate emergency response to a traffic incident, an emergency handling procedure should be quickly formulated and executed based on the actual situation.
[0059] Information coordination: When it is necessary to send information to passengers through station broadcasts and passenger information screens during emergency response, call the broadcast and passenger information sending tools, and with the permission of the dispatcher, uniformly release line network-level information to guide passengers to travel safely and orderly.
[0060] Collaborative work: When the emergency response process involves environmental and equipment dispatching, and power dispatching, it should be able to work closely with the power dispatching agent and the environmental and equipment dispatching agent to jointly ensure the normal operation of the rail transit network.
[0061] In an exemplary embodiment, the configuration of the vector database specifically includes the following contents.
[0062] A1: Import the required libraries; the required libraries include: chromadb function library and TF-IDF function library.
[0063] A2: Initialize the chromadb client and create a new collection; the new collection is used to store vectorized file data.
[0064] A3: Define a file vectorization function to read the file content. The file vectorization function is used to convert the file content into a vector using a vectorization tool.
[0065] A4: Determine a TF-IDF model based on the document vectorization function and the TF-IDF function library; the TF-IDF model is used to evaluate the importance of a word to a document set or one of the documents in a corpus.
[0066] A5: Based on the TF-IDF model, the file is vectorized, and the vectorized file is stored in the chromadb function library to obtain the chromadb vector database.
[0067] A6: The chromadb vector database is configured to the vehicle scheduling agent through the Autogen framework.
[0068] Specifically, by configuring the vector database through RAG (Retrieval Augmented Generation), professional documents related to train scheduling in the urban rail transit industry (such as operation manuals, emergency plans, historical accident analysis reports, etc.) are converted into vector form to achieve long-term memory capabilities and facilitate intelligent agents to query and learn.
[0069] This application uses chromadb as a vector database, so a chromadb server should be started in advance. This application uses the TF-IDF (Term Frequency-Inverse Document Frequency) model to convert text into vector representation. TF-IDF is a statistical method used to evaluate the importance of a word to a document set or one of the documents in a corpus.
[0070] First, import the required libraries, including the chromadb library and the TF-IDF library.
[0071] import chromadb
[0072] from sklearn.feature_extraction.text import TfidfVectorizer.
[0073] Then, initialize a chromadb client and create a new collection to store the vectorized file data.
[0074] / / Initialize ChromaDB client
[0075] client = chromadb.Client()
[0076] / / Create a new collection (if it doesn't already exist)
[0077] collection_name="your_collection_name"
[0078] collection = client.create_collection(name=collection_name).
[0079] Next, define a method to vectorize the file.
[0080] / / Define file vectorization function
[0081] def file_to_vector(file_path, vectorizer):
[0082] / / Read the file contents
[0083] with open(file_path, 'r') as file:
[0084] content = file.read()
[0085] / / Use the vectorization tool to convert text into vectors
[0086] vector = vectorizer.transform([content])
[0087] / / Convert the vector into a list
[0088] vector = vector.toarray().flatten().tolist()
[0089] return vector.
[0090] Next, instantiate the TF-IDF model object, vectorize the required files, and store them in the chromadb vector database.
[0091] / / Define the model or method for vectorizing text, here we take TF-IDF as an example
[0092] vectorizer = TfidfVectorizer()
[0093] / / Pseudocode: loop to process multiple files
[0094] for file_path in list_of_file_paths:
[0095] / / Vectorize the file
[0096] vector = file_to_vector(file_path, vectorizer)
[0097] #Define the metadata of the file
[0098] metadata = { "file_path": file_path,}
[0099] #Add vectors and metadata to the ChromaDB collection
[0100] collection.add( embeddings=[vector], / / vector list metadata=[metadata] / / metadata list)
[0101] / / Pseudocode: Save changes to
[0102] ChromaDB client. persist(collection_name).
[0103] In this way, the required files are vectorized and stored in the chromadb vector database. Finally, the chromadb vector database is configured to the vehicle scheduling agent through the Autogen framework.
[0104] / / Create an agent and pass the role definition prompt as a parameter to the system_message parameter
[0105] / / When creating the agent in the first step, pass in the file vectorization parameters
[0106] train_dispathing_agent= RetrieveUserProxyAgent("Urban Rail Transit Network Command Center Train Dispatching Intelligent Agent",llm_config={"config_list": [{"model": "gpt-4", "api_key":os.environ.get("OPENAI_API_KEY")}]},system_message=ROLE_PROMPT,
[0107] human_input_mode="ALWAYS", / / Always ask humans whether to continue the next step to prevent the agent from making mistakes
[0108] / / Configure the vector database created above to the agent
[0109] retrieve_config={"client": chromadb.PersistentClient(path="chromadb data persistence file path"),"embedding_model":"vectorizer" / / Specify the vectorization model, the same model as above
[0110] }
[0111] ).
[0112] like Figure 3 As shown, when the traffic dispatching agent is created, it can find the answer that best matches the demand through similarity query, so as to make subsequent decisions and execute operations (that is, the traffic dispatching method based on the large model agent also includes: when the vector database is configured, determine the answer that best matches the demand through similarity query; and make subsequent decisions and execute operations based on the best matching answer). For example, when a door closing failure occurs in traffic dispatching, the traffic dispatching agent will search the chromadb vector database for emergency response plans related to the door closing failure, as well as the actual processing process and analysis reports of historical door closing failures, so as to support it in making correct decisions. The traffic dispatching agent similarity query pseudocode is shown below.
[0113] question = "Emergency plan for door closing failure?",
[0114] / / Use the vectorization tool to convert text into vectors
[0115] question_vector = vectorizer.transform([question]),
[0116] / / Query results from the database
[0117] results = collection.query(embeddings=[question_vector])
[0118] / / Output query results
[0119] print(result).
[0120] In an exemplary embodiment, the construction of the Kafka distributed message queue specifically includes the following contents.
[0121] B1: Create a data producer; the data producer is used to connect the line-level signal system and vehicle system to the Kafka distributed message queue of the line network command center to obtain real-time train data; the line-level signal system is used to send train signal status and related equipment status data to the specified message queue; the vehicle system is used to send train driving status data to the specified message queue;
[0122] B2: Create a data consumer; the data consumer is used to consume the real-time data of the train;
[0123] B3: Create a REST API persistent connection service; the REST API persistent connection service is used to establish a persistent connection with the data consumer. When the data consumer obtains the data of the data producer, it is pushed to the driving dispatching agent in real time through the persistent connection;
[0124] B3: Use Python to define a long connection calling function as a tool for the traffic scheduling agent; the tool of the traffic scheduling agent is a predefined function, and the traffic scheduling agent obtains the real-time operation status of each line by calling the tool;
[0125] B4: According to the real-time running conditions of each line, write the prompt words of the REST API persistent connection service; the prompt words include: the name, purpose and calling method information of the persistent connection service;
[0126] B5: The prompt word is passed in as a parameter when the traffic scheduling agent is initialized to complete the construction of the Kafka distributed message queue.
[0127] This step is based on the role of the intelligent agent and optimizes it to enable it to achieve environmental perception capabilities.
[0128] The line network command center platform obtains the running status of the train in real time by connecting data with the line signals and vehicle systems, and inputs it to the driving dispatching intelligent body, so that the intelligent body can perceive the actual running status of the trains on each line. The Kafka distributed message queue is built in the line network command center. Kafka is a real-time data production and consumption technology suitable for large amounts of data. This application uses Kafka as the data connection channel between the line network command center and the line-level signals and vehicle systems. The real-time data of the train is shown in Table 1.
[0129] Table 1 Real-time train data
[0130]
[0131] The specific implementation steps are as follows.
[0132] 1. First, the line-level signal system and vehicle system are connected to the Kafka distributed message queue of the line network command center as data producers. The vehicle system sends train driving status data to the designated message queue, and the signal system sends train signal status and related equipment status data to the designated message queue. In actual code writing, the train driving status, train signal status and related equipment status can be sent to three different message queues respectively. The code for environmental perception in this application is implemented in Java, and the pseudo code is shown below.
[0133] / / Create Kafka producer
[0134] KafkaProducer<String, String> producer = new KafkaProducer<>(props);
[0135] / / Send message, message is the produced data
[0136] producer.send(message).
[0137] 2. Secondly, the agent connects to the Kafka distributed message queue as a data consumer. It consumes data in real time from the message queue specified above. The pseudo code is as follows.
[0138] / / Create Kafka consumer
[0139] KafkaConsumer<String, String> consumer = new KafkaConsumer<>(props);
[0140] / / Subscribe to the message queue
[0141] consumer.subscribe(“topic_name”);
[0142] / / Consume messages, message is the acquired data
[0143] String message = consumer.poll().
[0144] 3. Next, create a REST API service to establish a persistent connection with the above data consumer roles. When the data consumer obtains the data, it is pushed to the driving dispatch agent in real time through the persistent connection. The persistent connection technology is used to implement the server pushing data to the client without allowing the client to display the request. The pseudo code for creating a REST API is shown below.
[0145] / / Create a REST API persistent connection, the access address is url
[0146] @WebServlet(" / url")
[0147] public class TimeServlet extends HttpServlet {
[0148] @Override
[0149] protected void doGet(HttpServletRequest request, HttpServletResponseresponse){
[0150] / / Get the output stream for writing the response
[0151] PrintWriter writer = response.getWriter();
[0152] / / Continue to send real-time data stream until the long connection is disconnected
[0153] while(!response.isCommitted()){
[0154] / / Send message data. Message is the real-time data obtained above.
[0155] writer.write(message);
[0156] / / Refresh the output stream to ensure that the data is pushed
[0157] writer.flush();
[0158] }
[0159] }
[0160] }.
[0161] 4. Then, use Python to define a long connection calling function as a tool for the agent. The tool is a predefined function that the agent can call to obtain the real-time operation status of each line. The pseudo code is shown below.
[0162] import socket
[0163] / / Define a client to establish a connection with the server
[0164] def long_connection_client():
[0165] client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
[0166] server_address = ('server address', server port)
[0167] client_socket.connect(server_address)
[0168] while True:
[0169] / / Continuously receive driving messages from the server
[0170] data = client_socket.recv(16).
[0171] 5. Then, write the prompt words for the API long connection service. The prompt words need to describe the name, purpose, and calling method information of this long connection service. The sample prompt word template is as follows. The "{}" brackets need to be replaced with actual description information. {api_name} is replaced with the name of the API, and {description} is replaced with the definition and purpose of the API. {url} is replaced with the calling address of the API. {parameters} is replaced with the parameters that need to be passed in when calling the API. {response} is replaced with the result parameters returned by calling the API. {example} provides a call example for the agent to help the agent understand how to call the API. In the actual technical implementation process, the API information needs to be explained in detail based on this template to help the driving dispatch agent fully understand the purpose of the API and support its calls in different scenarios.
[0172] CONTEXT_API = "Describe the name and functionality of the API: {api_name}-{description}
[0173] API URL and HTTP method: URL:{url}
[0174] List all parameters and their descriptions: Parameters:{parameters}
[0175] Describe the structure of the return value: Response:{response}
[0176] Provide an example of usage: Example:{example}".
[0177] 6. Finally, the completed prompt words will be passed in as parameters when the agent is initialized so that it can understand the basic information of this API. The pseudo code is shown below.
[0178] from autogen import register_function
[0179] / / Register the connection_client function to the agent
[0180] register_function(
[0181] connection_client,
[0182] / / The agent can execute the call of connection_client
[0183] executor=train_dispathing_agent,
[0184] / / By default, the function name is used as the tool name
[0185] name="connection_client",
[0186] / / Transfer the API description to the description parameter
[0187] description=CONTEXT_API
[0188] ).
[0189] Driving environment perception diagram Figure 4 shown.
[0190] In an exemplary embodiment, the configuration of the query toolset specifically includes the following contents.
[0191] C1: Write prompt words for each query API tool.
[0192] C2: Use Python to write the calling method of each query API tool.
[0193] C3: According to the prompt words and corresponding calling methods of each query API tool, register the query tool for the driving scheduling agent to complete the configuration of the query tool set.
[0194] Further refine agent roles by configuring query toolsets.
[0195] The query tool set is a tool for the traffic dispatching agent to query historical related data to support its judgment of the current situation. The tool sets are provided in the form of APIs. This application provides the data query tool set shown in Table 2.
[0196] Table 2 Data query tool set
[0197]
[0198] The specific operations for configuring the query toolset for the vehicle scheduling agent are as follows.
[0199] 1. First, write prompt words for each API tool. The prompt word template is as follows: "{}" encloses the actual description information, {api_name} is replaced with the name of the API, and {description} is replaced with the definition and purpose of the API. {url} is replaced with the API call address. {parameters} is replaced with the parameters that need to be passed in when calling the API. {method} is replaced with the API calling method, which generally includes POST and GET. {response} is replaced with the result parameter returned by calling the API. {example} provides a call example for the agent to help the agent understand how to call the API.
[0200] QUERY_API = "Describe the name and functionality of the API: {api_name}-{description}
[0201] API URL and HTTP method: URL:{url}, Method:{method}
[0202] List all parameters and their descriptions: Parameters:{parameters}
[0203] Describe the structure of the return value: Response:{response}
[0204] Provide an example of usage: Example:{example}".
[0205] 2. Then, use Python to write the method for calling each API.
[0206] / / Create API call tool method
[0207] def post_request(url,data):
[0208] try:
[0209] response = requests.post(url,json=data)
[0210] if response.status_code == 200:
[0211] return response.json()
[0212] else:
[0213] return f"Request failed, status code: {response.status_code}".
[0214] 3. Finally, register the tool for the traffic dispatching agent.
[0215] from autogen import register_function
[0216] / / Register the post_request function to the traffic dispatching agent
[0217] register_function(
[0218] post_request,
[0219] / / The agent can execute the post_request call
[0220] executor=train_dispathing_agent,
[0221] / / By default, the function name is used as the tool name
[0222] name="post_request",
[0223] / / Transfer the API description to the description parameter
[0224] description=QUERY_API
[0225] ).
[0226] In an exemplary embodiment, the configuration of the execution toolset specifically includes the following contents.
[0227] D1: Write prompt words for each API execution tool.
[0228] D2: Use Python to write the calling method of each execution API tool.
[0229] D3: According to the prompt words and corresponding calling methods of each execution API tool, register the execution tool for the driving dispatching agent to complete the configuration of the execution tool set.
[0230] Further optimize the agent role by configuring the execution toolset.
[0231] The execution toolset provides the vehicle dispatching agent with tools for performing corresponding operations. The toolsets are provided in the form of APIs. This application provides the execution toolset shown in Table 3.
[0232] Table 3 Execution toolset
[0233]
[0234] The method of registering the execution tool set to the traffic dispatching agent is similar to that of the query tool set. For details, please refer to the configuration of the query tool set, which will not be repeated here. At this point, the construction of the agent is completed.
[0235] In an exemplary embodiment, in step S3, a reflective agent is constructed in order to enable the agent to have reflective capabilities.
[0236] Self-reflection is to reflect on the operations that the traffic dispatching agent has performed and the feedback it has received, analyze the shortcomings, and optimize the execution. This application creates a reflective agent to assist the traffic dispatching agent in reflection. The role of the reflective agent is to criticize and make suggestions on the results obtained by the traffic dispatching agent so that the problem can be better solved. The role prompts and creation pseudocode of the reflective agent are shown below.
[0237] / / Write the prompt words for the reflective agent
[0238] REACT_PROMPT = """
[0239] You are a reflective agent that assists the traffic dispatching agent by evaluating, criticizing, and making suggestions on the decisions and execution results made by the traffic dispatching agent.
[0240] You need to evaluate the decisions made by the traffic dispatching agent as follows:
[0241] Did this decision take into account all relevant safety regulations and standards?
[0242] Is there a better alternative?
[0243] What impact will this decision have on overall driving efficiency?
[0244] Did this dispatch have a negative impact on passengers’ travel experience?
[0245] """
[0246] / / Create a reflective agent and pass the prompt word into the parameter
[0247] react_agent = UserProxyAgent(
[0248] "Reflective Agents",
[0249] llm_config={"config_list": [{"model": "gpt-4", "api_key":os.environ.get("OPENAI_API_KEY")}]},
[0250] system_message=REACT_PROMPT,
[0251] human_input_mode="ALWAYS", / / Always ask humans whether to continue with the next step to prevent the agent from making mistakes
[0252] ).
[0253] Finally, the traffic dispatching agent and the reflective agent of the line network command center are associated, and the operation of the agents is started.
[0254] / / User agent processing
[0255] initializer = autogen.UserProxyAgent(
[0256] name="Initialization", )
[0258] / / Create agent groups
[0259] groupchat = autogen.GroupChat(agents=[initializer,react_agent,train_dispathing_agent])
[0260] manager = autogen.GroupChatManager(groupchat=groupchat, llm_config=gpt4_config)
[0261] / / Start the agent and start running
[0262] initializer.initiate_chat(manager, message="Please perceive the current line network train operation status in real time. If there is any abnormality, please promptly report it through the hall broadcast").
[0263] like Figure 5 As shown in the figure, the emergency scenario of signal communication failure of Line A during the morning rush hour is used as an actual case to illustrate the operation process of the traffic dispatching intelligent agent.
[0264] Real-time perception of emergencies: The network traffic dispatching intelligent body continuously perceives the operation status of each line by collecting data from the signal system and vehicle system. When the A line train signal communication is interrupted, the traffic dispatching intelligent body continues to not receive the A line train signal information, and receives the centralized station communication interruption fault status. At this time, the traffic dispatching intelligent body immediately informs the traffic dispatching personnel through the command center hall broadcast. The traffic dispatching personnel manually confirm whether to initiate emergency event processing.
[0265] Start emergency handling and generate a processing flow: The line network train dispatcher determines whether to start emergency event handling based on whether it has a significant impact on passenger transportation. If the A line train cannot run and passengers are stranded in the train or at the station, the train dispatching agent is informed to start emergency handling. The train dispatching agent obtains the emergency response plan under signal communication failure by calling the long-term memory data stored in the vector database, and formulates an emergency event handling process based on the actual situation. And execute in sequence according to the following steps.
[0266] Send passenger information and remind passengers to travel safely: The line network traffic dispatching intelligent body calls station broadcasts, station and passenger information screens to issue emergency event messages to passengers who are already on Line A and remind passengers of relevant safety measures. Emergency event messages are issued to passengers on other lines to remind passengers that Line A is faulty and they are requested to take other means of transportation.
[0267] Notify key stations to limit passenger flow and reduce passenger flow pressure: The network train dispatching intelligent body calls the passenger flow information query tool to query the current passenger flow of each station on Line A, including entry, exit, transfer, and OD (starting and ending points). By comparing the passenger flow of each station with the normal operation in the same period in history, analyze the key stations and transfer stations on Line A and other lines that need to limit passenger flow, and inform the train dispatching personnel through the command center broadcast, and the train dispatching personnel notify the station staff of the designated stations and transfer stations to limit passenger flow through the official telephone system. This prevents continuous entry of passengers from increasing the passenger density in the station.
[0268] Bus connection at key stations to quickly transport passengers: The network traffic dispatching agent calls the bus route information around the station, queries the bus route information near key stations and transfer stations, and informs the traffic dispatching personnel through the command center broadcast, increases the bus departure frequency at designated stations and transfer stations, connects passengers stranded in the subway through buses, and transports them to their destinations. The traffic dispatching personnel contact the bus command center through the official telephone system.
[0269] Update the operation diagram, and divert the rail transit itself: In order to prevent the A line train from being blocked, stop the departure or increase the departure interval, the line network traffic dispatching intelligent body updates the train plan operation diagram and sends it to the A line control center, which is executed by the A line traffic dispatcher. At the same time, by calling the passenger flow information query tool, query the starting station and destination station of the passengers taking the A line, analyze other lines that can help the A line share the passenger transportation demand, and by calling the operation diagram compilation tool, update the subsequent planned train operation diagram for these lines, increase the departure frequency, and call the operation diagram distribution tool to send the updated line plan train operation diagram to the control center of these lines, which will be executed by the line traffic dispatcher.
[0270] During the emergency response process, the network's traffic dispatching intelligent body always maintains continuous communication with the traffic dispatching personnel through the command center broadcast, and the two parties collaborate to complete the emergency response process.
[0271] This application is implemented on the basis of the rail transit domain big model, which serves as the core hub for the thinking and decision-making of the driving dispatching intelligent body. This application applies the domain big model to the business scenario of rail transit line network driving dispatching, which includes how to combine big data technology to set up the ability of the intelligent body to perceive the driving environment in real time, how to set up the long-term memory ability of the intelligent body, and to sort out the query and execution tool set that the line network driving dispatching intelligent body can perform. This application creates an intelligent robot that can assist and support driving dispatchers, which can realize the intelligent driving dispatching of the rail transit line network command center, assist in completing the daily work of the central driving dispatching personnel, and improve the intelligent level of urban rail line network driving monitoring.
[0272] Based on the same inventive concept, the embodiment of the present application also provides a vehicle scheduling device for implementing the vehicle scheduling method based on a large model intelligent agent involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more embodiments of the vehicle scheduling device based on a large model intelligent agent provided below can refer to the limitations of the vehicle scheduling method based on a large model intelligent agent above, and will not be repeated here.
[0273] In an exemplary embodiment, Figure 6As shown, a vehicle scheduling device based on a large model intelligent agent is provided, and the vehicle scheduling device based on a large model intelligent agent includes the following contents.
[0274] The role definition module M1 is used to define the role of the traffic dispatching agent of the line network command center based on the Autogen environment framework, and obtain the traffic dispatching agent after the role definition.
[0275] The optimization processing module M2 is used to optimize the driving scheduling intelligent body after the role definition to obtain the optimized driving scheduling intelligent body; the optimization processing includes: configuring a vector database, building a Kafka distributed message queue, configuring a query tool set and configuring an execution tool set; the vector database is used to convert professional documents related to driving scheduling in the urban rail transit industry into vector form; the professional documents include: operation manuals, emergency plans and historical accident analysis reports; the Kafka distributed message queue is used to realize environmental perception capabilities; the query tool set provides the driving scheduling intelligent body with tools for querying historical related data; the execution tool set provides the driving scheduling intelligent body with tools for performing corresponding operations.
[0276] The reflective agent construction module M3 is used to construct a reflective agent; the reflective agent is used to reflect on the operations that have been performed by the traffic scheduling agent and the feedback obtained, analyze the shortcomings therefrom, and perform optimized execution.
[0277] The association module M4 is used to associate the optimized traffic scheduling agent with the reflective agent to obtain a final traffic scheduling agent.
[0278] The perception module M5 is used to perceive the current line network train operation status in real time according to the final train scheduling intelligent agent.
[0279] The feedback result generating module M6 is used to generate feedback results when there is an abnormality in the operation of the trains in the current line network; the feedback results include: informing the corresponding train dispatching personnel and generating an emergency treatment plan.
[0280] In an exemplary embodiment, a computer device is provided. The computer device may be a server or a terminal. The internal structure diagram thereof may be as follows: Figure 7As shown. The computer device includes a processor, a memory, an input / output interface (Input / Output, referred to as I / O) and a communication interface. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface is connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store traffic scheduling data. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a traffic scheduling method based on a large model intelligent agent is implemented.
[0281] In an exemplary embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the above-mentioned method embodiments are implemented when the processor executes the computer program.
[0282] In an exemplary embodiment, a computer-readable storage medium is provided, storing a computer program, and when the computer program is executed by a processor, the above-mentioned method embodiments are implemented.
[0283] In an exemplary embodiment, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the above-mentioned method embodiments are implemented.
[0284] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0285] This article uses specific examples to illustrate the principles and implementation methods of this application. The description of the above embodiments is only used to help understand the method and core ideas of this application. At the same time, for those skilled in the art, according to the ideas of this application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as limiting this application.
Claims
1. A vehicle dispatching method based on a large model agent, characterized in that: The vehicle dispatching method based on the large model agent includes: Based on the Autogen environment framework, define roles for the traffic dispatching agent in the line network command center, and obtain the traffic dispatching agent after role definition; The driving dispatching agent after the role definition is optimized to obtain the optimized driving dispatching agent; the optimization process includes: configuring a vector database, building a Kafka distributed message queue, configuring a query tool set and configuring an execution tool set; the vector database is used to convert professional documents related to driving dispatching in the urban rail transit industry into vector form; the professional documents include: operation manuals, emergency plans and historical accident analysis reports; the Kafka distributed message queue is used to realize environmental perception capabilities; the query tool set provides the driving dispatching agent with tools for querying historical related data; the execution tool set provides the driving dispatching agent with tools for executing corresponding operations; Constructing a reflective agent; the reflective agent is used to reflect on the operations that have been performed by the traffic dispatching agent and the feedback obtained, analyze the deficiencies therefrom, and perform optimized execution; Associating the optimized traffic scheduling agent with the reflective agent to obtain a final traffic scheduling agent; According to the final train dispatching intelligent agent, the current line network train operation status is perceived in real time; When the train operation of the current line network is abnormal, a feedback result is generated; the feedback result includes: informing the corresponding train dispatching personnel and generating an emergency treatment plan; The vehicle dispatching method based on the large model agent also includes: When the vector database is configured, the answer that best matches the requirement is determined through similarity query; Based on the best matching answer, subsequent decisions and execution operations are made.
2. The vehicle dispatching method based on a large model agent according to claim 1 is characterized in that: The configuration of the vector database specifically includes: Import the required libraries; the required libraries include: chromadb function library and TF-IDF function library; Initialize the chromadb client and create a new collection; the new collection is used to store vectorized file data; Define a file vectorization function to read file content, wherein the file vectorization function is used to convert the file content into a vector using a vectorization tool; Determine a TF-IDF model based on the document vectorization function and the TF-IDF function library; the TF-IDF model is used to evaluate the importance of a word to a document set or one of the documents in a corpus; Based on the TF-IDF model, the vectorization of the file is completed, and the vectorized file is stored in the chromadb function library to obtain the chromadb vector database; The chromadb vector database is configured to the vehicle scheduling agent through the Autogen framework.
3. The vehicle dispatching method based on a large model agent according to claim 1 is characterized in that: The construction of the Kafka distributed message queue specifically includes: Create a data producer; the data producer is used to connect the line-level signal system and vehicle system to the Kafka distributed message queue of the line network command center to obtain real-time train data; the line-level signal system is used to send train signal status and related equipment status data to the specified message queue; the vehicle system is used to send train driving status data to the specified message queue; Creating a data consumer; the data consumer is used to consume the real-time data of the train; Create a REST API persistent connection service; the REST API persistent connection service is used to establish a persistent connection with the data consumer. When the data consumer obtains the data of the data producer, it is pushed to the driving scheduling agent in real time through the persistent connection; A long connection calling function is defined in Python as a tool for the traffic scheduling intelligent agent; the tool of the traffic scheduling intelligent agent is a predefined function, and the traffic scheduling intelligent agent obtains the real-time operation status of each line by calling the tool; According to the real-time running conditions of each line, a prompt word of the REST API persistent connection service is written; the prompt word includes: the name, purpose and calling method information of the persistent connection service; The prompt word is passed in as a parameter when the traffic scheduling agent is initialized to complete the construction of the Kafka distributed message queue.
4. The vehicle dispatching method based on a large model agent according to claim 1 is characterized in that: The configuration of the query toolset specifically includes: Write prompt words for each query API tool; Use Python to write the calling method of each query API tool; According to the prompt words and corresponding calling methods of each query API tool, register the query tool for the driving scheduling agent to complete the configuration of the query tool set.
5. The vehicle dispatching method based on a large model agent according to claim 1 is characterized in that: The configuration of the execution toolset specifically includes: Write prompt words for each API tool that executes it; Use Python to write the calling method of each execution API tool; According to the prompt words and corresponding calling methods of each execution API tool, register the execution tool for the driving scheduling agent to complete the configuration of the execution tool set.
6. A vehicle dispatching device based on a large model intelligent agent, characterized in that: The vehicle dispatching device based on the large model intelligent agent comprises: The role definition module is used to define roles for the traffic dispatching agent in the line network command center based on the Autogen environment framework, and obtain the traffic dispatching agent after the role definition; The optimization processing module is used to optimize the driving scheduling intelligent body after the role definition to obtain the optimized driving scheduling intelligent body; the optimization processing includes: configuring a vector database, building a Kafka distributed message queue, configuring a query tool set and configuring an execution tool set; the vector database is used to convert professional documents related to driving scheduling in the urban rail transit industry into vector form; the professional documents include: operation manuals, emergency plans and historical accident analysis reports; the Kafka distributed message queue is used to realize environmental perception capabilities; the query tool set provides the driving scheduling intelligent body with tools for querying historical related data; the execution tool set provides the driving scheduling intelligent body with tools for executing corresponding operations; when the vector database configuration is completed, the answer that best matches the demand is determined through similarity query; and subsequent decision-making and execution operations are performed according to the best matching answer; A reflective agent building module is used to build a reflective agent; the reflective agent is used to reflect on the operations that have been performed by the traffic dispatching agent and the feedback obtained, analyze the deficiencies therefrom, and perform optimized execution; An association module, used to associate the optimized traffic scheduling agent with the reflective agent to obtain a final traffic scheduling agent; A perception module, used to perceive the current network train operation status in real time according to the final train dispatching intelligent agent; The feedback result generating module is used to generate feedback results when there is an abnormality in the operation of the trains in the current line network; the feedback results include: informing the corresponding train dispatching personnel and generating an emergency treatment plan.
7. A computer device comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the large model agent-based vehicle scheduling method described in any one of claims 1 to 5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the vehicle scheduling method based on a large model intelligent agent described in any one of claims 1 to 5 is implemented.
9. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the vehicle scheduling method based on a large model intelligent agent described in any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Intelligent public transport cloud-brain system based on big data
CN110705747A
Urban rail transit train operation control system oriented to different intelligent levels
CN111923966A