A space index method, system, terminal and medium for super-large-scale crowd interaction calculation in a digital twin scene

By constructing an adaptive quadtree index structure, the query complexity of ultra-large-scale population simulation is reduced, fast proximity query and interactive calculation are realized, the real-time and performance instability problems of traditional methods are solved, and the real-time interaction needs in digital twin scenarios are met.

CN122285671APending Publication Date: 2026-06-26SHENZHEN UNIV

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
SHENZHEN UNIV
Filing Date
2026-04-30
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

In simulations of ultra-large-scale populations, existing technologies employ traditional global traversal search methods with a time complexity of O(n²), which cannot meet real-time requirements. Furthermore, existing index structures exhibit unstable performance under dynamic updates and non-uniform distribution scenarios, making it difficult to achieve efficient proximity queries.

Method used

An adaptive quadtree index structure is constructed, and the query complexity is reduced to O(NlogN) through recursive partitioning and geometric pruning. The number of node objects is monitored in real time to perform splitting and merging operations, thereby optimizing the index structure.

Benefits of technology

It enables fast proximity query and interactive computation for large-scale populations, meets the needs of real-time simulation, improves computational efficiency and memory usage flexibility, and solves the computational bottleneck of proximity search between intelligent agents.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122285671A_ABST
    Figure CN122285671A_ABST
Patent Text Reader

Abstract

This invention provides a spatial indexing method, system, terminal, and medium for large-scale crowd interaction computing in digital twin scenarios, relating to the field of computer simulation technology. The method includes: initializing a root node space based on the two-dimensional boundary of the simulation scene; performing recursive spatial partitioning operations based on the root node space to construct a quadtree index structure; responding to a received query request, starting from the root node space, using the root node space as the current node space, and determining whether the target query range intersects with the current node space; if so, performing geometric pruning operations; otherwise, determining the node space type of the current node space, and performing geometric intersection testing or recursive pruning traversal based on the node space type. This invention reduces the complexity of global traversal by constructing an efficient quadtree index structure and performing spatial queries starting from the root node space of the quadtree index structure through geometric intersection testing and recursive pruning traversal.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer simulation technology, and in particular to a spatial indexing method, system, terminal, and medium for large-scale crowd interaction computing in digital twin scenarios. Background Technology

[0002] With the increasing application of digital twin technology in large-scale public spaces such as major sporting events and transportation hubs, higher demands are being placed on the realism, real-time performance, and detailed characterization of individual behaviors in large-scale crowd simulations. Existing simulation technologies face core challenges when dealing with ultra-large-scale (e.g., tens of thousands to hundreds of thousands) virtual crowds: on the one hand, to improve the credibility of the simulation, it is necessary to meticulously characterize individual differences and responses to complex environments; on the other hand, the computational complexity of interactions between individuals increases exponentially with scale, easily falling into the "curse of dimensionality."

[0003] Current mainstream population simulation methods (such as social force models, agent models, and cellular automata) all require efficient underlying neighbor search and interaction computing mechanisms. However, traditional search methods based on global traversal have a time complexity of O(n²), which cannot meet real-time requirements. Summary of the Invention

[0004] In view of this, the purpose of this invention is to provide a spatial indexing method, system, terminal and medium for ultra-large-scale crowd interaction computing in digital twin scenarios, which can reduce the complexity of global traversal from O(N²) to close to O(NlogN) and meet the real-time requirements.

[0005] The technical solution adopted by this invention to solve the technical problem is as follows: In a first aspect, the present invention discloses a spatial indexing method for ultra-large-scale crowd interaction computation in digital twin scenarios, wherein the method includes: The root node space is initialized based on the two-dimensional boundary of the current simulation scene; the virtual individuals within the current simulation scene are used as spatial objects in the root node space. Recursive space partitioning operations are performed based on the root node space to construct a quadtree index structure; In response to the received query request, starting from the root node space of the quadtree index structure, the root node space is taken as the current node space, and it is determined whether the target query range intersects with the current node space. If the target query range does not intersect with the current node space, then perform a geometric pruning operation; If the target query range intersects with the current node space, the node space type of the current node space is determined. If the node space type of the current node space is a leaf node space, all space objects in the leaf node space are traversed, and the target space object is determined through geometric intersection test to obtain the set of virtual individuals within the target query range. When the node space type in the current node space is a branch node space, the four child node spaces under the branch node space are determined as the current node space, and the step of determining whether the target query range intersects with the current node space and its subsequent steps are re-executed.

[0006] Optionally, the recursive space partitioning operation based on the root node space to construct a quadtree index structure includes: The root node space is evenly divided into four sub-quadrants, and each sub-quadrant is used as the current parent node space. Determine the number of space objects in the current parent node's space; Determine whether the number of space objects in the current parent node space exceeds a preset threshold; If the number of space objects in the current parent node space exceeds the preset threshold, the current parent node space will be further divided into four child node spaces evenly. Each of the child node spaces is taken as the current parent node space, and the step of determining the number of space objects in the current parent node space and its subsequent steps are executed again. If the number of space objects in the current parent node space does not exceed the preset threshold, then the segmentation stops, and the child node space is determined as the leaf node space.

[0007] Optionally, the recursive space partitioning operation based on the root node space to construct a quadtree index structure includes: The root node space is evenly divided into four sub-quadrants, and each sub-quadrant is used as the current parent node space. Determine the current recursion depth and check if the current recursion depth has reached the maximum recursion depth; If the current recursion depth has not reached the maximum recursion depth, then the current parent node space will be further divided into four child node spaces evenly. Take each of the child node spaces as the current parent node space, and re-execute the steps of determining the current recursion depth and judging whether the current recursion depth has reached the maximum recursion depth; If the current recursion depth reaches the maximum recursion depth, then the segmentation stops, and the child node space is determined as the leaf node space.

[0008] Optionally, the spatial indexing method for ultra-large-scale crowd interaction computation in digital twin scenarios further includes: During the dynamic virtual crowd simulation, the number of spatial objects in each node space of the quadtree index structure is monitored in real time, and the node splitting or merging operation is automatically triggered based on the number of spatial objects in real time to optimize the quadtree index structure.

