简体   繁体   English

多线程galib247遗传算法卡在局部最大值

[英]Multithreaded galib247 genetic algorithm stuck in local maxima

I added multithreading support to galib247 (below), but I'm still seeing problems whereby solutions were getting stuck in local maxima. 我为galib247(下面)添加了多线程支持,但我仍然看到解决方案陷入局部最大值的问题。

Perhaps it's a shortcoming of genetic algorithms in general. 也许这是遗传算法的一个缺点。 Let me know if anyone has any suggestions. 如果有人有任何建议,请告诉我。 I've tried running 1000 independent populations, that are prioritized based on how recently the population has found a better solution, but I still think it's not finding the best solution. 我已经尝试过运行1000个独立人群,根据最近人口找到更好的解决方案的优先次序,我仍然认为它没有找到最佳解决方案。

I've also tried modifying the mutator. 我也试过修改mutator。 Perhaps the solution set it too complicated, there are a lot of local maxima. 也许解决方案设置太复杂,有很多局部最大值。 It usually finds different local maxima in every one of the 1000 pools of pools, but occasionally one of the pools of pools finds a better answer and is prioritized for scheduling. 它通常在1000个池池中的每一个池中找到不同的局部最大值,但偶尔会有一个池池找到更好的答案并且优先用于调度。

What I'm trying to do is generate an optimal technical analysis indicator list with parameters to an FX trade signal generator for live trading based on an expanding set of historical prices. 我正在尝试做的是根据一组不断变化的历史价格,为FX交易信号发生器生成一个最佳技术分析指标列表,其中包含参数。 There was a book about it years ago, I think the author's name was Katz. 几年前有一本关于它的书,我认为作者的名字是卡茨。

I'm testing the variance of the results against a second historical price set but basically, the real test is whether or not it is predictive of future prices. 我正在测试结果与第二个历史价格集的差异,但基本上,真正的考验是它是否可以预测未来的价格。

GAPopulation.C ( http://lancet.mit.edu/ga/Copyright.html ): GAPopulation.C( http://lancet.mit.edu/ga/Copyright.html ):

#include <boost/thread.hpp>
#include <boost/threadpool.hpp>

boost::threadpool::pool GAPopulation::thpool(5);

void GAPopulationEvaluatorWorker(void* individual_ptr) {
    ((GAGenome*) individual_ptr)->evaluate();
    boost::this_thread::yield();
}

void GAPopulation::DefaultEvaluator(GAPopulation& p) {
    for(int i = 0; i < p.size(); i++) {
        thpool.schedule(boost::bind(GAPopulationEvaluatorWorker, p.individual_ptr(i)));
    }

    thpool.wait();
}

Do you think your problem is caused by the multi-threading? 您认为您的问题是由多线程引起的吗? I wouldn't think so... 我不这么认为......

GA's always have the problem of overcoming local maxima. GA始终存在克服局部最大值的问题。 I was taught that as program time goes on, you're supposed to decrease the mutation rate to keep from jumping down. 我被教导说,随着程序时间的推移,你应该降低突变率以防止跳跃。 But recently, I made a GA that increased its mutation rate based on the lack of genetic diversity in its population. 但最近,我做了一个GA,根据人口中遗传多样性的缺乏,提高了突变率。 (Had to come up with a function that could calculate diversity). (不得不提出一个可以计算多样性的函数)。

With GA's, there are many things you need to do well: #1, have a solid way of calculating fitness that can be performed very quickly. 有了GA,你需要做很多事情:#1,有一个可以很快执行的计算适应性的可靠方法。 This simply can't be done with a lot of problems. 这很难解决很多问题。 #2, describe your problem in a set of genes. #2,用一组基因描述你的问题。 Again, that can be really hard to do. 同样,这真的很难做到。 #3, who to breed and how to breed them. #3,谁来繁殖以及如何繁殖它们。 I'd rather have a diverse breeding pool where the mid-performing genes can last for several generations, especially if your problem is overcoming local maxima. 我宁愿拥有一个多样化的繁殖池,其中中等表现的基因可以持续几代,特别是如果你的问题是克服局部最大值。 And of course, #4, your strategy for mutation. 当然,#4,你的变异策略。 It just may not be enough to flip 1 bit on a .1% chance. 仅仅0.1%的几率翻转1位可能还不够。 Or it might be too much. 或者它可能太多了。 How do you breed or mutate things like floating-point numbers? 你如何繁殖或改变像浮点数这样的东西? Flipping 1 bit a) makes a drastic change and b) has no discernible impact on fitness (it could be good or bad depending on the other bits). 翻转1位a)会发生剧烈变化,b)对健身没有明显的影响(取决于其他位,可能有好有坏)。

So using a GA requires a lot of tuning. 因此使用GA需要大量调整。 Evaluate #1 and #2 and make sure you're happy with it. 评估#1和#2并确保您对此感到满意。 Experiment with breeding. 繁殖实验。 "Killing your parents" might help. “杀死你的父母”可能有所帮助。 Maybe keep a few of the parents around, but breed everyone but the lowest 25%. 也许留下一些父母,但培养每个人,但最低的25%。 That way there's less of a chance of jumping down, but a good gene has a chance to go through a few sub-par mutations that might in the end create a better gene. 这样就不太可能跳下来了,但是一个好基因有机会经历一些可能最终产生更好基因的亚突变。

I hear you can use a GA to set the initial weights for a neural net. 我听说你可以使用GA设置神经网络的初始权重。 I've always wanted to try that, but I still haven't gotten around to writing neural nets. 我一直想尝试,但我还没有去写神经网络。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM