PHP 中的健身函数
我花了一整天的时间研究了一个在遗传算法中实现“适应度函数”的示例。 (我已经实现了“开始填充”、“突变”和排列)。接下来的步骤是“适应度函数”。有人有一个用 PHP 计算“适应度”的例子吗? Java 或 C# 也可以。
I looked a whole day after an example to implement the 'fitness function' in a Genetic algorithm. (I implemented already a 'begin population', 'mutation' and permutation). The following step is the 'fitness function'. Does anyone have an example of calculating the 'fitness' in PHP? Java or C# is OK as well.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
适应度函数只会对人口中的一名成员进行排名。具有最高适应度函数的项目“获胜”,然后在下一轮中与群体中的新成员进行交流。
如何定义会员的适合度取决于您。可以这么说,这个函数决定了 Brains vs. Brawn 中谁会获胜。
The fitness function will simply rank one member of your population. The item with the highest fitness function "wins" and then has intercourse with a new member of the population in the next round.
It is up to you how to define the fitness of a member. It is up to this function to determine what will win in Brains vs. Brawn, so to speak.
创建一个 Java、C 或 C# 软件来实现您的个人健身功能。稍后,您可以使用
exec()
函数来执行软件并收集输出。例如:Create a java, C or C# software wich implement your personal fitness function. Later, you can use the
exec()
function to execute the software and collect the output. For example:适应度函数完全取决于您的应用程序。它可以是任何东西,从一个生物移动的距离,到你在《星际争霸 2》游戏中的某个时间可以建造多少个单位,再到测量一个图像与另一个图像的相似程度。
确保它在好与坏之间有足够的粒度。
The fitness function is completely dependent on your application. It could be anything from how far a creature travels, to how many units you can build in Starcraft 2 at a certain time in the game, to measuring how closely an image resembles another.
Make sure it has enough granularity between good and bad though.