- The best option is to create an initial population by writing your own creation function without duplicate points.
- The second option is to cache/store the population. You can implement a simple strategy to create a cache inside the fitness function which can store the population evaluated in the past few generations. The size of the cache can be decided upfront so that it remains the same during the iterations. Using vectorized option will send all the population at once to the fitness function and that will be helpful.
How can a phrase the constraint for Genetic Algorithms to generate data without duplicates?
1 次查看(过去 30 天)
显示 更早的评论
Dear Matlab community,
I am trying use interpolation within the function body to evaluated by the genetic algorithm.
The genetic algorithm shall generate data of 60 variables within lower and upper bounds to be taken as x- and y-values and is therefore reshaped as follows:
datap=reshape(datap,30,2);
The first column is taken as x-values and the second column as y-values for interpolation. The x-values therefore need to be unique and in increasing order. I just cannot figure out how I can phrase the constraint for the x-values to be unique before Matlab generates them. Hope someone can help!
That's the beginning of the function:
function y=cube2shape_3(datap)
% bounds
% ub=[0,linspace(3,3,28),1,linspace(3,3,29),0]
% lb=[linspace(0,0,29),1,linspace(1,1,20),linspace(0,0,10)]
datap=reshape(datap,30,2);
sort(datap(:,1))
%fit graph to data points
ffit=fitit(datap(:,1),datap(:,2));
0 个评论
采纳的回答
Vidya Viswanathan
2016-3-30
Hi,
As far as I understand, there is no direct option to remove duplication of data points in Genetic Algorithm. However, as a workaround, you could consider one of the two approaches listed below:
If this does not address your query, you could consider contacting MathWorks Technical Support corresponding to the region you belong to using the following link:
Regards,
Vidya
更多回答(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!