Agent simulation method based on reinforcement learning
By using a reinforcement learning-based agent simulation method, the problems of lag and safety in traditional evacuation route planning in dynamic disaster scenarios are solved. This method enables agents to learn autonomously and model differently, thereby improving evacuation efficiency and safety.
Patent Information
- Application Number
- CN202611377186.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-07
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2046-09-07
AI Technical Summary
Traditional evacuation route planning methods are ill-suited to dynamic disaster scenarios and cannot accurately simulate individual autonomous decision-making and group interaction. This results in lagging route planning and insufficient safety, while high computational costs limit real-time decision-making and ignore the heterogeneity of agents.
A simulation method based on reinforcement learning is adopted. Through physical scene initialization, water level dynamics model construction, reinforcement learning model construction, and agent decision-making actions, combined with the Actor-Critic architecture and PPO algorithm, the agent can achieve differentiated modeling and autonomous learning of the optimal evacuation strategy.
It enables real-time path replanning in dynamic environments, refines the behavioral differences of agents of different ages, improves evacuation efficiency and safety, and reduces computational costs.
Smart Images

Figure CN122886932B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of intelligent agent simulation technology, specifically relating to an intelligent agent simulation method based on reinforcement learning. Background Technology
[0002] In public safety emergencies, the scientific and efficient nature of crowd evacuation is directly related to the safety of life and property. Traditional evacuation route planning methods rely heavily on static maps and preset rules, which are difficult to adapt to dynamic changes such as the spread of floods and channel congestion in disaster scenarios. Furthermore, they cannot accurately simulate the complex behaviors of autonomous decision-making and group interaction, resulting in problems such as lag and insufficient safety in the planned routes. Multi-agent systems offer a better option for solving flood evacuation problems. Traditional research methods have formed two separate paths when dealing with this problem: one focuses on the accurate reproduction of the physical environment, such as CFD modeling; the other focuses on the rule abstraction of crowd behavior, such as social force models and cellular automata.
[0003] The above technology has the following drawbacks: 1. Complex environment modeling: For example, CFD modeling requires three-dimensional numerical simulation based on the VOF method to simulate the environment based on the real physical environment. However, the CFD method requires accurate physical information, which leads to high computational costs. This makes it difficult to directly interface with real-time evacuation decision-making systems and cannot be used for dynamic environmental decision-making. 2. Inability to accurately reflect the influence of the environment on the agent: The "force" in the traditional social force model is a metaphor for psychological distance. Incorporating the physical force of floods into the social force model makes the parameters inaccurate, and the final conclusions are far from the actual situation. 3. The heterogeneity of intelligent agents is not taken into account: Traditional models often regard intelligent agents as the same intelligent agents from a macroscopic perspective, and they have the same response when facing the environment. This does not take into account the different behaviors of pedestrians of different ages and health conditions in the actual escape environment, and cannot truly reflect the pedestrian's escape status.
[0004] Therefore, we need to propose a simulation method for intelligent agents based on reinforcement learning. Summary of the Invention
[0005] The purpose of this invention is to provide an intelligent agent simulation method based on reinforcement learning. The model can autonomously learn the optimal evacuation strategy and adaptively adjust decisions, breaking through the limitations of rigid rules and static optimization in traditional models, and realizing real-time path replanning in dynamic environments, so as to solve the problems in the prior art mentioned in the background.
[0006] To achieve the above objectives, the present invention adopts the following technical solution: The agent simulation method based on reinforcement learning includes the following steps: S1, Physical scene initialization, specifically including: a. Physical space model construction: Discretize the actual physical space into a uniform grid, divide the site area into grids, and define the position and size of static obstacles in the grids to construct a two-dimensional planar space; b. Water level dynamics model construction: Establish an exponential decay model based on distance decay, linearly superimpose the water level contributions of each inlet, and calculate the real-time water depth and flow velocity of each grid point in the scene. c. Building a reinforcement learning model: Establish a Markov decision process framework, define the state space, action space and reward function, and use the Actor-Critic architecture to build the policy network and value network; S2. The agent makes a decision and obtains the state vector of the agent at the current moment. The state vector consists of the following information: the agent's own two-dimensional position coordinates, the two-dimensional position coordinates of the target exit, the one-dimensional water depth value at the current position, the two-dimensional velocity component of the water flow at the current position, the distances from the agent to the nearest obstacle in the four directions in front, behind, left and right, and the one-dimensional crowd density value within the preset range around the agent. S3. Decision experience replay: Construct an interactive cache pool to store the state transition sequences s, a, r, s′ obtained by the agent's interaction with the environment. For each iteration, randomly sample from the cache pool in batches to break the temporal correlation between consecutive samples. The sampled batch experience is used to update the Q function of the target network. S4. The agent motion cycle: each agent makes decisions one by one, and the system automatically switches to the next agent to continue the same simulation process until all agents reach the exit and complete the motion simulation. S5. Results visualization: Find the shortest path length and highest escape rate in the model test results, draw the escape path, and provide real-time escape strategies.
[0007] Preferably, in step a of S1, the physical space model construction includes site gridding and obstacle construction; the site gridding specifically involves dividing the site into 0.5m×0.5m grids to simulate subsequent agent actions and water level diffusion.
[0008] Preferably, in S1, in the exponential decay model based on distance decay, the water level at each grid point is calculated as follows: taking each inlet as the origin, the water level decays exponentially with the increase of distance from the inlet, and the formula is: water=base_height×exp(-dist / λ), where base_height is the basic water level rise, dist is the distance of the grid point from the inlet, and λ is the decay coefficient; the multi-inlet superposition mechanism is: the water level heights generated by each inlet at the same grid point are arithmetically summed to obtain the total water level height of the grid point.
[0009] Preferably, step S2 further includes differentiated configurations of the intelligent agents, specifically: the upper limit of the movement speed of the child intelligent agent is 70%-80% of that of the adult intelligent agent, and the upper limit of the movement speed of the elderly intelligent agent is 60%-70% of that of the adult intelligent agent; The perception range of children's and elderly's intelligent agents is smaller than that of adult intelligent agents, and the temperature parameter of their action selection probability distribution is higher than that of adult intelligent agents, in order to simulate the behavioral characteristics of children and the elderly with higher decision-making uncertainty; A group interaction mechanism is set up between various types of intelligent agents. The group interaction mechanism includes the synergistic effect of three forces: self-driving force, repulsive force, and attractive force. The self-driving force drives the intelligent agents to move towards the target direction, the repulsive force keeps the intelligent agents at a minimum safe distance to avoid collisions, and the attractive force keeps the same group together within a certain range.
[0010] Preferably, the water level dynamics model simulates the flood diffusion process, water flow velocity field and turbulence effect. It constructs a water model on a simulation platform using mathematical methods to simulate water diffusion and local water flow, which has high computational efficiency and takes into account various parameters of real water flow. The distance-based exponential decay model in the water level dynamics model construction is based on the planar space of the subway environment. The water diffusion model is based on the fact that the diffusion of flood in open space often manifests as the water level decays exponentially with the increase of distance from the inlet. Preferably, when a multi-inlet superposition mechanism is set in the water level dynamics model, the model accumulates the influence of each inlet on the total water level and the influence of different inlets on the water level rise through iterative calculation, and obtains the water level rise in the flood convergence area.
[0011] Preferably, in the construction of the reinforcement learning model, the Markov decision process is the standard mathematical formal framework for reinforcement learning problems, and a Markov decision process consists of quintuples. In full definition, the goal of Markov decision-making is to find an optimal strategy; In reinforcement learning model building, when building the PPO algorithm model, PPO is used to introduce a pruning alternative objective function, which effectively constrains the policy update magnitude in a concise first-order optimization form.
[0012] Preferably, in the construction of the reinforcement learning model, environmental information is constructed as follows: self-position information (two-dimensional), target position information (two-dimensional), water depth information (one-dimensional), water flow velocity information (two-dimensional), obstacle distance information (four-dimensional), and crowd density (one-dimensional).
[0013] Preferably, in the reinforcement learning model construction, the reward function not only guides the agent to choose the appropriate action, but also reflects the quality of a certain behavior of the agent; the reward function is designed in reinforcement learning to incentivize the agent to complete the main event, guide the agent to make evacuation and escape decisions, and find the optimal escape route.
[0014] Preferably, in the reinforcement learning model construction, the reward function includes: successful escape reward, distance reward, direction reward, reaching the marker point reward, distance away from the water source reward, water level penalty, effective speed reward, and crowd density penalty.
[0015] Technical effects and advantages of the present invention: The intelligent agent simulation method based on reinforcement learning proposed in this invention has the following advantages compared with the prior art: (1) Dynamic path planning based on PPO algorithm: The model can learn the optimal evacuation strategy autonomously, adjust the decision adaptively, break through the limitations of rigid rules and static optimization of traditional models, and realize real-time path replanning in dynamic environment. (2) Refined modeling of intelligent agents: differentiated characterization of the movement speed and decision-making ability of children, adults and the elderly, and introduction of crowd interaction mechanism (coordination of self-driven / repulsion / attraction forces) to better reflect the dynamics of real evacuation; (3) Physically driven flood environment model: Based on the water level dynamics model with exponential decay over distance and the linear superposition mechanism of multiple inlets, it takes into account both physical realism and computational efficiency, and supports millisecond-level step simulation. Attached Figure Description
[0016] Figure 1 This is a schematic diagram of the process framework of the present invention; Figure 2 This is a diagram showing the site dimensions and grid division for this invention; Figure 3 This is a schematic diagram of a 3D model of a subway station according to the present invention; Figure 4 This is a flowchart of the PPO algorithm of the present invention; Figure 5 This is a heatmap of the escape path of the intelligent agent in the embodiment; Figure 6This is a diagram showing the optimal escape route trajectory in the embodiment; Figure 7 The image shows the test results in the example. Figure 8 This is a line graph showing the change in escape rate in the example. Detailed Implementation
[0017] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The specific embodiments described herein are merely used to explain the present invention and are not intended to limit the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0018] This invention provides, for example Figure 1-8 The illustrated method for simulating an intelligent agent based on reinforcement learning includes the following steps: S1. Physical scene initialization: This involves planning the physical environment's scope and the types and locations of obstacles. The scene is built using Python and NumPy, and visualized using Matplotlib, thus constructing a digital physical scene. S1 specifically includes: a. Physical space model construction: Discretize the actual physical space into a uniform grid, divide the site area into grids, and define the position and size of static obstacles in the grids to construct a computable two-dimensional planar space; b. Water level dynamics model construction: Establish an exponential decay model based on distance decay, linearly superimpose the water level contributions of each inlet, and calculate the real-time water depth and flow velocity of each grid point in the scene. c. Building a reinforcement learning model: Establish a Markov decision process framework, define the state space, action space and reward function, and use the Actor-Critic architecture to build the policy network and value network; S2. The agent makes a decision and obtains the current state vector of the agent at the current moment. The state vector consists of the following information: the agent's own two-dimensional position coordinates, the two-dimensional position coordinates of the target exit, the one-dimensional water depth value at the current position, the two-dimensional velocity component of the water flow at the current position, the distances to the nearest obstacles in the four directions in front, behind, left, and right of the agent, and the one-dimensional crowd density value within a preset range around the agent. Under the guidance of the reward function, the agent's action is sampled. The Critic network inputs the state vector and outputs the state evaluation value. The PPO algorithm is used to replace the objective function to constrain the update magnitude of the old and new strategies. The decision process is stored in the experience pool, and the agent enters the next state. S3. Decision experience replay: Construct an interactive cache pool to store the state transition sequence s,a,r,s′ obtained by the agent's interaction with the environment, which is the four-tuple of state, action, reward and next state in the Markov decision process; During training, random batch sampling is performed from the cache pool for each iteration to break the temporal correlation between consecutive samples. The sampled batch experience is used to update the Q function of the target network. S4. The agent motion cycle: each agent makes decisions one by one, and the system automatically switches to the next agent to continue the same simulation process until all agents reach the exit and complete the motion simulation. S5. Results visualization: Find the best result of the model test, the shortest path length, and the highest escape rate, draw the escape path, and draw a heat map of the model. Through the visualization of results, the escape path is guided, and dynamic path planning is performed in real time. It can provide rapid feedback and real-time escape strategies.
[0019] In S2, agents are configured with different upper limits for movement speed and different decision-making ability parameters according to different age types, including children, adults and the elderly, to differentiate the escape behaviors of various agents in a flood environment.
[0020] The specific differentiated configurations of the intelligent agents are as follows: the maximum movement speed of the child intelligent agent is 70%-80% of that of the adult intelligent agent, and the maximum movement speed of the elderly intelligent agent is 60%-70% of that of the adult intelligent agent; In terms of decision-making ability, the perception range of children's and elderly's intelligent agents is smaller than that of adult intelligent agents, and the temperature parameter of their action selection probability distribution is higher than that of adult intelligent agents, in order to simulate the behavioral characteristics of children and the elderly with higher decision-making uncertainty. A group interaction mechanism is set up between various types of intelligent agents. The group interaction mechanism includes the synergistic effect of three forces: self-driving force, repulsive force, and attractive force. The self-driving force drives the intelligent agents to move towards the target direction, the repulsive force keeps the intelligent agents at a minimum safe distance to avoid collisions, and the attractive force keeps the same group together within a certain range.
[0021] Specifically, refined modeling of intelligent agents: To realistically reflect the behavioral differences among different types of intelligent agents in flood evacuation scenarios, this invention constructs an agent swarm. The agents are divided into three categories based on age: children (≤12 years old), adults (12 years < ≤ 60 years old), and the elderly (>60 years old). These three categories of agents have differentiated configurations in terms of physical mobility and decision-making behavior characteristics. 1. Differentiated movement speed configuration: The upper limit of the base movement speed for different types of intelligent agents is set as follows: Adult intelligent agent: The basic speed limit is 1.5-1.7m / s, which serves as the benchmark speed; Children's intelligent agents: The upper limit of the basic speed is 70%-80% of that of adult intelligent agents, that is, 1.1-1.3m / s, to simulate the physiological characteristics of children with smaller strides and weaker physical strength; Elderly AI Agent: The basic speed limit is 60%-70% of that of the adult AI agent, i.e., 0.9-1.1 m / s, to simulate the physiological characteristics of slow movement and physical decline in the elderly.
[0022] In actual simulations, the real-time movement speed of each agent is also affected by the current water depth: when the water depth exceeds 0.3m, the speed limit of all types of agents decreases linearly, with a speed decrease of 10%-15% for every 0.1m increase in water depth; when the water depth exceeds 1.2m, the agents will be unable to pass.
[0023] 2. Differentiated allocation of decision-making capabilities: The decision-making ability parameters for different types of intelligent agents are set as follows: Differentiated perception range: The environmental perception radius of an adult agent is 8-12 grid units; the perception radius of children's and elderly agents is reduced to 60%-80% of that of adult agents, i.e., 5-9 grid units, to simulate the cognitive characteristics of children and the elderly who have weaker ability to acquire and process environmental information and narrower field of vision. Differentiation in decision-making uncertainty: In the action selection strategy, a temperature parameter τ is introduced to control the smoothness of the action probability distribution. The temperature parameter τ of the adult agent is 0.8-1.0, and the decision-making is relatively certain; the temperature parameter τ of the child agent and the elderly agent is 1.2-1.5, and the action probability distribution is smoother and more random, simulating the characteristics of children and the elderly with greater decision-making fluctuations and poorer behavioral consistency. Differentiation in response delay: After perceiving changes in the environment, the child and elderly agents have a response delay of 1-2 simulation steps longer than the adult agents, simulating their slower information processing cognitive characteristics.
[0024] 3. Group interaction mechanism: The intelligent agents are connected by a group interaction mechanism, employing a three-force synergy model of self-driving force, repulsion force, and attraction force. Self-driving force: drives the agent to move towards the currently selected target exit at a desired speed. Its direction is a unit vector from the agent's current position to the target exit, and its magnitude is the desired speed value corresponding to the agent's current type. Repulsive force: When the distance between two agents is less than the preset safe distance threshold (0.5-1.0m), a repulsive force is generated in the direction of the line connecting the centers of the two agents, so that the agents maintain the minimum safe distance and avoid collisions and crowding. The magnitude of the repulsive force is inversely proportional to the distance between the agents; the smaller the distance, the greater the repulsive force. Attraction: When the distance between similar intelligent agents exceeds a preset aggregation distance threshold (usually 3-5m), a weak attraction is generated, causing the same type of group to remain relatively clustered within a certain range, simulating the companionship behavior of family members or homogeneous groups during evacuation; the resultant force of the three forces determines the actual direction and speed of movement of the intelligent agent at the current moment. The agent's position is updated by determining the direction of movement based on the direction of the resultant force, and determining the movement distance based on the current type's speed limit and water depth correction coefficient, and then gradually updating the coordinate position.
[0025] By refining the modeling of the agents described above, the simulation model can realistically reflect the behavioral differences among people of different ages during flood evacuation, avoiding the simulation distortion problem caused by treating all agents as homogeneous agents in traditional models.
[0026] like Figure 1 As shown, the overall process framework of this invention is as follows: The entire simulation system consists of two main modules: static elements and dynamic elements. Static elements include: a physical space model, a site grid, obstacle definitions, static obstacles such as pillars, chairs, vending machines, trash cans, and a simulated flooding model, including water level and velocity fields. Dynamic elements include: a group of intelligent agents, including children / adults / elderly individuals, agent state information, position, velocity, target direction, and a perception model, including state perception.
[0027] The simulation process is as follows: First, static elements are initialized to construct a digital physical scene and immersion environment; then, a group of intelligent agents is generated, and each agent acquires state information through a perception model; in each simulation step, the agent's decision model outputs an action based on the current state, the environment model updates its position based on the agent's action, and the water level dynamics model updates the water level distribution synchronously; the movement of the agents is constrained and modulated by the group interaction mechanism, with self-driving force, repulsive force, and attractive force working together; the above process is iterated until all agents reach the exit or the maximum simulation time is reached; finally, the simulation results are visualized and analyzed.
[0028] like Figure 4 As shown, the specific training process of the PPO algorithm of this invention is as follows: The training process of the PPO algorithm is achieved through the collaborative iterative updates of the policy network and the value network. In each training step, the Actor network first interacts with the environment based on the current policy to sample a batch of experience trajectories, which contain a sequence of states, actions, rewards, and the next state; simultaneously, the Critic network calculates the value estimate for each state. .
[0029] Calculate the dominance function based on the collected empirical trajectories. The dominance function is used to evaluate the performance of each action relative to the average level. A positive dominance function indicates that the action is better than the average level, while a negative dominance function indicates that the action is worse than the average level.
[0030] Then, the probability ratio of the new and old strategies is calculated. This is the ratio of the probability of the current policy and the old policy choosing the same action under the same state. This ratio reflects the magnitude of the policy update. Substitute into the trimming and substitution objective function In the middle, the objective function is pruned using the min operation: when Exceeding When the interval is reached, the objective function is pruned, thus limiting the magnitude of policy changes in a single update. The Actor network parameters are then updated by maximizing this objective function using stochastic gradient ascent.
[0031] The value network is updated by minimizing the value loss function, which is the mean squared error between the value estimate and the actual return. ,in For cumulative discount rewards.
[0032] The Actor network and Critic network are updated alternately, and the policy is gradually optimized through multiple iterations, eventually converging to the optimal evacuation policy.
[0033] Throughout the training process, the early stopping mechanism monitors the average reward and escape rate metrics on the validation set in real time. When the validation set performance no longer improves for several consecutive rounds, the training is terminated early to avoid overfitting and to save the current optimal model weights for subsequent testing.
[0034] Specifically, the physical space model: See Figure 2 Site gridding: The physical space model needs to be gridded. In order to accurately reproduce the real spatial characteristics of indoor personnel evacuation in the subway flood scenario, the model constructs a subway station plan with a length of 108.5m and a width of 23.0m, and uses a 0.5m×0.5m grid to divide the site to simulate the subsequent actions of the intelligent agent and the spread of water level, with a total of 217×45 grid points. The static elements include water inlets and escape exits, and the site boundaries are considered as static element walls. The water inlets are located at the left-hand virtual escalator position, with x-range [0,12] and y-range [9.75,13.75]. The water outlets are located at the right-hand virtual escalator position, with x-range [96.5,108.5] and y-range [9.75,13.75]. The virtual water inlets simplify the flood model. The entrance and exit locations are constructed according to a typical subway station layout. The site, water inlets, and escape exit locations are as follows... Figure 2 As shown.
[0035] See Figure 3 Obstacle construction: In order to simulate the subway environment in the physical space model, it is also necessary to simulate obstacles in the subway environment. In the environment file of this model, common obstacles in subway stations are defined and constructed, such as... Figure 3 As shown in Table 1, the types and shapes of obstacles are as follows: Table 1. Obstacle Types and Shapes:
[0036] Specifically, the water level dynamics model: In step b of S1, the water level at each grid point in the distance-based exponential decay model is calculated as follows: taking each inlet as the origin, the water level decreases exponentially with the increase of distance from the inlet; the multi-inlet superposition mechanism is: the water level heights generated by each inlet at the same grid point are arithmetically summed to obtain the total water level height of the grid point.
[0037] The water level dynamics model is the core module for simulating flood diffusion, water flow velocity field and turbulence effect. It constructs a water model on the simulation platform using mathematical methods to simulate water diffusion and local water flow. It has high computational efficiency and takes into account various parameters of real water flow. Among them, the exponential decay model based on distance decay: This model is based on the planar space of a subway environment. Since the diffusion of floodwater in open spaces often exhibits an exponential decrease in water level with increasing distance from the inlet, this is the basis for modeling the water diffusion. In the model, the water level update formula at the main inlet is as follows: base_height=riserate*time / 50 water=height*np.exp(-dist_main / 40) In the formula, base_height represents the rise in base water level, dist_main is the distance to the main inlet, and the exponential decay term np.exp(-dist_main / 40) simulates the attenuation characteristics of the flood wave. This is consistent with the principle of the diffuse wave model, that is, when the water flow changes slowly and the inertial force is much smaller than the pressure, gravity, and friction, the water flow behavior can be described by a convection-diffusion equation, resulting in a decrease in wave crest along the path and a broadening of the waveform.
[0038] Among them, the multi-inlet stacking mechanism: Due to flood pressure, subway stations may have multiple water inlets. Mathematically, these inlets can be represented as a linear superposition, and as long as there is no excessive disturbance, they can all be uniformly approximated by linear superposition. The model iteratively calculates and accumulates the impact of each water inlet on the total water level, the impact of different water inlets on the water level rise, and obtains the amount of water level rise in the flood convergence area.
[0039] Specifically, the Markov decision process: In reinforcement learning model building, Markov Decision Processes (MDPs) are the standard mathematical formal framework for reinforcement learning problems. A Markov Decision Process consists of quintuples. The complete definition and the meaning of each element are shown in Table 2: Table 2. Meaning of elements in a Markov decision process:
[0040] The core assumption of MDP is the Markov property, which can be stated in one sentence as follows: the state of the system in the next time step depends only on the current state and the current action, and is independent of the historical trajectory. This property is expressed by the following formula: This simplifies the complexity of the solution.
[0041] The goal of MDP is to find the optimal strategy. To maximize the expected cumulative discounted return starting from any initial state, the formula for calculating the cumulative reward is as follows:
[0042] Define two key value functions: 1. State value function —Measurement in strategy The expected return when in state s:
[0043] 2. Action-value function —Measure whether the policy continues to be followed after performing action a in state s. Expected returns:
[0044] The recurrence relation between the two is characterized by the Bellman Equation, which is the theoretical foundation of all reinforcement learning algorithm solutions. The Bellman optimality equation states that the value function under the optimal policy satisfies:
[0045] However, in multi-person evacuation scenarios, it is necessary to consider the interaction and coordination between multiple agents. On this basis, the state in the next moment is not only related to the current state and the current action. Therefore, the MDP of a single agent needs to be extended to Markov game or decentralized partially observable Markov decision process. The agent can only observe local information and needs to make decisions based on local information. This is the current challenge.
[0046] Specifically, the Actor-Critic architecture: The architecture comprises the following two complementary network modules: Actor: This is the network that manages actions in the model. It can be understood as an actor that outputs an action or a probability distribution of actions based on the current state. Its core task is decision-making. The agent obtains reward parameters by interacting with the surrounding environment and is the core of the model's perception.
[0047] Critic: This is the network responsible for decision-making in the model; it can be understood as a commentator or value network. (or The network is responsible for evaluating the merits of the current strategy and providing low-variance gradient guidance signals to the Actor. This network evaluates the quality of decisions and selects a more worthwhile one, which is the core of the model's judgment.
[0048] When the model begins training, the Actor first takes action, acquiring data in the corresponding dimensions through interaction with the surrounding environment. Then, the Critic processes the data, using temporal differencing to update the value assessment, calculate the advantage function, and determine whether the Actor's current action is a good or bad decision compared to the average level. Finally, the Actor updates its policy function based on the advantage function provided by the Critic, using it as the gradient signal for the next action. The expression for the policy function is as follows:
[0049] In the formula The advantage function is a judgment of the merits of the current action. The advantage function is calculated by subtracting the baseline. This effectively reduces variance while maintaining data unbiasedness. To further optimize the bias-variance tradeoff, generalized dominance estimation is applied by introducing parameters. Perform an exponentially weighted average of the TD errors of different time lengths:
[0050] in This represents the single-step TD error. When The time-degradation is a single-step TD estimate, characterized by low variance and high bias, while The time degenerates into a Monte Carlo estimate, characterized by low bias and high variance. In practical applications, it is usually taken as... To achieve the best balance.
[0051] Specifically, the PPO algorithm model is built as follows: Policy gradient methods can suffer from drastic performance degradation with excessively large step sizes during each update, leading to significant differences between the old and new policies. While trust region policy optimization addresses this issue through KL divergence constraints, its second-order optimization is computationally expensive. Therefore, a method that balances stability and computational efficiency is needed. The core innovation of PPO lies in introducing a pruning alternative objective function, which achieves an effective constraint on the policy update magnitude in a concise first-order optimization form:
[0052] in This represents the probability ratio between the old and new strategies. This is the clipping hyperparameter (usually set to 0.1 or 0.2). The advantage function estimate is calculated for GAE. The beauty of this objective function lies in the fact that when the advantage is positive ( When the action is better than average, Limited to no more than To prevent overly aggressive amplification of good moves; when the advantage is negative ( When the action is worse than average, Restricted to no less than This prevents overly aggressive suppression of poor actions; the min operation ensures that the objective function is always a lower bound of the true objective, providing a conservative but robust update direction, allowing the agent to gradually find the optimal solution in each training iteration.
[0053] Specifically, motion space settings: State space setup is a crucial step in reinforcement learning; the state space represents the environmental information that the agent can perceive. The environmental information constructed in this invention includes: Self-position information (two-dimensional): The agent's X and Y coordinates on the subway station floor plan. This directly determines the agent's physical location in the environment and is the foundation for all other environmental information. Other location information is calculated based on the agent's current location and needs to be updated in real-time according to the agent's movement.
[0054] Target location information (two-dimensional): This refers to the X and Y coordinates of the safety exit, which is the location of the target that the agent wants to reach. In a multi-exit environment, the agent will select the best escape exit based on its current location and water level information.
[0055] Water depth information (one-dimensional): The water depth at the agent's current location. Water depth affects the agent's walking speed; excessively deep water may even make it impossible to pass, causing panic behaviors. Therefore, the impact of water depth on the agent needs to be considered.
[0056] Water flow velocity information (two-dimensional): The X and Y velocity components of the water flow at the agent's current location. Water flow velocity not only affects the agent's movement direction and speed, but high flow velocities can also cause the agent to lose balance and fall, especially in narrow areas such as subway station stairs. Therefore, incorporating water flow velocity information more realistically simulates the state of the agent affected by water flow in a flood environment, making the model more realistic.
[0057] Obstacle distance information (four-dimensional): The distances of the intelligent agent from obstacles in front, behind, to the left, and to the right. If the agent cannot pass through an obstacle, it will adjust its escape path and escape strategy based on the distance to the obstacle.
[0058] Crowd density (one-dimensional): The number of agents in a 3x3 grid around an agent, used to simulate the crowd density in a flood escape environment. If the crowd density is too high, the agent will tend to avoid it and go to an area with a low crowd density, simulating the crowd avoidance behavior of the agent during escape.
[0059] The intelligent agent will read environmental information from different dimensions, and by analyzing this environmental information, it will gain the ability to perceive and understand the environment, which will serve as the basis for subsequent decision analysis.
[0060] Specifically, the reward function is set as follows: Besides guiding the agent to choose appropriate actions, the reward function can also reflect the quality of a particular action. In reinforcement learning, the reward function is designed to incentivize the agent to complete the main event, guide the agent to make evacuation decisions, and find optimal escape routes. In the model of this invention, the following reward design is implemented: (1) Successful escape reward: In the individual simulation of subway evacuation, the agent's sole objective is to escape safely to the suburbs. Therefore, the successful escape reward has the highest priority, satisfying the goal-oriented principle. A high final reward can motivate the agent to explore and learn the optimal behavioral method to achieve the goal.
[0061] (2) Distance reward: guides the agent to move towards the exit. Here, an exponential decay function is used, that is, the closer the agent is to the exit, the greater the reward increases, and the less it increases when the agent reaches the exit. This is defined to make the agent move towards the exit earlier and generate a large reward increase when approaching the exit, which is like the gravitational force of a social force model, creating a gravitational field.
[0062] (3) Directional Reward: Directional reward is a refinement of distance reward, directly reinforcing the agent to take the correct action towards the exit. When the agent attempts to shorten the distance between itself and the exit, it will receive a positive reward (+500); however, if its action causes it to move away from the exit, it will be penalized (-200). This direct feedback is a reward shaping method in reinforcement learning, which accelerates the agent's development of correct behavioral strategies so that the agent does not lose itself or wander outside the environment.
[0063] (4) Reward for reaching marker points: Reward for reaching marker points refers to the reward for reaching certain important points. In long-distance evacuation, the initial reward alone cannot alleviate the problem of reward sparsity, thus making learning very difficult. Setting marker points at various distances from the exit fence (60m, 40m, 25m, 15m, 8m, 3m) and providing incremental rewards for reaching more marker points can provide the agent with more intermediate feedback and compensate for the reward sparsity problem. This is similar to the sub-objectives in hierarchical reinforcement learning, which decomposes a more complex task into simpler sub-tasks to accelerate learning.
[0064] (5) Distance Reward from Water Source: Subway flood evacuation requires agents to not only escape but also avoid dangerous areas in the flooded region. Water inlets are often areas with fast-flowing, rapidly rising water levels and are prone to debris and other hazards. Therefore, agents will receive a reward (+100) when they are at a safe distance (>30m) from the water inlet, and a penalty (-150) when they approach dangerous areas (<20m). This reward encourages agents to learn behaviors that avoid dangerous events, ensuring their safety when evacuating from exits.
[0065] (6) Water Level Penalty: Water level is the most important environmental factor in a flooded environment, directly affecting the agent's ability to move and threatening its safety. Therefore, a negative reward is set for water level. When the water depth exceeds the impassable water level, a severe penalty of -1000 is applied to the agent to prevent it from entering shallow water areas; when the water depth exceeds the difficult-to-pass water level, a moderate penalty of -300 is applied. This guides the agent to understand the threat posed by high water levels, move to shallower water levels, avoid deep water levels, and plan a better route.
[0066] (7) Effective Speed Reward: Beyond ensuring safety, the discrete set mechanism is crucial for effective evacuation. Therefore, optimizing evacuation is a key indicator of the quality of the evacuation strategy. Effective speed reward encourages the agent to move at a certain speed, preventing excessive delays or slow movement within safe zones. This balances the agent's consideration of hazard avoidance with rapid movement, facilitating the learning of more proactive and effective evacuation strategies.
[0067] (8) Crowd density penalty: When escaping, dense crowds will block the escape path of the agent and reduce the evacuation efficiency, or even cause stampedes and result in injuries to the crowd. Therefore, a penalty for crowd density is added to the model. When the agent faces a dense area of agents, it will tend to avoid it. This can simulate the behavior of the agent during real evacuation, guide the agent to escape in a dispersed manner, avoid crowding, and make the evacuation path found by the agent more reasonable, more efficient and safer.
[0068] By designing a reward function, we can provide macroscopic guidance to agents to choose escape strategies in a directional manner and find more efficient escape routes.
[0069] In summary, this invention theoretically enables the exploration of the application of multi-agent reinforcement learning in disaster environments; in reality, it can provide strong technical support for emergency plan formulation, emergency response capability improvement, and public safety awareness enhancement.
[0070] For a simulated example of a real-world scenario, please refer to [link / reference]. Figure 5-8 : Scene setting: The dimensions are 108.5m × 23.0m. The main water inlet corresponds to the down escalator on the left, and the outlet corresponds to the up escalator on the right. 6 uprights (x=30 / 60 / 90, y=5 / 18, r=0.8m); 8 benches (x=20 / 40 / 60 / 80, y=2 and y=19.5); short chairs, vending machines, and trash cans are configured according to S1. A total of 20 people: 10 adults (50%) + 5 children (25%) + 5 elderly people (25%), evenly distributed in the middle of the platform; The standard rise rate is water_rise_rate × 1.0, and a secondary inlet appears randomly after 250s.
[0071] Operating steps: Call SubwayEnvironment(seed) to generate the above environment; Agent(i,env,age_type) generates an intelligent agent; PPOActor loads the weights from ppo_training_model_ep50.pth; Each step is executed as follows: env.update_water_level(step)→infer_action()→Agent.move(action,agents) (crowd avoidance + exit attraction fusion ON), until all are completed or 400s timeout; statistical analysis of escape rate, mortality rate, escape time, path length, and escape rate by age.
[0072] See Figure 5-8 As can be seen from the heat map, the escape path of the intelligent agent is clear, with no obvious blockages, and it can make full use of space to escape; See Figure 5-8 The training and testing results show that the agent training significantly improves the change in escape rate, and the early stop mechanism works normally. As the agent learns the escape strategy, it can complete the escape behavior in the flood environment, and the model is effective.
[0073] Finally, it should be noted that the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A reinforcement learning-based agent simulation method, characterized in that, Includes the following steps: S1, Physical scene initialization, S1 specifically includes: a. Physical space model construction: Discretize the actual physical space into a uniform grid, divide the site area into grids, and define the position and size of static obstacles in the grids to construct a two-dimensional planar space; b. Water level dynamics model construction: Establish an exponential decay model based on distance decay, linearly superimpose the water level contributions of each inlet, and calculate the real-time water depth and flow velocity of each grid point in the scene. c. Building a reinforcement learning model: Establish a Markov decision process framework, define the state space, action space and reward function, and use the Actor-Critic architecture to build the policy network and value network; In S1, the water level at each grid point is calculated using the distance-based exponential decay model as follows: taking each inlet as the origin, the water level decays exponentially with increasing distance from the inlet, as shown in the formula: water = base_height × exp(-dist / λ), where base_height is the base water level rise, dist is the distance from the grid point to the inlet, and λ is the decay coefficient. The multi-inlet superposition mechanism is as follows: the water level heights generated by each inlet at the same grid point are arithmetically summed to obtain the total water level height of that grid point. S2, the agent makes a decision and obtains the current state vector of the agent at the current moment. The state vector consists of the following information: the agent's own two-dimensional position coordinates, the two-dimensional position coordinates of the target exit, the one-dimensional water depth value at the current position, the two-dimensional velocity component of the water flow at the current position, the distances to the nearest obstacles in the four directions in front, behind, left, and right of the agent, and the one-dimensional crowd density value within a preset range around the agent. The agent is configured with different upper limits of movement speed and different decision-making ability parameters according to different age types, including children, adults, and the elderly, to differentiate the escape behaviors of various agents in a flood environment. S2 also includes differentiated configuration of the agent, specifically: the upper limit of movement speed for children's agents is 70%-80% of that for adults' agents, and the upper limit of movement speed for elderly agents is 60%-70% of that for adults' agents. The perception range of children's and elderly's intelligent agents is smaller than that of adult intelligent agents, and the temperature parameter of their action selection probability distribution is higher than that of adult intelligent agents, in order to simulate the behavioral characteristics of children and the elderly with higher decision-making uncertainty; A group interaction mechanism is set up between various types of intelligent agents. The group interaction mechanism includes the synergistic effect of three forces: self-driving force, repulsive force and attractive force. The self-driving force drives the intelligent agents to move towards the target direction, the repulsive force keeps the intelligent agents at a minimum safe distance to avoid collisions, and the attractive force keeps the same group together within a certain range. In the construction of the reinforcement learning model, the reward function includes: successful escape reward, distance reward, direction reward, reaching the marker point reward, distance away from the water source reward, water level penalty, effective speed reward, and crowd density penalty; S3. Decision experience replay: Construct an interactive cache pool to store the state transition sequence s,a,r,s′ obtained by the agent's interaction with the environment, which is the four-tuple of state, action, reward and next state in the Markov decision process; During training, random batch sampling is performed from the cache pool for each iteration to break the temporal correlation between consecutive samples. The sampled batch experience is used to update the target network. S4. The agent motion cycle: each agent makes decisions one by one, and the system automatically switches to the next agent to continue the same simulation process until all agents reach the exit and complete the motion simulation. S5. Results visualization: Find the shortest path length and highest escape rate in the model test results, draw the escape path, and provide real-time escape strategies. 2.The reinforcement learning based agent simulation method of claim 1, wherein: In step a of S1, the physical space model construction includes site gridding and obstacle construction; the site gridding specifically involves dividing the site into 0.5m×0.5m grids to simulate subsequent agent actions and water level diffusion. 3.The reinforcement learning based agent simulation method of claim 2, wherein: When a multi-inlet superposition mechanism is set in the water level dynamics model, the model iteratively calculates and accumulates the influence of each inlet on the total water level, the influence of different inlets on the water level rise, and obtains the water level rise in the flood convergence area. 4.The reinforcement learning based agent simulation method of claim 2, wherein: In the construction of the reinforcement learning model, the Markov decision process is the standard mathematical formal framework for reinforcement learning problems. A Markov decision process is fully defined by a quintuple. The goal of the Markov decision process is to find an optimal policy. In reinforcement learning model building, PPO algorithm model is used to introduce a pruning alternative objective function. 5.The reinforcement learning based agent simulation method of claim 2, wherein: In the construction of the reinforcement learning model, the reward function not only guides the agent to choose the appropriate action, but also reflects the quality of a certain behavior of the agent. The reward function is designed in reinforcement learning to incentivize the agent to complete the main event, guide the agent to make evacuation and escape decisions, and find the optimal escape route.
Citation Information
Patent Citations
City updating effect evaluation method and system based on big data
CN122066087A
