Method for automatic recognition of variable loop / recursion definitions

CN115374558BActive Publication Date: 2026-08-18GUILIN UNIV OF ELECTRONIC TECH
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210954124.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-10
Publication Date
2026-08-18
Estimated Expiration
2042-08-10

AI Technical Summary

Technical Problem

显然,该方案费时费力,缺少统一可行的自动批量识别对策,尤其是针对复杂的系统建模对象,由于需要采用人工反复试探检测,过程繁杂且效率低下,难以直接应用

Benefits of technology

[0036] (1) Compared with the prior art, this invention analyzes in principle the problem that the output model may have cyclic and recursive definitions of variables through mechanized dynamic modeling, and proposes an automatic identification method for cyclic/recursive definitions of variables. Through set theory and symbolic computation principle, it can accurately identify model variables with cyclic/recursive definitions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115374558B_ABST
    Figure CN115374558B_ABST
Patent Text Reader

Abstract

The application discloses an automatic identification method of variable circulation / recursion definition, and is used for solving the problem that the subsequent reordering cannot effectively process the variable circulation definition and recursion definition existing in the output model in the modeling process, thereby causing the model recursion calculation to be unable to continuously proceed. The algorithm disclosed by the application accurately identifies the model variable with the circulation definition or the recursion definition in an automatic identification batch processing mode through a computer software and hardware platform based on a script file output by mechanized modeling. The core algorithm is that, in combination with a set theory and a symbolic calculation principle, the model variable with the circulation definition or the recursion definition can be accurately positioned through identification of the set logical relationship between dependent variables and independent variables, and the original modeling document is returned for correction processing. The result is that the model variable can continuously proceed numerical iteration calculation. The application effectively solves the problem that the subsequent model recursion calculation cannot continuously proceed due to the variable circulation definition and the recursion definition existing in the model variable, and the automatic identification batch processing mode is used to replace the manual detection mode. The algorithm is accurate, efficient and simple to implement, and has strong engineering significance.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of mechanical system dynamics modeling technology, specifically to an automatic identification method for variable loop / recursive definitions. Background Technology

[0002] In traditional mechanical science research, dynamic models are used for characteristic simulation analysis and real-time motion control of mechanical systems; mechanized dynamic modeling is an effective method for establishing dynamic models of mechanical systems. Patent CN106383973A discloses a mechanized mechanical modeling method for nonholonomically constrained systems. Its main idea is to use the principle of forward modeling to give the implied relationships of motion variables during motion analysis, and then use a reverse output method to establish a recursive dynamic model of the system. Practice has proven that the recursive dynamic model established by patent CN106383973A can effectively reduce common defects in dynamic models such as repetitive and redundant calculations, and has high computational efficiency.

[0003] However, since human intervention is required in the motion analysis process, the output model of this method may have problems such as circular definition of variables (i.e., two or more variables are defined by referencing each other, forming a closed loop definition) and recursive definition (i.e., a single variable uses its own properties to define itself). Neither of these can effectively handle subsequent reordering, causing the model recursive calculation to be unable to continue, ultimately leading to a decrease in the reliability of mechanized dynamics modeling.

[0004] The existing solution to this problem involves substituting numerical calculations into the output model, locating the error point based on the abnormal interruption message, further manually screening for variables with loop definitions or recursive definitions, and finally returning to the original modeling document for correction. Clearly, this solution is time-consuming and labor-intensive, lacking a unified and feasible automatic batch identification strategy. Especially for complex system modeling objects, the need for repeated manual checks makes the process cumbersome and inefficient, making it difficult to apply directly. Summary of the Invention:

[0005] To address the shortcomings of existing technologies, this invention proposes an automatic identification method for circular / recursive variable definitions. The purpose of this method is to automatically identify model variables with circular or recursive definitions and return the original modeling document for technical personnel to process, thereby enabling continuous numerical iterative calculations of the model variables.

