Genetic Algorithm in Matlab tool box

조회 수: 1 (최근 30일)
Suresh Nayak Bhukya
Suresh Nayak Bhukya 2019년 9월 23일
댓글: Athul Prakash 2019년 10월 3일
How to specify string length in Binary coded Genetic algorithm in Matlab toolbox?\
eg:Say String length as 16 bits for variable.

답변 (1개)

Athul Prakash
Athul Prakash 2019년 9월 26일
Hi Suresh,
Please check the documentation for ga() carefully:
Looks like you will need to specify that in 'nvars' argument (2nd position) in your call to ga()
To illustrate
Optimizing ps_example built-in function, I did the following:
op = optimoptions('ga', 'PopulationType', 'bitstring'); %set up the options to use PopulationType=bitstring
x = ga(@ps_example, 8, [], [], [], [], [], [], [], op); %to use 8 bits only.
So, ga runs by calling ps_example with eight 1/0 values. But this doesn't work out since ps_example is not a function defined on 1's and 0's alone.
Make sure that your optimizing function correctly accepts only 1's and 0's. Additionally, function should be able to run with your given number of inputs, 16 as you say.
Hope it helps you!
  댓글 수: 2
Suresh Nayak Bhukya
Suresh Nayak Bhukya 2019년 9월 30일
Sir,
I am not able understand the above code. So please tell me in detail way.
Bounds for both variables are 0 to 10 and bit string length is 16.fbo.PNG
Athul Prakash
Athul Prakash 2019년 10월 3일
ga() will optimize your function without using bit strings, by default. It performs mutation/crossover on x1 & x2 directly if you call
ga(@fun, 2) %fun being your obj. function coded in matlab
If you must use bitstrings, you can write the function 'fun' in such a way that it accepts 32 inputs (16 for each of x1, x2). Also, you will have to code your function to convert the bit string to your inputs x1/x2.
Good Luck!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Genetic Algorithm에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by