[0009] Optionally, the splitting operation is triggered when the number of spatial objects in the leaf node space exceeds a preset splitting threshold, and the merging operation is triggered when the total number of spatial objects in all leaf nodes under the same branch node space does not exceed a preset merging threshold.

[0010] Optionally, the geometric intersection test includes at least one of the following: a point-node region inclusion test, an axis-aligned rectangle-node region overlap test, and a circle-node region farthest point distance test.

[0011] Optionally, the segmentation method used in the recursive spatial segmentation operation can be uniform segmentation or centroid-based segmentation.

[0012] Secondly, the present invention also discloses a spatial indexing system for ultra-large-scale crowd interaction computing in digital twin scenarios, wherein the system comprises: The root node initialization module is used to initialize the root node space according to the two-dimensional boundary of the current simulation scene; the virtual individuals in the current simulation scene are used as spatial objects in the root node space. The quadtree construction module is used to perform recursive space partitioning operations based on the root node space to construct a quadtree index structure. The intersection determination module is used to respond to the received query request, starting from the root node space of the quadtree index structure, taking the root node space as the current node space, and determining whether the target query range intersects with the current node space; The geometric pruning module is used to perform geometric pruning operations when the target query range does not intersect with the current node space. The type determination module is used to determine the node space type of the current node space when the target query range intersects with the current node space. The geometric intersection test module is used to traverse all spatial objects in the leaf node space when the node space type of the current node space is a leaf node space, and determine the target spatial object through geometric intersection test to obtain the set of virtual individuals within the target query range; The recursive pruning module is used to determine the four child node spaces under the branch node space as the current node space when the node space type of the current node space is a branch node space, and re-execute the step of determining whether the target query range intersects with the current node space and its subsequent steps.

[0013] Thirdly, the present invention discloses a terminal, comprising: a memory, a processor, and a spatial indexing program for large-scale crowd interaction computing in a digital twin scenario, stored in the memory and executable on the processor, wherein the spatial indexing program for large-scale crowd interaction computing in a digital twin scenario, when executed by the processor, implements the steps of the spatial indexing method for large-scale crowd interaction computing in a digital twin scenario as described above.

[0014] Fourthly, the present invention discloses a computer-readable storage medium storing a computer program that can be executed to implement the steps of the spatial indexing method for ultra-large-scale crowd interaction computing in a digital twin scenario as described above.

[0015] This invention provides a spatial indexing method, system, terminal, and medium for ultra-large-scale crowd interaction computation in a digital twin scenario. The spatial indexing method for ultra-large-scale crowd interaction computation in a digital twin scenario includes: initializing a root node space based on the two-dimensional boundary of the current simulation scenario; using virtual individuals within the current simulation scenario as spatial objects in the root node space; performing recursive spatial partitioning operations based on the root node space to construct a quadtree index structure; responding to a received query request, starting from the root node space of the quadtree index structure, using the root node space as the current node space, and determining whether the target query range intersects with the current node space; and in the case of a query request, determining whether the target query range intersects with the current node space. If the target query range does not intersect with the current node space, a geometric pruning operation is performed. If the target query range intersects with the current node space, the node space type of the current node space is determined. If the node space type of the current node space is a leaf node space, all space objects within the leaf node space are traversed, and the target space object is determined through a geometric intersection test to obtain the set of virtual individuals within the target query range. If the node space type of the current node space is a branch node space, the four child node spaces under the branch node space are determined as the current node space, and the step of determining whether the target query range intersects with the current node space and subsequent steps are re-executed. Therefore, this invention achieves fast proximity search and interactive computation for a large number of virtual individuals on a two-dimensional plane by constructing an efficient spatial index structure, namely a quadtree index structure. The continuous two-dimensional space is recursively divided into four equally sized quadrants to form a tree-like hierarchical quadtree index structure. Through geometric intersection testing and recursive pruning traversal, spatial queries are performed starting from the root node space of the quadtree index structure, thereby reducing the complexity of global traversal from O(N²) to close to O(NlogN). In scenarios with extremely high real-time requirements, such as real-time simulation of large-scale virtual crowds, this invention directly solves the computational bottleneck of proximity search between agents, enabling stable support for real-time interaction of larger-scale virtual crowds while maintaining the complexity of individual behavior. Attached Figure Description

[0016] Figure 1 This is a flowchart of a preferred embodiment of the spatial indexing method for ultra-large-scale crowd interaction computation in the digital twin scenario of the present invention; Figure 2 This is a flowchart of a specific spatial indexing method for ultra-large-scale crowd interaction computing in a digital twin scenario, as disclosed in this invention. Figure 3 This is a functional principle block diagram of a preferred embodiment of the spatial indexing system for ultra-large-scale crowd interaction computing in the digital twin scenario of the present invention; Figure 4This is a functional principle block diagram of a preferred embodiment of the terminal in this invention. Detailed Implementation

[0017] To make the objectives, technical solutions, and advantages of this invention clearer and more explicit, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

[0018] With the increasing application of digital twin technology in large-scale public spaces such as major sporting events and transportation hubs, the demand for high-fidelity reproduction and real-time interaction of the physical world based on digital twin scenarios has placed higher requirements on the realism, real-time performance, and detailed characterization of individual behaviors in large-scale crowd simulations. However, existing simulation technologies face core challenges when dealing with ultra-large-scale (e.g., tens of thousands to hundreds of thousands) virtual crowds: on the one hand, to improve the credibility of the simulation, it is necessary to meticulously characterize individual differences (such as age, physical fitness, and behavioral preferences) and responses to complex environments (such as moving obstacles and unstructured terrain); on the other hand, the computational complexity of interactions between individuals increases exponentially with scale, easily falling into the "curse of dimensionality."

[0019] Current mainstream population simulation methods (such as social force models, agent models, and cellular automata) all rely on efficient underlying neighbor search and interaction computing mechanisms. However, when the simulation scale exceeds tens of thousands, the time complexity of traditional global traversal-based search methods becomes O(n²), leading to an explosion in computational load and failing to meet real-time requirements. Moreover, these models based on manually generated rules struggle to automatically learn and generalize complex behaviors from real-world data, resulting in insufficient reliability of simulation results when facing unforeseen scenarios.

