0
무작위 정수의 초기 모집단을 개발 한 후에 각 개체의 개체를 적합도 함수에 연결하고 인수를 적합도 함수에 연결하는 문제에 직면하고 있습니다. 나는 다음과 같은 작성 및 피트니스 기능을 가지고,하지만 난 GA 작업 영역에서 오류 다음주고있다 실행할 때 "초기 사용자가 제공하는 피트니스 기능 평가에 실패 GA를 계속할 수 없습니다."정수 순열 GA 체력 함수
function pop = facilities_arrangement(NVARS,FitnessFcn,options)
%Creates a population of facility arrangement permutations.
totalPopulationSize = 50;
n = NVARS;
pop = cell(totalPopulationSize,1);
for i = 1:totalPopulationSize
pop{i} = randperm(n);
end
function scores = facility_layout_fitness(CR,distances)
% Custom fitness function for the facility layout problem.
% Calculates the fitness of an individual. The fitness is the total product
% between the closeness rating of the facilities and the distances
% travelled from one facility to another from their centroids
% by using the rectilinear distance.
pop = cell(totalPopulationSize,1);
scores = zeros(size(pop,1),1);
totalPopulationSize = 50;
for i = 1:totalPopulationSize
order = pop{i};
A = CR(order,order);
TCF = sum(A(:).*distances(:));
scores(i) = TCF;
end