[0006] Suppose that an existing mechanical modeling method outputs a script file as a recursive dynamic model of the system, and the variables in the model may have problems with circular or recursive definitions. This invention automatically identifies the internal variables based on the script file.

[0007] This invention is achieved through the following technical solution:

[0008] An automatic identification method for variable loop / recursive definitions, such as Figure 1 As shown, the specific steps are as follows:

[0009] Step 1: Import the script file output from the modeling process and read the variables and expressions in the internal factors;

[0010] Step 2, Initialization: Define the sequence of effective variables, the sequence of effective variable expressions, and the set of dependent variables S. A The set of independent variables S B Number of recognitions i;

[0011] Step 3: Let N be the length of the effective variable sequence, and set the dependent variable set S. A The initial dimension D is equal to 1;

[0012] Step 4: Reset the recognition count i to zero;

[0013] Step 5: From the sequence of effective variables, extract D variable elements without repetition using the replacement method and place them into the dependent variable set S. A middle;

[0014] Step 6: Traverse the dependent variable set S A Each variable corresponds to an expression, and the union of the independent variables in all expressions is placed in the set of independent variables S. B middle;

[0015] Step 7, Symbolic computation: Take f A =∑{set S A Each variable}, f B =∑{set S B Each variable};

[0016] Step 8: Let Δ = f B -f A ;

[0017] Step 9: Check if any of the symbolic elements inside Δ contain the symbol "-" (negative sign);

[0018] If the symbol "-" (negative sign) exists, it indicates that the dependent variable set S A If no loop / recursive definition exists for the variable elements in the code, proceed to step 11.

[0019] If the symbol "-" (negative sign) does not exist, it means that the dependent variable set S A If the variable elements in the code have loop / recursive definitions, proceed to step 10;

[0020] Step 10: Output the set of dependent variables S AIf the variable elements in the model contain circular / recursive definitions, return the original modeling document, which will be processed by the technicians to eliminate the circular / recursive definitions of the variable elements, and proceed to step 11.

[0021] Step 11: Increment the recognition count i by 1;

[0022] Step 12: Check if the number of recognitions i is equal to the permutation and combination.

[0023] If the number of recognitions i equals This indicates that all different combinations of variables have been sampled in the current dimension, and step 13 is executed;

[0024] If the number of recognitions i is not equal to This indicates that there are still undetected variable elements in the current dimension, and we need to return to step 5;

[0025] Step 13: Detect the dependent variable set S A Is the dimension D equal to the length N of the effective variable sequence?

[0026] If dimension D equals sequence length N, it means that all variable elements have been identified, and proceed to step 15.

[0027] If dimension D is less than sequence length N, it means that the identification and detection of variable sets under all dimensions has not been completed, and step 14 is executed.

[0028] Step 14: Expand the dependent variable set S A The dimension, i.e., the set of dependent variables S A Increment the current dimension D by 1 and return to step 4;

[0029] Step 15: Output the valid variables and expressions after identification in the form of a script file;

[0030] The identification process is complete; exit the program.

[0031] At this point, there are no longer any issues with circular or recursive definitions among the variables in the output script file, resulting in a system dynamics model that can be correctly iterated and calculated, enabling continuous numerical iterative calculation of the model variables.

[0032] The core algorithm of the aforementioned automatic identification method for cyclic / recursive definitions of variables is to extract a corresponding number of model variables with replacement without repetition in different dimensions. Combining set theory and symbolic computation principles, by identifying the set logic relationship between the dependent and independent variables, it can accurately locate model variables with cyclic / recursive definitions. The technical solution provided by this invention can be effectively proven through first mathematical induction, that is, this algorithm can accurately and automatically identify model variables with recursive definitions and cyclic definitions in different dimensions.

[0033] In step 3 of the above scheme, let N be the length of the effective variable sequence, and set the dependent variable set S. A The initial dimension D is equal to 1. In this step, the dependent variable set S A When the dimension D is 1, the algorithm proposed in this invention can identify whether each variable has a recursive definition.

