CN116663660A - One-dimensional blanking method based on genetic evaluation genetic algorithm - Google Patents

One-dimensional blanking method based on genetic evaluation genetic algorithm Download PDF

Info

Publication number
CN116663660A
CN116663660A CN202310652588.8A CN202310652588A CN116663660A CN 116663660 A CN116663660 A CN 116663660A CN 202310652588 A CN202310652588 A CN 202310652588A CN 116663660 A CN116663660 A CN 116663660A
Authority
CN
China
Prior art keywords
gene
chromosome
genes
individual
flag
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
Application number
CN202310652588.8A
Other languages
Chinese (zh)
Inventor
李鑫
薛桂香
王辉
陈宇昂
苗敬礼
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hebei University of Technology
Original Assignee
Hebei University of Technology
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Hebei University of Technology filed Critical Hebei University of Technology
Priority to CN202310652588.8A priority Critical patent/CN116663660A/en
Publication of CN116663660A publication Critical patent/CN116663660A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/12Computing arrangements based on biological models using genetic models
    • G06N3/126Evolutionary algorithms, e.g. genetic algorithms or genetic programming
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q10/00Administration; Management
    • G06Q10/04Forecasting or optimisation specially adapted for administrative or management purposes, e.g. linear programming or "cutting stock problem"
    • GPHYSICS
    • G16INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR SPECIFIC APPLICATION FIELDS
    • G16BBIOINFORMATICS, i.e. INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR GENETIC OR PROTEIN-RELATED DATA PROCESSING IN COMPUTATIONAL MOLECULAR BIOLOGY
    • G16B20/00ICT specially adapted for functional genomics or proteomics, e.g. genotype-phenotype associations
    • YGENERAL 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
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02PCLIMATE CHANGE MITIGATION TECHNOLOGIES IN THE PRODUCTION OR PROCESSING OF GOODS
    • Y02P90/00Enabling technologies with a potential contribution to greenhouse gas [GHG] emissions mitigation
    • Y02P90/30Computing systems specially adapted for manufacturing

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Theoretical Computer Science (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Biophysics (AREA)
  • Business, Economics & Management (AREA)
  • Evolutionary Biology (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Strategic Management (AREA)
  • Genetics & Genomics (AREA)
  • Human Resources & Organizations (AREA)
  • Economics (AREA)
  • General Physics & Mathematics (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Mathematical Physics (AREA)
  • Development Economics (AREA)
  • Computing Systems (AREA)
  • Evolutionary Computation (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Chemical & Material Sciences (AREA)
  • Analytical Chemistry (AREA)
  • Proteomics, Peptides & Aminoacids (AREA)
  • Biotechnology (AREA)
  • Medical Informatics (AREA)
  • Spectroscopy & Molecular Physics (AREA)
  • Computational Linguistics (AREA)
  • General Engineering & Computer Science (AREA)
  • Biomedical Technology (AREA)
  • Game Theory and Decision Science (AREA)
  • Artificial Intelligence (AREA)
  • Physiology (AREA)
  • Entrepreneurship & Innovation (AREA)
  • Marketing (AREA)
  • Operations Research (AREA)
  • Quality & Reliability (AREA)
  • Tourism & Hospitality (AREA)

Abstract

本发明为一种基于基因评价遗传算法的一维下料方法,通过将基因材料随机组合,可以直观地了解到每个基因的构成,同时也知道每根钢筋如何进行切割,在解码上花销的时间也就降低了,通过对染色体中的每一个基因进行评分,进而挑选出优秀的基因进行变异,最终更容易更快地得到最优解;利用新的变异方式,使得对个体的评估时间降低,加快了算法的收敛速度。

The present invention is a one-dimensional blanking method based on gene evaluation genetic algorithm. By randomly combining genetic materials, one can intuitively understand the composition of each gene, and at the same time know how to cut each steel bar, and spend a lot of money on decoding. The time is also reduced. By scoring each gene in the chromosome, and then selecting excellent genes for mutation, it is easier and faster to obtain the optimal solution; using the new mutation method, the evaluation time of the individual is reduced. decrease, which speeds up the convergence speed of the algorithm.

Description

一种基于基因评价遗传算法的一维下料方法A One-Dimensional Blanking Method Based on Gene Evaluation Genetic Algorithm

技术领域technical field

本方法涉及一维下料组合优化领域,更具体地涉及遗传算法在一维下料问题领域的研究。The method relates to the field of combination optimization of one-dimensional blanking, and more specifically relates to the research of genetic algorithm in the field of one-dimensional blanking.

背景技术Background technique

随着中国的工业化和城市化的不断推进,越来越多的领域需要钢铁的支撑,特别是钢筋的使用与日俱增。钢筋优化断料是指在满足结构设计要求的前提下,通过对钢筋长度进行合理的切割,尽量减少钢筋的浪费,提高钢筋利用率的过程。这里要特别说明,钢筋优化断料属于一维下料。传统的钢筋优化断料方法是人工进行计算,根据设计图纸上的长度要求,手工计算出每根钢筋的长度,再进行切割。这种方法的缺点是效率低、易出错、耗费时间和人力成本较高,而且不能保证最优解。现代一维下料方法利用计算机技术和优化算法,通过对钢筋长度、材质、规格等因素进行建模和计算,从而得出最优的断料方案,减少钢筋的浪费。With the continuous advancement of China's industrialization and urbanization, more and more fields need the support of steel, especially the increasing use of steel bars. Rebar optimization cutting refers to the process of reducing the waste of rebar and improving the utilization rate of rebar through reasonable cutting of rebar length under the premise of meeting the structural design requirements. It should be specially explained here that the optimal cutting of steel bars belongs to one-dimensional cutting. The traditional method of optimizing the cutting of steel bars is to calculate manually. According to the length requirements on the design drawings, the length of each steel bar is manually calculated, and then cut. The disadvantages of this method are low efficiency, error-prone, time-consuming and high labor costs, and the optimal solution cannot be guaranteed. The modern one-dimensional blanking method uses computer technology and optimization algorithms to model and calculate the length, material, specification and other factors of steel bars, so as to obtain the optimal cutting plan and reduce the waste of steel bars.

近几十年来,针对一维下料问题,国内在1997年提出用遗传算法求解一维下料问题,之后提出混合遗传算法、改进自适应遗传算法。其中魏凉良等人的一维下料问题的改进自适应遗传算法引入降序最优适应策略,提高了算法的求解精度,缺点是降序最优适应策略使得对每个个体的评估时间大大增加。之后国内学者祝胜兰等人在一维下料问题的优化算法研究中,证明遗传算法适用于大规模情形,但缺点是在基因变异方面有所不足。最近几年李斌、彭瑶瑶等学者发表的求解一维下料问题的改进混合遗传算法、基于扩张-收缩机制的遗传算法求解一维下料问题等文献,其方法使得种群样本更加丰富,容易求得最优解,但也增大了对计算机内存资源的消耗。In recent decades, for the one-dimensional blanking problem, a genetic algorithm was proposed in 1997 in China to solve the one-dimensional blanking problem, and then a hybrid genetic algorithm and an improved adaptive genetic algorithm were proposed. Among them, the improved adaptive genetic algorithm of Wei Liangliang et al. introduced the descending optimal adaptation strategy for the one-dimensional blanking problem, which improved the solution accuracy of the algorithm. The disadvantage is that the descending optimal adaptation strategy greatly increases the evaluation time for each individual. Later, domestic scholars such as Zhu Shenglan proved that the genetic algorithm is suitable for large-scale situations in the study of the optimization algorithm of the one-dimensional cutting problem, but the disadvantage is that it is insufficient in gene variation. In recent years, Li Bin, Peng Yaoyao and other scholars have published literatures such as improved hybrid genetic algorithm for solving one-dimensional blanking problem, and genetic algorithm based on expansion-shrinkage mechanism for solving one-dimensional blanking problem. The methods make the population samples more abundant and easy to obtain The optimal solution, but it also increases the consumption of computer memory resources.

发明内容Contents of the invention

为了克服现有技术的上述缺陷,本发明提出了一种基于基因评价遗传算法来求解一维下料问题,传统的一维下料遗传算法只注重对染色体进行适应度评价,本发明通过对染色体中的每一个基因进行评分,进而挑选出优秀的基因进行变异,从而解决上述背景技术中存在的缺点。In order to overcome the above-mentioned defects of the prior art, the present invention proposes a genetic algorithm based on gene evaluation to solve the one-dimensional blanking problem. The traditional one-dimensional blanking genetic algorithm only pays attention to the fitness evaluation of chromosomes. Each gene in the gene is scored, and then an excellent gene is selected for mutation, so as to solve the shortcomings in the above-mentioned background technology.

本发明采用的技术方案为:The technical scheme adopted in the present invention is:

一种基于基因评价遗传算法的一维下料方法,所述下料方法包括以下步骤:A kind of one-dimensional blanking method based on gene evaluation genetic algorithm, described blanking method comprises the following steps:

S1、输入原材料长度Len、需要的钢筋零件长度l1,l2,···,ls、数量de1,de2,···,des、迭代轮数R、交叉概率pc、变异概率pm、收敛速率c,种群规模n,其中零件长度和数量一一对应,称可以使用的钢筋零件长度和数量信息为基因材料,以零件长度作为基因中的元素,de1,de2,···,des的值均小于等于Len,s为零件长度的种类数;S1. Input the raw material length Len, the length of the required reinforcement parts l 1 ,l 2 ,···,l s , the quantity de 1 ,de 2 ,···,de s , the number of iterations R, the crossover probability p c , the mutation Probability p m , convergence rate c, population size n, where the length and quantity of parts correspond one-to-one, the information on the length and quantity of rebar parts that can be used is called genetic material, and the length of parts is used as the element in the gene, de 1 , de 2 , ···, the value of de s is less than or equal to Len, and s is the number of types of part length;

S2、根据S1中的基因材料对种群进行初始化操作,并进行随机组合编码,具体过程是:S2. Initialize the population according to the genetic material in S1, and perform random combination coding. The specific process is:

S21、d1,d2,···,ds表示不同长度的零件实时数量,初始时令d1,d2,···,ds等于步骤S1输入的de1,de2,···,des;L表示原材料剩余长度,初始时令L等于Len;S21, d 1 , d 2 ,···,d s represent the real-time quantities of parts of different lengths, the initial order d 1 ,d 2 ,···,d s is equal to de 1 ,de 2 ,··· inputted in step S1 , de s ; L represents the remaining length of the raw material, and L is equal to Len at the initial stage;

S22、判断出d1,d2,···,ds中哪些值大于0;S22. Determine which values among d 1 , d 2 ,...,d s are greater than 0;

S23、判断出l1,l2,···,ls中哪些值小于等于L;S23. Determine which values among l 1 , l 2 ,...,l s are less than or equal to L;

S24、挑选出同时满足步骤S22和步骤S23的基因材料;S24. Select the genetic material that satisfies both step S22 and step S23;

S25、从步骤S24得到的结果中随机挑选一个lr,将其所对应的dr减1并且更新原材料剩余长度L,即在原材料剩余长度L中减去所挑选的一个零件的长度;S25. Randomly select an l r from the results obtained in step S24, subtract 1 from its corresponding d r and update the remaining length L of the raw material, that is, subtract the length of a selected part from the remaining length L of the raw material;

S26、紧接着重复执行S22-S25,直至原材料剩余长度L小于d1,d2,···,ds中不为0的l1,l2,···,ls中的最小值或者d1,d2,···,ds都等于0,记录此时随机挑选出的零件长度,分别记为lx,ly,···,lzS26, followed by repeating S22-S25 until the remaining length L of the raw material is less than the minimum value of l 1 , l 2 ,...,l s that is not 0 in d 1 , d 2 ,...,d s or d 1 , d 2 ,···,d s are all equal to 0, record the lengths of the parts randomly selected at this time, denoted as l x ,ly y ,···,l z respectively;

S27、将挑选出的lx,ly,···,lz与稳定标志位和复制标志位三部分共同组合成为个体染色体的一个基因,两个标志位在基因刚被组合起来的时候均置为False,两个标志位在基因被拆解后消失,但基因中的元素不会消失;S27. Combining the selected l x , ly , . Set to False, the two flags will disappear after the gene is disassembled, but the elements in the gene will not disappear;

S28、选取多根原材料,重复执行S22-S27,直至d1,d2,···,ds都等于0,得到的众多基因组合成为个体染色体,实现随机组合编码;S28. Select multiple raw materials, and repeat S22-S27 until d 1 , d 2 ,...,d s are all equal to 0, and the obtained genes are combined into individual chromosomes, realizing random combination coding;

S29、执行n次S21-S28,完成种群的初始化,其中n为种群规模;S29. Execute n times of S21-S28 to complete the initialization of the population, where n is the population size;

S3、依交叉概率pc进行交叉操作;S3. Perform a crossover operation according to the crossover probability p c ;

S4、对种群中每个个体染色体的每个基因进行评分:找到个体中所有稳定标志位为False的基因,将每个稳定标志位为False的基因中的所有元素相加求和为suml,suml就是基因评分,选择出基因评分最大值的基因进行变异操作,选择个体染色体中基因评分最小值,利用基因评分最小值计算个体的适应度值,适应度函数f为:S4. Score each gene of each individual chromosome in the population: find all genes whose stable flags are False in the individual, add and sum all elements in each gene whose stable flag is False to form suml, suml It is the gene score, select the gene with the maximum gene score for mutation operation, select the minimum value of the gene score in the individual chromosome, and use the minimum value of the gene score to calculate the fitness value of the individual, the fitness function f is:

f(k,minsuml)=(k-1)*Len+minsumlf(k,minsuml)=(k-1)*Len+minsuml

其中:k为个体染色体中基因的个数,minsuml为个体染色体中最小的suml,Len为原材料长度;Among them: k is the number of genes in the individual chromosome, minsuml is the smallest suml in the individual chromosome, and Len is the length of the raw material;

S5、若达到进化条件,则输出最优解,若没有达到进化条件,则根据适应度值按选择概率选择需要进行下一轮迭代的个体,适应度值越小被选择的概率越大。S5. If the evolution condition is met, the optimal solution is output. If the evolution condition is not met, the individual to be selected for the next round of iteration is selected according to the fitness value according to the selection probability. The smaller the fitness value, the greater the probability of being selected.

进一步地,所述进化条件为:是否达到了迭代次数R或者种群中所有个体染色体的所有基因的稳定标志位和复制标志位都置为True。Further, the evolution condition is: whether the number of iterations R is reached or whether the stability flag and the replication flag of all genes of all individual chromosomes in the population are set to True.

进一步地,所述步骤S3包括以下分步骤:Further, the step S3 includes the following sub-steps:

S31、随机生成一个0-1的小数,如果随机生成的小数小于交叉概率pc,则执行S32、S33,如果大于等于pc,则什么都不做;S31. Randomly generate a decimal number of 0-1. If the randomly generated decimal number is less than the crossover probability p c , execute S32 and S33. If it is greater than or equal to p c , do nothing;

S32、从种群中任意挑选两个个体;S32. Randomly select two individuals from the population;

S33、从两个个体中分别任意挑选一个稳定标志位为False的基因进行交叉操作;S33. Randomly select a gene whose stable flag is False from two individuals to perform crossover operation;

其中交叉操作为:设A染色体要得到B染色体的b基因,B染色体要得到A染色体的a基因,则判断A染色体里所有稳定标志位为False的基因和a基因拆解开来能否组成一个交叉过来的b基因,如果能,则在小范围内拆解那些A染色体里可以组成b基因的基因,如果已拆解的基因能组成B染色体中的b基因,则不继续拆解A染色体;之后组合一个b基因且令b基因的稳定标志位和复制标志位为False,拆解下的剩余基因材料按照步骤S22至步骤S28进行组合直至使用完拆解下的基因材料;如果不能组成一个交叉过来的b基因则什么都不做;同样的,对B染色体执行相同的操作。The crossover operation is as follows: if the A chromosome needs to obtain the b gene of the B chromosome, and the B chromosome needs to obtain the a gene of the A chromosome, then it is judged whether all the genes whose stable flags are False in the A chromosome and the a gene can be disassembled to form a If the b gene that crossed over can be dismantled in a small range, the genes that can form the b gene in the A chromosome will be disassembled. If the disassembled gene can form the b gene in the B chromosome, then the disassembly of the A chromosome will not continue; Then combine a b gene and set the stable flag and replication flag of the b gene to False, and combine the remaining genetic material according to steps S22 to S28 until the disassembled genetic material is used; if a cross cannot be formed The incoming b gene does nothing; similarly, it does the same for the B chromosome.

进一步地,所述变异操作包括:Further, the mutation operation includes:

获得个体染色体的每个基因评分后,将基因评分进行由大到小排列;选择基因评分最大的基因,如果有多个相同最大的suml值基因,则任选其中一个基因;判断所选择的基因否满足变异条件,如果满足条件,则进行变异操作,否则什么都不做;After obtaining each gene score of an individual chromosome, arrange the gene scores from large to small; select the gene with the largest gene score, if there are multiple genes with the same maximum suml value, select one of the genes; judge the selected gene Whether the mutation condition is met, if the condition is met, the mutation operation is performed, otherwise nothing is done;

其中变异条件为:首先判断当前迭代轮数r是否小于等于R/10,如果是,紧接着判断选中的基因的suml值是否等于Len,如果是,则进行变异操作;如果当前迭代轮数r大于R/10,接着判断选中的基因的suml值是否大于等于L-c*r*(Len/10),如果是,则进行变异操作;其余情况什么都不做;The mutation condition is: first judge whether the current iteration number r is less than or equal to R/10, if yes, then judge whether the suml value of the selected gene is equal to Len, if yes, perform the mutation operation; if the current iteration number r is greater than R/10, then judge whether the suml value of the selected gene is greater than or equal to L-c*r*(Len/10), if so, perform the mutation operation; do nothing in other cases;

当前迭代轮数满足变异条件的基因为待变异基因,将待变异基因的稳定标志位和复制标志位都置为True,之后将个体染色体中所有稳定标志位为False的基因拆解,然后从拆解后基因材料中选择与待变异基因中的元素相同的基因材料进行复制并将复制出来的基因的稳定标志位和复制标志位同样置为True,直至不能复制为止,待变异基因是否能被复制主要是看所拆解下来的基因材料是否能够组合成标志位均为True的基因,如果能被组合,则可复制,如果不能被组合,则不可复制;剩余基因材料按照步骤S22至步骤S28进行组合,形成新的稳定标志位和复制标志位都为False的基因,直至使用完拆解下的基因材料。The gene whose number of current iterations meets the mutation condition is the gene to be mutated, and the stable flag and the replication flag of the gene to be mutated are both set to True, and then all the genes whose stable flags are False in the individual chromosomes are dismantled, and then from the dismantled After decomposing, select the same genetic material as the element in the gene to be mutated to copy and set the stable flag and copy flag of the copied gene to True until it cannot be copied. Whether the gene to be mutated can be copied It mainly depends on whether the disassembled genetic material can be combined into a gene whose flag bits are all True. If it can be combined, it can be copied; Combine to form a new gene whose stability flag and replication flag are both False, until the disassembled genetic material is used up.

进一步地,所述根据适应度值按选择概率选择需要进行下一轮迭代的个体的具体过程是:将适应度值由小到大排列,根据排名用指数函数确定选择概率,排名第i的个体染色体的选择概率为pi,其中pi=m·(1-m)i-1,i=1,2,···,n,m为小于1的常数,根据选择概率选择个体染色体进行迭代。Further, the specific process of selecting individuals who need to undergo the next round of iteration according to the selection probability according to the fitness value is: arrange the fitness values from small to large, determine the selection probability according to the ranking with an exponential function, and the i-th individual Chromosome selection probability is pi, where pi=m·(1-m) i-1 , i=1,2,···,n, m is a constant less than 1, and individual chromosomes are selected for iteration according to the selection probability.

所述m=4/n。Said m=4/n.

与现有技术相比,本发明的有益效果为:Compared with prior art, the beneficial effect of the present invention is:

(1)传统的一维下料遗传算法只注重对染色体进行适应度评价,本发明通过对染色体中的每一个基因进行评分,进而挑选出优秀的基因进行变异,最终更容易更快地得到最优解。(1) The traditional one-dimensional blanking genetic algorithm only pays attention to the fitness evaluation of chromosomes. The present invention scores each gene in the chromosome, and then selects excellent genes for mutation, and finally obtains the best genes more easily and faster. Excellent solution.

(2)本发明采用随机组合编码方式,改进了传统一维下料遗传算法中的染色体的编码方式,避免了不合法基因的产生。传统的编码方式为:对所有原材料进行编号为同样地,对所有零件进行编号/>随机从/>个数字中选取个数字来构成个体的染色体编码,如(3,5,2,···,3)就为一个个体的染色体编码,表示第1号零件排在第3号原材料上,第2号零件排在第5号原材料上,第3号零件排在第2号原材料上,……,第/>号零件排在第3号原材料上。传统编码方式在解码的时候会造成时间的巨大消耗,例如在钢筋优化断料中需要知道每根钢筋的切割方式,此时需要将染色体解码,而解码的时间复杂度与零件编号/>成正比。在本申请中,通过将基因材料随机组合,可以直观地了解到每个基因的构成,同时也知道每根钢筋如何进行切割,在解码上花销的时间也就降低了。(2) The present invention adopts a random combination coding method, improves the chromosome coding method in the traditional one-dimensional blanking genetic algorithm, and avoids the generation of illegal genes. The traditional coding method is: code all raw materials as Similarly, number all parts /> random from /> choose from numbers numbers to form the chromosome code of an individual, such as (3,5,2,...,3) is the chromosome code of an individual, indicating that the No. 1 part is arranged on the No. 3 raw material, and the No. 2 part is arranged on On the No. 5 raw material, the No. 3 part is arranged on the No. 2 raw material, ..., No. /> Part No. 3 ranks on Raw Material No. 3. The traditional coding method will cause a huge time consumption when decoding. For example, in the optimization of steel bar cutting, it is necessary to know the cutting method of each steel bar. At this time, the chromosome needs to be decoded, and the time complexity of decoding is related to the part number /> Proportional. In this application, by randomly combining genetic materials, one can intuitively understand the composition of each gene, and at the same time know how to cut each steel bar, and the time spent on decoding is also reduced.

(3)本发明通过所提出的变异方式,使得对个体的评估时间降低,加快了算法的收敛速度。(3) The present invention reduces the evaluation time of the individual through the proposed variation method, and accelerates the convergence speed of the algorithm.

附图说明Description of drawings

图1为基于基因评价遗传算法的一维下料方法流程图;Fig. 1 is the flow chart of one-dimensional blanking method based on genetic algorithm of genetic evaluation;

图2为种群染色体示意图,图中省略了稳定标志位和复制标志位;Figure 2 is a schematic diagram of population chromosomes, in which the stable markers and replication markers are omitted;

图3是A染色体交叉示意图,图中省略了稳定标志位和复制标志位;Figure 3 is a schematic diagram of A chromosome crossover, in which the stable flag and the replication flag are omitted;

图4是B染色体交叉示意图,图中省略了稳定标志位和复制标志位;Figure 4 is a schematic diagram of B chromosome crossover, in which the stable flag and the replication flag are omitted;

图5为变异操作示意图,图中省略了稳定标志位和复制标志位;Figure 5 is a schematic diagram of the mutation operation, in which the stable flag and the copy flag are omitted;

图6为染色体中的一个基因示意图。Fig. 6 is a schematic diagram of a gene in a chromosome.

具体实施方式Detailed ways

下面对本发明的具体实施方式进行描述,以便于本技术领域的技术人员理解本发明,但应该清楚,本发明不限于具体实施方式的范围,对本技术领域的普通技术人员来讲,只要各种变化在所附的权利要求限定和确定的本发明的精神和范围内,这些变化是显而易见的,一切利用本发明构思的发明创造均在保护之列。Specific embodiments of the present invention are described below so that those skilled in the art can understand the present invention, but it should be clear that the present invention is not limited to the scope of specific embodiments, and for those of ordinary skill in the art, as long as various changes Within the spirit and scope of the present invention defined and determined by the appended claims, these changes are obvious, and all inventions and creations using the concept of the present invention are included in the protection list.

如图1所示,基于基因评价遗传算法的一维下料方法,包括步骤S1-S8:As shown in Figure 1, the one-dimensional blanking method based on genetic evaluation genetic algorithm comprises steps S1-S8:

S1、输入原材料长度Len、需要的钢筋零件长度l1,l2,···,ls、数量de1,de2,···,des、迭代轮数R、交叉概率pc、变异概率pm、收敛速率c,种群规模n,其中零件长度和数量一一对应,称可以使用的钢筋零件长度和数量信息为基因材料,以零件长度作为基因中的元素,de1,de2,···,des的值均小于等于原材料长度Len(单位cm),s为零件长度的种类数。S1. Input the raw material length Len, the length of the required reinforcement parts l 1 ,l 2 ,···,l s , the quantity de 1 ,de 2 ,···,de s , the number of iterations R, the crossover probability p c , the mutation Probability p m , convergence rate c, population size n, where the length and quantity of parts correspond one by one, the length and quantity information of steel parts that can be used is called genetic material, and the length of parts is used as the element in the gene, de 1 , de 2 , ···, the value of de s is less than or equal to the length of raw material Len (unit cm), and s is the number of types of part length.

在本发明的一个可选实例中,令Len=1000、l1=512、l2=321、l3=128、l4=247、l5=290、de1=6、de2=8、de3=5、de4=10、de5=4、pc=0.2、pm=0.2、n=50、R=300、c=0.01。In an optional example of the present invention, let Len=1000, l 1 =512, l 2 =321, l 3 =128, l 4 =247, l 5 =290, de 1 = 6, de 2 =8, de 3 =5, de 4 =10, de 5 =4, p c =0.2, p m =0.2, n=50, R=300, c=0.01.

S2、根据S1中的基因材料对种群进行初始化操作。S2. Initialize the population according to the genetic material in S1.

在本发明的一个可选实例中,基于步骤S1中的信息进行初始化操作,得到的初始化结果可以用图2表示。In an optional example of the present invention, the initialization operation is performed based on the information in step S1, and the obtained initialization result can be shown in FIG. 2 .

步骤S2包括以下分步骤:Step S2 includes the following sub-steps:

S21、d1,d2,···,ds表示不同长度的零件实时数量,初始时令d1,d2,···,ds等于步骤S1输入的de1,de2,···,des;L表示原材料剩余长度,初始时令L等于Len;S21, d 1 , d 2 ,···,d s represent the real-time quantities of parts of different lengths, the initial order d 1 ,d 2 ,···,d s is equal to de 1 ,de 2 ,··· inputted in step S1 , de s ; L represents the remaining length of the raw material, and L is equal to Len at the initial stage;

在本发明的一个可选实例中,初始时有6个512、8个321、5个128、10个247、4个290的基因材料。In an alternative embodiment of the invention, initially there are 6 512, 8 321, 5 128, 10 247, 4 290 genetic material.

在本发明的一个可选实例中,初始时令L等于1000。In an optional example of the present invention, the initial time L is equal to 1000.

S22、判断出d1,d2,···,ds中哪些值大于0;S22. Determine which values among d 1 , d 2 ,...,d s are greater than 0;

在本发明的一个可选实例中,初始时6、8、5、10、4都大于0。In an optional example of the present invention, 6, 8, 5, 10, and 4 are all greater than 0 initially.

S23、判断出l1,l2,···,ls中哪些值小于等于L;S23. Determine which values among l 1 , l 2 ,...,l s are less than or equal to L;

在本发明的一个可选实例中,初始时512、321、128、247、290都小于1000。In an optional example of the present invention, 512, 321, 128, 247, and 290 are all less than 1000 initially.

S24、挑选出同时满足步骤S22和步骤S23的基因材料;S24. Select the genetic material that satisfies both step S22 and step S23;

在本发明的一个可选实例中,初始时6个512、8个321、5个128、10个247、4个290的基因材料都被选中。In an optional example of the present invention, 6 512, 8 321, 5 128, 10 247, and 4 290 genetic materials are all selected initially.

S25、从步骤S24得到的结果中随机挑选一个lr,将其所对应的dr减1并且更新原材料剩余长度L,即在原材料剩余长度L中减去所挑选的一个零件的长度,更新方式为L=L-lrS25. Randomly select an l r from the results obtained in step S24, subtract 1 from its corresponding d r and update the remaining length L of raw materials, that is, subtract the length of a selected part from the remaining length L of raw materials, and update the method is L=Ll r ;

在本发明的一个可选实例中,初始时选中512,则d1减1变为5,原材料剩余长度L减512变为488。这时基因材料变为5个512、8个321、5个128、10个247、4个290。In an optional example of the present invention, 512 is selected initially, then d 1 minus 1 becomes 5, and the remaining length L of the raw material minus 512 becomes 488. At this time, the genetic material becomes 5 512, 8 321, 5 128, 10 247, and 4 290.

S26、紧接着重复执行S22-S25,直至原材料剩余长度L小于d1,d2,···,ds中不为0的l1,l2,···,ls中的最小值或者d1,d2,···,ds都等于0,记录此时随机挑选出的零件长度,分别记为lx,ly,···,lzS26, followed by repeating S22-S25 until the remaining length L of the raw material is less than the minimum value of l 1 , l 2 ,...,l s that is not 0 in d 1 , d 2 ,...,d s or d 1 , d 2 ,···,d s are all equal to 0, record the lengths of the parts randomly selected at this time, denoted as l x ,ly y ,···,l z respectively;

在本发明的一个可选实例中,步骤S22判断5、8、5、10、4都大于0,步骤S23判断321、128、247、290小于488,步骤S24判断8个321、5个128、10个247、4个290的基因材料被选中,步骤S25选中321,则d2减1变为7、原材料剩余长度L减321变为167,这时基因材料变为5个512、7个321、5个128、10个247、4个290。紧接着S22判断5、7、5、10、4都大于0,步骤S23判断128小于167,步骤S24判断5个128的基因材料被选中,步骤S25选中128,则d3减1变为4、原材料剩余长度L减128变为39,这时基因材料变为5个512、7个321、4个128、10个247、4个290。此时原材料剩余长度L的值为39,512、321、128、247、290均大于39,1个基因的lx,ly,lz选择完毕。In an optional example of the present invention, step S22 judges that 5, 8, 5, 10, and 4 are all greater than 0, step S23 judges that 321, 128, 247, and 290 are less than 488, and step S24 judges that 8 321, 5 128, 10 genetic materials of 247 and 4 genetic materials of 290 are selected, step S25 selects 321, then d 2 minus 1 becomes 7, and the remaining length of raw material L minus 321 becomes 167, at this time the genetic material becomes 5 512 and 7 321 , 5 128, 10 247, 4 290. Then S22 judges that 5, 7, 5, 10, and 4 are all greater than 0, step S23 judges that 128 is less than 167, step S24 judges that five genetic materials of 128 are selected, and step S25 selects 128, then d3 minus 1 becomes 4, The remaining length L of the raw material minus 128 becomes 39. At this time, the genetic material becomes 5 pieces of 512, 7 pieces of 321, 4 pieces of 128, 10 pieces of 247, and 4 pieces of 290. At this time, the value of the remaining length L of the raw material is 39, 512, 321, 128, 247, and 290 are all greater than 39, and the selection of l x , ly , l z of one gene is completed.

这里解释原材料剩余长度L小于d1,d2,···,ds中不为0的l1,l2,···,ls中的最小值的含义。假如此时原材料剩余长度L为250,基因材料为2个512,0个321,0个128,0个247,6个290,则d1,d2,···,ds中不为0的l1,l2,···,ls中的最小值是290,290大于250,挑选基因的lx,ly,···,lz过程结束。Here, the meaning that the remaining length L of the raw material is less than the minimum value among l 1 , l 2 , ..., l s that are not 0 among d 1 , d 2 , ..., d s is explained. If the remaining length L of raw materials is 250 at this time, and the genetic material is 2 pieces of 512, 0 pieces of 321, 0 pieces of 128, 0 pieces of 247, and 6 pieces of 290, then d 1 , d 2 ,...,d s are not 0 The minimum value of l 1 ,l 2 ,···,l s is 290, and if 290 is greater than 250, the process of selecting genes l x ,ly y ,···,l z ends.

S27、将挑选出的lx,ly,···,lz与稳定标志位和复制标志位三部分共同组合成为个体染色体的一个基因,两个标志位在基因刚被组合起来的时候置为False,两个标志位在基因被拆解后消失,但lx,ly,···,lz等基因材料不会消失,其中x,y,···,z等于1,2,···,s中的值。两个标志位在基因形成的时候产生,在基因拆解的时候消失。基因中lx,ly,···,lz的排序按照随机选取的先后顺序排列。S27. Combining the selected l x , ly , . If it is False, the two flags will disappear after the gene is disassembled, but the genetic materials such as l x , ly ,···,l z will not disappear, where x,y,···,z are equal to 1,2, ···, the value in s. Two markers are produced when the gene is formed and disappear when the gene is dismantled. The sequence of l x , ly , ... , l z in the gene is arranged according to the order of random selection.

在本发明的一个可选实例中,512、321、128、值为False的稳定标志位、值为False的复制标志位组合成为1个基因,如图6所示。In an optional example of the present invention, 512, 321, 128, a stable flag with a value of False, and a replication flag with a value of False are combined into one gene, as shown in FIG. 6 .

S28、选取多根原材料,重复执行S22-S27,直至d1,d2,···,ds都等于0,得到的众多基因组合成为个体的染色体。S28. Select a plurality of raw materials, and repeat S22-S27 until d 1 , d 2 ,···,d s are all equal to 0, and the obtained multiple genes are combined to form individual chromosomes.

在本发明的一个可选实例中,其中一个个体的染色体中有1个247基因,1个512、321基因,1个321、321、247基因,1个321、247、247基因,1个290、128、512基因,1个247、247、247、247基因,1个247、321、128、128基因,1个290、321、290基因,2个321、128、512基因,1个512、247基因,1个512、290基因,这些基因组合成了一个个体的染色体。In an optional example of the present invention, one individual has 1 247 gene, 1 512, 321 gene, 1 321, 321, 247 gene, 1 321, 247, 247 gene, 1 290 gene in the chromosome of an individual , 128, 512 genes, 1 247, 247, 247, 247 genes, 1 247, 321, 128, 128 genes, 1 290, 321, 290 genes, 2 321, 128, 512 genes, 1 512, 247 genes, 1 512, 290 genes, these genes form an individual chromosome.

S29、执行n次S21-S28,完成种群的初始化,实现随机组合编码,其中n为种群规模。S29. Execute S21-S28 n times to complete the initialization of the population and realize random combination coding, wherein n is the population size.

S3、依交叉概率pc进行交叉操作。S3. Perform a crossover operation according to the crossover probability p c .

在本发明的一个可选实例中,交叉操作如图3和图4所示。In an optional example of the present invention, the interleaving operation is as shown in FIG. 3 and FIG. 4 .

步骤S3包括以下分步骤:Step S3 includes the following sub-steps:

S31、随机生成一个0-1的小数,如果随机生成的小数小于交叉概率pc,则执行S32、S33,如果大于等于pc,则什么都不做;S31. Randomly generate a decimal number of 0-1. If the randomly generated decimal number is less than the crossover probability p c , execute S32 and S33. If it is greater than or equal to p c , do nothing;

在本发明的一个可选实例中,本次随机生成的小数是0.18,决定继续执行步骤S32、S33。In an optional example of the present invention, the randomly generated decimal this time is 0.18, and it is decided to continue to execute steps S32 and S33.

S32、从种群中任意挑选两个个体;S32. Randomly select two individuals from the population;

S33、从两个个体中分别任意挑选一个稳定标志位为False的基因进行交叉操作。S33. Randomly select a gene whose stable flag bit is False from two individuals to perform a crossover operation.

其中交叉操作为:设A染色体(图3)要得到B染色体(图4)的b基因,B染色体要得到A染色体的a基因,则判断A染色体里所有稳定标志位为False的基因和a基因拆解开来能否组成一个交叉过来的b基因,如果能,则在小范围内拆解那些可以组成b基因的基因,其余基因不拆解。所述小范围指拆解时可通过依次扫描的方式进行判断,若选择的需要拆解的基因能够组成b基因,则不需要再拆解其他基因,也就是仅在小范围内进行拆解即可。之后组合一个b基因且令b基因的稳定标志位和复制标志位为False,拆解下的剩余基因材料按照步骤S22至步骤S28进行组合直至使用完拆解下的基因材料,如果不能组成一个交叉过来的b基因则什么都不做。同样的,对B染色体执行相同的操作。本申请的操作方式不会产生不合格的基因。Wherein, the crossover operation is as follows: set the A chromosome (Fig. 3) to obtain the b gene of the B chromosome (Fig. 4), and the B chromosome to obtain the a gene of the A chromosome, then judge all genes and a genes whose stable flags are False in the A chromosome Can it be disassembled to form a cross-over b gene? If so, those genes that can form b gene will be disassembled in a small range, and the rest of the genes will not be disassembled. The small range means that the disassembly can be judged by scanning sequentially. If the selected gene to be disassembled can form the b gene, then there is no need to disassemble other genes, that is, only disassemble within a small range. Can. Then combine a b gene and set the stable flag and replication flag of the b gene to False, and combine the remaining genetic material according to steps S22 to S28 until the disassembled genetic material is used up. If a cross cannot be formed The b gene that comes over does nothing. Likewise, do the same for the B chromosome. The method of operation of this application will not produce unqualified genes.

在本发明的一个可选实例中某次迭代轮数时,A染色体里的321、247、247基因与B染色体里的321、321、321基因打算进行交换。此时发现A染色体里的2个321、128、512基因的稳定标志位为True,则这两个基因不进行拆解,其余基因的稳定标志位为False。在小范围内发现A染色体里的321、247、247基因,321、321、247基因可以组合成一个321、321、321基因。因此将A染色体里的基因321、247、247,基因321、321、247拆解,组合成一个交换过来的321、321、321基因,剩余基因材料组合成一个247、247、247基因,这2个基因的稳定标志位和复制标志位设置为False,A染色体里的其他稳定标志位为False的基因不做拆解操作。In an optional example of the present invention, at a certain iteration round, genes 321, 247, and 247 in chromosome A are intended to be exchanged with genes 321, 321, and 321 in chromosome B. At this time, it is found that the stable flags of the two 321, 128, and 512 genes in the A chromosome are True, then these two genes are not disassembled, and the stable flags of the remaining genes are False. The 321, 247, and 247 genes in the A chromosome are found in a small range, and the 321, 321, and 247 genes can be combined into a 321, 321, and 321 gene. Therefore, the genes 321, 247, 247 and genes 321, 321, and 247 in the A chromosome are disassembled and combined into an exchanged gene 321, 321, and 321, and the remaining genetic material is combined into a gene 247, 247, and 247. The stable flag and replication flag of a gene are set to False, and the other genes in the A chromosome whose stable flag is False are not disassembled.

发现B染色体所有基因的稳定标志位为False,在小范围内发现基因321、321、321,基因512、247和基因247、247可以组合成一个交换过来的321、247、247基因,因此将这三个基因拆解组合成1个321、247、247基因,1个321、321基因和1个512、247基因,这三个基因的稳定标志位和复制标志位都设置为False,B染色体里的其他稳定标志位为False的基因不做操作。It is found that the stable flags of all genes on chromosome B are False, and genes 321, 321, 321, genes 512, 247, and genes 247, 247 can be combined into an exchanged gene 321, 247, 247 in a small range, so this The three genes are disassembled and combined into one 321, 247, 247 gene, one 321, 321 gene and one 512, 247 gene. The stability flag and replication flag of these three genes are set to False, and in the B chromosome Genes whose other stable flags are False do not operate.

S4、对种群中每个个体染色体的每个基因进行评分。S4. Scoring each gene of each individual chromosome in the population.

步骤S4包括以下分步骤:Step S4 includes the following sub-steps:

S41、选择种群中的一个个体;S41. Select an individual in the population;

S42、找到个体中所有稳定标志位为False的基因;S42. Find all genes whose stable flags are False in the individual;

S43、将步骤S42得到的基因中的元素lx,ly,···,lz值相加得到suml,suml就是基因评分,suml越大,说明该基因越容易变异。步骤S29得到的基因和交叉操作后得到的基因,它们的稳定标志位都为False,都会进行基因评分。S43. Add the elements l x , ly , . . . , l z values of the genes obtained in step S42 to obtain suml, suml is the gene score, and the larger the suml is, the easier it is for the gene to mutate. For the genes obtained in step S29 and the genes obtained after the crossover operation, their stable flags are all False, and the genes will be scored.

在本发明的一个可选实例中,对基因321、128、512,基因321、321、247,基因247、247、290等基因进行评分,发现基因321、128、512的suml值最大,则选择该基因进行变异。In an optional example of the present invention, gene 321, 128, 512, gene 321, 321, 247, gene 247, 247, 290 and other genes are scored, and it is found that the suml value of gene 321, 128, 512 is the largest, then select The gene mutates.

S44、种群中的每一个个体都执行步骤S42、S43。S44. Each individual in the population executes steps S42 and S43.

S5、按照变异概率pm进行变异操作。S5. Perform a mutation operation according to the mutation probability p m .

在本发明的一个可选实例中,变异操作如图5所示。In an optional example of the present invention, the mutation operation is shown in FIG. 5 .

步骤S5包括以下分步骤:Step S5 includes the following sub-steps:

S51、选择种群中的一个个体;S51. Select an individual in the population;

S52、找到个体染色体中所有稳定标志位为False的基因;S52. Find all genes whose stable flags are False in the individual chromosome;

S53、将步骤S52得到的基因的suml进行由大到小排列;S53, arrange the suml of the genes obtained in step S52 from large to small;

S54、选择suml值最大的基因,如果有多个相同最大的suml值基因,则任选其中一个基因;S54, select the gene with the largest suml value, if there are multiple genes with the same largest suml value, then select one of the genes;

S55、判断步骤S54得到的基因否满足变异条件,如果满足条件,则进行变异操作,否则什么都不做;S55, judging whether the gene obtained in step S54 satisfies the mutation condition, if the condition is met, then perform the mutation operation, otherwise do nothing;

其中变异条件为:首先判断当前迭代轮数r是否小于等于R/10,如果是,紧接着判断选中的基因的suml值是否等于Len,如果是,则进行变异操作,如果当前迭代轮数r大于R/10,接着判断选中的基因的suml值是否大于等于Len-c*r*(Len/10),如果是,则进行变异操作,通常迭代轮数R越大,收敛速率c越小,其余情况什么都不做。The mutation condition is: first judge whether the current iteration number r is less than or equal to R/10, if so, then judge whether the suml value of the selected gene is equal to Len, if yes, perform a mutation operation, if the current iteration number r is greater than R/10, then judge whether the suml value of the selected gene is greater than or equal to Len-c*r*(Len/10), if yes, perform a mutation operation, usually the larger the number of iterations R, the smaller the convergence rate c, and the rest The situation does nothing.

其中变异操作为:将要变异的基因的稳定标志位和复制标志位都置为True,之后将染色体中所有稳定标志位为False的基因拆解,然后从拆解后基因材料中选择与待变异基因中的元素进行复制并将复制出来的基因的稳定标志位和复制标志位同样置为True,直至不能复制为止,剩余基因材料按照步骤S22至步骤S28进行组合,形成新的稳定标志位和复制标志位都为False的基因,直至使用完拆解下的基因材料。The mutation operation is as follows: set both the stable flag and the replication flag of the gene to be mutated to True, then dismantle all genes whose stable flags are False in the chromosome, and then select the gene to be mutated from the disassembled genetic material Copy the elements in and set the stable flag and replication flag of the copied gene to True until it cannot be copied, and the remaining genetic materials are combined according to steps S22 to S28 to form new stable flags and replication flags All genes whose bits are False until the disassembled genetic material is used up.

在本发明的一个可选实例中2个247、247、247、247基因的稳定标志位和复制标志位在上一轮中已被变异过了,稳定标志位和复制标志位已置为True,本轮中基因321、128、512经过步骤S54被选中,经过步骤S55发现其满足变异条件。此时将基因321、128、512的稳定标志位和复制标志位设置为True。因此除这3个基因外,将该染色体里的其余基因全部拆解,拆解下来的基因材料有5个512、7个321、4个290、2个247、4个128。待变异基因是否能被复制主要是看所拆解下来的基因材料是否能够组合成待变异基因,如果能被组合,则可复制,如果不能被组合,则不可复制,之后将基因321、128、512按照数量最少的长度进行复制,复制次数为数量最少的长度的数量,可选实施例中复制4次,复制出来的4个321、128、512基因的稳定标志位和复制标志位同样为True,此时基因材料变为1个512、3个321、4个290、2个247、0个128。剩余的基因材料按照条件随机组合成1个512、321基因,1个290、290、247基因,1个321、247、290基因,1个290、321基因,但其组成的基因的稳定标志位和复制标志位都为False。In an optional example of the present invention, the stable flag and the replication flag of the two 247, 247, 247, 247 genes have been mutated in the last round, and the stable flag and the replication flag have been set to True, In this round, genes 321, 128, and 512 are selected through step S54, and are found to meet the mutation conditions through step S55. At this point, set the stable flag and replication flag of genes 321, 128, and 512 to True. Therefore, except for these three genes, all the other genes in the chromosome were disassembled, and the dismantled genetic materials were 5 512, 7 321, 4 290, 2 247, and 4 128. Whether the gene to be mutated can be copied mainly depends on whether the disassembled genetic material can be combined into the gene to be mutated. If it can be combined, it can be copied. If it cannot be combined, it cannot be copied. After that, the genes 321, 128, 512 is copied according to the length with the least number, and the number of copies is the number of the length with the least number. In the optional embodiment, it is copied 4 times, and the stable flags and replication flags of the copied 4 321, 128, and 512 genes are also True At this time, the genetic material becomes 1 512, 3 321, 4 290, 2 247, and 0 128. The remaining genetic material is randomly combined into one 512, 321 gene, one 290, 290, 247 gene, one 321, 247, 290 gene, and one 290, 321 gene according to the conditions, but the stable markers of the genes composed and copy flag are False.

S56、种群中的每一个个体染色体都执行步骤S52、S53、S54、S55。S56. Steps S52, S53, S54, and S55 are executed for each individual chromosome in the population.

S6、对种群中的每个个体进行适应度评定。S6. Evaluate the fitness of each individual in the population.

在本发明的一个可选实例中,图5的染色体中有5个321、128、512基因,2个247、247、247、247基因,1个512、321基因,1个290、290、247基因,1个321、247、247基因,1个290、321基因,minsuml值为611,该个体染色体中有11个基因,k=11,适应度值经过计算为10611。In an optional example of the present invention, there are 5 321, 128, 512 genes, 2 247, 247, 247, 247 genes, 1 512, 321 genes, 1 290, 290, 247 genes in the chromosome of Fig. 5 Genes, one 321, 247, 247 genes, one 290, 321 genes, the minsuml value is 611, there are 11 genes in this individual chromosome, k=11, and the fitness value is calculated as 10611.

步骤S6包括以下分步骤:Step S6 includes the following sub-steps:

S61、选择种群中的一个个体;S61. Select an individual in the population;

S62、将个体的相关数据代入到适应度函数中,得到适应度值,适应度函数为:f(k,minsuml)=(k-1)*Len+minsuml,其中:k为个体染色体中基因的个数,minsuml为个体染色体中最小的suml,Len为原材料长度。S62. Substituting the relevant data of the individual into the fitness function to obtain the fitness value, the fitness function is: f(k,minsuml)=(k-1)*Len+minsuml, wherein: k is the number of genes in the individual chromosome The number, minsuml is the smallest suml in the individual chromosome, and Len is the length of the raw material.

S63、种群中的每一个个体都执行步骤S62。S63. Each individual in the population executes step S62.

S7、决定是否继续进化,如果决定继续进化,则进行选择操作,之后继续执行S3、S4、S5、S6、S7,否则直接执行S8。S7. Decide whether to continue the evolution. If it decides to continue the evolution, perform a selection operation, and then continue to execute S3, S4, S5, S6, and S7, otherwise directly execute S8.

在本发明的一个可选实例中,经过300次迭代后决定放弃进化,输出最优解。In an optional example of the present invention, after 300 iterations, it is decided to abandon the evolution and output the optimal solution.

进一步地,步骤S7包括进化条件和选择操作:Further, step S7 includes evolution conditions and selection operations:

其中进化条件为:是否达到了迭代次数R或者种群中所有个体染色体的所有基因的稳定标志位和复制标志位都置为True。The evolution condition is: whether the number of iterations R is reached or whether the stable flag and the replication flag of all genes of all individual chromosomes in the population are set to True.

其中选择操作为:将得到的适应度值由小到大排列,根据排名用指数函数确定选择概率,其中pi=m·(1-m)i-1,i=1,2,···,n,i表示排名后的第i个个体,pi表示排名第i的个体的选择概率,这里m=4/n,n为种群规模,根据得到的概率选择个体进行迭代。The selection operation is: arrange the obtained fitness values from small to large, and use an exponential function to determine the selection probability according to the ranking, where p i =m·(1-m) i-1 , i=1,2,... , n, i represent the i-th individual after the ranking, p i represents the selection probability of the i-th individual, where m=4/n, n is the population size, and the individual is selected for iteration according to the obtained probability.

S8、输出最优解。S8. Outputting an optimal solution.

在本发明的一个可选实例中,输出的最优解为1个290、128、290、290基因,1个290、321、128、128、128基因,2个321、321、321基因,1个321、512、128基因,2个247、247、247、247基因,2个512、247基因,3个512基因。In an optional example of the present invention, the optimal solution of output is 1 290, 128, 290, 290 gene, 1 290, 321, 128, 128, 128 gene, 2 321, 321, 321 gene, 1 321, 512, 128 genes, 2 247, 247, 247, 247 genes, 2 512, 247 genes, 3 512 genes.

本领域的普通技术人员将会意识到,这里所述的实例是为了帮助读者理解本发明的原理,应被理解为本发明的保护范围并不局限于这样的特别陈述和实施例。本领域的普通技术人员可以根据本发明公开的这些技术启示做出各种不脱离本发明实质的其它各种具体变形和组合,这些变形和组合仍然在本发明的保护范围内。Those skilled in the art will appreciate that the examples described here are to help readers understand the principles of the present invention, and it should be understood that the protection scope of the present invention is not limited to such specific statements and examples. Those skilled in the art can make various other specific modifications and combinations based on the technical revelations disclosed in the present invention without departing from the essence of the present invention, and these modifications and combinations are still within the protection scope of the present invention.

本发明未述及之处适用于现有技术。What is not mentioned in the present invention is applicable to the prior art.

Claims (6)

1.一种基于基因评价遗传算法的一维下料方法,其特征在于,所述下料方法包括以下步骤:1. a one-dimensional blanking method based on gene evaluation genetic algorithm, it is characterized in that, described blanking method comprises the following steps: S1、输入原材料长度Len、需要的钢筋零件长度l1,l2,···,ls、数量de1,de2,···,des、迭代轮数R、交叉概率pc、变异概率pm、收敛速率c,种群规模n,其中零件长度和数量一一对应,称可以使用的钢筋零件长度和数量信息为基因材料,以零件长度作为基因中的元素,de1,de2,···,des的值均小于等于Len,s为零件长度的种类数;S1. Input the raw material length Len, the length of the required reinforcement parts l 1 ,l 2 ,···,l s , the quantity de 1 ,de 2 ,···,de s , the number of iterations R, the crossover probability p c , the mutation Probability p m , convergence rate c, population size n, where the length and quantity of parts correspond one-to-one, the information on the length and quantity of rebar parts that can be used is called genetic material, and the length of parts is used as the element in the gene, de 1 , de 2 , ···, the value of de s is less than or equal to Len, and s is the number of types of part length; S2、根据S1中的基因材料对种群进行初始化操作,并进行随机组合编码,具体过程是:S2. Initialize the population according to the genetic material in S1, and perform random combination coding. The specific process is: S21、d1,d2,···,ds表示不同长度的零件实时数量,初始时令d1,d2,···,ds等于步骤S1输入的de1,de2,···,des;L表示原材料剩余长度,初始时令L等于Len;S21, d 1 , d 2 ,···,d s represent the real-time quantities of parts of different lengths, the initial order d 1 ,d 2 ,···,d s is equal to de 1 ,de 2 ,··· inputted in step S1 , de s ; L represents the remaining length of the raw material, and L is equal to Len at the initial stage; S22、判断出d1,d2,···,ds中哪些值大于0;S22. Determine which values among d 1 , d 2 ,...,d s are greater than 0; S23、判断出l1,l2,···,ls中哪些值小于等于L;S23. Determine which values among l 1 , l 2 ,...,l s are less than or equal to L; S24、挑选出同时满足步骤S22和步骤S23的基因材料;S24. Select the genetic material that satisfies both step S22 and step S23; S25、从步骤S24得到的结果中随机挑选一个lr,将其所对应的dr减1并且更新原材料剩余长度L,即在原材料剩余长度L中减去所挑选的一个零件的长度;S25. Randomly select an l r from the results obtained in step S24, subtract 1 from its corresponding d r and update the remaining length L of the raw material, that is, subtract the length of a selected part from the remaining length L of the raw material; S26、紧接着重复执行S22-S25,直至原材料剩余长度L小于d1,d2,···,ds中不为0的l1,l2,···,ls中的最小值或者d1,d2,···,ds都等于0,记录此时随机挑选出的零件长度,分别记为lx,ly,···,lzS26, followed by repeating S22-S25 until the remaining length L of the raw material is less than the minimum value of l 1 , l 2 ,...,l s that is not 0 in d 1 , d 2 ,...,d s or d 1 , d 2 ,···,d s are all equal to 0, record the lengths of the parts randomly selected at this time, denoted as l x ,ly y ,···,l z respectively; S27、将挑选出的lx,ly,···,lz与稳定标志位和复制标志位三部分共同组合成为个体染色体的一个基因,两个标志位在基因刚被组合起来的时候均置为False,两个标志位在基因被拆解后消失,但基因中的元素不会消失;S27. Combining the selected l x , ly , . Set to False, the two flags will disappear after the gene is disassembled, but the elements in the gene will not disappear; S28、选取多根原材料,重复执行S22-S27,直至d1,d2,···,ds都等于0,得到的众多基因组合成为个体染色体,实现随机组合编码;S28. Select multiple raw materials, and repeat S22-S27 until d 1 , d 2 ,...,d s are all equal to 0, and the obtained genes are combined into individual chromosomes, realizing random combination coding; S29、执行n次S21-S28,完成种群的初始化,其中n为种群规模;S29. Execute n times of S21-S28 to complete the initialization of the population, where n is the population size; S3、依交叉概率pc进行交叉操作;S3. Perform a crossover operation according to the crossover probability p c ; S4、对种群中每个个体染色体的每个基因进行评分:找到个体中所有稳定标志位为False的基因,将每个稳定标志位为False的基因中的所有元素相加求和为suml,suml就是基因评分,选择出基因评分最大值的基因进行变异操作,选择个体染色体中基因评分最小值,利用基因评分最小值计算个体的适应度值,适应度函数f为:S4. Score each gene of each individual chromosome in the population: find all genes whose stable flags are False in the individual, add and sum all elements in each gene whose stable flag is False to form suml, suml It is the gene score, select the gene with the maximum gene score for mutation operation, select the minimum value of the gene score in the individual chromosome, and use the minimum value of the gene score to calculate the fitness value of the individual, the fitness function f is: f(k,min suml)=(k-1)*Len+min sumlf(k,min suml)=(k-1)*Len+min suml 其中:k为个体染色体中基因的个数,min suml为个体染色体中最小的suml,Len为原材料长度;Among them: k is the number of genes in the individual chromosome, min suml is the smallest suml in the individual chromosome, and Len is the length of the raw material; S5、若达到进化条件,则输出最优解,若没有达到进化条件,则根据适应度值按选择概率选择需要进行下一轮迭代的个体,适应度值越小被选择的概率越大。S5. If the evolution condition is met, the optimal solution is output. If the evolution condition is not met, the individual to be selected for the next round of iteration is selected according to the fitness value according to the selection probability. The smaller the fitness value, the greater the probability of being selected. 2.根据权利要求1所述的基于基因评价遗传算法的一维下料方法,其特征在于,所述进化条件为:是否达到了迭代次数R或者种群中所有个体染色体的所有基因的稳定标志位和复制标志位都置为True。2. the one-dimensional blanking method based on gene evaluation genetic algorithm according to claim 1, is characterized in that, described evolutionary condition is: whether has reached the stable flag position of all genes of all individual chromosomes in the number of iterations R or population and copy flags are both set to True. 3.根据权利要求1所述的基于基因评价遗传算法的一维下料方法,其特征在于,所述步骤S3包括以下分步骤:3. the one-dimensional blanking method based on gene evaluation genetic algorithm according to claim 1, is characterized in that, described step S3 comprises following sub-steps: S31、随机生成一个0-1的小数,如果随机生成的小数小于交叉概率pc,则执行S32、S33,如果大于等于pc,则什么都不做;S31. Randomly generate a decimal number of 0-1. If the randomly generated decimal number is less than the crossover probability p c , execute S32 and S33. If it is greater than or equal to p c , do nothing; S32、从种群中任意挑选两个个体;S32. Randomly select two individuals from the population; S33、从两个个体中分别任意挑选一个稳定标志位为False的基因进行交叉操作;S33. Randomly select a gene whose stable flag is False from two individuals to perform crossover operation; 其中交叉操作为:设A染色体要得到B染色体的b基因,B染色体要得到A染色体的a基因,则判断A染色体里所有稳定标志位为False的基因和a基因拆解开来能否组成一个交叉过来的b基因,如果能,则在小范围内拆解那些A染色体里可以组成b基因的基因,如果已拆解的基因能组成B染色体中的b基因,则不继续拆解A染色体;之后组合一个b基因且令b基因的稳定标志位和复制标志位为False,拆解下的剩余基因材料按照步骤S22至步骤S28进行组合直至使用完拆解下的基因材料;如果不能组成一个交叉过来的b基因则什么都不做;同样的,对B染色体执行相同的操作。The crossover operation is as follows: if the A chromosome needs to obtain the b gene of the B chromosome, and the B chromosome needs to obtain the a gene of the A chromosome, then it is judged whether all the genes whose stable flags are False in the A chromosome and the a gene can be disassembled to form a If the b gene that crossed over can be dismantled in a small range, the genes that can form the b gene in the A chromosome will be disassembled. If the disassembled gene can form the b gene in the B chromosome, then the disassembly of the A chromosome will not continue; Then combine a b gene and set the stable flag and replication flag of the b gene to False, and combine the remaining genetic material according to steps S22 to S28 until the disassembled genetic material is used; if a cross cannot be formed The incoming b gene does nothing; similarly, it does the same for the B chromosome. 4.根据权利要求1所述的基于基因评价遗传算法的一维下料方法,其特征在于,所述变异操作包括:4. the one-dimensional blanking method based on gene evaluation genetic algorithm according to claim 1, is characterized in that, described variation operation comprises: 获得个体染色体的每个基因评分后,将基因评分进行由大到小排列;选择基因评分最大的基因,如果有多个相同最大的suml值基因,则任选其中一个基因;判断所选择的基因否满足变异条件,如果满足条件,则进行变异操作,否则什么都不做;After obtaining each gene score of an individual chromosome, arrange the gene scores from large to small; select the gene with the largest gene score, if there are multiple genes with the same maximum suml value, select one of the genes; judge the selected gene Whether the mutation condition is met, if the condition is met, the mutation operation is performed, otherwise nothing is done; 其中变异条件为:首先判断当前迭代轮数r是否小于等于R/10,如果是,紧接着判断选中的基因的suml值是否等于Len,如果是,则进行变异操作;如果当前迭代轮数r大于R/10,接着判断选中的基因的suml值是否大于等于L-c*r*(Len/10),如果是,则进行变异操作;其余情况什么都不做;The mutation condition is: first judge whether the current iteration number r is less than or equal to R/10, if yes, then judge whether the suml value of the selected gene is equal to Len, if yes, perform the mutation operation; if the current iteration number r is greater than R/10, then judge whether the suml value of the selected gene is greater than or equal to L-c*r*(Len/10), if so, perform the mutation operation; do nothing in other cases; 当前迭代轮数满足变异条件的基因为待变异基因,将待变异基因的稳定标志位和复制标志位都置为True,之后将个体染色体中所有稳定标志位为False的基因拆解,然后从拆解后基因材料中选择与待变异基因中的元素相同的基因材料进行复制并将复制出来的基因的稳定标志位和复制标志位同样置为True,直至不能复制为止,待变异基因是否能被复制主要是看所拆解下来的基因材料是否能够组合成标志位均为True的基因,如果能被组合,则可复制,如果不能被组合,则不可复制;剩余基因材料按照步骤S22至步骤S28进行组合,形成新的稳定标志位和复制标志位都为False的基因,直至使用完拆解下的基因材料。The gene whose number of current iterations meets the mutation condition is the gene to be mutated, and the stable flag and the replication flag of the gene to be mutated are both set to True, and then all the genes whose stable flags are False in the individual chromosomes are dismantled, and then from the dismantled After decomposing, select the same genetic material as the element in the gene to be mutated to copy and set the stable flag and copy flag of the copied gene to True until it cannot be copied. Whether the gene to be mutated can be copied It mainly depends on whether the disassembled genetic material can be combined into a gene whose flag bits are all True. If it can be combined, it can be copied; Combine to form a new gene whose stability flag and replication flag are both False, until the disassembled genetic material is used up. 5.根据权利要求1所述的基于基因评价遗传算法的一维下料方法,其特征在于,所述根据适应度值按选择概率选择需要进行下一轮迭代的个体的具体过程是:将适应度值由小到大排列,根据排名用指数函数确定选择概率,排名第i的个体染色体的选择概率为pi,其中pi=m·(1-m)i-1,i=1,2,···,n,m为小于1的常数,根据选择概率选择个体染色体进行迭代。5. the one-dimensional blanking method based on gene evaluation genetic algorithm according to claim 1, is characterized in that, the specific process of selecting the individual who needs to carry out the next round of iteration according to the selection probability according to the fitness value is: Degree values are arranged from small to large, and the selection probability is determined with an exponential function according to the ranking. The selection probability of the i-th individual chromosome is p i , where p i =m·(1-m) i-1 , i=1,2 ,···, n, m are constants less than 1, and individual chromosomes are selected for iteration according to the selection probability. 6.根据权利要求1所述的基于基因评价遗传算法的一维下料方法,其特征在于,所述m=4/n。6. The one-dimensional blanking method based on genetic evaluation genetic algorithm according to claim 1, characterized in that, said m=4/n.
CN202310652588.8A 2023-06-05 2023-06-05 One-dimensional blanking method based on genetic evaluation genetic algorithm Pending CN116663660A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310652588.8A CN116663660A (en) 2023-06-05 2023-06-05 One-dimensional blanking method based on genetic evaluation genetic algorithm

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310652588.8A CN116663660A (en) 2023-06-05 2023-06-05 One-dimensional blanking method based on genetic evaluation genetic algorithm

Publications (1)

Publication Number Publication Date
CN116663660A true CN116663660A (en) 2023-08-29

Family

ID=87727473

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310652588.8A Pending CN116663660A (en) 2023-06-05 2023-06-05 One-dimensional blanking method based on genetic evaluation genetic algorithm

Country Status (1)

Country Link
CN (1) CN116663660A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117407966A (en) * 2023-12-14 2024-01-16 中国建筑西南设计研究院有限公司 Multi-specification steel bar blanking method and device integrating distributed pruning and genetic algorithm

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117407966A (en) * 2023-12-14 2024-01-16 中国建筑西南设计研究院有限公司 Multi-specification steel bar blanking method and device integrating distributed pruning and genetic algorithm
CN117407966B (en) * 2023-12-14 2024-02-13 中国建筑西南设计研究院有限公司 Multi-specification steel bar blanking method and device integrating distributed pruning and genetic algorithm

Similar Documents

Publication Publication Date Title
CN111832101B (en) Construction method of a cement strength prediction model and cement strength prediction method
CN109034633A (en) Improved adaptive GA-IAGA solves the flexible job shop scheduling method with traveling time
CN104835026B (en) Automatic stereowarehouse picking scheduling modeling optimization method based on Petri network and improved adaptive GA-IAGA
Yadav et al. An overview of genetic algorithm and modeling
CN105117461B (en) A kind of enquiring and optimizing method based on Revised genetic algorithum
CN106873372B (en) Reservoir regulation for flood control optimization method based on the control of Flood Control Dispatch data adaptive
CN111832949B (en) A Construction Method of Appraisal Index System for Equipment Combat Test
CN109448794A (en) A kind of epistasis site method for digging based on heredity taboo and Bayesian network
CN108537338B (en) Disaster rescue emergency resource scheduling method based on multi-agent genetic algorithm
CN116663660A (en) One-dimensional blanking method based on genetic evaluation genetic algorithm
CN110390360A (en) Method and device for determining the layout order of rectangular blocks based on genetic algorithm
CN115391385A (en) Database query optimization method based on ant colony genetic dynamic fusion algorithm
CN106874555A (en) A kind of Reed Muller logic circuits power consumption and area-optimized method
CN113779842A (en) Reinforcing rib structure layout optimization design method based on genetic algorithm
CN104616084A (en) Assembly sequence planning method
CN101706883A (en) Data mining method and device
CN112287480B (en) A Method of Mechanical Structure Topology Optimization Based on Multi-Population Genetic Algorithm
CN107748916A (en) Improved method for genetic evolution topology optimization
CN114611191A (en) Reinforced concrete frame structure optimization design method based on improved genetic algorithm
CN109559782B (en) A DNA Sequence Coding Method Based on Multi-objective Genetic Algorithm
CN114118000A (en) PCB splicing and blanking method based on deep intelligent genetic optimization algorithm
CN116705142B (en) Metabolite optimization method based on binary vector particle swarm optimization algorithm and flux balance analysis hybrid algorithm
CN110111838B (en) Method and device for ribonucleic acid folded structure prediction based on extended structure with pseudoknot
CN105069323B (en) Microbial fermentation control optimization method based on Memetic algorithms
CN115438970B (en) Large-scale production scheduling method suitable for discrete manufacturing of workpieces

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