CN117666471A - Micro-line segment global smoothing method and system based on improved particle swarm genetic algorithm - Google Patents
Micro-line segment global smoothing method and system based on improved particle swarm genetic algorithm Download PDFInfo
- Publication number
- CN117666471A CN117666471A CN202311663771.4A CN202311663771A CN117666471A CN 117666471 A CN117666471 A CN 117666471A CN 202311663771 A CN202311663771 A CN 202311663771A CN 117666471 A CN117666471 A CN 117666471A
- Authority
- CN
- China
- Prior art keywords
- point
- points
- curvature
- initial
- data
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 239000002245 particle Substances 0.000 title claims abstract description 134
- 238000000034 method Methods 0.000 title claims abstract description 84
- 238000004422 calculation algorithm Methods 0.000 title claims abstract description 56
- 230000002068 genetic effect Effects 0.000 title claims abstract description 45
- 238000009499 grossing Methods 0.000 title description 14
- YTCQFLFGFXZUSN-BAQGIRSFSA-N microline Chemical compound OC12OC3(C)COC2(O)C(C(/Cl)=C/C)=CC(=O)C21C3C2 YTCQFLFGFXZUSN-BAQGIRSFSA-N 0.000 title description 2
- 238000012216 screening Methods 0.000 claims abstract 3
- 230000006870 function Effects 0.000 claims description 68
- 239000013598 vector Substances 0.000 claims description 30
- 230000035772 mutation Effects 0.000 claims description 21
- 238000004364 calculation method Methods 0.000 claims description 20
- 238000000605 extraction Methods 0.000 claims description 16
- 230000003247 decreasing effect Effects 0.000 claims description 4
- 230000008030 elimination Effects 0.000 claims description 3
- 238000003379 elimination reaction Methods 0.000 claims description 3
- 238000005457 optimization Methods 0.000 claims description 3
- 238000009825 accumulation Methods 0.000 claims 1
- 238000004519 manufacturing process Methods 0.000 abstract description 2
- 238000004590 computer program Methods 0.000 description 14
- 230000003044 adaptive effect Effects 0.000 description 11
- 230000008569 process Effects 0.000 description 5
- 238000005516 engineering process Methods 0.000 description 4
- 238000003860 storage Methods 0.000 description 4
- 238000010586 diagram Methods 0.000 description 3
- 230000008859 change Effects 0.000 description 2
- 101001121408 Homo sapiens L-amino-acid oxidase Proteins 0.000 description 1
- 102100026388 L-amino-acid oxidase Human genes 0.000 description 1
- 101100233916 Saccharomyces cerevisiae (strain ATCC 204508 / S288c) KAR5 gene Proteins 0.000 description 1
- 230000001133 acceleration Effects 0.000 description 1
- 238000004458 analytical method Methods 0.000 description 1
- 230000006378 damage Effects 0.000 description 1
- 230000007547 defect Effects 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 230000003993 interaction Effects 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000008092 positive effect Effects 0.000 description 1
- 238000003672 processing method Methods 0.000 description 1
- 238000006467 substitution reaction Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G05—CONTROLLING; REGULATING
- G05B—CONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
- G05B19/00—Programme-control systems
- G05B19/02—Programme-control systems electric
- G05B19/18—Numerical control [NC], i.e. automatically operating machines, in particular machine tools, e.g. in a manufacturing environment, so as to execute positioning, movement or co-ordinated operations by means of programme data in numerical form
- G05B19/408—Numerical control [NC], i.e. automatically operating machines, in particular machine tools, e.g. in a manufacturing environment, so as to execute positioning, movement or co-ordinated operations by means of programme data in numerical form characterised by data handling or data format, e.g. reading, buffering or conversion of data
- G05B19/4083—Adapting programme, configuration
-
- G—PHYSICS
- G05—CONTROLLING; REGULATING
- G05B—CONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
- G05B2219/00—Program-control systems
- G05B2219/30—Nc systems
- G05B2219/32—Operator till task planning
- G05B2219/32063—Adapt speed of tool as function of deviation from target rate of workpieces
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02T—CLIMATE CHANGE MITIGATION TECHNOLOGIES RELATED TO TRANSPORTATION
- Y02T90/00—Enabling technologies or technologies with a potential or indirect contribution to GHG emissions mitigation
Landscapes
- Engineering & Computer Science (AREA)
- Human Computer Interaction (AREA)
- Manufacturing & Machinery (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Automation & Control Theory (AREA)
- Feedback Control In General (AREA)
Abstract
Description
技术领域Technical Field
本发明属于机械制造工程中数控技术领域,尤其涉及一种基于改进粒子群遗传算法的微线段全局光顺方法及系统。The invention belongs to the technical field of numerical control in mechanical manufacturing engineering, and in particular relates to a micro-segment global smoothing method and system based on an improved particle swarm genetic algorithm.
背景技术Background Art
随着科技和社会的发展,工业领域对加工质量和效率提出更高的要求。自由曲线曲面被广泛应用于现代工业产品,如航空航天、汽车、电气或电子产品、家用物品等领域。但传统加工方式在加工复杂曲线曲面时,通常是根据精度要求,将要加工的曲线轨迹离散成一系列首尾相接的小线段,来逼近原始刀具的轨迹。随着现代工业技术的发展,对数控机床加工速度和加工效率提出了更高的要求,但小线段所描述的曲线轨迹在相邻线段的拐角处,其切线方向会发生突变,曲率也不连续,这就导致了刀具行进中,在通过拐角处时会发生速度波动和加速度突变,从而引起工艺系统的振动与冲击。大量研究表明对连续小线段路径进行光顺是解决上述问题的有效手段。With the development of science and technology and society, the industrial field has put forward higher requirements for processing quality and efficiency. Free curves and surfaces are widely used in modern industrial products, such as aerospace, automobiles, electrical or electronic products, household items and other fields. However, when processing complex curves and surfaces, traditional processing methods usually discretize the curve trajectory to be processed into a series of small line segments connected end to end according to the accuracy requirements to approximate the trajectory of the original tool. With the development of modern industrial technology, higher requirements are put forward for the processing speed and efficiency of CNC machine tools, but the curve trajectory described by the small line segments will have a sudden change in tangent direction and discontinuous curvature at the corners of adjacent line segments, which leads to speed fluctuations and acceleration mutations when the tool passes through the corners, thereby causing vibration and impact of the process system. A large number of studies have shown that smoothing the continuous small line segment path is an effective means to solve the above problems.
通过上述分析,现有技术存在的问题及缺陷为:现有技术没有采用将最能反应轨迹形状的反曲点、曲率极值点和弓高特征点提取出作为主特征点的方法代替原始离散数据点,使得机械加工中需处理的数据量大,拟合效率低,影响加工效率。现有的粒子群算法和遗传算法存在各自的缺点。Through the above analysis, the problems and defects of the existing technology are as follows: the existing technology does not use the method of extracting the inflection points, curvature extreme points and bow height feature points that best reflect the trajectory shape as the main feature points instead of the original discrete data points, which makes the amount of data to be processed in mechanical processing large, the fitting efficiency is low, and the processing efficiency is affected. The existing particle swarm algorithm and genetic algorithm have their own shortcomings.
发明内容Summary of the invention
为克服相关技术中存在的问题,本发明公开实施例提供了一种基于改进粒子群遗传算法的微线段全局光顺方法及系统。In order to overcome the problems existing in the related art, the disclosed embodiments of the present invention provide a micro-segment global smoothing method and system based on an improved particle swarm genetic algorithm.
所述技术方案如下:基于改进粒子群遗传算法的微线段全局光顺方法,包括:The technical solution is as follows: a micro-segment global smoothing method based on an improved particle swarm genetic algorithm, comprising:
S1,从给定的离散数据点中筛选出反曲点和曲率极值点作为主特征点,根据获取的主特征点获取弓高特征点,并将弓高特征点加入到主特征点集,通过主特征点代替原始数据点,使得数据量压缩;S1, select the inflection points and curvature extreme value points from the given discrete data points as the main feature points, obtain the bow height feature points according to the obtained main feature points, and add the bow height feature points to the main feature point set, and replace the original data points with the main feature points to compress the data volume;
S2,采用最小二乘法逼近主特征点计算得到初始控制点,以初始控制点的位置坐标构造粒子初始种群,并建立衡量拟合误差的适应度函数;S2, the initial control points are calculated by using the least squares method to approximate the main feature points, the initial particle population is constructed based on the position coordinates of the initial control points, and a fitness function is established to measure the fitting error;
S3,利用改进的粒子群遗传算法进行迭代,直到达到给定的迭代次数为止。S3, using the improved particle swarm genetic algorithm to iterate until the given number of iterations is reached.
步骤S1中,主特征点通过以下步骤进行选取:In step S1, the main feature points are selected by the following steps:
步骤1.1,反曲点的提取;Step 1.1, extraction of inflection points;
步骤1.2,曲率极值点的提取;Step 1.2, extraction of curvature extreme points;
步骤1.3,弓高特征点的提取。Step 1.3, extraction of bow height feature points.
步骤1.1中,反曲点的提取,包括:In step 1.1, the extraction of inflection points includes:
对于二维平面的离散数据点,当相邻的两个数据点的坐标的法向量的夹角为π时,则凹凸性发生变化,反之则凹凸性一致,在连续四个数据点Qj-1,Qj,Qj+1,Qj+2中,计算连续四个数据点法向量Vj,Vj+1,公式如下:For discrete data points on a two-dimensional plane, when the angle between the normal vectors of the coordinates of two adjacent data points is π, the concavity and convexity change, otherwise the concavity and convexity are consistent. Among four consecutive data points Q j-1 , Q j , Q j+1 , Q j+2 , the normal vectors V j , V j+1 of the four consecutive data points are calculated, and the formula is as follows:
式中,Vj为连续四个数据点Qj-1,Qj,Qj+1,Qj+2计算的j个法向量,Qj-1为第j个数据点的前一个数据点,Qj为第j个数据点,Qj+1为第j个数据点的连续第1个点,Qj+2为第j个数据点的连续第2个点,Vj+1为连续四个数据点Qj-1,Qj,Qj+1,Qj+2计算的j+1个法向量,θ为法向量夹角阈值,|Vj|为连续四个数据点Qj-1,Qj,Qj+1,Qj+2计算的j个绝对法向量,|Vj+1|为连续四个数据点Qj-1,Qj,Qj+1,Qj+2计算的j+1个绝对法向量;Wherein, V j is the j normal vectors calculated from four consecutive data points Q j-1 , Q j , Q j+1 , Q j+2 , Q j-1 is the previous data point of the j-th data point, Q j is the j-th data point, Q j+1 is the first consecutive point of the j-th data point, Q j+2 is the second consecutive point of the j-th data point, V j+1 is the j+1 normal vector calculated from four consecutive data points Q j-1 , Q j , Q j+1 , Q j+2 , θ is the normal vector angle threshold, |V j | is the j absolute normal vectors calculated from four consecutive data points Q j-1 , Q j , Q j+1 , Q j+2 , and |V j+1 | is the j+1 absolute normal vector calculated from four consecutive data points Q j-1 , Q j , Q j+1 , Q j+2 ;
通过设定阈值θmax,判断所求点的法向量夹角是否超过阈值,判断该所求点是否为反曲点。By setting a threshold value θ max , it is determined whether the normal vector angle of the desired point exceeds the threshold value, and whether the desired point is an inflection point.
步骤1.2中,曲率极值点的提取,包括:In step 1.2, the extraction of the extreme points of curvature includes:
遍历所有离散数据点并计算出各点的曲率ki、平均曲率kavg和最大曲率kmax;设定介于平均曲率与最大曲率之间的曲率阈值ka;若某点的曲率大于所设曲率阈值,则认为该点为曲率极值点;若某点曲率处于平均曲率与曲率阈值之间,同时该点曲率大于该点前后曲率,则该点为曲率极值点;曲率极值点的计算公式如下:Traverse all discrete data points and calculate the curvature k i , average curvature k avg and maximum curvature km a x of each point; set a curvature threshold k a between the average curvature and the maximum curvature; if the curvature of a point is greater than the set curvature threshold, the point is considered to be a curvature extreme point; if the curvature of a point is between the average curvature and the curvature threshold, and the curvature of the point is greater than the curvature before and after the point, the point is a curvature extreme point; the calculation formula for the curvature extreme point is as follows:
式中,ki为曲率,ka为曲率阈值,kavg为平均曲率,ki为曲率,ki-1为第i个点的前一点的曲率,ki+1为第i个点的后一点的曲率。In the formula, k i is the curvature, ka is the curvature threshold, k avg is the average curvature, k i is the curvature, k i-1 is the curvature of the point before the i-th point, and k i+1 is the curvature of the point after the i-th point.
步骤1.3中,弓高特征点的提取,包括:In step 1.3, the extraction of bow height feature points includes:
利用点距准则获取离散数据点中的弓高特征点,使得到的主特征点体现原始轨迹的几何特征;Mj和Mj+1反曲点的曲率极值提取完成后的两个相邻主特征点,依次计算相邻两个主特征点之间的其他数据点到线段Mj,Mj+1的最大距离dk,设置阈值为dmax,如果dk>dmax,则Qk为弓高特征点,加入主特征点集,随后在MjQk和QkMj+1之间递归计算,依次获取所有的弓高特征点,并将弓高特征点加入主要特征点集。The point distance criterion is used to obtain the bow height feature points in the discrete data points, so that the obtained main feature points reflect the geometric characteristics of the original trajectory; after the curvature extreme values of the inflection points M j and M j+1 are extracted, the two adjacent main feature points are calculated in turn, and the maximum distance d k from other data points between the two adjacent main feature points to the line segments M j , M j+1 is calculated, and the threshold is set to d max . If d k > d max , Q k is the bow height feature point and is added to the main feature point set. Subsequently, recursive calculation is performed between M j Q k and Q k M j+1 to obtain all the bow height feature points in turn, and the bow height feature points are added to the main feature point set.
在步骤S2中,采用最小二乘法逼近主特征点计算得到初始控制点,包括:In step S2, the initial control points are calculated by using the least squares method to approximate the main feature points, including:
步骤2.1,NURBS曲线的定义为:Step 2.1, the definition of NURBS curve is:
式中,C(u)为NURBS曲线基函数;ωi为与控制点相对应的权因子,首末权因子为ω0,ωn>0,其余ωi≥0;Pi为n+1个控制点,i=0,1,2…n;Ni,p(u)为p次NURBS曲线基函数,u为自变量;Where, C(u) is the basis function of the NURBS curve; ω i is the weight factor corresponding to the control point, the first and last weight factors are ω 0 , ω n > 0, and the rest are ω i ≥ 0; Pi is the n+1 control point, i = 0, 1, 2…n; Ni ,p (u) is the p-order NURBS curve basis function, and u is the independent variable;
Ni,p(u)由De Boor递推关系式计算:Ni ,p (u) is calculated by De Boor recursion relation:
式中,ui为第i个点的自变量,ui+1为第i+1个点的自变量,ui+p为第i个点p次递推的自变量,up为p次递推的自变量,ui+p+1为第i个点p+1次递推的自变量,Ni+1,p-1(u)为第i+1个点p-1次递推的NURBS曲线基函数;Wherein, ui is the independent variable of the i-th point, ui +1 is the independent variable of the i+1-th point, ui +p is the independent variable of the i-th point p-time recursion, up is the independent variable of the p-time recursion, ui+p+1 is the independent variable of the i-th point p+1-time recursion, Ni +1,p-1 (u) is the NURBS curve basis function of the i+1-th point p-1-time recursion;
步骤2.2,初始控制点的计算;采用积累弦长法将主特征点参数化,采用取整法进行节点矢量的配置;对于初始拟合数据点列M={Mk|k=1,2,3,...s},首末控制点与特征点保持一致,即P0=M0=C(0),Pn=Ms=C(1),其他数据点在最小二乘法下进行逼近,建立逼近误差平方和方程f,使逼近误差平方和方程f为最小,计算公式如下:Step 2.2, calculation of initial control points; parameterize the main feature points using the accumulated chord length method, and configure the node vector using the integer method; for the initial fitting data point sequence M = {M k | k = 1, 2, 3, ... s}, the first and last control points are consistent with the feature points, that is, P 0 = M 0 = C(0), P n = Ms = C(1), and the other data points are approximated under the least squares method, and the approximation error square sum equation f is established to minimize the approximation error square sum equation f. The calculation formula is as follows:
式中,Mk为第k节点的初始拟合数据点列,C(uk)为在uk自变量下的末控制点初始拟合数据点列,Rk为第k节点的拟合数据点列差值,Ni,p(uk)为在uk自变量下p次NURBS曲线基函数;Wherein, Mk is the initial fitting data point sequence of the kth node, C( uk ) is the initial fitting data point sequence of the final control point under the u k independent variable, Rk is the difference of the fitting data point sequence of the kth node, and Ni,p ( uk ) is the basis function of the p-th NURBS curve under the u k independent variable;
Rk=Mk-N0,p(uk)M0-Nn,p(uk)Ms,k=1,…,s-1R k =M k -N 0,p ( uk )M 0 -N n,p ( uk )M s ,k=1,...,s-1
式中,N0,p(uk)为初始节点在uk自变量下p次NURBS曲线基函数,M0为初始节点初始拟合数据点列,Nn,p(uk)为第n节点在uk自变量下p次NURBS曲线基函数,Ms为第s节点初始拟合数据点列;Wherein, N0 ,p ( uk ) is the p-order NURBS curve basis function of the initial node under the u k independent variable, M0 is the initial fitting data point sequence of the initial node, Nn,p ( uk ) is the p-order NURBS curve basis function of the n-th node under the u k independent variable, and Ms is the initial fitting data point sequence of the s-th node;
为使误差平方和方程f的值最小,令方程f相对于控制点Pi偏导数为0,得:In order to minimize the value of the error square sum equation f, let the partial derivative of equation f with respect to the control point Pi be 0, and we get:
式中,Nt,p(uk)为第t节点在uk自变量下p次NURBS曲线基函数;Where N t, p ( uk ) is the basis function of the p-th NURBS curve at the t-th node under the u k independent variable;
得到一个包含n-1个未知量的线性方程组:We get a system of linear equations with n-1 unknowns:
(NTN)P=R(N T N)P=R
其中:in:
式中,NT为T阶NURBS曲线基函数,N为NURBS曲线基函数点列,P为控制点点列,R为拟合数据点列差值点列,N1,p(u1)为第1节点在u1自变量下p次NURBS曲线基函数,Nn-1,p(us-1)为第n-1节点在us-1自变量下p次NURBS曲线基函数,P1为第1控制点,Pn-1为第n-1控制点,N1,p(u1)R1为第1节点在u1自变量下p次NURBS曲线基函数的第1拟合数据点列差值,Nn-1,p(us-1)Rs-1为第n-1节点在us-1自变量下p次NURBS曲线基函数的第s-1拟合数据点列差值。In the formula, NT is the T-order NURBS curve basis function, N is the NURBS curve basis function point sequence, P is the control point sequence, R is the fitting data point sequence difference point sequence, N1,p ( u1 ) is the p-order NURBS curve basis function of the 1st node under the u1 independent variable, Nn-1,p (u s-1 ) is the p-order NURBS curve basis function of the n-1th node under the u s-1 independent variable, P1 is the 1st control point, Pn-1 is the n-1th control point, N1,p ( u1 ) R1 is the 1st fitting data point sequence difference of the p-order NURBS curve basis function of the 1st node under the u1 independent variable, and Nn-1,p (u s-1 )Rs -1 is the s-1th fitting data point sequence difference of the p-order NURBS curve basis function of the n-1th node under the u s-1 independent variable.
在步骤S2中,以初始控制点的位置坐标构造粒子初始种群,并建立衡量拟合误差的适应度函数,包括:In step S2, the initial particle population is constructed with the position coordinates of the initial control points, and a fitness function for measuring the fitting error is established, including:
采用高斯消元法求解P,加入首末控制点,获得初始控制点集,完成初始NURBS曲线的拟合。Gaussian elimination method is used to solve P, the first and last control points are added, the initial control point set is obtained, and the fitting of the initial NURBS curve is completed.
在步骤S3中,利用改进的粒子群遗传算法进行迭代,包括:In step S3, an improved particle swarm genetic algorithm is used for iteration, including:
设置粒子群遗传算法的参数,通过将最小二乘法所得到的初始控制点的坐标随机加上[-1,1]区间内的随机值来构造初始粒子群种群,设置每个个体的初始速度分量为[-5,5]的随机值;建立合适的适应度函数来判断拟合的误差大小,同时引入线性递减惯性因子,由适应度函数方程式计算出初始各粒子适应度值,对比分析各粒子的适应度值,更新粒子的个体最佳位置和全局最佳位置;Set the parameters of the particle swarm genetic algorithm, construct the initial particle swarm population by randomly adding the coordinates of the initial control points obtained by the least squares method to a random value in the interval [-1, 1], and set the initial velocity component of each individual to a random value of [-5, 5]; establish a suitable fitness function to determine the size of the fitting error, and introduce a linear decreasing inertia factor. Calculate the initial fitness value of each particle by the fitness function equation, compare and analyze the fitness value of each particle, and update the individual optimal position and global optimal position of the particle;
在每次迭代中,对惯性因子进行更新,同时更新粒子的速度和位置,计算公式如下:In each iteration, the inertia factor is updated, and the particle's velocity and position are updated at the same time. The calculation formula is as follows:
vid(t+1)=ωvid(t)+c1r1[Pbest(t)-xid(t)]+c2r2[Pgbest(t)-xid(t)];v id (t+1)=ωv id (t)+c 1 r 1 [P best (t)-x id (t)]+c 2 r 2 [P gbest (t)-x id (t)];
xid(t+1)=xid(t)+vid(t+1);x id (t+1)=x id (t)+v id (t+1);
式中,ω为惯性因子,vid为粒子i在d维的当前速度,c1,c2均为学习因子,r1,r2为[0,1]之间的随机数,Pbest(t)为粒子i在d维的个体最优解位置,xid为粒子i在d维的当前位置,Pgbest为当前整个粒子群在d维中的全局最优解位置,ωe为终止迭代时的惯性因子值,ωs为初始迭代时的惯性因子值,t为迭代次数,vid(t+1)为粒子i在d维的第t+1次迭代的速度,xid(t+1)为粒子i在d维的第t+1次迭代的位置,tmax为最大迭代次数,ω(t)为第t次的惯性因子。In the formula, ω is the inertia factor, v id is the current speed of particle i in dimension d, c 1 and c 2 are learning factors, r 1 and r 2 are random numbers between [0, 1], P best (t) is the individual optimal solution position of particle i in dimension d, x id is the current position of particle i in dimension d, P gbest is the global optimal solution position of the entire particle swarm in dimension d, ω e is the inertia factor value at the termination of iteration, ω s is the inertia factor value at the initial iteration, t is the number of iterations, v id (t+1) is the speed of particle i in dimension d at the t+1th iteration, x id (t+1) is the position of particle i in dimension d at the t+1th iteration, t max is the maximum number of iterations, and ω(t) is the inertia factor of the tth iteration.
进一步,根据适应度函数计算各粒子适应度值,对比各粒子适应度值,按照自适应交叉概率公式选择需要交叉的个体和群体,完成个体最优交叉和群体最优交叉操作;按照自适应变异概率公式对粒子进行变异操作,产生新粒子;其中交叉采用随机交叉的方式,变异采用高斯变异的方式;计算公式如下:Furthermore, the fitness value of each particle is calculated according to the fitness function, and the fitness values of each particle are compared. The individuals and groups that need to be crossed are selected according to the adaptive crossover probability formula to complete the individual optimal crossover and group optimal crossover operations; the particles are mutated according to the adaptive mutation probability formula to generate new particles; the crossover adopts the random crossover method, and the mutation adopts the Gaussian mutation method; the calculation formula is as follows:
其中:Pc和Pm分别表示粒子交叉概率和变异概率,Pcmax表示最大交叉概率,Pmmax表示最大变异概率,favg表示粒子群的平均适应度,f′表示要交叉的粒子的适应度值,f表示要变异的粒子的适应度值。Where: Pc and Pm represent the particle crossover probability and mutation probability respectively, Pcmax represents the maximum crossover probability, Pmmax represents the maximum mutation probability, favg represents the average fitness of the particle swarm, f′ represents the fitness value of the particle to be crossed, and f represents the fitness value of the particle to be mutated.
本发明的另一目的在于提供一种基于改进粒子群遗传算法的微线段全局光顺系统,该系统通过所述的基于改进粒子群遗传算法的微线段全局光顺方法实现,该系统包括:Another object of the present invention is to provide a micro-segment global smoothing system based on an improved particle swarm genetic algorithm, which is implemented by the micro-segment global smoothing method based on the improved particle swarm genetic algorithm, and the system comprises:
主特征点提取模块,用于从给定的离散数据点中筛选出反曲点和曲率极值点作为主特征点,根据获取的主特征点获取弓高特征点,并将弓高特征点加入到主特征点集,通过主特征点来代替原始数据点使得数据量得到压缩;The main feature point extraction module is used to select inflection points and curvature extreme value points from given discrete data points as main feature points, obtain bow height feature points based on the obtained main feature points, and add the bow height feature points to the main feature point set. The main feature points are used to replace the original data points so that the data volume is compressed;
初始控制点计算模块,用于采用最小二乘法逼近主特征点计算得到初始控制点,以初始控制点的位置坐标构造粒子初始种群,并建立衡量拟合误差的适应度函数;The initial control point calculation module is used to calculate the initial control points by using the least squares method to approximate the main feature points, construct the initial particle population with the position coordinates of the initial control points, and establish a fitness function to measure the fitting error;
初始控制点优化模块,用于利用改进的粒子群遗传算法进行迭代,直到达到给定的迭代次数为止。The initial control point optimization module is used to iterate using the improved particle swarm genetic algorithm until a given number of iterations is reached.
结合上述的所有技术方案,本发明所具备的优点及积极效果为:本发明采用三次NURBS曲线拟合连续微线段轨迹。首先从给定的离散数据点中筛选出反曲点和曲率极值点作为主特征点,根据获取的主特征点获取弓高特征点,并将其加入到主特征点集,通过主特征点来代替原始数据点使得数据量得到压缩。然后采用最小二乘法逼近主特征点计算得到初始控制点,以初始控制点的位置坐标构造粒子初始种群,并建立一个衡量拟合误差的适应度函数,然后利用改进的粒子群遗传算法进行迭代,直到达到给定的迭代次数为止。本发明在压缩数据量的同时保证了较高的拟合精度。Combining all the above technical solutions, the advantages and positive effects of the present invention are as follows: the present invention adopts cubic NURBS curve to fit continuous micro-segment trajectory. First, the inflection points and curvature extreme points are selected from the given discrete data points as the main feature points, and the bow height feature points are obtained according to the obtained main feature points, and added to the main feature point set. The main feature points are used to replace the original data points so that the data volume is compressed. Then, the least squares method is used to approximate the main feature points to calculate the initial control points, and the initial particle population is constructed with the position coordinates of the initial control points, and a fitness function that measures the fitting error is established, and then the improved particle swarm genetic algorithm is used to iterate until a given number of iterations is reached. The present invention ensures a high fitting accuracy while compressing the data volume.
本发明采用将最能反应轨迹形状的反曲点、曲率极值点和弓高特征点提取出作为主特征点的方法来代替原始离散数据点,在保证拟合精度的基础上压缩了数据量,提高了拟合效率;在标准粒子群算法和遗传算法的基础上,通过引入动态自适应调整策略,设计了一种动态自适应混合算法提高了算法的进化速度和收敛精度。The present invention adopts the method of extracting the inflection points, curvature extreme points and bow height feature points that can best reflect the trajectory shape as the main feature points to replace the original discrete data points, thereby compressing the data volume and improving the fitting efficiency on the basis of ensuring the fitting accuracy; on the basis of the standard particle swarm algorithm and genetic algorithm, a dynamic adaptive hybrid algorithm is designed by introducing a dynamic adaptive adjustment strategy to improve the evolution speed and convergence accuracy of the algorithm.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本公开的实施例,并与说明书一起用于解释本公开的原理;The accompanying drawings herein are incorporated in and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the description, serve to explain the principles of the present disclosure;
图1是本发明实施例提供的基于改进粒子群遗传算法的微线段全局光顺方法流程图;1 is a flow chart of a micro-segment global smoothing method based on an improved particle swarm genetic algorithm provided by an embodiment of the present invention;
图2是本发明实施例提供的基于改进粒子群遗传算法的微线段全局光顺方法原理图;2 is a schematic diagram of a micro-segment global smoothing method based on an improved particle swarm genetic algorithm provided by an embodiment of the present invention;
图3是本发明实施例提供的计算法向量Vj、Vj+1原理图;FIG3 is a schematic diagram of a method for calculating normal vectors V j and V j+1 according to an embodiment of the present invention;
图4是本发明实施例提供的弓高特征点的提取原理图。FIG. 4 is a schematic diagram showing the principle of extracting bow height feature points provided by an embodiment of the present invention.
具体实施方式DETAILED DESCRIPTION
为使本发明的上述目的、特征和优点能够更加明显易懂,下面结合附图对本发明的具体实施方式做详细的说明。在下面的描述中阐述了很多具体细节以便于充分理解本发明。但是本发明能够以很多不同于在此描述的其他方式来实施,本领域技术人员可以在不违背本发明内涵的情况下做类似改进,因此本发明不受下面公开的具体实施的限制。In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific embodiments of the present invention are described in detail below in conjunction with the accompanying drawings. In the following description, many specific details are set forth to facilitate a full understanding of the present invention. However, the present invention can be implemented in many other ways different from those described herein, and those skilled in the art can make similar improvements without violating the connotation of the present invention, so the present invention is not limited by the specific implementation disclosed below.
本发明实施例提供的基于改进粒子群遗传算法的微线段全局光顺方法及系统创新点在于:该方法从给定的离散数据点中筛选出反曲点和曲率极值点作为主特征点,根据获取的主特征点获取弓高特征点,并将弓高特征点加入到主特征点集,通过主特征点来代替原始数据点使得数据量得到压缩;采用最小二乘法逼近主特征点计算得到初始控制点,以初始控制点的位置坐标构造粒子初始种群,并建立衡量拟合误差的适应度函数;利用改进的粒子群遗传算法进行迭代。本发明采用将最能反应轨迹形状的反曲点、曲率极值点和弓高特征点提取出作为主特征点的方法来代替原始离散数据点,在保证拟合精度的基础上压缩了数据量,提高了拟合效率。同时采用具有自适应的改进粒子群遗传算法,提高了拟合精度。The micro-line segment global smoothing method and system based on the improved particle swarm genetic algorithm provided by the embodiment of the present invention are innovative in that: the method selects inflection points and curvature extreme value points from given discrete data points as main feature points, obtains bow height feature points based on the obtained main feature points, and adds the bow height feature points to the main feature point set, and replaces the original data points with the main feature points to compress the data volume; the least squares method is used to approximate the main feature points to calculate the initial control points, and the initial particle population is constructed with the position coordinates of the initial control points, and a fitness function that measures the fitting error is established; and the improved particle swarm genetic algorithm is used for iteration. The present invention uses the method of extracting the inflection points, curvature extreme value points and bow height feature points that best reflect the shape of the trajectory as the main feature points to replace the original discrete data points, compressing the data volume on the basis of ensuring the fitting accuracy and improving the fitting efficiency. At the same time, the improved particle swarm genetic algorithm with self-adaptation is used to improve the fitting accuracy.
实施例1,如图1所示,本发明实施例提供的基于改进粒子群遗传算法的微线段全局光顺方法采用三次NURBS曲线拟合连续微线段轨迹,具体包括:Embodiment 1, as shown in FIG1 , the micro-segment global smoothing method based on the improved particle swarm genetic algorithm provided by the embodiment of the present invention adopts a cubic NURBS curve to fit the continuous micro-segment trajectory, specifically comprising:
S1,从给定的离散数据点中筛选出反曲点和曲率极值点作为主特征点,根据获取的主特征点获取弓高特征点,并将弓高特征点加入到主特征点集,通过主特征点来代替原始数据点使得数据量得到压缩;S1, select the inflection points and the curvature extreme value points from the given discrete data points as the main feature points, obtain the bow height feature points according to the obtained main feature points, and add the bow height feature points to the main feature point set, so that the data volume is compressed by replacing the original data points with the main feature points;
S2,采用最小二乘法逼近主特征点计算得到初始控制点,以初始控制点的位置坐标构造粒子初始种群,并建立衡量拟合误差的适应度函数;S2, the initial control points are calculated by using the least squares method to approximate the main feature points, the initial particle population is constructed based on the position coordinates of the initial control points, and a fitness function is established to measure the fitting error;
S3,利用改进的粒子群遗传算法进行迭代,直到达到给定的迭代次数为止。S3, using the improved particle swarm genetic algorithm to iterate until the given number of iterations is reached.
在本发明实施例步骤S1中,主特征点的选取包括:In step S1 of the embodiment of the present invention, the selection of main feature points includes:
提取出反曲点和曲率极值点作为主特征点,再根据反曲点和曲率极值点提取出弓高特征点,将其加入主特征点集。同时为保持形状完整性,需要保证其两端的离散数据点不被筛选掉,因此需要将首末离散数据点划分为主特征点。The inflection points and curvature extreme points are extracted as the main feature points, and then the bow height feature points are extracted based on the inflection points and curvature extreme points, and added to the main feature point set. At the same time, in order to maintain the integrity of the shape, it is necessary to ensure that the discrete data points at both ends are not filtered out, so the first and last discrete data points need to be divided into main feature points.
在本发明实施例步骤S2中,采用最小二乘法进行NURBS曲线拟合得到初始控制点包括:In step S2 of the embodiment of the present invention, using the least squares method to perform NURBS curve fitting to obtain initial control points includes:
在对数据点进行逼近拟合之前,首先需要确定拟合曲线相关参数,主要有拟合曲线的次数p,权因子ωi以及节点向量U。由于三次NURBS曲线在连续性上达到了C2连续,满足了工程应用上的造型需求,因此确定拟合曲线的次数为3,将权因子设定为1,控制点数量为n+1。将主特征点采用积累弦长的办法参数化,然后采用取整法进行节点矢量配置。Before approximating the data points, we first need to determine the relevant parameters of the fitting curve, mainly the degree p of the fitting curve, the weight factor ω i and the node vector U. Since the cubic NURBS curve achieves C 2 continuity in continuity and meets the modeling requirements of engineering applications, the degree of the fitting curve is determined to be 3, the weight factor is set to 1, and the number of control points is n+1. The main feature points are parameterized by the method of accumulating chord lengths, and then the node vector is configured by the integer method.
在本发明实施例步骤S3中,采用改进粒子群遗传算法对控制点进行优化:In step S3 of the embodiment of the present invention, an improved particle swarm genetic algorithm is used to optimize the control points:
设置粒子群遗传算法的参数,即种群规模和最大迭代次数。通过将最小二乘法所得到的初始控制点的坐标随机加上[-1,1]区间内的随机值来构造初始粒子群种群,设置每个个体的初始速度分量为[-5,5]的随机值。建立合适的适应度函数,同时引入线性递减惯性因子来保证粒子在前期具备较强的全局搜索能力,在后期则具备较强的局部搜索能力。由适应度函数方程式计算出初始各粒子的适应度值,对比分析各粒子的适应度值,来更新粒子的个体最佳位置和全局最佳位置。在每次迭代中,对惯性因子进行更新,同时更新粒子的速度和位置,根据适应度函数计算每个粒子的适应度值,将每个粒子的当前适应度值与迭代前的个体最优解的适应度值进行比较,如果小于则更新个体最优解,否则不更新。将每个粒子的当前适应度值与全局最优解的适应度值进行比较,如果小于则更新全局最优解,否则不更新。根据适应度函数计算各粒子适应度值,对比各粒子适应度值,按照自适应交叉概率公式选择需要交叉的个体和群体,完成个体最优交叉和群体最优交叉操作。按照自适应变异概率公式对粒子进行变异操作,产生新粒子。由适应度函数方程式计算出新粒子的适应度值,并比较适应度值来更新粒子的个体最佳位置和全局最佳位置。判断算法是否满足终止条件,若满足,则结束迭代,输出结果;否则重复进行迭代直到达到最大迭代次数。Set the parameters of the particle swarm genetic algorithm, namely the population size and the maximum number of iterations. Construct the initial particle swarm population by randomly adding a random value in the interval [-1, 1] to the coordinates of the initial control point obtained by the least squares method, and set the initial velocity component of each individual to a random value of [-5, 5]. Establish a suitable fitness function, and introduce a linearly decreasing inertia factor to ensure that the particles have a strong global search ability in the early stage and a strong local search ability in the later stage. Calculate the fitness value of each initial particle by the fitness function equation, and compare and analyze the fitness value of each particle to update the individual optimal position and the global optimal position of the particle. In each iteration, update the inertia factor, update the speed and position of the particle at the same time, calculate the fitness value of each particle according to the fitness function, compare the current fitness value of each particle with the fitness value of the individual optimal solution before the iteration, if it is less than, update the individual optimal solution, otherwise do not update. Compare the current fitness value of each particle with the fitness value of the global optimal solution, if it is less than, update the global optimal solution, otherwise do not update. Calculate the fitness value of each particle according to the fitness function, compare the fitness values of each particle, select the individuals and groups that need to cross according to the adaptive crossover probability formula, and complete the individual optimal crossover and group optimal crossover operations. Perform mutation operations on particles according to the adaptive mutation probability formula to generate new particles. Calculate the fitness value of the new particle by the fitness function equation, and compare the fitness value to update the individual optimal position and global optimal position of the particle. Determine whether the algorithm meets the termination condition. If so, end the iteration and output the result; otherwise, repeat the iteration until the maximum number of iterations is reached.
在本发明实施例中,图2提供的基于改进粒子群遗传算法的微线段全局光顺方法原理。In the embodiment of the present invention, FIG. 2 provides the principle of a micro-segment global smoothing method based on an improved particle swarm genetic algorithm.
通过上述实施例可知,现有的粒子群算法和遗传算法都存在各自的缺点,粒子群算法容易陷入局部最优解,遗传算法收敛速度慢,因此采用具有自适应的改进粒子群遗传算法来保证更快地获得最优解。It can be seen from the above embodiments that the existing particle swarm algorithm and genetic algorithm have their own shortcomings. The particle swarm algorithm is easy to fall into the local optimal solution, and the genetic algorithm converges slowly. Therefore, an improved particle swarm genetic algorithm with self-adaptation is used to ensure that the optimal solution is obtained faster.
进一步的,本发明通过将粒子群和遗传算法相结合来的方法,可以在保证原有的方法的各自优点的同时改进各自的不足。同时粒子群算法采用自适应惯性因子,可以保证算法前期具备较强的全局搜索能力,后期具备较强的局部搜索能力,防止过早陷入局部最优解。本发明提出的遗传算法采用自适应交叉变异概率,可以保证不破坏优良个体,从而提高最优解精度。Furthermore, the present invention combines the particle swarm and the genetic algorithm to improve the shortcomings of the original methods while ensuring their respective advantages. At the same time, the particle swarm algorithm adopts an adaptive inertia factor, which can ensure that the algorithm has a strong global search capability in the early stage and a strong local search capability in the later stage, thereby preventing the algorithm from falling into the local optimal solution too early. The genetic algorithm proposed by the present invention adopts an adaptive crossover mutation probability, which can ensure that excellent individuals are not destroyed, thereby improving the accuracy of the optimal solution.
实施例2,作为本发明的另一种详细实施方式,本发明实施例提供的基于改进粒子群遗传算法的微线段全局光顺方法包括:Example 2, as another detailed implementation of the present invention, the micro-segment global smoothing method based on the improved particle swarm genetic algorithm provided in the embodiment of the present invention includes:
步骤1,主特征点的选取:Step 1, selection of main feature points:
对于离散数据点集来说,选取反曲点、曲率极值点和弓高特征点作为主特征点,一般可以反映原始曲线轨迹的基本形状,反曲点和曲率极值点分别可以反映出原始轨迹的凹凸性变化和平滑性变化,而弓高特征点可以描述原始轨迹的几何特征。为保持形状完整性,需要保证其两端的离散数据点不被筛选掉,因此需要将首末离散数据点划分为主特征点。通过选取主特征点来代替离散数据点集不仅可以完整的表示轨迹形状,还可以极大地压缩数据量。针对离散数据点主特征点的提取方法如下。For the discrete data point set, selecting the inflection point, curvature extreme point and bow height feature point as the main feature point can generally reflect the basic shape of the original curve trajectory. The inflection point and curvature extreme point can respectively reflect the concavity and convexity changes and smoothness changes of the original trajectory, while the bow height feature point can describe the geometric characteristics of the original trajectory. In order to maintain the integrity of the shape, it is necessary to ensure that the discrete data points at both ends are not filtered out, so it is necessary to divide the first and last discrete data points into main feature points. By selecting the main feature points to replace the discrete data point set, not only can the trajectory shape be fully represented, but also the amount of data can be greatly compressed. The method for extracting the main feature points of discrete data points is as follows.
步骤1.1,反曲点的提取:Step 1.1, extraction of inflection points:
对于二维平面的离散数据点,当相邻的两个数据点的坐标的法向量的夹角为π时,则认为凹凸性发生了变化,反之则认为凹凸性一致。以连续四个数据点Qj-1,Qj,Qj+1,Qj+2为例,如图3所示,可计算出其法向量Vj、Vj+1。计算公式如下:For discrete data points on a two-dimensional plane, when the angle between the normal vectors of the coordinates of two adjacent data points is π, it is considered that the concavity and convexity have changed, otherwise it is considered that the concavity and convexity are consistent. Taking four consecutive data points Q j-1 , Q j , Q j+1 , Q j+2 as an example, as shown in Figure 3, their normal vectors V j and V j+1 can be calculated. The calculation formula is as follows:
式中,Vj为连续四个数据点Qj-1,Qj,Qj+1,Qj+2计算的j个法向量,Qj-1为第j个数据点的前一个数据点,Qj为第j个数据点,Qj+1为第j个数据点的连续第1个点,Qj+2为第j个数据点的连续第2个点,Vj+1为连续四个数据点Qj-1,Qj,Qj+1,Qj+2计算的j+1个法向量,θ为法向量夹角阈值,|Vj|为连续四个数据点Qj-1,Qj,Qj+1,Qj+2计算的j个绝对法向量,|Vj+1|为连续四个数据点Qj-1,Qj,Qj+1,Qj+2计算的j+1个绝对法向量;Wherein, V j is the j normal vectors calculated from four consecutive data points Q j-1 , Q j , Q j+1 , Q j+2 , Q j-1 is the previous data point of the j-th data point, Q j is the j-th data point, Q j+1 is the first consecutive point of the j-th data point, Q j+2 is the second consecutive point of the j-th data point, V j+1 is the j+1 normal vector calculated from four consecutive data points Q j-1 , Q j , Q j+1 , Q j+2 , θ is the normal vector angle threshold, |V j | is the j absolute normal vectors calculated from four consecutive data points Q j-1 , Q j , Q j+1 , Q j+2 , and |V j+1 | is the j+1 absolute normal vector calculated from four consecutive data points Q j-1 , Q j , Q j+1 , Q j+2 ;
可以自己设定一个阈值θmax,通过判断所求点的法向量夹角是否超过阈值来判断该点是否为反曲点。You can set a threshold value θ max yourself, and determine whether the point is an inflection point by judging whether the normal vector angle of the point exceeds the threshold.
步骤1.2,曲率极值点的提取:Step 1.2, extraction of curvature extreme points:
遍历所有离散数据点并计算出各点的曲率ki、平均曲率kavg和最大曲率kmax。为防止噪声等干扰因素影响曲率极值点的提取,设定一个介于平均曲率与最大曲率之间的曲率阈值ka。若某点的曲率大于所设曲率阈值,则可以认为该点为曲率极值点;若某点曲率处于平均曲率与曲率阈值之间,同时该点曲率大于该点前后曲率,则也认为该点为曲率极值点。曲率极值点的计算公式如下:Traverse all discrete data points and calculate the curvature k i , average curvature k avg and maximum curvature km a x of each point. In order to prevent interference factors such as noise from affecting the extraction of curvature extreme points, a curvature threshold k a between the average curvature and the maximum curvature is set. If the curvature of a point is greater than the set curvature threshold, the point can be considered as a curvature extreme point; if the curvature of a point is between the average curvature and the curvature threshold, and the curvature of the point is greater than the curvature before and after the point, the point is also considered as a curvature extreme point. The calculation formula for the curvature extreme point is as follows:
式中,ki为曲率,ka为曲率阈值,kavg为平均曲率,ki为曲率,ki-1为第i个点的前一点的曲率,ki+1为第i个点的后一点的曲率。In the formula, k i is the curvature, ka is the curvature threshold, k avg is the average curvature, k i is the curvature, k i-1 is the curvature of the point before the i-th point, and k i+1 is the curvature of the point after the i-th point.
步骤1.3,弓高特征点的提取,如图4所示;Step 1.3, extraction of bow height feature points, as shown in Figure 4;
利用点距准则获取离散数据点中的弓高特征点,使得得到的主特征点更能体现原始轨迹的几何特征。Mj和Mj+1反曲点的曲率极值提取完成后的两个相邻主特征点,依次计算相邻两个主特征点之间的其他数据点到线段MjMj+1的最大距离dk,设置阈值为dmax,如果dk>dmax,则Qk为弓高特征点,将其加入主特征点集,随后在MjQk和QkMj+1之间递归计算,依次获取所有的弓高特征点,并将其加入主要特征点集。The point distance criterion is used to obtain the bow height feature points in the discrete data points, so that the obtained main feature points can better reflect the geometric characteristics of the original trajectory. After the curvature extreme value of the inflection point M j and M j+1 is extracted, the maximum distance d k from other data points between the two adjacent main feature points to the line segment M j M j+1 is calculated in turn, and the threshold is set to d max . If d k > d max , Q k is the bow height feature point, and it is added to the main feature point set. Then, recursive calculation is performed between M j Q k and Q k M j+1 to obtain all the bow height feature points in turn and add them to the main feature point set.
步骤2,采用最小二乘法进行NURBS曲线拟合得到初始控制点:Step 2: Use the least squares method to fit the NURBS curve to obtain the initial control points:
步骤2.1,NURBS曲线的定义;Step 2.1, definition of NURBS curve;
NURBS即非均匀有理B样条曲线,其定义为:NURBS is a non-uniform rational B-spline curve, which is defined as:
其中:C(u)为NURBS曲线基函数,u为自变量;Pi(i=0,1,2,...,n)表示n+1个控制点;ωi为与控制点相对应的权因子,首末权因子ω0,ωn>0,其余ωi≥0;Ni,p(u)是p次NURBS曲线基函数,Ni,p(u)可由De Boor递推关系式计算:Where: C(u) is the NURBS curve basis function, u is the independent variable; Pi (i=0, 1, 2, ..., n) represents n+1 control points; ωi is the weight factor corresponding to the control point, the first and last weight factors ω0 , ωn >0, and the rest ωi≥0 ; Ni ,p (u) is the p-order NURBS curve basis function, and Ni ,p (u) can be calculated by the De Boor recursive relationship:
式中,ui为第i个点的自变量,ui+1为第i+1个点的自变量,ui+p为第i个点p次递推的自变量,up为p次递推的自变量,ui+p+1为第i个点p+1次递推的自变量,Ni+1,p-1(u)为第i+1个点p-1次递推的NURBS曲线基函数;Wherein, ui is the independent variable of the i-th point, ui +1 is the independent variable of the i+1-th point, ui +p is the independent variable of the i-th point p-time recursion, up is the independent variable of the p-time recursion, ui+p+1 is the independent variable of the i-th point p+1-time recursion, Ni +1,p-1 (u) is the NURBS curve basis function of the i+1-th point p-1-time recursion;
步骤2.2,初始控制点的计算;Step 2.2, calculation of initial control points;
首先采用积累弦长法将主特征点参数化,然后采用取整法进行节点矢量的配置。对于初始拟合数据点列M={Mk|k=1,2,3,...s},为防止首末位置出现不可控和非线性问题,首末控制点需与特征点保持一致,即P0=M0=C(0),Pn=Ms=C(1),其他数据点在最小二乘法下进行逼近,建立逼近误差平方和方程f,使逼近误差平方和f为最小,计算公式如下:First, the main feature points are parameterized using the accumulated chord length method, and then the node vectors are configured using the integer method. For the initial fitting data point sequence M = {M k | k = 1, 2, 3, ... s}, in order to prevent uncontrollable and nonlinear problems at the first and last positions, the first and last control points must be consistent with the feature points, that is, P 0 = M 0 = C(0), P n = Ms = C(1), and other data points are approximated under the least squares method, and the approximation error square sum equation f is established to minimize the approximation error square sum f. The calculation formula is as follows:
式中,Mk为第k节点的初始拟合数据点列,C(uk)为在uk自变量下的末控制点初始拟合数据点列,Rk为第k节点的拟合数据点列差值,Ni,p(uk)为在uk自变量下p次NURBS曲线基函数;Wherein, Mk is the initial fitting data point sequence of the kth node, C( uk ) is the initial fitting data point sequence of the final control point under the u k independent variable, Rk is the difference of the fitting data point sequence of the kth node, and Ni,p ( uk ) is the basis function of the p-th NURBS curve under the u k independent variable;
Rk=Mk-N0,p(uk)M0-Nn,p(uk)Ms,k=1,…,s-1R k =M k -N 0,p ( uk )M 0 -N n,p ( uk )M s ,k=1,...,s-1
式中,N0,p(uk)为初始节点在uk自变量下p次NURBS曲线基函数,M0为初始节点初始拟合数据点列,Nn,p(uk)为第n节点在uk自变量下p次NURBS曲线基函数,Ms为第s节点初始拟合数据点列;Wherein, N0 ,p ( uk ) is the p-order NURBS curve basis function of the initial node under the u k independent variable, M0 is the initial fitting data point sequence of the initial node, Nn,p ( uk ) is the p-order NURBS curve basis function of the n-th node under the u k independent variable, and Ms is the initial fitting data point sequence of the s-th node;
为使误差平方和f的值最小,令f相对于控制点Pi偏导数为0,整理得:In order to minimize the value of the sum of squared errors f, let the partial derivative of f with respect to the control point Pi be 0, and then we get:
式中,Nt,p(uk)为第t节点在uk自变量下p次NURBS曲线基函数;Where N t, p ( uk ) is the basis function of the p-th NURBS curve at the t-th node under the u k independent variable;
进一步得到一个包含n-1个未知量的线性方程组:We can further obtain a linear equation system containing n-1 unknown quantities:
(NTN)P=R;(N T N)P = R;
其中:in:
式中,NT为T阶NURBS曲线基函数,N为NURBS曲线基函数点列,P为控制点点列,R为拟合数据点列差值点列,N1,p(u1)为第1节点在u1自变量下p次NURBS曲线基函数,Nn-1,p(us-1)为第n-1节点在us-1自变量下p次NURBS曲线基函数,P1为第1控制点,Pn-1为第n-1控制点,N1,p(u1)R1为第1节点在u1自变量下p次NURBS曲线基函数的第1拟合数据点列差值,Nn-1,p(us-1)Rs-1为第n-1节点在us-自变量下p次NURBS曲线基函数的第s-1拟合数据点列差值。In the formula, NT is the T-order NURBS curve basis function, N is the NURBS curve basis function point sequence, P is the control point sequence, R is the fitting data point sequence difference point sequence, N1 ,p (u1) is the p-order NURBS curve basis function of the 1st node under the u1 independent variable, Nn-1,p (u s-1 ) is the p-order NURBS curve basis function of the n-1th node under the u s-1 independent variable, P1 is the 1st control point, Pn-1 is the n-1th control point, N1,p (u 1 ) R1 is the 1st fitting data point sequence difference of the p-order NURBS curve basis function of the 1st node under the u1 independent variable, and Nn-1,p (u s-1 )Rs -1 is the s-1th fitting data point sequence difference of the p-order NURBS curve basis function of the n-1th node under the u s- independent variable.
采用高斯消元法求解P,再加入首末控制点,即获得初始控制点集,完成初始NURBS曲线的拟合。Gaussian elimination method is used to solve P, and then the first and last control points are added to obtain the initial control point set, completing the fitting of the initial NURBS curve.
步骤3,采用改进粒子群遗传算法对控制点进行优化:Step 3: Use improved particle swarm genetic algorithm to optimize the control points:
设置粒子群遗传算法的参数,即种群规模和最大迭代次数。通过将最小二乘法所得到的初始控制点的坐标随机加上[-1,1]区间内的随机值来构造初始粒子群种群,设置每个个体的初始速度分量为[-5,5]的随机值。建立合适的适应度函数来判断拟合的误差大小,同时引入线性递减惯性因子来保证粒子在前期具备较强的全局搜索能力,在后期则具备较强的局部搜索能力,防止种群过早陷入局部最优解。由适应度函数方程式计算出初始各粒子适应度值,对比分析各粒子的适应度值,来更新粒子的个体最佳位置和全局最佳位置。Set the parameters of the particle swarm genetic algorithm, namely the population size and the maximum number of iterations. Construct the initial particle swarm population by randomly adding a random value in the interval [-1, 1] to the coordinates of the initial control point obtained by the least squares method, and set the initial velocity component of each individual to a random value of [-5, 5]. Establish a suitable fitness function to determine the size of the fitting error, and introduce a linear decreasing inertia factor to ensure that the particles have a strong global search ability in the early stage and a strong local search ability in the later stage to prevent the population from falling into the local optimal solution too early. Calculate the initial fitness value of each particle by the fitness function equation, and compare and analyze the fitness value of each particle to update the individual optimal position and global optimal position of the particle.
在每次迭代中,对惯性因子进行更新,同时更新粒子的速度和位置,计算公式如下:In each iteration, the inertia factor is updated, and the particle's velocity and position are updated at the same time. The calculation formula is as follows:
vid(t+1)=ωvid(t)+c1r1[Pbest(t)-xid(t)]+c2r2[Pgbest(t)-xid(t)];v id (t+1)=ωv id (t)+c 1 r 1 [P best (t)-x id (t)]+c 2 r 2 [P gbest (t)-x id (t)];
xid(t+1)=xid(t)+vid(t+1);x id (t+1)=x id (t)+v id (t+1);
式中,ω为惯性因子,vid为粒子i在d维的当前速度,c1,c2均为学习因子,r1,r2为[0,1]之间的随机数,Pbest(t)为粒子i在d维的个体最优解位置,xid为粒子i在d维的当前位置,Pgbest为当前整个粒子群在d维中的全局最优解位置,ωe为终止迭代时的惯性因子值,ωs为初始迭代时的惯性因子值,t为迭代次数,vid(t+1)为粒子i在d维的第t+1次迭代的速度,xid(t+1)为粒子i在d维的第t+1次迭代的位置,tmax为最大迭代次数,ω(t)为第t次的惯性因子。In the formula, ω is the inertia factor, v id is the current speed of particle i in dimension d, c 1 and c 2 are learning factors, r 1 and r 2 are random numbers between [0, 1], P best (t) is the individual optimal solution position of particle i in dimension d, x id is the current position of particle i in dimension d, P gbest is the global optimal solution position of the entire particle swarm in dimension d, ω e is the inertia factor value at the termination of iteration, ω s is the inertia factor value at the initial iteration, t is the number of iterations, v id (t+1) is the speed of particle i in dimension d at the t+1th iteration, x id (t+1) is the position of particle i in dimension d at the t+1th iteration, t max is the maximum number of iterations, and ω(t) is the inertia factor of the tth iteration.
根据适应度函数计算每个粒子的适应度值,将每个粒子的当前适应度值与迭代前的个体最优解的适应度值进行比较,如果小于则更新个体最优解,否则不更新。将每个粒子的当前适应度值与全局最优解的适应度值进行比较,如果小于则更新全局最优解,否则不更新。根据适应度函数计算各粒子适应度值,对比各粒子适应度值,按照自适应交叉概率公式选择需要交叉的个体和群体,完成个体最优交叉和群体最优交叉操作。按照自适应变异概率公式对粒子进行变异操作,产生新粒子。其中交叉采用随机交叉的方式,变异采用高斯变异的方式。计算公式如下:Calculate the fitness value of each particle according to the fitness function, compare the current fitness value of each particle with the fitness value of the individual optimal solution before the iteration, if it is less than, update the individual optimal solution, otherwise do not update. Compare the current fitness value of each particle with the fitness value of the global optimal solution, if it is less than, update the global optimal solution, otherwise do not update. Calculate the fitness value of each particle according to the fitness function, compare the fitness value of each particle, select the individuals and groups that need to cross according to the adaptive crossover probability formula, and complete the individual optimal crossover and group optimal crossover operations. Perform mutation operations on the particles according to the adaptive mutation probability formula to generate new particles. The crossover adopts the random crossover method, and the mutation adopts the Gaussian mutation method. The calculation formula is as follows:
其中:Pc和Pm分别表示粒子交叉概率和变异概率,Pcmax表示最大交叉概率,Pmmax表示最大变异概率,favg表示粒子群的平均适应度,f′表示要交叉的粒子的适应度值,f表示要变异的粒子的适应度值。通过自适应交叉变异概率可以防止破坏最优个体,从而提高拟合精度。Among them: P c and P m represent the probability of particle crossover and mutation respectively, P cmax represents the maximum probability of crossover, P mmax represents the maximum probability of mutation, f avg represents the average fitness of the particle group, f′ represents the fitness value of the particle to be crossed, and f represents the fitness value of the particle to be mutated. The adaptive crossover and mutation probability can prevent the destruction of the optimal individual, thereby improving the fitting accuracy.
由适应度函数方程式计算出新粒子的适应度值,并比较适应度值来更新粒子的个体最佳位置和全局最佳位置。判断算法是否满足终止条件,若满足,则结束迭代,输出结果;否则重复进行迭代直到达到最大迭代次数。The fitness function equation is used to calculate the fitness value of the new particle, and the fitness value is compared to update the individual optimal position and the global optimal position of the particle. Determine whether the algorithm meets the termination condition. If it does, the iteration ends and the result is output; otherwise, the iteration is repeated until the maximum number of iterations is reached.
实施例2,本发明实施例还提供一种基于改进粒子群遗传算法的微线段全局光顺系统,该系统包括:Embodiment 2: The embodiment of the present invention further provides a micro-segment global smoothing system based on an improved particle swarm genetic algorithm, the system comprising:
主特征点提取模块,用于从给定的离散数据点中筛选出反曲点和曲率极值点作为主特征点,根据获取的主特征点获取弓高特征点,并将弓高特征点加入到主特征点集,通过主特征点来代替原始数据点使得数据量得到压缩;The main feature point extraction module is used to select inflection points and curvature extreme value points from given discrete data points as main feature points, obtain bow height feature points based on the obtained main feature points, and add the bow height feature points to the main feature point set. The main feature points are used to replace the original data points so that the data volume is compressed;
初始控制点计算模块,用于采用最小二乘法逼近主特征点计算得到初始控制点,以初始控制点的位置坐标构造粒子初始种群,并建立衡量拟合误差的适应度函数;The initial control point calculation module is used to calculate the initial control points by using the least squares method to approximate the main feature points, construct the initial particle population with the position coordinates of the initial control points, and establish a fitness function to measure the fitting error;
初始控制点优化模块,用于利用改进的粒子群遗传算法进行迭代,直到达到给定的迭代次数为止。The initial control point optimization module is used to iterate using the improved particle swarm genetic algorithm until a given number of iterations is reached.
在上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述或记载的部分,可以参见其它实施例的相关描述。In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
上述装置/单元之间的信息交互、执行过程等内容,由于与本发明方法实施例基于同一构思,其具体功能及带来的技术效果,具体可参见方法实施例部分,此处不再赘述。Since the information interaction, execution process, etc. between the above-mentioned devices/units are based on the same concept as the method embodiment of the present invention, their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.
所属领域的技术人员可以清楚地了解到,为了描述的方便和简洁,仅以上述各功能单元、模块的划分进行举例说明,实际应用中,可以根据需要而将上述功能分配由不同的功能单元、模块完成,即将所述装置的内部结构划分成不同的功能单元或模块,以完成以上描述的全部或者部分功能。实施例中的各功能单元、模块可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中,上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。另外,各功能单元、模块的具体名称也只是为了便于相互区分,并不用于限制本发明的保护范围。上述系统中单元、模块的具体工作过程,可以参考前述方法实施例中的对应过程。Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated in one processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment.
本发明实施例还提供了一种计算机设备,该计算机设备包括:至少一个处理器、存储器以及存储在所述存储器中并可在所述至少一个处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现上述任意各个方法实施例中的步骤。An embodiment of the present invention further provides a computer device, which includes: at least one processor, a memory, and a computer program stored in the memory and executable on the at least one processor, wherein the processor implements the steps of any of the above-mentioned method embodiments when executing the computer program.
本发明实施例还提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机程序,所述计算机程序被处理器执行时可实现上述各个方法实施例中的步骤。An embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
本发明实施例还提供了一种信息数据处理终端,所述信息数据处理终端用于实现于电子装置上执行时,提供用户输入接口以实施如上述各方法实施例中的步骤,所述信息数据处理终端不限于手机、电脑、交换机。An embodiment of the present invention further provides an information data processing terminal, which, when executed on an electronic device, provides a user input interface to implement the steps in the above method embodiments. The information data processing terminal is not limited to mobile phones, computers, and switches.
本发明实施例还提供了一种服务器,所述服务器用于实现于电子装置上执行时,提供用户输入接口以实施如上述各方法实施例中的步骤。An embodiment of the present invention further provides a server, which is used to provide a user input interface to implement the steps in the above method embodiments when executed on an electronic device.
本发明实施例提供了一种计算机程序产品,当计算机程序产品在电子设备上运行时,使得电子设备执行时可实现上述各个方法实施例中的步骤。An embodiment of the present invention provides a computer program product. When the computer program product runs on an electronic device, the electronic device can implement the steps in the above-mentioned method embodiments when executing the computer program product.
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请实现上述实施例方法中的全部或部分流程,可以通过计算机程序来指令相关的硬件来完成,所述的计算机程序可存储于一计算机可读存储介质中,该计算机程序在被处理器执行时,可实现上述各个方法实施例的步骤。其中,所述计算机程序包括计算机程序代码,所述计算机程序代码可以为源代码形式、对象代码形式、可执行文件或某些中间形式等。所述计算机可读介质至少可以包括:能够将计算机程序代码携带到拍照装置/终端设备的任何实体或装置、记录介质、计算机存储器、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random AccessMemory,RAM)、电载波信号、电信信号以及软件分发介质。例如U盘、移动硬盘、磁碟或者光盘等。If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the camera/terminal device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a disk or an optical disk.
以上所述,仅为本发明较优的具体的实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,凡在本发明的精神和原则之内所作的任何修改、等同替换和改进等,都应涵盖在本发明的保护范围之内。The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any modifications, equivalent substitutions and improvements made by any technician familiar with the technical field within the technical scope disclosed by the present invention and within the spirit and principles of the present invention should be covered within the protection scope of the present invention.
Claims (10)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202311663771.4A CN117666471A (en) | 2023-12-06 | 2023-12-06 | Micro-line segment global smoothing method and system based on improved particle swarm genetic algorithm |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202311663771.4A CN117666471A (en) | 2023-12-06 | 2023-12-06 | Micro-line segment global smoothing method and system based on improved particle swarm genetic algorithm |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| CN117666471A true CN117666471A (en) | 2024-03-08 |
Family
ID=90082187
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202311663771.4A Pending CN117666471A (en) | 2023-12-06 | 2023-12-06 | Micro-line segment global smoothing method and system based on improved particle swarm genetic algorithm |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN117666471A (en) |
Cited By (1)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN120597462A (en) * | 2025-08-07 | 2025-09-05 | 上海建工集团股份有限公司 | Submarine cable laying simulation initial linear optimization method based on genetic algorithm |
-
2023
- 2023-12-06 CN CN202311663771.4A patent/CN117666471A/en active Pending
Cited By (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN120597462A (en) * | 2025-08-07 | 2025-09-05 | 上海建工集团股份有限公司 | Submarine cable laying simulation initial linear optimization method based on genetic algorithm |
| CN120597462B (en) * | 2025-08-07 | 2025-10-03 | 上海建工集团股份有限公司 | Submarine cable laying simulation initial linear optimization method based on genetic algorithm |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| Ng et al. | PEGASUS: A policy search method for large MDPs and POMDPs | |
| CN112069610B (en) | Injection molding process parameter optimization method for transparent complex multi-cavity plastic part | |
| CN113010954A (en) | Bridge structure damage identification method and device and terminal equipment | |
| CN107516150A (en) | A short-term wind power prediction method, device and system | |
| CN119670991B (en) | Energy storage frequency modulation instruction prediction method and system based on two-stage method | |
| CN117314078B (en) | Deadlock-free Scheduling Method for Flexible Manufacturing System Based on Petri Net and Neural Network | |
| Audoux et al. | A surrogate model based on Non-Uniform Rational B-Splines hypersurfaces | |
| Sieger et al. | A comprehensive comparison of shape deformation methods in evolutionary design optimization | |
| CN107274009A (en) | A kind of time series data multistep forecasting method and system based on correlation | |
| CN117666471A (en) | Micro-line segment global smoothing method and system based on improved particle swarm genetic algorithm | |
| CN114595577A (en) | Staged and efficient constrained optimization method and device based on kriging surrogate model | |
| WO2025092293A1 (en) | Operation method and apparatus for digital twin system of power system, and device, medium and program product | |
| Perez et al. | Gaussian process regression with Sliced Wasserstein Weisfeiler-Lehman graph kernels | |
| WO2025138759A1 (en) | Method and apparatus for predicting energy consumption of industrial robot, and device and storage medium | |
| Ukwuoma et al. | Image inpainting and classification agent training based on reinforcement learning and generative models with attention mechanism | |
| CN115049176A (en) | Material performance evaluation method and device and computer equipment | |
| CN118709560B (en) | Machine tool structure optimization method based on self-guided online learning and high-efficiency sampling | |
| CN119004956B (en) | A low-cost, reconfigurable metasurface design method with a novel topology | |
| CN119129183B (en) | A collision detection method for 3D CAD models based on BVH and sum-of-squares programming | |
| US7870180B2 (en) | Method and apparatus for nonlinear signal and data aggregation | |
| CN117371496A (en) | Parameter optimization method, device, equipment and storage medium | |
| CN116720425A (en) | Reverse design method and system for multilayer film structure and multilayer film structure | |
| CN115731372B (en) | A quality optimization method for 3D measurement point cloud of large composite components | |
| CN120356589B (en) | An intelligent optimization method for inverting structural parameters of new materials | |
| CN119849429B (en) | A rational fraction modeling method for S-parameters based on parallel vector fitting calculation |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination |