问题标签 [mutation]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
algorithm - 遗传算法的自适应变异/交叉率
我一直在寻找可以为我正在研究的遗传算法实现自适应突变率的方法。我见过一种算法,它使用当前个体适应度和平均群体适应度来计算突变率,但我不确定它是否非常有效。
在算法中,我看到您执行以下操作:
这是一个好方法还是有更好的方法?
java - Improvements for an evolutionary algorithm with ANNs solving XOR
I'm supposed to implement an artificial neural network (ANN) with 2 input, 2 hidden and 1 output neuron that can solve the XOR problem. The weights of the network should be optimized using an evolutionary algorithm. The activation function for each neuron and the fitness function for each ANN are given. The following picture sums up the problem and introduces the variable names I used:
Now I tried my very best to solve the problem, but even with an evolutionary algorithm using a population size of 1000 ANNs and 2000 generations my best fitness is never better than 0.75. My code includes a ANN class with the neurons, activation and fitness function and a Main class that includes the evolutionary algorithm and that optimizes the weights for the ANNs. Here is the code:
Each ANN is initialized with random weights between -1 and 1 and able to mutate, i.e. return a mutation that differs in one weight wich is chosen randomly.
The Main class has the evolutionary algorithm and uses elitism and rank-based selection to create the next generation of each population, i.e. the 100 best ANNs are copied the remaining 900 are mutations of previously successful ANNs.
Even though, I put quite some thought into this and used techniques that I learned, the result is not satisfying. For some reason the optimal weights seem to drift to -1 for each weight. How does that make sense? Is the range of -1 to 1 for the weights a good choice? Should I also introduce crossovers in addition to the mutations? I know this is a very specific problem, but I would greatly appreciate some help!
algorithm - 遗传算法中的变异步长
有人可以向我解释什么是“突变步长”吗?我正在阅读一篇关于遗传算法的文章,它说:
“突变随机改变节点的决策或以 0.25 的步长改变值”
我知道突变在 GA 生命周期中的作用,但我找不到一个很好的解释来解释突变的步长。
谢谢。
evolutionary-algorithm - 进化计算中的示例任务帮助
我有一个来自进化计算课程的先前考试(2006 年)的一个示例问题。我真的不知道如何解决这个问题,所以任何想法、提示和技巧将不胜感激。
幻方是一个 N x N 的正方形,其中从 1 到 N × N 的所有整数都恰好出现一次。整数需要以这样一种方式放置,即每行、每列和两条平均对角线之和返回相同的值 S = [N (N^2 + 1)] / 2。我们想搜索具有进化算法的整数的位置。
问题是:
指定你能想到的最合适的适应度函数、表示、变异 算子和交叉算子。
我知道适应度函数、变异算子和交叉算子是什么,但我不知道它们的表示是什么意思。另外,它们如何适用于这类问题?
请不要将其视为某种“垃圾”问题,我要求“家庭作业帮助”,因为事实并非如此。我只是想从其他人的经验和知识中学习一些东西。
提前致谢。
haskell - ST 使用 RankNTypes 使其界面纯净
据我了解,Haskell 的 ST monad 是独一无二的,因为它允许我描述一个本地使用可变内存的计算,但仍然呈现一个纯接口。也就是说,只要该突变不会逃脱计算,它就允许我对内存进行突变。最简单的例子是这样的:
这会导致编译时错误(太酷了!):
我的理解是,如果允许可变引用逃避计算,它可能会在其他地方发生突变,并且我的 ST 计算可能不再具有纯接口(它可能在不同的调用上返回不同的值)。
我的问题是:这是如何实现的?我看到 runST 和 newSTRef 的定义大量使用了 RankNTypes,但我无法理解这些类型是如何产生上述编译错误的。
matlab - Matlab中遗传算法的变异阶段
我正在使用 Matlab 中的遗传算法优化图像重建算法。我在两个种群上进行了交叉并生成了两个后代,而没有在 matlab 中使用“ga”工具包。所以目前我有两个 1*n 矩阵,其整数值范围为 0-255(它们是按行主要顺序排列的两个图像)。例如
我做了单点排序交叉并得到了后代
接下来我需要以0.02的概率进行突变。我在这里使用了'gaoptimset'并编码如下。
我打印了结果。它给出了一个没有任何值的结构。
谁能帮我对交叉的孩子(Off_1和Off_2)进行突变?提前致谢。
javascript - 观察一个 DOM 属性
我正在尝试监视第三方网站上的 DOM 元素。在倒数计时器到达之前,该元素是不存在的,然后它被创建。
我已经取得了一些成功: document.getElementsByClassName('countdown ng-hide').length
当它从 0 变为 1 时,我想实现一个功能。
我该怎么做?我尝试过使用 Mutation Observer,但它不会让我观察到空节点。
谢谢!
编辑:这是我到目前为止所得到的。
genetic-algorithm - 为什么突变概率是三分之一?
在 jenetics 库中,Mutator 类的 alter() 方法中给出了以下代码:
最终双 p = pow(_probability, 1.0/3.0);
谁能解释计算这个新的突变概率的目的?它有什么好处?我们如何使用这个类来实现 One-Position 或 Point Mutation?
r - 如何在R中实现遗传算法的变异功能?
我正在实现 GA 算法。染色体具有-1,0,1值的组合。在突变部分,我想用prob(-1 to 1)将 -1 更改为 1 并用prob(1 to -1)将 1 更改为 -1 。我不知道 R 中是否有任何功能可以让我轻松。有人会告诉我是否有一种功能可以帮助我根据概率替换值吗?