[0034] In the above scheme, the setting of the dependent variable set S A The initial dimension D is equal to 1, and the dependent variable set S is expanded round by round in subsequent step 14. A The purpose of this dimension is to further identify the circular definitions of multi-dimensional variables while ensuring that each model variable has no recursive definition, so as to avoid reducing the accuracy of identifying circular definitions due to the existence of recursive definitions of model variables.

[0035] The beneficial effects of this invention are:

[0036] (1) Compared with the prior art, this invention analyzes in principle the problem that the output model may have cyclic and recursive definitions of variables through mechanized dynamic modeling, and proposes an automatic identification method for cyclic / recursive definitions of variables. Through set theory and symbolic computation principle, it can accurately identify model variables with cyclic / recursive definitions.

[0037] (2) This invention uses an automatic batch processing method to replace the manual detection method, which can quickly locate model variables with loop / recursive definitions. Its algorithm is simple and efficient, with a wide coverage, and can identify loop definitions in all dimensions. It also has high recognition accuracy and obvious engineering significance. Attached Figure Description

[0038] Figure 1 The flowchart shows the algorithm for an automatic identification method for variable loop / recursion definition. Detailed implementation method:

[0039] To make the objectives, technical solutions, and advantages of this invention clearer and easier to understand, the following are provided: Figure 1 The present invention is further described in detail with reference to the following specific embodiments, but the present invention is not limited to the following embodiments.

[0040] It should be noted that the technical solution provided by this invention can be proven by the first mathematical induction method, that is, this algorithm can accurately and automatically identify model variables with recursive definitions and loop definitions of different dimensions.

[0041] Example:

[0042] This embodiment assumes that the mechanization modeling of a certain system has been completed, and generates script files of each variable and its corresponding expression by outputting in reverse order.

[0043] The output script file is shown below:

[0044]

[0045] The output model variables (a1, a2, a3...a) n a n+1 The calculations will be imported into the computer hardware system. Clearly, when calculating variable a1, its expression a3+sin(a1*a6)+7 contains its own undefined variable a1, which is a recursive definition. When calculating variables a1 and a3, they are mutually referenced, forming a closed loop definition, which is a two-dimensional circular definition. Both of these situations will cause the abnormal interruption of the model's numerical recursive calculation. Similarly, there may be circular / recursive definitions among the other variables. This scenario will prevent subsequent reordering from being handled effectively, thus causing the model's recursive calculation to fail to continue, resulting in reduced reliability of the mechanized dynamics modeling.

[0046] To address the above issues, it is necessary to detect model variables defined in loops or recursions in the script file and return the original modeling document for technical personnel to process before the model calculation can proceed smoothly.

[0047] According to the algorithm described in this invention, the computer automatically identifies the following process:

[0048] start:

[0049] Step 1: Import the script file output from the modeling process and read the variables and expressions in the internal factors;

[0050] Step 2, Initialization: Define the sequence of effective variables, the sequence of effective variable expressions, and the set of dependent variables S. A The set of independent variables S B Number of recognitions i;

[0051] Step 3: Record the length of the effective variable sequence N = n + 1 (in this embodiment, the output script file has a total of n + 1 model variables), and set the dependent variable set S. A The initial dimension D is equal to 1;

[0052] Step 4: Reset the recognition count i to zero, i.e., the current recognition count i = 0;

[0053] Dependent variable set S A Dimension D = 1:

[0054] First round of drawing:

[0055] Step 5: In the effective variable sequence, extract D variable elements without repetition using the replacement method and place them in the dependent variable set SA. Let S be the dependent variable set for this round. A ={a1};

[0056] Step 6: Traverse the dependent variable set S A Each variable corresponds to an expression, and the union of the independent variables in all expressions is placed in the set of independent variables S. B middle;

[0057] Dependent variable set S A The expression corresponding to variable a1 is: a3 + sin(a1 * a6) + 7;

