AI intelligent-based magnetic toy auxiliary design method
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- DONGGUAN YONGNKIDS TOYS TECHNOLOGY CO LTD
- Filing Date
- 2026-05-29
- Publication Date
- 2026-08-07
AI Technical Summary
[0007]本发明的目的是解决现有技术中磁体布局依赖经验试错、可玩性无法量化、稳定性与可玩性矛盾、安全验证滞后的问题,为此提出一种基于AI智能的磁力玩具辅助设计方法
本发明通过构建以磁体布局参数为可训练变量的可微分磁场求解器,并迭代优化各连接面的吸附力,能够自动搜索最优磁体布局,避免经验试错,缩短设计周期。
Smart Images

Figure CN122528664A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer-aided design technology, and in particular to an AI-based method for designing magnetic toys. Background Technology
[0002] In the design process of magnetic toys, the layout of magnets usually relies on the experience and trial and error of designers, lacking automated optimization methods, resulting in long design cycles and high costs.
[0003] Existing design methods cannot quantify the playability of magnetic toys, making it difficult to assess structural robustness and reconfigurability during the design phase, resulting in a lack of objective evaluation criteria for the playability of design schemes.
[0004] There is an inherent contradiction between the connection stability and playability of magnetic toys: excessively strong attraction reduces children's flexibility in disassembly and reassembly and the fun of reconstruction, while insufficient attraction results in structural instability. Current technology cannot dynamically adjust the optimization weight of attraction based on playability indicators during the optimization process, making it difficult to achieve an adaptive balance between the two.
[0005] Safety verification is usually carried out after the product structure is finalized. If the verification process, such as dynamic drop simulation, finds that the safety requirements are not met, it must be scrapped and started over, resulting in a lot of rework.
[0006] Therefore, this invention proposes an AI-based magnetic toy-aided design method. Summary of the Invention
[0007] The purpose of this invention is to solve the problems in the existing technology, such as the reliance on experience and trial and error for magnet layout, the inability to quantify playability, the contradiction between stability and playability, and the lag in safety verification. To this end, an AI-based magnetic toy-assisted design method is proposed.
[0008] To achieve the above objectives, the present invention adopts the following technical solution: an AI-based magnetic toy-aided design method, comprising the following steps: Step S1: Obtain the design constraint information of the magnetic toy and generate an initial magnet layout diagram that encodes the spatial position and magnetization direction of each magnet. Step S2: Construct a differentiable magnetic field solver with magnet layout parameters as trainable variables, and iteratively optimize the magnet layout with the adsorption force of each connecting surface as the optimization objective. Step S3: Model the parts with the optimized magnet layout and their magnetic attraction relationships as a directed attribute graph, and calculate the playability index. The edge attributes of the directed attribute graph include magnetic polarity matching features. Step S4: Feed back the playability index to step S2. Dynamically adjust the weight of the adsorption force optimization target based on the real-time deviation between the adsorption force and the playability index. Repeat steps S2 to S3 until both the adsorption force and the playability index meet their respective preset thresholds. Step S5: Taking the amount of magnets used and safety constraints as optimization objectives, perform dynamic drop simulation to verify the optimized scheme, select the optimal solution and output the design results.
[0009] The beneficial effects of the technical solution provided by this invention include at least the following: This invention constructs a differentiable magnetic field solver with magnet layout parameters as trainable variables and iteratively optimizes the adsorption force of each connecting surface. It can automatically search for the optimal magnet layout, avoid trial and error, and shorten the design cycle.
[0010] This invention models parts with optimized magnet layouts and their magnetic attraction relationships as directed attribute graphs with edge attributes containing magnetic polarity matching features, and calculates playability indices. This allows for a quantitative evaluation of the structural robustness and reconfigurability of toys, providing an objective design basis for playability.
[0011] This invention feeds back playability metrics to the magnet layout optimization step, dynamically adjusts the weight of the adsorption force optimization target based on the real-time deviation between adsorption force and playability metrics, and iterates repeatedly until both meet the preset threshold. This enables an adaptive balance between connection stability and reconfiguration flexibility, overcoming the contradiction that traditional designs cannot achieve both simultaneously.
[0012] This invention verifies the optimized solution through dynamic drop simulation, selects the optimal solution with magnet usage and safety constraints as optimization objectives, can bring safety verification forward and couple it with the design process, reduce rework, and output a design solution that meets safety requirements and minimizes magnet usage. Attached Figure Description
[0013] To more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0014] Figure 1 This is a schematic diagram of the method flow provided in an embodiment of the present invention; Figure 2 The flowchart for calculating the directed attribute graph and playability index is provided for embodiments of the present invention. Detailed Implementation
[0015] To further illustrate the technical means and effects adopted by the present invention to achieve its intended purpose, the following, in conjunction with the accompanying drawings and preferred embodiments, details the specific implementation, structure, features, and effects of an AI-based magnetic toy assisted design method proposed according to the present invention. In the following description, different "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. Furthermore, specific features, structures, or characteristics in one or more embodiments can be combined in any suitable form.
[0016] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.
[0017] The following examples are for illustrative purposes only and are not intended to limit the scope of the invention.
[0018] The following description, in conjunction with the accompanying drawings, details a specific scheme of the AI-based magnetic toy assisted design method provided by the present invention.
[0019] Please see Figure 1 The diagram illustrates a flowchart of an AI-based magnetic toy design method according to an embodiment of the present invention, comprising the following steps: Step S1: Obtain the design constraint information of the magnetic toy and generate an initial magnet layout diagram that encodes the spatial position and magnetization direction of each magnet. Step S2: Construct a differentiable magnetic field solver with magnet layout parameters as trainable variables, and iteratively optimize the magnet layout with the adsorption force of each connecting surface as the optimization objective. Step S3: Model the parts with the optimized magnet layout and their magnetic attraction relationships as a directed attribute graph, and calculate the playability index. The edge attributes of the directed attribute graph include magnetic polarity matching features. Step S4: Feed back the playability index to step S2. Dynamically adjust the weight of the adsorption force optimization target based on the real-time deviation between the adsorption force and the playability index. Repeat steps S2 to S3 until both the adsorption force and the playability index meet their respective preset thresholds. Step S5: Taking the amount of magnets used and safety constraints as optimization objectives, perform dynamic drop simulation to verify the optimized scheme, select the optimal solution and output the design results.
[0020] It should be noted that design constraint information refers to the various requirements for magnetic toys that users input when starting the design process. These include the shape and type of parts, the number of target assembly forms, and the age range suitable for children. This information determines the basic specifications and design goals of the subsequently generated magnet layout diagram.
[0021] A magnet layout diagram is a three-dimensional tensor data structure. Each voxel of this three-dimensional tensor encodes whether a magnet exists at the corresponding location, the magnetization direction vector of the magnet, and the geometric dimensions of the magnet.
[0022] A differentiable magnetic field solver is a computational model that uses magnet layout parameters as trainable variables and calculates the gradient of the loss function with respect to the magnet layout parameters through an automatic differentiation mechanism, thereby enabling iterative optimization of the magnet layout using the gradient descent method.
[0023] A directed attribute graph is a graph structure constructed with each part as a node and the contact surface relationship between the parts as edges. The edge attributes include magnetic polarity matching features calculated based on the magnetization direction of the magnets on the relative connection surfaces.
[0024] Playability index refers to a numerical indicator that quantifies the structural robustness and reconfigurability of magnetic toys in various assembly forms, including structural robustness score and reconfigurability score.
[0025] Dynamic drop simulation verification refers to using a simulation proxy model to simulate the process of a magnetic toy falling freely from a preset height, predicting the probability of separation of each part, and selecting qualified solutions based on safety constraints.
[0026] In one specific implementation, taking the design of a children's magnetic toy set consisting of 6 triangular magnetic pieces and 4 square magnetic pieces as an example, the target assembly shapes are cube, triangular pyramid and star, and the applicable age range is 5 to 8 years old.
[0027] Step S1 is implemented as follows: Design constraints are input via a touchscreen interface: part shapes are triangles and squares, with 6 triangles and 4 squares; the target assembly form is 3; and the applicable age range for children is 5 to 8 years old. This information is encoded into a 16-dimensional conditional vector, where the first 4 dimensions represent the part types and quantities, the middle 6 dimensions represent the weights of the three forms, and the last 6 dimensions represent the safety threshold parameters corresponding to the age range. This conditional vector is input into a pre-trained conditional diffusion model. The model starts with standard Gaussian noise and, after 50 denoising iterations, generates a 64×64×64 resolution three-dimensional tensor. Each voxel in this three-dimensional tensor corresponds to a 2mm×2mm×2mm cube in actual space. The three-dimensional tensor is parsed, and voxel values are extracted for the preset connection surfaces of the 6 triangular pieces and 4 square pieces. If the voxel value is close to 1, it indicates the presence of a magnet, and the magnetization direction vector (three-dimensional unit vector) and geometric dimensions (5mm diameter, 2mm thickness) stored in that voxel are read. The initially generated layout may have magnetic circuit non-closure issues, such as inconsistent magnetization directions of three magnets on a connecting surface of a triangular piece, or the same magnet polarity on opposite faces of adjacent triangular and square pieces. In this case, a magnetic circuit closure constraint is applied: the magnetization direction of all magnets on each connecting surface is forced to be the same (through majority voting or adjusting vector signs), and the magnet polarities on opposite faces of adjacent parts are adjusted to be opposite (i.e., all N poles on one face, all S poles on another). If the constraint is still violated after adjustment, conditional resampling in the backdiffusion process is triggered: returning to step 40 of the backdiffusion, discarding the current intermediate result, resampling the noise and denoising again, until the generated 3D tensor satisfies the magnetic circuit closure constraint. Finally, an initial magnet layout that satisfies the magnetic circuit closure constraint is obtained.
[0028] The specific implementation of step S2: Obtain the geometric shape and preset connection surface information of each part from step S1. Each triangular piece has a side length of 50 mm and a thickness of 5 mm. The area of each connection surface (i.e., the inner surface of each side) is 500 square millimeters. Based on this, the initial number of magnets on this surface is determined to be 2, and the candidate positions are located at two interior points (uniformly distributed) among the three equal division points of the side length. Each square piece has a side length of 50 mm and an area of 625 square millimeters for each connection surface. The initial number of magnets is determined to be 2, and the candidate positions are located at the midpoint of the square's side. Construct a differentiable magnetic field solver and use the equivalent magnetic charge method to calculate the attraction force between any two magnets. Use the spatial position coordinates of the magnets and the magnetization direction angle as trainable variables. Set the target attraction force to 0.8 Newtons. Based on the disassembly and assembly force test data of children aged 5-8, set the lower threshold to 0.7 Newtons and the upper threshold to 1.0 Newtons. The loss function consists of three parts: attraction force error term, minimum spacing penalty term, and uniformity penalty term. The adsorption force error term adopts an asymmetric form: linear penalty is applied when the actual adsorption force is below 0.7N, exponential penalty is applied when it is above 1.0N, and no penalty is applied when it is in between. Minimum spacing constraint: The preset distance threshold is 8 mm (determined based on the magnet diameter of 5 mm and magnetic field interference simulation). When the center distance between two magnets is less than 8 mm, a repulsion penalty term is added, with the penalty value equal to the preset coefficient 1000 multiplied by the square of the distance difference, where the distance difference is equal to the preset distance threshold minus the actual center distance between the two magnets. Uniformity constraint: The variance of the magnet position coordinates on each connecting surface is calculated, with a preset uniformity threshold of 2 square millimeters (calibrated by the variance amplification factor of an ideal uniform distribution). When the variance is greater than 2, a uniformity penalty term is added, with the penalty value being 100 multiplied by the variance exceeding the threshold. The total loss function is a weighted sum of three terms with weight coefficients of 0.5, 0.3, and 0.2. The Adam optimizer is used with a learning rate of 0.01, and iterative optimization is performed. After 500 internal iterations, an optimized magnet layout was obtained: the spacing between each magnet is greater than 8 mm, the uniformity variance is less than 2, and the adsorption force is stable between 0.75 and 0.85 Newtons.
[0029] The specific implementation of step S3: Using 6 triangular pieces and 4 square pieces as nodes, and the 12 contact surface relationships between them as edges, a directed attribute graph is constructed. The initial attributes of each node include the geometry of the part (triangle or square, side length 50 mm) and the magnet position coordinates and magnetization direction vector of each connecting surface on the part after optimization in step S2. Each edge is traversed to obtain the magnet layout information of the two parts connected by the edge on their respective connecting surfaces. Taking an edge connecting triangular piece A and square piece B as an example: there are 2 magnets on the connecting surface of A, with magnetization directions of 0, 0, 1 (defined as N pole); there are 2 magnets on the opposite connecting surface of B, with magnetization directions of 0, 0, -1 (defined as S pole). The magnetic polarity matching coefficient between all magnet pairs is calculated, defined as the negative of the dot product of the two magnetization direction vectors. Thus, when the directions are opposite, the dot product is -1, and the matching coefficient is 1; a value greater than 0 indicates attraction. When the directions are the same, the dot product = 1, and the matching coefficient = -1 indicates mutual repulsion. There are 2×2=4 magnet pairs, each with a matching coefficient of 1, and the proportion greater than zero is 100%. The preset proportion threshold is 60% (determined based on the required minimum attraction force and safety factor), so this edge is judged as a magnetic connection. If two triangular pieces are facing each other, and both are magnetized in the directions 0, 0, 1, then the dot product of each magnet pair is 1, the matching coefficient is -1, and the proportion greater than zero is 0%, so it is judged as a mutual exclusion connection. The judgment result (magnetic or mutual exclusion) of each edge is stored in the edge attributes. Then the attribute graph is input into a 3-layer first-graph neural network (for playability evaluation). In the message passing of each layer of this network, the message passing weight is set to 0.9 for magnetically connected edges and 0.1 for mutually exclusive connected edges. After three layers of message passing, the feature vector of each node incorporates the information of its neighboring nodes. The neighbor information of magnetically connected edges is enhanced, while the neighbor information of mutually exclusive connected edges is suppressed. Finally, the feature vectors of all nodes are concatenated and input into a fully connected prediction layer, which outputs two values: structural robustness score of 0.82 and reconstruction flexibility score of 0.75. Together, they constitute the playability index.
[0030] The specific implementation of step S4: The structural robustness score of 0.82 and the reconstruction flexibility score of 0.75 calculated in step S3 are fed back to step S2. The preset threshold for structural robustness score is 0.8, and the preset threshold for reconstruction flexibility score is 0.7. Together, they constitute the playability achievement condition. In the current iteration step of the overall optimization loop (e.g., the 200th loop), the average adsorption force deviation of each connection surface is 0.05 Newtons (actual 0.75, target 0.80), the deviation of structural robustness score is 0.02 (actual 0.82, target 0.80), and the deviation of reconstruction flexibility score is 0.05 (actual 0.75, target 0.70). The deviation history sequence of the first 3 steps is as follows: adsorption force deviation 0.07, 0.06, 0.05; structural robustness deviation 0.03, 0.02, 0.02; reconstruction flexibility deviation 0.06, 0.05, 0.05. In this embodiment, the preset step count is 3, which captures the trend of deviation changes without making the state vector dimension too high. These 9 values are combined into a single state vector and input into the deep deterministic policy gradient agent. The agent's actor network is a 3-layer fully connected neural network with an input dimension of 9 and an output dimension of 1. The current total number of parts in the magnetic toy is 10, and the exploration noise amplitude is set to a relative value of 0.1 (i.e., 10% of the action output range), which is proportional to the total number of parts. The agent's continuous output weight adjustment under noise perturbation is +0.02.
[0031] The reward value is calculated based on the achievement of the standards: The current adsorption force of 0.75 is below the preset adsorption force standard range (0.78 to 0.82), the structural robustness score of 0.82 ≥ 0.8 meets the standard, and the reconstruction flexibility score of 0.75 ≥ 0.7 meets the standard. Therefore, it falls under the category of "only one standard achieved" (adsorption force is below the standard, but both playability standards are met), and the reward value is the second preset positive value, for example, +1. If the adsorption force also meets the standard, the reward value is the first preset positive value +10. If one or two playability standards are below the standard and the adsorption force is also below the standard, the reward value is negative, and the absolute value is equal to the sum of the adsorption force deviation and the playability deviation (the weighted sum of the two deviations).
[0032] The weight adjustment of +0.02 is added to the current attraction weight of 0.5, resulting in a new weight of 0.52. The state, action, reward, and next state generated in this loop are stored in the experience replay pool. During training, samples with an absolute value of temporal difference error greater than 0.1 are sampled from the replay pool. Taking the current sample error of 0.12 as an example, it is selected to update the actor and critic networks.
[0033] The entire loop described above is repeated (each loop includes 500 internal iterations of step S2, the playability index calculation in step S3, and the weight adjustment in step S4) until the termination condition is met: the actual adsorption force of each connecting surface falls within the preset adsorption force range of 0.78 to 0.82 Newtons, and the structural robustness score is ≥0.8 and the reconstruction flexibility score is ≥0.7. In this embodiment, after 200 loops, the adsorption force stabilizes at 0.79 to 0.81 Newtons, the structural robustness score stabilizes at ≥0.81, and the reconstruction flexibility score stabilizes at ≥0.71, all meeting the termination condition, and the loop ends.
[0034] The specific implementation of step S5 is as follows: First, a second graph neural network for dynamic drop simulation is constructed (this network is independent of the first graph neural network used for playability evaluation in step S3, and has a different structure and training objective). A multi-fidelity active learning strategy is used to train this second graph neural network. 10,000 sets of first-class simulation data are generated: using sparse mesh (5 mm mesh size) finite element simulation with randomly sampled magnet layout parameters, the maximum separation distance and collision energy of each part after a drop from a height of 1.2 meters are calculated, with each simulation taking approximately 2 seconds. Simultaneously, 100 sets of second-class simulation data are generated: using dense mesh (1 mm mesh size) finite element simulation with the same layout parameters, with each set taking approximately 200 seconds. The ratio of the two types of data is 100:1. The active learning algorithm randomly selects 100 data points from the 10,000 first-class data points as the initial training set to train a preliminary second graph neural network. Then, the prediction variance of the network for each sample in the remaining 100 second-class data points is calculated. The second-class data point with the largest variance is selected (e.g., a scheme where the maximum separation distance prediction fluctuates greatly due to a magnet layout), and a high-precision mesh simulation is performed. The obtained high-precision data is added to the training set. This process is repeated 10 times, and finally, the second graph neural network is trained using 10 high-precision points and 1000 low-precision points. The nodes of this second graph neural network correspond to the parts of a magnetic toy. The node features include the magnet layout parameters (position, magnetization direction, size) and mass distribution (10 grams for triangular pieces, 15 grams for square pieces) of the parts, and the edge features include the magnetic attraction and mechanical contact constraints between the parts. The network outputs the predicted value after three layers of message passing. After training, the final scheme converged in step S4 is input into the second graph neural network. The network inference time is 10 milliseconds, and the maximum separation distance is 2.8 mm with a collision energy of 0.04 joules. Based on toy safety standards (such as ASTM F963) and the impact resistance of the part materials (plastic), safety constraints were pre-set: the maximum separation distance should not exceed 3 mm and the collision energy should not exceed 0.05 joules. This scheme meets these safety constraints. Then, Bayesian optimization was performed with the goal of minimizing the amount of magnets used. The total amount of magnets used in the current scheme is as follows: each triangular piece has 3 connecting faces, 2 magnets per connecting face, for a total of 6 magnets / piece, and 36 magnets for 6 triangular pieces; each square piece has 4 connecting faces, 2 magnets per connecting face, for a total of 8 magnets / piece, and 32 magnets for 4 square pieces; totaling 68 magnets. Bayesian optimization uses a Gaussian process as a surrogate model, the sampling function as the desired improvement, and employs sampling weighting based on the variance of the second-graph neural network prediction (i.e., regions with high variance are given higher sampling weights). After 50 iterations, a new solution was found: the number of magnets on each connecting surface of the triangular piece was reduced to 1, and the number of magnets on each connecting surface of the square piece was reduced to 1. The total number of magnets used then became 6×3×1+4×4×1=18+16=34.The second neural network prediction indicates that the maximum separation distance for this scheme is 2.9 mm, and the collision energy is 0.045 joules, which still meets the safety threshold. Further optimization cannot reduce the number of magnets without violating safety constraints; therefore, this scheme is selected as the optimal solution. The output includes a 3D model file (STEP format), a magnet BOM list (spatial coordinates, magnetization direction, and dimensions of each magnet), and instructions for the three assembly forms: cube, triangular pyramid, and star.
[0035] Step S1 further includes the following sub-steps: S1-1, Obtain the design constraint information of the magnetic toy, and encode the part shape, number of target assembly forms and applicable age range of children in the design constraint information into a condition vector; S1-2, the conditional vector is input into the diffusion model to generate an initial three-dimensional tensor. Each voxel of the three-dimensional tensor encodes whether a magnet exists at the corresponding location, the magnetization direction vector of the magnet, and the geometric dimensions. S1-3, apply magnetic circuit closure constraint to the generated initial magnet layout diagram so that on each connecting surface of each part, the magnetization direction of all magnets points to the same polarity, and the magnets on the opposite connecting surfaces of adjacent parts have opposite polarities. S1-4 When the generated initial layout violates the magnetic circuit closure constraint, it is corrected by conditional resampling during the reverse diffusion process so that the initial layout satisfies the magnetic circuit closure constraint during the generation stage.
[0036] It should be noted that the condition vector refers to a one-dimensional feature array formed by numerically encoding the discrete or continuous parameters in the design constraint information. This array serves as the condition input of the diffusion model and is used to control the generation process to proceed in a direction that conforms to the constraints.
[0037] The diffusion model is a generative neural network based on a denoising probability model. It learns the process of gradually restoring the data distribution from pure noise and can generate constrained three-dimensional tensor data given a conditional vector.
[0038] A 3D tensor is a three-dimensional mesh-like data structure whose size is determined by the maximum part size and voxel resolution in the design constraints. Each voxel in the 3D tensor encodes the presence of a magnet at that spatial location, the magnetization direction vector of the magnet, and the geometric dimensions of the magnet. The presence is represented by 0 or 1, the magnetization direction vector is represented by a 3D unit vector, and the geometric dimensions are represented by diameter and thickness values.
[0039] Magnetic circuit closure constraint refers to a set of rules imposed on the physical characteristics of magnetic toys: on each connecting surface of each part, the magnetization direction of all magnets must point to the same magnetic polarity (all N poles or all S poles) to prevent magnets in the same connecting surface from canceling each other out; at the same time, on the opposite connecting surfaces between any two adjacent parts, the polarities of the magnets must be opposite (i.e., one connecting surface is N pole and the opposite surface is S pole) to ensure that the magnetic attraction force can be generated stably.
[0040] Conditional resampling in the reverse diffusion process refers to the process in the reverse diffusion stage of the diffusion model where, when the model predicts that the current step data does not meet the magnetic circuit closure constraint, a new latent variable is resampled from the noise distribution, and denoising calculation is performed again based on the condition vector until the generated data meets the constraint.
[0041] In step S1, this application transforms the design constraint information into a condition vector, driving the diffusion model to generate a three-dimensional tensor as the initial magnet layout. Since the diffusion model itself lacks the physical knowledge of magnetic toys, the generated layout often violates magnetic circuit closure (e.g., magnets on the same connecting surface have different polarities, or adjacent opposing surfaces have the same polarity). Therefore, this application actively applies magnetic circuit closure constraints after generation and corrects them using conditional resampling in back-diffusion. This mechanism ensures that the initial layout satisfies basic physical rules during the generation stage, providing a high-quality and feasible starting point for subsequent optimization and avoiding repeated iterations caused by non-closed magnetic circuits in later stages.
[0042] Step S2 further includes the following sub-steps: S2-1, Obtain the geometric shape and preset connection surface information of each part, and determine the initial number and candidate arrangement position of magnets on each connection surface based on the area and shape of the connection surface; S2-2, Set the minimum spacing constraint between adjacent magnets. When the spatial distance between two magnets is less than the preset distance threshold, add a repulsion penalty term to the loss function. S2-3, Set magnetic field distribution uniformity constraints. Based on the position coordinates of each magnet in the magnet layout, calculate the variance of the magnet position distribution on each connecting surface as a uniformity index. When the index is higher than the preset uniformity threshold, add a uniformity penalty term to the loss function. S2-4. During the iterative optimization process, the sum of the squares of the differences between the actual adsorption force and the target adsorption force of each connection surface is calculated as the adsorption force error term. The repulsion penalty term, uniformity penalty term and adsorption force error term are weighted and summed to form the total loss function of the current iteration step, and the gradient is used to update the magnet layout parameters.
[0043] Furthermore, in sub-step S2-4, the adsorption force error term adopts an asymmetric form: when the actual adsorption force is lower than the target adsorption force lower threshold, a linear penalty function is used to calculate the error; when the actual adsorption force is higher than the target adsorption force upper threshold, an exponential penalty function is used to calculate the error.
[0044] It should be noted that the geometry of a part refers to the shape of each magnetic toy part, such as a triangle or a square, as well as its side length, angles, and other dimensional parameters.
[0045] Preset connection surface information refers to the pre-defined planar area on each part for adsorption and contact with other parts, such as the inner surface of the three sides of a triangular piece. Each connection surface has its own area and shape characteristics.
[0046] The initial quantity and candidate placement positions refer to automatically calculating the maximum reasonable number of magnets that can be placed on the surface based on the area and shape of the connecting surface, and initially arranging the possible position coordinates of the magnets, such as evenly arranging candidate points on a rectangular surface according to a grid.
[0047] Minimum spacing constraint refers to the lower limit of spatial distance set to prevent adjacent magnets from being too close, which could lead to mutual interference of magnetic fields or a decrease in structural strength. When the center distance between two magnets is less than this lower limit, a penalty term needs to be applied to the loss function.
[0048] The preset distance threshold refers to the minimum permissible spatial distance used to determine whether two magnets are too close. A distance below this threshold will cause magnetic field interference or a decrease in structural strength. The threshold is determined by multiplying the magnet diameter by a safety factor between 2.5 and 3.0; or by verifying through finite element simulation that the additional attraction force between adjacent magnets is less than 5% of the main attraction force. For example, for a 5mm diameter NdFeB magnet, the theoretically calculated threshold is 12.5mm, but simulation yields 8mm. Its application is as follows: In step S2, when the spatial distance between the two magnets is less than this threshold, a repulsion penalty term is added to the loss function.
[0049] The exclusion penalty term is a positive value added to the loss function when the magnet spacing violates the constraint. Its magnitude is proportional to the degree of distance violation, forcing the optimization algorithm to push the magnets away.
[0050] The uniformity constraint of magnetic field distribution refers to the requirement that the positional distribution of magnets on a connecting surface be as uniform as possible, avoiding local over-density or under-density. This patent uses the variance of position coordinates as a quantitative indicator.
[0051] The uniformity index refers to the sample variance of the position coordinates of all magnets on the connecting surface. The smaller the variance, the more uniform the distribution.
[0052] The preset uniformity threshold refers to the critical variance value used to determine whether the magnet position distribution on a connecting surface is sufficiently uniform. The rule for obtaining it is: calculate the sample variance of the magnet position coordinates under an ideal uniform distribution, and take 1.5 to 4 times this variance as the threshold. For example, when four magnets are uniformly distributed on a rectangular surface, the ideal variance is approximately 0.5 square millimeters; taking 4 times yields 2 square millimeters; or, the critical variance when the adsorption force decreases by 5% using finite element scanning. Its application is as follows: in step S2, calculate the sample variance of the magnet position coordinates on the current connecting surface; if it exceeds the threshold, add a uniformity penalty term to the loss function.
[0053] The uniformity penalty term is a positive value added to the loss function when the uniformity index is higher than the preset uniformity threshold. Its magnitude is proportional to the difference between the threshold and the actual variance, which promotes the magnet distribution to become more uniform.
[0054] The adsorption force error term refers to the sum of squares of the deviations between the actual adsorption force at the current connection surface and the design target adsorption force, and is used to measure whether the adsorption force provided by the magnet layout meets the design requirements.
[0055] Weighted summation refers to multiplying the adsorption force error term, repulsion penalty term, and uniformity penalty term by their respective weighting coefficients and then summing them to obtain the total loss function.
[0056] Gradient update refers to using the derivative of the total loss function with respect to the magnet layout parameters, calculating the adjustment amount of each parameter through the backpropagation algorithm, and updating the parameter values using an optimizer such as Adam.
[0057] The asymmetric form refers to the use of different penalty functions for the adsorption force error term when it is below the target lower limit and above the target upper limit: a linear function is used when it is below the lower limit to avoid insufficient suction causing the structure to fall apart; an exponential function is used when it is above the upper limit to severely punish excessive suction and prevent children from having difficulty assembling and disassembling the structure.
[0058] The target adsorption force lower limit threshold refers to the minimum allowable value of actual adsorption force; below this value, the connection stability is considered insufficient. It is determined by a safety factor of 1.5 times the toy's weight and maximum load, or by the 5th percentile of a child disassembly force test. For example, 0.7 Newtons is used in tests on children aged 5-8. Its application is as follows: in the adsorption force error term of step S2, when the actual adsorption force is lower than this threshold, a linear penalty function is used, with the penalty value increasing linearly with the deviation.
[0059] The target adsorption force upper limit threshold refers to the maximum allowable adsorption force; values exceeding this threshold are considered difficult for children to disassemble and reassemble. It is determined by the 80th percentile of the 95th percentile in a child's disassembly force test, or by an ergonomic model. For example, the 95th percentile for children aged 5-8 is 1.2 Newtons; taking 80% yields 1.0 Newtons. Its application is as follows: in the adsorption force error term of step S2, when the actual adsorption force exceeds this threshold, an exponential penalty function is used to drastically penalize the excessive adsorption force.
[0060] In step S2, this application constructs a differentiable magnetic field solver, using parameters such as magnet position and magnetization direction as trainable variables. The loss function simultaneously incorporates a minimum spacing penalty (to prevent interference caused by magnets being too close), a uniformity penalty (to prevent uneven distribution of adsorption force), and an asymmetric adsorption force error penalty—a linear penalty is applied for values below the target lower threshold, and an exponential penalty is applied for values above the target upper threshold. This design fully considers the unique requirements of children's assembly and disassembly forces: slightly weaker adsorption force is acceptable, but excessively strong adsorption force will seriously affect safety and user experience. Through gradient descent iterative optimization, this application can automatically meet multiple engineering constraints such as magnet spacing, distribution uniformity, and a comfortable adsorption force range while ensuring connection stability, significantly outperforming traditional empirical designs.
[0061] Please see Figure 2 The flowchart for calculating the directed attribute graph and playability index is provided for embodiments of the present invention.
[0062] Step S3 further includes the following sub-steps: S3-1, construct an attribute graph with each part as a node and the relationship between the contact surfaces of the parts as edges, and initialize the node attributes according to the geometry of each part and the configured magnet parameters. S3-2, Traverse each edge in the attribute graph, determine whether the edge is a magnetic attraction connection or a mutual repulsion connection based on the magnet layout on the relative connection surface, and store the determination result of the edge as the attribute of the edge in the attribute graph. S3-3, input the attribute graph into the graph neural network. In the message passing of each layer of the graph neural network, set the message passing weight according to the magnetic connection or mutual exclusion connection attribute of the edge, so that the neighbor node information of the magnetic connection is enhanced and the neighbor node information of the mutual exclusion connection is suppressed. S3-4, after multiple layers of message passing, the graph neural network outputs the feature vector of each node, inputs the feature vector of each node into the prediction layer, and outputs the structural robustness score and reconstruction flexibility score as playability indicators.
[0063] Furthermore, in sub-step S3-2, the method for determining whether an edge is a magnetic attraction connection or a mutual repulsion connection based on the magnet layout on the relatively connected surfaces includes: Obtain the position, quantity, and magnetization direction of the magnets on the relative connection surface of the two parts connected by the edge. Calculate the magnetic polarity matching coefficient between all magnet pairs. The matching coefficient is the dot product of the magnetization direction vectors of the two magnets. Count the proportion of magnet pairs with negative matching coefficients to the total number of magnet pairs. If the proportion exceeds the preset proportion threshold, it is determined to be a magnetic attraction connection; otherwise, it is determined to be a mutual exclusion connection.
[0064] It should be noted that an attribute graph is a graph data structure built with parts as nodes and the contact surface relationships between parts as edges. Each node and edge can have multiple attributes attached.
[0065] Node attributes refer to the unique characteristics of each part node, including the part's geometry, such as a triangle or a square, and the configured magnet layout parameters, such as magnet position and magnetization direction.
[0066] Magnetic connection refers to a connection between two parts where the polarities of the magnets on their relative connection surfaces are generally attracted to each other, resulting in a stable adsorption relationship.
[0067] Mutually exclusive connection refers to a connection relationship between two parts where the magnetic polarities on the relative connection surfaces generally repel each other, making stable attraction impossible.
[0068] The magnetic polarity matching coefficient refers to the degree of attraction between two magnets on opposite surfaces, calculated based on the magnetization direction. Specifically, it is the cosine of the angle between the two magnetization direction vectors. A positive value indicates attraction, a negative value indicates repulsion, and zero indicates neutrality.
[0069] The preset ratio threshold refers to the percentage used to determine whether the proportion of attractive magnet pairs on a pair of opposing connecting surfaces meets the requirements. It is determined by the ratio of the minimum total attraction force required for the connecting surface to the maximum attraction force of a single magnet pair, combined with a safety factor. The minimum number of attractive pairs divided by the total number of magnet pairs multiplied by the safety factor (1.2~1.5) should not exceed 100%; it can also be directly set to 60%. Its application is as follows: In step S3-2, the proportion of magnet pairs with a matching coefficient greater than zero is counted to the total number of magnet pairs. If this proportion is greater than or equal to the preset ratio threshold, the edge is determined to be a magnetically attracted connection; otherwise, it is a mutually exclusive connection.
[0070] Graph Neural Networks are deep learning models specifically designed for processing graph-structured data. They learn the representation of each node by exchanging information between nodes through a message passing mechanism.
[0071] Message passing weights are coefficients multiplied when a node sends a message to its neighboring nodes in each layer of a graph neural network, used to control the influence of the message.
[0072] Enhanced delivery refers to setting the message delivery weight to a value greater than 1, which makes the information flow between two magnetically connected nodes stronger.
[0073] Suppressing message passing refers to setting the message passing weight to a positive number less than 1 or zero, which weakens the flow of information between two mutually exclusive nodes.
[0074] The structural robustness score is a numerical value that measures whether the overall structure of a magnetic toy is easily disintegrated or collapsed after a part is removed. The higher the score, the more stable the structure.
[0075] The reconfigurability score measures the degree to which a magnetic toy can be assembled into various shapes in different sequences; a higher score indicates a stronger reconfigurability.
[0076] The playability index is a comprehensive index composed of structural robustness score and reconfigurability score, used to evaluate the balance between the playability and stability of magnetic toys.
[0077] In step S3, this application models the optimized parts and magnetic relationships as a directed attribute graph, and innovatively determines the connection type (magnetic attraction or mutual repulsion) of edges by statistically analyzing the polarity matching ratio of all magnet pairs on the relatively connected surfaces, rather than relying on a single pair of magnets. This graph is then input into a graph neural network, where different weights are assigned based on the connection type during message passing: magnetic connections enhance information transmission, while mutual repulsion connections inhibit transmission. This physically guided graph neural network can automatically extract structural robustness features and reconstruction flexibility features, outputting a playability index. This application transforms the subjective, qualitative "playability" into an objective, calculable quantitative score, providing accurate feedback signals for subsequent dynamic adjustments.
[0078] Step S4 further includes the following sub-steps: S4-1, combine the adsorption force deviation, playability index deviation and the historical sequence of deviation of each connection surface in the current iteration step into a state vector, and input it into the deep deterministic policy gradient agent to realize the playability index feedback to step S2. S4-2, the deep deterministic policy gradient agent determines the magnitude of the exploration noise based on the total number of parts in the current magnetic toy, and outputs a continuous weight adjustment amount under the noise perturbation; S4-3, calculate the reward value based on the achievement of the adsorption force and playability indicators. When both are achieved, the reward value is the first preset positive value. When only one is achieved, the reward value is the second preset positive value. When neither is achieved, the reward value is negative and the absolute value of the negative value is equal to the sum of the two deviations. S4-4: The weight adjustment amount output by the agent is added to the current weight, and the state, action, reward and next state generated in this iteration are stored in the experience replay pool. During training, the agent is updated by sampling samples from large to small according to the absolute value of the temporal difference error. S4-5, repeat S4-1 to S4-4 until the adsorption force meets the preset adsorption force threshold and the playability index meets the preset playability threshold.
[0079] It should be noted that the adsorption force deviation refers to the difference between the actual adsorption force of the current connection surface and the target adsorption force. It can be positive or negative, reflecting the insufficiency or over-interference of the magnet layout in terms of connection stability.
[0080] Playability index deviation refers to the difference between the currently calculated playability index (including structural robustness score and reconfiguration flexibility score) and the target playability index.
[0081] The deviation history sequence refers to a continuous sequence of adsorption force deviation and playability index deviation recorded in the most recent several iteration steps, which is used to capture the trend of deviation changes.
[0082] The state vector is a one-dimensional array formed by concatenating the adsorption force deviation, playability index deviation, and the historical sequence of deviations from the previous preset number of steps in the current iteration step, and is used as the input to the deep reinforcement learning agent.
[0083] Deep deterministic policy gradient agent is a deep reinforcement learning model applicable to continuous action spaces, in which the actor network outputs weight adjustments and the critic network evaluates the value of the state.
[0084] Exploratory noise refers to random perturbations added when an agent outputs actions, used to explore unknown weight adjustment directions during training.
[0085] The total number of parts refers to the number of parts contained in the magnetic toy kit. It is used to adjust the amplitude of the exploration noise. The more parts there are, the more complex the state space becomes, and the greater the required exploration noise.
[0086] The weight adjustment amount refers to a real value output by the agent, which is added to the current target weight for adsorption force optimization.
[0087] Reward value is a scalar signal calculated based on the achievement of adsorption force and playability indicators. It is used to evaluate the quality of the agent's current actions and guide the agent to learn.
[0088] The first preset positive value refers to the positive reward value given when the attraction and playability indicators reach their respective preset thresholds, such as +10.
[0089] The second preset positive value refers to the positive reward value given when only one indicator is met, such as +1, and its value is less than the first preset positive value.
[0090] The experience replay pool is a data cache that stores the state, action, reward, and next state for each iteration. It is used to break the temporal correlation of data and improve training stability.
[0091] Temporal difference error refers to the gap between the critic network's estimate of the value of the current state action and the target value. The larger the absolute value, the higher the learning value of the sample.
[0092] Sampling refers to drawing samples from the experience replay pool during training in descending order of the absolute value of the temporal difference error, so that the agent pays more attention to the key experiences that have not yet been learned.
[0093] The preset adsorption force threshold refers to the range used in step S4 to determine whether the adsorption force meets the standard, including a lower limit and an upper limit. The rules for obtaining this threshold are: the lower limit is 90% of the target adsorption force or slightly higher than the target lower adsorption force threshold, and the upper limit is 102% of the target adsorption force or slightly lower than the target upper adsorption force threshold. For example, if the target adsorption force is 0.8 Newtons, the acceptable range is set to 0.78 to 0.82 Newtons. Its application is as follows: in step S4, check whether the actual adsorption force of all connected surfaces is within this range; if so, the adsorption force meets the standard.
[0094] The preset playability threshold refers to the critical value used to determine whether the playability index meets the standard, including the structural robustness score threshold and the reconfigurability flexibility score threshold. The structural robustness score threshold is determined as follows: through user testing, a score below 0.7 indicates the toy is prone to disintegration, hence 0.7 is chosen; in practice, 0.8 can be used. Its application is: if the actual structural robustness score is greater than or equal to this threshold, then structural robustness meets the standard. The reconfigurability flexibility score threshold is determined as follows: through expert evaluation, a score below 0.3 indicates a limited assembly method, hence 0.3 is chosen; in practice, 0.7 can be used. Its application is: if the actual reconfigurability flexibility score is greater than or equal to this threshold, then reconfigurability flexibility meets the standard. Both thresholds must be met for playability to be considered satisfactory.
[0095] In step S4, this application feeds back the playability index to the magnet layout optimization step, employing a deep deterministic gradient agent to achieve adaptive weight adjustment. The state vector includes not only the current adsorption force deviation and playability deviation, but also the historical sequence of deviations, enabling the agent to perceive trends. The agent automatically adjusts the exploration noise amplitude based on the total number of parts (more parts mean higher complexity and require greater exploration), outputting a continuous weight adjustment amount. The reward function is designed with three levels: high reward for achieving both criteria, low reward for achieving only one criterion, and negative reward proportional to the deviation sum for failing to achieve either. Through priority experience replay and temporal differential error guidance, the agent can quickly learn to find the optimal balance between stability and playability. This scheme fundamentally solves the contradiction of the incompatibility between the two in traditional methods.
[0096] Step S5 further includes the following sub-steps: S5-1 employs a multi-fidelity active learning strategy to train a graph neural network. S5-2, when performing dynamic drop simulation verification, uses this graph neural network as a simulation accelerator. The graph neural network receives the current scheme and outputs the maximum separation distance and collision energy of each part during the drop process. In S5-3, during the Bayesian optimization process of searching for the solution with the minimum magnet usage, the maximum separation distance and collision energy output by the graph neural network are used as safety constraints. A sampling weighting method based on prediction variance is used for the search. The solution with the minimum magnet usage is selected from the solutions that meet the safety constraints as the optimal solution, and the design results are output.
[0097] Furthermore, in sub-step S5-1, the multi-fidelity active learning strategy trains the graph neural network in the following way: the first type of simulation data is generated by sparse mesh finite element simulation, the second type of simulation data is generated by dense mesh finite element simulation, the ratio of the number of the first type of data to the number of the second type of data is 100:1, and the sampling criterion for active learning is to select the second type of data points that make the model prediction variance the largest for labeling.
[0098] Furthermore, in sub-step S5-2, the nodes of the graph neural network correspond to the parts of the magnetic toy, the node features include the magnetic layout parameters and mass distribution of the parts, and the edge features include the magnetic attraction and mechanical contact constraints between the parts.
[0099] It should be noted that the multi-fidelity active learning strategy is a method that trains a surrogate model by combining data of different accuracy levels and actively selects the most valuable data points for labeling. This method can significantly reduce simulation computation costs while ensuring prediction accuracy.
[0100] The first type of simulation data refers to low-precision but low-computational-cost data generated by finite element simulation using sparse mesh generation, which is used to quickly cover the design space.
[0101] The second type of simulation data refers to high-precision but computationally expensive data generated by finite element simulation using encrypted mesh generation, which is used to correct local prediction biases in the model.
[0102] Prediction variance refers to the statistical variance of the output value obtained by a graph neural network through multiple random samplings of the same input or through Bayesian approximation. The larger the variance, the higher the uncertainty of the model in that input region.
[0103] Simulation accelerators refer to replacing traditional finite element simulation software with pre-trained graph neural network surrogate models. Through forward propagation of the neural network, simulation results can be obtained quickly, reducing the simulation time from minutes to milliseconds.
[0104] The maximum separation distance refers to the maximum relative displacement between two originally attracted parts during a dynamic drop. Exceeding the safety threshold may cause the parts to detach completely.
[0105] Collision energy refers to the kinetic energy transferred between parts during a drop impact. Exceeding the safety threshold may cause damage to the parts or cause them to fly away.
[0106] Bayesian optimization is a global optimization algorithm based on a probabilistic surrogate model. It establishes a Gaussian process surrogate model for the objective function and uses the sampling function to determine the next sampling point. It is particularly suitable for optimization problems where the objective function is computationally expensive.
[0107] Sampling weighting based on prediction variance refers to a strategy in Bayesian optimization that uses the prediction variance of candidate solutions obtained by a surrogate model (such as a graph neural network) to adjust the sampling weights. The rules for obtaining the weighting coefficients are as follows: the weighting coefficients are directly taken as the prediction variance value, or a positive correlation function of the prediction variance (such as the square root, logarithm, etc.). A larger variance indicates higher uncertainty of the model in that region. The method of application is as follows: the weighting coefficients are multiplied by the Bayesian optimization sampling function (such as the desired improvement function) to obtain the weighted sampling function value. Then, the candidate solution with the largest weighted sampling function value is selected as the next sampling point. For example, if the prediction variance of one region is 0.1 and that of another region is 0.01, the former's sampling weight is 10 times that of the latter, thus prioritizing the exploration of regions with higher model uncertainty.
[0108] Safety constraints refer to the limit conditions set for the maximum separation distance and collision energy of parts in dynamic drop simulation. The rules for obtaining these constraints are as follows: the maximum separation distance threshold is set based on the connection surface size and swallowing safety requirements (e.g., 3 mm), and the collision energy threshold is set based on the material's impact resistance (e.g., 0.05 joules). The method of application is as follows: in step S5, the scheme is considered to have passed safety verification only if both the maximum separation distance and collision energy predicted by the graph neural network do not exceed the corresponding thresholds.
[0109] In step S5, this application introduces a multi-fidelity active learning strategy to train a graph neural network as a surrogate model for dynamic drop simulation. A large amount of low-fidelity data is generated through sparse mesh simulation to cover the design space, while a small amount of high-fidelity data is generated through dense mesh simulation to correct local accuracy. High-fidelity points with the largest prediction variance are actively selected for labeling, thereby obtaining a high-precision surrogate model at minimal cost. The network's node features include magnet layout parameters and mass, and its edge features include magnetic attraction and contact constraints, enabling millisecond-level output of maximum separation distance and collision energy. Subsequently, in Bayesian optimization, the safety indicators predicted by the network are used as constraints, and sampling weighting based on prediction variance is employed to prioritize searching regions with high model uncertainty, efficiently approximating the safety boundary. Finally, the solution with the minimum magnet usage is selected from the solutions that satisfy the safety constraints. This application moves safety verification from after design finalization to the optimization process and achieves a combination of rapid simulation and global search, significantly shortening the design cycle and ensuring product safety.
[0110] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A magnetic toy-aided design method based on AI intelligence, characterized in that, Includes the following steps: Step S1: Obtain the design constraint information of the magnetic toy and generate an initial magnet layout diagram that encodes the spatial position and magnetization direction of each magnet. Step S2: Construct a differentiable magnetic field solver with magnet layout parameters as trainable variables, and iteratively optimize the magnet layout with the adsorption force of each connecting surface as the optimization objective. Step S3: Model the parts with the optimized magnet layout and their magnetic attraction relationships as a directed attribute graph, and calculate the playability index. The edge attributes of the directed attribute graph include magnetic polarity matching features. Step S4: Feed back the playability index to step S2. Dynamically adjust the weight of the adsorption force optimization target based on the real-time deviation between the adsorption force and the playability index. Repeat steps S2 to S3 until both the adsorption force and the playability index meet their respective preset thresholds. Step S5: Taking the amount of magnets used and safety constraints as optimization objectives, perform dynamic drop simulation to verify the optimized scheme, select the optimal solution and output the design results.
2. The AI-based magnetic toy-aided design method according to claim 1, characterized in that: Step S1 further includes the following sub-steps: S1-1, Obtain the design constraint information of the magnetic toy, and encode the part shape, number of target assembly forms and applicable age range of children in the design constraint information into a condition vector; S1-2, Input the conditional vector into the diffusion model to generate an initial three-dimensional tensor. Each voxel of the three-dimensional tensor encodes whether a magnet exists at the corresponding location, the magnetization direction vector of the magnet, and the geometric dimensions. S1-3, apply magnetic circuit closure constraint to the generated initial magnet layout diagram so that on each connecting surface of each part, the magnetization direction of all magnets points to the same polarity, and the magnets on the opposite connecting surfaces of adjacent parts have opposite polarities. S1-4 When the generated initial layout violates the magnetic circuit closure constraint, it is corrected by conditional resampling during the reverse diffusion process so that the initial layout satisfies the magnetic circuit closure constraint during the generation stage.
3. The AI-based magnetic toy-aided design method according to claim 1, characterized in that: Step S2 further includes the following sub-steps: S2-1, Obtain the geometric shape and preset connection surface information of each part, and determine the initial number and candidate arrangement position of magnets on each connection surface based on the area and shape of the connection surface; S2-2, Set the minimum spacing constraint between adjacent magnets. When the spatial distance between two magnets is less than the preset distance threshold, add a repulsion penalty term to the loss function. S2-3, Set magnetic field distribution uniformity constraints. Based on the position coordinates of each magnet in the magnet layout, calculate the variance of the magnet position distribution on each connecting surface as a uniformity index. When the index is higher than the preset uniformity threshold, add a uniformity penalty term to the loss function. S2-4. During the iterative optimization process, the sum of the squares of the differences between the actual adsorption force and the target adsorption force of each connection surface is calculated as the adsorption force error term. The repulsion penalty term, uniformity penalty term and adsorption force error term are weighted and summed to form the total loss function of the current iteration step, and the gradient is used to update the magnet layout parameters.
4. The AI-based magnetic toy-aided design method according to claim 3, characterized in that, In sub-step S2-4, the adsorption force error term adopts an asymmetric form: when the actual adsorption force is lower than the target adsorption force lower threshold, a linear penalty function is used to calculate the error; when the actual adsorption force is higher than the target adsorption force upper threshold, an exponential penalty function is used to calculate the error.
5. The AI-based magnetic toy-aided design method according to claim 1, characterized in that: Step S3 further includes the following sub-steps: S3-1, construct an attribute graph with each part as a node and the relationship between the contact surfaces of the parts as edges, and initialize the node attributes according to the geometry of each part and the configured magnet parameters. S3-2, Traverse each edge in the attribute graph, determine whether the edge is a magnetic attraction connection or a mutual repulsion connection based on the magnet layout on the relative connection surface, and store the determination result of the edge as the attribute of the edge in the attribute graph. S3-3, input the attribute graph into the graph neural network. In the message passing of each layer of the graph neural network, set the message passing weight according to the magnetic connection or mutual exclusion connection attribute of the edge, so that the neighbor node information of the magnetic connection is enhanced and the neighbor node information of the mutual exclusion connection is suppressed. S3-4, after multiple layers of message passing, the graph neural network outputs the feature vector of each node, inputs the feature vector of each node into the prediction layer, and outputs the structural robustness score and reconstruction flexibility score as playability indicators.
6. The AI-based magnetic toy-aided design method according to claim 5, characterized in that, In sub-step S3-2, the method for determining whether an edge is a magnetic attraction connection or a mutual repulsion connection based on the magnet layout on the opposite connecting surfaces includes: Obtain the position, number, and magnetization direction of the magnets on the relative connection surface of the two parts connected by the edge. Calculate the magnetic polarity matching coefficient between all magnet pairs. The matching coefficient is the dot product of the magnetization direction vectors of the two magnets. Count the proportion of magnet pairs with negative matching coefficients to the total number of magnet pairs. If the proportion exceeds a preset threshold, it is determined to be a magnetic attraction connection; otherwise, it is determined to be a mutual exclusion connection.
7. The AI-based magnetic toy-aided design method according to claim 1, characterized in that: Step S4 further includes the following sub-steps: S4-1, combine the adsorption force deviation, playability index deviation and the historical sequence of deviation of each connection surface in the current iteration step into a state vector, and input it into the deep deterministic policy gradient agent to realize the playability index feedback to step S2. S4-2, the deep deterministic policy gradient agent determines the magnitude of the exploration noise based on the total number of parts in the current magnetic toy, and outputs a continuous weight adjustment amount under the noise perturbation; S4-3, calculate the reward value based on the achievement of the adsorption force and playability indicators. When both are achieved, the reward value is the first preset positive value. When only one is achieved, the reward value is the second preset positive value. When neither is achieved, the reward value is negative and the absolute value of the negative value is equal to the sum of the two deviations. S4-4: The weight adjustment amount output by the agent is added to the current weight, and the state, action, reward and next state generated in this iteration are stored in the experience replay pool. During training, the agent is updated by sampling samples from large to small according to the absolute value of the temporal difference error. S4-5, repeat S4-1 to S4-4 until the adsorption force meets the preset adsorption force threshold and the playability index meets the preset playability threshold.
8. The AI-based magnetic toy-aided design method according to claim 1, characterized in that: Step S5 further includes the following sub-steps: S5-1 employs a multi-fidelity active learning strategy to train a graph neural network. S5-2, when performing dynamic drop simulation verification, uses this graph neural network as a simulation accelerator. The graph neural network receives the current scheme and outputs the maximum separation distance and collision energy of each part during the drop process. In S5-3, during the Bayesian optimization process of searching for the solution with the minimum magnet usage, the maximum separation distance and collision energy output by the graph neural network are used as safety constraints. A sampling weighting method based on prediction variance is used for the search. The solution with the minimum magnet usage is selected from the solutions that meet the safety constraints as the optimal solution, and the design results are output.
9. The AI-based magnetic toy-aided design method according to claim 8, characterized in that, In sub-step S5-1, the multi-fidelity active learning strategy trains the graph neural network in the following way: the first type of simulation data is generated by sparse mesh finite element simulation, the second type of simulation data is generated by dense mesh finite element simulation, the ratio of the number of the first type of data to the number of the second type of data is 100:1, and the sampling criterion for active learning is to select the second type of data points that make the model prediction variance the largest for labeling.
10. The AI-based magnetic toy-aided design method according to claim 8, characterized in that, In sub-step S5-2, the nodes of the graph neural network correspond to the parts of the magnetic toy. The node features include the magnetic layout parameters and mass distribution of the parts, and the edge features include the magnetic attraction and mechanical contact constraints between the parts.