c++ 中的遗传编程,库建议?

发布于 2024-09-01 14:51:22 字数 1431 浏览 7 评论 0原文

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

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

发布评论

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

评论(5

从此见与不见 2024-09-08 14:51:22

我建议您自己滚动。 GP 90% 的工作是对基因型进行编码、如何对其进行操作以及适合度计算。这些部分会针对每个不同的问题/项目而变化。实际的进化算法部分通常非常简单。

有几个 GP 库( http://en.wikipedia.org/wiki/Symbolic_Regression#实现)。不过,我会使用这些作为示例和参考。

C++ 对于 GP 来说是一个不错的选择,因为它们往往计算量很大。通常,适应度函数是瓶颈,因此至少值得对这部分进行编译/优化。

I would recommend rolling your own. 90% of the work in a GP is coding the genotype, how it gets operated on, and the fitness calculation. These are parts that change for every different problem/project. The actual evolutionary algorithm part is usually quite simple.

There are several GP libraries out there ( http://en.wikipedia.org/wiki/Symbolic_Regression#Implementations ). I would use these as examples and references though.

C++ is a good choice for GP because they tend to be very computationally intensive. Usually, the fitness function is the bottleneck, so it's worthwhile to at least make this part compiled/optimized.

泛泛之交 2024-09-08 14:51:22

我使用 GAUL

它是一个 C 库,拥有您想要的一切。
( pthread/fork/openmp/mpi )
(各种交叉/变异函数)
(非 GA 优化:爬山、NM 单纯形、模拟退火、禁忌……)

既然有如此强大的工具,为什么要构建自己的库???

I use GAUL

it's a C library with all you want.
( pthread/fork/openmp/mpi )
( various crossover / mutation function )
( non GA optimisation: Hill-Climbing, N-M Simplex, Simulated annealling, Tabu, ... )

Why build your own library when there is such powerful tools ???

赠我空喜 2024-09-08 14:51:22

我个人还没有使用过这个方法,但是年龄分层人口结构(ALPS)方法已被用于产生人类竞争结果,并且在粗糙的健身环境中寻找最佳解决方案方面已被证明优于几种流行的方法。此外,该链接还包含 C++ FTW 的源代码。

I haven't used this personally yet, but the Age Layered Population Structure (ALPS) method has been used to generate human competitive results and has been shown to outperform several popular methods in finding optimal solutions in rough fitness landscapes. Additionally, the link contains source code in C++ FTW.

少跟Wǒ拽 2024-09-08 14:51:22

我也遇到过类似的问题。我曾经遇到过一个复杂的问题,并且根据固定长度向量定义解决方案是不可取的。即使是可变长度的向量看起来也没有吸引力。大多数库都关注成本函数计算成本低的情况,但与我的问题不符。缺乏并行性是他们的另一个缺陷。期望用户分配内存供库使用是雪上加霜。我的案例更加复杂,因为大多数库在评估之前都会检查非线性条件。同时,我需要根据评估结果检查评估期间或之后的非线性条件。当我需要评估解决方案以计算其成本,然后我必须重新计算解决方案以呈现它时,这也是不可取的。在大多数情况下,我必须将成本函数编写两次。一次用于 GA,一次用于演示。

面对所有这些问题,我最终设计了自己的 openGA 库,该库现已成熟。

  • 该库基于 C++,并通过免费的 Mozilla Public License 2.0 分发。它保证使用该库不会限制您的项目,并且可以免费用于商业或非商业目的,无需请求任何许可。从这个意义上说,并非所有图书馆都是透明的。
  • 支持单目标、多目标(NSGA-III)和交互式遗传算法(IGA)三种模式。
  • 该解并不强制必须是向量。它可以是具有任何定制设计的任何结构,包含任何可变长度的可选值。此功能使该库适合遗传编程 (GP) 应用。
  • 使用C++11。模板功能允许解决方案结构设计的灵活性。
  • 使用这个库标准库就足够了。除此之外没有任何依赖性。整个库也是一个易于使用的头文件。
  • 该库默认支持并行性,除非您将其关闭。如果您有 N 核 CPU,则线程数默认设置为 N。您可以更改设置。您还可以设置解决方案评估是否在线程之间平均分配,或者将它们分配给已完成其工作且当前空闲的任何线程。
  • 解决方案评估与最终成本的计算是分开的。这意味着你的评估函数可以模拟系统并保留大量信息。稍后调用您的成本函数并根据评估报告成本。而您的评估结果将被保留以供用户稍后使用。您不需要再次重新计算。
  • 您可以在评估期间随时拒绝解决方案。不浪费时间。事实上,评估和约束检查是一体化的。
  • GA 辅助 功能可帮助您根据您提供的信息生成 C++ 代码库。

如果这些功能符合您的需要,我建议您查看 openGA 的用户手册和示例。

相关出版物的读者数量和引用数量以及其 github 收藏标记不断增加,其使用量不断增长。

I have had similar problems. I used to have a complicated problem and defining a solution in terms of a fixed length vector was not desirable. Even a variable length vector does not look attractive. Most of the libraries focus on cases where the cost function is cheap to calculate which did not match my problem. Lack of parallelism is their another pitfall. Expecting the user to allocate memory for being used by the library is adding insult into injury. My cases were even more complicated because most of the libraries check the nonlinear conditions before evaluation. While, I needed to check the nonlinear condition during or after the evaluation based on the result of the evaluation. It is also undesirable when I needed to evaluate the solution to calculate its cost and then I had to recalculate the solution to present it. In most of the cases, I had to write the cost function two times. Once for GA and once for presentation.

Having all of these problems, I eventually, designed my own openGA library which is now mature.

  • This library is based on C++ and distributed with free Mozilla Public License 2.0. It guarantees that using this library does not limit your project and it can be used for commercial or none commercial purposes for free without asking for any permission. Not all libraries are transparent in this sense.
  • It supports three modes of single objective, multiple objective (NSGA-III) and Interactive Genetic Algorithm (IGA).
  • The solution is not mandated to be a vector. It can be any structure with any customized design containing any optional values with variable length. This feature makes this library suitable for Genetic Programming (GP) applications.
  • C++11 is used. Template feature allows flexibility of the solution structure design.
  • The standard library is enough to use this library. There is no dependency beyond that. The entire library is also a single header file for ease of use.
  • The library supports parallelism by default unless you turn it off. If you have an N-core CPU, the number of threads are set to N by default. You can change the settings. You can also set if the solution evaluations are distributed between threads equally or they are assigned to any thread which has finished its job and is currently idle.
  • The solution evaluation is separated from calculation of the final cost. It means that your evaluation function can simulate the system and keep a lot of information. Your cost function is called later and reports the cost based on the evaluation. While your evaluation results are kept to be used later by the user. You do not need to re-calculate it again.
  • You can reject a solution at any time during the evaluation. No waste of time. In fact, the evaluation and constraint check are integrated.
  • The GA assist feature help you to produce the C++ code base from the information you provide.

If these features match what you need, I recommend having a look at the user manual and the examples of openGA.

The number of the readers and citation of the related publication as well as its github favorite marks is increasing and its usage is keep growing.

初吻给了烟 2024-09-08 14:51:22

我建议您查看 matlab 优化工具包 - 它附带 GA框,您只需编写适应度函数(以及最终生成初始种群的函数),并且我相信 matlab 具有一定的 C++ 互操作性,因此您可以使用 C++ 编写函数。我在实验中使用它,一个非常好的功能是您还可以获得开箱即用的各种图表。

这么说 - 如果您的目标是学习遗传算法,您最好对其进行编码,但如果您只想运行实验,那么 matlab 和 C++(甚至只是 matlab)是一个不错的选择。

I suggest you have a look into the matlab optimization toolkit - it comes with GAs out of the box, you only haver to code the fitness function (and a function to generate inital population eventually) and I believe matlab has some C++ interoperability so you could code you functions in C++. I am using it for my experiments and a very nice feature is that you get all sorts of charts out of the box as well.

Said so - if your aim is to learn about genetic algorithms you're better off coding it, but if you just want to run experiments matlab and C++ (or even just matlab) is a good option.

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