[0058] Then the set of independent variables S B ={a1, a3, a6};

[0059] Step 7, Symbolic Calculation:

[0060] f A =∑{a1}=a1;

[0061] f B =∑{a1, a3, a6}=a1+a3+a6;

[0062] Step 8: Let Δ = f B -f A =a1+a3+a6-a1, that is, Δ=a3+a6;

[0063] Step 9: Check that none of the internal sign elements of Δ contain the sign "-" (negative sign), i.e., S A ∈S B This indicates that the dependent variable set S A If variable element a1 in the code has a recursive definition, proceed to step 10.

[0064] Step 10: Output the set of dependent variables S A The variable element a1 in the model is recursively defined, and the original modeling document is returned for processing by technicians.

[0065] This embodiment assumes the following modifications to the model variables:

[0066] The expression for variable a1 is modified to: a3 + sin(a6) + 7;

[0067] That is, a1 = a3 + sin(a6) + 7. Obviously, at this point, the variable a1 no longer has a recursive definition. The modified script file is shown below:

[0068]

[0069] After completing the processing, proceed to step 11;

[0070] Step 11: Increment the recognition count i by 1, that is, the current recognition count i = 1;

[0071] Step 12: The number of detections i is not equal to the permutations and combinations. This indicates that there are still undetected variable elements in the current dimension, and we need to return to step 5;

[0072] Second round of drawing:

[0073] Step 5: In the effective variable sequence, extract D variable elements without repetition using the replacement method and place them in the dependent variable set SA. Let S be the dependent variable set for this round. A ={a2};

[0074] Step 6: Traverse the dependent variable set S A Each variable corresponds to an expression, and the union of the independent variables in all expressions is placed in the set of independent variables S. B middle;

[0075] Dependent variable set S A The expression corresponding to variable a2 is: a7*cos(a n )+6a n+1 +4;

[0076] Then the set of independent variables S B ={a7, a n a n+1};

[0077] Step 7, Symbolic Calculation:

[0078] f A =∑{a2}=a2;

[0079] f B =∑{a7,a n a n+1}=a7+a n +a n+1 ;

[0080] Step 8: Let Δ = f B -f A =a7+a n +a n+1 -a2, that is, Δ=a7+a n +a n+ 1-a2;

[0081] Step 9: Detect the presence of the negative sign "-" in each of the symbolic elements inside Δ. This indicates that the dependent variable set S A If variable element a2 in the code does not have a recursive definition, proceed to step 11.

[0082] Step 11: Increment the recognition count i by 1, i.e., the current recognition count i = 2;

[0083] Step 12: The number of detections i is not equal to the permutations and combinations. This indicates that there are still undetected variable elements in the current dimension, and we need to return to step 5;

[0084]

[0085] No. Round-robin sampling:

[0086] Step 5: In the effective variable sequence, extract D variable elements without repetition using the replacement method and place them in the dependent variable set SA. Let S be the dependent variable set for this round. A ={a n+1};

[0087] Step 6: Traverse the dependent variable set S A Each variable corresponds to an expression, and the union of the independent variables in all expressions is placed in the set of independent variables S. B middle;

[0088] In the dependent variable set SA, variable a n+1 The corresponding expression is: a n +3a2+a 10 ;

[0089] Then the set of independent variables S B ={a2, a 10 a n};

[0090] Step 7, Symbolic Calculation:

[0091] f A =∑{a n+1}=a n+1 ;

[0092] f B =∑{a2, a 10 a n}=a2+a 10 +a n ;

[0093] Step 8: Let Δ = f B -f A =a2+a 10 +a n -a n+1 That is, Δ = a² + a 10 +a n -a n+1 ;

[0094] Step 9: Detect the presence of the negative sign "-" in each of the symbolic elements inside Δ. This indicates that the dependent variable set S A variable element a in n+1 No recursive definition exists, proceed to step 11;

