changes

来自「这是遗传算法的源代码」· 代码 · 共 42 行

TXT
42
字号
Changes made by Luis de la Ossa and Kumara Sastry. Date: March 24, 2006These are the changes from ECGA version 1.1 to deal with problems with integer variables (chi-ary alphabets). In the inputfile, after the chromosome length, cardinality of each variable has to be specified.chromosome_length              12values_per_gene		       4 6 4 6 4 6 8 2 10 2 6 2When programming the objective function, one can access the cardinality of an ith gene usingparameter::ranges[i].The test problem provided with the code takes m groups of (k=4) variables and sums the m subfunctions.Each subfunction returns the sum of the four variables except if such sum is 0. Then it returnsthe sum of cardinalities of the four variables plus one. For example, in the first block of the example it would be 4+6+4+6 = 20 + 1 = 21.-----------------Modified files ----------------------------------parameters.hpp: Added a vector "ranges" which contains the cardinality of each variable.main.cpp :      Modified to read the list of ranges for each variable.chromosome.cpp: Since the objective function will use arrays of integers, a function converts                each chromosome to such array. gene.cpp:       The gene is now position dependent and so is the mutatation and random generation.utility.cpp:    Added functions to encode/decode numbers basing on the cardinality of each variable.MPM.cpp:        Some small changes.objfunc.hpp:    Must be modified for each objective function.-----------------Un-Modified files -----------------------------cache.hppcache.cppchromosome.hppecga.hppecga.cppgene.hppintlist.hppintlist.cppsubset.hpp

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?