A state encoding method and device based on hypercube space
By mapping state vectors to a hypercube space and using integer indexes for storage and retrieval, the problem of high storage and computation costs in high-dimensional state representation is solved, achieving efficient state encoding and retrieval, and supporting dynamic dimension adjustment.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- 深圳市积微科技有限公司
- Filing Date
- 2026-03-23
- Publication Date
- 2026-06-19
Smart Images

Figure CN122240619A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data structure technology, and in particular to a state coding method and apparatus based on hypercube space. Background Technology
[0002] In the field of complex system modeling, the state representation problem is a fundamental problem.
[0003] Traditional continuous state representations (such as real number vectors) suffer from high storage and computation costs in high-dimensional spaces. For example, a floating-point vector of dimension N = 100 requires 400 bytes of storage space (4 bytes per dimension), and its distance calculation (such as Euclidean distance) has a complexity of O(N).
[0004] Therefore, a new encoding method is urgently needed to effectively reduce storage and computational overhead. Summary of the Invention In view of this, embodiments of the present invention provide a state coding method and apparatus based on hypercube space, which can effectively reduce storage and computational overhead.
[0005] According to one aspect of the present invention, a state coding method based on a hypercube space is provided, the method comprising: Obtain the first state vector to be encoded; The first state vector is binarized based on a preset mapping rule to determine the binary vector corresponding to the first state vector. Map the binary vector corresponding to the first state vector to the hypercube space, and determine the first integer index of the first state vector in the hypercube space; Store or query the first integer index as the first state vector; Wherein, storing or querying the first integer index as the first state vector includes: Whenever a distance query request is received, the first integer index and the second integer index to be compared are obtained from the distance query request, and the second integer index corresponds to the second state vector; XOR the first integer index and the second integer index to determine the bit comparison result; Execute a bit-1 counting instruction on the bit comparison result to obtain a bit-1 counting result; The bit-1 count result is used as the Hamming distance between the first state vector and the second state vector, and the Hamming distance is returned.
[0006] According to another aspect of the present invention, a state coding apparatus based on a hypercube space is provided, the apparatus comprising: The acquisition unit is used to acquire the first state vector to be encoded. The mapping unit is used to perform binary mapping on the first state vector based on a preset mapping rule to determine the binary vector corresponding to the first state vector; and to map the binary vector corresponding to the first state vector to a hypercube space to determine the first integer index of the first state vector in the hypercube space. A storage unit is used to store or query the first integer index as the first state vector; The storage unit includes a distance query subunit, which is used for: Whenever a distance query request is received, the first integer index and the second integer index to be compared are obtained from the distance query request, and the second integer index corresponds to the second state vector; XOR the first integer index and the second integer index to determine the bit comparison result; Execute a bit-1 counting instruction on the bit comparison result to obtain a bit-1 counting result; The bit-1 count result is used as the Hamming distance between the first state vector and the second state vector, and the Hamming distance is returned.
[0007] According to another aspect of the present invention, an electronic device is provided, comprising: Processor; and Stored program memory, The program includes instructions that, when executed by the processor, cause the processor to perform the state encoding method based on the hypercube space.
[0008] According to another aspect of the present invention, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause a computer to execute the aforementioned state coding method based on hypercube space.
[0009] In this invention, when encoding the first state vector, it can be converted into a binary vector and mapped to a hypercube space. The first integer index in the hypercube space is then used to replace the first state vector for storage or retrieval, achieving a mapping compression from high-dimensional binary states to compact integers. This allows an N-dimensional state vector to be stored using only N bits. This not only reduces storage overhead but also preserves the topological relationships between states. Attached Figure Description
[0010] Further details, features, and advantages of the invention are disclosed in the following description of exemplary embodiments in conjunction with the accompanying drawings, in which: Figure 1A flowchart of a state coding method based on a hypercube space according to an exemplary embodiment of the present invention is shown; Figure 2 A schematic block diagram of a state coding device based on a hypercube space according to an exemplary embodiment of the present invention is shown. Figure 3 A structural block diagram of an exemplary electronic device that can be used to implement embodiments of the present invention is shown. Detailed Implementation
[0011] Embodiments of the present invention will now be described in more detail with reference to the accompanying drawings. While some embodiments of the invention are shown in the drawings, it should be understood that the invention can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the invention. It should be understood that the accompanying drawings and embodiments are for illustrative purposes only and are not intended to limit the scope of protection of the invention.
[0012] It should be understood that the various steps described in the method embodiments of the present invention may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present invention is not limited in this respect.
[0013] The term "comprising" and its variations as used herein are open-ended, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Definitions of other terms will be given in the following description. It should be noted that the concepts of "first", "second", etc., mentioned in this invention are used only to distinguish different devices, modules, or units, and are not intended to limit the order of functions performed by these devices, modules, or units or their interdependencies.
[0014] It should be noted that the terms "a" and "a plurality of" used in this invention are illustrative rather than restrictive. Those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".
[0015] The names of the messages or information exchanged between the multiple devices in the embodiments of the present invention are for illustrative purposes only and are not intended to limit the scope of these messages or information.
[0016] This invention provides a state coding method based on a hypercube space, which can be implemented by a terminal, a server, and / or other devices with processing capabilities. The method provided in this embodiment can be implemented by any of the aforementioned devices, or by multiple devices working together; this invention does not limit this.
[0017] To facilitate understanding of the technical solution of this invention, the following will use a mental health intervention system as an example to illustrate the technical problems that this invention needs to solve in practical scenarios. Of course, this invention can also be applied to other specific scenarios, such as data storage and query optimization in graph databases, state consistency maintenance in distributed systems, and user behavior modeling in intelligent recommendation engines. This invention does not limit the specific application scenarios.
[0018] In a mental health intervention system, a psychological assessment scale can be used to score an individual's six-dimensional mental state, including sleep quality, stress level, social support, emotional state, cognitive function, and physical activity. Each dimension can be scored, and the scores are displayed in the system. 1 or +1 represents a negative or positive state, forming a state vector, such as The vector (-1,-1,+1,-1,+1,-1) represents an individual's current state of poor sleep quality, high stress levels, insufficient social support, negative emotional state, and good cognitive function but lack of physical activity. Furthermore, this first state vector can be used for psychological health navigation, recommending personalized intervention pathways through path planning, such as prioritizing improvements in sleep quality and stress levels to enhance overall psychological resilience.
[0019] However, when storing the above state vector, the original state vector is stored directly. The 1 / +1 form increases the complexity of computation and comparison. For example, to find all neighbors at a given state distance, it is necessary to traverse all states, which has a complexity of O(2^N), where N is the total number of state dimensions.
[0020] Based on this, the technical problem to be solved by the present invention can be summarized as follows: 1. How to represent N-dimensional binary states in the most compact way; 2. How to encode the topology in the state representation; 3. How to efficiently calculate the distance between states; 4. How to quickly query all neighbors within a given distance; 5. How to support dynamic dimension expansion and contraction to adapt to the state dimension change requirements in different application scenarios.
[0021] To address the aforementioned technical problems, this invention proposes an encoding method based on hypercube topology, which maps N-dimensional binary states to the vertices of an N-dimensional hypercube and utilizes bit operations and Hamming distance to achieve efficient storage and retrieval.
[0022] The following will refer to Figure 1 A flowchart of a state encoding method based on a hypercube space is shown, and the method is introduced. The method includes the following steps 101-104.
[0023] Step 101: Obtain the first state vector to be encoded.
[0024] In one possible implementation, in fields such as state-space modeling, graph databases, and distributed systems, it is often necessary to efficiently encode, store, and transmit the states of various nodes in the system. The first state vector refers to any state vector in the system, and the value range of each dimension in the state vector can be arbitrary.
[0025] Whenever it is necessary to encode any state vector, that state vector can be used as the first state vector to be encoded as input.
[0026] Step 102: Binarize the first state vector based on the preset mapping rules to determine the binary vector corresponding to the first state vector.
[0027] In one possible implementation, different mapping rules can be set for different types of first state vectors to achieve binarization mapping. For example, for continuous value type state vectors, the mapping rule can be based on a preset threshold and perform sign function processing, mapping components greater than or equal to the threshold to 1 and components less than the threshold to 0; for discrete multi-value type state vectors, the conversion can be performed according to the correspondence table between state category and binary code.
[0028] Specifically, for the binarized first state vector, the values of each dimension are already... A value of 1 or +1 can be directly converted into a binary representation of 0 or 1 using a linear mapping function. Specifically, the first state vector can be represented as follows:
[0029] in, Represents the first state vector, each dimension This represents the binary state of this dimension.
[0030] The linear mapping function can be as follows:
[0031] The resulting binary vector is as follows:
[0032] in, This represents the binary vector corresponding to the first state vector, with each dimension... This represents the corresponding binary state value.
[0033] Step 103: Map the binary vector corresponding to the first state vector to the hypercube space and determine the first integer index of the first state vector in the hypercube space.
[0034] In one possible implementation, the vertices of the N-dimensional hypercube space correspond one-to-one with an N-bit binary vector, with each vertex corresponding to an integer index.
[0035] Specifically, little-endian integer encoding can be used, where the i-th dimension corresponds to the (i-1)-th bit of the binary representation. The binary vector can be converted into its corresponding integer index using the following mapping method:
[0036] in, Represents the first state vector The first integer index corresponding to the hypercube space.
[0037] For example, state vector The binary vector b = (0, 0, 1, 0, 1, 0) corresponding to (-1, -1, +1, -1, +1, -1) is mapped to obtain the integer index index. ) = 1 × 2² + 1 × 2 4 =4+16=20. This index uniquely identifies a vertex in the hypercube space, reflects the positional characteristics of the state vector in the high-dimensional space, and provides a quantization basis for subsequent state addressing, similarity retrieval, or pattern storage.
[0038] The integer encoding and subsequent state decoding processes described above support N≤64 (using 64-bit integers) or N>64 (using a large integer library).
[0039] The hypercube space has the following topological properties: 1. Vertex degree In the hypercube space, each vertex has a degree of N, meaning each vertex is connected to exactly N one-hop neighbors (1-neighbors), and each edge corresponds to a state flip in one dimension. This structural property ensures that the binary vectors corresponding to any two adjacent vertices differ by only one bit.
[0040] 2. Diameter The hypercube space has a diameter of N, meaning the maximum distance between any two vertices is N (i.e., all dimensions of the two state vectors are different). This indicates that the maximum number of bits required to flip from one state vector to the other, the furthest state vector, is N. This topology provides geometric support for efficient traversal of the state space and enables state similarity measures based on Hamming distance.
[0041] 3. Average distance The average Hamming distance between any two vertices in a hypercube space is N / 2, indicating that two randomly selected state vectors are statistically about half different in dimension. This property gives hypercube space good discriminative power in information encoding and pattern recognition, maintaining state independence while supporting proximity-based clustering analysis, providing a compact and structured geometric framework for the organization and retrieval of high-dimensional binary data.
[0042] 4. Connectivity A hypercube is a strongly connected graph, meaning there is at least one path between any two vertices, ensuring that any two states in the state space can be transformed into each other through a finite number of flips. This property guarantees the traversal completeness of the search algorithm on the hypercube, supports global state reachability and dynamic pathfinding optimization, and forms the topological foundation for efficient pattern retrieval and associative memory.
[0043] 5. Symmetry A hypercube is a vertex-symmetric graph where all vertices have the same local structure, indicating that any vertex can be used as the origin for an equivalent description. This high degree of symmetry ensures the topological equivalence of positions in the state space, eliminates boundary effects, makes the system behavior independent of the initial state selection, and enhances its generalization ability and robustness in high-dimensional spaces.
[0044] Step 104: Store or query the first integer index as the first state vector.
[0045] In one possible implementation, the first integer index can be stored in the storage space instead of the original state vector. This achieves a mapping compression from high-dimensional binary states to compact integers, requiring only N bits to store an N-dimensional state vector. This not only reduces storage overhead but also preserves the topological relationships between states.
[0046] Furthermore, queries can be performed directly using the first integer index, allowing for the lookup of distances between states and neighboring state vectors at a given distance without decoding.
[0047] If the first state vector is a binary state, the original state vector can be decoded as follows: Whenever a status query request is received, retrieve the first integer index from the status query request; Convert the first integer index into a binary vector; The binary vector is inversely mapped based on a preset mapping rule to determine the first state vector queried by the state query request.
[0048] In one possible implementation, whenever a status query request for any integer index is triggered, the integer index can be converted into its corresponding binary representation, as shown in the following conversion formula:
[0049] Furthermore, the original N-dimensional binary state vector can be recovered by performing an inverse mapping using the preset mapping rules in step 102. =2* -1, thus completing the lossless reconstruction from integer index to the original state vector.
[0050] The distance between states can be calculated as follows: Whenever a distance query request is received, the first integer index and the second integer index to be compared are obtained from the distance query request, and the second integer index corresponds to the second state vector; XOR the first integer index and the second integer index to determine the bit comparison result; The bit comparison result is used to execute a bit-1 counting instruction to obtain the bit-1 count result; Use the bit-1 count result as the Hamming distance between the first and second state vectors, and return the Hamming distance.
[0051] The bit-counting instruction can be accelerated by hardware, including the POPCNT instruction for x86 architecture, the CNT instruction for ARM architecture, or the CPOP instruction for RISC-V architecture. With hardware acceleration, the complexity of a single instruction is O(1), enabling efficient calculation of Hamming distance and significantly improving the computational efficiency of similarity retrieval and clustering analysis in large-scale state spaces.
[0052] In one possible implementation, a distance query request for the two state vectors can be triggered whenever it is necessary to compare the Hamming distance between two state vectors or to compare their similarity. The distance query request can carry integer indices for the two state vectors, namely a first integer index and a second integer index, corresponding to the first state vector and the second state vector, respectively.
[0053] When the system receives the distance query request, it can obtain the first integer index and the second integer index, perform a bitwise XOR operation, and if the binary representations corresponding to the two integer indices have different values in the same bit, the bit in the bit comparison result is 1, otherwise it is 0.
[0054] The bit comparison result is then processed by a bit-counting instruction, which counts the number of bits with a value of 1. This count represents the Hamming distance between the two state vectors. This Hamming distance is then returned to the requesting party as the distance query result.
[0055] As a concrete example, suppose the first integer index of the first state vector is 20 (corresponding to binary vector 001010), and the second integer index of the second state vector is 21 (corresponding to binary vector 001011). Performing an XOR operation on them yields the binary result 000001, where only the least significant bit is 1, and the remaining bits are 0. Executing a bit-1 count using the POPCNT or CNT instruction results in a Hamming distance of 1. This indicates that the two state vectors differ only in their least significant bit, meaning they differ in only one dimension of the N-dimensional space, reflecting a high degree of similarity between the two state vectors.
[0056] For a neighbor query with a given distance, the corresponding processing can be as follows: Whenever a neighbor query request is received, the first integer index to be queried and the neighbor distance are obtained from the neighbor query request. The neighbor distance is used to represent the number of dimensions that the parameter values of the neighbor state vector are different from those of the first state vector. Based on the neighbor distance, multiple mask dimension vectors are generated. The mask dimension vectors are used to represent the dimensions in which the parameter values of the neighbor state vectors and the first state vectors are different. Construct the corresponding bitmask for each mask dimension vector; Based on the first integer index and the bitmask corresponding to each mask dimension vector, generate neighbor indices for multiple neighbor state vectors and return multiple neighbor indices.
[0057] In one possible implementation, d-neighbors refer to the set of state vectors reachable from the current state vector x by exactly flipping d dimensions. ,in, Let x be any d-neighbor state vector, where d is the sum of the states of state vector x and its neighbor state vectors. The Hamming distance between them. Whenever it is necessary to query the d-neighbors of any state vector, a corresponding neighbor query request can be triggered. This neighbor query request can carry the integer index idx of the state vector and the set neighbor distance d.
[0058] When the system receives the neighbor query request, it can obtain the integer index idx and the neighbor distance d. Then, it can construct all possible combinations of dimensions to be masked (i.e., mask dimension vectors, composed of the number of bits i in the mask dimension). These dimension combinations contain all possible combinations of selecting d dimensions from N dimensions, each corresponding to a specific flipping pattern. For example, for a 3-dimensional state vector x, when d=1, there are three possible flipping patterns, corresponding to flipping the 0th, 1st, or 2nd bit respectively, i.e., the mask dimension vectors are (0), (1), and (2); when d=2, there are three possible combinations of flipping patterns, corresponding to simultaneously flipping the 0th and 1st bits, the 0th and 2nd bits, and the 1st and 2nd bits respectively, i.e., the mask dimension vectors are (0,1), (0,2), and (1,2).
[0059] Subsequently, a corresponding bitmask is generated for each mask dimension vector. Specifically, the parameters in the mask dimension vector include the number of bits i in the mask dimension, and the bitmask is calculated using Σ(2^i). For example, for the mask dimension vector (0), its corresponding bitmask is 2^0 = 1; for the mask dimension vector (0,1), its corresponding bitmask is 2^0 + 2^1 = 3.
[0060] Furthermore, based on the first integer index and the bitmask corresponding to each mask dimension vector, neighbor indices of multiple neighbor state vectors can be generated. Specifically, for each mask dimension vector, the first integer index and the bitmask can be XORed to obtain the neighbor index of the neighbor state vector corresponding to the mask dimension vector. For example, assuming the integer index of the 3-dimensional state vector x is 5 (101 in binary), when d=1, the three mask dimension vectors are (0), (1), and (2), and the corresponding bitmasks are 1, 2, and 4 respectively. XORing the integer index with each bitmask yields three neighbor indices of 4, 7, and 1, corresponding to binary-reversed state vectors of 100, 111, and 001.
[0061] The obtained set of neighbor indexes is used as the result of the neighbor query and returned to the requester.
[0062] The above method efficiently generates a d-neighbor index set by XORing an integer index with a bitmask, where the number of neighbors is... For example, when N=6, the number of 1-hop neighbors is The number of 2-hop neighbors is The number of 3-hop neighbors is Therefore, this embodiment can quickly locate any d-hop neighbor by bitwise operations when querying the neighbor state vector without traversing all state combinations, achieving a complexity of O(n log n). The efficiency is directly proportional to the number of neighbors, significantly outperforming the exponential complexity of traditional traversal methods.
[0063] Furthermore, the state encoding method provided by this invention can also support dynamic state adjustment, including dimensional expansion and compression. The corresponding processing may include: Whenever a dimensionality upgrade request is triggered, determine the binary bit value corresponding to the state parameter of the new dimension; if the binary bit value is 0, set the dimensionality upgrade integer index of the first state vector to the first integer index; if the binary bit value is 1, set the dimensionality upgrade integer index of the first state vector to the first integer index and 2. N The sum of these, where N is the total number of original dimensions of the hypercube space.
[0064] Integer index idx of the original N-dimensional state vector x N The integer index idx after expansion to N+1 dimensions N+1 It can be represented as follows:
[0065] in, That is, the state parameters of the new dimension. The corresponding binary bit value is 0. The corresponding binary bit value is 1.
[0066] Whenever a dimensionality reduction request is triggered, the number of bits j to be deleted in the dimension is determined, and the integer index of the first state vector for dimensionality reduction is determined using the following formula:
[0067] in, Integer index representing the dimension reduction of the first state vector. Represents the first integer index of the first state vector.
[0068] As can be seen from the above embodiments, dimensionality increase and decrease operations can still be implemented based on integer indices, without the need for additional storage of state mapping relationships, which greatly improves the efficiency of state dimension adjustment in high-dimensional space. Especially in large-scale dynamic systems, where the need for real-time reconstruction of the state space is frequent, this method avoids the high overhead of traditional matrix transformations or table lookup methods.
[0069] This embodiment can achieve the following beneficial effects: (1) When encoding the first state vector, it can be converted into a binary vector and mapped to a hypercube space. The first integer index in the hypercube space is used to replace the first state vector for storage or retrieval, realizing the mapping compression from high-dimensional binary states to compact integers, so that the N-dimensional state vector only needs N bits for storage. This not only reduces storage overhead, but also preserves the topological relationship between states.
[0070] (2) Perform XOR operation based on integer index and quickly calculate Hamming distance between any two states by bit-1 counting. The bit-1 counting instruction can be accelerated by hardware. With hardware acceleration, the complexity of a single instruction is O(1), which can realize efficient calculation of Hamming distance and significantly improve the computational efficiency of similarity retrieval and clustering analysis in large-scale state spaces.
[0071] (3) When performing a neighbor lookup, the d-neighbor index set is efficiently generated by XORing the integer index with the bitmask. It eliminates the need to traverse all possible state combinations and can quickly locate any d-hop neighbor using only bitwise operations, with a complexity of O(n). The complexity is directly proportional to the number of neighbors, which is significantly better than the exponential complexity of traditional traversal methods.
[0072] (4) It can support dynamic dimension adjustment, and realize dimension increase and dimension decrease operations based on integer index. No additional storage of state mapping relationship is required, which greatly improves the efficiency of state dimension adjustment in high-dimensional space.
[0073] Based on the same inventive concept, embodiments of the present invention provide a state coding device based on hypercube space, which is used to implement the above-described state coding method based on hypercube space. For example... Figure 2 As shown, a state coding device 200 based on hypercube space includes: an acquisition unit 201, a mapping unit 202, and a storage unit 203.
[0074] Acquisition unit 201 is used to acquire the first state vector to be encoded; Mapping unit 202 is used to perform binarization mapping on the first state vector based on a preset mapping rule to determine the binary vector corresponding to the first state vector; and to map the binary vector corresponding to the first state vector to a hypercube space to determine the first integer index of the first state vector in the hypercube space. Storage unit 203 is used to store or query the first integer index as the first state vector; The storage unit 203 includes a distance query subunit, which is used for: Whenever a distance query request is received, the first integer index and the second integer index to be compared are obtained from the distance query request, and the second integer index corresponds to the second state vector; XOR the first integer index and the second integer index to determine the bit comparison result; Execute a bit-1 counting instruction on the bit comparison result to obtain a bit-1 counting result; The bit-1 count result is used as the Hamming distance between the first state vector and the second state vector, and the Hamming distance is returned.
[0075] Optionally, the storage unit 203 includes a decoding subunit, which is used for: Whenever a status query request is received, the first integer index is obtained from the status query request; Convert the first integer index into the binary vector; Based on the preset mapping rule, the binary vector is inversely mapped to determine the first state vector queried by the state query request.
[0076] Optionally, the bit-1 counting instruction employs hardware-accelerated instructions, including the POPCNT instruction for x86 architecture, the CNT instruction for ARM architecture, or the CPOP instruction for RISC-V architecture.
[0077] Optionally, the storage unit 203 includes a neighbor query subunit, which is used for: Whenever a neighbor query request is received, the first integer index to be queried and the neighbor distance are obtained from the neighbor query request. The neighbor distance is used to represent the number of dimensions that the neighbor state vector has different parameter values from the first state vector. Based on the neighbor distance, multiple mask dimension vectors are generated, which are used to represent the dimensions in which the parameter values of the neighbor state vector and the first state vector are different. Construct the corresponding bitmask for each mask dimension vector; Based on the first integer index and the bitmask corresponding to each of the mask dimension vectors, a plurality of neighbor indices for the neighbor state vectors are generated, and a plurality of neighbor indices are returned. The complexity of the neighbor query is O(n). , N Let be the total number of dimensions of the hypercube space. d The distance to the neighbor is denoted as .
[0078] Optionally, the parameters in the mask dimension vector include the number of bits i in the mask dimension, and the bit mask is calculated using Σ(2^i); The neighbor query subunit is used for: For each of the mask dimension vectors, the first integer index and the bit mask are XORed to obtain the neighbor index of the neighbor state vector corresponding to the mask dimension vector.
[0079] Optionally, the device further includes a topology management unit, the topology management unit being configured to: Whenever a dimensionality upgrade request is triggered, the binary bit value corresponding to the state parameter of the new dimension is determined; if the binary bit value is 0, the dimensionality upgrade integer index of the first state vector is set to the first integer index; if the binary bit value is 1, the dimensionality upgrade integer index of the first state vector is set to the first integer index plus 2. N The sum of these, where N is the total number of original dimensions of the hypercube space; Whenever a dimensionality reduction request is triggered, the number of bits j to be deleted in the dimension is determined, and the integer index of the first state vector for dimensionality reduction is determined using the following formula:
[0080] in, This represents the dimensionality-reduced integer index of the first state vector. The first integer index represents the first state vector.
[0081] This embodiment can achieve the following beneficial effects: In this embodiment, when encoding the first state vector, it can be converted into a binary vector and mapped to a hypercube space. The first integer index in the hypercube space is used to replace the first state vector for storage or retrieval, achieving a mapping compression from high-dimensional binary states to compact integers, so that an N-dimensional state vector only requires N bits of storage. This not only reduces storage overhead but also preserves the topological relationships between states.
[0082] An exemplary embodiment of the present invention also provides an electronic device, including: at least one processor; and a memory communicatively connected to the at least one processor. The memory stores a computer program executable by the at least one processor, the computer program being executed by the at least one processor to cause the electronic device to perform a method according to an embodiment of the present invention.
[0083] An exemplary embodiment of the present invention also provides a non-transitory computer-readable storage medium storing a computer program, wherein the computer program, when executed by a computer's processor, is used to cause the computer to perform a method according to an embodiment of the present invention.
[0084] An exemplary embodiment of the present invention also provides a computer program product, including a computer program, wherein, when executed by a computer's processor, the computer program is used to cause the computer to perform a method according to an embodiment of the present invention.
[0085] refer to Figure 3The present invention will now be described in the form of a structural block diagram of an electronic device 300 that can serve as a server or client of the present invention, which is an example of a hardware device that can be applied to various aspects of the present invention. The electronic device is intended to represent various forms of digital electronic computer devices, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0086] like Figure 3 As shown, the electronic device 300 includes a computing unit 301, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 302 or a computer program loaded from a storage unit 308 into a random access memory (RAM) 303. The RAM 303 may also store various programs and data required for the operation of the device 300. The computing unit 301, ROM 302, and RAM 303 are interconnected via a bus 304. An input / output (I / O) interface 305 is also connected to the bus 304.
[0087] Multiple components in electronic device 300 are connected to I / O interface 305, including: input unit 306, output unit 307, storage unit 308, and communication unit 309. Input unit 306 can be any type of device capable of inputting information to electronic device 300. Input unit 306 can receive input digital or text information and generate key signal inputs related to user settings and / or function control of electronic device. Output unit 307 can be any type of device capable of presenting information and may include, but is not limited to, a display, speaker, video / audio output terminal, vibrator, and / or printer. Storage unit 308 may include, but is not limited to, disk and optical disk. Communication unit 309 allows electronic device 300 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks, and may include, but is not limited to, modems, network cards, infrared communication devices, wireless communication transceivers, and / or chipsets, such as Bluetooth devices, Wi-Fi devices, WiMax devices, cellular communication devices, and / or the like.
[0088] The computing unit 301 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 301 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 301 performs the various methods and processes described above. For example, in some embodiments, the above-described hypercube-based state coding method can be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as storage unit 308. In some embodiments, part or all of the computer program can be loaded and / or installed on the electronic device 300 via ROM 302 and / or communication unit 309. In some embodiments, the computing unit 301 can be configured to perform the above-described hypercube-based state coding method by any other suitable means (e.g., by means of firmware).
[0089] The program code used to implement the methods of the present invention can be written in any combination of one or more programming languages. This program code can be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing device, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code can be executed entirely on the machine, partially on the machine, as a standalone software package partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0090] In the context of this invention, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. Machine-readable media can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0091] As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, device, and / or apparatus (e.g., disk, optical disk, memory, programmable logic device (PLD)) for providing machine instructions and / or data to a programmable processor, including machine-readable media that receive machine instructions as machine-readable signals. The term "machine-readable signal" refers to any signal for providing machine instructions and / or data to a programmable processor.
[0092] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).
[0093] The systems and technologies described herein can be implemented in computing systems that include back-end components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include front-end components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with implementations of the systems and technologies described herein), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.
[0094] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other.
Claims
1. A state coding method based on hypercube space, characterized in that, The method includes: Obtain the first state vector to be encoded; The first state vector is binarized based on a preset mapping rule to determine the binary vector corresponding to the first state vector. Map the binary vector corresponding to the first state vector to the hypercube space, and determine the first integer index of the first state vector in the hypercube space; Store or query the first integer index as the first state vector; Wherein, storing or querying the first integer index as the first state vector includes: Whenever a distance query request is received, the first integer index and the second integer index to be compared are obtained from the distance query request, and the second integer index corresponds to the second state vector; XOR the first integer index and the second integer index to determine the bit comparison result; Execute a bit-1 counting instruction on the bit comparison result to obtain a bit-1 counting result; The bit-1 count result is used as the Hamming distance between the first state vector and the second state vector, and the Hamming distance is returned.
2. The method according to claim 1, characterized in that, The step of storing or querying the first integer index as the first state vector includes: Whenever a status query request is received, the first integer index is obtained from the status query request; Convert the first integer index into the binary vector; Based on the preset mapping rule, the binary vector is inversely mapped to determine the first state vector queried by the state query request.
3. The method according to claim 1, characterized in that, The bit-counting instruction uses hardware-accelerated instructions, including the POPCNT instruction for x86 architecture, the CNT instruction for ARM architecture, or the CPOP instruction for RISC-V architecture.
4. The method according to claim 1, characterized in that, The step of storing or querying the first integer index as the first state vector includes: Whenever a neighbor query request is received, the first integer index to be queried and the neighbor distance are obtained from the neighbor query request. The neighbor distance is used to represent the number of dimensions that the neighbor state vector has different parameter values from the first state vector. Based on the neighbor distance, multiple mask dimension vectors are generated, which are used to represent the dimensions in which the parameter values of the neighbor state vector and the first state vector are different. Construct the corresponding bitmask for each mask dimension vector; Based on the first integer index and the bitmask corresponding to each of the mask dimension vectors, a plurality of neighbor indices for the neighbor state vectors are generated, and a plurality of neighbor indices are returned. The complexity of the neighbor query is O(n). , N Let be the total number of dimensions of the hypercube space. d The distance to the neighbor is denoted as .
5. The method according to claim 4, characterized in that, The parameters in the mask dimension vector include the number of bits i in the mask dimension, and the bit mask is calculated using Σ(2^i); The step of generating neighbor indices for multiple neighbor state vectors based on the first integer index and the bitmask corresponding to each of the mask dimension vectors includes: For each of the mask dimension vectors, the first integer index and the bit mask are XORed to obtain the neighbor index of the neighbor state vector corresponding to the mask dimension vector.
6. The method according to claim 1, characterized in that, The method further includes: Whenever a dimensionality upgrade request is triggered, the binary bit value corresponding to the state parameter of the new dimension is determined; if the binary bit value is 0, the dimensionality upgrade integer index of the first state vector is set to the first integer index; if the binary bit value is 1, the dimensionality upgrade integer index of the first state vector is set to the first integer index plus 2. N The sum of these, where N is the total number of original dimensions of the hypercube space; Whenever a dimensionality reduction request is triggered, the number of bits j to be deleted in the dimension is determined, and the integer index of the first state vector for dimensionality reduction is determined using the following formula: in, This represents the dimensionality-reduced integer index of the first state vector. The first integer index represents the first state vector.
7. A state coding device based on a hypercube space, characterized in that, The device includes: The acquisition unit is used to acquire the first state vector to be encoded. The mapping unit is used to perform binary mapping on the first state vector based on a preset mapping rule to determine the binary vector corresponding to the first state vector; and to map the binary vector corresponding to the first state vector to a hypercube space to determine the first integer index of the first state vector in the hypercube space. A storage unit is used to store or query the first integer index as the first state vector; The storage unit includes a distance query subunit, which is used for: Whenever a distance query request is received, the first integer index and the second integer index to be compared are obtained from the distance query request, and the second integer index corresponds to the second state vector; XOR the first integer index and the second integer index to determine the bit comparison result; Execute a bit-1 counting instruction on the bit comparison result to obtain a bit-1 counting result; The bit-1 count result is used as the Hamming distance between the first state vector and the second state vector, and the Hamming distance is returned.
8. The apparatus according to claim 7, characterized in that, The storage unit includes a neighbor query subunit, which is used for: Whenever a neighbor query request is received, the first integer index to be queried and the neighbor distance are obtained from the neighbor query request. The neighbor distance is used to represent the number of dimensions that the neighbor state vector has different parameter values from the first state vector. Based on the neighbor distance, multiple mask dimension vectors are generated, which are used to represent the dimensions in which the parameter values of the neighbor state vector and the first state vector are different. Construct the corresponding bitmask for each mask dimension vector; Based on the first integer index and the bitmask corresponding to each of the mask dimension vectors, a neighbor index of a plurality of neighbor state vectors is generated, and a plurality of neighbor indexes are returned.
9. An electronic device, comprising: processor; as well as Stored program memory, The program includes instructions that, when executed by the processor, cause the processor to perform the method according to any one of claims 1-6.
10. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to perform the method according to any one of claims 1-6.