How to set the variables as integers in a Genetic Algorithm Function?

Hi,
Supposing the objective function is @(x)f(x(1),x(2)). I would like to set the variable 'x' as a integer in a Genetic Algorithm Function.
How should I do? Is there anyone knowing it?
Thanks, Zheng

 採用された回答

Walter Roberson
Walter Roberson 2012 年 7 月 7 日
編集済み: Walter Roberson 2015 年 2 月 27 日

2 投票

Note that there are a number of restrictions on ga()'s operation when you constrain to integer.

9 件のコメント

Zheng
Zheng 2012 年 7 月 7 日
Thanks, Walter.
But after I set IntCon as [1 2] and run the function, I've got this message. "Tenth input argument must be a valid structure created with GAOPTIMSET."
The function I wrote was "nvars=2; IntCon=[1 2]; [x,fval]=ga(Obj,nvars,[],[],[],[],LB,UB,[],IntCon);"
Walter Roberson
Walter Roberson 2012 年 7 月 8 日
Which MATLAB version are you using?
Zheng
Zheng 2012 年 7 月 8 日
R2010b
Walter Roberson
Walter Roberson 2012 年 7 月 8 日
It appears it was introduced in R2011b
Zheng
Zheng 2012 年 7 月 8 日
Thanks, Walter.
Walter Roberson
Walter Roberson 2012 年 7 月 8 日
Do not keep re-asking the same Question -- especially without providing the crucial information that you need to do the work in a release before IntCon was introduced!
If you wanted to ask how you could proceed in R2010b anyhow, then just ask that. The answer would be:
Zheng
Zheng 2012 年 7 月 8 日
This example really helps. Cheers
Pratik Anandpara
Pratik Anandpara 2017 年 3 月 22 日
how to set it in ga boundry value only in integer lb=[100 1] ub=[500 50]
i want upper and lower boundry value only in integer not in decimal point
Walter Roberson
Walter Roberson 2017 年 3 月 22 日
Is the general form
x = ga(fitnessfcn,nvars,A,b,[],[],LB,UB,nonlcon,IntCon)
not what you need?

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by