[0095] Step 11: Increment the recognition count i by 1, that is, the current recognition count i = n + 1;

[0096] Step 12: The number of detection and recognition attempts, i, is equal to the number of permutations and combinations. This indicates that all different combinations of variables have been sampled under the current dimension D=1. The script file at this point is as follows:

[0097]

[0098] Clearly, in the dependent variable set S A With dimension D=1, the model variables no longer have recursive definitions after identification, so proceed to step 13;

[0099] Step 13: Detect the dependent variable set S A If the dimension D is less than the effective variable sequence length N, it means that the identification and detection of variable sets under all dimensions has not been completed, and step 14 is executed.

[0100] Step 14: Expand the dependent variable set S A The dimension, i.e., the set of dependent variables S A Increment the current dimension D by 1, then the current dimension D = 2, and return to step 4;

[0101] Step 4: Reset the recognition count i to zero, i.e., the current recognition count i = 0;

[0102] Dependent variable set S A Dimension D = 2:

[0103] First round of drawing:

[0104] Step 5: In the effective variable sequence, extract D variable elements without repetition using the replacement method and place them in the dependent variable set SA. Let S be the dependent variable set for this round. A ={a1, a3};

[0105] Step 6: Traverse the dependent variable set S A Each variable corresponds to an expression, and the union of the independent variables in all expressions is placed in the set of independent variables S. B middle;

[0106] The expressions for variables a1 and a3 in the dependent variable set SA are a3+sin(a6)+7 and 2(a1+a2)+3sin(a6), respectively.

[0107] Then the set of independent variables S B ={a1, a2, a3, a6};

[0108] Step 7, Symbolic Calculation:

[0109] f A =∑{a1, a3}=a1+a3;

[0110] f B =∑{a1, a2, a3, a6}=a1+a2+a3+a6;

[0111] Step 8: Let Δ = T B -f A =a1+a2+a3+a6-a1-a3, that is, Δ=a2+a6;

[0112] Step 9: Check that none of the internal sign elements of Δ contain the sign "-" (negative sign), i.e., S A ∈S B This indicates that the dependent variable set S A If the variable elements a1 and a3 in the loop are defined in a two-dimensional loop, execute step 10;

[0113] Step 10: Output the set of dependent variables S A The variable elements a1 and a3 in the model are defined in a two-dimensional loop and the original modeling document is returned for processing by technicians.

[0114] This embodiment assumes the following modifications to the model variables:

[0115] The expression for variable a1 remains unchanged, while the expression for variable a3 is modified to: 2(4a5+a2)+3sin(a6);

[0116] That is, a1 = a3 + sin(a6) + 7, a3 = 2(4a5 + a2) + 3sin(a6). Obviously, there is no longer a two-dimensional loop definition between variables a1 and a3. The modified script file is shown below:

[0117]

[0118] After completing the processing, proceed to step 11;

[0119] Step 11: Increment the recognition count i by 1, that is, the current recognition count i = 1;

[0120] Step 12: The number of detections i is not equal to the permutations and combinations. This indicates that there are still undetected variable elements in the current dimension, and we need to return to step 5;

[0121] Second round of drawing:

[0122] Step 5: In the effective variable sequence, extract D variable elements without repetition using the replacement method and place them in the dependent variable set SA. Let S be the dependent variable set for this round. A ={a1, a n};

[0123] Step 6: Traverse the dependent variable set S A Each variable corresponds to an expression, and the union of the independent variables in all expressions is placed in the set of independent variables S. B middle;

[0124] Dependent variable set S A In the variable a2, a n The corresponding expressions are: a7*cos(a n )+6a n+1 +4 and a3*a 12 +4ln(6)+a8;

[0125] Then the set of independent variables S B ={a3, a7, a8, a 12 a n a n+1};

[0126] Step 7, Symbolic Calculation:

[0127] f A =∑{a2, a n}=a2+a n ;

[0128] f B =∑{a3, a7, a8, a 12 a n a n+1}=a3+a7+a8+a 12 +a n +a n+1 ;