[0020] For example, current mainstream pedestrian simulation methods mainly revolve around individual behavior modeling, forming two technical paths: one is the mechanical driving method represented by social force models, which drives continuous motion through virtual force equations. Its model is intuitive but its parameters are sensitive. That is, although social force models can generate continuous motion trajectories, its parameter system is highly sensitive and its physical meaning is obscure. The adjustment process heavily relies on expert experience and is difficult to adapt to different behavioral patterns. The other is the behavior driving method represented by intelligent agent models, which endows individuals with perception and decision-making capabilities. It can simulate complex behaviors but has a large computational cost. Furthermore, cellular automata, as a classic discrete model, updates pedestrian states on a grid-by-grid basis. While computationally efficient, they suffer from weak motion continuity. In other words, cellular automata discretize a continuous space, resulting in unnatural grid jumps in motion and an inability to describe fine-grained turns and speed changes. Gas dynamics models, on the other hand, treat the crowd as a continuous medium, suitable for macroscopic flow analysis, but struggle to characterize individual details. In other words, gas dynamics models completely sacrifice individual discernibility, limiting their applicability to macroscopic flow analysis. Moreover, these rule-based models struggle to automatically learn from real-world data and generalize complex behaviors, leading to insufficient reliability of simulation results in unforeseen scenarios. Despite their different modeling approaches, all methods require addressing collision avoidance and path coordination at the underlying level, thus relying on efficient neighbor search and interactive computation mechanisms. Especially in the typical neighbor-based interactive computing paradigm, each agent needs to traverse all other individuals in the scene to determine interactive neighbors. This search method with a time complexity of O(n²) requires about 100 million distance judgments in a single calculation when simulating a scale of 10,000 people. Even with the introduction of basic optimization methods such as spatial grids, it is still difficult to meet the stringent requirements of real-time simulation or long-term extrapolation on computing performance.

[0021] Currently, spatial indexing technology has become crucial for achieving efficient computation. Besides fundamental methods like uniform grids, mainstream efficient indexing structures include: quadtrees, which achieve adaptive space management through recursive partitioning; KD-trees, which alternately partition along dimensions to support dynamic data; and various binary tree structures (such as BSP trees). However, uniform grids can lead to memory waste and ineffective computation due to a large number of empty cells when the population distribution is extremely uneven. While KD-trees and other binary tree structures are suitable for dynamic point sets, their rebalancing overhead under frequent updates is significant, and they lack naturalness in two-dimensional space partitioning. Traditional basic quadtrees lack real-time perception of scene density distribution, and their fixed partitioning strategy easily leads to tree structure depth imbalance, causing performance fluctuations between dynamic updates and queries. Furthermore, existing mainstream indexing structures are often coarsely coupled with upper-level behavioral models, failing to form an efficient data flow integrating perception, decision-making, and movement, thus limiting overall scalability and flexibility.

[0022] To this end, this application provides a spatial indexing scheme for ultra-large-scale crowd interaction computing in digital twin scenarios, which can reduce the complexity of global traversal from O(N²) to close to O(NlogN).

[0023] Please see Figure 1 , Figure 1 This is a flowchart of the spatial indexing method for ultra-large-scale crowd interaction computation in digital twin scenarios, as described in this invention. Figure 1 As shown in the embodiments of the present invention, the spatial indexing method for ultra-large-scale crowd interaction computation in digital twin scenarios includes: Step S11: Initialize the root node space according to the two-dimensional boundary of the current simulation scene; the virtual individuals in the current simulation scene are used as spatial objects in the root node space.

[0024] The root node space represents the entire two-dimensional space, such as a square region. The root node space can be defined by the center point coordinates O and the dimension S. The center point coordinates O are the (x,y) coordinates of the geometric center of the two-dimensional square region in the current coordinate system; the dimension S refers to the side length of the two-dimensional square region.

[0025] In this embodiment, the root node space is initialized based on the two-dimensional boundary range of the current simulation scene. The spatial objects in the root node space are the virtual individuals within the current simulation scene. Furthermore, the number of spatial objects is also the number of virtual individuals.

[0026] Step S12: Perform a recursive space partitioning operation based on the root node space to construct a quadtree index structure.

[0027] The construction of this quadtree index structure enables fast proximity queries and interactive calculations for a large number of virtual individuals on a two-dimensional plane.

[0028] In this embodiment, after initializing the root node space based on the two-dimensional boundary range of the current simulation scene, a recursive spatial partitioning operation is performed starting from the root node space to construct a quadtree index structure. That is, the quadtree index structure is constructed through a recursive spatial partitioning process. Furthermore, in the recursive spatial partitioning process, in addition to uniform partitioning, centroid-based partitioning can also be used, that is, calculating the centroid of objects within a node as a partitioning reference point, which helps to construct a more balanced subtree structure. For simulation spaces with special geometric shapes, a surface subdivision strategy can be adopted to make the partitioning boundaries conform to the actual geometric contours of the space, thereby providing better spatial partitioning efficiency in different scenarios.

[0029] The uniform division into four equal parts ensures that the spatial size of each child node is completely equal, avoiding the imbalance of tree structure depth caused by non-uniform division. At the same time, after each split, the expected number of objects in each child node is reduced to 1 / 4 of the parent node. In the uniform distribution scenario, the recursion depth is stable at log4(N / T) layers, where N is the total number of objects and T is the single node capacity threshold, ensuring that the query path length is always on the order of O(logN).

[0030] In one specific implementation, the root node space is evenly divided into four sub-quadrants, and each sub-quadrant is used as the current parent node space; the number of space objects in the current parent node space is determined; it is determined whether the number of space objects in the current parent node space exceeds a preset threshold; if the number of space objects in the current parent node space exceeds the preset threshold, the current parent node space is further evenly divided into four child node spaces; each child node space is used as the current parent node space, and the step of determining the number of space objects in the current parent node space and its subsequent steps are executed again; if the number of space objects in the current parent node space does not exceed the preset threshold, the division is stopped, and the child node spaces are determined as leaf node spaces.

