使用遗传算法进行稀疏参数选择

发布于 2024-07-21 05:35:51 字数 474 浏览 4 评论 0原文

我面临一个参数选择问题,我想使用遗传算法(GA)来解决。 我应该从 3000 个可能的参数中选择不超过 4 个参数。 使用二元染色体表示似乎是一个自然的选择。 评估函数会惩罚太多“选定”属性,如果属性数量可以接受,则会评估选择。

问题在于,在这些稀疏条件下,遗传算法很难改善种群。 经过几代人的努力,平均健康成本和“最差”个体的健康状况都没有改善。 我所看到的只是最佳个体的分数略有(甚至微小)提高,我认为这是随机抽样的结果。

使用参数索引对问题进行编码也不起作用。 这很可能是因为染色体是有方向的,而选择问题不是(即染色体 [1, 2, 3, 4];[4, 3, 2, 1];[3, 2, 4, 1] 等是相同的)

您会建议什么问题表示?

PS 如果这很重要,我使用 PyEvolve

I'm facing a parameter selection problem, which I would like to solve using Genetic Algorithm (GA). I'm supposed to select not more than 4 parameters out of 3000 possible ones. Using the binary chromosome representation seems like a natural choice. The evaluation function punishes too many "selected" attributes and if the number of attributes is acceptable, it then evaluates the selection.

The problem is that in these sparse conditions the GA can hardly improve the population. Neither the average fitness cost, nor the fitness of the "worst" individual improves over the generations. All I see is slight (even tiny) improvement in the score of the best individual, which, I suppose, is a result of random sampling.

Encoding the problem using indices of the parameters doesn't work either. This is most probably, due to the fact that the chromosomes are directional, while the selection problem isn't (i.e. chromosomes [1, 2, 3, 4]; [4, 3, 2, 1]; [3, 2, 4, 1] etc. are identical)

What problem representation would you suggest?

P.S If this matters, I use PyEvolve.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

巷子口的你 2024-07-28 05:35:51

我不熟悉 PyEvolve,但从我对遗传算法的记忆来看,您关心的是 4 个步骤,

  1. 染色体评估(您可能已经弄清楚了)
  2. 染色体初始化
  3. 染色体交叉
  4. 染色体突变

我认为您可以使用列出来就好了。 您需要重载一些运算符,但看起来 PyEvolve 允许您执行此操作 一个简单的事情是保留列表表示,只需在返回染色体之前对它们进行数字排序。

我需要更多地了解你的问题,但这是我的建议。 由于参数数量可变,因此您需要得出染色体中参数数量的某种概率分布。 我在这里假设 1、2、3、4 是均匀随机的,但如果您更喜欢,可以尝试其他方法。 我将把这个分布称为 P_n。

  1. 初始化。 用(至少)3000 条染色体播种您的种群。 称这些为 c_1,...,c_3000。 从 P_n 中得出 n_j。 将 j 放入 c_j 中。 从剩余参数中选择剩余的n_j - 1 个均匀随机分布的参数。
  2. 交叉。 假设我们有两条染色体。 C_1 和 C_2。 我们将创建(并返回)染色体 C_3。 从 {n_1, n_2} 中选择 n_3,每个概率为 1/2。 现在将 C_1 和 C_2 的参数放入一个列表中(并且它们是唯一的,因此如果 C_1 和 C_2 都包含参数 1,则它仅在列表中出现一次)。 从联合列表中抽取n_3个参数并将其放入染色体C_3中。
  3. 突变。 给定染色体 C_1,从 P_n 中绘制 n_1*。 如果 n_1* 小于 n_1,从C_1中随机删除元素,直到有n_1*个元素。 如果 n_1* = n_1 从 C_1 中随机选择 1 个元素,并将其替换为从 C_1 中没有的参数中随机选择的参数。 如果n_1*> n_1 随机向 C_1 添加元素,直到其大小为 n_1*。

现在,有很多方法可以解决这个问题,因此请采取对您的问题最有意义的方法。

I'm not familiar with with PyEvolve, but from what I can recall about Genetic algorithms, you are concerned with 4 steps,

  1. Chormosome Evalutation (you probably already have this figured out)
  2. Chromosome Initialization
  3. Chromosome Crossover
  4. Chromosome Mutation

I think you can do this with lists just fine. You'll need to overload some operators, but it looks like PyEvolve lets you do this A simple thing would be to keep the list representation, just sort them numerically before you return the chromosome.

I would need to know more about your problem, but here are my suggestions. Since you have a variable number of parameters, you need to come up with some sort of probability distribution for number of parameters in a chromosome. I'll assume a uniform random on 1,2,3,4 here, but you can try something else if you like that better. I'm going to call this distribution P_n.

  1. Initialization. Seed your population with (at least) 3000 chromosomes. Call these c_1,...,c_3000. Draw n_j from P_n. put j into c_j. Choose the remaining n_j - 1 parameters with a uniform random distribution from the remaining parameters.
  2. Crossover. Lets suppose that we have two chromosomes. C_1 and C_2. We're going to create (and return) chromosome C_3. Choose n_3 from {n_1, n_2} each with probability 1/2. Now put the parameters of C_1 and C_2 into one list (and unique them, so if both C_1 and C_2 contain parameter 1, it is only in the list once). Draw n_3 parameters from the joint list and put them into chromosome C_3.
  3. Mutation. Given Chromosome C_1, draw n_1* from P_n. if n_1* is < n_1, randomly delete elements from C_1 until has n_1* elements. If n_1* = n_1 randomly choose 1 element from C_1 and replace it with a parameter randomly chosen from those not in C_1. If n_1* > n_1 randomly add elements to C_1 until is has size n_1*.

Now, there are many ways to go about this, so do what makes the most sense for your problem.

别低头,皇冠会掉 2024-07-28 05:35:51

我认为奇异值分解(http://en.wikipedia.org/wiki/Singular_value_decomposition考虑到参数数量的限制,这里可能更合适。

I think a singular value decomposition (http://en.wikipedia.org/wiki/Singular_value_decomposition) might be more appropriate here on account of the limit on the number of parameters.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文