[0129] Step 8: Let Δ = f B -f A =a3+a7+a8+a 12 +a n +a n+1 -a2-a n That is, Δ = a3 + a7 + a8 + a 12 +a n+1 -a2;

[0130] Step 9: Detect the presence of the negative sign "-" in each of the symbolic elements inside Δ. This indicates that the dependent variable set S A The variable elements a2, a nNo two-dimensional loop definition exists; proceed to step 11.

[0131] Step 11: Increment the recognition count i by 1, i.e., the current recognition count i = 2;

[0132] Step 12: The number of detections i is not equal to the permutations and combinations. This indicates that there are still undetected variable elements in the current dimension, and we need to return to step 5;

[0133]

[0134] No. Round-robin sampling:

[0135] Step 5: In the effective variable sequence, extract D variable elements without repetition using the replacement method and place them in the dependent variable set SA. Let S be the dependent variable set for this round. A ={a2, a n+1};

[0136] Step 6: Traverse the dependent variable set S A Each variable corresponds to an expression, and the union of the independent variables in all expressions is placed in the set of independent variables S. B middle;

[0137] Dependent variable set S A In the variable a2, a n+1 The corresponding expressions are: a7*cos(a n )+6a n+1 +4 and a n +3a2+a 10 ;

[0138] Then the set of independent variables S B ={a2, a7, a 10 a n a n+1};

[0139] Step 7, Symbolic Calculation:

[0140] f A =∑{a2, a n+1}=a2+a n+1 ;

[0141] f B =∑{a2, a7, a 10 a n a n+1}=a2+a7+a 10 +a n +a n+1 ;

[0142] Step 8: Let Δ = f B-f A =a2+a7+a 10 +a n +a n+1 -a2-a n+1 That is, Δ = a7 + a 10 +a n ;

[0143] Step 9: Check that none of the internal sign elements of Δ contain the sign "-" (negative sign), i.e., S A ∈S B This indicates that the dependent variable set S A The variable elements a2, a n+1 Given a two-dimensional loop definition, proceed to step 10.

[0144] Step 10: Output the variable elements a2 and a2 in the dependent variable set SA. n+1 A two-dimensional loop definition exists, and the original modeling document is returned for processing by technicians;

[0145] This embodiment assumes the following modifications to the model variables:

[0146] The expression for variable a2 is modified to: a7*cos(a n )+6a n-2 +4, for variable a n+1 The expression is modified to: a n +7a8+a 10 ;

[0147] That is, a2 = a7 * cos(a n )+6a n-2 +4, a n+1 =a n +7a8+a 10 Clearly, at this point, variable a2 and variable a... n+1 Since there is no longer a two-dimensional loop definition, the modified script file is as follows:

[0148]

[0149] After completing the processing, proceed to step 11;

[0150] Step 11: Increment the recognition count i by 1, i.e., the current recognition count.

[0151] Step 12: The number of detection and recognition attempts, i, is equal to the number of permutations and combinations. This indicates that all different combinations of variables have been sampled under the current dimension D=2. The script file at this point is as follows:

[0152]

[0153] Clearly, in the dependent variable set S A With dimension D=2, there are no longer two-dimensional loop definitions between the model variables after the identification is completed, so proceed to step 13;

[0154] Step 13: Detect the dependent variable set S A If the dimension D is less than the effective variable sequence length N, it means that the identification and detection of variable sets under all dimensions has not been completed, and step 14 is executed.

[0155] Step 14: Expand the dependent variable set S A The dimension, i.e., the set of dependent variables S A Increment the current dimension D by 1, then the current dimension D = 3, and return to step 4;

[0156] Step 4: Reset the recognition count i to zero, i.e., the current recognition count i = 0;

[0157] Dependent variable set S A Dimension D = 3:

[0158] First round of drawing:

[0159] Step 5: In the effective variable sequence, extract D variable elements without repetition using the replacement method and place them in the dependent variable set SA. Let S be the dependent variable set for this round. A ={a2, a3, a n};

[0160] Step 6: Traverse the dependent variable set S A Each variable corresponds to an expression, and the union of the independent variables in all expressions is placed in the set of independent variables S. B middle;

[0161] Dependent variable set S A In the variables a2, a3, a n The corresponding expressions are: a7*cos(a n )+6a n-2 +4, 2(4a5+a2)+3sin(a6) and a3*a 12 +4ln(6)+a8;

[0162] Then the set of independent variables S B ={a2, a3, a5, a6, a7, a8, a 12 a n a n-2};

[0163] Step 7, Symbolic Calculation:

[0164] f A =∑{a2, a3, a n}=a2+a3+an ;

[0165] f B =∑{a2, a3, a5, a6, a7, a8, a 12 a n a n-2}=a2+a3+a5+a6+a7+a8+a 12 +a n +a n -2;

[0166] Step 8: Let Δ = f B -f A =a2+a3+a5+a6+a7+a8+a 12 +a n +a n -2-a2-a3-a n That is, Δ = a5 + a6 + a7 + a8 + a 12 +a n-2 ;

[0167] Step 9: Check that none of the internal sign elements of Δ contain the sign "-" (negative sign), i.e., S A ∈S B This indicates that the dependent variable set S A The variable elements a2, a3, a n A three-dimensional loop definition exists; proceed to step 10.

[0168] Step 10: Output the set of dependent variables S A The variable elements a2, a3, a n A 3D loop definition exists, and the original modeling document is returned for processing by technicians;

[0169] This embodiment assumes the following modifications to the model variables:

[0170] The expression for variable a2 remains unchanged. The expression for variable a3 is modified to: 2(4a5+7)+3sin(a6). The expression for variable a... n The expression is modified to: 0.8a n-1 *a 12 +4ln(6)+a8;

[0171] That is, a2 = a7 * cos(a n )+6a n-2 +4,a3=2(4a5+7)+3sin(a6),a n =0.8a n-1 *a 12 +4ln(6)+a8, obviously, at this time variables a2, a3 and a nThe three-dimensional loop definition no longer exists. The modified script file is shown below:

[0172]

[0173] After completing the processing, proceed to step 11;

[0174] Step 11: Increment the recognition count i by 1, that is, the current recognition count i = 1;

[0175] Step 12: The number of detections i is not equal to the permutations and combinations. This indicates that there are still undetected variable elements in the current dimension, and we need to return to step 5;

[0176]

[0177] (Similarly, this algorithm can also identify loop definitions in three or more dimensions.)

[0178]

[0179] As the set of dependent variables S is continuously expanded A When the dimension D is equal to the length N of the effective variable sequence, i.e., D = n + 1, and after the identification of the highest dimension variable set is completed, proceed to step 13.

[0180] Step 13: Detect the dependent variable set S A If the dimension D is equal to the length N of the effective variable sequence, it means that the identification of all variable elements has been completed, and proceed to step 15.

[0181] Step 15: After the valid variables and expressions have been identified, they will be output in the form of a script file, as shown below:

[0182]

[0183] The identification process is complete; exit the program.

[0184] The output script file will reorder and process the internal model variables before being imported into the computer hardware system platform for individual calculation and output. Clearly, after algorithmic identification, the model variables in the script file no longer have loop / recursive definitions, resulting in effective subsequent reordering processing and allowing the model's recursive calculations to continue.

[0185] From the perspective of the complexity of the implementation process, the algorithm proposed in this invention is simple and clear. It can accurately identify model variables with cyclic / recursive definitions by using set theory and symbolic computation principles. Compared with the identification method of manual trial and error, the algorithm proposed in this invention has a wider coverage, can identify cyclic definitions in all dimensions, and has high recognition accuracy.