[0031] In another specific implementation, the root node space is evenly divided into four sub-quadrants, and each sub-quadrant is used as the current parent node space; the current recursion depth is determined, and it is determined whether the current recursion depth has reached the maximum recursion depth; if the current recursion depth has not reached the maximum recursion depth, the current parent node space is further evenly divided into four child node spaces; each child node space is used as the current parent node space, and the steps of determining the current recursion depth and determining whether the current recursion depth has reached the maximum recursion depth are executed again; if the current recursion depth has reached the maximum recursion depth, the division is stopped, and the child node spaces are determined as leaf node spaces.

[0032] Understandably, the partitioning process starting from the root node space follows strict geometric rules: the space of the node to be partitioned (i.e., the root node as the parent node) is uniformly divided into four sub-quadrants, corresponding to four child nodes. The size of each child node is half the size of its parent node, i.e., S. split =S / 2, specifically: during segmentation, calculate the offset vector. =S split / 2, the center coordinates of the four child nodes can be O respectively. child =O+ ×(±1,±1), when the number of spatial objects contained within a node does not exceed a preset threshold or the current recursion depth reaches the maximum recursion depth, the segmentation process terminates, and the child node becomes a leaf node. That is, if a region contains multiple spatial objects, and the number of spatial objects within that region exceeds a preset threshold or the current recursion depth reaches the maximum recursion depth, then that region is recursively divided into four sub-regions. Each sub-region becomes a child node.

[0033] Step S13: In response to the received query request, starting from the root node space of the quadtree index structure, take the root node space as the current node space, and determine whether the target query range intersects with the current node space.

[0034] Understandably, when a query request is received, the response adopts a depth-first recursive traversal strategy, starting from the root node of the quadtree index structure and using it as the current node space. First, it determines whether the target query range intersects with the current node space, quickly determining whether the target query range is within the simulation space. Through a combination of geometric intersection testing and recursive pruning, it only visits a subset of local nodes that have spatial overlap with the target query range, thereby compressing the global traversal complexity of O(N²) to an efficient retrieval close to O(NlogN).

[0035] Step S14: If the target query range does not intersect with the current node space, then perform a geometric pruning operation.

[0036] In this embodiment, it is determined whether the target query range intersects with the current node space. If the determination result indicates that the target query range does not intersect with the current node space, then pruning is performed directly, meaning the entire non-intersecting subtree is skipped. The smaller the query range, the higher the pruning ratio. The purpose of pruning is to avoid unnecessary recursive traversal and calculation by pre-excluding nodes that are unlikely to contain the target result, thereby significantly improving query efficiency. In other words, the geometric pruning strategy only needs to access a limited number of nodes related to the query region, thus achieving an order-of-magnitude improvement in query efficiency.

[0037] Step S15: If the target query range intersects with the current node space, then determine the node space type of the current node space.

[0038] In this embodiment, it is determined whether the target query range intersects with the current node space. If the determination result shows that the target query range intersects with the current node space, the node space type of the current node space can be further determined. In subsequent steps, geometric intersection test or recursive pruning traversal is performed based on the node space type.

[0039] In the quadtree index structure, all nodes are divided into two types: leaf nodes and branch nodes. Leaf nodes are terminal nodes in the tree structure with no child nodes. They directly store spatial objects and have zero child nodes. They directly hold a list of virtual individuals as storage content. During a query, they traverse all internal objects, performing precise geometric intersection tests one by one. When the number of objects in a leaf node exceeds the threshold triggering a split, it transforms into a branch node. Branch nodes are intermediate nodes in the tree structure with four child nodes. They do not directly store objects, and the number of child nodes is fixed at four (corresponding to the four spatial quadrants). They hold references to the four child nodes and do not directly store individuals. During a query, they do not perform precise geometric intersection tests but recursively distribute the query to the four child nodes. When the total number of objects in all child nodes falls below the threshold triggering a merge, it degenerates into a leaf node.

[0040] It should be noted that leaf nodes are the actual locations where precise geometric tests are performed, serving as the final destination for queries; branch nodes are spatial routing layers that determine whether to enter a subtree through geometric pruning, thereby significantly reducing the total number of objects requiring precise testing. The two work together to reduce query complexity.

[0041] Step S16: When the node space type of the current node space is a leaf node space, traverse all space objects in the leaf node space, and determine the target space object through geometric intersection test to obtain the set of virtual individuals within the target query range.

[0042] In this embodiment, it is determined whether the target query range intersects with the current node space. If the determination result shows that the target query range intersects with the current node space and the node space type of the current node space is determined to be a leaf node space, that is, the target query range intersects with the current node space and the current node is a leaf node, then all objects in the leaf node are traversed, and the results that meet the conditions are filtered out through geometric intersection test.

[0043] Step S17: When the target query range intersects with the current node space and the node space type of the current node space is a branch node space, the four child node spaces under the branch node space are determined as the current node space, and the step of determining whether the target query range intersects with the current node space and its subsequent steps are re-executed.

[0044] In this embodiment, it is determined whether the target query range intersects with the current node space. If the determination result shows that the target query range intersects with the current node space and the node space type of the current node space is determined to be a branch node space, that is, the target query range intersects with the current node space and the current node is a branch node, then the same operation is recursively performed on its four child nodes. The four child node spaces are used as the current node space, and the intersection of the target query range and the current node space is re-determined. It can be understood that the query is implemented through a depth-first recursive traversal strategy. That is, when a query request is received, the query starts from the root node space of the quadtree index structure and performs a spatial query through geometric intersection testing and recursive pruning traversal to retrieve the set of virtual individuals within the target query range.

[0045] It should be noted that the geometric intersection test includes at least one of the following: the inclusion test between a point and a node region, the overlap test between an axis-aligned rectangle and a node region, and the distance test between a circle and the farthest point of a node region. This is to support efficient spatial queries and realize the intersection detection between the basic geometry and the node space.

[0046] Among them, point query (i.e., the containment test between a point and a node region) is the most basic operation. For example, if the query point is P(x,y) and the center of the node region is O(x,y), that is, the center point of the region governed by the node, the condition for determining whether the query point is within the node space is: ; in, Let x be the x-coordinate of the virtual individual to be queried in the two-dimensional simulation space. Let y be the ordinate of the virtual entity to be queried in the two-dimensional simulation space. Let x be the x-coordinate of the geometric center of the quadtree node space. Let be the ordinate of the geometric center of the quadtree node space. It is half the dimension of the node space in the X-axis direction (half the length of the node side). The x-axis represents half the size of the node space, which determines the spatial coverage of the node region.

[0047] For axis-aligned rectangle queries (i.e., overlap testing between axis-aligned rectangles and node regions), the method for detecting overlap between the rectangular query box and the node space is based on the two-dimensional projection overlap judgment method of the separating axis theorem. The necessary and sufficient condition for two rectangles to intersect is that their projections on both the X and Y axes overlap. Let the range of the query box be... The range of the quadtree node region is The minimum boundary of the node region is min B The maximum bound is max BThe intersection of the two means that, on any axis, the upper limit of one rectangular coordinate interval cannot be less than the lower limit of the other rectangular coordinate interval, that is: ; In other words, if the projection ranges of the two rectangles on both the X and Y axes overlap, they are considered to intersect; if they are separated on either axis, they are definitely not intersecting and should be pruned directly.

[0048] in, To find the minimum coordinate boundary of a bounding box (such as the field of view or event triggering area) along the X-axis, To query the maximum coordinate boundary of a bounding box (such as the field of view or event triggering area) along the X-axis, To find the minimum coordinate boundary of the rectangle in the Y-axis direction, To find the maximum coordinate boundary of the rectangle in the Y-axis direction, To check if the projection intervals in the X-axis direction overlap: The query box and the node area have spatial overlap in the horizontal direction. To determine if the projection intervals in the Y-axis direction overlap: There is spatial overlap between the query box and the node area in the vertical direction.

[0049] For circular queries (i.e., the distance test between a circle and the farthest point in the node region), used to detect whether a circular area with a specified radius centered at a certain point intersects with the node space, an approximate polygon method is used to discretize the circle into regular polygons for processing, or a more general GJK algorithm is used for accurate detection between convex bodies, or the nearest point distance method is used. For example, the nearest point distance method first finds the point N in the node region that is closest to the circle center C, and then determines whether the Euclidean distance between N and C is less than the circular query radius r. Specifically, the nearest point in the node space to the circle center C is first calculated, i.e.: ; Then, determine the Euclidean distance. Is it smaller than the circular query radius r?

[0050] in, The point within the node space that is Euclidean closest to the center C of the circle is the key intermediate quantity for determining whether the circle and the rectangle intersect. The query radius r of the circle corresponds to the perception radius of the virtual individual.

[0051] For example, agent A001 is located at (120, 130) with a radius r = 10m. Using a circular query, C = (120, 130) and r = 10, for the lower left quadrant node (center (-125, -125), size (250, 250)), Nx = clamp(120, -250, 0) = 0, Ny = clamp(130, -250, 0) = 0, distance = sqrt((0-120)² + (0-130)²) ≈ 177.2 >> 10, which indicates that they do not intersect. Therefore, a pruning operation is performed, skipping this quadrant and all its child nodes. For the node in the upper right quadrant (center (125, 125), size (250, 250)), Nx = clamp(120, 0, 250) = 120, Ny = clamp(130, 0, 250) = 130, and distance = sqrt(0² + 0²) = 0 < 10, it indicates an intersection, and the child node is recursively queried. It can be seen that this single pruning eliminates more than 75% of the search space (at least two of the three quadrants are directly skipped), ultimately performing exact matching only on the leaf nodes within the overlapping region, returning a set containing 12 neighboring individuals.

[0052] The GJK algorithm is used to calculate distances, but it does not directly calculate the distance between all points on two objects. Instead, it uses a geometric operation called Minkowski difference to transform the problem of determining whether two objects intersect into the problem of determining whether a newly generated virtual object contains the origin of the coordinate system, thereby greatly improving computational efficiency.

[0053] Furthermore, during the dynamic virtual crowd simulation, the real-time number of spatial objects within each node of the quadtree index structure is monitored, and node splitting or merging operations are automatically triggered based on the real-time number of spatial objects to optimize the quadtree index structure. In other words, the quadtree index structure is optimized based on the dynamic changes in the number of spatial objects within each node. This adaptive quadtree index structure can adaptively adjust the granularity of subdivision according to the object distribution density, performing fine-grained division in densely populated areas to improve query accuracy, and maintaining larger nodes in sparsely populated areas to reduce memory and management overhead.

[0054] It's important to note that the splitting operation is triggered when the number of spatial objects in a leaf node exceeds a preset splitting threshold, and the merging operation is triggered when the total number of spatial objects in all leaf nodes under the same branch node does not exceed a preset merging threshold. In other words, the number of spatial objects in each node of the quadtree index structure is monitored in real time. When the number of spatial objects in a leaf node exceeds the preset splitting threshold but has not reached the maximum recursion depth, node splitting is automatically triggered to achieve fine-grained partitioning of dense areas, improve the accuracy of proximity queries, and reduce the number of objects in a single accurate test. When the total number of spatial objects in all child nodes of a node is lower than a preset merging threshold, node merging is triggered to achieve coarse-grained management of sparse areas, reduce the number of nodes, and save memory and management overhead. This allows the quadtree index structure to adaptively optimize as the population distribution changes, maintaining coarse-grained management in sparse areas to save memory and fine-grained partitioning in dense areas to improve accuracy, thus achieving an optimal balance between computational efficiency and memory usage.

[0055] It should also be noted that spatial indexing technology transforms global searches into local queries through spatial data structures, thereby significantly reducing computational load and is key to achieving high-efficiency computing. Currently, mainstream high-efficiency indexing structures mainly include: uniform grids, quadtrees, KD-trees, and various binary tree structures. Among them, quadtrees, due to their naturalness in two-dimensional spatial partitioning, efficient dynamic updates, and good fit with regular scenarios, have become the preferred solution for supporting real-time simulation of ultra-large-scale populations through hierarchical region management via recursive uniform partitioning, achieving a significant balance between efficiency and flexibility. Furthermore, quadtrees have a more intuitive spatial partitioning logic and more stable query performance in two-dimensional space, avoiding structural imbalance problems caused by alternating dimensional partitioning.

[0056] As can be seen, in this embodiment of the invention, by constructing an efficient spatial index structure, namely a quadtree index structure, fast proximity query and interactive calculation for a large number of virtual individuals on a two-dimensional plane are realized. The continuous two-dimensional space is recursively divided into four equally sized quadrants to form a tree-like hierarchical quadtree index structure. Through geometric intersection testing and recursive pruning traversal, spatial query is performed starting from the root node space of the quadtree index structure. This transforms the traditional O(N²) complexity proximity search based on global traversal into an O(log N) efficient retrieval that only needs to access locally relevant nodes. This provides a fundamental performance guarantee for real-time collision detection, field of view calculation, and interactive perception in large-scale crowd simulation. Furthermore, in scenarios with extremely high real-time requirements, such as real-time simulation of large-scale virtual crowds, it directly solves the computational bottleneck of proximity search between agents, enabling stable support for real-time interaction of larger-scale virtual crowds while maintaining the complexity of individual behavior.

[0057] For example, see Figure 2As shown, based on the two-dimensional boundary range of the current simulation scenario, the root node space is initialized, and a quadtree index is constructed based on the root node space. When a query request is received, starting from the root node space of the quadtree index structure, the root node space is used as the current node space. When the target query range in the query request intersects with the current node space and the node space type of the current node space is a leaf node space, all spatial objects in the leaf node space are traversed. Intersection tests are performed by point query, axis-aligned bounding box query, or circular query to filter out query results that meet the conditions. That is, the precise geometric intersection test of the leaf nodes is performed. Precise judgment is only performed on a small number of candidate objects to avoid calculating each of the N objects one by one. When the target query range intersects with the current node space and the node space type of the current node space is a branch node, the same operation is recursively performed on its four child nodes. All query results that meet the conditions are collected to obtain the corresponding result set. When collecting query results, a hash set can be used to automatically remove duplicates to ensure that cross-node boundary objects are not returned repeatedly.

[0058] It should be noted that the spatial indexing technology solution for ultra-large-scale crowd interaction computation in digital twin scenarios provided in this application is not a replacement for behavioral models such as social forces, cellular automata, or gas dynamics. Rather, it provides general and efficient underlying support for spatial queries. The calculation of near-distance repulsion force in social force models, the acquisition of neighbor states in cellular automata, and the estimation of local density in gas dynamics models can all be quickly obtained through the adaptive quadtree index of this application. Furthermore, through the dynamic node splitting and merging mechanism of the adaptive quadtree index structure, the memory efficiency and computational stability in non-uniform and dynamically changing crowd distribution scenarios are significantly improved. This allows the computational bottleneck of proximity search between agents to be directly solved in real-world applications with extremely high real-time requirements, such as large-scale crowd simulation. This enables the simulation system to stably support real-time interaction of larger-scale virtual crowds while maintaining the complexity of individual behaviors.

[0059] For example, in a real-world application scenario of a large-scale digital twin rail transit hub, such as a train station waiting hall, the real-time interactive computation of 20,000 virtual pedestrians (intelligent agents) in this scenario was selected as the experimental subject. The specific process of constructing and querying the spatial index is as follows: Step 1: Simulation Environment Initialization and Root Node Establishment: This involves determining the simulation boundary based on the actual physical dimensions of the waiting hall. The waiting hall is set as a square area with center coordinates O(0,0) and a total size of 500m × 500m. For example, the center point origin=(0,0), spatial size size=(500,500), maximum depth maxDepth=8, and the maximum object threshold for each node maxLeafsPerNode=20. Then, the root node RootNode is created, with its initial spatial range Volume having a minimum boundary minBounds of (-250,-250) and a maximum boundary maxBounds of (250,250).

[0060] Step Two: Virtual Individual Insertion and Adaptive Spatial Segmentation: At the beginning of the simulation, 20,000 virtual individuals are inserted one by one into the quadtree. Taking an agent located at coordinates P(120,130) (ID A001) as an example: (1) Perform insertion determination: that is, call the Point.TestIntersection interface. Since 120∈[-250,250] and 130∈[-250,250], it is determined that the point belongs to the coverage area of ​​the root node.

[0061] (2) Trigger split: When the number of people in the northeast corner of the waiting hall (such as near the ticket gate) exceeds the threshold of 20, the VolumeSplitter.SplitUniform split logic is triggered.

[0062] (3) Coordinate calculation: that is, calculate the segmentation size S_split=500 / 2=250, offset delta=250 / 2=125, generate the center of four child nodes, among which the center of the upper right child node (first quadrant) is (125,125).

[0063] (4) Recursive allocation: that is, agent A001 is precisely allocated to a child node with a center point of (125,125) according to its coordinates.

[0064] Step 3: Neighborhood Obstacle Avoidance Query and Geometric Pruning: When agent A001 needs to perform dynamic obstacle avoidance calculations, it needs to obtain all its neighboring individuals within a 10-meter radius. Details are as follows: (1) Query construction: that is, instantiate a Circle object, set the center origin=(120,130) and the radius adius=10.

[0065] (2) Intersection test: that is, calling Circle.TestIntersection(volume) to recursively traverse the quadtree branches.

[0066] (3) Pruning efficiency: For a node in the lower left quadrant centered at (-125, -125), calculate the shortest distance between its boundary and the center of the query circle. If the calculated shortest distance is much greater than 10 meters, return false. Directly skip this quadrant and all its subordinate branches, instantly reducing the search range by more than 75%.

[0067] (4) Output: The final result is to perform exact matching only on the leaf nodes in the overlapping area and return a set containing 12 neighboring individuals.

