help for roulette-wheel selection matlab code for minimization problem?
이전 댓글 표시
Hello,
I am trying to implement genetic algorithm.(Already able to generate initial population (matlab code attached))
can any one please help to write roulette-wheel selection matlab code for minimization problem --
Just to explain, Suppose my input to matlab program is online2([9 1 3; 8 2 4], 5)
fitness function= Min. C(1,1)*X(1,1)+C(1,2)*X(1,2)+C(1,3)*X(1,3)+C(1,4)*X(1,4)+C(1,5)*X(1,5)+
C(2,1)*X(2,1)+..............+C(2,5)*X(2,5)+C(3,1)*X(3,1)+........C(3,5)*X(3,5)+C(4,1)*X(4,1)+
.....+C(4,5)*X(4,5)+
C(5,1)*X(5,1)+.....+C(5,5)*X(5,5)
input matrix for C(i,j)= [1 2 3 4 5;2 3 4 5 6; 1 2 3 4 5; 3 4 6 7 8; 9 6 5 3 2]
Matrix X = output from run u (:,1:5)+output from run u (:,6:10)..... note r=5 is given as input within program
X wiil be 5*5 matrix .
댓글 수: 7
Geoff Hayes
2014년 8월 26일
Reshdev - do you have the Global Optimization Toolbox? If you do, you can use the genetic algorithm functionality from that rather than re-creating the selection, crossover, and mutation operations.
As for your attached file, you indicate that it will generate an initial population. I think that you need some way to output all those members (of the population) from that file so that you can evaluate each separately using your fitness function. Which should be developed next, before moving to the roulette wheel selection which is dependent upon the fitness function to score each member of the population.
reshdev
2014년 8월 26일
Geoff Hayes
2014년 8월 26일
Reshdev - what does each member of your population represent? How many variables in your optimization problem are you trying to minimize? What is your fitness function? I know that you have described the latter in your question, but it is difficult to understand the pseudo-code.
I think that you should concentrate on getting the fitness function defined next. Use this as the function signature
function [score] = fitnessFunc(inputVar)
where inputVar is a vector (?) of input variables, and score is a scalar output that indicates the fitness of the input data. Since we are minimizing (is this correct?) then the smaller the score, the more fit the member (of the population) that has these input variables.
Once you have defined the fitness function, and a way to manage your population (i.e. will you use a cell array to hold each member of the population?) then you can move on to the selection operator.
But, you didn't answer my initial question. Do you have the Global Optimization Toolbox?
Geoff Hayes
2014년 8월 26일
How do you measure the fitness of a single member of the population? What problem are you trying to minimize?
If each member of the population is a 5x10 matrix, then how do you apply a function to this to say whether this is a "better" 5x10 matrix over another member of the population?
reshdev
2014년 8월 26일
Geoff Hayes
2014년 8월 26일
reshdev - you will need to separate your fitness function from the population initialization. Something like
function [score] = myFitnessFunction(inputData)
X = inputData(:,1:5)+inputData(:,6:10);
C= [1 2 3 4 5;2 3 4 5 6; 1 2 3 4 5; 3 4 6 7 8; 9 6 5 3 2];
r = size(X,1);
Ff = zeros(r,r);
for row=1:r
for col =1:r
Ff(row,col)= C(row,col)*X(row,col);
end
end
%disp(Ff)
score= sum(sum(Ff));
%disp(Fitness)
end
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!