How to set the variables as integers in a Genetic Algorithm Function?
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Show older comments
0 votes
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
Accepted Answer
Walter Roberson
on 7 Jul 2012
Edited: Walter Roberson
on 27 Feb 2015
2 votes
Note that there are a number of restrictions on ga()'s operation when you constrain to integer.
9 Comments
Zheng
on 7 Jul 2012
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
on 8 Jul 2012
Which MATLAB version are you using?
Zheng
on 8 Jul 2012
R2010b
Walter Roberson
on 8 Jul 2012
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
Zheng
on 8 Jul 2012
Thanks, Walter.
Walter Roberson
on 8 Jul 2012
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
on 8 Jul 2012
This example really helps. Cheers
Pratik Anandpara
on 22 Mar 2017
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
on 22 Mar 2017
Is the general form
x = ga(fitnessfcn,nvars,A,b,[],[],LB,UB,nonlcon,IntCon)
not what you need?
More Answers (0)
Categories
Find more on Genetic Algorithm in Help Center and File Exchange
Tags
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)