[0068] To verify the superiority of the technical solution of the present invention, the solution of this embodiment (based on dynamic adaptive quadtree) and the traditional global traversal solution were compared in the same hardware environment, such as CPU 3.5GHz and 32GB RAM, as shown in Table 1.

[0069] Table 1

[0070] As shown in Table 1, with the increase of the number of simulation participants N, the computation time of the traditional scheme increases exponentially (O(N)). 2 The solution of this invention, through spatial adaptive partitioning and recursive pruning, controls the query time to the millisecond level (O(NlogN)), which fully meets the real-time interaction requirements in digital twin scenarios.

[0071] In one embodiment, such as Figure 3 As shown, based on the above-mentioned spatial indexing method for ultra-large-scale crowd interaction computation in digital twin scenarios, this invention also provides a spatial indexing system for ultra-large-scale crowd interaction computation in digital twin scenarios, comprising: The root node initialization module 11 is used to initialize the root node space according to the two-dimensional boundary of the current simulation scene; the virtual individuals in the current simulation scene are used as spatial objects in the root node space. The quadtree construction module 12 is used to perform recursive space partitioning operations based on the root node space to construct a quadtree index structure. The intersection judgment module 13 is used to respond to the received query request, starting from the root node space of the quadtree index structure, taking the root node space as the current node space, and judging whether the target query range intersects with the current node space. The geometric pruning module 14 is used to perform geometric pruning operations when the target query range does not intersect with the current node space. The type determination module 15 is used to determine the node space type of the current node space when the target query range intersects with the current node space. The geometric intersection test module 16 is used to traverse all spatial objects in the leaf node space when the node space type of the current node space is a leaf node space, and determine the target spatial object through geometric intersection test to obtain the set of virtual individuals within the target query range; The recursive pruning module 17 is used to determine the four child node spaces under the branch node space as the current node space when the node space type of the current node space is a branch node space, and re-execute the step of determining whether the target query range intersects with the current node space and its subsequent steps.

[0072] In some specific embodiments, the quadtree construction module 12 may specifically include: The first segmentation unit is used to evenly divide the root node space into four sub-quadrants and use each sub-quadrant as the current parent node space. The first object count unit is used to determine the number of space objects in the current parent node's space; The first judgment unit is used to determine whether the number of space objects in the current parent node space exceeds a preset threshold. The first re-segmentation unit is used to further divide the current parent node space into four child node spaces if the number of space objects in the current parent node space exceeds the preset threshold. The first recursive execution unit is used to take each of the child node spaces as the current parent node space and re-execute the step of determining the number of space objects in the current parent node space and its subsequent steps. The first segmentation stopping unit is used to stop segmentation if the number of space objects in the current parent node space does not exceed the preset threshold, and to determine the child node space as the leaf node space.

[0073] In some specific embodiments, the quadtree construction module 12 may specifically include: The first segmentation unit is used to evenly divide the root node space into four sub-quadrants and use each sub-quadrant as the current parent node space. The recursion depth determination unit is used to determine the current recursion depth; The second judgment unit is used to determine whether the current recursion depth has reached the maximum recursion depth; The second re-segmentation unit is used to further divide the current parent node space into four child node spaces evenly if the current recursion depth has not reached the maximum recursion depth. The second recursive execution unit is used to take each of the child node spaces as the current parent node space and re-execute the steps of determining the current recursion depth and judging whether the current recursion depth has reached the maximum recursion depth. The second segmentation stopping unit is used to stop segmentation when the current recursion depth reaches the maximum recursion depth, and to determine the child node space as the leaf node space.

[0074] In some specific embodiments, the spatial indexing system for ultra-large-scale crowd interaction computing in digital twin scenarios may specifically include: The quadtree optimization module is used to monitor the number of spatial objects in each node space of the quadtree index structure in real time during the dynamic virtual crowd simulation process, and automatically trigger node splitting or merging operations based on the number of spatial objects in real time to optimize the quadtree index structure.

[0075] In some specific embodiments, the splitting operation is triggered when the number of spatial objects in the leaf node space exceeds a preset splitting threshold, and the merging operation is triggered when the total number of spatial objects in all leaf nodes under the same branch node space does not exceed a preset merging threshold.

[0076] In some specific embodiments, the geometric intersection test includes at least one of the following: a point-node region inclusion test, an axis-aligned rectangle-node region overlap test, and a circle-node region farthest point distance test.

[0077] In some specific embodiments, the segmentation method used in the recursive spatial segmentation operation is either uniform segmentation or centroid-based segmentation.

[0078] Furthermore, it is worth noting that the working process of the spatial indexing system for ultra-large-scale crowd interaction computing in digital twin scenarios provided in this embodiment is the same as the working process of the spatial indexing method for ultra-large-scale crowd interaction computing in digital twin scenarios described above. Therefore, it will not be repeated here. For details, please refer to the working process of the spatial indexing method for ultra-large-scale crowd interaction computing in digital twin scenarios described above.

[0079] Figure 4 A schematic diagram of the structure of a terminal provided in an embodiment of this application. The terminal may include: The memory 501, the processor 502, and the computer program stored on the memory 501 and capable of running on the processor 502.

[0080] When the processor 502 executes the program, it implements the spatial indexing method for large-scale crowd interaction computing in digital twin scenarios provided in the above embodiments.

[0081] Furthermore, the terminal also includes: Communication interface 503 is used for communication between memory 501 and processor 502.

[0082] The memory 501 is used to store computer programs that can run on the processor 502.

[0083] Memory 501 may include high-speed RAM memory, and may also include non-volatile memory, such as at least one disk storage device.

[0084] If the memory 501, processor 502, and communication interface 503 are implemented independently, they can be interconnected via a bus to communicate with each other. The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of representation, only one line is used in the diagram, but this does not imply that there is only one bus or one type of bus.

[0085] Optionally, in a specific implementation, if the memory 501, processor 502, and communication interface 503 are integrated on a single chip, then the memory 501, processor 502, and communication interface 503 can communicate with each other through an internal interface.

[0086] Processor 502 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application.

