bit string ga tool
이전 댓글 표시
I want way to represent the value of variable (X) from (1 to 16) or (1 to 32) by using Bit string type gatool (matlab optimization tool)with out repeating any value of X ?
I used this way x=x(1)+x(2)*2+x(3)*4+x(4)*8+x(5)*16 but the matlab remained running with repeating the value of x for example x=4,x=7,x=1,x=1,x=5,x=7,x=13,....etc. with out stopping
댓글 수: 3
Walter Roberson
2012년 12월 29일
How does this differ from your previous question http://www.mathworks.co.uk/matlabcentral/answers/57616-genetic-algorithm-tool-bit-string ?
mohammed sportman
2012년 12월 29일
Walter Roberson
2012년 12월 30일
I still do not understand how it is different. It looks to me to be just the same as the part at the end of your previous question where you remarked about it running endlessly.
답변 (1개)
Walter Roberson
2012년 12월 30일
0 개 추천
If you want each value to be used exactly once, you should be using a "for" loop or a vectorized computation, not ga(). ga() does adaptive fitting on the value of each variable. If the random computations are leading towards the tendency that x(3) is (say) 0, then x(3) = 0 will be favored in the computations over x(3) = 1. ga() will not systematically try all the possibilities.
Is there a reason why you are not using IntCon and bounds of [1 16] or [1 32] ?
댓글 수: 25
mohammed sportman
2012년 12월 30일
Walter Roberson
2012년 12월 30일
It does not sound to me as if you have tried using intCon
mohammed sportman
2013년 1월 1일
편집: mohammed sportman
2013년 1월 1일
Walter Roberson
2013년 1월 1일
Please reformat your comment.
mohammed sportman
2013년 1월 1일
Walter Roberson
2013년 1월 2일
nvars = 1;
[x,fval,exitflag] = ga(@myfitness3, nvars, [], [], [], [], 1, 16, nonlcon, 1, options);
function g = myfitness3(x)
LAMBDA = X;
TYPE = 1;
ITER = 1000;
R1 = Routing3a(TYPE, LAMBDA, ITER);
g = -R1;
end
mohammed sportman
2013년 1월 2일
편집: mohammed sportman
2013년 1월 2일
Walter Roberson
2013년 1월 2일
편집: Walter Roberson
2013년 1월 2일
function answers56718
nvars = 1;
[x,fval,exitflag] = ga(@myfitness3, nvars, [], [], [], [], 1, 16, [], 1, []);
end
function g = myfitness3(x)
LAMBDA = X;
TYPE = 1;
ITER = 1000;
R1 = Routing3a(TYPE, LAMBDA, ITER);
g = -R1;
end
mohammed sportman
2013년 1월 3일
Walter Roberson
2013년 1월 3일
Which routine does it complain about?
It would not hurt to get rid of the final [] making it
[x,fval,exitflag] = ga(@myfitness3, nvars, [], [], [], [], 1, 16, [], 1);
mohammed sportman
2013년 1월 3일
Walter Roberson
2013년 1월 3일
Which MATLAB version are you using? It appears yours might not be recent enough to support integer constraints.
Walter Roberson
2013년 1월 3일
Try this:
function answers56718
nvars = 1;
[x,fval,exitflag] = ga(@myfitness3, nvars, [], [], [], [], 0.5, 16.5);
end
function g = myfitness3(X)
LAMBDA = round(X);
TYPE = 1;
ITER = 1000;
R1 = Routing3a(TYPE, LAMBDA, ITER);
g = -R1;
end
mohammed sportman
2013년 1월 3일
mohammed sportman
2013년 1월 3일
mohammed sportman
2013년 1월 3일
mohammed sportman
2013년 1월 3일
편집: mohammed sportman
2013년 1월 3일
Walter Roberson
2013년 1월 3일
Yes, that is a normal termination. Remember that ga does not know how many minima there are, so it is going to keep searching hoping to find a combination that provides a better result. Eventually the search will get to the point where searching everywhere "near" the minimum value that it found is not going to find any change in value. ga is not going to know that that means that value is the minima, it is just going to know that the changes it can detect are very very small. Eventually it will run out of steam and when it does, that is the message it would give. It is completely normal for ga.
mohammed sportman
2013년 1월 4일
mohammed sportman
2013년 1월 4일
mohammed sportman
2013년 1월 4일
Walter Roberson
2013년 1월 4일
The way to find the solution in minimal time is not to use ga() .
mohammed sportman
2013년 1월 4일
Walter Roberson
2013년 1월 4일
Then you report back to your supervisor that Yes, you can use ga, but that it is very very time consuming and that the results it produces are not better and cannot be better than a very short "for" loop, and then ask how they want you to proceed. If they tell you to go ahead with it anyhow, then you deliver the code that takes 40+ hours for something that should be a fraction of a second.
Now I notice that your Routing3a routine has an "ITER" parameter. What is the purpose of that? Is there some randomization going on in Routing3a? If Routing3a is doing some kind of searching, then it is that searching that you should be automating through ga.
mohammed sportman
2013년 1월 5일
편집: mohammed sportman
2013년 1월 5일
카테고리
도움말 센터 및 File Exchange에서 Genetic Algorithm에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!