使用遗传算法找到给定距离的正确/最佳轨道组合

发布于 2024-09-30 17:55:26 字数 370 浏览 5 评论 0原文

我有一个不同长度的轨道(模型铁轨)列表,例如: 3.0cm 处的轨道A, 5.0cm 上的 TrackB, TrackC 位于 6.5 厘米, TrackD on 10.5cm

然后我想找出应该组合什么样的轨道才能以给定的距离和边距从 A 点到达 B 点。我还应该能够优先考虑轨道类型的使用。

例子;从A点到B点的距离是1.7m,我有很多TrackC和很少的TrackB。 我会在距离上留出 +/- 0.5 厘米的余量。

我应该使用什么样的曲目,每个曲目有多少个,以及我有多少个组合,排序在我拥有最多的曲目之后。

在使用遗传算法获得一些 C# 帮助后,我在 Google 上找到了答案,但我迷失了,如何才能用一种好的方法来实现这一点。

请帮忙..

I have a list of tracks (model railroad tracks) with different length, example:
TrackA on 3.0cm,
TrackB on 5.0cm,
TrackC on 6.5cm,
TrackD on 10.5cm

Then I want to find out of what kind of track I should put together to get from point A to point B with a given distance and a margin. And I should also be able to a prioritizes the use of track type.

Example; Distance from point A to B is 1.7m, and I have lot of TrackC and few of TrackB.
And I will allow a margin on +/- 0.5cm to the distance.

What kind of tracks should I use, and how many of each track, and how many combination do I have, sorted after the track where I have most of.

I have Google after some C# help using genetic algorithm, but I am lost in, how I can implement this in a good methode.

Please help..

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

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

发布评论

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

评论(1

雨的味道风的声音 2024-10-07 17:55:26

这就是你的做法。我假设您熟悉基本的遗传算法概念:

群体中的每个个体都由不同的“轨迹长度”组成。

因此,原始集将是一组与可用长度相对应的常量,例如 { 3, 4, 5}

因此,每个人的适应度被称为总误差之和。或者更简单地说:假设你的轨道应该是 1 米长。如果一个个体的长度正好是1米,则没有误差,适应度为0。如果另一个个体的长度为0.5m,则其适应度为0.5。所以越低越好。


所以你的算法是这样的:

  1. 构建一个群体(可能是随机的,但还有其他初始化技术,例如斜坡对半、完整等......查找它们)。
  2. 评估每个人的健康状况。如果任何人的健康状况在一定范围内,那么您就完成了。
  3. 否则通过交叉/繁殖/突变前进一代。
  4. 转到#2

This is how you do it. Ill assume you are familiar with the basic G.A. concepts:

Each individual in the population much consist of various 'lengths of track'.

The primitive set would therefore be a set of constants corresponding to the lengths you have available fore example { 3, 4, 5}

The fitness of each individual is therefore said to be the sum of total error. Or more simply: say your track is supposed to be 1 metre long. If an individual is 1 metre long exactly, there is no error and the fitness is 0. If another individual has a length of 0.5m, its fitness is 0.5. So the lower the better.


So your algorithm goes like:

  1. Construct a population (maybe randomly but there are other techniques for initialisation such as ramped half-and-half, full etc... look them up).
  2. Assess the fitness of each individual. If any have fitness within a certain margin, you're done.
  3. Else advance by one generation via crossover / reproduction / mutation.
  4. Goto #2
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文