使用遗传算法找到给定距离的正确/最佳轨道组合
我有一个不同长度的轨道(模型铁轨)列表,例如: 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这就是你的做法。我假设您熟悉基本的遗传算法概念:
群体中的每个个体都由不同的“轨迹长度”组成。
因此,原始集将是一组与可用长度相对应的常量,例如 { 3, 4, 5}
因此,每个人的适应度被称为总误差之和。或者更简单地说:假设你的轨道应该是 1 米长。如果一个个体的长度正好是1米,则没有误差,适应度为0。如果另一个个体的长度为0.5m,则其适应度为0.5。所以越低越好。
所以你的算法是这样的:
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: