A Method for Data Acquisition and Wireless Upload of Cattle Shed Environment Based on the Internet of Things
By using an IoT-based method for collecting environmental data in cattle sheds, a spatial weight matrix and a dimension-reduced reconstruction basis are generated using a 3D mesh model and historical parameters. A quadratic programming problem is constructed and transformed into a semidefinite programming problem. This solves the problems of reconstruction error and spatial coverage in cattle shed environmental monitoring, achieves efficient data collection and uploading, and reduces energy consumption and bandwidth pressure.
Patent Information
- Application Number
- CN202611086350.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-21
- Publication Date
- 2026-11-17
AI Technical Summary
Existing cattle shed environmental monitoring solutions struggle to balance reconstruction errors and spatial coverage, resulting in low global environmental reconstruction accuracy and high communication bandwidth and node energy consumption due to full data upload.
The IoT-based method for collecting environmental data in cattle sheds involves acquiring a 3D mesh model of the cattle shed and historical environmental parameters, generating a spatial weight matrix and a dimensionality-reduced basis, constructing a quadratic constrained quadratic programming problem, and transforming it into a semidefinite programming problem. Gaussian randomization is then used to solve the problem to determine the sensor activation scheme.
While ensuring high-precision reconstruction of the global environment, it significantly reduces redundant data collection and uploading, lowers network bandwidth pressure and equipment energy consumption, and improves system operating efficiency.
Smart Images

