遗传算法matlab最小化

时间:2015-11-11 12:33:32

标签: algorithm matlab optimization genetic-algorithm

我想使用Matlab的Optimization-ToolBox为遗传算法提供工具。我有一个小方程(得分= alpha *(\ sum(L [i])^(1 / alpha)+ Beta *(\ sum(R [i])^(1 / Beta))计算得分{ {1}}和L是我之前计算过的值的向量,Ralpha是我想通过GA优化的参数。约束条件是得分应该接近另一个称为beta的分数向量。 我们可以通过以下方式形式化这个约束:“|| score - ground_truth_score || _2 ^ {2} = 0”

因此,对于每个ground truth\sum(L[i])\sum(R[i])Alpha都会优化之前定义的约束。

我试图在Matlab中发现GA,但是,我不知道如何使用适应度函数(等式)来形式化约束。

1 个答案:

答案 0 :(得分:0)

在阅读这个例子后,我认为这与我的http://fr.mathworks.com/help/gads/examples/coding-and-minimizing-a-fitness-function-using-the-genetic-algorithm.html?prodcode=GD&language=fr

类似

我做了这个目标函数来管理我的问题的最小化,但是我不确定它是否是正确的答案:

function y=parametrized_fitness_fct(x,ground_truth_score)

 y=x(1)*(L^(1/x(1))) + x(2)*(R^(1/x(2))) + ground_truth_score;
      % ground_truth_score, L and R are single values
end
FitnessFunction =@(x) parametrized_fitness_fct(x,ground_truth_score);
[x,score] = ga(FitnessFunction,numberOfVariables)%numberOfVariables=2
%x will be a vector containing the searched values "alpha and beta",    
%and score is the score optimized to be close to the ground_truth_score
相关问题