[0087] This embodiment also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the spatial indexing method described above for large-scale crowd interaction computing in digital twin scenarios.

[0088] Other embodiments of the invention will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This invention is intended to cover any variations, uses, or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein.

[0089] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.

[0090] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus or device (such as a computer-based system, a processor-included system or other system that can read and execute instructions from and from an instruction execution system, apparatus or device).

[0091] It should be understood that various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. If implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.

[0092] It should be understood that the application of the present invention is not limited to the examples above. Those skilled in the art can make improvements or modifications based on the above description, and all such improvements and modifications should fall within the protection scope of the appended claims.

Claims

1. A spatial indexing method for ultra-large-scale crowd interaction computation in digital twin scenarios, characterized in that, The method includes: The root node space is initialized based on the two-dimensional boundary of the current simulation scene; the virtual individuals within the current simulation scene are used as spatial objects in the root node space. Recursive space partitioning operations are performed based on the root node space to construct a quadtree index structure; In response to the received query request, starting from the root node space of the quadtree index structure, the root node space is taken as the current node space, and it is determined whether the target query range intersects with the current node space. If the target query range does not intersect with the current node space, then perform a geometric pruning operation; If the target query range intersects with the current node space, then the node space type of the current node space is determined. When the node space type in the current node space is a leaf node space, all space objects in the leaf node space are traversed, and the target space object is determined through geometric intersection test to obtain the set of virtual individuals within the target query range; When the node space type in the current node space is a branch node space, the four child node spaces under the branch node space are determined as the current node space, and the step of determining whether the target query range intersects with the current node space and its subsequent steps are re-executed.

2. The spatial indexing method for ultra-large-scale crowd interaction computing in digital twin scenarios according to claim 1, characterized in that, The recursive space partitioning operation based on the root node space to construct a quadtree index structure includes: The root node space is evenly divided into four sub-quadrants, and each sub-quadrant is used as the current parent node space. Determine the number of space objects in the current parent node's space; Determine whether the number of space objects in the current parent node space exceeds a preset threshold; If the number of space objects in the current parent node space exceeds the preset threshold, the current parent node space will be further divided into four child node spaces evenly. Each of the child node spaces is taken as the current parent node space, and the step of determining the number of space objects in the current parent node space and its subsequent steps are executed again. If the number of space objects in the current parent node space does not exceed the preset threshold, then the segmentation stops, and the child node space is determined as the leaf node space.

3. The spatial indexing method for ultra-large-scale crowd interaction computing in digital twin scenarios according to claim 1, characterized in that, The recursive space partitioning operation based on the root node space to construct a quadtree index structure includes: The root node space is evenly divided into four sub-quadrants, and each sub-quadrant is used as the current parent node space. Determine the current recursion depth and check if the current recursion depth has reached the maximum recursion depth; If the current recursion depth has not reached the maximum recursion depth, then the current parent node space will be further divided into four child node spaces evenly. Take each of the child node spaces as the current parent node space, and re-execute the steps of determining the current recursion depth and judging whether the current recursion depth has reached the maximum recursion depth; If the current recursion depth reaches the maximum recursion depth, then the segmentation stops, and the child node space is determined as the leaf node space.

4. The spatial indexing method for ultra-large-scale crowd interaction computing in digital twin scenarios according to claim 1, characterized in that, Also includes: During the dynamic virtual crowd simulation, the number of spatial objects in each node space of the quadtree index structure is monitored in real time, and the node splitting or merging operation is automatically triggered based on the number of spatial objects in real time to optimize the quadtree index structure.

5. The spatial indexing method for ultra-large-scale crowd interaction computation in digital twin scenarios according to claim 4, characterized in that, The splitting operation is triggered when the number of spatial objects in the leaf node space exceeds a preset splitting threshold, and the merging operation is triggered when the total number of spatial objects in all leaf nodes under the same branch node space does not exceed a preset merging threshold.

6. The spatial indexing method for ultra-large-scale crowd interaction computing in digital twin scenarios according to claim 1, characterized in that, The geometric intersection test includes at least one of the following: point and node region inclusion test, axis-aligned rectangle and node region overlap test, and circle and node region farthest point distance test.

7. The spatial indexing method for ultra-large-scale crowd interaction computing in digital twin scenarios according to any one of claims 1 to 6, characterized in that, The segmentation method used in the recursive spatial segmentation operation is either uniform segmentation or centroid-based segmentation.

8. A spatial indexing system for ultra-large-scale crowd interaction computing in digital twin scenarios, characterized in that, The system includes: The root node initialization module is used to initialize the root node space according to the two-dimensional boundary of the current simulation scene; the virtual individuals in the current simulation scene are used as spatial objects in the root node space. The quadtree construction module is used to perform recursive space partitioning operations based on the root node space to construct a quadtree index structure. The intersection determination module is used to respond to the received query request, starting from the root node space of the quadtree index structure, taking the root node space as the current node space, and determining whether the target query range intersects with the current node space; The geometric pruning module is used to perform geometric pruning operations when the target query range does not intersect with the current node space. The type determination module is used to determine the node space type of the current node space when the target query range intersects with the current node space. The geometric intersection test module is used to traverse all spatial objects in the leaf node space when the node space type of the current node space is a leaf node space, and determine the target spatial object through geometric intersection test to obtain the set of virtual individuals within the target query range; The recursive pruning module is used to determine the four child node spaces under the branch node space as the current node space when the node space type of the current node space is a branch node space, and re-execute the step of determining whether the target query range intersects with the current node space and its subsequent steps.

9. A terminal, characterized in that, include: The system includes a memory, a processor, and a spatial indexing program for large-scale crowd interaction computation in a digital twin scenario, which is stored in the memory and can run on the processor. When the spatial indexing program for large-scale crowd interaction computation in a digital twin scenario is executed by the processor, it implements the steps of the spatial indexing method for large-scale crowd interaction computation in a digital twin scenario as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that can be executed to implement the steps of the spatial indexing method for large-scale crowd interaction computation in a digital twin scenario as described in any one of claims 1 to 7.