2014-04-15 2 views
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 

답변

0

당신은 호출 할 수 있습니다 초기 인구를주지 않고 GA 기능.

그러나 사용하려는 경우 (그리고 나는 좋은 생각입니다) 초기 인구가 문제 제한 조건을 충족시키고 시작하기에 충분한 솔루션이라고 확신해야합니다. 임의적 인 인구를 생성하는 것과 같은 방식으로 아무 일도하지 않습니다.

당신은 호출 할 수

x = ga(fitnessfcn,nvars) 

를이 시설 위치 문제가 있다면, 그것은 보인다, 당신은 당신의 유전자 알고리즘을 공급하는 것이 가능한 솔루션을 생성하려고 욕심 알고리즘의 어떤 종류를 사용해야합니다.