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
采纳的回答
Note that there are a number of restrictions on ga()'s operation when you constrain to integer.
9 个评论
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);"
Which MATLAB version are you using?
It appears R2010b did not support IntCon http://www.mathworks.com/help/releases/R2010b/toolbox/gads/ga.html
It appears it was introduced in R2011b
Thanks, Walter.
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:
This example really helps. Cheers
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
Is the general form
x = ga(fitnessfcn,nvars,A,b,[],[],LB,UB,nonlcon,IntCon)
not what you need?
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Genetic Algorithm 的更多信息
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 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)
