Variable number of variables for each polling point for optimization algorithm
1 次查看(过去 30 天)
显示 更早的评论
The number of variables in my input point vector (x0) to the genetic algorithm changes depending on the integer value of one of the elements in x0 (ranging from 1 to n). This value can vary from one population to another. Therefore, each population may have a different size. Since I am using vectorization my x0 matrix must be square (population size x n), and so there may be differing numbers of redundant elements in each population.
Is there a way to tell the genetic algorithm to ignore/account for these redundant elements, so that the algorithm may potentially run more efficiently?
Currently, my objective function sets the redundant elements to zero, which seems to work but is not the most elegant approach.
0 个评论
回答(1 个)
Matt J
2015-9-24
编辑:Matt J
2015-9-24
Your population matrix must have a fixed size, but there's no reason why the redundant elements need to slow down or even participate in the evaluation of the fitness function in any way. Just structure your fitness function like this:
function fvals=myfitness(X0)
n=X0(i); %The last non-redundant index
X0(:,n+1:end)=[]; %delete redundant values
.... %continue deriving fitness values from X0
end
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Genetic Algorithm 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!