Figure CN123124012A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data acquisition technology. More specifically, this invention relates to a method for acquiring and wirelessly uploading data about a cattle shed environment based on the Internet of Things (IoT). Background Technology
[0002] Monitoring and refined management of the internal environment of cattle sheds has become a crucial aspect of improving animal welfare and ensuring farming efficiency. Changes in environmental parameters such as temperature, humidity, ammonia, and carbon dioxide levels within the cattle shed have a profound impact on the health, feeding behavior, and milk and meat production performance of cattle. To understand the environmental conditions within the cattle shed, traditional solutions typically deploy a dense and extensive sensor network for continuous, high-frequency data collection and uploading of large amounts of data to cloud servers. Due to the high spatiotemporal correlation of environmental data between adjacent nodes, simultaneous operation of all sensors generates a large amount of redundant data, exacerbating bandwidth pressure on communication networks and wasting energy on underlying equipment. Furthermore, the massive amount of data during upload can easily lead to network congestion and transmission delays, affecting the data processing efficiency of the server and the real-time performance of global status assessment. Therefore, how to rationally schedule sensor nodes while ensuring the accuracy of overall environmental monitoring in the cattle shed, and achieve overall environmental status restoration with minimal data collection and upload overhead, has become a critical issue that urgently needs to be addressed in the field of smart farming.
[0003] Existing sensor node selection and data acquisition strategies fail to meet the comprehensive requirements of data acquisition and high-fidelity reconstruction in the complex environment of cattle sheds. The internal spatial structure of cattle sheds is complex, with different areas, such as feeding areas, resting areas, and milking areas, exhibiting significantly different sensitivities to environmental changes and varying levels of operational importance. Conventional data acquisition schemes often fail to consider the spatial distribution differences of these functional attributes and cannot combine spatial weights with historical environmental change patterns, resulting in extracted environmental features that cannot accurately represent complex global change patterns. Sensor node activation scheduling is essentially a typical non-convex combinatorial optimization problem. As the number of spatial grids and sensors in the cattle shed increases, the problem's scale expands exponentially. Traditional heuristic algorithms or conventional optimization strategies fail to achieve a good balance between computational efficiency and solution quality when solving such problems, easily getting trapped in local optima. Consequently, the selected sensor activation schemes often fail to simultaneously meet the multi-dimensional performance requirements of reducing reconstruction errors and improving spatial coverage. Summary of the Invention
[0004] To address the technical challenges of existing cattle shed environmental monitoring solutions, which struggle to balance reconstruction errors and spatial coverage, resulting in low global environmental reconstruction accuracy and high communication bandwidth and node energy consumption due to full data upload, this invention provides an IoT-based method for cattle shed environmental data acquisition and wireless upload.
[0005] This invention provides a method for collecting and wirelessly uploading environmental data of a cattle shed based on the Internet of Things (IoT), comprising: S1: acquiring a three-dimensional mesh model of the cattle shed and a historical environmental parameter dataset; generating a spatial weight matrix based on the functional attributes of the mesh nodes in the three-dimensional mesh model of the cattle shed; and extracting a dimension-reduction reconstruction basis based on the historical environmental parameter dataset; S2: setting the activation variables of the binary sensors as decision variables; constructing a quadratic constrained quadratic programming problem with the goal of minimizing the weighted reconstruction error by combining the dimension-reduction reconstruction basis and the spatial weight matrix; transforming the quadratic constrained quadratic programming problem into a semidefinite programming problem and solving it to obtain a positive semidefinite solution matrix; generating multiple sets of Gaussian randomized vectors with zero mean using the positive semidefinite solution matrix as the covariance matrix, and performing symbolic processing to generate multiple candidate solutions; S3: calculating the objective function value and spatial coverage entropy measure of the candidate solutions; determining the activation scheme on the Pareto optimal boundary based on the objective function value and spatial coverage entropy measure; controlling the sensors corresponding to the activation scheme to collect real-time environmental data; and uploading the dimension-reduction reconstruction basis, activation scheme, and real-time environmental data to the server.
[0006] By adopting the above technical solution, this invention generates a spatial weight matrix based on node functional attributes and extracts a dimension-reduced reconstruction basis, constructing sensor scheduling as a quadratic constraint quadratic programming problem. After semidefinite relaxation and Gaussian randomization, the activation scheme is determined on the Pareto boundary combined with spatial coverage entropy measurement. This technical solution transforms the complex non-convex combinatorial optimization problem into a polynomial-time solvable convex optimization problem, while taking into account reconstruction error and spatial distribution uniformity. This solves the problem that large-scale sensor scheduling is prone to getting trapped in local optima and is difficult to balance spatial coverage. While ensuring high-precision reconstruction of the global environment and monitoring without blind spots, it significantly reduces the collection and uploading of redundant data, reducing network bandwidth pressure and equipment energy consumption.
[0007] Preferably, the step of generating a spatial weight matrix based on the functional attributes of grid nodes in the three-dimensional grid model of the cattle shed includes: dividing the grid nodes into rest area nodes, feeding area nodes, and passageway nodes; assigning a first prior weight value to the rest area nodes, a second prior weight value to the feeding area nodes, and a third prior weight value to the passageway nodes, wherein the first prior weight value is greater than the second prior weight value, and the second prior weight value is greater than the third prior weight value; filling the prior weight values of all grid nodes in ascending order of their numbers into the main diagonal of the square matrix, and setting all elements except those on the main diagonal to zero, thereby generating the spatial weight matrix.
[0008] By adopting the above technical solution, the present invention directly encodes the differences in environmental sensitivity of different functional areas inside the cattle shed into the subsequent optimization solution penalty term, thereby forcing the system to prioritize the reconstruction accuracy of the core area that has the greatest impact on the health of cattle, avoiding the problem of the critical area accuracy being weakened at the edge in the traditional uniform weight scheme.
[0009] Preferably, the step of extracting the dimensionality reduction and reconstruction basis based on the historical environmental parameter dataset includes: calculating the environmental covariance matrix of the historical environmental parameter dataset; decomposing the environmental covariance matrix to extract eigenvalues and corresponding eigenvectors; sorting the eigenvalues in descending order according to their numerical values, extracting the eigenvectors corresponding to the top K largest eigenvalues and concatenating them column-wise to extract the dimensionality reduction and reconstruction basis.
[0010] Preferably, calculating the environmental covariance matrix of the historical environmental parameter dataset includes: calculating the average value of historical data for each sensor node and the standard deviation of the corresponding historical data; subtracting the average value from the historical data and dividing by the standard deviation to perform dimensionless standardization; and calculating the environmental covariance matrix of the standardized data.
[0011] Preferably, the step of constructing a quadratic constrained quadratic programming problem with the objective of minimizing weighted reconstruction error by combining the dimensionality reduction reconstruction basis and the spatial weight matrix includes: constructing a reconstruction error vector represented by decision variables with discrete values of 1 and -1 and the dimensionality reduction reconstruction basis; left-multiplying the reconstruction error vector by the spatial weight matrix to obtain a weighted vector, and calculating the inner product of the weighted vectors to obtain the objective function; establishing a constraint condition that the sum of all decision variables is 2M-N, where N is the total number of sensor nodes and M is the preset number of activated nodes; and combining the objective function and the constraint condition to construct the quadratic constrained quadratic programming problem.
[0012] Preferably, the step of transforming the quadratic constrained quadratic programming problem into a semidefinite programming problem and solving it to obtain a positive semidefinite solution matrix includes: constructing an auxiliary matrix variable; using matrix trace operations to transform the non-convex quadratic objective function of the quadratic constrained quadratic programming problem into a linear objective function; relaxing the discrete binary constraints of the decision variables into linear equality constraints where all diagonal elements of the auxiliary matrix variable are equal to 1; discarding the non-convex constraint where the rank of the auxiliary matrix variable is 1, retaining the linear equality constraint and the positive semidefinite constraint of the total number of sensor activations, thus transforming it into the semidefinite programming problem; and iteratively solving the semidefinite programming problem to obtain the optimal auxiliary matrix variable as the positive semidefinite solution matrix.
[0013] By adopting the above technical solution, this invention cleverly transforms the non-convex quadratic optimization problem, which is originally NP-hard and expands exponentially with the number of nodes, into a convex semidefinite programming problem that can be solved efficiently in polynomial time. This ensures that the algorithm can still converge quickly and output a high-quality approximate solution matrix when facing large-scale scenarios with thousands of cowshed grid nodes.
[0014] Preferably, the symbolization process to generate multiple candidate solutions includes: binding the element values of each Gaussian randomized vector to the spatial index of the grid node and arranging them in descending order; rewriting the elements with the highest ranking and a number equal to the preset number of active nodes as positive flag state variables, and rewriting the remaining elements as negative flag state variables; and forming a fixed-length vector from the rewritten state variables according to the spatial index recovery order to generate the multiple candidate solutions.
[0015] By adopting the above technical solution, this invention utilizes the spatial topological coupling information implicit in the semidefinite relaxation solution, and covers multiple local optimal neighborhoods in the solution space through a probability sampling method. This effectively avoids the huge approximation error introduced when the continuous solution is directly hard-truncated and transformed into the discrete domain, and significantly improves the probability of finding a discrete sensor activation scheme close to the global optimal solution.
[0016] Preferably, the calculation of the spatial coverage entropy measure of the candidate solution includes: dividing the three-dimensional cowshed space into grid plots at fixed intervals; obtaining the three-dimensional spatial coordinates of the sensors in the active state in each candidate solution and determining the grid plot to which they belong; counting the frequency of the sensors in the active state in each grid plot and calculating the ratio of the frequency to the total number of sensors in the active state in the candidate solution; and calculating the spatial coverage entropy measure using the discrete information entropy formula based on the ratio distribution of all grid plots.
[0017] Preferably, determining the activation scheme on the Pareto optimal boundary based on the objective function value and the spatial cover entropy metric includes: mapping all candidate solutions to a two-dimensional evaluation coordinate system to form a scatter set with the objective function value as the abscissa and the reciprocal of the spatial cover entropy metric as the ordinate; removing scatter points dominated by other solutions and retaining the non-dominated solution set to form the Pareto optimal boundary, wherein the dominance condition of the non-dominated solution is that the objective function value is smaller and the reciprocal of the spatial cover entropy metric is smaller; and determining the activation scheme in the non-dominated solution set of the Pareto optimal boundary.
[0018] By adopting the above technical solution, this invention introduces a spatial coverage entropy metric and maps the objective function value and the reciprocal of the spatial coverage entropy metric to a two-dimensional coordinate system to construct a Pareto optimal boundary. This forces the sensor activation scheme to achieve a balance between reducing environmental reconstruction errors and improving the uniformity of spatial distribution. It avoids the problem of excessive concentration of sensors in a few high-weight areas, which leads to ventilation dead zones and monitoring blind spots, and improves the stability of the spatial distribution of the entire sensing network.
[0019] Preferably, determining the activation scheme in the set of non-dominated solutions on the Pareto optimal boundary includes: normalizing the objective function value and the reciprocal of the spatial cover entropy metric of each non-dominated solution on the Pareto optimal boundary; calculating the Euclidean distance between each normalized non-dominated solution and the normalized ideal optimal point; and selecting the candidate solution corresponding to the solution with the shortest Euclidean distance as the activation scheme.
[0020] The technical solution of the present invention has the following beneficial technical effects:
[0021] This invention acquires a 3D mesh model of a cattle shed and historical environmental parameters, and constructs a spatial weight matrix based on spatial functional attributes to extract a dimensionality-reduced reconstruction basis. This fully utilizes the spatial differences and environmental change patterns within the cattle shed to effectively reduce the dimensionality of data processing. The invention constructs a planning problem with minimizing the weighted reconstruction error as the optimization objective and solves it using a semi-definite relaxation combined with Gaussian randomization, thereby generating multiple sets of sensor activation candidate schemes. By comprehensively considering the objective function value and spatial coverage entropy, the invention determines the final activation scheme on the Pareto optimal boundary, significantly reducing the number of redundant sensors activated while ensuring full spatial monitoring coverage and high-precision reconstruction of environmental data. With a mechanism that only requires uploading the dimensionality-reduced reconstruction basis, the activation scheme, and a small amount of real-time data, the server can accurately restore the global environmental state. This significantly reduces the amount of data transmitted over the network, effectively alleviating node energy consumption and communication bandwidth pressure, thereby improving the overall operational efficiency of the system. Attached Figure Description
[0022] Figure 1 This is a flowchart of a method for collecting and wirelessly uploading data about a cattle shed environment based on the Internet of Things in this invention; Figure 2 This is a schematic diagram of the gradient distribution of the prior weights of the grid nodes; Figure 3 This is a schematic diagram of the candidate solution distribution and multi-objective optimization results. Detailed Implementation
[0023] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are some embodiments of the present invention, but not all embodiments.
[0024] This invention discloses a method for collecting and wirelessly uploading data on cattle shed environment based on the Internet of Things (IoT), referring to... Figure 1 This includes steps S1-S3: S1: Generate the spatial weight matrix and reconstruct the basis by dimension reduction.
[0025] In an optional embodiment, a three-dimensional mesh model of the cattle shed and a historical environmental parameter dataset of various sensor nodes arranged inside the cattle shed are obtained. Prior weight values are assigned to different mesh nodes in the three-dimensional mesh model of the cattle shed to form a spatial weight matrix. An environmental covariance matrix is calculated based on the historical environmental parameter dataset, and the environmental covariance matrix is decomposed to extract a dimension-reduced reconstruction basis for representing environmental change patterns.
[0026] In the specific execution process, the system first acquires a 3D mesh model of the cattle shed. For example, it reads a 3D mesh model file with the .obj extension using Blender 3D modeling software, extracts the coordinates of the mesh vertices, and discretizes the coordinates into a set of mesh nodes. Then, it performs spatial simplification on the set of mesh nodes, for example, by calling the voxel downsampling filtering algorithm in the Open3D point cloud processing library to perform the simplification operation. After completing the spatial normalization of the mesh nodes, the system divides the 3D mesh model into feeding areas, resting areas, and passageways according to the functional area distribution of the cattle shed. Based on the importance of each functional area to the health of the cattle, it assigns corresponding prior weight values to each type of mesh node. Specifically, the resting area, which has the greatest impact on the health of the cattle, is given the highest prior weight, followed by the feeding area, and then the passageway area, thus constructing a diagonal matrix-like spatial weight matrix, where the elements on the main diagonal are the prior weight values of each mesh node, and the remaining elements are zero. Figure 2 As shown, the weights of all grid nodes are assigned according to the three-zone division rules of the cattle shed. The weight values are arranged in order of node number, and a stepped piecewise curve distinguishes the weight gradient intervals corresponding to the three types of nodes: rest area, feeding area, and passageway area. This distinguishes the weight hierarchy differences between different monitoring areas. Among them, the rest area is the core sleeping and rumination activity area for cattle, and environmental parameters have the highest impact on the health of cattle in this area, so it is assigned the highest prior weight; the feeding area is directly related to the feeding behavior of cattle and is assigned a medium prior weight; the passageway area is a passageway where cattle have less activity and is assigned the lowest prior weight. By introducing this differentiated spatial weight mechanism based on functional attributes, the system can prioritize the reconstruction accuracy of key monitoring areas in subsequent optimization modeling, avoiding the accuracy dispersion problem caused by treating core areas and peripheral areas equally in traditional uniform weight schemes.
[0027] Meanwhile, the system reads historical environmental parameter data from the environmental monitoring database for each grid node location to construct a multidimensional historical environmental parameter dataset. For example, it reads the sensor historical data record table stored in the MySQL database to obtain temperature, humidity, and harmful gas concentration data for the past 30 days. Based on this historical environmental parameter dataset, the system fuses the parameters of temperature, humidity, and gas concentration to calculate a globally unified historical environmental covariance matrix and extracts a corresponding set of dimensionality-reduced reconstruction basis. Specifically, the system first standardizes the original historical data to eliminate the influence of dimensional differences: it calculates the average value of the historical data for each sensor node, subtracts this average value from the original data, and divides it by the historical standard deviation of each parameter to complete the dimensionless Z-score standardization. Subsequently, the system calculates the environmental covariance matrix of the standardized data and performs decomposition operations on the environmental covariance matrix. For example, it uses singular value decomposition, extracts the left singular vectors corresponding to the top K largest eigenvalues in descending order of singular values, and concatenates them to form a truncated singular vector matrix as a dimensionality-reduced reconstruction basis for representing environmental change patterns. The dimensionality reduction and reconstruction basis is essentially a low-dimensional compressed representation of the environmental change patterns across the entire cattle shed. Since the environmental data in the original N-dimensional sensor space exhibits high spatiotemporal correlation, after covariance decomposition and feature truncation, the K-dimensional reconstruction basis captures the most prevalent major change patterns in the data, while discarding secondary patterns representing occasional noise. Thus, while preserving core environmental information, the system significantly reduces the dimension of the subsequent optimization problem from N to K, substantially alleviating the computational burden.
[0028] In an optional embodiment, the specific process of assigning prior weight values to different grid nodes in the three-dimensional grid model of the cattle shed to form a spatial weight matrix includes: dividing the grid nodes into rest area nodes, feeding area nodes, and passageway nodes; assigning a first prior weight value to the rest area nodes, a second prior weight value to the feeding area nodes, and a third prior weight value to the passageway nodes, wherein the first prior weight value is greater than the second prior weight value, and the second prior weight value is greater than the third prior weight value; filling the prior weight values of all grid nodes in ascending order of their numbers into the main diagonal of the square matrix, and setting all elements except those on the main diagonal to zero, thereby generating a spatial weight matrix.
[0029] More specifically, the system first acquires grid nodes with precise 3D spatial coordinates and semantic labels, with a positioning accuracy set to, for example, 0.01m, and then divides the model space into grids according to the experience rules of cowshed experts. For example, for a cowshed 80m long, 40m wide, and 6m high, the system divides the areas along the X-axis (20m to 60m) and Y-axis (10m to 30m), where core sleeping and rumination activities occupy the most space, into resting area nodes; the area near the feeding troughs into feeding area nodes; and the remaining area into passageway nodes. Based on the above division results, the system automatically traverses a total of N grid nodes (here, N is set to 1000 as an example) and assigns scalar weight values to these three types of nodes. For example, the first prior weight value can be 0.7, the second prior weight value can be 0.2, and the third prior weight value can be 0.1, and the sum of the three can be 1, thus representing the priority level of the importance of monitoring the health status of dairy cows. The system generates a one-dimensional weighted feature vector of length N by concatenating elements in ascending order of their numbers, and then performs spatial matrix diagonalization: a pre-defined N×N floating-point matrix of all zeros is constructed. Each element of the aforementioned one-dimensional weighted feature vector of length N is then filled into the main diagonal position of this matrix, where the row and column indices are equal, thus generating a sparse spatial weight matrix. The off-diagonal elements of this weight matrix are all 0, which will act as a penalty multiplier matrix in subsequent multiplication operations, amplifying the reconstruction error proportion of the grid nodes in the core monitoring area. Without this functional attribute-based differentiated spatial weighting, sensor nodes at all spatial locations would be treated equally in subsequent optimization solutions. This could result in the system allocating only a small number of active sensors in critical areas such as rest areas, leading to larger reconstruction errors in temperature or harmful gas concentrations in these areas. Consequently, early environmental signals of heat stress or respiratory diseases in cattle would not be detected in a timely manner, resulting in a serious disconnect between the accuracy of environmental monitoring and the actual needs of livestock management. Through this differentiated spatial weighting mechanism, the system ensures that limited sensor resources prioritize coverage of functional areas with the greatest impact on cattle health.
[0030] In an optional embodiment, the specific process of calculating the environmental covariance matrix based on the historical environmental parameter dataset and decomposing the environmental covariance matrix to extract the dimensionality-reduced reconstruction basis for representing the environmental change pattern includes: calculating the environmental covariance matrix of the historical environmental parameter dataset; decomposing the environmental covariance matrix to extract eigenvalues and corresponding eigenvectors; arranging the eigenvalues in descending order according to their numerical values; extracting the eigenvectors corresponding to the top K largest eigenvalues, concatenating the vectors column-wise to form a matrix, and extracting the dimensionality-reduced reconstruction basis.
[0031] More specifically, the system retrieves historical observation readings covering all grid sensor nodes within a continuous time slice from the environmental monitoring server database. It then uses spatial interpolation algorithms, such as Kriging interpolation, to map the limited sensor observation data onto a global grid model, generating a full-space historical state matrix covering N grid nodes (where N is set to 1000). Based on this, the system reassembles it into a historical observation matrix data stack with a physical scale of N rows and T time steps. Where N rows represent 1000 nodes, and time step T contains, for example, 672 columns of dimensional features. The system derives a specification based on the empirical inner product variance mapping product criterion derived from statistical theory. The sample space environment covariance matrix, the size of which is, for example, 1000×1000.
[0032] Specifically, the sample space environment covariance matrix satisfies the following relationship:
[0033] in, Indicates specifications as The sample space environment covariance matrix has elements on the diagonal representing the time variance of the environmental parameters of each node, and elements off the diagonal representing the covariance between sensor readings at different spatial locations. The larger the value, the higher the degree of synchronization of environmental changes between the two locations. This represents the total number of columns for each time step in the historical observation matrix data stack; Indicates specifications as Action and The historical observation matrix data stack of the column; Represents the stack of historical observation matrix data. The transpose of .
[0034] Subsequently, the system processed the generated above The semidefinite environmental covariance matrix undergoes standard decomposition operations, such as singular value decomposition or eigenvalue decomposition, to extract N complete eigenvalues and N sets of spatial feature column vectors of dimension N that maintain orthogonality. The system sorts the extracted eigenvalue parameter columns in descending order and determines the truncation number K based on this sorting result and a truncation threshold strategy. For example, the system calculates the truncation number K=12 to ensure that the total accumulated information retention ratio of the overall signal exceeds 95%, thereby deleting the remaining redundant low-energy mode branch terms representing occasional isolated noise perturbations. The system extracts the eigenvectors corresponding to the top K maximal eigenvalues separately and concatenates the extracted K eigenvectors column-wise to form a matrix of size [missing information]. The system employs a rectangular mapping array, which serves as the basis matrix for global dimensionality reduction and reconstruction, representing the mechanisms of overall environmental changes within the system's architecture. During this process, the selection of the value of K must balance information fidelity and dimensionality compression: if K is too small, the reduced basis cannot adequately capture the main patterns of environmental change, leading to insufficient reconstruction accuracy; if K is too large, the dimensionality compression effect is limited, and the computational complexity of subsequent optimization remains high. By using a 95% cumulative information contribution rate as a truncation criterion, the system achieves a balance between the two, ensuring that the reduced reconstruction basis contains both the main information about environmental changes and has a sufficiently low dimensionality for subsequent optimization.
[0035] In an optional embodiment, the specific process of calculating the environmental covariance matrix of the historical environmental parameter dataset includes: calculating the average value of historical data for each sensor node; subtracting the average value from the original data and dividing by the historical standard deviation to perform dimensionless standardization; and calculating the environmental covariance matrix of the standardized data.
[0036] More specifically, when dealing with environmental parameters of multiple physical dimensions such as temperature, humidity, and harmful gas concentration, the system must perform Z-score standardization before calculating the covariance matrix to eliminate the interference of different parameter dimensions on the estimation of the covariance structure. In this process, the system iterates through the historical data of the sensors corresponding to N grid nodes. For each sensor node location, it accumulates the observations over all T time slices and divides the sum by T to obtain the node's time mean. Then, the system calculates the mean of the sum of squares of the differences between the observations of each time slice and the aforementioned mean, and takes the square root to obtain the node's historical standard deviation. The system subtracts the mean of the corresponding node from the raw data of each sensor node for each time slice, and then divides the resulting difference by its historical standard deviation, thus completing the dimensionless standardization process. After standardization, parameters of different physical dimensions are uniformly mapped to the same scale space, and their covariance matrix reflects the pure linear correlation structure between the nodes, rather than a spurious correlation distorted by dimensional differences. After this standardization process is completed, the system calculates the environmental covariance matrix on the standardized data matrix. The resulting covariance matrix can accurately represent the real correlation pattern of environmental parameter changes between different spatial locations in the cattle shed, providing a reliable data foundation for subsequent singular value decomposition and dimensionality reduction reconstruction basis extraction.
[0037] S2: Optimization problem construction and semidefinite relaxation to generate candidate solutions.
[0038] In one possible embodiment, the sensor activation variable is set as the decision variable, and a quadratic constrained quadratic programming problem with the goal of minimizing the weighted reconstruction error is constructed by combining the dimension reduction reconstruction basis and the spatial weight matrix. The quadratic constrained quadratic programming problem is transformed into a semidefinite programming problem by semidefinite relaxation, and the positive semidefinite solution matrix is obtained by solving it. Multiple sets of Gaussian randomized vectors are generated using the positive semidefinite solution matrix as the covariance matrix, and multiple candidate solutions representing sensor activation schemes are generated after symbolization.
[0039] In the specific execution process, the system first constructs a column vector consisting of -1 and +1 as the sensor activation variable, where +1 indicates that the sensor node at the corresponding location is in an active state, and -1 indicates that the sensor node at the corresponding location is in a dormant state. This column vector is used as the optimization decision variable. The system uses the spatial weight matrix obtained in stage S1. Dimensional Reduction and Reconstruction Base and its transpose matrix Perform a series of multiplications to calculate the objective parameter matrix. This target parameter matrix integrates both spatial functional attribute weights and environmental change patterns: the matrix The diagonal elements amplify the error sensitivity of the core region nodes, while This captures the low-dimensional structure of environmental changes. The system uses decision variables... transpose, objective parameter matrix With decision variables The product of the three As the objective function, this quadratic form essentially represents the total reconstruction error in a spatially weighted sense, representing the environmental information lost by inactive nodes under the current sensor activation configuration. The system constraint is that the total number of elements with a value of +1 in the sensor activation variable equals the preset maximum number of activated sensors. Equivalently expressed as Furthermore, each element of the sensor activation variable must belong to the discrete binary set {+1, -1}. Therefore, the system constructs a quadratic constrained quadratic programming problem with the objective of minimizing the weighted reconstruction error.
[0040] However, the aforementioned quadratic constrained quadratic programming problem is a typical NP-hard non-convex combinatorial optimization problem. The discrete binary constraints on the decision variables in this optimization problem cause the feasible region to expand from... Composed of isolated points, the system becomes computationally infeasible through direct exhaustive search as the total number of nodes N increases. Therefore, the system employs a semidefinite relaxation transformation to obtain a high-quality approximate solution. The system constructs a new auxiliary matrix variable. The outer product of the sensor activation variable and its own transpose is used to transform the original non-convex quadratic objective function using matrix trace operations. Transform it into a linear objective function with respect to the auxiliary matrix variable. The system will impose discrete binary constraints on the original decision variable elements, i.e. The equivalent relaxation is a linear equality constraint where all elements on the main diagonal of the auxiliary matrix variable are equal to 1. At the same time, discard the non-convex constraint that the rank of the auxiliary matrix variable must be equal to 1. Only the linear equality constraint of the total number of active nodes derived from the original discrete variables and the convex cone constraint that the auxiliary matrix variable is a positive semi-definite matrix are retained. After the relaxation transformation described above, the original NP-hard quadratic constrained quadratic programming problem is transformed into a convex semidefinite programming problem that can be solved in polynomial time.
[0041] The system iteratively solves the semidefinite programming problem to obtain the positive semidefinite solution matrix. For example, the system uses the CVXPY optimization modeling library in conjunction with the MOSEK solver engine to iteratively solve the semidefinite programming problem using the interior-point method: starting from strictly feasible interior points, it gradually approaches the optimal solution along the central path guided by the obstacle function, iterating until the primordial-dual gap meets the preset convergence tolerance, and outputting the converged optimal auxiliary matrix variable as the positive semidefinite solution matrix. Interior-point methods have a key advantage here, specifically in that their computational complexity increases with the problem size. It grows at a polynomial rate, rather than exponentially like exhaustive search, thus enabling processing within a reasonable time. The actual grid size of the cattle shed at each level.
[0042] In obtaining the positive semidefinite solution matrix Next, the system needs to transform the continuous relaxation solution back into a discrete sensor activation scheme. The system uses a positive semi-definite solution matrix. To generate multiple sets of Gaussian randomized vectors with zero mean for the covariance matrix, the system calls the multivariate normal distribution function of the randomization module in the NumPy library, using the vector with all zero elements as the mean vector, and then calculates the positive semidefinite solution matrix. As the covariance matrix, 1000 Gaussian randomized vectors are generated using a multivariate Gaussian distribution. Each Gaussian randomized vector has a length of N, and its covariance structure is determined by... The decision, therefore, incorporates spatial topological coupling information from the original semidefinite programming solution. The system symbolizes each element of each Gaussian randomized vector, converting it to +1 or -1 to generate candidate solutions. In one symbolization strategy, the system converts elements with values greater than or equal to zero to +1 and elements with values less than zero to -1, then filters out invalid vectors that do not meet the preset maximum number of sensor activations constraint, retaining the remaining compliant symbolized vectors as candidate solutions. Alternatively, the element values of each randomized vector are bound to the spatial index of the grid nodes and sorted in descending order, converting the top M elements to +1 and the remaining elements to -1, thus obtaining symbolized vectors that satisfy the activation number constraint. If the above Gaussian randomization and symbolization processing are not performed and a deterministic rounding strategy is directly adopted, it is easy to introduce large approximation errors due to the hard truncation of continuous solutions into the discrete domain, resulting in the reconstruction accuracy of the finally selected sensor activation scheme being far lower than the theoretical optimal value. Through a method based on... The covariance structure is generated by multiple independent randomizations, and the system probabilistically covers multiple local optimal neighborhoods in the solution space, which significantly improves the probability of finding a discrete solution close to the global optimum.
[0043] In an optional embodiment, the specific process of setting the sensor activation variables as decision variables and constructing a quadratic constrained quadratic programming problem with the goal of minimizing the weighted reconstruction error by combining the dimensionality-reduced reconstruction basis and the spatial weight matrix includes: setting the binary sensor activation variables as decision variables, with a value range of discrete -1 and 1; constructing a reconstruction error vector represented by the decision variables and the dimensionality-reduced reconstruction basis; multiplying the spatial weight matrix on the left by the reconstruction error vector to obtain a weighted vector; calculating the inner product of the weighted vectors to obtain the objective function; and establishing the sum of all decision variables as... The constraints, among which This represents the total number of sensor nodes. To predetermine the number of activated nodes, a quadratic constrained quadratic programming problem is constructed by combining the objective function and constraints.
[0044] More specifically, the system takes an N-dimensional binary decision vector as input when the total number is N, for example, when N equals 1000. This serves as the sensor activation variable for the system. Each element in this decision vector is constrained to belong to the discrete set {-1, 1}, where 1 represents deploying and activating the sensor at the corresponding grid point, and -1 represents not deploying or keeping the sensor dormant. The system is based on the extracted dimensionality-reduced reconstruction basis. , to the dimensionality reduction and reconstruction base Consider as a The matrix parameterizes the environmental projection uncertainty of the unmonitored area into a reconstruction error vector. The diagonal spatial weight matrix generated in stage S1 is then used. Multiply the reconstruction error vector by left and apply position-sensitive weights to each grid node: the error term of the rest area node is... The larger diagonal elements are amplified to obtain higher penalty weights in the optimization objective; the error terms of the aisle nodes correspond to smaller weights, allowing for relatively large reconstruction tolerances. The system transforms the weighted reconstruction error into a standard quadratic form by calculating the inner product of the obtained weighted vector and itself to seek the minimum of the overall reconstruction distortion.
[0045] Specifically, the global objective function satisfies the following relation:
[0046] in, This represents the global objective function aimed at minimizing the weighted reconstruction error. This represents an N-dimensional binary decision vector, i.e., the sensor activation variable; The transpose matrix of the decision vector; Denotes the eigenker matrix, and satisfies ; Represents the diagonal space weight matrix; This represents the dimension-reduced reconstructed basis matrix used to characterize environmental change patterns; This represents the transpose of the basis matrix for dimensionality reduction reconstruction.
[0047] To meet the hardware overhead constraints of deploying a limited number of devices on-site, the system sets a node cardinality constraint. For example, with a preset maximum number of active nodes M=20, if the activation variables of 20 sensors are 1 and the activation variables of the remaining 980 sensors are -1, then the theoretical sum of all elements of the decision vector is -960. Based on this, the system constructs a standard linear equation constraint. By mathematically combining the quadratic objective function, the cumulative equality constraint, and the discrete constraint of the binary range of the variables, a quadratic programming problem with two variables and two constraints is established.
[0048] In an optional embodiment, the specific process of transforming the quadratic constrained quadratic programming problem into a semidefinite programming problem and solving it to obtain the positive semidefinite solution matrix includes: constructing an auxiliary matrix variable; using matrix trace operations to transform the non-convex quadratic objective function of the quadratic constrained quadratic programming problem into a linear objective function; relaxing the discrete binary constraints of the decision variables into linear equality constraints where all diagonal elements of the auxiliary matrix variable are equal to 1; discarding the non-convex constraint that the rank of the auxiliary matrix variable is 1, retaining the linear equality constraint of the total number of sensor activations and the positive semidefinite constraint, thus transforming it into a semidefinite programming problem; and iteratively solving the semidefinite programming problem to obtain the optimal auxiliary matrix variable as the positive semidefinite solution matrix.
[0049] More specifically, the system defines auxiliary matrix variables. ,make Then the original quadratic objective function It can be transformed using the cyclic property of the matrix trace. This linearizes the non-convex quadratic objective function. The original decision variables are subject to discrete binary constraints. Equivalent to That is, auxiliary matrix Each main diagonal element The system directly applies this equivalent constraint to... On the main diagonal, forming Several linear equality constraints. Meanwhile, due to... It must be a positive semi-definite matrix of rank 1. The system discards the non-convex constraint of rank 1 and only retains the relaxed positive semi-definite constraint. Thus The feasible region is expanded from a non-convex low-dimensional manifold to a convex one. The intersection of a positive semi-definite cone and a hyperplane. Additionally, the original constraints. Equivalent to The system retains this as a linear equality constraint. Thus, the system transforms the original NP-hard problem into the following semidefinite programming problem: For a linear objective function, with , and The constraints are as follows. Preferably, the system uses the CVXPY optimization modeling library to construct the above semidefinite programming model and calls the interior-point method algorithm of the MOSEK solver engine for iterative solution. The interior-point method has an important advantage in this scenario: the computational complexity of each iteration mainly comes from solving a single... The complexity of a Vie Newtonian linear system is approximately For a cowshed size of N=1000, convergence can be achieved within seconds to tens of seconds, while the complexity of the original exhaustive search is O(n). This is completely infeasible at this scale. After iterations until the primal-dual gap satisfies the Caro-Kun-Tucker optimization condition, the system outputs the convergent optimal auxiliary matrix variable. As a positive semidefinite solution matrix.
[0050] In an optional embodiment, the specific process of generating multiple sets of Gaussian randomized vectors using the positive semi-definite solution matrix as the covariance matrix and generating multiple candidate solutions representing sensor activation schemes after symbolization includes: continuously extracting and generating multiple sets of multidimensional Gaussian randomized vectors with zero mean using the positive semi-definite solution matrix as the covariance matrix; binding the element values of each randomized vector to the spatial index of the grid node and arranging them in descending order; rewriting the top M elements as positive flag state quantity 1 and rewriting the remaining elements as negative flag state quantity -1, where M is the preset number of activation nodes; and constructing a fixed-length vector from the rewritten state quantities according to the spatial index recovery order as candidate solutions, where each candidate solution represents a set of sensor array activation distribution patterns.
[0051] More specifically, in obtaining The positive semidefinite solution matrix of the size Then, for example, when the size is 1000×1000, at this stage, it is necessary to use the matrix to perform the Gaussian approximation inverse operation to transform the continuous solution into a discrete solution.
[0052] To satisfy the Cholesky decomposition algorithm's requirement that the matrix must be strictly positive definite, when the semi-positive definite solution matrix... When eigenvalues close to zero exist, the system adds a very small regularization perturbation term to its main diagonal (e.g., using...). ,in It is a very small positive real constant. The system corrects the solution matrix (which is the identity matrix) to make it a strictly positive definite matrix. Then, it applies a matrix factorization algorithm, such as the Cholesky decomposition algorithm, to this corrected solution matrix, splitting it into lower triangular matrices. Rather than transpose Product form Subsequently, the system calls a pseudo-random number generator to generate random variables following a standard normal distribution, and then combines the generated independent standard normal random vectors with the split lower triangular matrix. Multiplying them together yields a vector with a mean of zero and a covariance of... The system generates a multivariate Gaussian distributed random vector. This process is iteratively repeated; specifically, the system continuously generates 1000 sets of vectors, each of length N, with a mean of zero and conforming to a specific covariance. The system uses a set of structurally constrained multidimensional Gaussian randomized vectors, where each Gaussian vector contains spatial topological coupling information with continuous-domain floating-point numbers. The system performs a truncation mapping discretization transformation step: each continuous element's value is tuple-bound to its initial position index (1 to N), for example, creating key-value pairs (1, 2.45) and (2, -0.12). The set of tuples to be sorted in descending order based on the magnitude of the numerical parts. According to a pre-defined budget deployment value M (e.g., M = 20), elements ranking in the top M positions after reordering are rewritten with a positive flag state value of 1, while elements ranking from M+1 to N are rewritten with a negative flag state value of -1. After rewriting all element flags, the system reconstructs the element flags into a fixed-length N-dimensional spatial discrete sequence according to the original hooked index order, thus obtaining a candidate solution that satisfies the activation quantity limit. The candidate solution can be regarded as a binary array layout on the roof and column frame of the cowshed. Each candidate solution approximates the quality level of the original semidefinite programming optimal solution in a probabilistic manner.
[0053] S3: Multi-objective optimization to determine the activation scheme and upload the data.
[0054] In one possible embodiment, the objective function value corresponding to each candidate solution is calculated; the spatial coverage entropy measure corresponding to each candidate solution is calculated; a two-dimensional evaluation coordinate system is constructed using the objective function value and the spatial coverage entropy measure, all candidate solutions are mapped to the two-dimensional evaluation coordinate system, and an activation scheme is determined on the Pareto optimal boundary; the sensor corresponding to the activation scheme is instructed to collect real-time environmental data, and the dimensionality reduction reconstruction basis, activation scheme, and real-time environmental data are encapsulated and uploaded to the server to restore the global environmental state.
[0055] In the specific execution process, the system iterates through each candidate solution vector generated in stage S2, and then... Substitute the pre-calculated target parameter matrix In the middle, through calculation The corresponding weighted reconstruction error is obtained and used as the objective function value for the current candidate solution. The smaller the objective function value, the less environmental information is lost by inactive nodes under the sensor activation configuration, i.e., the higher the global reconstruction accuracy.
[0056] Simultaneously, the system calculates the spatial coverage entropy metric corresponding to each candidate solution to evaluate the uniformity of the distribution of activated sensors in the three-dimensional cowshed space. The spatial coverage entropy metric can be obtained through various statistical algorithms based on spatial topology: Optionally, the Euclidean distance between each pair of activated sensor nodes in each candidate solution can be calculated, and the nodes can be divided into ten equally spaced distance intervals. The probability ratio is then calculated, and the result is obtained using the Shannon information entropy formula. Preferably, the three-dimensional cowshed space is divided into grid plots at fixed intervals along the X, Y, and Z axes. The three-dimensional spatial coordinates of the activated sensors in each candidate solution are obtained, and the grid plot to which the sensors belong is determined. The frequency of activated sensors within each grid plot is counted, and the ratio of this frequency to the total number of activated nodes is calculated. Based on the ratio distribution of all grid plots, the discrete information entropy formula is used. The spatial coverage entropy metric is calculated. A higher spatial coverage entropy metric indicates a more uniform spatial distribution of activated sensors and a wider coverage area. Conversely, if the activated sensors are excessively clustered in a local area, the spatial coverage entropy metric will decrease significantly. The core design consideration of this metric mechanism is that pursuing only the minimum reconstruction error may lead to the concentrated deployment of sensors on a few high-weight nodes. Although the reconstruction accuracy is high, the spatial coverage is severely uneven. Once a sensor in a local area fails or communication is interrupted, the system will lose all monitoring capabilities for that area. By introducing spatial coverage entropy as a second optimization objective, the system forces the activation scheme to achieve a balance between reconstruction accuracy and spatial distribution stability.
[0057] After obtaining the objective function values and spatial cover entropy measures of all candidate solutions, the system constructs a two-dimensional evaluation coordinate system with the objective function values as the horizontal axis and the reciprocal of the spatial cover entropy measures as the vertical axis. The system then plots the horizontal and vertical coordinate values of all candidate solutions onto this two-dimensional evaluation coordinate system to generate a scatter plot. For example... Figure 3 As shown, all candidate solutions are projected onto a two-dimensional plane with dual objectives. A curve is used to connect the non-dominated solution set under multi-objective optimization. The starred points represent the output solutions closest to the ideal reference point, allowing for comparison of the trade-off between reconstruction error and spatial distribution uniformity for each candidate solution. The system uses a non-dominated sorting algorithm in multi-objective optimization to calculate all scattered points, eliminating those dominated by other solutions in both the horizontal and vertical directions. Specifically, the elimination criteria are: if solution B's value on the horizontal axis is greater than or equal to solution A's value on the vertical axis, and at least one dimension is strictly greater than A, then B is considered dominated by A. The system extracts the non-dominated solution set located at the lower left of the two-dimensional evaluation coordinate system to form a Pareto optimal boundary. Each solution on this boundary represents the optimal spatial coverage uniformity achievable with a given reconstruction accuracy, and vice versa.
[0058] After determining the Pareto optimal boundary, the system calculates the Euclidean distance from each non-dominated solution point on the boundary to the ideal reference point. The x-axis of the ideal reference point represents the minimum objective function value among all candidate solutions, and the y-axis represents the reciprocal of the minimum spatial coverage entropy among all candidate solutions, representing the ideal scenario with the minimum reconstruction error and the most uniform spatial distribution. The system selects the non-dominated solution with the closest Euclidean distance to the ideal reference point as the activation scheme with the best overall performance. Subsequently, the system sends data acquisition commands to the sensor nodes corresponding to the +1 value in the activation scheme via a lightweight IoT communication protocol such as MQTT. The activated sensor nodes use their built-in microcontrollers to read the analog signals of ambient temperature, humidity, and harmful gases in real time, and perform analog-to-digital conversion to generate real-time environmental data.
[0059] After completing real-time data acquisition, the system serializes the dimensionality reduction and reconstruction basis data obtained in stage S1 into structured text formats such as JSON, and combines the activation scheme configuration information with the real-time environmental data. The resulting data payload is then transmitted to the cloud server via a wireless communication module. The cloud server receives and parses the data payload to extract the real-time environmental data. Based on the received activation scheme configuration information, it extracts the row vectors corresponding to the grid nodes where the activated sensors are located from the global dimensionality reduction and reconstruction basis, and concatenates them to form a subspace sampling matrix. The number of activated nodes is then verified. Greater than or equal to the number of truncated features Given that the sampling matrix of this subspace is full rank, the system calls a matrix inversion algorithm to calculate the pseudo-inverse matrix of the sampling matrix of this subspace. This pseudo-inverse matrix is then multiplied by the real-time environmental data to estimate the hidden state vector of the reduced-dimensional space. Subsequently, the system multiplies the complete basis matrix containing all N nodes in the global domain—that is, the complete global dimensionality reduction reconstruction basis—by this hidden state vector to reconstruct the environmental parameters of all inactive grid nodes inside the cattle shed. Based on this, the system performs an inverse standardization operation, combining the mean and standard deviation of each node calculated in stage S1. The inverse standardization operation multiplies the reconstructed standardized value by the historical standard deviation of the corresponding node and adds the historical mean, thereby obtaining a multidimensional global environmental state with real physical dimensions in terms of temperature, humidity, and harmful gas concentration.
[0060] The complete data acquisition and upload process described above significantly improves communication efficiency: the system only needs to upload real-time data of the K-dimensional reconstruction base and M activation nodes, along with activation scheme configuration information. The total data volume of the reconstruction base, real-time data, and configuration information is approximately [data missing]. With a floating-point number plus a small amount of configuration bytes, the environmental state of all N grid nodes can be restored on the server side. Compared to the N sensor data required by traditional full sensor upload solutions, the data transmission volume is reduced from... Reduce to Level, in , , In a typical configuration, the amount of uploaded data is reduced by approximately 97%, effectively alleviating bandwidth pressure on the wireless communication network and reducing the power consumption of sensor nodes. Without the aforementioned combination of dimensionality reduction and selective activation, large-scale cattle shed deployments would face severe communication bottlenecks: hundreds to thousands of sensor nodes simultaneously reporting data at high frequencies would not only quickly exhaust wireless channel capacity but also be highly susceptible to transmission delays and packet loss due to data packet collisions. This would prevent the server from obtaining complete real-time environmental status in a timely manner, thus affecting the timeliness of livestock management decisions.
[0061] In an optional embodiment, the specific process of calculating the spatial coverage entropy measure corresponding to each candidate solution includes: dividing the three-dimensional cowshed space into grid plots at fixed intervals along the X, Y, and Z axes; obtaining the three-dimensional spatial coordinates of the sensors in the active state in each candidate solution and determining the grid plot to which the sensors belong; counting the frequency of the sensors in the active state in each grid plot and calculating the ratio of the frequency to the total number of sensors in the active state in the candidate solution; and calculating the spatial coverage entropy measure using the discrete information entropy formula based on the ratio distribution of all grid plots.
[0062] More specifically, the system acquires the three-dimensional geometric span of the 3D cattle shed facility, including its length, width, and height. For example, the cattle shed model is 80m long, 40m wide, and 6m high. The system executes a geometric cutting algorithm, using a given constant sampling interval step size, such as 10m in the X direction, 10m in the Y direction, and 6m in the Z direction, to divide the complete cattle shed space into a set of 32 independent 3D bounding boxes forming a grid of plots. Each plot is equipped with a globally unique region ID identifier with boundary determination parameters. After acquiring a set of sensor nodes with M active states generated in a single extraction (taking M = 20 as an example), the system reads the fine-grained absolute spatial coordinates built into the node set and uses spatial point-to-region bounding box envelope discrimination logic to determine the grid plot belonging to each device. After completing the coordinate association projection, the system starts statistical calculations on the frequency of sensors in positive flag states assigned to each grid plot, accumulating the results to obtain the... Number of activated nodes identified within grid parcel # ,in Calculate the frequency ratio distribution variable This satisfies the fundamental theorem that the sum of all probability ratios is always equal to 1. The system uses all the obtained... Substituting the parameters into the discrete information entropy formula Quantitative calculations are performed. If there are completely unsensitized, zero-sensor voids in the terrain, leading to… If the entropy increase contribution of the voided area approaches 0, then the aggregated floating-point value calculated accordingly represents the spatial cover entropy measure: if a candidate solution tends to cause equipment clustering in ventilation dead zones, resulting in a decrease in the spatial cover entropy measure, it indicates poor spatial cover uniformity; if the equipment is macroscopically evenly distributed across the grid, the spatial cover entropy measure approaches the theoretical maximum value. This indicates that the spatial coverage has reached the highest degree of uniformity.
[0063] In an optional embodiment, the specific process of constructing a two-dimensional evaluation coordinate system using the objective function value and the spatial cover entropy metric, mapping all candidate solutions to the two-dimensional evaluation coordinate system, and determining the activation scheme on the Pareto optimal boundary includes: mapping all candidate solutions to the two-dimensional evaluation coordinate system to form a scatter set with the objective function value as the abscissa and the reciprocal of the spatial cover entropy metric as the ordinate; removing scatter points that are simultaneously dominated by other solutions in both the abscissa and ordinate, and retaining the non-dominated solution set to form the Pareto optimal boundary, wherein the dominance condition of the non-dominated solution is that the objective function value is smaller and the reciprocal of the spatial cover entropy metric is smaller; and determining the activation scheme in the non-dominated solution set of the Pareto optimal boundary.
[0064] More specifically, the system extracts the reconstruction objective function value and the corresponding spatial coverage entropy metric for each of the overall candidate pool containing multiple sets of randomly generated rewrite schemes, for example, 1000 sets. The range of the reconstruction objective function value is, for example, [12.5, 45.3], and the range of the corresponding spatial coverage entropy metric is, for example, [1.8, 3.9]. The system establishes a two-dimensional planar evaluation coordinate system with the weighted reconstruction objective function value as the horizontal axis representing the global reconstruction accuracy of the measurement data, and the reciprocal of the spatial coverage entropy metric as the vertical axis representing the topological anti-crowding degree. All candidate pool schemes are mapped to a scatter set in this rectangular coordinate plane. The system implements multi-objective non-dominated sorting logic, traversing all scatter points pairwise and comparing their performance in two dimensions: if scheme B's value on the horizontal axis is greater than or equal to scheme A's value on the vertical axis, and at least one dimension is a strict inequality, then B is determined to be dominated by A. The system removes the scatter points in a dominated state, retaining the non-dominated scatter point sequence to form the Pareto front curve representing the performance boundary of multi-objective optimization. The horizontal axis uses the objective function value (reconstruction error) instead of its optimization form, intuitively corresponding to the engineering preference for data accuracy; the vertical axis uses the reciprocal of spatial coverage entropy instead of entropy itself, considering that in Pareto dominance analysis, both objectives should be optimized in the direction of minimizing the error, i.e., minimizing both the reconstruction error and the spatial coverage concentration (the reciprocal of entropy). This ensures that the non-dominated dominance criterion is mathematically consistent and intuitively interpretable.
[0065] In an optional embodiment, the specific process of determining the activation scheme in the non-dominated solution set of the Pareto optimal boundary includes: normalizing the objective function value and the reciprocal of the spatial cover entropy metric of each non-dominated solution on the Pareto optimal boundary; calculating the Euclidean distance between each normalized non-dominated solution and the normalized ideal optimal point; and selecting the candidate solution corresponding to the solution with the shortest Euclidean distance as the activation scheme.
[0066] More specifically, to avoid distance calculation bias caused by the original reconstruction error's horizontal axis being much larger than the inverse of the vertical spatial coverage entropy, and to prevent the Euclidean distance result from being almost entirely dominated by the horizontal axis error term, thus marginalizing the vertical axis spatial coverage uniformity factor, the system performs normalization processing on each candidate scatter point in the non-dominated scatter point set retained in the Pareto front using the min-maximum feature scaling method. Preferably, after performing a local maximum / minimum search within the front set, the system linearly maps and compresses all horizontal axis values of the currently retained candidate solutions to the floating-point range of [0,1], where 1 corresponds to the original maximum reconstruction error and 0 corresponds to the minimum reconstruction error; simultaneously, the vertical axis values are also mapped to the [0,1] interval, where 1 corresponds to the maximum inverse of the spatial coverage entropy metric and 0 corresponds to the minimum inverse of the spatial coverage entropy metric. After normalization, the values of the two dimensions are unified to the same order of magnitude, allowing the Euclidean distance to fairly consider both reconstruction accuracy and spatial coverage uniformity objectives. The system constructs an ideal reference point located at the origin (0,0) of the coordinate plane in a new normalized dimension space. This ideal reference point represents the ideal scenario with the minimum absolute error and the most uniform sensor distribution. Under a standard distance space system, the system evaluates and calculates the normalized Euclidean space segment lengths from the vectors of each scatter point on the boundary point sequence to the origin (0,0). From all Euclidean distance calculation results, the system selects the candidate scheme parameter pair corresponding to the minimum value, retrieves the original code of the binary decision array recording the membership association of the candidate scatter point, and transforms the original code into the optimal activation scheme for the server to assign on / off sleep commands to various field node controllers. Through the above normalization plus Euclidean distance optimization strategy, the system automatically determines an activation scheme that achieves the best trade-off between reconstruction accuracy and spatial coverage uniformity from multiple non-dominant candidate schemes on the Pareto front, avoiding the arbitrariness of manual experience-based selection and ensuring the objectivity and reproducibility of the scheme selection.
[0067] Figure 2This diagram illustrates the gradient distribution of prior weights for grid nodes. The stepped horizontal lines at different heights represent weight levels for different functional areas. The image shows significant interval differences in the prior weights, with the higher platforms representing rest areas that have the greatest impact on cattle health. The lower platforms on either side correspond to feeding and passageway nodes, respectively. This stepped weight allocation demonstrates that the system successfully encodes spatial functional attributes into the weight matrix, achieving a proactive tilt of monitoring resources towards the core area. Observing the weight heights of different intervals reveals that rest areas receive significantly higher penalty weights than passageway areas. This corresponds to the differentiated spatial weighting strategy described in the specific implementation that prioritizes the reconstruction accuracy of the core monitoring area.
[0068] Figure 3 This diagram illustrates the distribution of candidate solutions and the results of multi-objective optimization. The scattered points in the background represent candidate solutions for sensor activation generated through Gaussian randomization. The polygonal line marked with squares represents the Pareto front under multi-objective optimization. The star symbol represents the optimal activation scheme determined after normalization and Euclidean distance calculation. The image shows that a large number of candidate solutions are distributed within a two-dimensional coordinate space composed of the reconstructed objective function value and spatial coverage entropy. The Pareto front is located at the upper left edge of the scattered point set, and the points on its line segment represent non-dominated solutions with better spatial distribution uniformity at the same level of reconstruction error. The position of the star symbol reflects the algorithm's optimal trade-off between reducing environmental data reconstruction errors and improving spatial monitoring coverage. Observing the distribution of the Pareto front reveals that the scheme selection process fully balances monitoring accuracy and topological distribution stability. This corresponds to the decision-making logic described in the specific implementation method, which uses spatial coverage entropy to avoid excessive sensor aggregation and achieve high-fidelity restoration of the overall environmental state.
[0069] It should be noted that those skilled in the art can make various modifications and improvements without departing from the inventive concept, and these all fall within the scope of protection of this invention. Therefore, the scope of protection of this patent should be determined by the appended claims.
Claims
1. A cowshed environment data collection and wireless uploading method based on Internet of Things, characterized in that, include: S1: Obtain the 3D mesh model of the cattle shed and the historical environmental parameter dataset. Generate a spatial weight matrix based on the functional attributes of the mesh nodes in the 3D mesh model of the cattle shed, and extract the dimension reduction reconstruction basis based on the historical environmental parameter dataset. S2: Set the activation variables of the binary sensors as decision variables, and construct a quadratic constrained quadratic programming problem with the goal of minimizing the weighted reconstruction error by combining the dimension reduction reconstruction basis and the spatial weight matrix. Transform the quadratic constrained quadratic programming problem into a semidefinite programming problem and solve it to obtain the positive semidefinite solution matrix. Multiple sets of Gaussian randomized vectors with zero mean are generated using the positive semi-definite solution matrix as the covariance matrix, and then symbolic processing is performed to generate multiple candidate solutions; S3: Calculate the objective function value and spatial cover entropy measure of the candidate solution, and determine the activation scheme on the Pareto optimal boundary based on the objective function value and spatial cover entropy measure; control the sensor corresponding to the activation scheme to collect real-time environmental data, and upload the dimensionality reduction reconstruction basis, activation scheme and real-time environmental data to the server.
2. The cowshed environment data collection and wireless uploading method based on the Internet of Things according to claim 1, characterized in that, The method for generating a spatial weight matrix based on the functional attributes of grid nodes in a 3D grid model of a cattle shed includes: dividing the grid nodes into rest area nodes, feeding area nodes, and passageway nodes; assigning a first prior weight value to the rest area nodes, a second prior weight value to the feeding area nodes, and a third prior weight value to the passageway nodes, wherein the first prior weight value is greater than the second prior weight value, and the second prior weight value is greater than the third prior weight value; filling the prior weight values of all grid nodes in ascending order of their numbers into the main diagonal of the square matrix, and setting all elements except those on the main diagonal to zero, thereby generating the spatial weight matrix.
3. The cowshed environment data collection and wireless uploading method based on the Internet of Things according to claim 1, characterized in that, The step of extracting the dimensionality reduction and reconstruction basis based on the historical environmental parameter dataset includes: calculating the environmental covariance matrix of the historical environmental parameter dataset; decomposing the environmental covariance matrix to extract eigenvalues and their corresponding eigenvectors; sorting the eigenvalues in descending order according to their numerical values, extracting the eigenvectors corresponding to the top K largest eigenvalues and concatenating them column-wise to extract the dimensionality reduction and reconstruction basis.
4. The cowshed environment data collection and wireless uploading method based on the Internet of Things according to claim 3, characterized in that, The calculation of the environmental covariance matrix of the historical environmental parameter dataset includes: calculating the average value of historical data for each sensor node and the standard deviation of the corresponding historical data; subtracting the average value from the historical data and dividing by the standard deviation to perform dimensionless standardization; and calculating the environmental covariance matrix of the standardized data.
5. The cowshed environment data collection and wireless uploading method based on the Internet of Things according to claim 1, characterized in that, The method of constructing a quadratic constrained quadratic programming problem with the objective of minimizing weighted reconstruction error by combining the dimensionality reduction reconstruction basis and the spatial weight matrix includes: constructing a reconstruction error vector represented by decision variables with discrete values of 1 and -1 and the dimensionality reduction reconstruction basis; multiplying the reconstruction error vector by the spatial weight matrix on the left to obtain a weighted vector, and calculating the inner product of the weighted vectors to obtain the objective function; establishing a constraint that the sum of all decision variables is 2M-N, where N is the total number of sensor nodes and M is the preset number of activated nodes; and combining the objective function and the constraint to construct the quadratic constrained quadratic programming problem.
6. The cowshed environment data collection and wireless uploading method based on the Internet of Things according to claim 5, characterized in that, The process of transforming a quadratic constrained quadratic programming problem into a semidefinite programming problem and solving it to obtain a positive semidefinite solution matrix includes: constructing an auxiliary matrix variable; using matrix trace operations to transform the non-convex quadratic objective function of the quadratic constrained quadratic programming problem into a linear objective function; relaxing the discrete binary constraints of the decision variables into linear equality constraints where all diagonal elements of the auxiliary matrix variable are equal to 1; discarding the non-convex constraint where the rank of the auxiliary matrix variable is 1, retaining the linear equality constraint and the positive semidefinite constraint of the total number of sensor activations, thus transforming it into a semidefinite programming problem; and iteratively solving the semidefinite programming problem to obtain the optimal auxiliary matrix variable as the positive semidefinite solution matrix.
7. The cowshed environment data collection and wireless uploading method based on the Internet of Things according to claim 1, characterized in that, The symbolization process to generate multiple candidate solutions includes: binding the element values of each Gaussian randomized vector to the spatial index of the grid node and arranging them in descending order; rewriting the elements with the highest ranking and a number equal to the preset number of active nodes as positive flag state variables, and rewriting the remaining elements as negative flag state variables; and constructing a fixed-length vector from the rewritten state variables according to the spatial index recovery order to generate the multiple candidate solutions.
8. The cowshed environment data collection and wireless uploading method based on the Internet of Things according to claim 1, characterized in that, The calculation of the spatial coverage entropy measure for candidate solutions includes: dividing the three-dimensional cowshed space into grid plots at fixed intervals; obtaining the three-dimensional spatial coordinates of the sensors in the active state in each candidate solution and determining their respective grid plots; counting the frequency of the sensors in the active state in each grid plot and calculating the ratio of the frequency to the total number of sensors in the active state in the candidate solutions; and calculating the spatial coverage entropy measure using the discrete information entropy formula based on the ratio distribution of all grid plots.
9. The cowshed environment data collection and wireless uploading method based on the Internet of Things according to claim 1, characterized in that, The method of determining the activation scheme on the Pareto optimal boundary based on the objective function value and the spatial cover entropy metric includes: mapping all candidate solutions to a two-dimensional evaluation coordinate system to form a scatter set with the objective function value as the abscissa and the reciprocal of the spatial cover entropy metric as the ordinate; removing scatter points dominated by other solutions and retaining the non-dominated solution set to form the Pareto optimal boundary, wherein the dominance condition of the non-dominated solution is that the objective function value is smaller and the reciprocal of the spatial cover entropy metric is smaller; and determining the activation scheme in the non-dominated solution set of the Pareto optimal boundary.
10. The cowshed environment data collection and wireless uploading method based on the Internet of Things according to claim 9, characterized in that, The step of determining the activation scheme in the set of non-dominated solutions on the Pareto optimal boundary includes: normalizing the objective function value and the reciprocal of the spatial cover entropy metric of each non-dominated solution on the Pareto optimal boundary; calculating the Euclidean distance between each normalized non-dominated solution and the normalized ideal optimal point; and selecting the candidate solution corresponding to the solution with the shortest Euclidean distance as the activation scheme.