[0186] It should be noted that although the embodiments described above are illustrative, they are not intended to limit the invention. Therefore, the invention is not limited to the specific embodiments described above. Any other embodiments obtained by those skilled in the art under the guidance of this invention without departing from its principles are considered to be within the protection scope of this invention.

Claims

1. An automatic identification method for variable loop / recursive definitions, comprising the following specific steps: Step 1: Import the script file output from the modeling process and read the variables and expressions in the internal factors; Step 2, initialization: set the sequence of active variables, the sequence of active variable expressions, the set of dependent variables S A , the set of independent variables S B , the identification number i; Step 3, Let the length of the sequence of independent variables be N and set the initial dimensionality D of the dependent variable set S equal to 1. A Step 3, Let the length of the sequence of independent variables be N and set the initial dimensionality D of the dependent variable set S equal to 1. Step 4: Reset the recognition count i to zero; Step 5, in the effective variable sequence, put back the D variable elements in the dependent variable set S A in the effective variable sequence; Step 6, traverse the set of dependent variables S A corresponding to each variable in the set of dependent variables S and place the union of the independent variables in the set of independent variables S B corresponding to each variable in the set of dependent variables S and place the union of the independent variables in the set of independent variables S Step 7, Symbolic Calculation: Take , ; Step 8, let ; Step 9, Detection Does each of the internal symbolic elements contain a symbol? (minus sign); If the symbol "" exists (A negative sign indicates that the set of dependent variables S) A If no loop / recursive definition exists for the variable elements in the code, proceed to step 11. If the symbol " does not exist" (A negative sign indicates that the set of dependent variables S) A If the variable elements in the code have loop / recursive definitions, proceed to step 10; Step 10: Output the set of dependent variables S A If the variable elements in the model contain circular / recursive definitions, return the original modeling document, which will be processed by the technicians to eliminate the circular / recursive definitions of the variable elements, and proceed to step 11. Step 11: Increment the recognition count i by 1; Step 12: Check if the number of recognitions i is equal to the permutation and combination. ; If the number of recognitions i equals If this is true, it means that all different combinations of variables have been sampled in the current dimension, and step 13 is executed. If the number of recognitions i is not equal to If so, it means that there are still undetected variable elements in the current dimension, and we need to return to step 5; Step 13: Detect the dependent variable set S A Is the dimension D equal to the length N of the effective variable sequence? If dimension D equals sequence length N, it means that all variable elements have been identified, and proceed to step 15. If dimension D is less than sequence length N, it means that the identification and detection of variable sets under all dimensions has not been completed, and step 14 is executed. Step 14: Expand the dependent variable set S A The dimension, i.e., the set of dependent variables S A Increment the current dimension D by 1 and return to step 4; Step 15: Output the valid variables and expressions after identification in the form of a script file; The identification process is complete; exit the program.

2. The automatic identification method for variable loop / recursive definition according to claim 1, characterized in that: Its core algorithm is to extract a corresponding number of model variables with replacement without repetition under different dimensions. Combining set theory and symbolic computation principles, it can accurately locate model variables with cyclic / recursive definitions by identifying the set logic relationship between dependent and independent variables.

3. The automatic identification method for variable loop / recursive definition according to claim 1, characterized in that: In step 3, let N be the length of the effective variable sequence, and set the dependent variable set S. A The initial dimension D is equal to 1. In this step, the dependent variable set S A When the dimension D is 1, it is possible to identify whether each variable has a recursive definition.

4. The automatic identification method for variable loop / recursive definition according to claims 1 and 3, characterized in that: The set of dependent variables S is set. A The initial dimension D is equal to 1, and the dependent variable set S is expanded round by round in subsequent step 14. A Dimensions.

Citation Information

Patent Citations

  • Mechanical modeling method for nonholonomic constraint system

    CN106383973A

  • Compound expression intelligent analytic method based on operator variable recursion recognition technology

    CN103488609A

  • Principal component analysis multivariable decision-making tree-based connection manner identification method

    CN105335752A