現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
bit string ga tool
1 回表示 (過去 30 日間)
古いコメントを表示
mohammed sportman
2012 年 12 月 29 日
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 ?
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 日
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 日
I have a Master project and needed compared to my work in the first two using MATLAB directives have been used(for loop) and the second must be using a genetic algorithm . when i using Double type (integer) the ga tool using single number(0.00 ... point)i do not need that. i want just real number so i used Bit string
mohammed sportman
2013 年 1 月 1 日
編集済み: mohammed sportman
2013 年 1 月 1 日
i tried to use intCon [x,fval,exitflag] = ga(fitnessfcn,nvars,A,b,[],[],...lb,ub,nonlcon,IntCon,options) but my program have one variable X with out A or b or lb .... when i remove them(A or b ...etc) i get an error message . i want to put my program in this equation intCon. can you help me to how i can do that ????
code
function g = myfitness2(X)
LAMDA=X(1)+X(2)*2+X(3)*4+X(4)*8+X(5)*16
TYPE=1;
ITER=1000;
R1=Routing3a(TYPE,LAMDA,ITER);
g=-R1
end
-----------
i just want to put the value of LAMDA or(X) as intCon and the value of it between [1 to 16] or [1 to 32]
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 日
When i use the code Who sent to me i get an error like that
Function definitions are not permitted in this context.
and when i using it at command line
nvars = 1;
[x,fval,exitflag] = ga(@myfitness3, nvars, [], [], [], [], 1, 16, nonlcon, 1, options);
i get this error Undefined function or variable 'nonlcon' then i define nonlcon=1
another error appear
Undefined function or variable 'options'*.
when i correct it this error appear
Too many input arguments.
where is the error?????
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
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 日
what you mean please ? i can not understand .
I get this error
Error using ==> ga at 250 Tenth input argument must be a valid structure created with GAOPTIMSET.
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 日
it is about 40 minutes and matalb program still running with out any result
busy
mohammed sportman
2013 年 1 月 3 日
編集済み: mohammed sportman
2013 年 1 月 3 日
after 4 hours i get this message
Optimization terminated: average change in the fitness value less than options.TolFun
with out round(x) i use this function
[x,fval,exitflag] = ga(@myfitness33, nvars, [], [], [], [], 1, 16);
function g = myfitness33(X)
LAMDA = X;
TYPE = 1;
ITER = 1000;
R1 = Routing3a(TYPE, LAMDA, ITER);
g = -R1;
end
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 日
I understand what you mean.But how do I find the solution to the problem I told you in the beginning using the method I find the right solution, but after a long period and the second method find solutions quickly, but it will not stop and, of course, repeat (all using Ga)
mohammed sportman
2013 年 1 月 4 日
first one
function g =myfitness2(X)
X
s=0;
if (X(1)==1)
s=s+1;
end
if (X(2)==1)
s=s+2;
end
if (X(3)==1)
s=s+4;
end
if (X(4)==1)
s=s+8;
end
LAMDA=s;
TYPE=1;
ITER=1000;
R1=Routing3a(TYPE,LAMDA,ITER);
g=-R1;
end
mohammed sportman
2013 年 1 月 4 日
second way
function g =myfitness2(X)
LAMDA=X(1)+X(2)*2+X(3)*4+X(4)*8+X(5)*16
TYPE=1;
ITER=1000;
R1=Routing3a(TYPE,LAMDA,ITER);
g=-R1
end
mohammed sportman
2013 年 1 月 4 日
if i want to use the genetic algorithm in my project what i say (the ga don't support my project)
my super visor asked me to use the ga.
that is problem for me.
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 日
Thank you Walter Roberson for your valuable with me constantly.Draft works at the expense of the number of requests accepted and rejected for optical networks.The possibility of increasing the number of services using optical fiber.Where lambda is the channel inside the optical fiber and increase the number of it means to increase the number of requests accepted. I have a major program calls paths function to find all shortest paths.We have completed the programming using MATLAB directives. Supervisors asked me to improve it using genetic function because the main business of GA in any function is optimization . And my time to complete the project narrow somewhat (few) so I tried to use tools function genetic to improvement project as a whole and by comparing running and find lamda appropriate to create a state saturation 100% where all requests are accepted (no rejection) in terms of time, but I was surprised where that time the situation normal less much of the use of genetic function. There is a part of my project is to find all paths if there was a ready function used in the genetic algorithm please help me out. And if you can help me in any part of the project, please tell me so and I will send detail required.... with my respect and appreciation
Routing3a it the main function in project.
ITER number of iteration .The more increase the accuracy of the results, but does not have many teams for my project
参考
カテゴリ
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!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
アジア太平洋地域
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)